Skip to content

Commit

Permalink
Added warning about indirect method calls (#23)
Browse files Browse the repository at this point in the history
* Added warning about indirect method calls

* typo
  • Loading branch information
Nyholm authored Aug 20, 2021
1 parent 97e0b64 commit a46b9ef
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,23 @@ This trick will not work if you have two different PHP processes, i.e. you are r
your tests with Panther, Selenium etc.

We can also not create a proxy if your service is final.

We only able to mock direct access to a service. Indirect method calls are not mocked.
Example:

```php
class MyService {
public function foo()
{
return $this->bar();
}

public function bar()
{
return 'original';
}
}
```

If we mock `MyService::bar()` to return `"mocked"`. You will still get `"orignal"`
when you call `MyService::foo()`. The workaround is to mock `MyService::foo()` too.

0 comments on commit a46b9ef

Please sign in to comment.