44
55use  phpmock \AbstractMockTest ;
66use  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$ functionNameandReturnUsing ($ 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
49+  continue ;
50+ 51+  }
52+  try  {
53+  $ _mockery_methodsnew  \ReflectionProperty ($ class"_mockery_methods " );
54+  $ _mockery_methodssetAccessible (true );
55+  $ _mockery_methodssetValue (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