partialMock(LogoService::class, function (MockInterface $mock) { $mock->shouldAllowMockingProtectedMethods(); $mock->shouldReceive('getLogo', 'copyToIcons') ->once() ->andReturn('service.svg', true); }); $icon = $logoServiceMock->getIcon('service'); $this->assertNotNull($icon); } /** * @test */ public function test_getIcon_returns_null_when_no_logo_exists() { $logoServiceMock = $this->partialMock(LogoService::class, function (MockInterface $mock) { $mock->shouldAllowMockingProtectedMethods() ->shouldReceive('getLogo') ->once() ->andReturn(null); }); $icon = $logoServiceMock->getIcon('no_logo_should_exists_with_this_name'); $this->assertEquals(null, $icon); } }