Does unit test work with scenarious?
I keep on getting error:
Test tests/unit/models/ModeNameTest.php:testSuccess
[yii\base\ErrorException] Trying to get property of non-object
This is the code for testSuccess method in ModeNameTest model:
public function testSuccess()
{
$model = new UserNamesTestModel(['scenario' => UserNamesTestModel::SCENARIO_CLIENT]);
$model->user_id = 1;
$model->name = 'Test Name';
expect_that($model->save());
}
Error it happening on this line:
expect_that($model->save());
UserNamesTestModel extends ActiveRecord, thefore such method as save(), update() should be there and I have no idea why it is throwing such Exception…
Did anybody cross this problem before?
P.s. it is not related to rules validation, because $model->errors return empty array.