diff --git a/2.x/as-fake.md b/2.x/as-fake.md index 47262c2..2eb7d9e 100644 --- a/2.x/as-fake.md +++ b/2.x/as-fake.md @@ -60,6 +60,18 @@ FetchContactsFromGoogle::shouldNotRun(); FetchContactsFromGoogle::mock()->shouldNotReceive('handle'); ``` +### `shouldExpect` +Helper method adding an expectation on the `handle` method. + +```php +FetchContactsFromGoogle::shouldExpect(); + +// Equivalent to: +FetchContactsFromGoogle::shouldRun()->once(); +// And: +FetchContactsFromGoogle::mock()->expects('handle'); +``` + ### `allowToRun` Helper method allowing the `handle` method on a spy. diff --git a/2.x/mock-and-test.md b/2.x/mock-and-test.md index d68945b..8117fd4 100644 --- a/2.x/mock-and-test.md +++ b/2.x/mock-and-test.md @@ -36,6 +36,17 @@ FetchContactsFromGoogle::shouldNotRun(); FetchContactsFromGoogle::mock()->shouldNotReceive('handle'); ``` +The helper method `shouldExpect` is the same as `shouldRun` but adds the expection that `handle` will be called once and only once. + +```php +FetchContactsFromGoogle::shouldExpect(); + +// Equivalent to: +FetchContactsFromGoogle::shouldRun()->once(); +// And: +FetchContactsFromGoogle::mock()->expects('handle'); +``` + ## Partial mocking If you only want to mock the methods that have expectations, you may use the `partialMock` method instead. In the example below, only the `fetch` method will be mocked.