5
5
*/
6
6
namespace Magento \Framework \TestFramework \Unit \Helper ;
7
7
8
+ use PHPUnit \Framework \MockObject \MockObject ;
9
+
8
10
/**
9
11
* Helper class for basic object retrieving, such as blocks, models etc...
10
12
*
13
+ * @deprecated Class under test should be instantiated with `new` keyword with explicit dependencies declaration
11
14
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
12
15
*/
13
16
class ObjectManager
@@ -44,7 +47,7 @@ public function __construct(\PHPUnit\Framework\TestCase $testObject)
44
47
*
45
48
* @param string $argClassName
46
49
* @param array $originalArguments
47
- * @return null|object|\PHPUnit_Framework_MockObject_MockObject
50
+ * @return null|object|MockObject
48
51
*/
49
52
protected function _createArgumentMock ($ argClassName , array $ originalArguments )
50
53
{
@@ -82,7 +85,7 @@ protected function _processSpecialCases($className, $arguments)
82
85
/**
83
86
* Retrieve specific mock of core resource model
84
87
*
85
- * @return \Magento\Framework\Module\ResourceInterface|\PHPUnit_Framework_MockObject_MockObject
88
+ * @return \Magento\Framework\Module\ResourceInterface|MockObject
86
89
*/
87
90
protected function _getResourceModelMock ()
88
91
{
@@ -108,7 +111,7 @@ protected function _getResourceModelMock()
108
111
* Retrieve mock of core translator model
109
112
*
110
113
* @param string $className
111
- * @return \Magento\Framework\TranslateInterface|\PHPUnit_Framework_MockObject_MockObject
114
+ * @return \Magento\Framework\TranslateInterface|MockObject
112
115
*/
113
116
protected function _getTranslatorMock ($ className )
114
117
{
@@ -130,7 +133,7 @@ protected function _getTranslatorMock($className)
130
133
* Get mock without call of original constructor
131
134
*
132
135
* @param string $className
133
- * @return \PHPUnit_Framework_MockObject_MockObject
136
+ * @return MockObject
134
137
*/
135
138
protected function _getMockWithoutConstructorCall ($ className )
136
139
{
@@ -152,6 +155,7 @@ protected function _getMockWithoutConstructorCall($className)
152
155
*/
153
156
public function getObject ($ className , array $ arguments = [])
154
157
{
158
+ // phpstan:ignore
155
159
if (is_subclass_of ($ className , \Magento \Framework \Api \AbstractSimpleObjectBuilder::class)
156
160
|| is_subclass_of ($ className , \Magento \Framework \Api \Builder::class)
157
161
) {
@@ -292,7 +296,7 @@ public function getConstructArguments($className, array $arguments = [])
292
296
*
293
297
* @param string $className
294
298
* @param array $data
295
- * @return \PHPUnit_Framework_MockObject_MockObject
299
+ * @return MockObject
296
300
* @throws \InvalidArgumentException
297
301
*/
298
302
public function getCollectionMock ($ className , array $ data )
@@ -326,17 +330,16 @@ public function getCollectionMock($className, array $data)
326
330
*
327
331
* @param string $argClassName
328
332
* @param array $arguments
329
- * @return null|object|\PHPUnit_Framework_MockObject_MockObject
333
+ * @return null|object|MockObject
330
334
*/
331
335
private function _getMockObject ($ argClassName , array $ arguments )
332
336
{
337
+ // phpstan:ignore
333
338
if (is_subclass_of ($ argClassName , \Magento \Framework \Api \ExtensibleObjectBuilder::class)) {
334
- $ object = $ this ->getBuilder ($ argClassName , $ arguments );
335
- return $ object ;
336
- } else {
337
- $ object = $ this ->_createArgumentMock ($ argClassName , $ arguments );
338
- return $ object ;
339
+ return $ this ->getBuilder ($ argClassName , $ arguments );
339
340
}
341
+
342
+ return $ this ->_createArgumentMock ($ argClassName , $ arguments );
340
343
}
341
344
342
345
/**
0 commit comments