I'm running phpunit with mockery (without DB/fixtures), but I have a trouble with mocking a model.
$customer = Mockery::mock(CustomerModel::class);
echo $customer->id;
Produces error:
BadMethodCallException: Method Mockery_1_models_Customer::hasAttribute() does not exist on this mock object
Then I tried:
$customer->shouldReceive('hasAttribute')->andReturn(true);
But again, I run in to:
Fatal error: Call to a member function getDb() on a non-object in ..\yiisoft\yii2\db\ActiveRecord.php on line 135
Any suggestions?
Aucun commentaire:
Enregistrer un commentaire