Пробую на шаблоне yii2-app-basic.
Делаю все по мануалу https://github.com/yiisoft/yii2/blob/ma ... ixtures.md:
Создаю файл StyleFixture.php, по пути tests/codeception/fixturies
Код: Выделить всё
<?php
namespace app\tests\fixtures;
use yii\test\ActiveFixture;
class StyleFixture extends ActiveFixture
{
public $modelClass = 'app\models\Style';
}
Код: Выделить всё
<?php
return [
'style1' => [
'name' => 'yeti',
'title' => 'yeti-txt',
],
'style2' => [
'name' => 'united',
'title' => 'unity style',
],
];
Код: Выделить всё
<?php
namespace tests\codeception\unit\models;
use yii\codeception\DbTestCase;
use app\tests\fixtures\StyleFixture;
class StyleTest extends DbTestCase
{
public function fixtures()
{
return [
'styles' => StyleFixture::className(),
];
}
// ...test methods...
}
Код: Выделить всё
codecept run unit
Codeception PHP Testing Framework v2.0.12
Powered by PHPUnit 4.5.1 by Sebastian Bergmann and contributors.
Unit Tests (4) --------------------------------------------------------------------------------------------------
Test contact (tests\codeception\unit\models\ContactFormTest::testContact) Ok
Test login no user (tests\codeception\unit\models\LoginFormTest::testLoginNoUser) Ok
Test login wrong password (tests\codeception\unit\models\LoginFormTest::testLoginWrongPassword) Ok
<pre>PHP Fatal Error 'yii\base\ErrorException' with message 'Class 'app\tests\fixtures\StyleFixture' not found'
in W:\domains\page\tests\codeception\unit\models\StyleTest.php:14
Stack trace:
#0 [internal function]: yii\base\ErrorHandler->handleFatalError()
#1 {main}</pre>
Код: Выделить всё
use app\tests\fixtures\StyleFixture