diff --git a/app/code/Magento/Backend/Model/Url.php b/app/code/Magento/Backend/Model/Url.php index c1aa03a457cac21032566c9b0540f7b5972ab563..f09c9c04ee6bb942eb774b60837dbbe598a1426b 100644 --- a/app/code/Magento/Backend/Model/Url.php +++ b/app/code/Magento/Backend/Model/Url.php @@ -5,6 +5,8 @@ */ namespace Magento\Backend\Model; +use Magento\Framework\Url\HostChecker; +use Magento\Framework\App\ObjectManager; /** * Class \Magento\Backend\Model\UrlInterface @@ -77,6 +79,8 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn protected $_scope; /** + * Constructor + * * @param \Magento\Framework\App\Route\ConfigInterface $routeConfig * @param \Magento\Framework\App\RequestInterface $request * @param \Magento\Framework\Url\SecurityInfoInterface $urlSecurityInfo @@ -96,7 +100,7 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn * @param \Magento\Store\Model\StoreFactory $storeFactory * @param \Magento\Framework\Data\Form\FormKey $formKey * @param array $data - * + * @param HostChecker|null $hostChecker * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( @@ -118,9 +122,11 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn \Magento\Framework\Encryption\EncryptorInterface $encryptor, \Magento\Store\Model\StoreFactory $storeFactory, \Magento\Framework\Data\Form\FormKey $formKey, - array $data = [] + array $data = [], + HostChecker $hostChecker = null ) { $this->_encryptor = $encryptor; + $hostChecker = $hostChecker ?: ObjectManager::getInstance()->get(HostChecker::class); parent::__construct( $routeConfig, $request, @@ -133,7 +139,8 @@ class Url extends \Magento\Framework\Url implements \Magento\Backend\Model\UrlIn $scopeConfig, $routeParamsPreprocessor, $scopeType, - $data + $data, + $hostChecker ); $this->_backendHelper = $backendHelper; $this->_menuConfig = $menuConfig; diff --git a/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php b/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php index 2bc3d86e74d697cd64be58742ab2a5e3204e8b01..4eda145156c6dbf881eadf3d88981ffb9318d32c 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/UrlTest.php @@ -3,16 +3,13 @@ * Copyright © 2016 Magento. All rights reserved. * See COPYING.txt for license details. */ - -// @codingStandardsIgnoreFile - -/** - * Test class for \Magento\Backend\Model\Url - */ namespace Magento\Backend\Test\Unit\Model; +use Magento\Framework\Url\HostChecker; + /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @codingStandardsIgnoreFile */ class UrlTest extends \PHPUnit_Framework_TestCase { @@ -21,10 +18,12 @@ class UrlTest extends \PHPUnit_Framework_TestCase */ protected $_model; + /** + * @var string + */ protected $_areaFrontName = 'backendArea'; /** - * Mock menu model * @var \PHPUnit_Framework_MockObject_MockObject */ protected $_menuMock; @@ -62,7 +61,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_paramsResolverMock; + protected $routeParamsResolverFactoryMock; /** * @var \Magento\Framework\Encryption\EncryptorInterface @@ -75,6 +74,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase */ protected function setUp() { + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_menuMock = $this->getMock( \Magento\Backend\Model\Menu::class, [], @@ -141,25 +141,21 @@ class UrlTest extends \PHPUnit_Framework_TestCase false, false ); - $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_encryptor = $this->getMock(\Magento\Framework\Encryption\Encryptor::class, null, [], '', false); - $this->_paramsResolverMock = $this->getMock( + $routeParamsResolver = $this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false); + $this->routeParamsResolverFactoryMock = $this->getMock( \Magento\Framework\Url\RouteParamsResolverFactory::class, [], [], '', false ); - $this->_paramsResolverMock->expects( - $this->any() - )->method( - 'create' - )->will( - $this->returnValue( - $this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false) - ) - ); - $this->_model = $helper->getObject( + $this->routeParamsResolverFactoryMock->expects($this->any()) + ->method('create') + ->willReturn($routeParamsResolver); + /** @var HostChecker|\PHPUnit_Framework_MockObject_MockObject $hostCheckerMock */ + $hostCheckerMock = $this->getMock(HostChecker::class, [], [], '', false); + $this->_model = $objectManager->getObject( \Magento\Backend\Model\Url::class, [ 'scopeConfig' => $this->_scopeConfigMock, @@ -168,31 +164,10 @@ class UrlTest extends \PHPUnit_Framework_TestCase 'menuConfig' => $this->_menuConfigMock, 'authSession' => $this->_authSessionMock, 'encryptor' => $this->_encryptor, - 'routeParamsResolverFactory' => $this->_paramsResolverMock + 'routeParamsResolverFactory' => $this->routeParamsResolverFactoryMock, + 'hostChecker' => $hostCheckerMock ] ); - $this->_paramsResolverMock->expects( - $this->any() - )->method( - 'create' - )->will( - $this->returnValue( - $this->getMock(\Magento\Framework\Url\RouteParamsResolver::class, [], [], '', false) - ) - ); - $this->_model = $helper->getObject( - \Magento\Backend\Model\Url::class, - [ - 'scopeConfig' => $this->_scopeConfigMock, - 'backendHelper' => $helperMock, - 'formKey' => $this->_formKey, - 'menuConfig' => $this->_menuConfigMock, - 'authSession' => $this->_authSessionMock, - 'encryptor' => $this->_encryptor, - 'routeParamsResolverFactory' => $this->_paramsResolverMock - ] - ); - $this->_requestMock = $this->getMock(\Magento\Framework\App\Request\Http::class, [], [], '', false); $this->_model->setRequest($this->_requestMock); } @@ -262,7 +237,7 @@ class UrlTest extends \PHPUnit_Framework_TestCase [ 'backendHelper' => $helperMock, 'authSession' => $this->_authSessionMock, - 'routeParamsResolverFactory' => $this->_paramsResolverMock + 'routeParamsResolverFactory' => $this->routeParamsResolverFactoryMock ] ); $urlModel->getAreaFrontName(); diff --git a/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php index 29e670e9f7f4fc95ccc51974d484dc0d802c13e2..9eedf22fbc1ae721fa6f453617c2a68ad6ea32e2 100644 --- a/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php +++ b/app/code/Magento/ConfigurableImportExport/Model/Import/Product/Type/Configurable.php @@ -12,6 +12,7 @@ namespace Magento\ConfigurableImportExport\Model\Import\Product\Type; use Magento\Catalog\Api\Data\ProductInterface; use Magento\CatalogImportExport\Model\Import\Product as ImportProduct; +use Magento\Framework\EntityManager\MetadataPool; /** * Importing configurable products @@ -140,6 +141,7 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ * Instance of database adapter. * * @var \Magento\Framework\DB\Adapter\AdapterInterface + * @deprecated */ protected $_connection; @@ -200,6 +202,7 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ * @param \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypesConfig * @param \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper * @param \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $_productColFac + * @param MetadataPool $metadataPool */ public function __construct( \Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $attrSetColFac, @@ -208,12 +211,12 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ array $params, \Magento\Catalog\Model\ProductTypes\ConfigInterface $productTypesConfig, \Magento\ImportExport\Model\ResourceModel\Helper $resourceHelper, - \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $_productColFac + \Magento\Catalog\Model\ResourceModel\Product\CollectionFactory $_productColFac, + MetadataPool $metadataPool = null ) { - parent::__construct($attrSetColFac, $prodAttrColFac, $resource, $params); + parent::__construct($attrSetColFac, $prodAttrColFac, $resource, $params, $metadataPool); $this->_productTypesConfig = $productTypesConfig; $this->_resourceHelper = $resourceHelper; - $this->_resource = $resource; $this->_productColFac = $_productColFac; $this->_connection = $this->_entityModel->getConnection(); } @@ -379,14 +382,14 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ if (!empty($productIds)) { $mainTable = $this->_resource->getTableName('catalog_product_super_attribute'); $optionTable = $this->_resource->getTableName('eav_attribute_option'); - $select = $this->_connection->select()->from( + $select = $this->connection->select()->from( ['m' => $mainTable], ['product_id', 'attribute_id', 'product_super_attribute_id'] )->joinLeft( ['o' => $optionTable], - $this->_connection->quoteIdentifier( + $this->connection->quoteIdentifier( 'o.attribute_id' - ) . ' = ' . $this->_connection->quoteIdentifier( + ) . ' = ' . $this->connection->quoteIdentifier( 'o.attribute_id' ), ['option_id'] @@ -395,7 +398,7 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ $productIds ); - foreach ($this->_connection->fetchAll($select) as $row) { + foreach ($this->connection->fetchAll($select) as $row) { $attrId = $row['attribute_id']; $productId = $row['product_id']; if ($row['option_id']) { @@ -448,8 +451,8 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ 'product_id' => $this->_productSuperData['assoc_entity_ids'][$assocId], 'parent_id' => $this->_productSuperData['product_id'], ]; - $subEntityId = $this->_connection->fetchOne( - $this->_connection->select()->from( + $subEntityId = $this->connection->fetchOne( + $this->connection->select()->from( ['cpe' => $this->_resource->getTableName('catalog_product_entity')], ['entity_id'] )->where($metadata->getLinkField() . ' = ?', $assocId) ); @@ -557,10 +560,10 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ && !empty($this->_productSuperData['product_id']) && !empty($this->_simpleIdsToDelete) ) { - $quoted = $this->_connection->quoteInto('IN (?)', [$this->_productSuperData['product_id']]); - $quotedChildren = $this->_connection->quoteInto('IN (?)', $this->_simpleIdsToDelete); - $this->_connection->delete($linkTable, "parent_id {$quoted} AND product_id {$quotedChildren}"); - $this->_connection->delete($relationTable, "parent_id {$quoted} AND child_id {$quotedChildren}"); + $quoted = $this->connection->quoteInto('IN (?)', [$this->_productSuperData['product_id']]); + $quotedChildren = $this->connection->quoteInto('IN (?)', $this->_simpleIdsToDelete); + $this->connection->delete($linkTable, "parent_id {$quoted} AND product_id {$quotedChildren}"); + $this->connection->delete($relationTable, "parent_id {$quoted} AND child_id {$quotedChildren}"); } return $this; } @@ -587,16 +590,16 @@ class Configurable extends \Magento\CatalogImportExport\Model\Import\Product\Typ } } if ($mainData) { - $this->_connection->insertOnDuplicate($mainTable, $mainData); + $this->connection->insertOnDuplicate($mainTable, $mainData); } if ($this->_superAttributesData['labels']) { - $this->_connection->insertOnDuplicate($labelTable, $this->_superAttributesData['labels']); + $this->connection->insertOnDuplicate($labelTable, $this->_superAttributesData['labels']); } if ($this->_superAttributesData['super_link']) { - $this->_connection->insertOnDuplicate($linkTable, $this->_superAttributesData['super_link']); + $this->connection->insertOnDuplicate($linkTable, $this->_superAttributesData['super_link']); } if ($this->_superAttributesData['relation']) { - $this->_connection->insertOnDuplicate($relationTable, $this->_superAttributesData['relation']); + $this->connection->insertOnDuplicate($relationTable, $this->_superAttributesData['relation']); } return $this; } diff --git a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php index 8ce7489db932ef9f21eb5eb1ae21d6341e1658c9..4cc4e6648a0ef8d63c6ae13e28c547b6e9019155 100644 --- a/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php +++ b/app/code/Magento/ConfigurableImportExport/Test/Unit/Model/Import/Product/Type/ConfigurableTest.php @@ -312,15 +312,10 @@ class ConfigurableTest extends \Magento\ImportExport\Test\Unit\Model\Import\Abst 'prodAttrColFac' => $this->attrCollectionFactory, 'params' => $this->params, 'resource' => $this->resource, - 'productColFac' => $this->productCollectionFactory + 'productColFac' => $this->productCollectionFactory, + 'metadataPool' => $metadataPoolMock, ] ); - $reflection = new \ReflectionClass( - \Magento\ConfigurableImportExport\Model\Import\Product\Type\Configurable::class - ); - $reflectionProperty = $reflection->getProperty('metadataPool'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->configurable, $metadataPoolMock); } /** diff --git a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php index ff028e2f7340ba96161484a6cca621c626bac68c..2b4a93084c7ac40ec5909d484079245f161c35f3 100644 --- a/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php +++ b/app/code/Magento/Customer/Test/Unit/Model/Address/ConfigTest.php @@ -5,140 +5,115 @@ */ namespace Magento\Customer\Test\Unit\Model\Address; -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ class ConfigTest extends \PHPUnit_Framework_TestCase { /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_readerMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_cacheMock; + protected $addressHelperMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_storeManagerMock; + protected $storeMock; /** * @var \PHPUnit_Framework_MockObject_MockObject */ - protected $_addressHelperMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_storeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_scopeConfigMock; - - /** - * @var \Magento\Framework\Serialize\SerializerInterface|\PHPUnit_Framework_MockObject_MockObject - */ - private $serializerMock; + protected $scopeConfigMock; /** * @var \Magento\Customer\Model\Address\Config */ - protected $_model; - - /** - * @var string - */ - protected $_cacheId = 'cache_id'; + protected $model; protected function setUp() { - $this->_storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); - $this->_scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); + $cacheId = 'cache_id'; + $objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $this->storeMock = $this->getMock(\Magento\Store\Model\Store::class, [], [], '', false); + $this->scopeConfigMock = $this->getMock(\Magento\Framework\App\Config\ScopeConfigInterface::class); - $this->_readerMock = $this->getMock( + $readerMock = $this->getMock( \Magento\Customer\Model\Address\Config\Reader::class, [], [], '', false ); - $this->_cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); - $this->_storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); - $this->_storeManagerMock->expects( + $cacheMock = $this->getMock(\Magento\Framework\Config\CacheInterface::class); + $storeManagerMock = $this->getMock(\Magento\Store\Model\StoreManager::class, [], [], '', false); + $storeManagerMock->expects( $this->once() )->method( 'getStore' )->will( - $this->returnValue($this->_storeMock) + $this->returnValue($this->storeMock) ); - $this->_addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); + $this->addressHelperMock = $this->getMock(\Magento\Customer\Helper\Address::class, [], [], '', false); - $this->_cacheMock->expects( + $cacheMock->expects( $this->once() )->method( 'load' )->with( - $this->_cacheId + $cacheId )->will( $this->returnValue(false) ); $fixtureConfigData = require __DIR__ . '/Config/_files/formats_merged.php'; - $this->_readerMock->expects($this->once())->method('read')->will($this->returnValue($fixtureConfigData)); + $readerMock->expects($this->once())->method('read')->will($this->returnValue($fixtureConfigData)); - $this->_cacheMock->expects($this->once()) + $cacheMock->expects($this->once()) ->method('save') ->with( json_encode($fixtureConfigData), - $this->_cacheId + $cacheId ); - $this->serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); - $this->serializerMock->method('serialize') + $serializerMock = $this->getMock(\Magento\Framework\Serialize\SerializerInterface::class); + $serializerMock->method('serialize') ->willReturn(json_encode($fixtureConfigData)); - $this->serializerMock->method('unserialize') + $serializerMock->method('unserialize') ->willReturn($fixtureConfigData); - $this->_model = new \Magento\Customer\Model\Address\Config( - $this->_readerMock, - $this->_cacheMock, - $this->_storeManagerMock, - $this->_addressHelperMock, - $this->_scopeConfigMock, - $this->_cacheId, - $this->serializerMock + $this->model = $objectManagerHelper->getObject( + \Magento\Customer\Model\Address\Config::class, + [ + 'reader' => $readerMock, + 'cache' => $cacheMock, + 'storeManager' => $storeManagerMock, + 'scopeConfig' => $this->scopeConfigMock, + 'cacheId' => $cacheId, + 'serializer' => $serializerMock, + 'addressHelper' => $this->addressHelperMock, + ] ); } public function testGetStore() { - $this->assertEquals($this->_storeMock, $this->_model->getStore()); + $this->assertEquals($this->storeMock, $this->model->getStore()); } public function testSetStore() { - $this->_model->setStore($this->_storeMock); - - //no call to $_storeManagerMock's method - $this->assertEquals($this->_storeMock, $this->_model->getStore()); + $this->model->setStore($this->storeMock); + $this->assertEquals($this->storeMock, $this->model->getStore()); } public function testGetFormats() { - $this->_storeMock->expects($this->once())->method('getId'); + $this->storeMock->expects($this->once())->method('getId'); - $this->_scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue('someValue')); + $this->scopeConfigMock->expects($this->any())->method('getValue')->will($this->returnValue('someValue')); $rendererMock = $this->getMock(\Magento\Framework\DataObject::class); - $this->_addressHelperMock->expects( + $this->addressHelperMock->expects( $this->any() )->method( 'getRenderer' @@ -173,6 +148,6 @@ class ConfigTest extends \PHPUnit_Framework_TestCase ); $expectedResult = [$firstExpected, $secondExpected]; - $this->assertEquals($expectedResult, $this->_model->getFormats()); + $this->assertEquals($expectedResult, $this->model->getFormats()); } } diff --git a/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php b/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php index a34276ab5f4c63093e50fde63b1aafd3a84660ae..7a447aa90eea8f6eb39100e0218bbc90302a715f 100644 --- a/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php +++ b/app/code/Magento/DownloadableImportExport/Model/Import/Product/Type/Downloadable.php @@ -266,7 +266,6 @@ class Downloadable extends \Magento\CatalogImportExport\Model\Import\Product\Typ parent::__construct($attrSetColFac, $prodAttrColFac, $resource, $params, $metadataPool); $this->parameters = $this->_entityModel->getParameters(); $this->_resource = $resource; - $this->connection = $resource->getConnection('write'); $this->uploaderHelper = $uploaderHelper; $this->downloadableHelper = $downloadableHelper; } diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php index b5b33fb8dc39e288cfbaf85c78b9409e2f5c020a..48cd2ab7c4850450d5c62986619877531fc382b4 100644 --- a/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php +++ b/app/code/Magento/SalesRule/Test/Unit/Model/RuleTest.php @@ -5,16 +5,8 @@ */ namespace Magento\SalesRule\Test\Unit\Model; -/** - * @SuppressWarnings(PHPMD.CouplingBetweenObjects) - */ class RuleTest extends \PHPUnit_Framework_TestCase { - /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager - */ - private $objectManager; - /** * @var \Magento\SalesRule\Model\Rule */ @@ -37,7 +29,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase protected function setUp() { - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->coupon = $this->getMockBuilder(\Magento\SalesRule\Model\Coupon::class) ->disableOriginalConstructor() @@ -64,7 +56,7 @@ class RuleTest extends \PHPUnit_Framework_TestCase ->setMethods(['create']) ->getMock(); - $this->model = $this->objectManager->getObject( + $this->model = $objectManager->getObject( \Magento\SalesRule\Model\Rule::class, [ 'couponFactory' => $couponFactory, diff --git a/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php b/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php index 8db369facf97f4d61dd8468dd34db67b5250bf13..d25e0406882377e1ef5e6ab89c21bf5a1368496c 100644 --- a/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php +++ b/dev/tests/integration/testsuite/Magento/DownloadableImportExport/Model/Import/Product/Type/DownloadableTest.php @@ -5,9 +5,7 @@ */ namespace Magento\DownloadableImportExport\Model\Import\Product\Type; -use Magento\Framework\App\Bootstrap; use Magento\Framework\App\Filesystem\DirectoryList; -use Magento\ImportExport\Model\Import; /** * @magentoAppArea adminhtml diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php index c858bcb8812c4026dc4c0b4081ccd821af85335b..7d15d1029bda65837aacc94111132fdc1c34e829 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php @@ -7,7 +7,6 @@ namespace Magento\Framework\Interception\Test\Unit\Config; use Magento\Framework\Serialize\SerializerInterface; -use Magento\Framework\Serialize\Serializer\Serialize; require_once __DIR__ . '/../Custom/Module/Model/Item.php'; require_once __DIR__ . '/../Custom/Module/Model/Item/Enhanced.php'; diff --git a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php index 15d1b55f7cfcdad9448ed694b7cbd50d114e511d..11e8dabf6d924cb4c566746514af503091b85935 100644 --- a/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php +++ b/lib/internal/Magento/Framework/Interception/Test/Unit/PluginList/PluginListTest.php @@ -6,6 +6,7 @@ namespace Magento\Framework\Interception\Test\Unit\PluginList; use Magento\Framework\Serialize\SerializerInterface; +use Magento\Framework\ObjectManagerInterface; require_once __DIR__ . '/../Custom/Module/Model/Item.php'; require_once __DIR__ . '/../Custom/Module/Model/Item/Enhanced.php'; @@ -37,15 +38,20 @@ class PluginListTest extends \PHPUnit_Framework_TestCase */ private $cacheMock; + /** + * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + */ + private $loggerMock; + /** * @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject */ private $serializerMock; /** - * @var \Psr\Log\LoggerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ObjectManagerInterface||\PHPUnit_Framework_MockObject_MockObject */ - private $loggerMock; + private $objectManagerMock; protected function setUp() { @@ -66,8 +72,10 @@ class PluginListTest extends \PHPUnit_Framework_TestCase $omConfigMock->expects($this->any())->method('getOriginalInstanceType')->will($this->returnArgument(0)); - $objectManagerMock = $this->getMock(\Magento\Framework\ObjectManagerInterface::class); - $objectManagerMock->expects($this->any())->method('get')->will($this->returnArgument(0)); + $this->objectManagerMock = $this->getMock(ObjectManagerInterface::class); + $this->objectManagerMock->expects($this->any()) + ->method('get') + ->willReturnArgument(0); $this->serializerMock = $this->getMock(SerializerInterface::class); $definitions = new \Magento\Framework\ObjectManager\Definition\Runtime(); @@ -82,7 +90,7 @@ class PluginListTest extends \PHPUnit_Framework_TestCase 'relations' => new \Magento\Framework\ObjectManager\Relations\Runtime(), 'omConfig' => $omConfigMock, 'definitions' => new \Magento\Framework\Interception\Definition\Runtime(), - 'objectManager' => $objectManagerMock, + 'objectManager' => $this->objectManagerMock, 'classDefinitions' => $definitions, 'scopePriorityScheme' => ['global'], 'cacheId' => 'interception', @@ -234,7 +242,7 @@ class PluginListTest extends \PHPUnit_Framework_TestCase public function testLoadScopedDataNotCached() { - $this->configScopeMock->expects($this->exactly(2)) + $this->configScopeMock->expects($this->exactly(3)) ->method('getCurrentScope') ->will($this->returnValue('scope')); $this->serializerMock->expects($this->once()) @@ -295,23 +303,23 @@ class PluginListTest extends \PHPUnit_Framework_TestCase */ public function testLoadScopeDataWithEmptyData() { - $this->_objectManagerMock->expects($this->any()) + $this->objectManagerMock->expects($this->any()) ->method('get') ->will($this->returnArgument(0)); - $this->_configScopeMock->expects($this->any()) + $this->configScopeMock->expects($this->any()) ->method('getCurrentScope') ->will($this->returnValue('emptyscope')); $this->assertEquals( [4 => ['simple_plugin']], - $this->_model->getNext( + $this->object->getNext( \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'getName' ) ); $this->assertEquals( \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemPlugin\Simple::class, - $this->_model->getPlugin( + $this->object->getPlugin( \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class, 'simple_plugin' )