Skip to content

Commit 253d6f5

Browse files
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 ------- a68c16d Polyfill the method createPartialMock
2 parents 215ba8a + a68c16d commit 253d6f5

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/Symfony/Bridge/PhpUnit/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)