ProjetsFixture.php 4.8 KB
<?php
namespace App\Test\Fixture;

use Cake\TestSuite\Fixture\TestFixture;

/**
 * ProjetsFixture
 */
class ProjetsFixture extends TestFixture
{
    
    /* 
     * (EP202009)
     * 
     * Pour importer automatiquement la définition de la table projets
     * (https://book.cakephp.org/3/en/development/testing.html#importing-table-information)
     *
     */
    public $import = ['model' => 'Projets'];
    /*
     * Si on n'utilise pas la variable $import ci-dessus,
     * alors il faut définir tous les champs utilisés,
     * comme ci-dessous, avec la variable $fields,
     * GALÈRE !!!
     *
     */
    
    /**
     * Fields
     *
     * @var array
     */
    /*
    // @codingStandardsIgnoreStart
    public $fields = [
        'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null],
        'nom' => ['type' => 'string', 'length' => 45, 'null' => false, 'default' => null, 'collate' => 'latin1_swedish_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
        'description' => ['type' => 'text', 'length' => null, 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'comment' => '', 'precision' => null],
        'groupes_thematique_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null],
        'chef_science_id' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
        'chef_projet_id' => ['type' => 'string', 'length' => 45, 'null' => true, 'default' => null, 'collate' => 'latin1_swedish_ci', 'comment' => '', 'precision' => null, 'fixed' => null],
        'date_start' => ['type' => 'date', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
        'date_stop' => ['type' => 'date', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null],
        '_indexes' => [
            'fk_projets_groupes_thematique_id' => ['type' => 'index', 'columns' => ['groupes_thematique_id'], 'length' => []],
            'fk_projets_chef_science_id' => ['type' => 'index', 'columns' => ['chef_science_id'], 'length' => []],
            'fk_projets_chef_projet_id' => ['type' => 'index', 'columns' => ['chef_projet_id'], 'length' => []],
        ],
        '_constraints' => [
            'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []],
            'nom' => ['type' => 'unique', 'columns' => ['nom'], 'length' => []],
            'fk_projets_groupes_thematique_id' => ['type' => 'foreign', 'columns' => ['groupes_thematique_id'], 'references' => ['groupes_thematiques', 'id'], 'update' => 'restrict', 'delete' => 'setNull', 'length' => []],
            //'fk_projets_chef_projet_id' => ['type' => 'foreign', 'columns' => ['chef_projet_id'], 'references' => ['users', 'username'], 'update' => 'restrict', 'delete' => 'noAction', 'length' => []],
            'fk_projets_chef_projet_id' => ['type' => 'foreign', 'columns' => ['chef_projet_id'], 'references' => ['users', 'id'], 'update' => 'restrict', 'delete' => 'noAction', 'length' => []],
            //'fk_projets_chef_science_id' => ['type' => 'foreign', 'columns' => ['chef_science_id'], 'references' => ['users', 'username'], 'update' => 'restrict', 'delete' => 'noAction', 'length' => []],
            'fk_projets_chef_science_id' => ['type' => 'foreign', 'columns' => ['chef_science_id'], 'references' => ['users', 'id'], 'update' => 'restrict', 'delete' => 'noAction', 'length' => []],
        ],
        '_options' => [
            'engine' => 'InnoDB',
            'collation' => 'latin1_swedish_ci'
        ],
    ];
    // @codingStandardsIgnoreEnd
    */

    
    /**
     * Init method
     *
     * @return void
     */
    public function init()
    {
        $this->records = [
            [
                'id' => 1,
                'nom' => 'Lorem ipsum dolor sit amet',
                'description' => 'Lorem ipsum dolor sit amet, aliquet feugiat. Convallis morbi fringilla gravida, phasellus feugiat dapibus velit nunc, pulvinar eget sollicitudin venenatis cum nullam, vivamus ut a sed, mollitia lectus. Nulla vestibulum massa neque ut et, id hendrerit sit, feugiat in taciti enim proin nibh, tempor dignissim, rhoncus duis vestibulum nunc mattis convallis.',
                'groupes_thematique_id' => 1,
                //'chef_science_id' => 'Lorem ipsum dolor sit amet',
                'chef_science_id' => 1,
                //'chef_projet_id' => 'Lorem ipsum dolor sit amet',
                'chef_projet_id' => 1,
                'date_start' => '2020-09-08',
                'date_stop' => '2020-09-08'
            ],
        ];
        parent::init();
    }
}