Laravel Mock Accessors

Sometimes you’re trying to unit test some methods that have dependencies on other accessors. Here’s how to make sure that only some accessors are mocked while others are accessible as normal. $mock = \Mockery::mock(Model::class)->makePartial(); $mock->shouldReceive(‘setAttribute’)->passthru(); $mock->shouldReceive(‘getAccessorAttribute’)->andReturnTrue(); Advertisements Continue reading Laravel Mock Accessors