Skip to content

Commit

Permalink
Merge pull request #5527 from kennith/add-partial-mock
Browse files Browse the repository at this point in the history
[6.x] Add partialMock shorthand method
  • Loading branch information
taylorotwell authored Oct 14, 2019
2 parents 19c6ff7 + 8c4a8a7 commit 5506055
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions mocking.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ In order to make this more convenient, you may use the `mock` method, which is p
$mock->shouldReceive('process')->once();
});

You may use the `partialMock` method when you only need to mock a few methods of an object. The methods that are not mocked will be executed normally when called:

use App\Service;

$this->partialMock(Service::class, function ($mock) {
$mock->shouldReceive('process')->once();
});

Similarly, if you want to spy on an object, Laravel's base test case class offers a `spy` method as a convenient wrapper around the `Mockery::spy` method:

use App\Service;
Expand Down

0 comments on commit 5506055

Please sign in to comment.