Closed matzeeable closed 4 years ago
Hi, do you happen to have a patchwork.json
in your setup by any chance?
Thanks for your fast response! Yeah, my patchwork.json
looks like this:
{
"redefinable-internals": ["call_user_func", "error_log"]
}
I just figured out if I remove the internals and make the packwork.json
like the below, the test passes:
{
"redefinable-internals": []
}
Do you need anything else to know? Can you reprocedure the problem? What versions of the tools are you using?
I reproduced it with Mockery 1.3.0 and PHPUnit 8.5.0. A fix is now in the master
branch; please try it.
I implemented the fix on my local vendor
folder and the error is gone, thank you!
Unfortunately I can not rely on the dev-master
because I use all the packages together with WP_Mock. When do you release a new version? 🙂
Okay, I just found another strange thing I think you can reprocedure... Just try the following test case:
class Service {
private $foo;
public function __construct($foo) {
$this->foo = $foo;
}
}
trait Foo {
private $service;
public function foo() {
$this->service = new Service($this);
$this->getService();
// Do something here with service ...
return $this->anotherFoo();
}
public function getService() {
return $this->service;
}
public function anotherFoo() {
return 'my value';
}
}
class Bar {
use Foo;
}
and the test case keeps the same. Again here, if I do not load patchwork it work as expected. If I have patchwork active, the following error occurs:
1) MyAwesomeTest::testFoo
call_user_func_array() expects parameter 1 to be a valid callback, cannot access parent:: when no class scope is active
XXX/test/php/MyAwesomeTest.php:21
XXX/vendor/antecedent/patchwork/src/CallRerouting.php:529
XXX/vendor/antecedent/patchwork/src/CallRerouting.php:353
XXX/vendor/antecedent/patchwork/src/CallRerouting.php:538
XXX/vendor/antecedent/patchwork/src/CallRerouting.php:285
XXX/vendor/antecedent/patchwork/src/CallRerouting.php:317
XXX/vendor/antecedent/patchwork/src/Stack.php:27
XXX/vendor/antecedent/patchwork/src/CallRerouting.php:328
XXX/test/php/MyAwesomeTest.php:55
This took considerably longer, but should now be working. Could you confirm that?
I would release a new version shortly thereafter if everything works as intended.
It works as expected! Should I let you know if I find further compatibility issues with patchwork
+ mockery
? 🙂
Great! The fixes are now in version 2.1.12.
Should I let you know if I find further compatibility issues with
patchwork
+mockery
? 🙂
Yes, please do :)
Hi!
I am using PHPUnit 7 and want to unit test a WordPress plugin (I can not go with PHPUnit 8 because WordPress has official an incompatibility, see here). Additionally I use mockery as mock framework instead of PHPUnit's mock builder.
I have the following strange situation, my test file
MyAwesomeTest.php
looks like thisRunning the test gives the following result:
But if I do the following (comment out Patchwork):
I get correct results:
Is there any incompatibility with Mockery + Patchwork?
Versions:
Regards, Matthew 🙂