I’m using auth module for authorizationa, and i want to test it but fixture data doesn’t loading.
If im right Debug::debug(count($this->user)) result have to be 2, but it 0.
I can login and logout so the authorization module work well just the test failed, because the fixture doesnt loaded.
Have anybody some suggestion to my problem?
vendor/bin/codecept run -vvv --debug tests/unit/models
Codeception PHP Testing Framework v1.8.6-dev
Powered by PHPUnit 3.7.36 by Sebastian Bergmann.
Unit Tests (1) ----------------------------------------------------------------------------
Modules: CodeHelper
Trying to test login no user (tests\unit\models\LoginFormTest::testLoginNoUser) FIXTURES: USER
DATA
0
Ok
LoginFormTest.php
namespace tests\unit\models;
use Yii;
use yii\codeception\DbTestCase;
use Codeception\Util\Debug;
//use auth\models\User;
use tests\unit\fixtures\UserFixture;
class LoginFormTest extends DbTestCase
{
use \Codeception\Specify;
public function fixtures()
{
Debug::debug("FIXTURES: USER");
return [
'user' => UserFixture::className(),
];
}
protected function tearDown()
{
Yii::$app->user->logout();
parent::tearDown();
}
public function testLoginNoUser()
{
Debug::debug("DATA");
Debug::debug(count($this->user));
foreach ($this->user as $row){
Debug::debug($row['username']);
}
fixture\users.php
return [
'user1' => [
'username' => 'admin',
'email' => 'admin@admin.com',
'auth_key' => 'C4Fu8bliNkU89vnoU8Cs7C5x6AhczFSM',
'password' => '$2y$13$kkgpvJ8lnjKo8RuoR30ay.RjDf15bMcHIF7Vz1zz/6viYG5xJExU6',
],
'user2' => [
'username' => 'napoleon69',
'email' => 'aileen.barton@heaneyschumm.com',
'auth_key' => 'dZlXsVnIDgIzFgX4EduAqkEPuphhOh9q',
'password' => '$2y$13$kkgpvJ8lnjKo8RuoR30ay.RjDf15bMcHIF7Vz1zz/6viYG5xJExU6',
],
];
UserFixture.php
namespace tests\unit\fixtures;
use yii\test\ActiveFixture;
class UserFixture extends ActiveFixture
{
public $modelClass = 'auth\models\User';
}