PHP code example of silinternational / yii2-codeception

1. Go to this page and download the library: Download silinternational/yii2-codeception library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silinternational / yii2-codeception example snippets



namespace tests\unit\fixtures\common\models;

use Sil\yii\test\ActiveFixture;

class UserFixture extends ActiveFixture
{
    public $modelClass = 'common\models\User';
    public $dataFile = 'tests/unit/fixtures/data/common/models/User.php';
}


namespace tests\unit\common\models;

use Sil\Codeception\TestCase\Test;
use tests\unit\fixtures\common\models\UserFixture;

class UserTest extends Test
{
    public function fixtures()
    {
        return [
            'users' => UserFixture::className(),
        ];
    }
    
    public function testGetUser1()
    {
        $user1 = $this->users('user1');
        $this->assertEquals(1, $user1->id);
    }
}