I have been trying to get going with Patchwork, in order to help me write unit tests to a legacy PHP codebase. Unfortunately, I have run into an error which I can't resolve.
Whenever I try to call an overridden method, I get the following error: "Only variables should be passed by reference"
I have a very simple test case that demonstrates this:
<?php
require_once('../build/patchwork/Patchwork.php');
require_once('../build/clsOverrideMe.php');
class patchworkTest extends PHPUnit_Framework_TestCase {
public function testOverrideMe() {
Patchwork\replace("clsOverrideMe::sayBar", function() { return "overridden"; });
$result = clsOverrideMe::sayBar(); //standard $result='bar', but with Patchwork, $result='overridden'.
}
}
...and clsOverrideMe.php:
<?php
class clsOverrideMe {
public static function sayBar() {
return "bar";
}
}
Then at the command prompt, I get the following:
C:\DEVELOPMENT\_tests>phpunit patchworkTest.php
PHPUnit 3.5.14 by Sebastian Bergmann.
E
Time: 0 seconds, Memory: 6.75Mb
There was 1 error:
1) patchworkTest::testClsOverrideMe
Only variables should be passed by reference
C:\DEVELOPMENT\build\patchwork\lib\Stack.php:39
C:\DEVELOPMENT\build\patchwork\lib\Interceptor.php:68
C:\DEVELOPMENT\build\patchwork\lib\Interceptor.php:87
C:\DEVELOPMENT\build\patchwork\lib\Stack.php:27
C:\DEVELOPMENT\build\patchwork\lib\Interceptor.php:93
C:\DEVELOPMENT\build\clsOverrideMe.php:3
C:\DEVELOPMENT\_tests\patchworkTest.php:8
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
Any idea what I'm doing wrong here? Or have I found a bug in Patchwork?
The above is the simplest possible example I could come up with in the context of PHPUnit (ie how I want to use it). It also throws the same error when written as a simple PHP program.
PHP version 5.3.8 on Windows7.
The text was updated successfully, but these errors were encountered:
It does indeed overlap -- it's the same issue: I posted this ticket first, and then decided to try fixing it myself; the second ticket was generated by Github when I posted the fix. :-)
I have been trying to get going with Patchwork, in order to help me write unit tests to a legacy PHP codebase. Unfortunately, I have run into an error which I can't resolve.
Whenever I try to call an overridden method, I get the following error: "Only variables should be passed by reference"
I have a very simple test case that demonstrates this:
...and clsOverrideMe.php:
Then at the command prompt, I get the following:
Any idea what I'm doing wrong here? Or have I found a bug in Patchwork?
The above is the simplest possible example I could come up with in the context of PHPUnit (ie how I want to use it). It also throws the same error when written as a simple PHP program.
PHP version 5.3.8 on Windows7.
The text was updated successfully, but these errors were encountered: