Skip to content

Commit b889439

Browse files
author
Daniel Plainview
committed
Disable autoload in order to avoid crashes with legacy autoloaders
1 parent d496dc9 commit b889439

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

PHPUnit/Extensions/MockFunction.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class PHPUnit_Extensions_MockFunction
5858
*
5959
* If the function did not exist before mocking, it's empty.
6060
*
61-
* @var type
61+
* @var string
6262
*/
6363
protected $restore_name;
6464

@@ -72,7 +72,7 @@ class PHPUnit_Extensions_MockFunction
7272
/**
7373
* List of active mock object instances (those that are not restored) with their ID as key.
7474
*
75-
* @var type
75+
* @var PHPUnit_Extensions_MockFunction[]
7676
*/
7777
protected static $instances = array();
7878

@@ -114,10 +114,13 @@ public function __construct( $function_name, $scope_object )
114114
$this->function_name = $function_name;
115115
$this->scope_object = $scope_object;
116116
$this->test_case = self::findTestCase();
117-
$this->mock_object = $this->test_case->getMock(
118-
'Mock_' . str_replace( '::', '__', $this->function_name ) . '_' . $this->id,
119-
array( 'invoked' )
120-
);
117+
$this->mock_object =
118+
$this->test_case->getMockBuilder(
119+
'Mock_' . str_replace( '::', '__', $this->function_name ) . '_' . $this->id
120+
)
121+
->disableAutoload()
122+
->setMethods(array( 'invoked' ))
123+
->getMock();
121124

122125
++self::$next_id;
123126
self::$instances[$this->id] = $this;
@@ -229,7 +232,7 @@ public static function findMock( $id )
229232
* Finds the rist object in the call cstack that is instance of a PHPUnit test case.
230233
*
231234
* @see self::TESTCASE_CLASSNAME
232-
* @return object
235+
* @return PHPUnit_Framework_TestCase
233236
*/
234237
public static function findTestCase()
235238
{

0 commit comments

Comments
 (0)