From 98bda3507011d10cae282dedc1e43ef8deaaff0b Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Mon, 25 Apr 2016 13:45:41 +0300 Subject: [PATCH 01/19] MAGETWO-52215: Cms pages isn't synchronized with core_config_data --- app/code/Magento/Cms/Model/Page.php | 38 +++++ .../Magento/Cms/Test/Unit/Model/PageTest.php | 139 ++++++++++-------- 2 files changed, 119 insertions(+), 58 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 05b9450c32315..5a8a743848c16 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -7,7 +7,9 @@ use Magento\Cms\Api\Data\PageInterface; use Magento\Cms\Model\ResourceModel\Page as ResourceCmsPage; +use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\DataObject\IdentityInterface; +use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Model\AbstractModel; /** @@ -49,6 +51,11 @@ class Page extends AbstractModel implements PageInterface, IdentityInterface */ protected $_eventPrefix = 'cms_page'; + /** + * @var ScopeConfigInterface + */ + private $scopeConfig; + /** * Initialize resource model * @@ -505,4 +512,35 @@ public function setIsActive($isActive) { return $this->setData(self::IS_ACTIVE, $isActive); } + + public function beforeSave() + { + $originalIdentifier = $this->getOrigData('identifier'); + $currentIdentifier = $this->getIdentifier(); + $scopeConfigIdentifier = $this->getScopeConfig()->getValue( + \Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE + ); + + if ( + $this->getId() + && $originalIdentifier !== $currentIdentifier + && $originalIdentifier === $scopeConfigIdentifier + ) { + throw new LocalizedException(__('This identifier is reserved for 404 error page in configuration.')); + } + + return parent::beforeSave(); + } + + /** + * @return ScopeConfigInterface + */ + private function getScopeConfig() + { + if (null === $this->scopeConfig) { + $this->scopeConfig = \Magento\Framework\App\ObjectManager::getInstance()->get(ScopeConfigInterface::class); + } + + return $this->scopeConfig; + } } diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php index 768a131e99cac..78a6e382607ec 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php @@ -5,88 +5,90 @@ */ namespace Magento\Cms\Test\Unit\Model; +use Magento\Cms\Model\Page; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\Event\ManagerInterface; +use Magento\Framework\Model\Context; +use Magento\Cms\Model\ResourceModel\Page as PageResource; +use Magento\Framework\Model\ResourceModel\AbstractResource; + /** * @covers \Magento\Cms\Model\Page */ class PageTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Cms\Model\Page|\PHPUnit_Framework_MockObject_MockObject + * @var \Magento\Cms\Model\Page */ - protected $thisMock; + protected $model; /** - * @var \Magento\Backend\Block\Template\Context + * @var \Magento\Backend\Block\Template\Context|\PHPUnit_Framework_MockObject_MockObject */ - protected $context; + protected $contextMock; /** - * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ protected $eventManagerMock; /** - * @var \Magento\Cms\Model\ResourceModel\Page|\PHPUnit_Framework_MockObject_MockObject + * @var PageResource|\PHPUnit_Framework_MockObject_MockObject */ protected $resourcePageMock; + /** + * @var AbstractResource|\PHPUnit_Framework_MockObject_MockObject + */ + protected $resourcesMock; + + /** + * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject + */ + protected $scopeConfigMock; + protected function setUp() { - $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->eventManagerMock = $this->getMockBuilder('Magento\Framework\Event\ManagerInterface') + $this->eventManagerMock = $this->getMockBuilder(ManagerInterface::class) ->disableOriginalConstructor() ->getMock(); - $this->context = $objectManager->getObject( - 'Magento\Framework\Model\Context', - [ - 'eventDispatcher' => $this->eventManagerMock - ] - ); - $this->resourcePageMock = $this->getMockBuilder('Magento\Cms\Model\ResourceModel\Page') + $this->contextMock = $this->getMockBuilder(Context::class) ->disableOriginalConstructor() - ->setMethods( - [ - 'getIdFieldName', - 'checkIdentifier', - ] - ) ->getMock(); - $this->thisMock = $this->getMockBuilder('Magento\Cms\Model\Page') - ->setConstructorArgs( - [ - $this->context, - $this->getMockBuilder('Magento\Framework\Registry') - ->disableOriginalConstructor() - ->getMock(), - $this->getMockBuilder('Magento\Framework\Model\ResourceModel\AbstractResource') - ->disableOriginalConstructor() - ->setMethods( - [ - '_construct', - 'getConnection', - ] - ) - ->getMockForAbstractClass(), - $this->getMockBuilder('Magento\Framework\Data\Collection\AbstractDb') - ->disableOriginalConstructor() - ->getMockForAbstractClass(), - ] - ) - ->setMethods( - [ - '_construct', - '_getResource', - 'load', - ] - ) + $this->resourcePageMock = $this->getMockBuilder(PageResource::class) + ->disableOriginalConstructor() + ->setMethods(['getIdFieldName', 'checkIdentifier',]) + ->getMock(); + $this->eventManagerMock = $this->getMockBuilder(ManagerInterface::class) + ->disableOriginalConstructor() ->getMock(); + $this->resourcesMock = $this->getMockBuilder(AbstractResource::class) + ->setMethods(['getIdFieldName', 'load', 'checkIdentifier']) + ->getMockForAbstractClass(); + $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class) + ->getMockForAbstractClass(); - $this->thisMock->expects($this->any()) - ->method('_getResource') - ->willReturn($this->resourcePageMock); - $this->thisMock->expects($this->any()) - ->method('load') - ->willReturnSelf(); + $this->contextMock->expects($this->any()) + ->method('getEventDispatcher') + ->willReturn($this->eventManagerMock); + $this->resourcePageMock->expects($this->any()) + ->method('getResources') + ->willReturn($this->resourcesMock); + + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $this->model = $objectManager->getObject( + Page::class, + [ + 'context' => $this->contextMock, + 'resource' => $this->resourcesMock, + ] + ); + $objectManager->setBackwardCompatibleProperty( + $this->model, + 'scopeConfig', + $this->scopeConfigMock + ); } /** @@ -94,7 +96,7 @@ protected function setUp() */ public function testNoRoutePage() { - $this->assertEquals($this->thisMock, $this->thisMock->noRoutePage()); + $this->assertEquals($this->model, $this->model->noRoutePage()); } /** @@ -106,11 +108,32 @@ public function testCheckIdentifier() $storeId = 2; $fetchOneResult = 'some result'; - $this->resourcePageMock->expects($this->atLeastOnce()) + $this->resourcesMock->expects($this->atLeastOnce()) ->method('checkIdentifier') ->with($identifier, $storeId) ->willReturn($fetchOneResult); - $this->assertInternalType('string', $this->thisMock->checkIdentifier($identifier, $storeId)); + $this->assertInternalType('string', $this->model->checkIdentifier($identifier, $storeId)); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage This identifier is reserved for 404 error page in configuration. + */ + public function testBeforeSave404Identifier() + { + $this->model->setId(1); + $this->model->setOrigData('identifier', 'no-route'); + $this->model->setIdentifier('no-route2'); + + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with( + \Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null + )->willReturn('no-route'); + + $this->model->beforeSave(); } } From ea39011172ef7f27201b6aef9434f8273637ef0c Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Mon, 25 Apr 2016 14:02:15 +0300 Subject: [PATCH 02/19] MAGETWO-52215: Cms pages isn't synchronized with core_config_data --- app/code/Magento/Cms/Model/Page.php | 3 +++ app/code/Magento/Cms/Test/Unit/Model/PageTest.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index 5a8a743848c16..b44a9d4cc8711 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -513,6 +513,9 @@ public function setIsActive($isActive) return $this->setData(self::IS_ACTIVE, $isActive); } + /** + * {@inheritdoc} + */ public function beforeSave() { $originalIdentifier = $this->getOrigData('identifier'); diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php index 78a6e382607ec..0fbe458ad8d68 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php @@ -14,6 +14,7 @@ /** * @covers \Magento\Cms\Model\Page + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class PageTest extends \PHPUnit_Framework_TestCase { @@ -57,7 +58,7 @@ protected function setUp() ->getMock(); $this->resourcePageMock = $this->getMockBuilder(PageResource::class) ->disableOriginalConstructor() - ->setMethods(['getIdFieldName', 'checkIdentifier',]) + ->setMethods(['getIdFieldName', 'checkIdentifier']) ->getMock(); $this->eventManagerMock = $this->getMockBuilder(ManagerInterface::class) ->disableOriginalConstructor() From 36ff0dce7b5eabf2e587b457586a161c6935ecc5 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Mon, 25 Apr 2016 15:39:54 +0300 Subject: [PATCH 03/19] MAGETWO-52215: Cms pages isn't synchronized with core_config_data --- app/code/Magento/Cms/Model/Page.php | 21 +++++----- .../Magento/Cms/Test/Unit/Model/PageTest.php | 41 ++++++++++++++++--- 2 files changed, 47 insertions(+), 15 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index b44a9d4cc8711..e52c9ad0632d4 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -11,6 +11,7 @@ use Magento\Framework\DataObject\IdentityInterface; use Magento\Framework\Exception\LocalizedException; use Magento\Framework\Model\AbstractModel; +use Magento\Cms\Helper\Page as PageHelper; /** * Cms Page Model @@ -520,16 +521,16 @@ public function beforeSave() { $originalIdentifier = $this->getOrigData('identifier'); $currentIdentifier = $this->getIdentifier(); - $scopeConfigIdentifier = $this->getScopeConfig()->getValue( - \Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE - ); - - if ( - $this->getId() - && $originalIdentifier !== $currentIdentifier - && $originalIdentifier === $scopeConfigIdentifier - ) { - throw new LocalizedException(__('This identifier is reserved for 404 error page in configuration.')); + + if (!$this->getId() || $originalIdentifier === $currentIdentifier) { + return parent::beforeSave(); + } + + switch ($originalIdentifier) { + case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_ROUTE_PAGE): + throw new LocalizedException(__('This identifier is reserved for 404 error page in configuration.')); + case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_HOME_PAGE): + throw new LocalizedException(__('This identifier is reserved for home page in configuration.')); } return parent::beforeSave(); diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php index 0fbe458ad8d68..2477b7307a9d4 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php @@ -129,11 +129,42 @@ public function testBeforeSave404Identifier() $this->scopeConfigMock->expects($this->once()) ->method('getValue') - ->with( - \Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE, - ScopeConfigInterface::SCOPE_TYPE_DEFAULT, - null - )->willReturn('no-route'); + ->willReturnMap( + [ + [ + \Magento\Cms\Helper\Page::XML_PATH_NO_ROUTE_PAGE, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + 'no-route' + ] + ] + ); + + $this->model->beforeSave(); + } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage This identifier is reserved for home page in configuration. + */ + public function testBeforeSaveHomeIdentifier() + { + $this->model->setId(1); + $this->model->setOrigData('identifier', 'home'); + $this->model->setIdentifier('home2'); + + $this->scopeConfigMock->expects($this->atLeastOnce()) + ->method('getValue') + ->willReturnMap( + [ + [ + \Magento\Cms\Helper\Page::XML_PATH_HOME_PAGE, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + 'home' + ] + ] + ); $this->model->beforeSave(); } From 5b3d23220e5853b56d67329bb70b8b7227357062 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Wed, 27 Apr 2016 13:27:46 +0300 Subject: [PATCH 04/19] MAGETWO-52343: 404 when trying to display product view page (product.info.main container label is missing) #4234 --- .../View/Layout/Generator/Container.php | 15 ++++++++------ .../Unit/Layout/Generator/ContainerTest.php | 20 +++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/lib/internal/Magento/Framework/View/Layout/Generator/Container.php b/lib/internal/Magento/Framework/View/Layout/Generator/Container.php index 5be37817bb411..3ae7146dffb7b 100644 --- a/lib/internal/Magento/Framework/View/Layout/Generator/Container.php +++ b/lib/internal/Magento/Framework/View/Layout/Generator/Container.php @@ -84,12 +84,15 @@ public function generateContainer( $elementName, $options ) { - $structure->setAttribute( - $elementName, - Layout\Element::CONTAINER_OPT_LABEL, - $options[Layout\Element::CONTAINER_OPT_LABEL] - ); - unset($options[Layout\Element::CONTAINER_OPT_LABEL]); + if (isset($options[Layout\Element::CONTAINER_OPT_LABEL])) { + $structure->setAttribute( + $elementName, + Layout\Element::CONTAINER_OPT_LABEL, + $options[Layout\Element::CONTAINER_OPT_LABEL] + ); + unset($options[Layout\Element::CONTAINER_OPT_LABEL]); + } + unset($options['type']); $this->validateOptions($options); diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php index ecbeb99c8d0e9..cabd1b980cf25 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Generator/ContainerTest.php @@ -116,6 +116,26 @@ public function processDataProvider() ['first_container', Container::CONTAINER_OPT_HTML_ID, 'dd_id'], ], 'setAttributeCalls' => 4, + ], + 'sample_data2' => [ + 'structureElements' => [ + 'first_container' => [ + 'container', + [ + 'attributes' => [ + Container::CONTAINER_OPT_HTML_TAG => 'dd', + Container::CONTAINER_OPT_HTML_CLASS => 'dd_class', + Container::CONTAINER_OPT_HTML_ID => 'dd_id', + ] + ], + ], + ], + 'setAttributeData' => [ + ['first_container', Container::CONTAINER_OPT_HTML_TAG, 'dd'], + ['first_container', Container::CONTAINER_OPT_HTML_CLASS, 'dd_class'], + ['first_container', Container::CONTAINER_OPT_HTML_ID, 'dd_id'], + ], + 'setAttributeCalls' => 3, ] ]; } From 82d778983b087649305933fee8bb702857815b31 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Wed, 27 Apr 2016 17:59:33 +0300 Subject: [PATCH 05/19] MAGETWO-52215: Cms pages isn't synchronized with core_config_data --- app/code/Magento/Cms/Model/Page.php | 10 +++++-- .../Magento/Cms/Test/Unit/Model/PageTest.php | 30 +++++++++++++++++-- 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php index e52c9ad0632d4..a7a7184412b79 100644 --- a/app/code/Magento/Cms/Model/Page.php +++ b/app/code/Magento/Cms/Model/Page.php @@ -528,9 +528,15 @@ public function beforeSave() switch ($originalIdentifier) { case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_ROUTE_PAGE): - throw new LocalizedException(__('This identifier is reserved for 404 error page in configuration.')); + throw new LocalizedException( + __('This identifier is reserved for "CMS No Route Page" in configuration.') + ); case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_HOME_PAGE): - throw new LocalizedException(__('This identifier is reserved for home page in configuration.')); + throw new LocalizedException(__('This identifier is reserved for "CMS Home Page" in configuration.')); + case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_COOKIES_PAGE): + throw new LocalizedException( + __('This identifier is reserved for "CMS No Cookies Page" in configuration.') + ); } return parent::beforeSave(); diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php index 2477b7307a9d4..443f2105fea4e 100644 --- a/app/code/Magento/Cms/Test/Unit/Model/PageTest.php +++ b/app/code/Magento/Cms/Test/Unit/Model/PageTest.php @@ -119,7 +119,7 @@ public function testCheckIdentifier() /** * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage This identifier is reserved for 404 error page in configuration. + * @expectedExceptionMessage This identifier is reserved for "CMS No Route Page" in configuration. */ public function testBeforeSave404Identifier() { @@ -145,7 +145,7 @@ public function testBeforeSave404Identifier() /** * @expectedException \Magento\Framework\Exception\LocalizedException - * @expectedExceptionMessage This identifier is reserved for home page in configuration. + * @expectedExceptionMessage This identifier is reserved for "CMS Home Page" in configuration. */ public function testBeforeSaveHomeIdentifier() { @@ -168,4 +168,30 @@ public function testBeforeSaveHomeIdentifier() $this->model->beforeSave(); } + + /** + * @expectedException \Magento\Framework\Exception\LocalizedException + * @expectedExceptionMessage This identifier is reserved for "CMS No Cookies Page" in configuration. + */ + public function testBeforeSaveNoCookiesIdentifier() + { + $this->model->setId(1); + $this->model->setOrigData('identifier', 'no-cookies'); + $this->model->setIdentifier('no-cookies2'); + + $this->scopeConfigMock->expects($this->atLeastOnce()) + ->method('getValue') + ->willReturnMap( + [ + [ + \Magento\Cms\Helper\Page::XML_PATH_NO_COOKIES_PAGE, + ScopeConfigInterface::SCOPE_TYPE_DEFAULT, + null, + 'no-cookies' + ] + ] + ); + + $this->model->beforeSave(); + } } From 3ea7fcbaa4934dea2c7e8e51ffbcf2750db46e79 Mon Sep 17 00:00:00 2001 From: Oleh Posyniak Date: Thu, 28 Apr 2016 17:01:01 +0300 Subject: [PATCH 06/19] MAGETWO-52248: Incorrect Usage of \Magento\Framework\Console\CommandList --- app/code/Magento/Backend/etc/di.xml | 2 +- app/code/Magento/Catalog/etc/di.xml | 2 +- app/code/Magento/Cron/etc/di.xml | 2 +- app/code/Magento/Customer/etc/di.xml | 2 +- app/code/Magento/Deploy/etc/di.xml | 2 +- app/code/Magento/Developer/etc/di.xml | 2 +- app/code/Magento/Indexer/etc/di.xml | 2 +- app/code/Magento/SampleData/etc/di.xml | 2 +- app/code/Magento/Theme/etc/di.xml | 2 +- app/code/Magento/Translation/etc/di.xml | 2 +- app/code/Magento/User/etc/di.xml | 2 +- app/etc/di.xml | 1 + lib/internal/Magento/Framework/Console/Cli.php | 4 ++-- .../Magento/Framework/Console/CommandListInterface.php | 1 + lib/internal/Magento/Framework/Console/README.md | 2 +- 15 files changed, 16 insertions(+), 14 deletions(-) diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 3009bc4e1fc8c..7307bbe09f1b4 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -149,7 +149,7 @@ Magento\Backend\Model\Session\Quote\Storage - + Magento\Backend\Console\Command\CacheEnableCommand diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml index 92f86792a83fa..a747a3ed6021e 100644 --- a/app/code/Magento/Catalog/etc/di.xml +++ b/app/code/Magento/Catalog/etc/di.xml @@ -493,7 +493,7 @@ - + Magento\Catalog\Console\Command\ImagesResizeCommand diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml index d6c924dfb0a46..740eff2aed432 100644 --- a/app/code/Magento/Cron/etc/di.xml +++ b/app/code/Magento/Cron/etc/di.xml @@ -29,7 +29,7 @@ shellBackground - + Magento\Cron\Console\Command\CronCommand diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml index 5a55c0de0b8bd..d08832aedaf55 100644 --- a/app/code/Magento/Customer/etc/di.xml +++ b/app/code/Magento/Customer/etc/di.xml @@ -297,7 +297,7 @@ Magento\Customer\Model\ResourceModel\Visitor - + Magento\Customer\Console\Command\UpgradeHashAlgorithmCommand diff --git a/app/code/Magento/Deploy/etc/di.xml b/app/code/Magento/Deploy/etc/di.xml index b1a9020ce9afd..e1a0295a0fe32 100644 --- a/app/code/Magento/Deploy/etc/di.xml +++ b/app/code/Magento/Deploy/etc/di.xml @@ -13,7 +13,7 @@ - + Magento\Deploy\Console\Command\DeployStaticContentCommand diff --git a/app/code/Magento/Developer/etc/di.xml b/app/code/Magento/Developer/etc/di.xml index f04d55ea8285f..a7fc549a0d993 100644 --- a/app/code/Magento/Developer/etc/di.xml +++ b/app/code/Magento/Developer/etc/di.xml @@ -92,7 +92,7 @@ - + Magento\Developer\Console\Command\DevTestsRunCommand diff --git a/app/code/Magento/Indexer/etc/di.xml b/app/code/Magento/Indexer/etc/di.xml index b29cc6ca71d1a..80b42bd2f72e4 100644 --- a/app/code/Magento/Indexer/etc/di.xml +++ b/app/code/Magento/Indexer/etc/di.xml @@ -43,7 +43,7 @@ type="Magento\Indexer\Model\Processor\CleanCache" sortOrder="10"/> - + Magento\Indexer\Console\Command\IndexerInfoCommand diff --git a/app/code/Magento/SampleData/etc/di.xml b/app/code/Magento/SampleData/etc/di.xml index 961ece0771ba0..2e3d15cf5476d 100644 --- a/app/code/Magento/SampleData/etc/di.xml +++ b/app/code/Magento/SampleData/etc/di.xml @@ -6,7 +6,7 @@ */ --> - + Magento\SampleData\Console\Command\SampleDataDeployCommand diff --git a/app/code/Magento/Theme/etc/di.xml b/app/code/Magento/Theme/etc/di.xml index bfa6f070e4ed4..9cb17d93ab652 100644 --- a/app/code/Magento/Theme/etc/di.xml +++ b/app/code/Magento/Theme/etc/di.xml @@ -98,7 +98,7 @@ Magento\Theme\Model\Design\Proxy - + Magento\Theme\Console\Command\ThemeUninstallCommand diff --git a/app/code/Magento/Translation/etc/di.xml b/app/code/Magento/Translation/etc/di.xml index d842a137e99f2..5ba072594b016 100644 --- a/app/code/Magento/Translation/etc/di.xml +++ b/app/code/Magento/Translation/etc/di.xml @@ -81,7 +81,7 @@ - + Magento\Translation\Console\Command\UninstallLanguageCommand diff --git a/app/code/Magento/User/etc/di.xml b/app/code/Magento/User/etc/di.xml index 678e3209ef9b6..c38140bc7aae3 100644 --- a/app/code/Magento/User/etc/di.xml +++ b/app/code/Magento/User/etc/di.xml @@ -15,7 +15,7 @@ - + Magento\User\Console\UnlockAdminAccountCommand diff --git a/app/etc/di.xml b/app/etc/di.xml index 06c6c4c74272f..243017b2341bd 100755 --- a/app/etc/di.xml +++ b/app/etc/di.xml @@ -149,6 +149,7 @@ + diff --git a/lib/internal/Magento/Framework/Console/Cli.php b/lib/internal/Magento/Framework/Console/Cli.php index 9742acbbd237c..ab03d9f7c503d 100644 --- a/lib/internal/Magento/Framework/Console/Cli.php +++ b/lib/internal/Magento/Framework/Console/Cli.php @@ -122,8 +122,8 @@ protected function getApplicationCommands() } if ($objectManager->get('Magento\Framework\App\DeploymentConfig')->isAvailable()) { - /** @var \Magento\Framework\Console\CommandList $commandList */ - $commandList = $objectManager->create('Magento\Framework\Console\CommandList'); + /** @var \Magento\Framework\Console\CommandListInterface */ + $commandList = $objectManager->create(\Magento\Framework\Console\CommandListInterface::class); $commands = array_merge($commands, $commandList->getCommands()); } diff --git a/lib/internal/Magento/Framework/Console/CommandListInterface.php b/lib/internal/Magento/Framework/Console/CommandListInterface.php index 27970f5809601..8158e253ac3a3 100644 --- a/lib/internal/Magento/Framework/Console/CommandListInterface.php +++ b/lib/internal/Magento/Framework/Console/CommandListInterface.php @@ -7,6 +7,7 @@ /** * Contains a list of Console commands + * @api */ interface CommandListInterface { diff --git a/lib/internal/Magento/Framework/Console/README.md b/lib/internal/Magento/Framework/Console/README.md index b9057127c8891..245b85a27d4ea 100644 --- a/lib/internal/Magento/Framework/Console/README.md +++ b/lib/internal/Magento/Framework/Console/README.md @@ -5,7 +5,7 @@ This component contains Magento Cli and can be extended via DI configuration. For example we can introduce new command in module using di.xml: ``` - + Magento\MyModule\Console\TestMeCommand From fc3e2bf51a08e518610e26cc6420da8bb1ff9ea6 Mon Sep 17 00:00:00 2001 From: Dmytro Poperechnyy Date: Fri, 29 Apr 2016 16:57:11 +0300 Subject: [PATCH 07/19] MAGETWO-52248: Incorrect Usage of \Magento\Framework\Console\CommandList - Added static test to verify that di.xml file has no directly configured CommandList class and CommandListInterface is used instead; --- .../Framework/ObjectManager/DiConfigTest.php | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php index 451b7d4b3d0d0..ce078e9deafb1 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/Magento/Framework/ObjectManager/DiConfigTest.php @@ -50,4 +50,30 @@ public function assertObsoleteFormat($file) 'The node is obsolete. Instead, provide the actual value as a text literal.' ); } + + public function testCommandListClassIsNotDirectlyConfigured() + { + $invoker = new \Magento\Framework\App\Utility\AggregateInvoker($this); + $invoker( + [$this, 'assertCommandListClassIsNotDirectlyConfigured'], + \Magento\Framework\App\Utility\Files::init()->getDiConfigs(true) + ); + } + + /** + * Scan the specified di.xml file and assert that it has no directly configured CommandList class + * + * @param string $file + */ + public function assertCommandListClassIsNotDirectlyConfigured($file) + { + $xml = simplexml_load_file($file); + foreach ($xml->xpath('//type') as $type) { + $this->assertNotContains( + 'Magento\Framework\Console\CommandList', + $type->attributes(), + 'Use \Magento\Framework\Console\CommandListInterface instead of \Magento\Framework\Console\CommandList' + ); + } + } } From f9c8486cf0d47e952c7f4e3e52a1b02ee659e09f Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 5 May 2016 13:06:41 +0300 Subject: [PATCH 08/19] MAGETWO-51921: Error if CMS pages for different store views with identical URL Key #4113 --- .../ProcessUrlRewriteSavingObserver.php | 9 +- .../ProcessUrlRewriteSavingObserverTest.php | 166 ++++++++++++++++++ 2 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php diff --git a/app/code/Magento/CmsUrlRewrite/Observer/ProcessUrlRewriteSavingObserver.php b/app/code/Magento/CmsUrlRewrite/Observer/ProcessUrlRewriteSavingObserver.php index b36cef6c631c4..35d704dad27ef 100644 --- a/app/code/Magento/CmsUrlRewrite/Observer/ProcessUrlRewriteSavingObserver.php +++ b/app/code/Magento/CmsUrlRewrite/Observer/ProcessUrlRewriteSavingObserver.php @@ -9,6 +9,7 @@ use Magento\UrlRewrite\Model\UrlPersistInterface; use Magento\Framework\Event\ObserverInterface; use Magento\CmsUrlRewrite\Model\CmsPageUrlRewriteGenerator; +use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; class ProcessUrlRewriteSavingObserver implements ObserverInterface { @@ -42,8 +43,14 @@ public function execute(EventObserver $observer) { /** @var $cmsPage \Magento\Cms\Model\Page */ $cmsPage = $observer->getEvent()->getObject(); - if ($cmsPage->dataHasChangedFor('identifier')) { + + if ($cmsPage->dataHasChangedFor('identifier') || $cmsPage->dataHasChangedFor('store_id')) { $urls = $this->cmsPageUrlRewriteGenerator->generate($cmsPage); + + $this->urlPersist->deleteByData([ + UrlRewrite::ENTITY_ID => $cmsPage->getId(), + UrlRewrite::ENTITY_TYPE => CmsPageUrlRewriteGenerator::ENTITY_TYPE, + ]); $this->urlPersist->replace($urls); } } diff --git a/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php b/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php new file mode 100644 index 0000000000000..4bc1fa5177e32 --- /dev/null +++ b/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php @@ -0,0 +1,166 @@ +objectManagerHelper = new ObjectManagerHelper($this); + + $this->urlPersistMock = $this->getMockBuilder(UrlPersistInterface::class) + ->getMockForAbstractClass(); + $this->cmsPageUrlRewriteGeneratorMock = $this->getMockBuilder(CmsPageUrlRewriteGenerator::class) + ->disableOriginalConstructor() + ->getMock(); + $this->pageMock = $this->getMockBuilder(Page::class) + ->setMethods(['getId', 'dataHasChangedFor']) + ->disableOriginalConstructor() + ->getMock(); + $this->eventMock = $this->getMockBuilder(Event::class) + ->setMethods(['getObject']) + ->disableOriginalConstructor() + ->getMock(); + $this->eventObserverMock = $this->getMockBuilder(EventObserver::class) + ->disableOriginalConstructor() + ->getMock(); + + $this->eventObserverMock->expects($this->once()) + ->method('getEvent') + ->willReturn($this->eventMock); + $this->eventMock->expects($this->once()) + ->method('getObject') + ->willReturn($this->pageMock); + + + $this->observer = $this->objectManagerHelper->getObject( + ProcessUrlRewriteSavingObserver::class, + [ + 'cmsPageUrlRewriteGenerator' => $this->cmsPageUrlRewriteGeneratorMock, + 'urlPersist' => $this->urlPersistMock, + ] + ); + } + + /** + * @param bool $identifierChanged + * @param bool $storeIdChanged + * @return void + * @dataProvider executeDataProvider + */ + public function testExecute($identifierChanged, $storeIdChanged) + { + $pageId = 1; + $urls = ['first url', 'second url']; + + $this->pageMock->expects($this->any()) + ->method('dataHasChangedFor') + ->willReturnMap([ + ['identifier', $identifierChanged], + ['store_id', $storeIdChanged], + ]); + $this->pageMock->expects($this->once()) + ->method('getId') + ->willReturn($pageId); + $this->cmsPageUrlRewriteGeneratorMock->expects($this->once()) + ->method('generate') + ->with($this->pageMock) + ->willReturn($urls); + $this->urlPersistMock->expects($this->once()) + ->method('deleteByData') + ->with([ + UrlRewrite::ENTITY_ID => $pageId, + UrlRewrite::ENTITY_TYPE => CmsPageUrlRewriteGenerator::ENTITY_TYPE, + ]); + $this->urlPersistMock->expects($this->once()) + ->method('replace') + ->with($urls); + + $this->observer->execute($this->eventObserverMock); + } + + /** + * return array + */ + public function executeDataProvider() + { + return [ + ['identifier' => true, 'storeIdChanged' => true], + ['identifier' => true, 'storeIdChanged' => false], + ['identifier' => false, 'storeIdChanged' => true], + ]; + } + + /** + * @return void + */ + public function testExecuteWithoutDataChanged() + { + $this->pageMock->expects($this->any()) + ->method('dataHasChangedFor') + ->willReturnMap([ + ['identifier', false], + ['store_id', false], + ]); + $this->pageMock->expects($this->never()) + ->method('getId'); + $this->cmsPageUrlRewriteGeneratorMock->expects($this->never()) + ->method('generate'); + $this->urlPersistMock->expects($this->never()) + ->method('deleteByData'); + $this->urlPersistMock->expects($this->never()) + ->method('replace'); + + $this->observer->execute($this->eventObserverMock); + } +} From f3598cd1f90d07ac96589a926b3d66c2b6f0896d Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Thu, 5 May 2016 13:33:15 +0300 Subject: [PATCH 09/19] MAGETWO-51921: Error if CMS pages for different store views with identical URL Key #4113 --- .../Unit/Observer/ProcessUrlRewriteSavingObserverTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php b/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php index 4bc1fa5177e32..c4c1093bd385d 100644 --- a/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php +++ b/app/code/Magento/CmsUrlRewrite/Test/Unit/Observer/ProcessUrlRewriteSavingObserverTest.php @@ -14,6 +14,9 @@ use Magento\Cms\Model\Page; use Magento\UrlRewrite\Service\V1\Data\UrlRewrite; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class ProcessUrlRewriteSavingObserverTest extends \PHPUnit_Framework_TestCase { /** @@ -82,7 +85,6 @@ protected function setUp() ->method('getObject') ->willReturn($this->pageMock); - $this->observer = $this->objectManagerHelper->getObject( ProcessUrlRewriteSavingObserver::class, [ From 173fbd959b8206da9eb05ea3bbf361f06f188a19 Mon Sep 17 00:00:00 2001 From: Bohdan Korablov Date: Fri, 6 May 2016 13:38:11 +0300 Subject: [PATCH 10/19] MAGETWO-52386: JS validation is absent for "Configurations" and "Images And Videos" panels --- .../adminhtml/layout/catalog_product_form.xml | 5 ++++ .../catalog/product/helper/gallery.phtml | 4 +++ .../view/adminhtml/web/js/product-gallery.js | 29 ++++++++++++++++++- .../adminhtml/layout/catalog_product_form.xml | 5 ++++ .../adminhtml/templates/helper/gallery.phtml | 4 +++ 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml index 8c57cbde72aa1..bdcd5da65bbea 100644 --- a/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/layout/catalog_product_form.xml @@ -21,6 +21,11 @@ + + + product_form.product_form.block_gallery.block_gallery + + diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml index 5ffd25a41f3af..c39965659520e 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/helper/gallery.phtml @@ -9,10 +9,14 @@ /** @var $block \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Gallery\Content */ $elementName = $block->getElement()->getName() . '[images]'; $formName = $block->getFormName(); +$parentComponent = $block->getData('config/parentComponent') + ? 'data-parent-component="' . $block->getData('config/parentComponent') . '"' + : ''; ?>