Skip to content

Commit d6efc8e

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1225 from magento-engcom/develop-prs
Public Pull Requests #9358 #9359 #9361 #9362 #9429
2 parents e1774ec + 9bd9128 commit d6efc8e

File tree

27 files changed

+198
-165
lines changed

27 files changed

+198
-165
lines changed

app/code/Magento/Checkout/Block/Checkout/DirectoryDataProcessor.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
namespace Magento\Checkout\Block\Checkout;
77

88
use Magento\Directory\Helper\Data as DirectoryHelper;
9+
use Magento\Store\Model\StoreManagerInterface;
910
use Magento\Store\Api\StoreResolverInterface;
11+
use Magento\Framework\App\ObjectManager;
1012

1113
/**
1214
* Directory data processor.
@@ -37,9 +39,9 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
3739
private $countryCollectionFactory;
3840

3941
/**
40-
* @var StoreResolverInterface
42+
* @var StoreManagerInterface
4143
*/
42-
private $storeResolver;
44+
private $storeManager;
4345

4446
/**
4547
* @var DirectoryHelper
@@ -49,19 +51,22 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
4951
/**
5052
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection
5153
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection
52-
* @param StoreResolverInterface $storeResolver
54+
* @param StoreResolverInterface $storeResolver @deprecated
5355
* @param DirectoryHelper $directoryHelper
56+
* @param StoreManagerInterface $storeManager
57+
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
5458
*/
5559
public function __construct(
5660
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection,
5761
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection,
5862
StoreResolverInterface $storeResolver,
59-
DirectoryHelper $directoryHelper
63+
DirectoryHelper $directoryHelper,
64+
StoreManagerInterface $storeManager = null
6065
) {
6166
$this->countryCollectionFactory = $countryCollection;
6267
$this->regionCollectionFactory = $regionCollection;
63-
$this->storeResolver = $storeResolver;
6468
$this->directoryHelper = $directoryHelper;
69+
$this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class);
6570
}
6671

6772
/**
@@ -91,7 +96,7 @@ private function getCountryOptions()
9196
{
9297
if (!isset($this->countryOptions)) {
9398
$this->countryOptions = $this->countryCollectionFactory->create()->loadByStore(
94-
$this->storeResolver->getCurrentStoreId()
99+
$this->storeManager->getStore()->getId()
95100
)->toOptionArray();
96101
$this->countryOptions = $this->orderCountryOptions($this->countryOptions);
97102
}
@@ -108,7 +113,7 @@ private function getRegionOptions()
108113
{
109114
if (!isset($this->regionOptions)) {
110115
$this->regionOptions = $this->regionCollectionFactory->create()->addAllowedCountriesFilter(
111-
$this->storeResolver->getCurrentStoreId()
116+
$this->storeManager->getStore()->getId()
112117
)->toOptionArray();
113118
}
114119

app/code/Magento/Checkout/Test/Unit/Block/Checkout/DirectoryDataProcessorTest.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ class DirectoryDataProcessorTest extends \PHPUnit_Framework_TestCase
4040
/**
4141
* @var \PHPUnit_Framework_MockObject_MockObject
4242
*/
43-
protected $directoryDataHelperMock;
43+
protected $storeManagerMock;
44+
45+
/**
46+
* @var \PHPUnit_Framework_MockObject_MockObject
47+
*/
48+
private $directoryDataHelperMock;
4449

4550
protected function setUp()
4651
{
@@ -75,6 +80,9 @@ protected function setUp()
7580
$this->storeResolverMock = $this->getMock(
7681
\Magento\Store\Api\StoreResolverInterface::class
7782
);
83+
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
84+
->disableOriginalConstructor()
85+
->getMock();
7886
$this->directoryDataHelperMock = $this->getMock(
7987
\Magento\Directory\Helper\Data::class,
8088
[],
@@ -87,7 +95,8 @@ protected function setUp()
8795
$this->countryCollectionFactoryMock,
8896
$this->regionCollectionFactoryMock,
8997
$this->storeResolverMock,
90-
$this->directoryDataHelperMock
98+
$this->directoryDataHelperMock,
99+
$this->storeManagerMock
91100
);
92101
}
93102

@@ -98,6 +107,12 @@ public function testProcess()
98107
'region_id' => [],
99108
];
100109

110+
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
111+
->disableOriginalConstructor()
112+
->getMock();
113+
$storeMock->expects($this->atLeastOnce())->method('getId')->willReturn(42);
114+
$this->storeManagerMock->expects($this->atLeastOnce())->method('getStore')->willReturn($storeMock);
115+
101116
$this->countryCollectionFactoryMock->expects($this->once())
102117
->method('create')
103118
->willReturn($this->countryCollectionMock);

app/code/Magento/Customer/Model/ResourceModel/Address/Attribute/Source/Country.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
*/
1212
namespace Magento\Customer\Model\ResourceModel\Address\Attribute\Source;
1313

14-
use Magento\Checkout\Model\Session;
1514
use Magento\Framework\App\ObjectManager;
16-
use Magento\Store\Api\StoreResolverInterface;
1715
use Magento\Store\Model\StoreManagerInterface;
1816

1917
/**
@@ -28,9 +26,9 @@ class Country extends \Magento\Eav\Model\Entity\Attribute\Source\Table
2826
protected $_countriesFactory;
2927

3028
/**
31-
* @var StoreResolverInterface
29+
* @var StoreManagerInterface
3230
*/
33-
private $storeResolver;
31+
private $storeManager;
3432

3533
/**
3634
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
@@ -55,7 +53,7 @@ public function getAllOptions()
5553
{
5654
if (!$this->_options) {
5755
$this->_options = $this->_createCountriesCollection()->loadByStore(
58-
$this->getStoreResolver()->getCurrentStoreId()
56+
$this->getStoreManager()->getStore()->getId()
5957
)->toOptionArray();
6058
}
6159
return $this->_options;
@@ -70,16 +68,16 @@ protected function _createCountriesCollection()
7068
}
7169

7270
/**
73-
* Retrieve Store Resolver
71+
* Retrieve Store Manager
7472
* @deprecated
75-
* @return StoreResolverInterface
73+
* @return StoreManagerInterface
7674
*/
77-
private function getStoreResolver()
75+
private function getStoreManager()
7876
{
79-
if (!$this->storeResolver) {
80-
$this->storeResolver = ObjectManager::getInstance()->get(StoreResolverInterface::class);
77+
if (!$this->storeManager) {
78+
$this->storeManager = ObjectManager::getInstance()->get(StoreManagerInterface::class);
8179
}
8280

83-
return $this->storeResolver;
81+
return $this->storeManager;
8482
}
8583
}

lib/internal/Magento/Framework/App/Utility/Files.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,8 @@ private function classFileExistsCheckContent($fullPath, $namespace, $className)
13911391
$fileContent = file_get_contents($fullPath);
13921392
if (strpos($fileContent, 'namespace ' . $namespace) !== false
13931393
&& (strpos($fileContent, 'class ' . $className) !== false
1394-
|| strpos($fileContent, 'interface ' . $className) !== false)
1394+
|| strpos($fileContent, 'interface ' . $className) !== false
1395+
|| strpos($fileContent, 'trait ' . $className) !== false)
13951396
) {
13961397
return true;
13971398
}

lib/internal/Magento/Framework/Code/Test/Unit/GeneratorTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Code\Test\Unit;
108

119
use Magento\Framework\Code\Generator;

lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76

8-
// @codingStandardsIgnoreFile
7+
/**
8+
* @codingStandardsIgnoreFile
9+
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
10+
*/
911

1012
class ClassWithAllArgumentTypes
1113
{

lib/internal/Magento/Framework/Code/Test/Unit/Validator/ConstructorArgumentTypesTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Code\Test\Unit\Validator;
108

119
class ConstructorArgumentTypesTest extends \PHPUnit_Framework_TestCase

lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForArgumentSequence.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76

8-
// @codingStandardsIgnoreFile
7+
/**
8+
* @codingStandardsIgnoreFile
9+
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
10+
*/
911

1012
namespace ArgumentSequence;
1113

lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForConstructorIntegrity.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76

8-
// @codingStandardsIgnoreFile
7+
/**
8+
* @codingStandardsIgnoreFile
9+
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
10+
*/
911

1012
class ClassA
1113
{
@@ -16,16 +18,16 @@ class ClassB
1618
class ClassC
1719
{
1820
}
19-
interface InterfaceA
21+
interface FirstInterface
2022
{
2123
}
22-
class ImplementationOfInterfaceA implements InterfaceA
24+
class ImplementationOfFirstInterface implements FirstInterface
2325
{
2426
}
25-
interface InterfaceB
27+
interface SecondInterface
2628
{
2729
}
28-
class ImplementationOfInterfaceB implements InterfaceB
30+
class ImplementationOfSecondInterface implements SecondInterface
2931
{
3032
}
3133
class Context implements \Magento\Framework\ObjectManager\ContextInterface
@@ -46,21 +48,21 @@ class Context implements \Magento\Framework\ObjectManager\ContextInterface
4648
protected $_exC;
4749

4850
/**
49-
* @var InterfaceA
51+
* @var FirstInterface
5052
*/
5153
protected $_interfaceA;
5254

5355
/**
54-
* @var ImplementationOfInterfaceB
56+
* @var ImplementationOfSecondInterface
5557
*/
5658
protected $_implOfBInterface;
5759

5860
public function __construct(
5961
\ClassA $exA,
6062
\ClassB $exB,
6163
\ClassC $exC,
62-
\InterfaceA $interfaceA,
63-
\ImplementationOfInterfaceB $implOfBInterface
64+
\FirstInterface $interfaceA,
65+
\ImplementationOfSecondInterface $implOfBInterface
6466
) {
6567
$this->_exA = $exA;
6668
$this->_exB = $exB;

lib/internal/Magento/Framework/Code/Test/Unit/Validator/_files/ClassesForTypeDuplication.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
<?php
22
/**
3-
*
43
* Copyright © Magento, Inc. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76

8-
// @codingStandardsIgnoreFile
7+
/**
8+
* @codingStandardsIgnoreFile
9+
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
10+
*/
911

1012
namespace TypeDuplication;
1113

lib/internal/Magento/Framework/Code/Test/Unit/_files/app/code/Magento/SomeModule/Model/SevenInterface.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
7+
/**
8+
* @codingStandardsIgnoreFile
9+
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
10+
*/
811

912
namespace Magento\SomeModule\Model;
1013

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Code\Generator;
108

119
class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract
@@ -87,13 +85,8 @@ protected function _getClassMethods()
8785
*/
8886
protected function isInterceptedMethod(\ReflectionMethod $method)
8987
{
90-
return !($method->isConstructor() ||
91-
$method->isFinal() ||
92-
$method->isStatic() ||
93-
$method->isDestructor()) && !in_array(
94-
$method->getName(),
95-
['__sleep', '__wakeup', '__clone']
96-
);
88+
return !($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) &&
89+
!in_array($method->getName(), ['__sleep', '__wakeup', '__clone']);
9790
}
9891

9992
/**
@@ -113,8 +106,8 @@ protected function _getMethodInfo(\ReflectionMethod $method)
113106
'name' => ($method->returnsReference() ? '& ' : '') . $method->getName(),
114107
'parameters' => $parameters,
115108
'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" .
116-
"if (!\$pluginInfo) {\n" .
117-
" return parent::{$method->getName()}({$this->_getParameterList(
109+
"if (!\$pluginInfo) {\n" .
110+
" return parent::{$method->getName()}({$this->_getParameterList(
118111
$parameters
119112
)});\n" .
120113
"} else {\n" .
@@ -160,8 +153,8 @@ protected function _generateCode()
160153
} else {
161154
$this->_classGenerator->setExtendedClass($typeName);
162155
}
163-
$this->_classGenerator->addTrait('\Magento\Framework\Interception\Interceptor');
164-
$interfaces[] = '\Magento\Framework\Interception\InterceptorInterface';
156+
$this->_classGenerator->addTrait('\\'. \Magento\Framework\Interception\Interceptor::class);
157+
$interfaces[] = '\\'. \Magento\Framework\Interception\InterceptorInterface::class;
165158
$this->_classGenerator->setImplementedInterfaces($interfaces);
166159
return parent::_generateCode();
167160
}

lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/InterceptorTest.php

Lines changed: 1 addition & 0 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+
67
namespace Magento\Framework\Interception\Test\Unit\Code\Generator;
78

89
use Composer\Autoload\ClassLoader;

0 commit comments

Comments
 (0)