I am currently writing a test to test a model method.
My model Store
has this method:
public function hourTemplate() {
return $this->belongsTo(HourTemplate::class);
}
I have a test as well with this code in setUp method:
public function setUp() : void
{
parent::setUp();
$this->storeMock = Mockery::mock(StoreModel::class)->makePartial();
app()->instance(StoreModel::class, $this->storeMock);
}
And test method is like this:
public function test_getStoreHoursArray_when_hour_isNull() {
$this->storeMock->shouldReceive('hourTemplate')->andReturn(new HourTemplate());
dump((new StoreModel())->hourTemplate);
}
But the returned value is null.
Aucun commentaire:
Enregistrer un commentaire