Хочу написать юнит тест. Но уперся в то что не могу подключить модель из приложения
yii2basic\tests\codeception\unit\models\BehaviorTest.php
<?php
namespace models;
use Yii;
use app\modules\video\models\Video;
class BehaviorTest extends \Codeception\TestCase\Test {
/**
* @var \UnitTester
*/
protected $tester;
protected function _before()
{
}
protected function _after()
{
}
// tests
public function testMe()
{
$video = new Video();
$video = $video::findAll();
$this->assertEquals(0, count($video->id), 'Review count after save');
}
}
php I:\OpenServer\domains\yii2itmh\vendor\codeception\codeception\codecept run unit Codeception PHP Testing Framework v2.1.7 Powered by PHPUnit 5.2.12 by Sebastian Bergmann and contributors.
Unit Tests (1) ---------------------------------------------------------------------------------------------- Trying to test me (models\BehaviorTest::testMe)... Fatal error: Class 'app\modules\video\models\Video' not found in I:\OpenServer\domains\yii2itmh\tests\codeception\unit\models\BehaviorTest.php on line 26
UPD пробую
<?php
namespace models;
use app\modules\video\models\Video;
class BehaviorTest extends \yii\codeception\DbTestCase {
// tests
public function testMe()
{
$var = new Video();
codecept_debug($var);
$video = $var::findAll();
$this->assertEquals(0, count($video->id), 'Review count after save');
}
}
получаю
Test me (models\BehaviorTest::testMe) Error
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-------------------------------------------------------------------------------------------------------------
Time: 1.14 seconds, Memory: 8.50Mb
There was 1 error:
---------
1) Test me (models\BehaviorTest::testMe)
[yii\base\ErrorException] Missing argument 1 for yii\db\BaseActiveRecord::findAll(), called in I:\OpenServer\domains\yii2itmh\tests\codeception\unit\models\BehaviorTest.php on line 12 and defined
#1 I:\OpenServer\domains\yii2itmh\vendor\yiisoft\yii2\db\BaseActiveRecord.php:109
#2 I:\OpenServer\domains\yii2itmh\tests\codeception\unit\models\BehaviorTest.php:12
#3 models\BehaviorTest->testMe
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
как все таки правильно обратиться?
что получилось
des1roer.blogspot.com/2016/03/yii-2-codeception.html