minor #32893 [PhpUnitBridge] Polyfill the method createPartialMock (jderusse)

This PR was merged into the 4.4 branch.

Discussion
----------

[PhpUnitBridge] Polyfill the method createPartialMock

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32844
| License       | MIT
| Doc PR        | NA

Provide a polyfill for `createPartialMock` required by #32885

Commits
-------

a68c16d844 Polyfill the method createPartialMock
This commit is contained in:
Nicolas Grekas 2019-08-03 08:58:53 +02:00
commit 253d6f52ab

View File

@ -105,6 +105,26 @@ trait ForwardCompatTestTraitForV5
return $mock->getMock();
}
/**
* @param string $originalClassName
*
* @return MockObject
*/
protected function createPartialMock($originalClassName, array $methods)
{
$mock = $this->getMockBuilder($originalClassName)
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->setMethods(empty($methods) ? null : $methods);
if (method_exists($mock, 'disallowMockingUnknownTypes')) {
$mock = $mock->disallowMockingUnknownTypes();
}
return $mock->getMock();
}
/**
* @param string $message
*