From a46b9efafe6fbdcf293139572597447ca4599145 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Fri, 20 Aug 2021 15:31:05 -0700 Subject: [PATCH] Added warning about indirect method calls (#23) * Added warning about indirect method calls * typo --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 1441dad..f066b12 100644 --- a/README.md +++ b/README.md @@ -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.