Skip to content

Commit 60a698c

Browse files
Merge branch '4.4'
* 4.4: Polyfill the method createPartialMock
2 parents 58cf06e + 1f2dd3a commit 60a698c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Legacy/ForwardCompatTestTraitForV5.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,26 @@ protected function createMock($originalClassName)
105105
return $mock->getMock();
106106
}
107107

108+
/**
109+
* @param string $originalClassName
110+
*
111+
* @return MockObject
112+
*/
113+
protected function createPartialMock($originalClassName, array $methods)
114+
{
115+
$mock = $this->getMockBuilder($originalClassName)
116+
->disableOriginalConstructor()
117+
->disableOriginalClone()
118+
->disableArgumentCloning()
119+
->setMethods(empty($methods) ? null : $methods);
120+
121+
if (method_exists($mock, 'disallowMockingUnknownTypes')) {
122+
$mock = $mock->disallowMockingUnknownTypes();
123+
}
124+
125+
return $mock->getMock();
126+
}
127+
108128
/**
109129
* @param string $message
110130
*

0 commit comments

Comments
 (0)