Skip to content

Commit e6c0c83

Browse files
committed
Merge remote-tracking branch 'github-magento2ce/MC-17251' into EPAM-PR-71
2 parents 6427ae6 + bc9cc8b commit e6c0c83

File tree

6 files changed

+129
-16
lines changed

6 files changed

+129
-16
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\TestFramework\Catalog\Model\Indexer\Category\Product\Action;
10+
11+
use Magento\Catalog\Model\Indexer\Category\Product\Action\Full as OriginFull;
12+
13+
/**
14+
* Class Full reindex action
15+
*
16+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
17+
*/
18+
class Full extends OriginFull
19+
{
20+
//
21+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Catalog\Model\Indexer\Category\Product\Action;
9+
10+
use Magento\Catalog\Model\Indexer\Category\Product\Action\Full as OriginObject;
11+
use Magento\TestFramework\Catalog\Model\Indexer\Category\Product\Action\Full as PreferenceObject;
12+
use Magento\Framework\Interception\PluginListInterface;
13+
use Magento\TestFramework\Helper\Bootstrap;
14+
use Magento\TestFramework\ObjectManager;
15+
16+
/**
17+
* Test for Magento\Catalog\Model\Indexer\Category\Product\Action\Full *
18+
*/
19+
class FullTest extends \PHPUnit\Framework\TestCase
20+
{
21+
/**
22+
* @var PreferenceObject
23+
*/
24+
private $interceptor;
25+
26+
/**
27+
* List of plugins
28+
*
29+
* @var PluginListInterface
30+
*/
31+
private $pluginList;
32+
33+
/**
34+
* @var ObjectManager
35+
*/
36+
private $objectManager;
37+
38+
/**
39+
* @inheritDoc
40+
*/
41+
protected function setUp()
42+
{
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);
56+
}
57+
58+
/**
59+
* Test possibility to add object preference
60+
*/
61+
public function testPreference()
62+
{
63+
$interceptorClassName = get_class($this->interceptor);
64+
65+
// Check interceptor class name
66+
$this->assertEquals($interceptorClassName, PreferenceObject::class . '\Interceptor');
67+
68+
//check that there are no fatal errors
69+
$this->pluginList->getNext($interceptorClassName, 'execute');
70+
}
71+
}

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

Lines changed: 6 additions & 1 deletion
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
*
53-
* @magentoDataFixtureBeforeTransaction Magento/MediaStorage/_files/database_mode.php
55+
* @magentoDbIsolation enabled
56+
* @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: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
67

78
namespace Magento\Framework\Interception\Code\Generator;
89

@@ -58,6 +59,7 @@ protected function _getDefaultConstructorDefinition()
5859
? "parent::__construct({$this->_getParameterList($parameters)});"
5960
: "parent::__construct();";
6061
}
62+
6163
return [
6264
'name' => '__construct',
6365
'parameters' => $parameters,
@@ -81,6 +83,7 @@ protected function _getClassMethods()
8183
$methods[] = $this->_getMethodInfo($method);
8284
}
8385
}
86+
8487
return $methods;
8588
}
8689

@@ -109,7 +112,7 @@ protected function _getMethodInfo(\ReflectionMethod $method)
109112
$parameters[] = $this->_getMethodParameterInfo($parameter);
110113
}
111114

112-
$returnTypeValue = $this->getReturnTypeValue($method->getReturnType());
115+
$returnTypeValue = $this->getReturnTypeValue($method);
113116
$methodInfo = [
114117
'name' => ($method->returnsReference() ? '& ' : '') . $method->getName(),
115118
'parameters' => $parameters,
@@ -133,8 +136,8 @@ protected function _getMethodInfo(\ReflectionMethod $method)
133136
}
134137
METHOD_BODY
135138
),
136-
'returnType' => $returnTypeValue,
137-
'docblock' => ['shortDescription' => '{@inheritdoc}'],
139+
'returnType' => $returnTypeValue,
140+
'docblock' => ['shortDescription' => '{@inheritdoc}'],
138141
];
139142

140143
return $methodInfo;
@@ -184,6 +187,7 @@ protected function _generateCode()
184187
$this->_classGenerator->addTrait('\\' . \Magento\Framework\Interception\Interceptor::class);
185188
$interfaces[] = '\\' . \Magento\Framework\Interception\InterceptorInterface::class;
186189
$this->_classGenerator->setImplementedInterfaces($interfaces);
190+
187191
return parent::_generateCode();
188192
}
189193

@@ -211,24 +215,27 @@ protected function _validateData()
211215
$result = false;
212216
}
213217
}
218+
214219
return $result;
215220
}
216221

217222
/**
218223
* Returns return type
219224
*
220-
* @param mixed $returnType
225+
* @param \ReflectionMethod $method
221226
* @return null|string
222227
*/
223-
private function getReturnTypeValue($returnType): ?string
228+
private function getReturnTypeValue(\ReflectionMethod $method): ?string
224229
{
225230
$returnTypeValue = null;
231+
$returnType = $method->getReturnType();
226232
if ($returnType) {
227233
$returnTypeValue = ($returnType->allowsNull() ? '?' : '');
228234
$returnTypeValue .= ($returnType->getName() === 'self')
229-
? $this->getSourceClassName()
235+
? $this->_getFullyQualifiedClassName($method->getDeclaringClass()->getName())
230236
: $returnType->getName();
231237
}
238+
232239
return $returnTypeValue;
233240
}
234241
}

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

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

910
namespace Magento\Framework\ObjectManager\Code\Generator;
1011

@@ -73,6 +74,7 @@ protected function _getClassProperties()
7374
'tags' => [['name' => 'var', 'description' => 'bool']],
7475
],
7576
];
77+
7678
return $properties;
7779
}
7880

@@ -154,6 +156,7 @@ protected function _generateCode()
154156
$this->_classGenerator->setExtendedClass($typeName);
155157
$this->_classGenerator->setImplementedInterfaces(['\\' . self::NON_INTERCEPTABLE_INTERFACE]);
156158
}
159+
157160
return parent::_generateCode();
158161
}
159162

@@ -173,7 +176,7 @@ protected function _getMethodInfo(\ReflectionMethod $method)
173176
$parameters[] = $this->_getMethodParameterInfo($parameter);
174177
}
175178

176-
$returnTypeValue = $this->getReturnTypeValue($method->getReturnType());
179+
$returnTypeValue = $this->getReturnTypeValue($method);
177180
$methodInfo = [
178181
'name' => $method->getName(),
179182
'parameters' => $parameters,
@@ -269,24 +272,27 @@ protected function _validateData()
269272
$result = false;
270273
}
271274
}
275+
272276
return $result;
273277
}
274278

275279
/**
276280
* Returns return type
277281
*
278-
* @param mixed $returnType
282+
* @param \ReflectionMethod $method
279283
* @return null|string
280284
*/
281-
private function getReturnTypeValue($returnType): ?string
285+
private function getReturnTypeValue(\ReflectionMethod $method): ?string
282286
{
283287
$returnTypeValue = null;
288+
$returnType = $method->getReturnType();
284289
if ($returnType) {
285290
$returnTypeValue = ($returnType->allowsNull() ? '?' : '');
286291
$returnTypeValue .= ($returnType->getName() === 'self')
287-
? $this->getSourceClassName()
292+
? $this->_getFullyQualifiedClassName($method->getDeclaringClass()->getName())
288293
: $returnType->getName();
289294
}
295+
290296
return $returnTypeValue;
291297
}
292298
}

0 commit comments

Comments
 (0)