Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 024c6c1

Browse files
committed
Workaround for mockery/mockery#268
1 parent 955c2bb commit 024c6c1

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

‎tests/PHPMockeryTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use phpmock\AbstractMockTest;
66
use Mockery;
7+
use Mockery\MockInterface;
78

89
/**
910
* Tests PHPMockery.
@@ -25,4 +26,37 @@ protected function mockFunction($namespace, $functionName, callable $function)
2526
{
2627
PHPMockery::mock($namespace, $functionName)->andReturnUsing($function);
2728
}
29+
30+
protected function setUp()
31+
{
32+
parent::setUp();
33+
34+
$this->workaroundMockeryIssue268();
35+
}
36+
37+
/**
38+
* Workaround for Mockery's issue 268.
39+
*
40+
* Mockery-0.9 introduced global memoization of reflection methods. This
41+
* workaround clears that memoization to fix the affected tests.
42+
*
43+
* @link https://github.com/padraic/mockery/issues/268 Issue 268
44+
*/
45+
private function workaroundMockeryIssue268()
46+
{
47+
foreach (get_declared_classes() as $class) {
48+
if (!is_subclass_of($class, MockInterface::class)) {
49+
continue;
50+
51+
}
52+
try {
53+
$_mockery_methods = new \ReflectionProperty($class, "_mockery_methods");
54+
$_mockery_methods->setAccessible(true);
55+
$_mockery_methods->setValue(null);
56+
57+
} catch (\ReflectionException $e) {
58+
// The unaffected version mockery-0.8 didn't had that property.
59+
}
60+
}
61+
}
2862
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /