Skip to content

Commit

Permalink
Merge pull request #1225 from magento-engcom/develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests

#9358
#9359
#9361
#9362
#9429
  • Loading branch information
Oleksii Korshenko authored Jun 23, 2017
2 parents e1774ec + 9bd9128 commit d6efc8e
Show file tree
Hide file tree
Showing 27 changed files with 198 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
namespace Magento\Checkout\Block\Checkout;

use Magento\Directory\Helper\Data as DirectoryHelper;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Store\Api\StoreResolverInterface;
use Magento\Framework\App\ObjectManager;

/**
* Directory data processor.
Expand Down Expand Up @@ -37,9 +39,9 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
private $countryCollectionFactory;

/**
* @var StoreResolverInterface
* @var StoreManagerInterface
*/
private $storeResolver;
private $storeManager;

/**
* @var DirectoryHelper
Expand All @@ -49,19 +51,22 @@ class DirectoryDataProcessor implements \Magento\Checkout\Block\Checkout\LayoutP
/**
* @param \Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection
* @param \Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection
* @param StoreResolverInterface $storeResolver
* @param StoreResolverInterface $storeResolver @deprecated
* @param DirectoryHelper $directoryHelper
* @param StoreManagerInterface $storeManager
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
\Magento\Directory\Model\ResourceModel\Country\CollectionFactory $countryCollection,
\Magento\Directory\Model\ResourceModel\Region\CollectionFactory $regionCollection,
StoreResolverInterface $storeResolver,
DirectoryHelper $directoryHelper
DirectoryHelper $directoryHelper,
StoreManagerInterface $storeManager = null
) {
$this->countryCollectionFactory = $countryCollection;
$this->regionCollectionFactory = $regionCollection;
$this->storeResolver = $storeResolver;
$this->directoryHelper = $directoryHelper;
$this->storeManager = $storeManager ?: ObjectManager::getInstance()->get(StoreManagerInterface::class);
}

/**
Expand Down Expand Up @@ -91,7 +96,7 @@ private function getCountryOptions()
{
if (!isset($this->countryOptions)) {
$this->countryOptions = $this->countryCollectionFactory->create()->loadByStore(
$this->storeResolver->getCurrentStoreId()
$this->storeManager->getStore()->getId()
)->toOptionArray();
$this->countryOptions = $this->orderCountryOptions($this->countryOptions);
}
Expand All @@ -108,7 +113,7 @@ private function getRegionOptions()
{
if (!isset($this->regionOptions)) {
$this->regionOptions = $this->regionCollectionFactory->create()->addAllowedCountriesFilter(
$this->storeResolver->getCurrentStoreId()
$this->storeManager->getStore()->getId()
)->toOptionArray();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ class DirectoryDataProcessorTest extends \PHPUnit_Framework_TestCase
/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
protected $directoryDataHelperMock;
protected $storeManagerMock;

/**
* @var \PHPUnit_Framework_MockObject_MockObject
*/
private $directoryDataHelperMock;

protected function setUp()
{
Expand Down Expand Up @@ -75,6 +80,9 @@ protected function setUp()
$this->storeResolverMock = $this->getMock(
\Magento\Store\Api\StoreResolverInterface::class
);
$this->storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$this->directoryDataHelperMock = $this->getMock(
\Magento\Directory\Helper\Data::class,
[],
Expand All @@ -87,7 +95,8 @@ protected function setUp()
$this->countryCollectionFactoryMock,
$this->regionCollectionFactoryMock,
$this->storeResolverMock,
$this->directoryDataHelperMock
$this->directoryDataHelperMock,
$this->storeManagerMock
);
}

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

$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
->disableOriginalConstructor()
->getMock();
$storeMock->expects($this->atLeastOnce())->method('getId')->willReturn(42);
$this->storeManagerMock->expects($this->atLeastOnce())->method('getStore')->willReturn($storeMock);

