Skip to content

Commit 170425c

Browse files
committed
MC-17251: Creating a preference for category product indexer breaks setup:di:compile
- Changed \Magento\Framework\Async\Code\Generator\ProxyDeferredGenerator (CR comment)
1 parent 389c21e commit 170425c

File tree

5 files changed

+39
-16
lines changed

5 files changed

+39
-16
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Model/Indexer/Category/Product/Action/FullTest.php

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Catalog\Model\Indexer\Category\Product\Action;
79

810
use Magento\Catalog\Model\Indexer\Category\Product\Action\Full as OriginObject;
911
use Magento\TestFramework\Catalog\Model\Indexer\Category\Product\Action\Full as PreferenceObject;
1012
use Magento\Framework\Interception\PluginListInterface;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use Magento\TestFramework\ObjectManager;
1115

1216
/**
13-
* Class FullTest
14-
* @package Magento\Catalog\Model\Indexer\Category\Product\Action
17+
* Test for Magento\Catalog\Model\Indexer\Category\Product\Action\Full *
1518
*/
1619
class FullTest extends \PHPUnit\Framework\TestCase
1720
{
@@ -28,14 +31,28 @@ class FullTest extends \PHPUnit\Framework\TestCase
2831
private $pluginList;
2932

3033
/**
31-
* Prepare data for test
34+
* @var ObjectManager
35+
*/
36+
private $objectManager;
37+
38+
/**
39+
* @inheritDoc
3240
*/
3341
protected function setUp()
3442
{
35-
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
36-
$objectManager->configure(['preferences' => [OriginObject::class => PreferenceObject::class]]);
37-
$this->interceptor = $objectManager->get(OriginObject::class);
38-
$this->pluginList = $objectManager->get(PluginListInterface::class);
43+
$this->objectManager = Bootstrap::getObjectManager();
44+
$preferenceObject = $this->objectManager->get(PreferenceObject::class);
45+
$this->objectManager->addSharedInstance($preferenceObject, OriginObject::class);
46+
$this->interceptor = $this->objectManager->get(OriginObject::class);
47+
$this->pluginList = $this->objectManager->get(PluginListInterface::class);
48+
}
49+
50+
/**
51+
* @inheritDoc
52+
*/
53+
protected function tearDown()
54+
{
55+
$this->objectManager->removeSharedInstance(OriginObject::class);
3956
}
4057

4158
/**

dev/tests/integration/testsuite/Magento/MediaStorage/Helper/File/Storage/DatabaseTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\MediaStorage\Helper\File\Storage;
79

810
use Magento\Framework\ObjectManagerInterface;
@@ -50,7 +52,10 @@ protected function setUp()
5052
/**
5153
* test for \Magento\MediaStorage\Model\File\Storage\Database::deleteFolder()
5254
*
55+
* @magentoDbIsolation enabled
5356
* @magentoDataFixture Magento/MediaStorage/_files/database_mode.php
57+
* @magentoConfigFixture current_store system/media_storage_configuration/media_storage 1
58+
* @magentoConfigFixture current_store system/media_storage_configuration/media_database default_setup
5459
*/
5560
public function testDeleteFolder()
5661
{

lib/internal/Magento/Framework/Async/Code/Generator/ProxyDeferredGenerator.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Framework\Async\Code\Generator;
@@ -151,7 +150,7 @@ protected function _getMethodInfo(\ReflectionMethod $method)
151150
$parameters[] = $this->_getMethodParameterInfo($parameter);
152151
}
153152

154-
$returnTypeValue = $this->getReturnTypeValue($method->getReturnType());
153+
$returnTypeValue = $this->getReturnTypeValue($method);
155154
$methodInfo = [
156155
'name' => $method->getName(),
157156
'parameters' => $parameters,
@@ -208,6 +207,7 @@ protected function _getMethodBody(
208207
} else {
209208
$methodCall = sprintf('%s(%s)', $name, implode(', ', $parameters));
210209
}
210+
211211
//Waiting for deferred result and using it's methods.
212212
return "\$this->wait();\n"
213213
.($withoutReturn ? '' : 'return ')."\$this->instance->$methodCall;";
@@ -231,24 +231,27 @@ protected function _validateData()
231231
$result = false;
232232
}
233233
}
234+
234235
return $result;
235236
}
236237

237238
/**
238239
* Returns return type
239240
*
240-
* @param mixed $returnType
241+
* @param \ReflectionMethod $method
241242
* @return null|string
242243
*/
243-
private function getReturnTypeValue($returnType): ?string
244+
private function getReturnTypeValue(\ReflectionMethod $method): ?string
244245
{
245246
$returnTypeValue = null;
247+
$returnType = $method->getReturnType();
246248
if ($returnType) {
247249
$returnTypeValue = ($returnType->allowsNull() ? '?' : '');
248250
$returnTypeValue .= ($returnType->getName() === 'self')
249-
? $this->getSourceClassName()
251+
? $this->_getFullyQualifiedClassName($method->getDeclaringClass()->getName())
250252
: $returnType->getName();
251253
}
254+
252255
return $returnTypeValue;
253256
}
254257
}

lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
declare(strict_types=1);
87

98
namespace Magento\Framework\Interception\Code\Generator;
@@ -137,8 +136,8 @@ protected function _getMethodInfo(\ReflectionMethod $method)
137136
}
138137
METHOD_BODY
139138
),
140-
'returnType' => $returnTypeValue,
141-
'docblock' => ['shortDescription' => '{@inheritdoc}'],
139+
'returnType' => $returnTypeValue,
140+
'docblock' => ['shortDescription' => '{@inheritdoc}'],
142141
];
143142

144143
return $methodInfo;

lib/internal/Magento/Framework/ObjectManager/Code/Generator/Proxy.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
* Copyright © Magento, Inc. All rights reserved.
66
* See COPYING.txt for license details.
77
*/
8-
98
declare(strict_types=1);
109

1110
namespace Magento\Framework\ObjectManager\Code\Generator;

0 commit comments

Comments
 (0)