phpunit - Models unit testing on Yii2 -
i'm trying build yii2 app through unit testing , have questions it.
class userstest extends \codeception\testcase\test { /** * @var \unittester */ protected $users; protected function _before() { $this->users = new \app\models\users; } protected function _after() { } // tests public function testgeid() { } }
when try run test class have fatal error message users class not found. cause of problem , how solve it?
there readme file in yii2 tests folder tell setup yii2-faker , yii2_basic_tests
database. these 2 things , why should use them?
thank you.
it need create application instance in tests/_bootstrap.php. must following code in file:
require('/../vendor/autoload.php'); require('/../vendor/yiisoft/yii2/yii.php'); $config = require('config/web.php'); (new yii\web\application($config));
Comments
Post a Comment