$this->countryCollectionFactoryMock->expects($this->once())
->method('create')
->willReturn($this->countryCollectionMock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
*/
namespace Magento\Customer\Model\ResourceModel\Address\Attribute\Source;

use Magento\Checkout\Model\Session;
use Magento\Framework\App\ObjectManager;
use Magento\Store\Api\StoreResolverInterface;
use Magento\Store\Model\StoreManagerInterface;

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

/**
* @var StoreResolverInterface
* @var StoreManagerInterface
*/
private $storeResolver;
private $storeManager;

/**
* @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Option\CollectionFactory $attrOptionCollectionFactory
Expand All @@ -55,7 +53,7 @@ public function getAllOptions()
{
if (!$this->_options) {
$this->_options = $this->_createCountriesCollection()->loadByStore(
$this->getStoreResolver()->getCurrentStoreId()
$this->getStoreManager()->getStore()->getId()
)->toOptionArray();
}
return $this->_options;
Expand All @@ -70,16 +68,16 @@ protected function _createCountriesCollection()
}

/**
* Retrieve Store Resolver
* Retrieve Store Manager
* @deprecated
* @return StoreResolverInterface
* @return StoreManagerInterface
*/
private function getStoreResolver()
private function getStoreManager()
{
if (!$this->storeResolver) {
$this->storeResolver = ObjectManager::getInstance()->get(StoreResolverInterface::class);
if (!$this->storeManager) {
$this->storeManager = ObjectManager::getInstance()->get(StoreManagerInterface::class);
}

return $this->storeResolver;
return $this->storeManager;
}
}
3 changes: 2 additions & 1 deletion lib/internal/Magento/Framework/App/Utility/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,8 @@ private function classFileExistsCheckContent($fullPath, $namespace, $className)
$fileContent = file_get_contents($fullPath);
if (strpos($fileContent, 'namespace ' . $namespace) !== false
&& (strpos($fileContent, 'class ' . $className) !== false
|| strpos($fileContent, 'interface ' . $className) !== false)
|| strpos($fileContent, 'interface ' . $className) !== false
|| strpos($fileContent, 'trait ' . $className) !== false)
) {
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Code\Test\Unit;

use Magento\Framework\Code\Generator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile
/**
* @codingStandardsIgnoreFile
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
*/

class ClassWithAllArgumentTypes
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Code\Test\Unit\Validator;

class ConstructorArgumentTypesTest extends \PHPUnit_Framework_TestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile
/**
* @codingStandardsIgnoreFile
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
*/

namespace ArgumentSequence;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile
/**
* @codingStandardsIgnoreFile
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
*/

class ClassA
{
Expand All @@ -16,16 +18,16 @@ class ClassB
class ClassC
{
}
interface InterfaceA
interface FirstInterface
{
}
class ImplementationOfInterfaceA implements InterfaceA
class ImplementationOfFirstInterface implements FirstInterface
{
}
interface InterfaceB
interface SecondInterface
{
}
class ImplementationOfInterfaceB implements InterfaceB
class ImplementationOfSecondInterface implements SecondInterface
{
}
class Context implements \Magento\Framework\ObjectManager\ContextInterface
Expand All @@ -46,21 +48,21 @@ class Context implements \Magento\Framework\ObjectManager\ContextInterface
protected $_exC;

/**
* @var InterfaceA
* @var FirstInterface
*/
protected $_interfaceA;

/**
* @var ImplementationOfInterfaceB
* @var ImplementationOfSecondInterface
*/
protected $_implOfBInterface;

public function __construct(
\ClassA $exA,
\ClassB $exB,
\ClassC $exC,
\InterfaceA $interfaceA,
\ImplementationOfInterfaceB $implOfBInterface
\FirstInterface $interfaceA,
\ImplementationOfSecondInterface $implOfBInterface
) {
$this->_exA = $exA;
$this->_exB = $exB;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile
/**
* @codingStandardsIgnoreFile
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
*/

namespace TypeDuplication;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile
/**
* @codingStandardsIgnoreFile
* Coding Standards have to be ignored in this file, as it is just a data source for tests.
*/

namespace Magento\SomeModule\Model;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
* See COPYING.txt for license details.
*/

// @codingStandardsIgnoreFile

namespace Magento\Framework\Interception\Code\Generator;

class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract
Expand Down Expand Up @@ -87,13 +85,8 @@ protected function _getClassMethods()
*/
protected function isInterceptedMethod(\ReflectionMethod $method)
{
return !($method->isConstructor() ||
$method->isFinal() ||
$method->isStatic() ||
$method->isDestructor()) && !in_array(
$method->getName(),
['__sleep', '__wakeup', '__clone']
);
return !($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) &&
!in_array($method->getName(), ['__sleep', '__wakeup', '__clone']);
}

/**
Expand All @@ -113,8 +106,8 @@ protected function _getMethodInfo(\ReflectionMethod $method)
'name' => ($method->returnsReference() ? '& ' : '') . $method->getName(),
'parameters' => $parameters,
'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" .
"if (!\$pluginInfo) {\n" .
" return parent::{$method->getName()}({$this->_getParameterList(
"if (!\$pluginInfo) {\n" .
" return parent::{$method->getName()}({$this->_getParameterList(
$parameters
)});\n" .
"} else {\n" .
Expand Down Expand Up @@ -160,8 +153,8 @@ protected function _generateCode()
} else {
$this->_classGenerator->setExtendedClass($typeName);
}
$this->_classGenerator->addTrait('\Magento\Framework\Interception\Interceptor');
$interfaces[] = '\Magento\Framework\Interception\InterceptorInterface';
$this->_classGenerator->addTrait('\\'. \Magento\Framework\Interception\Interceptor::class);
$interfaces[] = '\\'. \Magento\Framework\Interception\InterceptorInterface::class;
$this->_classGenerator->setImplementedInterfaces($interfaces);
return parent::_generateCode();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Framework\Interception\Test\Unit\Code\Generator;

use Composer\Autoload\ClassLoader;
Expand Down
Loading

0 comments on commit d6efc8e

Please sign in to comment.