diff --git a/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php b/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php index 6d65d43ef4a9ce4e9e4a72d4ea9c756d7b8408c7..83b1f1c8958831d3b0daa6eeb4c9b71b40a68e05 100644 --- a/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php +++ b/app/code/Magento/Backend/Test/Unit/Model/Menu/Filter/IteratorTest.php @@ -12,11 +12,6 @@ class IteratorTest extends \PHPUnit_Framework_TestCase */ protected $_menuModel; - /** - * @var \Magento\Backend\Model\Menu\Filter\Iterator - */ - protected $_filterIteratorModel; - /** * @var \Magento\Backend\Model\Menu\Item[] */ @@ -42,9 +37,6 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $loggerMock = $this->getMock('Psr\Log\LoggerInterface'); $this->_menuModel = new \Magento\Backend\Model\Menu($loggerMock); - $this->_filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( - $this->_menuModel->getIterator() - ); } public function testLoopWithAllItemsDisabledDoesntIterate() @@ -54,8 +46,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); + $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(0, $items); @@ -70,9 +66,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); @@ -88,9 +87,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); @@ -106,9 +108,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); @@ -125,9 +130,12 @@ class IteratorTest extends \PHPUnit_Framework_TestCase $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); $this->_menuModel->add($this->getMock('Magento\Backend\Model\Menu\Item', [], [], '', false)); + $filterIteratorModel = new \Magento\Backend\Model\Menu\Filter\Iterator( + $this->_menuModel->getIterator() + ); $items = []; - foreach ($this->_filterIteratorModel as $item) { + foreach ($filterIteratorModel as $item) { $items[] = $item; } $this->assertCount(1, $items); diff --git a/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php index d004784f72e0c5834889b949ba51e9f2e5d15fad..8ea0563b44b9fc26f41bf8385fc0402b1604587b 100644 --- a/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/CategoryAttributeInterface.php @@ -9,6 +9,4 @@ namespace Magento\Catalog\Api\Data; interface CategoryAttributeInterface extends \Magento\Catalog\Api\Data\EavAttributeInterface { const ENTITY_TYPE_CODE = 'catalog_category'; - - const DEFAULT_ATTRIBUTE_SET_ID = 3; } diff --git a/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php b/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php index a6ec3a93a7d2f81c5aec4803515df9525c0a28bb..7ebf031245f8487597af670ed8c88446161c2e8a 100644 --- a/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php +++ b/app/code/Magento/Catalog/Api/Data/ProductAttributeInterface.php @@ -9,6 +9,4 @@ namespace Magento\Catalog\Api\Data; interface ProductAttributeInterface extends \Magento\Catalog\Api\Data\EavAttributeInterface { const ENTITY_TYPE_CODE = 'catalog_product'; - - const DEFAULT_ATTRIBUTE_SET_ID = 4; } diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php index befec2129c66c23d71061597defe3af86ec77b46..e22d3b2dcd39a2a8ad3138842d69d418ff8df874 100644 --- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php +++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Validate.php @@ -9,6 +9,11 @@ namespace Magento\Catalog\Controller\Adminhtml\Product; use Magento\Backend\App\Action; use Magento\Catalog\Controller\Adminhtml\Product; +/** + * Product validate + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product { /** @@ -31,6 +36,9 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product */ protected $layoutFactory; + /** @var \Magento\Catalog\Model\ProductFactory */ + protected $productFactory; + /** * @param Action\Context $context * @param Builder $productBuilder @@ -38,6 +46,7 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product * @param \Magento\Catalog\Model\Product\Validator $productValidator * @param \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory * @param \Magento\Framework\View\LayoutFactory $layoutFactory + * @param \Magento\Catalog\Model\ProductFactory $productFactory */ public function __construct( \Magento\Backend\App\Action\Context $context, @@ -45,13 +54,15 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product \Magento\Framework\Stdlib\DateTime\Filter\Date $dateFilter, \Magento\Catalog\Model\Product\Validator $productValidator, \Magento\Framework\Controller\Result\JSONFactory $resultJsonFactory, - \Magento\Framework\View\LayoutFactory $layoutFactory + \Magento\Framework\View\LayoutFactory $layoutFactory, + \Magento\Catalog\Model\ProductFactory $productFactory ) { $this->_dateFilter = $dateFilter; $this->productValidator = $productValidator; parent::__construct($context, $productBuilder); $this->resultJsonFactory = $resultJsonFactory; $this->layoutFactory = $layoutFactory; + $this->productFactory = $productFactory; } /** @@ -73,13 +84,13 @@ class Validate extends \Magento\Catalog\Controller\Adminhtml\Product $productData['stock_data']['use_config_manage_stock'] = 0; } /* @var $product \Magento\Catalog\Model\Product */ - $product = $this->_objectManager->create('Magento\Catalog\Model\Product'); + $product = $this->productFactory->create(); $product->setData('_edit_mode', true); $storeId = $this->getRequest()->getParam('store'); if ($storeId) { $product->setStoreId($storeId); } - $setId = $this->getRequest()->getParam('set'); + $setId = $this->getRequest()->getPost('set'); if ($setId) { $product->setAttributeSetId($setId); } diff --git a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php index bf52fc7acb6dc2c02ae364cc603460edb96c2d58..7538322e36920ec192f3b49607c6a96d7278524d 100644 --- a/app/code/Magento/Catalog/Model/Category/AttributeRepository.php +++ b/app/code/Magento/Catalog/Model/Category/AttributeRepository.php @@ -24,22 +24,30 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface */ protected $eavAttributeRepository; + /** + * @var \Magento\Eav\Model\Config + */ + protected $eavConfig; + /** * @param \Magento\Framework\Api\Config\MetadataConfig $metadataConfig * @param \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository + * @param \Magento\Eav\Model\Config $eavConfig */ public function __construct( \Magento\Framework\Api\Config\MetadataConfig $metadataConfig, \Magento\Framework\Api\SearchCriteriaBuilder $searchCriteriaBuilder, \Magento\Framework\Api\FilterBuilder $filterBuilder, - \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository + \Magento\Eav\Api\AttributeRepositoryInterface $eavAttributeRepository, + \Magento\Eav\Model\Config $eavConfig ) { $this->metadataConfig = $metadataConfig; $this->searchCriteriaBuilder = $searchCriteriaBuilder; $this->filterBuilder = $filterBuilder; $this->eavAttributeRepository = $eavAttributeRepository; + $this->eavConfig = $eavConfig; } /** @@ -69,11 +77,14 @@ class AttributeRepository implements CategoryAttributeRepositoryInterface */ public function getCustomAttributesMetadata($dataObjectClassName = null) { + $defaultAttributeSetId = $this->eavConfig + ->getEntityType(\Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE) + ->getDefaultAttributeSetId(); $searchCriteria = $this->searchCriteriaBuilder->addFilter( [ $this->filterBuilder ->setField('attribute_set_id') - ->setValue(\Magento\Catalog\Api\Data\CategoryAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->setValue($defaultAttributeSetId) ->create(), ] ); diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php index 6bbae5a2350c1005e73cbb8abf46f7ae87ef6159..03799df3732029c155c4c182a649d4b4df429575 100644 --- a/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php +++ b/app/code/Magento/Catalog/Model/Product/Attribute/Repository.php @@ -216,11 +216,14 @@ class Repository implements \Magento\Catalog\Api\ProductAttributeRepositoryInter */ public function getCustomAttributesMetadata($dataObjectClassName = null) { + $defaultAttributeSetId = $this->eavConfig + ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) + ->getDefaultAttributeSetId(); $searchCriteria = $this->searchCriteriaBuilder->addFilter( [ $this->filterBuilder ->setField('attribute_set_id') - ->setValue(\Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->setValue($defaultAttributeSetId) ->create(), ] ); diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php index 051681c4c319186a54020a6d0e1a9744cfb8d9d4..5bdcebfbe9b1b41e31728fee08067265fe038858 100644 --- a/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php +++ b/app/code/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFile.php @@ -150,7 +150,6 @@ class ValidatorFile extends Validator $upload->addFilter(new \Zend_Filter_File_Rename(['target' => $fileFullPath, 'overwrite' => true])); - // TODO: I don't know how change this if (!is_null($this->product)) { $this->product->getTypeInstance()->addFileQueue( [ diff --git a/app/code/Magento/Catalog/Model/ProductRepository.php b/app/code/Magento/Catalog/Model/ProductRepository.php index a42e163a2b0b6ee5d0f3c037c9efc102e4c3917e..c401e56db17c410b16b49a4e8d201f9b598d02b6 100644 --- a/app/code/Magento/Catalog/Model/ProductRepository.php +++ b/app/code/Magento/Catalog/Model/ProductRepository.php @@ -71,6 +71,11 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa */ protected $metadataService; + /** + * @var \Magento\Eav\Model\Config + */ + protected $eavConfig; + /** * @param ProductFactory $productFactory * @param \Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper $initializationHelper @@ -81,6 +86,8 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa * @param Resource\Product $resourceModel * @param \Magento\Framework\Api\FilterBuilder $filterBuilder * @param \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataServiceInterface + * @param \Magento\Eav\Model\Config $eavConfig + * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ public function __construct( ProductFactory $productFactory, @@ -91,7 +98,8 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa \Magento\Catalog\Api\ProductAttributeRepositoryInterface $attributeRepository, \Magento\Catalog\Model\Resource\Product $resourceModel, \Magento\Framework\Api\FilterBuilder $filterBuilder, - \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataServiceInterface + \Magento\Catalog\Api\ProductAttributeRepositoryInterface $metadataServiceInterface, + \Magento\Eav\Model\Config $eavConfig ) { $this->productFactory = $productFactory; $this->collectionFactory = $collectionFactory; @@ -102,6 +110,7 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa $this->attributeRepository = $attributeRepository; $this->filterBuilder = $filterBuilder; $this->metadataService = $metadataServiceInterface; + $this->eavConfig = $eavConfig; } /** @@ -261,12 +270,14 @@ class ProductRepository implements \Magento\Catalog\Api\ProductRepositoryInterfa { /** @var \Magento\Catalog\Model\Resource\Product\Collection $collection */ $collection = $this->collectionFactory->create(); - + $defaultAttributeSetId = $this->eavConfig + ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE) + ->getDefaultAttributeSetId(); $extendedSearchCriteria = $this->searchCriteriaBuilder->addFilter( [ $this->filterBuilder ->setField('attribute_set_id') - ->setValue(\Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->setValue($defaultAttributeSetId) ->create(), ] ); diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php new file mode 100644 index 0000000000000000000000000000000000000000..2de489fa7a9e3a5eff966359a1dd3e5eb3e65e09 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Product/ValidateTest.php @@ -0,0 +1,140 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Test\Unit\Controller\Adminhtml\Product; + +use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; + +class ValidateTest extends \Magento\Catalog\Test\Unit\Controller\Adminhtml\ProductTest +{ + /** @var \Magento\Catalog\Controller\Adminhtml\Product\Validate */ + protected $action; + /** @var \Magento\Backend\Model\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultPage; + /** @var \Magento\Backend\Model\View\Result\Forward|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultForward; + /** @var \Magento\Catalog\Controller\Adminhtml\Product\Builder|\PHPUnit_Framework_MockObject_MockObject */ + protected $productBuilder; + /** @var \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject */ + protected $product; + /** @var \Magento\Backend\Model\View\Result\RedirectFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultRedirectFactory; + /** @var \Magento\Backend\Model\View\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultRedirect; + /** @var Helper|\PHPUnit_Framework_MockObject_MockObject */ + protected $initializationHelper; + /** @var \Magento\Catalog\Model\ProductFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $productFactory; + /** @var \Magento\Framework\Controller\Result\JSON|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultJson; + /** @var \Magento\Framework\Controller\Result\JSONFactory|\PHPUnit_Framework_MockObject_MockObject */ + protected $resultJsonFactory; + + protected function setUp() + { + $this->productBuilder = $this->getMock( + 'Magento\Catalog\Controller\Adminhtml\Product\Builder', + ['build'], + [], + '', + false + ); + $this->product = $this->getMockBuilder('Magento\Catalog\Model\Product')->disableOriginalConstructor() + ->setMethods([ + 'addData', 'getSku', 'getTypeId', 'getStoreId', '__sleep', '__wakeup', 'getAttributes', + 'setAttributeSetId', + ]) + ->getMock(); + $this->product->expects($this->any())->method('getTypeId')->will($this->returnValue('simple')); + $this->product->expects($this->any())->method('getStoreId')->will($this->returnValue('1')); + $this->product->expects($this->any())->method('getAttributes')->will($this->returnValue([])); + $this->productBuilder->expects($this->any())->method('build')->will($this->returnValue($this->product)); + + $this->resultPage = $this->getMockBuilder('Magento\Backend\Model\View\Result\Page') + ->disableOriginalConstructor() + ->getMock(); + + $resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $resultPageFactory->expects($this->any())->method('create')->willReturn($this->resultPage); + + $this->resultForward = $this->getMockBuilder('Magento\Backend\Model\View\Result\Forward') + ->disableOriginalConstructor() + ->getMock(); + $resultForwardFactory = $this->getMockBuilder('Magento\Backend\Model\View\Result\ForwardFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $resultForwardFactory->expects($this->any()) + ->method('create') + ->willReturn($this->resultForward); + $this->resultPage->expects($this->any())->method('getLayout')->willReturn($this->layout); + $this->resultRedirectFactory = $this->getMock( + 'Magento\Backend\Model\View\Result\RedirectFactory', + ['create'], + [], + '', + false + ); + $this->resultRedirect = $this->getMock( + 'Magento\Backend\Model\View\Result\Redirect', + [], + [], + '', + false + ); + $this->resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirect); + + $this->initializationHelper = $this->getMock( + 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper', + [], + [], + '', + false + ); + + $this->productFactory = $this->getMockBuilder('Magento\Catalog\Model\ProductFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->productFactory->expects($this->any())->method('create')->willReturn($this->product); + + $this->resultJson = $this->getMock('Magento\Framework\Controller\Result\JSON', [], [], '', false); + $this->resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') + ->disableOriginalConstructor() + ->setMethods(['create']) + ->getMock(); + $this->resultJsonFactory->expects($this->any())->method('create')->willReturn($this->resultJson); + + $this->action = (new ObjectManagerHelper($this))->getObject( + 'Magento\Catalog\Controller\Adminhtml\Product\Validate', + [ + 'context' => $this->initContext(), + 'productBuilder' => $this->productBuilder, + 'resultPageFactory' => $resultPageFactory, + 'resultForwardFactory' => $resultForwardFactory, + 'resultRedirectFactory' => $this->resultRedirectFactory, + 'initializationHelper' => $this->initializationHelper, + 'resultJsonFactory' => $this->resultJsonFactory, + 'productFactory' => $this->productFactory, + ] + ); + } + + /** + * @return void + */ + public function testAttributeSetIsObtainedFromPost() + { + $this->request->expects($this->any())->method('getPost')->willReturnMap([['set', null, 9]]); + + $this->product->expects($this->once())->method('setAttributeSetId')->with(9); + + $this->action->execute(); + } +} diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php index 0deb8c5810accfe642978c0b698292da42b0ba71..3e04c8a0c27f345cb2ef5892098f65a04f61b667 100644 --- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/ProductTest.php @@ -41,7 +41,7 @@ abstract class ProductTest extends \PHPUnit_Framework_TestCase ->setMethods(['add'])->disableOriginalConstructor()->getMock(); $title->expects($this->any())->method('prepend')->withAnyParameters()->will($this->returnSelf()); $requestInterfaceMock = $this->getMockBuilder('Magento\Framework\App\Request\Http')->setMethods( - ['getParam', 'getFullActionName', 'getPostValue'] + ['getParam', 'getPost', 'getFullActionName', 'getPostValue'] )->disableOriginalConstructor()->getMock(); $responseInterfaceMock = $this->getMockBuilder('Magento\Framework\App\ResponseInterface')->setMethods( diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php index e5948f941ab03c593376010814923b26705c193b..ffba8e8113717a370bd4cd1823ce7dd16136f3c7 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Category/AttributeRepositoryTest.php @@ -9,7 +9,8 @@ namespace Magento\Catalog\Test\Unit\Model\Category; -use \Magento\Catalog\Model\Category\AttributeRepository; +use Magento\Catalog\Model\Category\AttributeRepository; +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase { @@ -43,6 +44,11 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $searchResultMock; + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfigMock; + protected function setUp() { $this->searchBuilderMock = @@ -63,16 +69,23 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase 'setItems', 'setSearchCriteria', 'setTotalCount', - '__wakeup' + '__wakeup', ], [], '', false); - $this->model = new AttributeRepository( - $this->metadataConfigMock, - $this->searchBuilderMock, - $this->filterBuilderMock, - $this->attributeRepositoryMock + $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock->expects($this->any())->method('getEntityType') + ->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 3])); + $this->model = (new ObjectManager($this))->getObject( + 'Magento\Catalog\Model\Category\AttributeRepository', + [ + 'metadataConfig' => $this->metadataConfigMock, + 'searchCriteriaBuilder' => $this->searchBuilderMock, + 'filterBuilder' => $this->filterBuilderMock, + 'eavAttributeRepository' => $this->attributeRepositoryMock, + 'eavConfig' => $this->eavConfigMock, + ] ); } @@ -106,7 +119,7 @@ class AttributeRepositoryTest extends \PHPUnit_Framework_TestCase $this->filterBuilderMock->expects($this->once())->method('setField') ->with('attribute_set_id')->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('setValue')->with( - \Magento\Catalog\Api\Data\CategoryAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID + 3 )->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock])->willReturnSelf(); diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php index e738b7e96bfeee4c68abcb87a6f07cfeffdf56fe..96744e487a0ddc76ed0ae8121e46e2233a152606 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Attribute/RepositoryTest.php @@ -79,6 +79,8 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase $this->eavAttributeRepositoryMock = $this->getMock('Magento\Eav\Api\AttributeRepositoryInterface', [], [], '', false); $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock->expects($this->any())->method('getEntityType') + ->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4])); $this->validatorFactoryMock = $this->getMock( 'Magento\Eav\Model\Adminhtml\System\Config\Source\Inputtype\ValidatorFactory', [], @@ -101,7 +103,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase 'setItems', 'setSearchCriteria', 'setTotalCount', - '__wakeup' + '__wakeup', ], [], '', @@ -177,9 +179,7 @@ class RepositoryTest extends \PHPUnit_Framework_TestCase ->willReturnSelf(); $this->filterBuilderMock->expects($this->once()) ->method('setValue') - ->with( - \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID - ) + ->with(4) ->willReturnSelf(); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->searchCriteriaBuilderMock->expects($this->once()) diff --git a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php index 33e3305cefa18a734566e56cfb55cd3d2985949e..4a9f671bcdb570bb3a26900d7b66aa7482bb84e9 100644 --- a/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Model/ProductRepositoryTest.php @@ -60,6 +60,11 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase */ protected $searchResultsFactoryMock; + /** + * @var \Magento\Eav\Model\Config|\PHPUnit_Framework_MockObject_MockObject + */ + protected $eavConfigMock; + /** * @var array data to create product */ @@ -114,6 +119,9 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase false ); $this->resourceModelMock = $this->getMock('\Magento\Catalog\Model\Resource\Product', [], [], '', false); + $this->eavConfigMock = $this->getMock('Magento\Eav\Model\Config', [], [], '', false); + $this->eavConfigMock->expects($this->any())->method('getEntityType') + ->willReturn(new \Magento\Framework\Object(['default_attribute_set_id' => 4])); $this->objectManager = new ObjectManager($this); $this->model = $this->objectManager->getObject( @@ -126,7 +134,8 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase 'collectionFactory' => $this->collectionFactoryMock, 'searchCriteriaBuilder' => $this->searchCriteriaBuilderMock, 'metadataServiceInterface' => $this->metadataServiceMock, - 'searchResultsFactory' => $this->searchResultsFactoryMock + 'searchResultsFactory' => $this->searchResultsFactoryMock, + 'eavConfig' => $this->eavConfigMock, ] ); } @@ -392,7 +401,7 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase ->will($this->returnSelf()); $this->filterBuilderMock->expects($this->once())->method('create')->willReturn($filterMock); $this->filterBuilderMock->expects($this->once())->method('setValue') - ->with(\Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID) + ->with(4) ->willReturn($this->filterBuilderMock); $this->searchCriteriaBuilderMock->expects($this->once())->method('addFilter')->with([$filterMock]) ->willReturn($searchCriteriaBuilderMock); @@ -461,44 +470,44 @@ class ProductRepositoryTest extends \PHPUnit_Framework_TestCase [ 'identifier' => 'test-sku', 'editMode' => false, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 25, 'editMode' => false, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 25, 'editMode' => true, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 'test-sku', 'editMode' => true, - 'storeId' => null + 'storeId' => null, ], [ 'identifier' => 25, 'editMode' => true, - 'storeId' => $anyObject + 'storeId' => $anyObject, ], [ 'identifier' => 'test-sku', 'editMode' => true, - 'storeId' => $anyObject + 'storeId' => $anyObject, ], [ 'identifier' => 25, 'editMode' => false, - 'storeId' => $anyObject + 'storeId' => $anyObject, ], [ 'identifier' => 'test-sku', 'editMode' => false, - 'storeId' => $anyObject - ] + 'storeId' => $anyObject, + ], ]; } } diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml index f56ab28a4b7cf8d1fd1271c769f51860b233cf4e..999e11608c9218837b8b8ddec5f542c9afb84431 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/checkboxes/tree.phtml @@ -13,10 +13,11 @@ <script> require([ + 'jquery', "prototype", "extjs/ext-tree-checkbox", "mage/adminhtml/form" - ], function(){ + ], function(jQuery){ //<![CDATA[ @@ -69,7 +70,7 @@ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, { } }); -Ext.onReady(function() +jQuery(function() { var categoryLoader = new Ext.tree.TreeLoader({ dataUrl: '<?php echo $block->getLoadTreeUrl() ?>' diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml index 11ee3d968ae71456177951cdbcd337a4eef7aab5..f80c4d2ac53cdf71f504450e1c6b74ce4cff440a 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/tree.phtml @@ -276,7 +276,7 @@ function _renderNewTree(config, scopeParams) { //updateContent(url); //commented since ajax requests replaced with http ones to load a category } -Ext.onReady(function () { +jQuery(function () { categoryLoader = new Ext.tree.TreeLoader({ dataUrl:'<?php echo $block->getLoadTreeUrl() ?>' }); diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml index 45dcffcf34afd2c03acc10c4fbc56f17320d648f..c578a7e5e17b2dadf607f62421daefcc24ba8866 100644 --- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml +++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/category/widget/tree.phtml @@ -12,7 +12,7 @@ <div id="<?php echo $_divId ?>" class="tree"></div> <script> -require(["prototype", "extjs/ext-tree-checkbox"], function(){ +require(['jquery', "prototype", "extjs/ext-tree-checkbox"], function(jQuery){ var tree<?php echo $block->getId() ?>; @@ -54,7 +54,7 @@ Ext.extend(Ext.tree.TreePanel.Enhanced, Ext.tree.TreePanel, { } }); -Ext.onReady(function() +jQuery(function() { var emptyNodeAdded = <?php echo($block->getWithEmptyNode() ? 'false' : 'true') ?>; diff --git a/app/code/Magento/Checkout/Block/Cart/EmptyCart.php b/app/code/Magento/Checkout/Block/Cart/EmptyCart.php new file mode 100644 index 0000000000000000000000000000000000000000..75928dc465489f8df30e1f465471ed0f5d30f0d0 --- /dev/null +++ b/app/code/Magento/Checkout/Block/Cart/EmptyCart.php @@ -0,0 +1,39 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Checkout\Block\Cart; + +class EmptyCart extends \Magento\Checkout\Block\Cart +{ + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Checkout\Model\Session $checkoutSession + * @param \Magento\Catalog\Model\Resource\Url $catalogUrlBuilder + * @param \Magento\Checkout\Helper\Cart $cartHelper + * @param \Magento\Framework\App\Http\Context $httpContext + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Customer\Model\Session $customerSession, + \Magento\Checkout\Model\Session $checkoutSession, + \Magento\Catalog\Model\Resource\Url $catalogUrlBuilder, + \Magento\Checkout\Helper\Cart $cartHelper, + \Magento\Framework\App\Http\Context $httpContext, + array $data = [] + ) { + parent::__construct( + $context, + $customerSession, + $checkoutSession, + $catalogUrlBuilder, + $cartHelper, + $httpContext, + $data + ); + $this->_isScopePrivate = false; + } +} diff --git a/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php new file mode 100644 index 0000000000000000000000000000000000000000..867be6583a61e8c17cdc5809dcf2d040a3c8cdfb --- /dev/null +++ b/app/code/Magento/Checkout/Block/Cart/ValidationMessages.php @@ -0,0 +1,107 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Checkout\Block\Cart; + +/** + * Shopping cart validation messages block + */ +class ValidationMessages extends \Magento\Framework\View\Element\Messages +{ + /** @var \Magento\Checkout\Helper\Cart */ + protected $cartHelper; + + /** @var \Magento\Framework\Locale\CurrencyInterface */ + protected $currency; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Framework\Message\Factory $messageFactory + * @param \Magento\Framework\Message\CollectionFactory $collectionFactory + * @param \Magento\Framework\Message\ManagerInterface $messageManager + * @param \Magento\Checkout\Helper\Cart $cartHelper + * @param \Magento\Framework\Locale\CurrencyInterface $currency + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Framework\Message\Factory $messageFactory, + \Magento\Framework\Message\CollectionFactory $collectionFactory, + \Magento\Framework\Message\ManagerInterface $messageManager, + \Magento\Checkout\Helper\Cart $cartHelper, + \Magento\Framework\Locale\CurrencyInterface $currency, + array $data = [] + ) { + parent::__construct( + $context, + $messageFactory, + $collectionFactory, + $messageManager, + $data + ); + $this->cartHelper = $cartHelper; + $this->currency = $currency; + $this->_isScopePrivate = true; + } + + /** + * @return $this + */ + protected function _prepareLayout() + { + if ($this->cartHelper->getItemsCount()) { + $this->validateMinimunAmount(); + $this->addQuoteMessages(); + return parent::_prepareLayout(); + } + return $this; + } + + /** + * Validate minimum amount and display notice in error + * + * @return void + */ + public function validateMinimunAmount() + { + if (!$this->cartHelper->getQuote()->validateMinimumAmount()) { + $warning = $this->_scopeConfig->getValue( + 'sales/minimum_order/description', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ); + if (!$warning) { + $currencyCode = $this->_storeManager->getStore()->getCurrentCurrencyCode(); + $minimumAmount = $this->currency->getCurrency($currencyCode)->toCurrency( + $this->_scopeConfig->getValue( + 'sales/minimum_order/amount', + \Magento\Store\Model\ScopeInterface::SCOPE_STORE + ) + ); + $warning = __('Minimum order amount is %1', $minimumAmount); + } + $this->messageManager->addNotice($warning); + } + } + + /** + * Add quote messages + * + * @return void + */ + public function addQuoteMessages() + { + // Compose array of messages to add + $messages = []; + /** @var \Magento\Framework\Message\MessageInterface $message */ + foreach ($this->cartHelper->getQuote()->getMessages() as $message) { + if ($message) { + // Escape HTML entities in quote message to prevent XSS + $message->setText($this->escapeHtml($message->getText())); + $messages[] = $message; + } + } + $this->messageManager->addUniqueMessages($messages); + } +} diff --git a/app/code/Magento/Checkout/Controller/Cart/Add.php b/app/code/Magento/Checkout/Controller/Cart/Add.php index d9cf864bd356fc02a1d18210cb4c451a523158da..69aa88b0b3dc81e75993c2e7fb99689b175b71a4 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Add.php +++ b/app/code/Magento/Checkout/Controller/Cart/Add.php @@ -108,8 +108,6 @@ class Add extends \Magento\Checkout\Controller\Cart $this->cart->save(); - $this->_checkoutSession->setCartWasUpdated(true); - /** * @todo remove wishlist observer processAddToCart */ diff --git a/app/code/Magento/Checkout/Controller/Cart/Addgroup.php b/app/code/Magento/Checkout/Controller/Cart/Addgroup.php index 3ee2d8c653078e84c9dd5b5beae9c844ccf4bb11..f3f8a349b6a80948ca037c6387c91c10aec3bf71 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Addgroup.php +++ b/app/code/Magento/Checkout/Controller/Cart/Addgroup.php @@ -36,7 +36,6 @@ class Addgroup extends \Magento\Checkout\Controller\Cart } } $this->cart->save(); - $this->_checkoutSession->setCartWasUpdated(true); } return $this->_goBack(); } diff --git a/app/code/Magento/Checkout/Controller/Cart/CouponPost.php b/app/code/Magento/Checkout/Controller/Cart/CouponPost.php index 92541c821e5162613938ceb03334e47cc89540fd..26225b39fa6f9732cb5562c4ffda4d28c0f7eacd 100644 --- a/app/code/Magento/Checkout/Controller/Cart/CouponPost.php +++ b/app/code/Magento/Checkout/Controller/Cart/CouponPost.php @@ -94,6 +94,7 @@ class CouponPost extends \Magento\Checkout\Controller\Cart $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($couponCode) ) ); + $this->cart->save(); } } else { $this->messageManager->addSuccess(__('The coupon code was canceled.')); diff --git a/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php b/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php index 1a9f88450bf2ff1f047d518aaf80efa57513e9b5..88a1d46d971e69146a4b0f40ff2fb4fe19c3d9d3 100644 --- a/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php +++ b/app/code/Magento/Checkout/Controller/Cart/EstimatePost.php @@ -68,6 +68,7 @@ class EstimatePost extends \Magento\Checkout\Controller\Cart ->setRegion($region) ->setCollectShippingRates(true); $this->quoteRepository->save($this->cart->getQuote()); + $this->cart->save(); return $this->_goBack(); } } diff --git a/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php b/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php index 4f873d1e10254ecbfeafbb8003dcf8f0438f2f2e..0dcd81a8e01856f4aa677f79362d4db96b732233 100644 --- a/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php +++ b/app/code/Magento/Checkout/Controller/Cart/EstimateUpdatePost.php @@ -16,6 +16,7 @@ class EstimateUpdatePost extends \Magento\Checkout\Controller\Cart $code = (string)$this->getRequest()->getParam('estimate_method'); if (!empty($code)) { $this->cart->getQuote()->getShippingAddress()->setShippingMethod($code)->save(); + $this->cart->save(); } return $this->_goBack(); } diff --git a/app/code/Magento/Checkout/Controller/Cart/Index.php b/app/code/Magento/Checkout/Controller/Cart/Index.php index 41d6d95cb0ba57fa3f72d32fa6af8f4adeb63660..8a29029fd18365c618a3c0f5fede9a0edfd7a0d1 100644 --- a/app/code/Magento/Checkout/Controller/Cart/Index.php +++ b/app/code/Magento/Checkout/Controller/Cart/Index.php @@ -5,8 +5,6 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Checkout\Controller\Cart; class Index extends \Magento\Checkout\Controller\Cart @@ -55,62 +53,9 @@ class Index extends \Magento\Checkout\Controller\Cart */ public function execute() { - $this->_eventManager->dispatch('collect_totals_failed_items'); - if ($this->cart->getQuote()->getItemsCount()) { - $this->cart->init(); - $this->cart->save(); - - if (!$this->cart->getQuote()->validateMinimumAmount()) { - $currencyCode = $this->_objectManager->get('Magento\Store\Model\StoreManagerInterface') - ->getStore() - ->getCurrentCurrencyCode(); - $minimumAmount = $this->_objectManager->get('Magento\Framework\Locale\CurrencyInterface') - ->getCurrency($currencyCode) - ->toCurrency( - $this->_scopeConfig->getValue( - 'sales/minimum_order/amount', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) - ); - - $warning = $this->_scopeConfig->getValue( - 'sales/minimum_order/description', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) ? $this->_scopeConfig->getValue( - 'sales/minimum_order/description', - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ) : __( - 'Minimum order amount is %1', - $minimumAmount - ); - - $this->messageManager->addNotice($warning); - } - } - - // Compose array of messages to add - foreach ($this->cart->getQuote()->getMessages() as $message) { - if (!$message) { - continue; - } - if ($message instanceof \Magento\Framework\Phrase) { - $message = $message->__toString(); - } - $this->messageManager->addError($message); - } - - /** - * if customer enteres shopping cart we should mark quote - * as modified bc he can has checkout page in another window. - */ - $this->_checkoutSession->setCartWasUpdated(true); - - \Magento\Framework\Profiler::start(__METHOD__ . 'cart_display'); - $resultPage = $this->resultPageFactory->create(); $resultPage->getLayout()->initMessages(); $resultPage->getConfig()->getTitle()->set(__('Shopping Cart')); - \Magento\Framework\Profiler::stop(__METHOD__ . 'cart_display'); return $resultPage; } } diff --git a/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php b/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php index 61be91b6a1e925178502254081decb8d0cc3112d..efb5d35dcca1e0fc8f54e20a2545187fe04a5a9c 100644 --- a/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php +++ b/app/code/Magento/Checkout/Controller/Cart/UpdateItemOptions.php @@ -54,8 +54,6 @@ class UpdateItemOptions extends \Magento\Checkout\Controller\Cart $this->cart->save(); - $this->_checkoutSession->setCartWasUpdated(true); - $this->_eventManager->dispatch( 'checkout_cart_update_item_complete', ['item' => $item, 'request' => $this->getRequest(), 'response' => $this->getResponse()] diff --git a/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php b/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php index dc71ca01354e36206279c5a580c9a5f4be0b71c8..31d94cb623031c751834ec5e49b38259eaf820ed 100644 --- a/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php +++ b/app/code/Magento/Checkout/Controller/Cart/UpdatePost.php @@ -20,7 +20,6 @@ class UpdatePost extends \Magento\Checkout\Controller\Cart { try { $this->cart->truncate()->save(); - $this->_checkoutSession->setCartWasUpdated(true); } catch (\Magento\Framework\Exception\LocalizedException $exception) { $this->messageManager->addError($exception->getMessage()); } catch (\Exception $exception) { @@ -53,7 +52,6 @@ class UpdatePost extends \Magento\Checkout\Controller\Cart $cartData = $this->cart->suggestItemsQty($cartData); $this->cart->updateItems($cartData)->save(); } - $this->_checkoutSession->setCartWasUpdated(true); } catch (\Magento\Framework\Exception\LocalizedException $e) { $this->messageManager->addError( $this->_objectManager->get('Magento\Framework\Escaper')->escapeHtml($e->getMessage()) diff --git a/app/code/Magento/Checkout/Model/Cart.php b/app/code/Magento/Checkout/Model/Cart.php index b119b7744530a1f5f0bb15a38d6392d86e37c12f..39b276ce099f8c11dd88c748a3ed5f49d1bee05d 100644 --- a/app/code/Magento/Checkout/Model/Cart.php +++ b/app/code/Magento/Checkout/Model/Cart.php @@ -220,23 +220,19 @@ class Cart extends Object implements CartInterface } /** - * Initialize cart quote state to be able use it on cart page + * Reinitialize cart quote state * * @return $this */ - public function init() + protected function reinitializeState() { $quote = $this->getQuote()->setCheckoutMethod(''); - + $this->_checkoutSession->setCartWasUpdated(true); + // reset for multiple address checkout if ($this->_checkoutSession->getCheckoutState() !== Session::CHECKOUT_STATE_BEGIN) { $quote->removeAllAddresses()->removePayment(); $this->_checkoutSession->resetCheckout(); } - - if (!$quote->hasItems()) { - $quote->getShippingAddress()->setCollectShippingRates(false)->removeAllShippingRates(); - } - return $this; } @@ -562,6 +558,7 @@ class Cart extends Object implements CartInterface * Cart save usually called after changes with cart items. */ $this->_eventManager->dispatch('checkout_cart_save_after', ['cart' => $this]); + $this->reinitializeState(); return $this; } diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php index 6dc1c2336f2135f3933598fe3233e94a96af78af..43b5fb8657ded5fc413dc2aaa4f5a627d5af6183 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/IndexTest.php @@ -131,35 +131,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase */ public function testExecuteWithMessages() { - $phrase = $this->getMockBuilder('Magento\Framework\Phrase') - ->disableOriginalConstructor() - ->getMock(); - $phrase->expects($this->once()) - ->method('__toString') - ->willReturn('test_phrase'); - - $messages = [ - '', - 'test', - $phrase - ]; - $this->cart->expects($this->any()) - ->method('getQuote') - ->willReturn($this->quote); - $this->quote->expects($this->once()) - ->method('getItemsCount') - ->willReturn(0); - $this->quote->expects($this->once()) - ->method('getMessages') - ->willReturn($messages); - $map = [ - ['test'], - ['test_phrase'] - ]; - $this->messageManager->expects($this->exactly(2)) - ->method('addError') - ->willReturnMap($map); - $layout = $this->getMockBuilder('Magento\Framework\View\Layout') ->disableOriginalConstructor() ->getMock(); diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php index d9cb30e55e34905336d7155b3bd75d23a40c30f5..9bf66e02a93d7b92d7f81ee1e67f6e4762c35886 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveBillingTest.php @@ -144,6 +144,7 @@ class SaveBillingTest extends \PHPUnit_Framework_TestCase $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\JSON') ->disableOriginalConstructor() + ->setMethods(['setData']) ->getMock(); $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JSONFactory') ->disableOriginalConstructor() diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php index e2cd55295d11e9c12cfd1eda8c20fe1501920319..480e9fe957d808908c970bbca413aec2cf515c06 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Onepage/SaveShippingTest.php @@ -144,6 +144,7 @@ class SaveShippingTest extends \PHPUnit_Framework_TestCase $this->resultJson = $this->getMockBuilder('Magento\Framework\Controller\Result\Json') ->disableOriginalConstructor() + ->setMethods(['setData']) ->getMock(); $resultJsonFactory = $this->getMockBuilder('Magento\Framework\Controller\Result\JsonFactory') ->disableOriginalConstructor() diff --git a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml index b794a949e28849ff8795677e6458ea29a2ca00dd..9b690c5b43fbd0ccee106decb8ea17b9a2d8dca5 100644 --- a/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml +++ b/app/code/Magento/Checkout/view/frontend/layout/checkout_cart_index.xml @@ -9,6 +9,9 @@ <update handle="checkout_cart_item_renderers"/> <update handle="checkout_shipping_price_renderer"/> <body> + <referenceContainer name="page.messages"> + <block class="Magento\Checkout\Block\Cart\ValidationMessages" name="checkout.cart.validationmessages"/> + </referenceContainer> <referenceContainer name="content"> <block class="Magento\Checkout\Block\Cart" name="checkout.cart" template="cart.phtml"> <container name="checkout.cart.items" as="with-items"> @@ -35,7 +38,7 @@ </block> </container> <container name="checkout.cart.noitems" as="no-items"> - <block class="Magento\Checkout\Block\Cart" name="checkout.cart.empty" before="-" template="cart/noItems.phtml"/> + <block class="Magento\Checkout\Block\Cart\EmptyCart" name="checkout.cart.empty" before="-" template="cart/noItems.phtml"/> <container name="checkout.cart.empty.widget" as="checkout_cart_empty_widget" label="Empty Shopping Cart Content Before"/> </container> </block> diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml index 9fe14c75f86a8eda4d403233b02c2f8c9f5cee93..b3e8bcd4d6792b189fd0df5bb7b00ad97babacc6 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/noItems.phtml @@ -4,7 +4,7 @@ * See COPYING.txt for license details. */ -/** @var $block \Magento\Checkout\Block\Cart */ +/** @var $block \Magento\Checkout\Block\Cart\EmptyCart */ ?> <div class="cart-empty"> <?php echo $block->getChildHtml('checkout_cart_empty_widget'); ?> diff --git a/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml b/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml index b2f1360d69d4f01e6f8eb88da2622fc166f52bec..7585ca9388f9034e59d9b0a3e3d17434acbb258a 100644 --- a/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml +++ b/app/code/Magento/Checkout/view/frontend/templates/cart/shipping.phtml @@ -77,7 +77,7 @@ } </script> <?php if (($_shippingRateGroups = $block->getEstimateRates())): ?> - <form id="co-shipping-method-form" action="<?php echo $block->getUrl('checkout/cart/estimateUpdatePost') ?>"> + <form id="co-shipping-method-form" action="<?php echo $block->getUrl('checkout/cart/estimateUpdatePost') ?>" method="post"> <fieldset class="fieldset rates"> <dl class="items methods"> <?php foreach ($_shippingRateGroups as $code => $_rates): ?> diff --git a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php index 421989782a9634fb21747e9d99828763185cfe98..3b0d1837ed3b1dd99d33f5dc0bfe2bb7a3121e4d 100644 --- a/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php +++ b/app/code/Magento/Cms/Test/Unit/Block/Adminhtml/Block/EditTest.php @@ -53,7 +53,7 @@ class EditTest extends \PHPUnit_Framework_TestCase 'Magento\Cms\Block\Adminhtml\Block\Edit', [ 'registry' => $this->registryMock, - 'escaper' => $this->escaperMock + 'escaper' => $this->escaperMock, ] ); } @@ -91,7 +91,7 @@ class EditTest extends \PHPUnit_Framework_TestCase { return [ 'modelBlockId NOT EMPTY' => ['modelBlockId' => 1], - 'modelBlockId IS EMPTY' => ['modelBlockId' => null] + 'modelBlockId IS EMPTY' => ['modelBlockId' => null], ]; } } diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml b/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml index c430e91be2cc8ab9ac2134ff68bd9785ec284a29..ed335b6babce89860d2af06041a59957ce9dcea5 100644 --- a/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml +++ b/app/code/Magento/ConfigurableProduct/view/frontend/layout/checkout_cart_item_renderers.xml @@ -8,7 +8,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="checkout.cart.item.renderers"> - <block class="Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Checkout::cart/item/default.phtml" cacheable="false"/> + <block class="Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable" as="configurable" template="Magento_Checkout::cart/item/default.phtml"/> </referenceBlock> </body> </page> diff --git a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php index 26cf7b0f6fc2b278202b2246d015009100b2abde..8244f9f253ab3e92ed44cea29e148835c702ff79 100644 --- a/app/code/Magento/Customer/Block/Account/Dashboard/Info.php +++ b/app/code/Magento/Customer/Block/Account/Dashboard/Info.php @@ -84,7 +84,7 @@ class Info extends \Magento\Framework\View\Element\Template */ public function getChangePasswordUrl() { - return $this->_urlBuilder->getUrl('*/account/edit/changepass/1'); + return $this->_urlBuilder->getUrl('customer/account/edit/changepass/1'); } /** @@ -133,4 +133,12 @@ class Info extends \Magento\Framework\View\Element\Template { return $this->_subscriberFactory->create(); } + + /** + * @return string + */ + protected function _toHtml() + { + return $this->currentCustomer->getCustomerId() ? parent::_toHtml() : ''; + } } diff --git a/app/code/Magento/Customer/Block/Account/Link.php b/app/code/Magento/Customer/Block/Account/Link.php index e6d3898b4836b2eca372b850665ef4b682cabc96..ae7f7b6831bdc099efa3fc377bee629bb989163e 100644 --- a/app/code/Magento/Customer/Block/Account/Link.php +++ b/app/code/Magento/Customer/Block/Account/Link.php @@ -29,7 +29,6 @@ class Link extends \Magento\Framework\View\Element\Html\Link ) { $this->_customerUrl = $customerUrl; parent::__construct($context, $data); - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Customer/Block/Account/RegisterLink.php b/app/code/Magento/Customer/Block/Account/RegisterLink.php index a286b05fb17d8f2395f65f0d2825242f184b1b4d..a9496c3c4784c4f1f5434680a93b2c990d18099c 100644 --- a/app/code/Magento/Customer/Block/Account/RegisterLink.php +++ b/app/code/Magento/Customer/Block/Account/RegisterLink.php @@ -49,7 +49,6 @@ class RegisterLink extends \Magento\Framework\View\Element\Html\Link $this->httpContext = $httpContext; $this->_registration = $registration; $this->_customerUrl = $customerUrl; - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Customer/Block/Form/Login.php b/app/code/Magento/Customer/Block/Form/Login.php index cd10974d943c75e37b5659be9e51a95ec6be6d87..256b49c9e931d19ce47957bccc1320830f19764e 100644 --- a/app/code/Magento/Customer/Block/Form/Login.php +++ b/app/code/Magento/Customer/Block/Form/Login.php @@ -27,53 +27,22 @@ class Login extends \Magento\Framework\View\Element\Template */ protected $_customerUrl; - /** - * Checkout data - * - * @var \Magento\Checkout\Helper\Data - */ - protected $checkoutData; - - /** - * Core url - * - * @var \Magento\Framework\Url\Helper\Data - */ - protected $coreUrl; - - /** - * Registration - * - * @var \Magento\Customer\Model\Registration - */ - protected $registration; - /** * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Customer\Model\Registration $registration * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Customer\Model\Url $customerUrl - * @param \Magento\Checkout\Helper\Data $checkoutData - * @param \Magento\Framework\Url\Helper\Data $coreUrl * @param array $data */ public function __construct( \Magento\Framework\View\Element\Template\Context $context, - \Magento\Customer\Model\Registration $registration, \Magento\Customer\Model\Session $customerSession, \Magento\Customer\Model\Url $customerUrl, - \Magento\Checkout\Helper\Data $checkoutData, - \Magento\Framework\Url\Helper\Data $coreUrl, array $data = [] ) { - $this->registration = $registration; - $this->_customerUrl = $customerUrl; - $this->_customerSession = $customerSession; - $this->checkoutData = $checkoutData; - $this->coreUrl = $coreUrl; - parent::__construct($context, $data); $this->_isScopePrivate = true; + $this->_customerUrl = $customerUrl; + $this->_customerSession = $customerSession; } /** @@ -85,16 +54,6 @@ class Login extends \Magento\Framework\View\Element\Template return parent::_prepareLayout(); } - /** - * Return registration - * - * @return \Magento\Customer\Model\Registration - */ - public function getRegistration() - { - return $this->registration; - } - /** * Retrieve form posting url * @@ -105,23 +64,6 @@ class Login extends \Magento\Framework\View\Element\Template return $this->_customerUrl->getLoginPostUrl(); } - /** - * Retrieve create new account url - * - * @return string - */ - public function getCreateAccountUrl() - { - $url = $this->getData('create_account_url'); - if (is_null($url)) { - $url = $this->_customerUrl->getRegisterUrl(); - } - if ($this->checkoutData->isContextCheckout()) { - $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']); - } - return $url; - } - /** * Retrieve password forgotten url * diff --git a/app/code/Magento/Customer/Block/Form/Login/Info.php b/app/code/Magento/Customer/Block/Form/Login/Info.php new file mode 100644 index 0000000000000000000000000000000000000000..1cfb3afac43663e0c0caabdc06a8c6450ff6480c --- /dev/null +++ b/app/code/Magento/Customer/Block/Form/Login/Info.php @@ -0,0 +1,88 @@ +<?php +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Customer\Block\Form\Login; + +/** + * Customer login info block + */ +class Info extends \Magento\Framework\View\Element\Template +{ + /** + * @var \Magento\Customer\Model\Url + */ + protected $_customerUrl; + + /** + * Checkout data + * + * @var \Magento\Checkout\Helper\Data + */ + protected $checkoutData; + + /** + * Core url + * + * @var \Magento\Framework\Url\Helper\Data + */ + protected $coreUrl; + + /** + * Registration + * + * @var \Magento\Customer\Model\Registration + */ + protected $registration; + + /** + * @param \Magento\Framework\View\Element\Template\Context $context + * @param \Magento\Customer\Model\Registration $registration + * @param \Magento\Customer\Model\Url $customerUrl + * @param \Magento\Checkout\Helper\Data $checkoutData + * @param \Magento\Framework\Url\Helper\Data $coreUrl + * @param array $data + */ + public function __construct( + \Magento\Framework\View\Element\Template\Context $context, + \Magento\Customer\Model\Registration $registration, + \Magento\Customer\Model\Url $customerUrl, + \Magento\Checkout\Helper\Data $checkoutData, + \Magento\Framework\Url\Helper\Data $coreUrl, + array $data = [] + ) { + parent::__construct($context, $data); + $this->registration = $registration; + $this->_customerUrl = $customerUrl; + $this->checkoutData = $checkoutData; + $this->coreUrl = $coreUrl; + } + + /** + * Return registration + * + * @return \Magento\Customer\Model\Registration + */ + public function getRegistration() + { + return $this->registration; + } + + /** + * Retrieve create new account url + * + * @return string + */ + public function getCreateAccountUrl() + { + $url = $this->getData('create_account_url'); + if (is_null($url)) { + $url = $this->_customerUrl->getRegisterUrl(); + } + if ($this->checkoutData->isContextCheckout()) { + $url = $this->coreUrl->addRequestParam($url, ['context' => 'checkout']); + } + return $url; + } +} diff --git a/app/code/Magento/Customer/Test/Unit/Block/Form/LoginTest.php b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php similarity index 68% rename from app/code/Magento/Customer/Test/Unit/Block/Form/LoginTest.php rename to app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php index 493674bf0ad7290d4591bf1915fa5843e7d35168..b45a2811d9dd36cb67bcb332a667737915df0f64 100644 --- a/app/code/Magento/Customer/Test/Unit/Block/Form/LoginTest.php +++ b/app/code/Magento/Customer/Test/Unit/Block/Form/Login/InfoTest.php @@ -3,17 +3,12 @@ * Copyright © 2015 Magento. All rights reserved. * See COPYING.txt for license details. */ -namespace Magento\Customer\Test\Unit\Block\Form; +namespace Magento\Customer\Test\Unit\Block\Form\Login; -class LoginTest extends \PHPUnit_Framework_TestCase +class InfoTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager - */ - protected $objectManager; - - /** - * @var \Magento\Customer\Block\Form\Login + * @var \Magento\Customer\Block\Form\Login\Info */ protected $block; @@ -50,9 +45,8 @@ class LoginTest extends \PHPUnit_Framework_TestCase ['addRequestParam'] )->getMock(); - $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); - $this->block = $this->objectManager->getObject( - 'Magento\Customer\Block\Form\Login', + $this->block = (new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this))->getObject( + 'Magento\Customer\Block\Form\Login\Info', [ 'customerUrl' => $this->customerUrl, 'checkoutData' => $this->checkoutData, @@ -61,13 +55,20 @@ class LoginTest extends \PHPUnit_Framework_TestCase ); } - public function testGetCreateAccountUrl() + public function testGetExistingCreateAccountUrl() { $expectedUrl = 'Custom Url'; $this->block->setCreateAccountUrl($expectedUrl); $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false)); $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); + } + + public function testGetCreateAccountUrlWithContext() + { + $url = 'Custom Url'; + $expectedUrl = 'Custom Url with context'; + $this->block->setCreateAccountUrl($url); $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(true)); $this->coreUrl->expects( @@ -75,30 +76,20 @@ class LoginTest extends \PHPUnit_Framework_TestCase )->method( 'addRequestParam' )->with( - $expectedUrl, + $url, ['context' => 'checkout'] )->will( $this->returnValue($expectedUrl) ); $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); + } - $this->block->unsCreateAccountUrl(); - $this->customerUrl->expects($this->any())->method('getRegisterUrl')->will($this->returnValue($expectedUrl)); - $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false)); - $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); + public function testGetCreateAccountUrl() + { + $expectedUrl = 'Custom Url'; $this->customerUrl->expects($this->any())->method('getRegisterUrl')->will($this->returnValue($expectedUrl)); - $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(true)); - $this->coreUrl->expects( - $this->any() - )->method( - 'addRequestParam' - )->with( - $expectedUrl, - ['context' => 'checkout'] - )->will( - $this->returnValue($expectedUrl) - ); + $this->checkoutData->expects($this->any())->method('isContextCheckout')->will($this->returnValue(false)); $this->assertEquals($expectedUrl, $this->block->getCreateAccountUrl()); } } diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php index 6323dec97d41723037ebf55067c6a088d3c6f5bd..a4fe4832056411b7453b2eaa2b8b01ea04d3b010 100644 --- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php +++ b/app/code/Magento/Customer/Test/Unit/Controller/Account/ConfirmTest.php @@ -19,7 +19,7 @@ use Magento\Store\Model\ScopeInterface; class ConfirmTest extends \PHPUnit_Framework_TestCase { /** - * @var \Magento\Customer\Controller\Account + * @var \Magento\Customer\Controller\Account\Confirm */ protected $model; @@ -171,7 +171,7 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase 'customerRepository' => $this->customerRepositoryMock, 'addressHelper' => $this->addressHelperMock, 'urlFactory' => $urlFactoryMock, - 'resultRedirectFactory' => $redirectFactoryMock + 'resultRedirectFactory' => $redirectFactoryMock, ] ); } @@ -426,7 +426,7 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase 'http://example.com/success', 'http://example.com/success', true, - __('Thank you for registering with') + __('Thank you for registering with'), ], [ 1, @@ -435,7 +435,7 @@ class ConfirmTest extends \PHPUnit_Framework_TestCase 'http://example.com/success', 'http://example.com/success', false, - __('Thank you for registering with') + __('Thank you for registering with'), ], ]; } diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml index c5b7b4ed77af6114c5ee5edc8d46901c256b8e42..c931d10ffacfca9771214fa8b2186555d5e516de 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_account_create.xml @@ -11,7 +11,7 @@ <block class="Magento\Framework\View\Element\Js\Components" name="customer_account_create_head_components" template="Magento_Customer::js/components.phtml"/> </referenceBlock> <referenceContainer name="content"> - <block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml" cacheable="false"> + <block class="Magento\Customer\Block\Form\Register" name="customer_form_register" template="form/register.phtml"> <container name="form.additional.info" as="form_additional_info"/> <container name="customer.form.register.fields.before" as="form_fields_before" label="Form Fields Before" htmlTag="div" htmlClass="customer-form-before"/> </block> diff --git a/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml b/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml index 6a2d849c364d45f46a674d4ab4c011053cb0cc94..6dafbfb6cecb2b19cc5f787050abb2065a05d163 100644 --- a/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml +++ b/app/code/Magento/Customer/view/frontend/layout/customer_account_login.xml @@ -10,10 +10,10 @@ <referenceContainer name="content"> <!-- customer.form.login.extra --> <container name="customer.login.container" label="Customer Login Container" htmlTag="div" htmlClass="login-container"> - <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/login.phtml" cacheable="false"> + <block class="Magento\Customer\Block\Form\Login" name="customer_form_login" template="form/login.phtml"> <container name="form.additional.info" as="form_additional_info"/> </block> - <block class="Magento\Customer\Block\Form\Login" name="customer.new" template="newcustomer.phtml" cacheable="false"/> + <block class="Magento\Customer\Block\Form\Login\Info" name="customer.new" template="newcustomer.phtml"/> </container> <block class="Magento\Cookie\Block\RequireCookie" name="require-cookie" template="Magento_Cookie::require_cookie.phtml"> <arguments> diff --git a/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml b/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml index 31e31a9dfa48c4db9eda150b348df3a10a12e637..e4609e91131483a037adc9d592d72d6455cb2f09 100644 --- a/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/newcustomer.phtml @@ -11,7 +11,7 @@ /** * New Customer block template * - * @var $block \Magento\Customer\Block\Form\Login + * @var $block \Magento\Customer\Block\Form\Login\Info */ ?> <?php if ($block->getRegistration()->isAllowed()): ?> diff --git a/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml b/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml index 705b5bcde58bb20c707e747c50bc73ef38b0fb36..c16bce0be3303278b3aa6c8643b22e77229a034b 100644 --- a/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml +++ b/app/code/Magento/DesignEditor/view/adminhtml/templates/editor/tools/files/tree.phtml @@ -35,8 +35,7 @@ require([ "extjs/ext-tree-checkbox", 'Magento_DesignEditor/js/tools-files' ], function(jQuery){ - -Ext.onReady(function(){ +jQuery(function(){ var Tree = Ext.tree; var tree = new Tree.TreePanel('tree', { animate:true, diff --git a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php index 5b6c1b0960b4d8366c54d9be8bbcefb02e7c438b..1e09a35920dae97946d759c147f82b3b264ef7e0 100644 --- a/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php +++ b/app/code/Magento/Downloadable/Block/Customer/Products/ListProducts.php @@ -155,7 +155,7 @@ class ListProducts extends \Magento\Framework\View\Element\Template */ public function getDownloadUrl($item) { - return $this->getUrl('*/download/link', ['id' => $item->getLinkHash(), '_secure' => true]); + return $this->getUrl('downloadable/download/link', ['id' => $item->getLinkHash(), '_secure' => true]); } /** diff --git a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php index f5139b50c8737e7cea0d5e9dc9cc1b7c2d36aac8..f44fe22015929528a2d7decdcc81858696c76e11 100644 --- a/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php +++ b/app/code/Magento/GroupedProduct/Model/Product/Type/Grouped.php @@ -262,7 +262,7 @@ class Grouped extends \Magento\Catalog\Model\Product\Type\AbstractType if (!$product->hasData($this->_keyStatusFilters)) { return [ \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED, - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED + \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED, ]; } return $product->getData($this->_keyStatusFilters); diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php index b352c126ad3bcee98de67385eea22a472a73ffe5..3be90c1459b5a6f773450d9debaf86cf673d2e2d 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Config/ConverterTest.php @@ -25,24 +25,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $this->assertEquals($data['expected'], $this->_model->convert($dom)); } - - /** - * @param string $xmlData - * @dataProvider wrongXmlDataProvider - * @expectedException \Exception - */ - public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) - { - $dom = new \DOMDocument(); - $dom->loadXML($xmlData); - $this->_model->convert($dom); - } - - /** - * @return array - */ - public function wrongXmlDataProvider() - { - return [['<?xml version="1.0"?><config>']]; - } } diff --git a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php index 353e5cfaf83f0d9ec0c36fd718a6f6c8a74cb74c..b35dd6e74c6a9b0aa4a9ef75d5421b2220449819 100644 --- a/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php +++ b/app/code/Magento/Indexer/Test/Unit/Model/Resource/AbstractResourceTest.php @@ -86,13 +86,13 @@ class AbstractResourceTest extends \PHPUnit_Framework_TestCase /** * @expectedException \Exception - * @expectedExceptionMessage array_keys() expects parameter 1 to be array, null given */ public function testSyncDataException() { $connectionMock = $this->getMock('Magento\Framework\DB\Adapter\AdapterInterface', [], [], '', false); $this->_resourceMock->expects($this->any())->method('getConnection')->will($this->returnValue($connectionMock)); $this->_resourceMock->expects($this->any())->method('getTableName')->will($this->returnArgument(0)); + $connectionMock->expects($this->once())->method('rollback'); $this->model->syncData(); } diff --git a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php index fb09bbfca7410a68c6ea4b2395792af9c6dfd3b7..d0fe99eda0571a212c1c5657dbba5721a3b8d8c6 100644 --- a/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php +++ b/app/code/Magento/Multishipping/Model/Checkout/Type/Multishipping/Plugin.php @@ -31,7 +31,7 @@ class Plugin * @return void * @SuppressWarnings(PHPMD.UnusedFormalParameter) */ - public function beforeInit(\Magento\Checkout\Model\Cart $subject) + public function beforeSave(\Magento\Checkout\Model\Cart $subject) { if ($this->checkoutSession->getCheckoutState() === State::STEP_SELECT_ADDRESSES) { $this->checkoutSession->setCheckoutState(\Magento\Checkout\Model\Session::CHECKOUT_STATE_BEGIN); diff --git a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php index 10f158e0e893817f76c1b1e637054a70957895d0..a0eea6088d081f56dc27ae3c79fcda9e06def353 100644 --- a/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php +++ b/app/code/Magento/Multishipping/Test/Unit/Model/Checkout/Type/Multishipping/PluginTest.php @@ -44,7 +44,7 @@ class PluginTest extends \PHPUnit_Framework_TestCase ->willReturn(State::STEP_SELECT_ADDRESSES); $this->checkoutSessionMock->expects($this->once())->method('setCheckoutState') ->with(Session::CHECKOUT_STATE_BEGIN); - $this->model->beforeInit($this->cartMock); + $this->model->beforeSave($this->cartMock); } public function testBeforeInitCaseFalse() @@ -52,6 +52,6 @@ class PluginTest extends \PHPUnit_Framework_TestCase $this->checkoutSessionMock->expects($this->once())->method('getCheckoutState') ->willReturn(''); $this->checkoutSessionMock->expects($this->never())->method('setCheckoutState'); - $this->model->beforeInit($this->cartMock); + $this->model->beforeSave($this->cartMock); } } diff --git a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml index b71e35b9b4c706d22a15c6ae0e40b994c2a253b7..8ea4f26cae9086940879b09517d88a63951acce2 100644 --- a/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml +++ b/app/code/Magento/Multishipping/view/frontend/layout/multishipping_checkout_overview.xml @@ -15,7 +15,7 @@ </action> </referenceBlock> <referenceContainer name="content"> - <block class="Magento\Multishipping\Block\Checkout\Overview" name="checkout_overview" template="checkout/overview.phtml"> + <block class="Magento\Multishipping\Block\Checkout\Overview" name="checkout_overview" template="checkout/overview.phtml" cacheable="false"> <arguments> <argument name="renderer_template" xsi:type="string">Magento_Multishipping::checkout/item/default.phtml</argument> <argument name="row_renderer_template" xsi:type="string">Magento_Multishipping::checkout/overview/item.phtml</argument> diff --git a/app/code/Magento/Newsletter/Block/Subscribe.php b/app/code/Magento/Newsletter/Block/Subscribe.php index 66ecb517455a96c3c46816e9b789144587d67b3e..ae9549930d6b67849ffa9b0079b513622c1db053 100644 --- a/app/code/Magento/Newsletter/Block/Subscribe.php +++ b/app/code/Magento/Newsletter/Block/Subscribe.php @@ -13,48 +13,6 @@ namespace Magento\Newsletter\Block; class Subscribe extends \Magento\Framework\View\Element\Template { - /** - * Newsletter session - * - * @var \Magento\Newsletter\Model\Session - */ - protected $_newsletterSession; - - /** - * @param \Magento\Framework\View\Element\Template\Context $context - * @param \Magento\Newsletter\Model\Session $newsletterSession - * @param array $data - */ - public function __construct( - \Magento\Framework\View\Element\Template\Context $context, - \Magento\Newsletter\Model\Session $newsletterSession, - array $data = [] - ) { - parent::__construct($context, $data); - $this->_newsletterSession = $newsletterSession; - $this->_isScopePrivate = true; - } - - /** - * Get success message - * - * @return string - */ - public function getSuccessMessage() - { - return $this->_newsletterSession->getSuccess(); - } - - /** - * Get error message - * - * @return string - */ - public function getErrorMessage() - { - return $this->_newsletterSession->getError(); - } - /** * Retrieve form action url and set "secure" param to avoid confirm * message when we submit form from secure page to unsecure diff --git a/app/code/Magento/Review/Block/Customer/ListCustomer.php b/app/code/Magento/Review/Block/Customer/ListCustomer.php index 30a856c8384f419fb2e11d46bbdf888c7c3940ac..eee22e93bf790cb6b5bc5fd23e44861eb89ae8b5 100644 --- a/app/code/Magento/Review/Block/Customer/ListCustomer.php +++ b/app/code/Magento/Review/Block/Customer/ListCustomer.php @@ -62,31 +62,7 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard $data ); $this->currentCustomer = $currentCustomer; - } - - /** - * Initialize review collection - * - * @return $this - */ - protected function _initCollection() - { - $this->_collection = $this->_collectionFactory->create(); - $this->_collection - ->addStoreFilter($this->_storeManager->getStore()->getId()) - ->addCustomerFilter($this->currentCustomer->getCustomerId()) - ->setDateOrder(); - return $this; - } - - /** - * Gets collection items count - * - * @return int - */ - public function count() - { - return $this->_getCollection()->getSize(); + $this->_isScopePrivate = true; } /** @@ -106,40 +82,39 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard */ protected function _prepareLayout() { - $toolbar = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager', - 'customer_review_list.toolbar' - )->setCollection( - $this->getCollection() - ); - - $this->setChild('toolbar', $toolbar); + if ($this->getReviews()) { + $toolbar = $this->getLayout()->createBlock( + 'Magento\Theme\Block\Html\Pager', + 'customer_review_list.toolbar' + )->setCollection( + $this->getReviews() + ); + + $this->setChild('toolbar', $toolbar); + } return parent::_prepareLayout(); } /** - * Get collection + * Get reviews * - * @return \Magento\Review\Model\Resource\Review\Product\Collection + * @return bool|\Magento\Review\Model\Resource\Review\Product\Collection */ - protected function _getCollection() + public function getReviews() { + if (!($customerId = $this->currentCustomer->getCustomerId())) { + return false; + } if (!$this->_collection) { - $this->_initCollection(); + $this->_collection = $this->_collectionFactory->create(); + $this->_collection + ->addStoreFilter($this->_storeManager->getStore()->getId()) + ->addCustomerFilter($customerId) + ->setDateOrder(); } return $this->_collection; } - /** - * Get collection - * - * @return \Magento\Review\Model\Resource\Review\Product\Collection - */ - public function getCollection() - { - return $this->_getCollection(); - } - /** * Get review link * @@ -178,7 +153,10 @@ class ListCustomer extends \Magento\Customer\Block\Account\Dashboard */ protected function _beforeToHtml() { - $this->_getCollection()->load()->addReviewSummary(); + $reviews = $this->getReviews(); + if ($reviews) { + $reviews->load()->addReviewSummary(); + } return parent::_beforeToHtml(); } } diff --git a/app/code/Magento/Review/Block/Customer/Recent.php b/app/code/Magento/Review/Block/Customer/Recent.php index bbb8cf71cb44bb7af39c2ca26cb7d8984c1a20ba..7cd61cd717e8e489ea25a4cb2c152b36bf99b659 100644 --- a/app/code/Magento/Review/Block/Customer/Recent.php +++ b/app/code/Magento/Review/Block/Customer/Recent.php @@ -53,6 +53,7 @@ class Recent extends \Magento\Framework\View\Element\Template $this->_collectionFactory = $collectionFactory; parent::__construct($context, $data); $this->currentCustomer = $currentCustomer; + $this->_isScopePrivate = true; } /** @@ -74,54 +75,28 @@ class Recent extends \Magento\Framework\View\Element\Template } /** - * Initialize review collection - * @return $this - */ - protected function _initCollection() - { - $this->_collection = $this->_collectionFactory->create(); - $this->_collection - ->addStoreFilter($this->_storeManager->getStore()->getId()) - ->addCustomerFilter($this->currentCustomer->getCustomerId()) - ->setDateOrder() - ->setPageSize(5) - ->load() - ->addReviewSummary(); - return $this; - } - - /** - * Get number of reviews + * Return collection of reviews * - * @return int + * @return array|\Magento\Review\Model\Resource\Review\Product\Collection */ - public function count() - { - return $this->_getCollection()->getSize(); - } - - /** - * Initialize and return collection of reviews - * @return Collection - */ - protected function _getCollection() + public function getReviews() { + if (!($customerId = $this->currentCustomer->getCustomerId())) { + return []; + } if (!$this->_collection) { - $this->_initCollection(); + $this->_collection = $this->_collectionFactory->create(); + $this->_collection + ->addStoreFilter($this->_storeManager->getStore()->getId()) + ->addCustomerFilter($customerId) + ->setDateOrder() + ->setPageSize(5) + ->load() + ->addReviewSummary(); } return $this->_collection; } - /** - * Return collection of reviews - * - * @return Collection - */ - public function getCollection() - { - return $this->_getCollection(); - } - /** * Return review customer view url * diff --git a/app/code/Magento/Review/Block/Customer/View.php b/app/code/Magento/Review/Block/Customer/View.php index 7ca1541ba9842f61f3454f6a4a1babc4a46cf5db..3bab2ed7c7c7957fb68224a912a77e4a8a748022 100644 --- a/app/code/Magento/Review/Block/Customer/View.php +++ b/app/code/Magento/Review/Block/Customer/View.php @@ -79,11 +79,11 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct $this->_voteFactory = $voteFactory; $this->_ratingFactory = $ratingFactory; $this->currentCustomer = $currentCustomer; - parent::__construct( $context, $data ); + $this->_isScopePrivate = true; } /** @@ -199,16 +199,6 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct return $this->formatDate($date, \IntlDateFormatter::LONG); } - /** - * Check whether current customer is review owner - * - * @return bool - */ - public function isReviewOwner() - { - return ($this->getReviewData()->getCustomerId() == $this->currentCustomer->getCustomerId()); - } - /** * Get product reviews summary * @@ -227,4 +217,12 @@ class View extends \Magento\Catalog\Block\Product\AbstractProduct } return parent::getReviewsSummaryHtml($product, $templateType, $displayIfNoReviews); } + + /** + * @return string + */ + protected function _toHtml() + { + return $this->currentCustomer->getCustomerId() ? parent::_toHtml() : ''; + } } diff --git a/app/code/Magento/Review/Block/Form.php b/app/code/Magento/Review/Block/Form.php index 88429e9c1195415d153f9b0ad4e7b0a9fe46bb07..9682f444c4100126155f6daa0ecde88b656ce156 100644 --- a/app/code/Magento/Review/Block/Form.php +++ b/app/code/Magento/Review/Block/Form.php @@ -112,6 +112,7 @@ class Form extends \Magento\Framework\View\Element\Template $this->httpContext = $httpContext; $this->customerUrl = $customerUrl; parent::__construct($context, $data); + $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Review/Controller/Customer/View.php b/app/code/Magento/Review/Controller/Customer/View.php index 8470249f465e4f6501a7eb46ab588a65fee56a90..d1ea95e7afc90d83b7b9d44fd020297f57488e1d 100644 --- a/app/code/Magento/Review/Controller/Customer/View.php +++ b/app/code/Magento/Review/Controller/Customer/View.php @@ -8,6 +8,22 @@ namespace Magento\Review\Controller\Customer; class View extends \Magento\Review\Controller\Customer { + /** @var \Magento\Review\Model\ReviewFactory */ + protected $reviewFactory; + + /** + * @param \Magento\Framework\App\Action\Context $context + * @param \Magento\Customer\Model\Session $customerSession + * @param \Magento\Review\Model\ReviewFactory $reviewFactory + */ + public function __construct( + \Magento\Framework\App\Action\Context $context, + \Magento\Customer\Model\Session $customerSession, + \Magento\Review\Model\ReviewFactory $reviewFactory + ) { + parent::__construct($context, $customerSession); + $this->reviewFactory = $reviewFactory; + } /** * Render review details * @@ -15,6 +31,10 @@ class View extends \Magento\Review\Controller\Customer */ public function execute() { + $review = $this->reviewFactory->create()->load($this->getRequest()->getParam('id')); + if ($review->getCustomerId() != $this->_customerSession->getCustomerId()) { + return $this->_forward('noroute'); + } $this->_view->loadLayout(); if ($navigationBlock = $this->_view->getLayout()->getBlock('customer_account_navigation')) { $navigationBlock->setActive('review/customer'); diff --git a/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php b/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php index f3d2edd7e4095750ec79a998ef37c214f9dfc97c..b04e90e9cc7c194bb55058040fb2fb5684fc018d 100644 --- a/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php +++ b/app/code/Magento/Review/Test/Unit/Block/Customer/RecentTest.php @@ -135,6 +135,6 @@ class RecentTest extends \PHPUnit_Framework_TestCase $this->returnValue($this->collection) ); - $this->assertSame($this->collection, $this->object->getCollection()); + $this->assertSame($this->collection, $this->object->getReviews()); } } diff --git a/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml b/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml index 799a455f7e0f463ec93837c756085fbd45cfb0f8..7434c634ab44c53c0c10f2180e82d42031f0b390 100644 --- a/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml +++ b/app/code/Magento/Review/view/frontend/layout/customer_account_index.xml @@ -8,7 +8,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> - <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="customer/recent.phtml" after="customer_account_dashboard_address" cacheable="false"/> + <block class="Magento\Review\Block\Customer\Recent" name="customer_account_dashboard_info1" template="customer/recent.phtml" after="customer_account_dashboard_address"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml b/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml index 01a6340b9f2bc125783abc69f20482a0abae4b59..23bfd524f3265ceaccef483e8a9e7465895523cb 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_customer_index.xml @@ -9,7 +9,7 @@ <update handle="customer_account"/> <body> <referenceContainer name="content"> - <block class="Magento\Review\Block\Customer\ListCustomer" name="review_customer_list" template="customer/list.phtml" cacheable="false"/> + <block class="Magento\Review\Block\Customer\ListCustomer" name="review_customer_list" template="customer/list.phtml"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml b/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml index 43e7ba2afa619b3219ee10e1a3d447dd0259ee13..5895da97549768a18e46377139534f4c378436c6 100644 --- a/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml +++ b/app/code/Magento/Review/view/frontend/layout/review_customer_view.xml @@ -9,7 +9,7 @@ <update handle="customer_account"/> <body> <referenceContainer name="content"> - <block class="Magento\Review\Block\Customer\View" name="customers_review" cacheable="false"/> + <block class="Magento\Review\Block\Customer\View" name="customers_review"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/list.phtml b/app/code/Magento/Review/view/frontend/templates/customer/list.phtml index 4b28025a528c3a417e8a9636f7c33963e3d5eb78..e90990095151a90e6277319328689994401f1534 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/list.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/list.phtml @@ -5,9 +5,9 @@ */ // @codingStandardsIgnoreFile - +/** @var \Magento\Review\Block\Customer\ListCustomer $block */ ?> -<?php if ($block->getCollection() && $block->count()): ?> +<?php if ($block->getReviews() && count($block->getReviews())): ?> <div class="table-wrapper reviews"> <table class="data table table-reviews" id="my-reviews-table"> <caption class="table-caption"><?php echo __('Product Reviews') ?></caption> @@ -21,7 +21,7 @@ </tr> </thead> <tbody> - <?php foreach ($block->getCollection() as $_review): ?> + <?php foreach ($block->getReviews() as $_review): ?> <tr> <td data-th="<?php echo $block->escapeHtml(__('Created')) ?>" class="col date"><?php echo $block->dateFormat($_review->getReviewCreatedAt()); ?></td> <td data-th="<?php echo $block->escapeHtml(__('Product Name')) ?>" class="col item"> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml b/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml index 84a83bedefb087cc0582deebf44d6ea54e00d00b..6bb7aa429fcef85f443be27e2634faaded6e10f8 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/recent.phtml @@ -12,7 +12,7 @@ /** @var $block \Magento\Review\Block\Customer\Recent */ ?> -<?php if ($block->getCollection() && $block->count()): ?> +<?php if ($block->getReviews() && count($block->getReviews())): ?> <div class="block block-reviews-dashboard"> <div class="block-title"> <strong><?php echo __('My Recent Reviews') ?></strong> @@ -20,7 +20,7 @@ </div> <div class="block-content"> <ol class="items"> - <?php foreach ($block->getCollection() as $_review): ?> + <?php foreach ($block->getReviews() as $_review): ?> <li class="item"> <strong class="product-name"><a href="<?php echo $block->getReviewUrl($_review->getReviewId()) ?>"><?php echo $block->escapeHtml($_review->getName()) ?></a></strong> <?php if ($_review->getSum()): ?> diff --git a/app/code/Magento/Review/view/frontend/templates/customer/view.phtml b/app/code/Magento/Review/view/frontend/templates/customer/view.phtml index 34ab7ba21d39baffbcdf091d9127fb2cefb0e8d7..0a260e7c57a3fbe4398747fb6432f7518bf0dbdc 100644 --- a/app/code/Magento/Review/view/frontend/templates/customer/view.phtml +++ b/app/code/Magento/Review/view/frontend/templates/customer/view.phtml @@ -29,7 +29,7 @@ <div class="review-details"> <?php if ($block->getRating() && $block->getRating()->getSize()): ?> <div class="title"> - <strong><?php echo($block->isReviewOwner()) ? __('Your Review') : __('Review'); ?></strong> + <strong><?php echo __('Your Review'); ?></strong> </div> <div class="customer-review-rating"> <?php foreach ($block->getRating() as $_rating): ?> diff --git a/app/code/Magento/Sales/Block/Guest/Link.php b/app/code/Magento/Sales/Block/Guest/Link.php index 225a0be5f159550ecae71b6e1322117ad7799c26..4e432ceff508910699f81b2cd4bf90ca9e2cf161 100644 --- a/app/code/Magento/Sales/Block/Guest/Link.php +++ b/app/code/Magento/Sales/Block/Guest/Link.php @@ -33,7 +33,6 @@ class Link extends \Magento\Framework\View\Element\Html\Link\Current ) { parent::__construct($context, $defaultPath, $data); $this->httpContext = $httpContext; - $this->_isScopePrivate = true; } /** diff --git a/app/code/Magento/Sales/Block/Order/History.php b/app/code/Magento/Sales/Block/Order/History.php index 196382cbd7ee46f1f65cd6c8d27fbe112adb2993..adee793ade5d1ffff85a5db62af7121791627c57 100644 --- a/app/code/Magento/Sales/Block/Order/History.php +++ b/app/code/Magento/Sales/Block/Order/History.php @@ -30,6 +30,9 @@ class History extends \Magento\Framework\View\Element\Template */ protected $_orderConfig; + /** @var \Magento\Sales\Model\Resource\Order\Collection */ + protected $orders; + /** * @param \Magento\Framework\View\Element\Template\Context $context * @param \Magento\Sales\Model\Resource\Order\CollectionFactory $orderCollectionFactory @@ -57,39 +60,50 @@ class History extends \Magento\Framework\View\Element\Template protected function _construct() { parent::_construct(); - - $orders = $this->_orderCollectionFactory->create()->addFieldToSelect( - '*' - )->addFieldToFilter( - 'customer_id', - $this->_customerSession->getCustomerId() - )->addFieldToFilter( - 'status', - ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()] - )->setOrder( - 'created_at', - 'desc' - ); - - $this->setOrders($orders); $this->pageConfig->getTitle()->set(__('My Orders')); } + /** + * @return bool|\Magento\Sales\Model\Resource\Order\Collection + */ + public function getOrders() + { + if (!($customerId = $this->_customerSession->getCustomerId())) { + return false; + } + if (!$this->orders) { + $this->orders = $this->_orderCollectionFactory->create()->addFieldToSelect( + '*' + )->addFieldToFilter( + 'customer_id', + $customerId + )->addFieldToFilter( + 'status', + ['in' => $this->_orderConfig->getVisibleOnFrontStatuses()] + )->setOrder( + 'created_at', + 'desc' + ); + } + return $this->orders; + } + /** * @return $this */ protected function _prepareLayout() { parent::_prepareLayout(); - - $pager = $this->getLayout()->createBlock( - 'Magento\Theme\Block\Html\Pager', - 'sales.order.history.pager' - )->setCollection( - $this->getOrders() - ); - $this->setChild('pager', $pager); - $this->getOrders()->load(); + if ($this->getOrders()) { + $pager = $this->getLayout()->createBlock( + 'Magento\Theme\Block\Html\Pager', + 'sales.order.history.pager' + )->setCollection( + $this->getOrders() + ); + $this->setChild('pager', $pager); + $this->getOrders()->load(); + } return $this; } @@ -107,7 +121,7 @@ class History extends \Magento\Framework\View\Element\Template */ public function getViewUrl($order) { - return $this->getUrl('*/*/view', ['order_id' => $order->getId()]); + return $this->getUrl('sales/order/view', ['order_id' => $order->getId()]); } /** @@ -116,7 +130,7 @@ class History extends \Magento\Framework\View\Element\Template */ public function getTrackUrl($order) { - return $this->getUrl('*/*/track', ['order_id' => $order->getId()]); + return $this->getUrl('sales/order/track', ['order_id' => $order->getId()]); } /** @@ -125,7 +139,7 @@ class History extends \Magento\Framework\View\Element\Template */ public function getReorderUrl($order) { - return $this->getUrl('*/*/reorder', ['order_id' => $order->getId()]); + return $this->getUrl('sales/order/reorder', ['order_id' => $order->getId()]); } /** diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php index 4aab2e8cc19f3fe1788d0e4ddeb0cdcd3c94e07d..3552bc851409baec712b24f6ff4733a0185c15c5 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/Total/Config/BaseTest.php @@ -114,9 +114,7 @@ class BaseTest extends \PHPUnit_Framework_TestCase $this->returnValue([ 'some_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1903], 'other_code' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], - 'equal_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 1112], 'big_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal', 'sort_order' => 3000], - 'no_order' => ['instance' => 'Magento\Sales\Model\Order\Total\AbstractTotal'], ]) ); @@ -126,8 +124,6 @@ class BaseTest extends \PHPUnit_Framework_TestCase $this->assertSame( [ - 'no_order' => $total, - 'equal_order' => $total, 'other_code' => $total, 'some_code' => $total, 'big_order' => $total, diff --git a/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml b/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml index 0e7620a75693e4a879a1214035c612058a6885e7..0bdf0c8d2061a6d78872dbefc128c5c294dfd570 100644 --- a/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml +++ b/app/code/Magento/Sales/view/frontend/layout/customer_account_index.xml @@ -8,7 +8,7 @@ <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd"> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Order\Recent" name="customer_account_dashboard_top" after="customer_account_dashboard_hello" template="order/recent.phtml" cacheable="false"/> + <block class="Magento\Sales\Block\Order\Recent" name="customer_account_dashboard_top" after="customer_account_dashboard_hello" template="order/recent.phtml"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml b/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml index 7210c1c06163c6209b5819fa01c9332ab032d16e..62219a6e98970d5227425d928d677e8286abae7d 100644 --- a/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml +++ b/app/code/Magento/Sales/view/frontend/layout/sales_order_history.xml @@ -9,10 +9,10 @@ <update handle="customer_account"/> <body> <referenceContainer name="content"> - <block class="Magento\Sales\Block\Order\History" name="sales.order.history" cacheable="false"> + <block class="Magento\Sales\Block\Order\History" name="sales.order.history"> <container name="sales.order.history.info" as="info" label="Order History Info"/> </block> - <block class="Magento\Customer\Block\Account\Dashboard" name="customer.account.link.back" template="account/link/back.phtml" cacheable="false"/> + <block class="Magento\Customer\Block\Account\Dashboard" name="customer.account.link.back" template="account/link/back.phtml"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml index f0218c9507c02c76c7e45d78c6301f633ef366d7..dafd6a2a61513e9716520703a32fcd34f487655b 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml @@ -9,7 +9,7 @@ ?> <?php $_orders = $block->getOrders(); ?> <?php echo $block->getChildHtml('info');?> -<?php if ($_orders->getSize()): ?> +<?php if ($_orders && count($_orders)): ?> <div class="table-wrapper orders-history"> <table class="data table table-order-items history" id="my-orders-table"> <caption class="table-caption"><?php echo __('Orders') ?></caption> diff --git a/app/code/Magento/UrlRewrite/Controller/Router.php b/app/code/Magento/UrlRewrite/Controller/Router.php index ce2f31fc0d2a23af6fd36b0deb657e0c220a66dc..d6ae92b0f0e7700659f1e721237bb79287ce7936 100644 --- a/app/code/Magento/UrlRewrite/Controller/Router.php +++ b/app/code/Magento/UrlRewrite/Controller/Router.php @@ -85,6 +85,7 @@ class Router implements \Magento\Framework\App\RouterInterface return $this->processRedirect($request, $rewrite); } + $request->setAlias(\Magento\Framework\UrlInterface::REWRITE_REQUEST_PATH_ALIAS, $rewrite->getRequestPath()); $request->setPathInfo('/' . $rewrite->getTargetPath()); return $this->actionFactory->create('Magento\Framework\App\Action\Forward', ['request' => $request]); } diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php index 827d0b608c41d50d4018edf7d0d28bb63f50037a..67844a8956ffc4d634a3eb21aab8a993d17b73ae 100644 --- a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php +++ b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php @@ -252,8 +252,11 @@ class RouterTest extends \PHPUnit_Framework_TestCase ->disableOriginalConstructor()->getMock(); $urlRewrite->expects($this->any())->method('getRedirectType')->will($this->returnValue(0)); $urlRewrite->expects($this->any())->method('getTargetPath')->will($this->returnValue('target-path')); + $urlRewrite->expects($this->any())->method('getRequestPath')->will($this->returnValue('request-path')); $this->urlFinder->expects($this->any())->method('findOneByData')->will($this->returnValue($urlRewrite)); $this->request->expects($this->once())->method('setPathInfo')->with('/target-path'); + $this->request->expects($this->once())->method('setAlias') + ->with(\Magento\Framework\UrlInterface::REWRITE_REQUEST_PATH_ALIAS, 'request-path'); $this->actionFactory->expects($this->once())->method('create') ->with('Magento\Framework\App\Action\Forward', ['request' => $this->request]); diff --git a/app/code/Magento/Webapi/Model/Soap/Server.php b/app/code/Magento/Webapi/Model/Soap/Server.php index 541a47e2fe8dc0e22c544209280439a58f96081d..02370c9fc4f75302e884621d067eb3a5588cc7a0 100644 --- a/app/code/Magento/Webapi/Model/Soap/Server.php +++ b/app/code/Magento/Webapi/Model/Soap/Server.php @@ -14,11 +14,9 @@ class Server /**#@+ * Path in config to Webapi settings. */ - const CONFIG_PATH_WSDL_CACHE_ENABLED = 'webapi/soap/wsdl_cache_enabled'; - const CONFIG_PATH_SOAP_CHARSET = 'webapi/soap/charset'; - /**#@-*/ + const REQUEST_PARAM_SERVICES = 'services'; const REQUEST_PARAM_WSDL = 'wsdl'; @@ -101,16 +99,6 @@ class Server $this->_soapServerFactory = $soapServerFactory; $this->_typeProcessor = $typeProcessor; $this->_scopeConfig = $scopeConfig; - /** Enable or disable SOAP extension WSDL cache depending on Magento configuration. */ - $wsdlCacheEnabled = $this->_scopeConfig->isSetFlag( - self::CONFIG_PATH_WSDL_CACHE_ENABLED, - \Magento\Store\Model\ScopeInterface::SCOPE_STORE - ); - if ($wsdlCacheEnabled) { - ini_set('soap.wsdl_cache_enabled', '1'); - } else { - ini_set('soap.wsdl_cache_enabled', '0'); - } } /** diff --git a/app/code/Magento/Webapi/etc/adminhtml/system.xml b/app/code/Magento/Webapi/etc/adminhtml/system.xml index 9335abf34b7128239f69a3a0c9a6cff20e1e0ea9..12671fe2ba7793f4c17a7fd970d573b56c7c223f 100644 --- a/app/code/Magento/Webapi/etc/adminhtml/system.xml +++ b/app/code/Magento/Webapi/etc/adminhtml/system.xml @@ -19,11 +19,6 @@ <label>Default Response Charset</label> <comment>If empty, UTF-8 will be used.</comment> </field> - <field id="wsdl_cache_enabled" translate="label" type="select" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1"> - <label>Enable WSDL Cache</label> - <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> - <backend_model>Magento\Config\Model\Config\Backend\Store</backend_model> - </field> </group> </section> </system> diff --git a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml index 2c3de7069e91977efdb6b1002029a42df2d56fbd..b3a294959551111b2dd789d1f6ead5b382606ed5 100644 --- a/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml +++ b/app/code/Magento/Widget/view/adminhtml/templates/instance/edit/layout.phtml @@ -17,10 +17,11 @@ </fieldset> <script> require([ + 'jquery', 'mage/template', "prototype", "extjs/ext-tree-checkbox" -], function (mageTemplate) { +], function (jQuery, mageTemplate) { //<![CDATA[ @@ -476,7 +477,7 @@ var WidgetInstance = { window.WidgetInstance = WidgetInstance; -Ext.onReady(function(){ +jQuery(function(){ <?php foreach ($block->getPageGroups() as $pageGroup): ?> WidgetInstance.addPageGroup(<?php echo Zend_Json::encode($pageGroup) ?>); <?php endforeach; ?> diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php index 671ca5c98c92fbd288d5dc446727ff2c00230bc7..9a86641155cc6c1bc7c2c6e428a6d5b5bcd068e5 100644 --- a/app/code/Magento/Wishlist/Block/Customer/Wishlist.php +++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist.php @@ -30,12 +30,16 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock */ protected $_formKey; + /** @var \Magento\Customer\Helper\Session\CurrentCustomer */ + protected $currentCustomer; + /** * @param \Magento\Catalog\Block\Product\Context $context * @param \Magento\Framework\App\Http\Context $httpContext * @param \Magento\Catalog\Api\ProductRepositoryInterface $productRepository * @param \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool * @param \Magento\Framework\Data\Form\FormKey $formKey + * @param \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer * @param array $data */ public function __construct( @@ -44,16 +48,18 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, \Magento\Catalog\Helper\Product\ConfigurationPool $helperPool, \Magento\Framework\Data\Form\FormKey $formKey, + \Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer, array $data = [] ) { - $this->_formKey = $formKey; - $this->_helperPool = $helperPool; parent::__construct( $context, $httpContext, $productRepository, $data ); + $this->_formKey = $formKey; + $this->_helperPool = $helperPool; + $this->currentCustomer = $currentCustomer; } /** @@ -209,4 +215,16 @@ class Wishlist extends \Magento\Wishlist\Block\AbstractBlock ['wishlist_id' => $this->getWishlistInstance()->getId(), 'form_key' => $this->_formKey->getFormKey()] ); } + + /** + * @return string + */ + protected function _toHtml() + { + if ($this->currentCustomer->getCustomerId()) { + return parent::_toHtml(); + } else { + return ''; + } + } } diff --git a/app/code/Magento/Wishlist/Controller/Index/Add.php b/app/code/Magento/Wishlist/Controller/Index/Add.php index d19ecf32ff670c82b1ff4045a4557cf7f9340e37..997590a667ded0dfeea35e441ed5d1759b45f7e4 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Add.php +++ b/app/code/Magento/Wishlist/Controller/Index/Add.php @@ -112,10 +112,6 @@ class Add extends Action\Action implements IndexInterface $referer = $this->_redirect->getRefererUrl(); } - /** - * Set referer to avoid referring to the compare popup window - */ - $session->setAddActionReferer($referer); /** @var $helper \Magento\Wishlist\Helper\Data */ $helper = $this->_objectManager->get('Magento\Wishlist\Helper\Data')->calculate(); diff --git a/app/code/Magento/Wishlist/Controller/Index/Index.php b/app/code/Magento/Wishlist/Controller/Index/Index.php index 12fa1224384affd7e608c486aa87831a6d0ce909..56f08a2e53190b4d28b46d11c9e23642c6b72ea5 100644 --- a/app/code/Magento/Wishlist/Controller/Index/Index.php +++ b/app/code/Magento/Wishlist/Controller/Index/Index.php @@ -17,22 +17,14 @@ class Index extends Action\Action implements IndexInterface */ protected $wishlistProvider; - /** - * @var \Magento\Customer\Model\Session - */ - protected $_customerSession; - /** * @param Action\Context $context - * @param \Magento\Customer\Model\Session $customerSession * @param \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider */ public function __construct( Action\Context $context, - \Magento\Customer\Model\Session $customerSession, \Magento\Wishlist\Controller\WishlistProviderInterface $wishlistProvider ) { - $this->_customerSession = $customerSession; $this->wishlistProvider = $wishlistProvider; parent::__construct($context); } @@ -49,19 +41,7 @@ class Index extends Action\Action implements IndexInterface throw new NotFoundException(); } $this->_view->loadLayout(); - - $session = $this->_customerSession; - $block = $this->_view->getLayout()->getBlock('customer.wishlist'); - $referer = $session->getAddActionReferer(true); - if ($block) { - $block->setRefererUrl($this->_redirect->getRefererUrl()); - if ($referer) { - $block->setRefererUrl($referer); - } - } - $this->_view->getLayout()->initMessages(); - $this->_view->renderLayout(); } } diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php index fcff26f30b664a28a1c1866ed00ecced2d49bd64..0914b03d69877239bf3678b47a5001fd78da1974 100644 --- a/app/code/Magento/Wishlist/Helper/Data.php +++ b/app/code/Magento/Wishlist/Helper/Data.php @@ -387,7 +387,14 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper protected function _getCartUrlParameters($item) { $continueUrl = $this->urlEncoder->encode( - $this->_getUrl('*/*/*', ['_current' => true, '_use_rewrite' => true, '_scope_to_url' => true]) + $this->_getUrl( + 'wishlist/index/index', + [ + '_current' => true, + '_use_rewrite' => true, + '_scope_to_url' => true + ] + ) ); return [ diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php index 7efb091fa1718dbf272bd2d56c95f400f26dcde2..6b6695e96fa80008a4b0010f77c751f0c8f88e3a 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/AddTest.php @@ -255,7 +255,7 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('getParams') ->will($this->returnValue([])); - $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false ); + $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false); $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); $url = $this->getMock('Magento\Framework\Url', null, [], '', false); @@ -350,9 +350,9 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('getParams') ->will($this->returnValue(['product' => 2])); - $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false ); + $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false); $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false ); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); $url = $this->getMock('Magento\Framework\Url', null, [], '', false); $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', null, [], '', false); $redirect = $this->getMock('\Magento\Store\App\Response\Redirect', ['redirect'], [], '', false); @@ -460,9 +460,9 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('getParams') ->will($this->returnValue(['product' => 2])); - $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false ); + $om = $this->getMock('Magento\Framework\App\ObjectManager', null, [], '', false); $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false ); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', null, [], '', false); $url = $this->getMock('Magento\Framework\Url', null, [], '', false); $actionFlag = $this->getMock('Magento\Framework\App\ActionFlag', null, [], '', false); $redirect = $this->getMock('\Magento\Store\App\Response\Redirect', ['redirect'], [], '', false); @@ -589,7 +589,7 @@ class AddTest extends \PHPUnit_Framework_TestCase ->will($this->returnValue($product)); $exception = new \Exception('Exception'); - $wishListItem = new \stdClass(); + $wishListItem = new \stdClass(); $wishlist = $this->getMock('Magento\Wishlist\Model\Wishlist', ['addNewItem', 'save', 'getId'], [], '', false); $wishlist @@ -649,8 +649,8 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('critical') ->with($exception) ->will($this->returnValue(true)); - - $om = $this->getMock('Magento\Framework\App\ObjectManager', ['get'], [], '', false ); + + $om = $this->getMock('Magento\Framework\App\ObjectManager', ['get'], [], '', false); $om ->expects($this->at(0)) ->method('get') @@ -671,9 +671,9 @@ class AddTest extends \PHPUnit_Framework_TestCase ->method('get') ->with('Psr\Log\LoggerInterface') ->will($this->returnValue($logger)); - + $response = $this->getMock('Magento\Framework\App\Response\Http', null, [], '', false); - $eventManager = $this->getMock('Magento\Framework\Event\Manager', ['dispatch'], [], '', false ); + $eventManager = $this->getMock('Magento\Framework\Event\Manager', ['dispatch'], [], '', false); $eventManager ->expects($this->once()) ->method('dispatch') @@ -757,11 +757,6 @@ class AddTest extends \PHPUnit_Framework_TestCase ->expects($this->once()) ->method('getBeforeWishlistUrl') ->will($this->returnValue('http://test-url.com')); - $this->customerSession - ->expects($this->once()) - ->method('setAddActionReferer') - ->with('http://test-url.com') - ->will($this->returnValue(null)); $this->customerSession ->expects($this->once()) ->method('setBeforeWishlistUrl') diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php index e247ea5fbd595450f3558c82c0ba5ea7a08e1c3f..7199faa0652cb2eb5d9af9f4f585d83bd47c1113 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/IndexTest.php @@ -28,11 +28,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase */ protected $wishlistProvider; - /** - * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject - */ - protected $customerSession; - /** * @var \Magento\Framework\App\View|\PHPUnit_Framework_MockObject_MockObject */ @@ -48,7 +43,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->context = $this->getMock('Magento\Framework\App\Action\Context', [], [], '', false); $this->request = $this->getMock('Magento\Framework\App\Request\Http', [], [], '', false); $this->response = $this->getMock('Magento\Framework\App\Response\Http', [], [], '', false); - $this->customerSession = $this->getMock('Magento\Customer\Model\Session', [], [], '', false); $this->wishlistProvider = $this->getMock('Magento\Wishlist\Controller\WishlistProvider', [], [], '', false); $this->view = $this->getMock('Magento\Framework\App\View', [], [], '', false); $this->redirect = $this->getMock('\Magento\Store\App\Response\Redirect', [], [], '', false); @@ -105,7 +99,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase $this->prepareContext(); return new \Magento\Wishlist\Controller\Index\Index( $this->context, - $this->customerSession, $this->wishlistProvider ); } @@ -126,29 +119,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase { $wishlist = $this->getMock('Magento\Wishlist\Model\Wishlist', [], [], '', false); - $block = $this->getMock('Magento\Ui\Component\Form\Element\Input', [], [], '', false); - $block - ->expects($this->at(0)) - ->method('__call') - ->with('setRefererUrl', ['http://referer-url-test.com']) - ->willReturn(true); - $block - ->expects($this->at(1)) - ->method('__call') - ->with('setRefererUrl', ['http://referer-url.com']) - ->willReturn(true); - - $this->redirect - ->expects($this->once()) - ->method('getRefererUrl') - ->willReturn('http://referer-url-test.com'); - $layout = $this->getMock('Magento\Framework\View\Layout', [], [], '', false); - $layout - ->expects($this->once()) - ->method('getBlock') - ->with('customer.wishlist') - ->willReturn($block); $layout ->expects($this->once()) ->method('initMessages') @@ -164,7 +135,7 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->method('loadLayout') ->willReturn(true); $this->view - ->expects($this->exactly(2)) + ->expects($this->once()) ->method('getLayout') ->willReturn($layout); $this->view @@ -172,12 +143,6 @@ class IndexTest extends \PHPUnit_Framework_TestCase ->method('renderLayout') ->willReturn(true); - $this->customerSession - ->expects($this->once()) - ->method('__call') - ->with('getAddActionReferer', [true]) - ->willReturn('http://referer-url.com'); - $this->getController()->execute(); } } diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php index 6a317fb288eb3dd3ddb7412562778d444093bb26..f971e7af207e8780a89b6743121875a2a93b1ef2 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php @@ -182,12 +182,11 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ->with('product') ->willReturn(2); - $exception = $this->getMock('Magento\Framework\Exception\NoSuchEntityException', [], [], '', false); $this->productRepository ->expects($this->once()) ->method('getById') ->with(2) - ->willThrowException($exception); + ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException()); $this->messageManager ->expects($this->once()) @@ -369,16 +368,15 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase ->with('wishlist_update_item', ['wishlist' => $wishlist, 'product' => $product, 'item' => $item]) ->willReturn(true); - $exception = $this->getMock('\Magento\Framework\Exception\LocalizedException', [], [], '', false); $this->messageManager ->expects($this->once()) ->method('addSuccess') ->with('Test name has been updated in your wish list.', null) - ->willThrowException($exception); + ->willThrowException(new \Magento\Framework\Exception\LocalizedException('error-message')); $this->messageManager ->expects($this->once()) ->method('addError') - ->with('', null) + ->with('error-message', null) ->willReturn(true); $this->redirect @@ -399,7 +397,7 @@ class UpdateItemOptionsTest extends \PHPUnit_Framework_TestCase $item = $this->getMock('Magento\Wishlist\Model\Item', [], [], '', false); $helper = $this->getMock('Magento\Wishlist\Helper\Data', [], [], '', false); $logger = $this->getMock('Magento\Framework\Logger\Monolog', [], [], '', false); - $exception = $this->getMock('Exception', [], [], '', false); + $exception = new \Exception(); $logger ->expects($this->once()) diff --git a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php index 5bb6173097935c6100c2fa4b4ad1902fd7776e71..08108bf77b12d79d8f9768eceac6c0db4ecf24d3 100644 --- a/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Wishlist/Test/Unit/Helper/DataTest.php @@ -72,7 +72,7 @@ class DataTest extends \PHPUnit_Framework_TestCase } else { $urlBuilder->expects($this->any()) ->method('getUrl') - ->with('*/*/*', ['_current' => true, '_use_rewrite' => true, '_scope_to_url' => true]) + ->with('wishlist/index/index', ['_current' => true, '_use_rewrite' => true, '_scope_to_url' => true]) ->will($this->returnValue($this->url)); } diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml index 874fa3beb833d6396c21af38e820c31521851564..b67ab0352d844cb2edd890d8b2b00b2593cdac7f 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_configure.xml @@ -9,7 +9,7 @@ <update handle="catalog_product_view"/> <body> <referenceContainer name="product.info.social"> - <block class="Magento\Wishlist\Block\Item\Configure" name="product.info.addto" as="addto" template="Magento_Wishlist::item/configure/addto.phtml"/> + <block class="Magento\Wishlist\Block\Item\Configure" name="product.info.addto" as="addto" template="Magento_Wishlist::item/configure/addto.phtml" cacheable="false"/> </referenceContainer> </body> </page> diff --git a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml index 5f000a79c1859578ac853abd49df7f58ad7d65e1..6943f7e2ee4f9407a94822274ea69ac442d37747 100644 --- a/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml +++ b/app/code/Magento/Wishlist/view/frontend/layout/wishlist_index_index.xml @@ -12,12 +12,12 @@ <block class="Magento\Framework\View\Element\Js\Components" name="wishlist_head_components" template="Magento_Wishlist::js/components.phtml"/> </referenceBlock> <referenceContainer name="content"> - <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="view.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist" name="customer.wishlist" template="view.phtml"> <block class="Magento\Wishlist\Block\Rss\Link" name="wishlist.rss.link" template="rss/wishlist.phtml"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="item/list.phtml" cacheable="false"> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="item/column/image.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.price" template="item/column/price.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Items" name="customer.wishlist.items" as="items" template="item/list.phtml"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Image" name="customer.wishlist.item.image" template="item/column/image.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Info" name="customer.wishlist.item.name" template="item/column/name.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.price" template="item/column/price.phtml"> <block class="Magento\Catalog\Pricing\Render" name="product.price.render.wishlist"> <arguments> <argument name="price_render" xsi:type="string">product.price.render.default</argument> @@ -26,36 +26,36 @@ <argument name="zone" xsi:type="string">item_list</argument> </arguments> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Options" name="customer.wishlist.item.options" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Options" name="customer.wishlist.item.options"/> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.inner" template="item/column/actions.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.inner" template="item/column/actions.phtml"> <arguments> <argument name="css_class" xsi:type="string">product-item-inner</argument> </arguments> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Comment" name="customer.wishlist.item.comment" template="item/column/comment.phtml"> <arguments> <argument name="title" translate="true" xsi:type="string">Product Details and Comment</argument> </arguments> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.cart" template="item/column/cart.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Cart" name="customer.wishlist.item.cart" template="item/column/cart.phtml"> <arguments> <argument name="title" translate="true" xsi:type="string">Add to Cart</argument> </arguments> </block> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.actions" template="item/column/actions.phtml" cacheable="false"> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Actions" name="customer.wishlist.item.actions" template="item/column/actions.phtml"> <arguments> <argument name="css_class" xsi:type="string">product-item-actions</argument> </arguments> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Edit" name="customer.wishlist.item.edit" template="item/column/edit.phtml" before="-" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Remove" name="customer.wishlist.item.remove" template="item/column/remove.phtml" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Edit" name="customer.wishlist.item.edit" template="item/column/edit.phtml" before="-"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Item\Column\Remove" name="customer.wishlist.item.remove" template="item/column/remove.phtml"/> </block> </block> </block> <container name="customer.wishlist.buttons" as="control_buttons" label="Wishlist Control Buttons"> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.update" template="button/update.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.share" template="button/share.phtml" cacheable="false"/> - <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.toCart" template="button/tocart.phtml" cacheable="false"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.update" template="button/update.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.share" template="button/share.phtml"/> + <block class="Magento\Wishlist\Block\Customer\Wishlist\Button" name="customer.wishlist.button.toCart" template="button/tocart.phtml"/> </container> </block> </referenceContainer> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml b/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml index 9b145c00421d1ac1884b166358cf13ac9d081aef..9a94c0a193811fa75baa0a8cc99aaa121adfbde4 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/shared.phtml @@ -11,7 +11,7 @@ $imageBlock = $block->getLayout()->createBlock('Magento\Catalog\Block\Product\I ?> <?php if ($block->hasWishlistItems()): ?> - <form class="form shared wishlist" action="<?php echo $block->getUrl('*/*/update') ?>" method="post"> + <form class="form shared wishlist" action="<?php echo $block->getUrl('wishlist/index/update') ?>" method="post"> <div class="wishlist table-wrapper"> <table class="table data wishlist" id="wishlist-table"> <caption class="table-caption"><?php echo __('Wish List'); ?></caption> diff --git a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml index 52ea6d9490f7355b7ae6594bd4ebebbc3250a910..035364489f3caa8386c6d57bd34e6994b2d965ac 100644 --- a/app/code/Magento/Wishlist/view/frontend/templates/view.phtml +++ b/app/code/Magento/Wishlist/view/frontend/templates/view.phtml @@ -25,7 +25,7 @@ "confirmRemoveMessage":"<?php echo __("Are you sure you want to remove this product from your wishlist?") ?>", "addAllToCartUrl":"<?php echo $block->getAddAllToCartUrl(); ?>", "commentString":""}, - "validation": {}}' action="<?php echo $block->getUrl('*/*/update', ['wishlist_id' => $block->getWishlistInstance()->getId()]) ?>" method="post"> + "validation": {}}' action="<?php echo $block->getUrl('wishlist/index/update', ['wishlist_id' => $block->getWishlistInstance()->getId()]) ?>" method="post"> <?php echo $block->getChildHtml('top'); ?> <?php if ($block->hasWishlistItems()): ?> <?php echo $block->getBlockHtml('formkey');?> diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php index c8e4a55b1eeb5f9181ce660ec91d33d9ccb954d8..4ea45309be3c9c937a6c15bbc2e5d7eccf50fc13 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductAttributeManagementTest.php @@ -20,7 +20,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web public function testGetAttributes() { - $attributeSetId = \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID; + $attributeSetId = 4; $serviceInfo = [ 'rest' => [ @@ -155,7 +155,7 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web $serviceInfo, [ 'attributeSetId' => $payload['attributeSetId'], - 'attributeCode' => $payload['attributeCode'] + 'attributeCode' => $payload['attributeCode'], ] ) ); @@ -164,10 +164,10 @@ class ProductAttributeManagementTest extends \Magento\TestFramework\TestCase\Web protected function getAttributeData() { return [ - 'attributeSetId' => \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID, + 'attributeSetId' => 4, 'attributeGroupId' => 8, 'attributeCode' => 'cost', - 'sortOrder' => 3 + 'sortOrder' => 3, ]; } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php index dcd021475a053f48137961d472a5dd119be6fa3b..5d12b4575d9adc26f53cb67398eb84941db42375 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Cart.php @@ -57,6 +57,13 @@ class Cart extends Block */ protected $cartEmpty = '.cart-empty'; + /** + * Cart container selector + * + * @var string + */ + protected $cartContainer = '.cart-container'; + /** * Get cart item block * @@ -170,4 +177,12 @@ class Cart extends Block { return $this->_rootElement->find($this->cartEmpty, Locator::SELECTOR_CSS)->isVisible(); } + + /** + * Wait while cart container is loaded + */ + public function waitCartContainerLoading() + { + $this->waitForElementVisible($this->cartContainer); + } } diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php index 9813b554032d126da7ec78f111d92c6c6fca7918..d49dd6cec919433d45319097da2f5884fa1c5ec3 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/EstimateShippingAndTaxStep.php @@ -106,6 +106,7 @@ class EstimateShippingAndTaxStep implements TestStepInterface public function run() { $this->checkoutCart->open(); + $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); /** @var \Magento\Checkout\Test\Fixture\Cart $cart */ if ($this->cart !== null) { $cart = $this->fixtureFactory->createByCode( @@ -113,6 +114,7 @@ class EstimateShippingAndTaxStep implements TestStepInterface ['data' => array_merge($this->cart->getData(), ['items' => ['products' => $this->products]])] ); $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($this->address); + $this->checkoutCart->getCartBlock()->waitCartContainerLoading(); if (!empty($this->shipping)) { $this->checkoutCart->getShippingBlock()->selectShippingMethod($this->shipping); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php index 1bffd3078e356fb693004493a4ba3dabe5f210ef..bff724ba12559379b2bf9dc7e35b3d95a0d8714a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Constraint/AssertCustomerDefaultAddresses.php @@ -25,6 +25,7 @@ class AssertCustomerDefaultAddresses extends AbstractConstraint public function processAssert(CustomerAccountIndex $customerAccountIndex, Address $address) { $customerAccountIndex->getAccountMenuBlock()->openMenuItem('Account Dashboard'); + sleep(6); $defaultBillingAddress = explode( "\n", $customerAccountIndex->getDashboardAddress()->getDefaultBillingAddressText() diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php index b42c48cbb8013423b8dd0e502972d240387331b5..1831cdcbd2168ecca66ec836b256511705db838a 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/Handler/Customer/Curl.php @@ -93,7 +93,8 @@ class Curl extends AbstractCurl implements CustomerInterface $curl->write(CurlInterface::POST, $url, '1.0', [], $data); $response = $curl->read(); $curl->close(); - if (!strpos($response, 'data-ui-id="global-messages-message-success"')) { + // After caching My Account page we cannot check by success message + if (!strpos($response, 'customer/account/logout')) { throw new \Exception("Customer entity creating by curl handler was not successful! Response: $response"); } diff --git a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php index 5fdcc4b7c39932cc2f0ab925a8f79d8f8b6d40fe..036c03c76f7e381b633155db19993757a37ceadd 100644 --- a/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/UpdateCustomerFrontendEntityTest.php @@ -134,6 +134,7 @@ class UpdateCustomerFrontendEntityTest extends Injectable // Steps $this->cmsIndex->open(); $this->cmsIndex->getLinksBlock()->openLink('Log In'); + sleep(3); $this->customerAccountLogin->getLoginBlock()->fill($initialCustomer); $this->customerAccountLogin->getLoginBlock()->submit(); diff --git a/dev/tests/integration/framework/bootstrap.php b/dev/tests/integration/framework/bootstrap.php index c28fdc6d7a0d92fdb9aa5c64b37cbcc3eaa8e13c..41453aa0becc0e2d32513736f2cb99ddc60e8854 100644 --- a/dev/tests/integration/framework/bootstrap.php +++ b/dev/tests/integration/framework/bootstrap.php @@ -32,7 +32,7 @@ try { $installConfigFile = $installConfigFile . '.dist'; } $sandboxUniqueId = md5(sha1_file($installConfigFile)); - $installDir = "{$testsTmpDir}/sandbox-{$sandboxUniqueId}"; + $installDir = "{$testsTmpDir}/sandbox-{$settings->get('TESTS_PARALLEL_THREAD', 0)}-{$sandboxUniqueId}"; $application = new \Magento\TestFramework\Application( $shell, $installDir, diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php index 65ec766a6c8366ae3ece6783d7b662e458fa011d..559381cbe85dfad46f6e7666d81f66f0b0ea47d8 100644 --- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Cache/MassActionTest.php @@ -6,8 +6,8 @@ namespace Magento\Backend\Controller\Adminhtml\Cache; -use Magento\TestFramework\Helper\Bootstrap; use Magento\Framework\App\Cache\Type\ConfigSegment; +use Magento\TestFramework\Helper\Bootstrap; class MassActionTest extends \Magento\Backend\Utility\Controller { @@ -32,8 +32,8 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $cacheState = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); foreach (self::$typesSegment->getData() as $type => $value) { $cacheState->setEnabled($type, $value); - $cacheState->persist(); } + $cacheState->persist(); parent::tearDown(); } @@ -48,18 +48,11 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $this->getRequest()->setParams(['types' => $typesToEnable]); $this->dispatch('backend/admin/cache/massEnable'); - Bootstrap::getInstance()->reinitialize(); - - /** @var \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); - $types = array_keys($cacheTypeList->getTypes()); - /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ - $cacheState = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); - foreach ($types as $type) { - if (in_array($type, $typesToEnable)) { - $this->assertTrue($cacheState->isEnabled($type), "Type '{$type}' has not been enabled"); + foreach ($this->getCacheStates() as $cacheType => $cacheState) { + if (in_array($cacheType, $typesToEnable)) { + $this->assertEquals(1, $cacheState, "Type '{$cacheType}' has not been enabled"); } else { - $this->assertFalse($cacheState->isEnabled($type), "Type '{$type}' must remain disabled"); + $this->assertEquals(0, $cacheState, "Type '{$cacheType}' has not been enabled"); } } } @@ -75,22 +68,31 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $this->getRequest()->setParams(['types' => $typesToDisable]); $this->dispatch('backend/admin/cache/massDisable'); - Bootstrap::getInstance()->reinitialize(); - - /** @var \Magento\Framework\App\Cache\TypeListInterface $cacheTypeList */ - $cacheTypeList = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); - $types = array_keys($cacheTypeList->getTypes()); - /** @var $cacheState \Magento\Framework\App\Cache\StateInterface */ - $cacheState = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\StateInterface'); - foreach ($types as $type) { - if (in_array($type, $typesToDisable)) { - $this->assertFalse($cacheState->isEnabled($type), "Type '{$type}' has not been disabled"); + foreach ($this->getCacheStates() as $cacheType => $cacheState) { + if (in_array($cacheType, $typesToDisable)) { + $this->assertEquals(0, $cacheState, "Type '{$cacheType}' has not been disabled"); } else { - $this->assertTrue($cacheState->isEnabled($type), "Type '{$type}' must remain enabled"); + $this->assertEquals(1, $cacheState, "Type '{$cacheType}' must remain enabled"); } } } + /** + * Retrieve cache states (enabled/disabled) information + * + * Access configuration file directly as it is not possible to re-include modified file under HHVM + * @link https://github.com/facebook/hhvm/issues/1447 + * + * @return array + * @SuppressWarnings(PHPMD.EvalExpression) + */ + protected function getCacheStates() + { + $configPath = Bootstrap::getInstance()->getAppTempDir() . '/etc/config.php'; + $configData = eval(str_replace('<?php', '', file_get_contents($configPath))); + return $configData['cache_types']; + } + /** * Sets all cache types to enabled or disabled state * @@ -121,7 +123,7 @@ class MassActionTest extends \Magento\Backend\Utility\Controller $cacheTypeList = Bootstrap::getObjectManager()->get('Magento\Framework\App\Cache\TypeListInterface'); $invalidatedTypes = array_keys($cacheTypeList->getInvalidated()); $failed = array_intersect($typesToRefresh, $invalidatedTypes); - $this->assertEmpty($failed, 'Could not refresh following cache types: ' . join(', ', $failed)); + $this->assertEmpty($failed, 'Could not refresh following cache types: ' . implode(', ', $failed)); } /** @@ -135,8 +137,8 @@ class MassActionTest extends \Magento\Backend\Utility\Controller [ \Magento\Framework\App\Cache\Type\Config::TYPE_IDENTIFIER, \Magento\Framework\App\Cache\Type\Layout::TYPE_IDENTIFIER, - \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER - ] + \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER, + ], ] ]; } diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php index a11e5dfd4549f0fe9a3e29236d36ce6fa88f6b41..1af4fd36b8f494e3005f00b50ed0609d290c5e55 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/NewActionTest.php @@ -22,10 +22,7 @@ class NewActionTest extends \Magento\Backend\Utility\Controller */ public function testCustomerGroupArePresentInGroupPriceTemplate() { - $this->dispatch('backend/catalog/product/new/set/' - . \Magento\Catalog\Api\Data\ProductAttributeInterface::DEFAULT_ATTRIBUTE_SET_ID - . '/type/' . \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE - ); + $this->dispatch('backend/catalog/product/new/set/4/type/' . \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE); $lines = explode(PHP_EOL, $this->getResponse()->getBody()); foreach ($lines as $index => $line) { if ($line && strpos($line, 'name="product[group_price][<%- data.index %>][cust_group]"') !== false) { diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php index 640c2c286a300a133a6e30322828d504a7ef6c8a..6be24179208de756406648fd6107c19d68720e3a 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php @@ -9,8 +9,19 @@ */ namespace Magento\Catalog\Controller; +/** + * @magentoAppIsolation enabled + */ class ProductTest extends \Magento\TestFramework\TestCase\AbstractController { + protected function setUp() + { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped('Randomly fails due to known HHVM bug (DOMText mixed with DOMElement)'); + } + parent::setUp(); + } + public function assert404NotFound() { parent::assert404NotFound(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php index 7569dd3be71a0777011c129dbac3e0b190728c51..d39b040df295d85c733c3a86613ac5860b33da06 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorFileTest.php @@ -25,10 +25,21 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase */ protected $httpFactoryMock; + /** @var int */ + protected $maxFileSizeInMb; + + /** @var int */ + protected $maxFileSize; + protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->httpFactoryMock = $this->getMock('Magento\Framework\HTTP\Adapter\FileTransferFactory', ['create']); + /** @var \Magento\Framework\File\Size $fileSize */ + $fileSize = $this->objectManager->create('Magento\Framework\File\Size'); + $this->maxFileSize = $fileSize->getMaxFileSize(); + $this->maxFileSizeInMb = $fileSize->getMaxFileSizeInMb(); + $this->model = $this->objectManager->create( 'Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile', [ @@ -53,14 +64,16 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase } /** - * @expectedException \Magento\Framework\Exception\File\LargeSizeException - * @expectedExceptionMessage The file you uploaded is larger than 2 Megabytes allowed by server * @return void */ public function testLargeSizeException() { + $this->setExpectedException( + '\Magento\Framework\Exception\File\LargeSizeException', + sprintf('The file you uploaded is larger than %s Megabytes allowed by server', $this->maxFileSizeInMb) + ); $this->prepareEnv(); - $_SERVER['CONTENT_LENGTH'] = 2097153; + $_SERVER['CONTENT_LENGTH'] = $this->maxFileSize + 1; $httpAdapterMock = $this->getMock('Zend_File_Transfer_Adapter_Http', ['getFileInfo']); $exception = function () { throw new \Exception(); @@ -122,7 +135,10 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "Maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" - . "The file 'test.jpg' you uploaded is larger than the 2 megabytes allowed by our server." + . sprintf( + "The file 'test.jpg' you uploaded is larger than the %s megabytes allowed by our server.", + $this->maxFileSizeInMb + ) ); $this->prepareEnv(); $httpAdapterMock = $this->getMock('Zend_File_Transfer_Adapter_Http', ['isValid', 'getErrors']); @@ -201,7 +217,7 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase */ protected function prepareEnv() { - $file = 'magento_small_image.jpg'; + $file = 'magento_small_image.jpg'; /** @var \Magento\Framework\Filesystem $filesystem */ $filesystem = $this->objectManager->get('Magento\Framework\Filesystem'); @@ -215,7 +231,6 @@ class ValidatorFileTest extends \PHPUnit_Framework_TestCase 'error' => 0, 'size' => 12500, ]; - $_SERVER['CONTENT_LENGTH'] = 2097152; } /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php index 101e0456b84b53e427f44b7d301908fdd1d4cbb6..d0a5bdb5bdf034ed408ef27de589cc31626d10ea 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Type/File/ValidatorInfoTest.php @@ -20,6 +20,9 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase */ protected $objectManager; + /** @var int */ + protected $maxFileSizeInMb; + /** * @var \Magento\Catalog\Model\Product\Option\Type\File\ValidateFactory|\PHPUnit_Framework_MockObject_MockObject */ @@ -28,6 +31,10 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase protected function setUp() { $this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + /** @var \Magento\Framework\File\Size $fileSize */ + $fileSize = $this->objectManager->create('Magento\Framework\File\Size'); + $this->maxFileSizeInMb = $fileSize->getMaxFileSizeInMb(); + $this->validateFactoryMock = $this->getMock( 'Magento\Catalog\Model\Product\Option\Type\File\ValidateFactory', ['create'] @@ -50,7 +57,10 @@ class ValidatorInfoTest extends \PHPUnit_Framework_TestCase "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "The file 'test.jpg' for 'MediaOption' has an invalid extension.\n" . "Maximum allowed image size for 'MediaOption' is 2000x2000 px.\n" - . "The file 'test.jpg' you uploaded is larger than the 2 megabytes allowed by our server." + . sprintf( + "The file 'test.jpg' you uploaded is larger than the %s megabytes allowed by our server.", + $this->maxFileSizeInMb + ) ); $validateMock = $this->getMock('Zend_Validate', ['isValid', 'getErrors']); diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php index 1563fc9e8d6ea3b382a1bd7bffbdb622359f199a..eb7f1a37ba216ffaa43d603e87ae475e6b3accc6 100644 --- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php +++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php @@ -322,7 +322,7 @@ class ProductTest extends \PHPUnit_Framework_TestCase $this->_model->importData(); - reset($source); + $source->rewind(); foreach ($source as $row) { /** @var $productAfterImport \Magento\Catalog\Model\Product */ $productBeforeImport = $productsBeforeImport[$row['sku']]; diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php index 017943a3a4fc5d6348415577a6139bc26d6c561e..42524e3ea0ed5ceb5cdcef04bc51b2ed3e308b31 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Block/Cart/Item/RendererTest.php @@ -6,6 +6,7 @@ namespace Magento\Checkout\Block\Cart\Item; /** + * @magentoDbIsolation enabled * @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_and_image.php */ class RendererTest extends \PHPUnit_Framework_TestCase diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php index 85d670d1caea880f8158b3145df8786e4c013ccc..5632555d4bec588f7650bb837bd0b1a40eaf7750 100644 --- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php +++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php @@ -9,6 +9,9 @@ */ namespace Magento\Checkout\Controller; +/** + * @magentoDbIsolation enabled + */ class CartTest extends \Magento\TestFramework\TestCase\AbstractController { /** diff --git a/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php b/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php index b1440adba626ebfd24344841aecbc544780ea734..248c90684a529a95cba9717392663360e6ed2a5f 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Image/Adapter/InterfaceTest.php @@ -7,6 +7,9 @@ namespace Magento\Framework\Image\Adapter; use Magento\Framework\App\Filesystem\DirectoryList; +/** + * @magentoAppIsolation enabled + */ class InterfaceTest extends \PHPUnit_Framework_TestCase { /** @@ -107,6 +110,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase * Mark test as skipped if not * * @param string $adapterType + * @return \Magento\Framework\Image\Adapter\AdapterInterface */ protected function _getAdapter($adapterType) { @@ -319,7 +323,7 @@ class InterfaceTest extends \PHPUnit_Framework_TestCase $pixel['y'] -= $center['y']; return [ 'x' => round($size[0] / 2 + $pixel['x'] * cos($angle) + $pixel['y'] * sin($angle), 0), - 'y' => round($size[1] / 2 + $pixel['y'] * cos($angle) - $pixel['x'] * sin($angle), 0) + 'y' => round($size[1] / 2 + $pixel['y'] * cos($angle) - $pixel['x'] * sin($angle), 0), ]; } diff --git a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php index 68a1a23fec84a94e7e220cf1961af26459de37cc..9962b27826a785f1a29388d735b8e67bc5497757 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/Session/ConfigTest.php @@ -210,11 +210,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertSame((bool)ini_get('session.cookie_secure'), $this->_model->getCookieSecure()); } - public function testCookieSecureIsMutable() + public function testSetCookieSecureInOptions() { - $value = ini_get('session.cookie_secure') ? false : true; - $this->_model->setCookieSecure($value); - $this->assertEquals($value, $this->_model->getCookieSecure()); + $this->_model->setCookieSecure(true); + $this->assertTrue($this->_model->getCookieSecure()); } public function testCookieDomainIsMutable() @@ -243,11 +242,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals($preVal, $this->_model->getCookieDomain()); } - public function testCookieHttpOnlyIsMutable() + public function testSetCookieHttpOnlyInOptions() { - $value = ini_get('session.cookie_httponly') ? false : true; - $this->_model->setCookieHttpOnly($value); - $this->assertEquals($value, $this->_model->getCookieHttpOnly()); + $this->_model->setCookieHttpOnly(true); + $this->assertTrue($this->_model->getCookieHttpOnly()); } public function testUseCookiesDefaultsToIniSettings() @@ -255,11 +253,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertSame((bool)ini_get('session.use_cookies'), $this->_model->getUseCookies()); } - public function testUseCookiesIsMutable() + public function testSetUseCookiesInOptions() { - $value = ini_get('session.use_cookies') ? false : true; - $this->_model->setUseCookies($value); - $this->assertEquals($value, (bool)$this->_model->getUseCookies()); + $this->_model->setUseCookies(true); + $this->assertTrue($this->_model->getUseCookies()); } public function testUseOnlyCookiesDefaultsToIniSettings() @@ -267,11 +264,10 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertSame((bool)ini_get('session.use_only_cookies'), $this->_model->getUseOnlyCookies()); } - public function testUseOnlyCookiesIsMutable() + public function testSetUseOnlyCookiesInOptions() { - $value = ini_get('session.use_only_cookies') ? false : true; - $this->_model->setOption('use_only_cookies', $value); - $this->assertEquals($value, (bool)$this->_model->getOption('use_only_cookies')); + $this->_model->setOption('use_only_cookies', true); + $this->assertTrue((bool)$this->_model->getOption('use_only_cookies')); } public function testRefererCheckDefaultsToIniSettings() diff --git a/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php b/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php index 6df823cf87be89fbe8ce929fc99b91eafaa09954..4dde9773e60fba23c54046012b38a02ebcc2cb6c 100644 --- a/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php +++ b/dev/tests/integration/testsuite/Magento/Framework/View/Layout/Reader/BlockTest.php @@ -43,7 +43,9 @@ class BlockTest extends \PHPUnit_Framework_TestCase public function testInterpretBlockDirective() { $pageXml = new \Magento\Framework\View\Layout\Element( - __DIR__ . '/_files/_layout_update_block.xml', 0, true + __DIR__ . '/_files/_layout_update_block.xml', + 0, + true ); $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>'); @@ -71,13 +73,12 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->assertEquals($this->blockName, $structure->getStructure()[$this->childBlockName][self::IDX_PARENT]); } - /** - * @depends testInterpretBlockDirective - */ public function testInterpretReferenceBlockDirective() { $pageXml = new \Magento\Framework\View\Layout\Element( - __DIR__ . '/_files/_layout_update_reference.xml', 0, true + __DIR__ . '/_files/_layout_update_reference.xml', + 0, + true ); $parentElement = new \Magento\Framework\View\Layout\Element('<page></page>'); diff --git a/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php b/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php index 2a391f73699dac69a704b6773606ff61175da86f..96ea9e4516f60f0b3cbf7a26b20a3d67235ee5d4 100644 --- a/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php +++ b/dev/tests/integration/testsuite/Magento/MemoryUsageTest.php @@ -19,6 +19,9 @@ class MemoryUsageTest extends \PHPUnit_Framework_TestCase protected function setUp() { + if (defined('HHVM_VERSION')) { + $this->markTestSkipped("For HHVM it's not relevant while MAGETWO-33679 is not resolved"); + } $this->_helper = new \Magento\TestFramework\Helper\Memory( new \Magento\Framework\Shell(new \Magento\Framework\Shell\CommandRenderer()) ); diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php index f0d383549ac913e94928aa365da58946c2f0195b..985b0fd9bad9c0594b81362d179b0c7997a835c6 100644 --- a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/EmailTest.php @@ -6,6 +6,9 @@ namespace Magento\ProductAlert\Model; +/** + * @magentoAppIsolation enabled + */ class EmailTest extends \PHPUnit_Framework_TestCase { /** diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php index cc314c331967cfc805c86ba53d785003edd4835c..10b2024b303668c00168d2f466bd8cb123714801 100644 --- a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php +++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php @@ -5,6 +5,9 @@ */ namespace Magento\ProductAlert\Model; +/** + * @magentoAppIsolation enabled + */ class ObserverTest extends \PHPUnit_Framework_TestCase { /** diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php deleted file mode 100644 index 84a5a3269427b85aa6aadaaa7aacdfdfcd8bfab9..0000000000000000000000000000000000000000 --- a/dev/tests/integration/testsuite/Magento/Webapi/Model/Soap/ServerTest.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php -/** - * Test SOAP server model. - * - * Copyright © 2015 Magento. All rights reserved. - * See COPYING.txt for license details. - */ -namespace Magento\Webapi\Model\Soap; - -class ServerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_configScopeMock; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $_areaListMock; - - /** @var \Magento\Webapi\Controller\Soap\Request */ - protected $_requestMock; - - /** @var \Magento\Framework\DomDocument\Factory */ - protected $_domDocumentFactory; - - /** @var \Magento\Store\Model\Store */ - protected $_storeMock; - - /** @var \Magento\Store\Model\StoreManagerInterface */ - protected $_storeManagerMock; - - /** @var \Magento\Webapi\Model\Soap\ServerFactory */ - protected $_soapServerFactory; - - /** @var \Magento\Framework\Reflection\TypeProcessor */ - protected $_typeProcessor; - - /** @var \Magento\Store\Model\Store|\PHPUnit_Framework_MockObject_MockObject */ - protected $_configMock; - - protected function setUp() - { - $this->_storeManagerMock = $this->getMockBuilder( - 'Magento\Store\Model\StoreManager' - )->disableOriginalConstructor()->getMock(); - $this->_storeMock = $this->getMockBuilder( - 'Magento\Store\Model\Store' - )->disableOriginalConstructor()->getMock(); - - $this->_areaListMock = $this->getMock('Magento\Framework\App\AreaList', [], [], '', false); - $this->_configScopeMock = $this->getMock('Magento\Framework\Config\ScopeInterface'); - $this->_storeManagerMock->expects( - $this->any() - )->method( - 'getStore' - )->will( - $this->returnValue($this->_storeMock) - ); - $this->_requestMock = $this->getMockBuilder( - 'Magento\Webapi\Controller\Soap\Request' - )->disableOriginalConstructor()->getMock(); - $this->_domDocumentFactory = $this->getMockBuilder( - 'Magento\Framework\DomDocument\Factory' - )->disableOriginalConstructor()->getMock(); - $this->_soapServerFactory = $this->getMockBuilder( - 'Magento\Webapi\Model\Soap\ServerFactory' - )->disableOriginalConstructor()->getMock(); - $this->_typeProcessor = $this->getMock( - 'Magento\Framework\Reflection\TypeProcessor', - [], - [], - '', - false - ); - $this->_configMock = $this->getMock('Magento\Framework\App\Config\ScopeConfigInterface'); - - parent::setUp(); - } - - /** - * Test SOAP server construction with WSDL cache enabling. - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - public function testConstructEnableWsdlCache() - { - /** Mock getConfig method to return true. */ - $this->_configMock->expects($this->once())->method('isSetFlag')->will($this->returnValue(true)); - /** Create SOAP server object. */ - $server = new \Magento\Webapi\Model\Soap\Server( - $this->_areaListMock, - $this->_configScopeMock, - $this->_requestMock, - $this->_domDocumentFactory, - $this->_storeManagerMock, - $this->_soapServerFactory, - $this->_typeProcessor, - $this->_configMock - ); - /** Assert that SOAP WSDL caching option was enabled after SOAP server initialization. */ - $this->assertTrue((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not enabled.'); - } - - /** - * Test SOAP server construction with WSDL cache disabling. - * @SuppressWarnings(PHPMD.UnusedLocalVariable) - */ - public function testConstructDisableWsdlCache() - { - /** Mock getConfig method to return false. */ - $this->_configMock->expects($this->once())->method('isSetFlag')->will($this->returnValue(false)); - /** Create SOAP server object. */ - $server = new \Magento\Webapi\Model\Soap\Server( - $this->_areaListMock, - $this->_configScopeMock, - $this->_requestMock, - $this->_domDocumentFactory, - $this->_storeManagerMock, - $this->_soapServerFactory, - $this->_typeProcessor, - $this->_configMock - ); - /** Assert that SOAP WSDL caching option was disabled after SOAP server initialization. */ - $this->assertFalse((bool)ini_get('soap.wsdl_cache_enabled'), 'WSDL caching was not disabled.'); - } -} diff --git a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php index 3d226ef1c24fb6da37e9e901538016c03456f9e0..8ea64f945afdfe44ef49a430a8e4b09de717cb77 100644 --- a/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php +++ b/dev/tests/static/framework/tests/unit/testsuite/Magento/TestFramework/CodingStandard/Tool/CodeMessDetectorTest.php @@ -13,6 +13,6 @@ class CodeMessDetectorTest extends \PHPUnit_Framework_TestCase 'some/ruleset/file.xml', 'some/report/file.xml' ); - $this->assertEquals(class_exists('PHP_PMD_TextUI_Command'), $messDetector->canRun()); + $this->assertEquals(class_exists('PHPMD\TextUI\Command'), $messDetector->canRun()); } } diff --git a/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php b/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php new file mode 100644 index 0000000000000000000000000000000000000000..c3a9fe9933ee4948c40bbd5630eea75f0b46a1e0 --- /dev/null +++ b/dev/tests/static/testsuite/Magento/Test/Integrity/HhvmCompatibilityTest.php @@ -0,0 +1,96 @@ +<?php +/** + * Hhvm ini_get/ini_set compatibility test + * + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + * + */ +namespace Magento\Test\Integrity; + +use Magento\Framework\App\Utility\Files; + +class HhvmCompatibilityTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var array + */ + protected $allowedDirectives = [ + 'session.cookie_secure', + 'session.cookie_httponly', + 'session.use_cookies', + 'session.use_only_cookies', + 'session.referer_check', + 'session.save_path', + 'session.save_handler', + 'session.cookie_lifetime', + 'session.cookie_secure', + 'date.timezone', + 'memory_limit', + 'max_execution_time', + 'short_open_tag', + 'disable_functions', + 'asp_tags', + 'apc.enabled', + 'eaccelerator.enable', + 'mime_magic.magicfile', + 'display_errors', + 'default_socket_timeout', + ]; + + public function testAllowedIniGetSetDirectives() + { + $deniedDirectives = []; + foreach ($this->getFiles() as $file) { + $fileDirectives = $this->parseDirectives($file); + if ($fileDirectives) { + $fileDeniedDirectives = array_diff($fileDirectives, $this->allowedDirectives); + if ($fileDeniedDirectives) { + $deniedDirectives[$file] = array_unique($fileDeniedDirectives); + } + } + } + if ($deniedDirectives) { + $this->fail($this->createMessage($deniedDirectives)); + } + } + + /** + * @return array + */ + protected function getFiles() + { + return \array_merge( + Files::init()->getPhpFiles(true, true, true, false), + Files::init()->getPhtmlFiles(false, false), + Files::init()->getFiles([Files::init()->getPathToSource() . '/dev/'], '*.php') + ); + } + + /** + * @param string $file + * @return null|array + */ + protected function parseDirectives($file) + { + $content = file_get_contents($file); + $pattern = '/ini_[g|s]et\(\s*[\'|"]([\w\._]+?)[\'|"][\s\w,\'"]*\)/'; + preg_match_all($pattern, $content, $matches); + + return $matches ? $matches[1] : null; + } + + /** + * @param array $deniedDirectives + * @return string + */ + protected function createMessage($deniedDirectives) + { + $rootPath = Files::init()->getPathToSource(); + $message = 'HHVM-incompatible ini_get/ini_set options were found:'; + foreach ($deniedDirectives as $file => $fileDeniedDirectives) { + $message .= "\n" . str_replace($rootPath, '', $file) . ': [' . implode(', ', $fileDeniedDirectives) . ']'; + } + return $message; + } +} diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php index 4c9230c1665722ee3096b802cd2a598a98f5802d..250f9b13074a52be623450e3d8a79f16f0f9b536 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_constants.php @@ -20,7 +20,7 @@ return [ [ 'CACHE_TAG', 'Magento\Framework\Model\Resource\Db\Collection\AbstractCollection', - 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG' + 'Magento_Core_Model_Cache_Type_Collection::CACHE_TAG', ], ['CACHE_TAG', 'Magento\Framework\Translate', 'Magento_Core_Model_Cache_Type_Translate::CACHE_TAG'], ['CACHE_TAG', 'Magento\Rss\Block\Catalog\NotifyStock'], @@ -42,17 +42,17 @@ return [ [ 'DEFAULT_SETUP_RESOURCE', 'Mage_Core_Model_Resource', - 'Magento_Core_Model_Config_Resource::DEFAULT_SETUP_CONNECTION' + 'Magento_Core_Model_Config_Resource::DEFAULT_SETUP_CONNECTION', ], [ 'DEFAULT_READ_RESOURCE', 'Mage_Core_Model_Resource', - 'Magento_Core_Model_Config_Resource::DEFAULT_READ_CONNECTION' + 'Magento_Core_Model_Config_Resource::DEFAULT_READ_CONNECTION', ], [ 'DEFAULT_WRITE_RESOURCE', 'Mage_Core_Model_Resource', - 'Magento_Core_Model_Config_Resource::DEFAULT_WRITE_CONNECTION' + 'Magento_Core_Model_Config_Resource::DEFAULT_WRITE_CONNECTION', ], ['DEFAULT_READ_CONNECTION', 'Magento\Framework\App\Resource\Config'], ['DEFAULT_WRITE_CONNECTION', 'Magento\Framework\App\Resource\Config'], @@ -77,7 +77,7 @@ return [ [ 'LAYOUT_GENERAL_CACHE_TAG', 'Magento\Core\Model\Layout\Merge', - 'Magento_Core_Model_Cache_Type_Layout::CACHE_TAG' + 'Magento_Core_Model_Cache_Type_Layout::CACHE_TAG', ], ['LOCALE_CACHE_KEY', 'Magento\Backend\Block\Page\Footer'], ['LOCALE_CACHE_LIFETIME', 'Magento\Backend\Block\Page\Footer'], @@ -90,19 +90,19 @@ return [ [ 'PUBLIC_MODULE_DIR', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::PUBLIC_MODULE_DIR' + 'Magento_Core_Model_Design_Package::PUBLIC_MODULE_DIR', ], ['PUBLIC_MODULE_DIR', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\Publisher\FileInterface::PUBLIC_MODULE_DIR'], [ 'PUBLIC_THEME_DIR', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::PUBLIC_THEME_DIR' + 'Magento_Core_Model_Design_Package::PUBLIC_THEME_DIR', ], ['PUBLIC_THEME_DIR', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\Publisher\FileInterface::PUBLIC_THEME_DIR'], [ 'PUBLIC_VIEW_DIR', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::PUBLIC_VIEW_DIR' + 'Magento_Core_Model_Design_Package::PUBLIC_VIEW_DIR', ], ['PUBLIC_VIEW_DIR', 'Magento\Framework\View\Publisher', 'Magento\Framework\View\Publisher\FileInterface::PUBLIC_VIEW_DIR'], ['REGISTRY_FORM_PARAMS_KEY', null, 'direct value'], @@ -114,7 +114,7 @@ return [ [ 'SCOPE_TYPE_WEBSITE', 'Magento\Core\Model\App', - 'Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE' + 'Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE', ], ['SEESION_MAX_COOKIE_LIFETIME'], ['TYPE_BINARY', null, 'Magento_DB_Ddl_Table::TYPE_BLOB'], @@ -138,12 +138,12 @@ return [ [ 'XML_NODE_ATTRIBUTE_NODES', 'Magento\Catalog\Model\Resource\Product\Flat\Indexer', - 'XML_NODE_ATTRIBUTE_GROUPS' + 'XML_NODE_ATTRIBUTE_GROUPS', ], [ 'XML_PATH_ALLOW_DUPLICATION', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::XML_PATH_ALLOW_DUPLICATION' + 'Magento_Core_Model_Design_Package::XML_PATH_ALLOW_DUPLICATION', ], ['XML_PATH_ALLOW_MAP_UPDATE', 'Mage_Core_Model_Design_PackageInterface'], ['XML_PATH_BACKEND_FRONTNAME', 'Mage_Backend_Helper_Data'], @@ -155,24 +155,24 @@ return [ [ 'XML_PATH_DEBUG_TEMPLATE_HINTS', 'Magento\Framework\View\Element\Template', - 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS' + 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS', ], [ 'XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS', 'Magento\Framework\View\Element\Template', - 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS' + 'Magento\Core\Model\TemplateEngine\Plugin::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS', ], ['XML_PATH_DEFAULT_COUNTRY', 'Magento\Core\Helper\Data', 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_COUNTRY'], ['XML_PATH_DEFAULT_LOCALE', 'Magento\Core\Helper\Data', 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_LOCALE'], [ 'XML_PATH_DEFAULT_TIMEZONE', 'Magento\Core\Helper\Data', - 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_TIMEZONE' + 'Magento\Directory\Helper\Data::XML_PATH_DEFAULT_TIMEZONE', ], [ 'XML_PATH_DEV_ALLOW_IPS', 'Magento\Core\Helper\Data', - 'Magento\Developer\Helper\Data::XML_PATH_DEV_ALLOW_IPS' + 'Magento\Developer\Helper\Data::XML_PATH_DEV_ALLOW_IPS', ], ['XML_PATH_INSTALL_DATE', 'Mage_Core_Model_App', 'Mage_Core_Model_Config_Primary::XML_PATH_INSTALL_DATE'], ['XML_PATH_LOCALE_INHERITANCE', 'Mage_Core_Model_Translate'], @@ -183,105 +183,105 @@ return [ [ 'XML_PATH_SKIP_PROCESS_MODULES_UPDATES', 'Mage_Core_Model_App', - 'Mage_Core_Model_Db_UpdaterInterface::XML_PATH_SKIP_PROCESS_MODULES_UPDATES' + 'Mage_Core_Model_Db_UpdaterInterface::XML_PATH_SKIP_PROCESS_MODULES_UPDATES', ], [ 'XML_PATH_STATIC_FILE_SIGNATURE', 'Magento\Core\Helper\Data', - 'Magento_Core_Model_Design_Package::XML_PATH_STATIC_FILE_SIGNATURE' + 'Magento_Core_Model_Design_Package::XML_PATH_STATIC_FILE_SIGNATURE', ], [ 'XML_PATH_STORE_ADDRESS1', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS1' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS1', ], [ 'XML_PATH_STORE_ADDRESS2', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS2' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ADDRESS2', ], [ 'XML_PATH_STORE_CITY', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_CITY' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_CITY', ], [ 'XML_PATH_STORE_REGION_ID', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_REGION_ID' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_REGION_ID', ], [ 'XML_PATH_STORE_ZIP', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ZIP' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_ZIP', ], [ 'XML_PATH_STORE_COUNTRY_ID', 'Magento\Shipping\Model\Shipping', - 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID' + 'Magento\Sales\Model\Order\Shipment::XML_PATH_STORE_COUNTRY_ID', ], ['XML_PATH_TEMPLATE_EMAIL', 'Magento\Core\Model\Email\Template'], [ 'XML_PATH_TEMPLATE_FILTER', 'Magento\Newsletter\Helper\Data', - 'Use directly model \Magento\Newsletter\Model\Template\Filter' + 'Use directly model \Magento\Newsletter\Model\Template\Filter', ], [ 'XML_PATH_THEME', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::XML_PATH_THEME' + 'Magento_Core_Model_Design_Package::XML_PATH_THEME', ], [ 'XML_PATH_THEME_ID', 'Magento\Core\Model\Design\PackageInterface', - 'Magento_Core_Model_Design_Package::XML_PATH_THEME_ID' + 'Magento_Core_Model_Design_Package::XML_PATH_THEME_ID', ], ['XML_STORE_ROUTERS_PATH', 'Mage_Core_Controller_Varien_Front'], ['XML_PATH_SESSION_MESSAGE_MODELS', 'Magento\Catalog\Helper\Product\View'], [ 'VALIDATOR_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_KEY', ], [ 'VALIDATOR_HTTP_USER_AGENT_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_USER_AGENT_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_USER_AGENT_KEY', ], [ 'VALIDATOR_HTTP_X_FORVARDED_FOR_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_X_FORWARDED_FOR_KEY', ], [ 'VALIDATOR_HTTP_VIA_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_VIA_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_HTTP_VIA_KEY', ], [ 'VALIDATOR_REMOTE_ADDR_KEY', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::VALIDATOR_REMOTE_ADDR_KEY' + 'Magento_Core_Model_Session_Validator::VALIDATOR_REMOTE_ADDR_KEY', ], [ 'XML_PATH_USE_REMOTE_ADDR', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_REMOTE_ADDR' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_REMOTE_ADDR', ], [ 'XML_PATH_USE_HTTP_VIA', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_HTTP_VIA' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_HTTP_VIA', ], [ 'XML_PATH_USE_X_FORWARDED', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_X_FORWARDED' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_X_FORWARDED', ], [ 'XML_PATH_USE_USER_AGENT', 'Magento\Core\Model\Session\AbstractSession', - 'Magento_Core_Model_Session_Validator::XML_PATH_USE_USER_AGENT' + 'Magento_Core_Model_Session_Validator::XML_PATH_USE_USER_AGENT', ], ['XML_NODE_DIRECT_FRONT_NAMES', 'Magento\Framework\App\Request\Http'], ['XML_NODE_USET_AGENT_SKIP', 'Magento\Core\Model\Session\AbstractSession'], @@ -335,37 +335,37 @@ return [ [ 'XML_PATH_EU_COUNTRIES_LIST', '\Magento\Core\Helper\Data', - 'Magento\Customer\Helper\Data::XML_PATH_EU_COUNTRIES_LIST' + 'Magento\Customer\Helper\Data::XML_PATH_EU_COUNTRIES_LIST', ], [ 'XML_PATH_MERCHANT_COUNTRY_CODE', '\Magento\Core\Helper\Data', - 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_COUNTRY_CODE' + 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_COUNTRY_CODE', ], [ 'XML_PATH_MERCHANT_VAT_NUMBER', '\Magento\Core\Helper\Data', - 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_VAT_NUMBER' + 'Magento\Customer\Helper\Data::XML_PATH_MERCHANT_VAT_NUMBER', ], [ 'XML_PATH_PROTECTED_FILE_EXTENSIONS', '\Magento\Core\Helper\Data', - '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::XML_PATH_PROTECTED_FILE_EXTENSIONS' + '\Magento\MediaStorage\Model\File\Validator\NotProtectedExtension::XML_PATH_PROTECTED_FILE_EXTENSIONS', ], [ 'XML_PATH_PUBLIC_FILES_VALID_PATHS', '\Magento\Core\Helper\Data', - '\Magento\Catalog\Helper\Catalog::XML_PATH_PUBLIC_FILES_VALID_PATHS' + '\Magento\Catalog\Helper\Catalog::XML_PATH_PUBLIC_FILES_VALID_PATHS', ], [ 'XML_PATH_PUBLIC_FILES_VALID_PATHS', 'Magento\Catalog\Helper\Catalog', - '\Magento\Sitemap\Helper\Data::XML_PATH_PUBLIC_FILES_VALID_PATHS' + '\Magento\Sitemap\Helper\Data::XML_PATH_PUBLIC_FILES_VALID_PATHS', ], [ 'XML_PATH_SITEMAP_VALID_PATHS', '\Magento\Catalog\Helper\Catalog', - '\Magento\Sitemap\Helper\Data::XML_PATH_SITEMAP_VALID_PATHS' + '\Magento\Sitemap\Helper\Data::XML_PATH_SITEMAP_VALID_PATHS', ], ['TYPE_PHYSICAL', '\Magento\Core\Model\Theme', '\Magento\Framework\View\Design\ThemeInterface::TYPE_PHYSICAL'], ['TYPE_VIRTUAL', '\Magento\Core\Model\Theme', '\Magento\Framework\View\Design\ThemeInterface::TYPE_VIRTUAL'], @@ -375,17 +375,17 @@ return [ [ 'XML_PATH_IMAGE_ADAPTER', '\Magento\Core\Model\Image\AdapterFactory', - '\Magento\Core\Model\Image\Adapter\Config::XML_PATH_IMAGE_ADAPTER' + '\Magento\Core\Model\Image\Adapter\Config::XML_PATH_IMAGE_ADAPTER', ], [ 'ADAPTER_IM', '\Magento\Core\Model\Image\AdapterFactory', - '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM' + '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_IM', ], [ 'ADAPTER_GD2', '\Magento\Core\Model\Image\AdapterFactory', - '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2' + '\Magento\Framework\Image\Adapter\AdapterInterface::ADAPTER_GD2', ], ['XML_PATH_IMAGE_TYPES', 'Magento\Adminhtml\Block\Catalog\Product\Frontend\Product\Watermark'], ['XML_PATH_WEBHOOK', 'Magento\Webhook\Model\Source\Hook'], @@ -394,103 +394,103 @@ return [ [ 'XML_PATH_USE_FRONTEND_SID', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID' + '\Magento\Framework\Session\SidResolver::XML_PATH_USE_FRONTEND_SID', ], [ 'SESSION_ID_QUERY_PARAM', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Framework\Session\SidResolverInterface::SESSION_ID_QUERY_PARAM' + '\Magento\Framework\Session\SidResolverInterface::SESSION_ID_QUERY_PARAM', ], [ 'XML_PATH_COOKIE_DOMAIN', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_DOMAIN' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_DOMAIN', ], [ 'XML_PATH_COOKIE_PATH', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_PATH' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_PATH', ], [ 'XML_PATH_COOKIE_LIFETIME', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_LIFETIME' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_LIFETIME', ], [ 'XML_PATH_COOKIE_HTTPONLY', '\Magento\Framework\Stdlib\Cookie', - '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_HTTPONLY' + '\Magento\Core\Model\Session\Config::XML_PATH_COOKIE_HTTPONLY', ], [ 'PARAM_SESSION_SAVE_METHOD', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD' + '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD', ], [ 'PARAM_SESSION_SAVE_PATH', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH' + '\Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH', ], [ 'PARAM_SESSION_CACHE_LIMITER', '\Magento\Core\Model\Session\AbstractSession', - '\Magento\Core\Model\Session\Config::PARAM_SESSION_CACHE_LIMITER' + '\Magento\Core\Model\Session\Config::PARAM_SESSION_CACHE_LIMITER', ], [ 'XML_NODE_SESSION_SAVE_PATH', 'Magento\Core\Model\Session\AbstractSession', - 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH' + 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_PATH', ], [ 'XML_NODE_SESSION_SAVE', 'Magento\Core\Model\Session\AbstractSession', - 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD' + 'Magento\Core\Model\Session\Config::PARAM_SESSION_SAVE_METHOD', ], ['XML_PATH_LOG_EXCEPTION_FILE', 'Magento\Core\Model\Session\AbstractSession'], [ 'XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS', 'Magento\Theme\Helper\Robots', - 'Magento\Backend\Block\Page\System\Config\Robots::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS' + 'Magento\Backend\Block\Page\System\Config\Robots::XML_PATH_ROBOTS_DEFAULT_CUSTOM_INSTRUCTIONS', ], [ 'XML_PATH_MERGE_CSS_FILES', 'Magento\Framework\View\Asset\MergeService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_CSS_FILES' + 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_CSS_FILES', ], [ 'XML_PATH_MERGE_JS_FILES', 'Magento\Framework\View\Asset\MergeService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_JS_FILES' + 'Magento\Core\Model\Asset\Config::XML_PATH_MERGE_JS_FILES', ], [ 'XML_PATH_MINIFICATION_ENABLED', 'Magento\Framework\View\Asset\MinifyService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ENABLED' + 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ENABLED', ], [ 'XML_PATH_MINIFICATION_ADAPTER', 'Magento\Framework\View\Asset\MinifyService', - 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ADAPTER' + 'Magento\Core\Model\Asset\Config::XML_PATH_MINIFICATION_ADAPTER', ], [ 'USE_PARENT_IMAGE', 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable', - 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE' + 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE', ], [ 'USE_PARENT_IMAGE', 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', - 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE' + 'Magento\Catalog\Model\Config\Source\Product\Thumbnail::OPTION_USE_PARENT_IMAGE', ], [ 'CONFIGURABLE_PRODUCT_IMAGE', 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable', - 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::CONFIG_THUMBNAIL_SOURCE' + 'Magento\ConfigurableProduct\Block\Cart\Item\Renderer\Configurable::CONFIG_THUMBNAIL_SOURCE', ], [ 'GROUPED_PRODUCT_IMAGE', 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped', - 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE' + 'Magento\GroupedProduct\Block\Cart\Item\Renderer\Grouped::CONFIG_THUMBNAIL_SOURCE', ], ['TYPE_BLOCK', 'Magento\Framework\View\Layout', '\Magento\Framework\View\Layout\Element'], ['TYPE_CONTAINER', 'Magento\Framework\View\Layout', '\Magento\Framework\View\Layout\Element'], @@ -512,36 +512,36 @@ return [ [ 'MAX_QTY_VALUE', '\Magento\Catalog\Controller\Adminhtml\Product', - 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter::MAX_QTY_VALUE' + 'Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter::MAX_QTY_VALUE', ], [ 'LINK_TYPE_GROUPED', '\Magento\Catalog\Model\Product\Link', - '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED' + '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED', ], [ 'TYPE_GROUPED', '\Magento\Catalog\Model\Product\Type', - '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED' + '\Magento\GroupedProduct\Model\Resource\Product\Link::LINK_TYPE_GROUPED', ], ['PARAM_APP_URIS', 'Magento\Framework\Filesystem'], ['ROOT_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::ROOT'], ['APP_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::APP'], ['MODULES_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::MODULES' + '\Magento\Framework\App\Filesystem\DirectoryList::MODULES', ], ['THEMES_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::THEMES' + '\Magento\Framework\App\Filesystem\DirectoryList::THEMES', ], ['CONFIG_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::CONFIG' + '\Magento\Framework\App\Filesystem\DirectoryList::CONFIG', ], ['LIB_INTERNAL', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::LIB_INTERNAL' + '\Magento\Framework\App\Filesystem\DirectoryList::LIB_INTERNAL', ], ['LOCALE_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::LOCALE'], ['PUB_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::PUB'], @@ -549,7 +549,7 @@ return [ ['MEDIA_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::MEDIA'], ['STATIC_VIEW_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::STATIC_VIEW' + '\Magento\Framework\App\Filesystem\DirectoryList::STATIC_VIEW', ], ['VAR_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR'], ['TMP_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::TMP'], @@ -557,31 +557,31 @@ return [ ['LOG_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::LOG'], ['SESSION_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::SESSION' + '\Magento\Framework\App\Filesystem\DirectoryList::SESSION', ], ['DI_DIR', '\Magento\Framework\App\Filesystem', '\Magento\Framework\App\Filesystem\DirectoryList::DI'], ['GENERATION_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::GENERATION' + '\Magento\Framework\App\Filesystem\DirectoryList::GENERATION', ], ['UPLOAD_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Filesystem\DirectoryList::UPLOAD' + '\Magento\Framework\App\Filesystem\DirectoryList::UPLOAD', ], ['SYS_TMP_DIR', '\Magento\Framework\App\Filesystem', - '\Magento\Framework\Filesystem\DirectoryList::SYS_TMP' + '\Magento\Framework\Filesystem\DirectoryList::SYS_TMP', ], ['LAYOUT_NAVIGATION_CLASS_NAME', 'Magento\DesignEditor\Model\State'], [ 'TYPE_CONFIGURABLE', '\Magento\Catalog\Model\Product\Type', - '\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE' + '\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE', ], [ 'XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY', '\Magento\Catalog\Helper\Category\Flat', - '\Magento\Catalog\Model\Indexer\Category\Flat\Config::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY' + '\Magento\Catalog\Model\Indexer\Category\Flat\Config::XML_PATH_IS_ENABLED_FLAT_CATALOG_CATEGORY', ], ['CSV_SEPARATOR', 'Magento\Framework\Translate'], ['SCOPE_SEPARATOR', 'Magento\Framework\Translate'], @@ -592,17 +592,17 @@ return [ [ 'XML_NODE_MAX_INDEX_COUNT', 'Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction', - 'Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder' + 'Magento\Catalog\Model\Indexer\Product\Flat\FlatTableBuilder', ], [ 'ATTRIBUTES_CHUNK_SIZE', 'Magento\Catalog\Model\Indexer\Product\Flat\AbstractAction', - 'Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer' + 'Magento\Catalog\Model\Indexer\Product\Flat\Action\Indexer', ], [ 'CACHE_CATEGORY_TAG', 'Magento\Catalog\Model\Product', - 'Magento\Catalog\Model\Product::CACHE_PRODUCT_CATEGORY_TAG' + 'Magento\Catalog\Model\Product::CACHE_PRODUCT_CATEGORY_TAG', ], ['XML_PATH_UNSECURE_BASE_LIB_URL'], ['XML_PATH_SECURE_BASE_LIB_URL'], @@ -621,12 +621,12 @@ return [ [ 'PARAM_APP_DIRS', 'Magento\Framework\App\Filesystem', - '\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS' + '\Magento\Framework\App\Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS', ], [ 'CACHE_VIEW_REL_DIR', 'Magento\Framework\App\Filesystem', - '\Magento\Framework\View\Asset\Minified::CACHE_VIEW_REL' + '\Magento\Framework\View\Asset\Minified::CACHE_VIEW_REL', ], ['WRAPPER_CONTENT_ZLIB', 'Magento\Framework\Filesystem', '\Magento\Framework\Filesystem\DriverPool::ZLIB'], ['WRAPPER_CONTENT_PHAR', 'Magento\Framework\Filesystem'], @@ -669,21 +669,32 @@ return [ [ 'PARAM_ALLOWED_MODULES', 'Magento\Framework\Module\Declaration\Reader\Filesystem', - 'Magento\Framework\App\ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG' + 'Magento\Framework\App\ObjectManagerFactory::INIT_PARAM_DEPLOYMENT_CONFIG', ], [ 'NOT_INSTALLED_URL_PATH_PARAM', 'Magento\Framework\App\Http', - 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL_PATH' + 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL_PATH', ], [ 'NOT_INSTALLED_URL_PARAM', 'Magento\Framework\App\Http', - 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL' + 'Magento\Framework\App\SetupInfo::PARAM_NOT_INSTALLED_URL', ], [ 'NOT_INSTALLED_URL_PATH', 'Magento\Framework\App\Http', - 'Magento\Framework\App\SetupInfo::DEFAULT_PATH' + 'Magento\Framework\App\SetupInfo::DEFAULT_PATH', ], + [ + 'DEFAULT_ATTRIBUTE_SET_ID', + 'Magento\Catalog\Api\Data\CategoryAttributeInterface', + 'Use \Magento\Eav\Model\Entity\Type::getDefaultAttributeSetId() method instead', + ], + [ + 'DEFAULT_ATTRIBUTE_SET_ID', + '\Magento\Catalog\Api\Data\ProductAttributeInterface', + 'Use \Magento\Eav\Model\Entity\Type::getDefaultAttributeSetId() method instead', + ], + ['CONFIG_PATH_WSDL_CACHE_ENABLED', 'Magento\Webapi\Model\Soap\Server'], ]; diff --git a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php index 77afd6d62a2ffa35e950fbb7efb73914513aa736..e47cc2c1d2d314c6050365aeea5d2b1707bb36d0 100644 --- a/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php +++ b/dev/tests/static/testsuite/Magento/Test/Legacy/_files/obsolete_methods.php @@ -2041,6 +2041,7 @@ return [ ['_initSendToFriendModel', 'Magento\Sendfriend\Controller\Product'], ['register', 'Magento\Sendfriend\Model\Sendfriend'], ['_getImageHelper', 'Magento\Catalog\Model\Product'], + ['streamOpen', 'Magento\Framework\Io\File'], ['getPreProcessors', 'Magento\Framework\View\Asset\PreProcessor\Pool', 'process'], ['isPhpFile', '\Magento\Tools\Di\Code\Reader\ClassesScanner'], ['renderPage', 'Magento\Cms\Helper\Page'], @@ -2104,6 +2105,19 @@ return [ 'Magento\Integration\Helper\Validator', 'Magento\Integration\Model\CredentialsValidator::validate' ], + ['isReviewOwner', 'Magento\Review\Block\Customer\View'], + ['getRegistration', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getRegistration'], + ['getCreateAccountUrl', 'Magento\Customer\Block\Form\Login', 'Magento\Customer\Block\Form\Login\Info::getCreateAccountUrl'], + ['getSuccessMessage', 'Magento\Newsletter\Block\Subscribe'], + ['getErrorMessage', 'Magento\Newsletter\Block\Subscribe'], + ['_initCollection', 'Magento\Review\Block\Customer\ListCustomer'], + ['count', 'Magento\Review\Block\Customer\ListCustomer'], + ['_getCollection', 'Magento\Review\Block\Customer\ListCustomer'], + ['getCollection', 'Magento\Review\Block\Customer\ListCustomer', 'Magento\Review\Block\Customer\ListCustomer::getReviews'], + ['_initCollection', 'Magento\Review\Block\Customer\Recent'], + ['count', 'Magento\Review\Block\Customer\Recent'], + ['_getCollection', 'Magento\Review\Block\Customer\Recent'], + ['getCollection', 'Magento\Review\Block\Customer\Recent', 'Magento\Review\Block\Customer\Recent::getReviews'], ['getProductEntityTypeId', 'Magento\Reports\Model\Resource\Product\Collection'], ['setProductEntityTypeId', 'Magento\Reports\Model\Resource\Product\Collection'], ['bindLocale', 'Magento\Backend\Model\Observer'], diff --git a/dev/tests/unit/.gitignore b/dev/tests/unit/.gitignore index ace6e823e41a3ed294eb1ed9a1a14451bd3e2e8c..319b3826f933880445af33b78c1ee4e05666d321 100644 --- a/dev/tests/unit/.gitignore +++ b/dev/tests/unit/.gitignore @@ -1,2 +1 @@ /phpunit.xml -tmp diff --git a/dev/tests/unit/framework/bootstrap.php b/dev/tests/unit/framework/bootstrap.php index afd5f88e899199d6db3934bb2d3e2d64431a972f..96ff9c21b8765cddb3f750ce6aeb61e2dbece0a5 100755 --- a/dev/tests/unit/framework/bootstrap.php +++ b/dev/tests/unit/framework/bootstrap.php @@ -12,11 +12,6 @@ if (!defined('TESTS_TEMP_DIR')) { require BP . '/app/functions.php'; -if (is_dir(TESTS_TEMP_DIR)) { - $filesystemAdapter = new \Magento\Framework\Filesystem\Driver\File(); - $filesystemAdapter->deleteDirectory(TESTS_TEMP_DIR); -} -mkdir(TESTS_TEMP_DIR); \Magento\Framework\Phrase::setRenderer(new \Magento\Framework\Phrase\Renderer\Placeholder()); diff --git a/dev/tests/unit/tmp/.gitignore b/dev/tests/unit/tmp/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..a68d087bfe51165cfcd71d2185d9d8a94855728a --- /dev/null +++ b/dev/tests/unit/tmp/.gitignore @@ -0,0 +1,2 @@ +/* +!/.gitignore diff --git a/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php b/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php index 742a8915e337a020bcd4477b01e3a54f79a61bd0..9d7b19a228b410627c063090415fa43932b97442 100644 --- a/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php +++ b/dev/tools/Magento/Tools/I18n/Test/Unit/FactoryTest.php @@ -39,15 +39,15 @@ class FactoryTest extends \PHPUnit_Framework_TestCase return [ [ 'Magento\Tools\I18n\Dictionary\Writer\Csv', - 'filename.invalid_type', + TESTS_TEMP_DIR . '/filename.invalid_type', ], [ 'Magento\Tools\I18n\Dictionary\Writer\Csv', - 'filename' + TESTS_TEMP_DIR . '/filename' ], [ 'Magento\Tools\I18n\Dictionary\Writer\Csv', - 'filename.csv' + TESTS_TEMP_DIR . '/filename.csv' ], [ 'Magento\Tools\I18n\Dictionary\Writer\Csv\Stdo', diff --git a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php index 973f461ee88b54e8ed4fa815d11af70c170f66c6..c1502736e273ec2e56af9c4faba802208d4172f3 100644 --- a/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php +++ b/lib/internal/Magento/Framework/App/Test/Unit/Response/HttpTest.php @@ -114,13 +114,12 @@ class HttpTest extends \PHPUnit_Framework_TestCase $ttl = 120; $pragma = 'cache'; $cacheControl = 'max-age=' . $ttl . ', public, s-maxage=' . $ttl; - $between = 1000; + $expiresResult = gmdate('D, d M Y H:i:s T', time() + $ttl); $this->model->setPublicHeaders($ttl); $this->assertEquals($pragma, $this->model->getHeader('Pragma')->getFieldValue()); $this->assertEquals($cacheControl, $this->model->getHeader('Cache-Control')->getFieldValue()); - $expiresResult = time($this->model->getHeader('Expires')->getFieldValue()); - $this->assertTrue($expiresResult > $between || $expiresResult < $between); + $this->assertLessThanOrEqual($expiresResult, $this->model->getHeader('Expires')->getFieldValue()); } /** diff --git a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php index 5f6b0c6221c0705107eba10c0ed1e16d55f9113c..84ec6cf98539214addb0e08193fb73e728a28c75 100644 --- a/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Cache/Test/Unit/Config/ConverterTest.php @@ -27,24 +27,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $expectedResult = include $convertedFile; $this->assertEquals($expectedResult, $this->_model->convert($dom)); } - - /** - * @param string $xmlData - * @dataProvider wrongXmlDataProvider - * @expectedException \Exception - */ - public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) - { - $dom = new \DOMDocument(); - $dom->loadXML($xmlData); - $this->_model->convert($dom); - } - - /** - * @return array - */ - public function wrongXmlDataProvider() - { - return [['<?xml version="1.0"?><config>']]; - } } diff --git a/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php b/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php index 98eafe0f910928432718435f533c032980bd8e38..c26f31283ddb0a747cdcb0c51b32927e6e0e8001 100644 --- a/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php +++ b/lib/internal/Magento/Framework/Code/Reader/ArgumentsReader.php @@ -47,12 +47,10 @@ class ArgumentsReader } elseif (true == is_int($value)) { $default = $value; } else { - $default = is_null( - $parameter->getDefaultValue() - ) ? 'null' : "'" . $parameter->getDefaultValue() . "'"; + $default = $parameter->getDefaultValue(); } } elseif ($parameter->allowsNull()) { - $default = 'null'; + $default = null; } } diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php index 412c5dc49df9d8bf239cdb9802d208074c9b5e8e..8c5e45a18732f91d8d004bfe64fe057a20cc032e 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/ArgumentsReaderTest.php @@ -48,7 +48,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 3, 'type' => null, 'isOptional' => true, - 'default' => "'Const Value'", + 'default' => 'Const Value', ], 'optionalNumValue' => [ 'name' => 'optionalNumValue', @@ -62,7 +62,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 5, 'type' => null, 'isOptional' => true, - 'default' => "'optional string'", + 'default' => 'optional string', ], 'optionalArrayValue' => [ 'name' => 'optionalArrayValue', @@ -115,7 +115,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 3, 'type' => null, 'isOptional' => true, - 'default' => "'Const Value'", + 'default' => 'Const Value', ], 'optionalNumValue' => [ 'name' => 'optionalNumValue', @@ -129,7 +129,7 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 5, 'type' => null, 'isOptional' => true, - 'default' => "'optional string'", + 'default' => 'optional string', ], 'optionalArrayValue' => [ 'name' => 'optionalArrayValue', @@ -177,24 +177,24 @@ class ArgumentsReaderTest extends \PHPUnit_Framework_TestCase 'position' => 0, 'type' => null, 'isOptional' => true, - 'default' => null, + 'default' => '', ], 'code' => [ 'name' => 'code', 'position' => 1, 'type' => null, 'isOptional' => true, - 'default' => null, + 'default' => 0, ], 'previous' => [ 'name' => 'previous', 'position' => 2, - 'type' => null, + 'type' => '\Exception', 'isOptional' => true, 'default' => null, ], ]; - $class = new \ReflectionClass('ClassExtendsDefaultPhpType'); + $class = new \ReflectionClass('ClassExtendsDefaultPhpTypeWithIOverrideConstructor'); $actualResult = $this->_model->getConstructorArguments($class, false, true); $this->assertEquals($expectedResult, $actualResult); diff --git a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php index 9987087c3d3ee84189eccab7a076f3ec2dc51972..9ce41a9fe3c73dfc3592b113f35a78f22a63aa24 100644 --- a/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php +++ b/lib/internal/Magento/Framework/Code/Test/Unit/Reader/_files/ClassesForArgumentsReader.php @@ -82,6 +82,22 @@ class ClassWithoutConstruct class ClassExtendsDefaultPhpType extends \RuntimeException { } +class ClassExtendsDefaultPhpTypeWithIOverrideConstructor extends \RuntimeException +{ + /** + * Override constructor due to Reflection API incorrect work with internal PHP classes. + * Obtaining of default argument value and default argument type is incorrect + * + * @param string $message + * @param int $code + * @param Exception $previous + */ + public function __construct($message = '', $code = 0, Exception $previous = null) + { + parent::__construct($message, $code, $previous); + } +} + class FirstClassForParentCall { /** diff --git a/lib/internal/Magento/Framework/Convert/ConvertArray.php b/lib/internal/Magento/Framework/Convert/ConvertArray.php index bf9fa3110998d548374f234ea82748b2af4c253e..902c7c99dee79309cb3af33e4c03fbcdbd130d73 100644 --- a/lib/internal/Magento/Framework/Convert/ConvertArray.php +++ b/lib/internal/Magento/Framework/Convert/ConvertArray.php @@ -67,7 +67,7 @@ XML; * @return \SimpleXMLElement * @throws Exception */ - private function _assocToXml(array $array, $rootName, \SimpleXMLElement &$xml) + private function _assocToXml(array $array, $rootName, \SimpleXMLElement $xml) { $hasNumericKey = false; $hasStringKey = false; @@ -78,12 +78,13 @@ XML; throw new Exception('Associative key must not be the same as its parent associative key.'); } $hasStringKey = true; - $xml->{$key} = $value; + $xml->addChild($key, $value); } elseif (is_int($key)) { $hasNumericKey = true; - $xml->{$rootName}[$key] = $value; + $xml->addChild($key, $value); } } else { + $xml->addChild($key); self::_assocToXml($value, $key, $xml->{$key}); } } diff --git a/lib/internal/Magento/Framework/Filesystem/Io/File.php b/lib/internal/Magento/Framework/Filesystem/Io/File.php index bda846e3ce5e310614266bdb7271050a259c173d..947409e10c185e4c50d22cfeb99bff839ee142b5 100644 --- a/lib/internal/Magento/Framework/Filesystem/Io/File.php +++ b/lib/internal/Magento/Framework/Filesystem/Io/File.php @@ -88,39 +88,6 @@ class File extends AbstractIo } } - /** - * Open file in stream mode - * For set folder for file use open method - * - * @param string $fileName - * @param string $mode - * @param int $chmod - * @return true - * @throws \Exception - */ - public function streamOpen($fileName, $mode = 'w+', $chmod = 0666) - { - $writeableMode = preg_match('#^[wax]#i', $mode); - if ($writeableMode && !is_writeable($this->_cwd)) { - throw new \Exception('Permission denied for write to ' . $this->_cwd); - } - - if (!ini_get('auto_detect_line_endings')) { - ini_set('auto_detect_line_endings', 1); - } - - $this->_cwd(); - $this->_streamHandler = @fopen($fileName, $mode); - $this->_iwd(); - if ($this->_streamHandler === false) { - throw new \Exception('Error write to file ' . $fileName); - } - - $this->_streamFileName = $fileName; - $this->_streamChmod = $chmod; - return true; - } - /** * Lock file * diff --git a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php index 1d3b133279ae43d9439bc1fa521854c926f66e3c..25fcd6ac2f4f51f4bba579aeb064a6d6368824bb 100644 --- a/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php +++ b/lib/internal/Magento/Framework/Image/Adapter/ImageMagick.php @@ -130,7 +130,7 @@ class ImageMagick extends \Magento\Framework\Image\Adapter\AbstractAdapter public function getImage() { $this->_applyOptions(); - return (string)$this->_imageHandler; + return $this->_imageHandler->getImageBlob(); } /** @@ -316,7 +316,7 @@ class ImageMagick extends \Magento\Framework\Image\Adapter\AbstractAdapter } // merge layers - $this->_imageHandler->flattenImages(); + $this->_imageHandler->mergeImageLayers(\Imagick::LAYERMETHOD_FLATTEN); $watermark->clear(); $watermark->destroy(); } diff --git a/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php b/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php index 81a0535a1955692719e3e0025f280503e850e1bd..c9c0b024ca9c9dc95ee54f68ea21482c3309f9fe 100644 --- a/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php +++ b/lib/internal/Magento/Framework/Module/Test/Unit/Declaration/Converter/DomTest.php @@ -28,22 +28,26 @@ class DomTest extends \PHPUnit_Framework_TestCase /** * @param string $xmlString - * @dataProvider testConvertWithInvalidDomDataProvider + * @dataProvider convertWithInvalidDomDataProvider * @expectedException \Exception */ public function testConvertWithInvalidDom($xmlString) { $dom = new \DOMDocument(); - $dom->loadXML($xmlString); - $this->_converter->convert($dom); + try { + $dom->loadXML($xmlString); + $this->_converter->convert($dom); + } catch (\PHPUnit_Framework_Error $ex) { + // do nothing because we expect \Exception but not \PHPUnit_Framework_Error + } } - public function testConvertWithInvalidDomDataProvider() + public function convertWithInvalidDomDataProvider() { return [ 'Module node without "name" attribute' => ['<?xml version="1.0"?><config><module /></config>'], 'Sequence module node without "name" attribute' => [ - '<?xml dbversion="1.0"?><config><module name="Module_One" setup_version="1.0.0.0">' . + '<?xml version="1.0"?><config><module name="Module_One" setup_version="1.0.0.0">' . '<sequence><module/></sequence></module></config>', ], ]; diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php index a3ea7de3792d2cc2b447e23bb171b319762099c7..13901c1283cca62deaec9be9cf03eab0a73e1dae 100644 --- a/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php +++ b/lib/internal/Magento/Framework/Mview/Test/Unit/Config/ConverterTest.php @@ -25,24 +25,4 @@ class ConverterTest extends \PHPUnit_Framework_TestCase $this->assertEquals($data['expected'], $this->_model->convert($dom)); } - - /** - * @param string $xmlData - * @dataProvider wrongXmlDataProvider - * @expectedException \Exception - */ - public function testMapThrowsExceptionWhenXmlHasWrongFormat($xmlData) - { - $dom = new \DOMDocument(); - $dom->loadXML($xmlData); - $this->_model->convert($dom); - } - - /** - * @return array - */ - public function wrongXmlDataProvider() - { - return [['<?xml version="1.0"?><config>']]; - } } diff --git a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php index 8c0e0812b5601c8fbbfc6866baab37a0131d66e1..96a4abb41e71b3cf0b92be5b493f23c02bb12fad 100644 --- a/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php +++ b/lib/internal/Magento/Framework/Pricing/Test/Unit/Adjustment/CollectionTest.php @@ -76,7 +76,7 @@ class CollectionTest extends \PHPUnit_Framework_TestCase $result = $collection->getItems(); - $this->assertEquals($expectedResult, array_keys($result)); + $this->assertEmpty(array_diff($expectedResult, array_keys($result))); } public function getItemsDataProvider() diff --git a/lib/internal/Magento/Framework/Simplexml/Config.php b/lib/internal/Magento/Framework/Simplexml/Config.php index f94ec099c6fc5124217d1fbd52b3a3fae5b95d1c..4e1265ebd4a4c180d7bbc4a8b84b0334b5b1676a 100644 --- a/lib/internal/Magento/Framework/Simplexml/Config.php +++ b/lib/internal/Magento/Framework/Simplexml/Config.php @@ -489,10 +489,9 @@ class Config * @param \DOMNode $dom * @return bool */ - public function loadDom($dom) + public function loadDom(\DOMNode $dom) { $xml = simplexml_import_dom($dom, $this->_elementClass); - if ($xml) { $this->_xml = $xml; return true; diff --git a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php index f0842c5a78b122980e895ff077f1a57da621c9b8..1b690780cccd7fdaad65bb33d818aca0113d7662 100644 --- a/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php +++ b/lib/internal/Magento/Framework/Simplexml/Test/Unit/ConfigTest.php @@ -42,17 +42,13 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertFalse($this->config->loadString('')); $this->assertTrue($this->config->loadString($xml)); $this->assertXmlStringEqualsXmlString($xml, $this->config->getXmlString()); - $this->setExpectedException( - '\Exception', - 'simplexml_load_string(): Entity: line 1: parser error : Start tag expected,' - ); - $this->assertFalse($this->config->loadString('wrong_path')); } public function testLoadDom() { - $this->config->loadString('<?xml version="1.0"?><config><node>1</node></config>'); - $this->assertTrue($this->config->loadDom($this->config->getNode())); + $dom = new \DOMDocument(); + $dom->loadXML('<?xml version="1.0"?><config><node>1</node></config>'); + $this->assertTrue($this->config->loadDom($dom)); } public function testGetNode() diff --git a/lib/internal/Magento/Framework/View/Layout/Proxy.php b/lib/internal/Magento/Framework/View/Layout/Proxy.php index 697b16a908ee9d9e27ee9937eee4274ec1db7641..8c399f4e4161a7f847b4f22db49e7e97e8528ef2 100644 --- a/lib/internal/Magento/Framework/View/Layout/Proxy.php +++ b/lib/internal/Magento/Framework/View/Layout/Proxy.php @@ -847,7 +847,7 @@ class Proxy extends \Magento\Framework\View\Layout * @param \DOMNode $dom * @return bool */ - public function loadDom($dom) + public function loadDom(\DOMNode $dom) { return $this->getSubject()->loadDom($dom); } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php index 6b2719e088bf574f033352963bfc63cc363e1674..0e5c9ec84d8957895337051890d256bccda9431b 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/BlockTest.php @@ -38,26 +38,28 @@ class BlockTest extends \PHPUnit_Framework_TestCase /** * @param string $xml + * @param string $elementType * @return \Magento\Framework\View\Layout\Element */ - protected function getElement($xml) + protected function getElement($xml, $elementType) { $xml = '<' . \Magento\Framework\View\Layout\Reader\Block::TYPE_BLOCK . '>' . $xml . '</' . \Magento\Framework\View\Layout\Reader\Block::TYPE_BLOCK . '>'; $xml = simplexml_load_string($xml, 'Magento\Framework\View\Layout\Element'); - return current($xml->children()); + return $xml->{$elementType}; } /** * Prepare reader pool * * @param string $xml + * @param string $elementType */ - protected function prepareReaderPool($xml) + protected function prepareReaderPool($xml, $elementType) { - $this->currentElement = $this->getElement($xml); + $this->currentElement = $this->getElement($xml, $elementType); $this->readerPool->expects($this->once())->method('interpret')->with($this->context, $this->currentElement); } @@ -116,7 +118,11 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->scheduledStructure->expects($getCondition) ->method('getStructureElementData') ->with($literal, []) - ->willReturn([]); + ->willReturn([ + 'actions' => [ + ['someMethod', [], 'action_config_path', 'scope'], + ], + ]); $this->scheduledStructure->expects($setCondition) ->method('setStructureElementData') ->with( @@ -140,8 +146,9 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->prepareReaderPool( '<' . $literal . ' ifconfig="' . $ifconfigValue . '">' - . '<action method="someMethod" ifconfig="action_config_path" />' - . '</' . $literal . '>' + . '<action method="someMethod" ifconfig="action_config_path" />' + . '</' . $literal . '>', + $literal ); /** @var \Magento\Framework\View\Layout\Reader\Block $block */ @@ -184,7 +191,11 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->scheduledStructure->expects($getCondition) ->method('getStructureElementData') ->with($literal, []) - ->willReturn([]); + ->willReturn([ + 'actions' => [ + ['someMethod', [], 'action_config_path', 'scope'], + ], + ]); $this->scheduledStructure->expects($setCondition) ->method('setStructureElementData') ->with( @@ -199,8 +210,9 @@ class BlockTest extends \PHPUnit_Framework_TestCase $this->prepareReaderPool( '<' . $literal . ' name="' . $literal . '">' - . '<action method="someMethod" ifconfig="action_config_path" />' - . '</' . $literal . '>' + . '<action method="someMethod" ifconfig="action_config_path" />' + . '</' . $literal . '>', + $literal ); /** @var \Magento\Framework\View\Layout\Reader\Block $block */ diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php index e79b16a2ca6a6b9627e59b72f78a4ae9285e22fd..2f90f4c1b1f23cd62412465d34ac9073e953a2c3 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/ContainerTest.php @@ -103,7 +103,10 @@ class ContainerTest extends \PHPUnit_Framework_TestCase { return [ 'container' => [ - 'elementCurrent' => $this->getElement('<container name="container" id="id_add" tag="body"/>'), + 'elementCurrent' => $this->getElement( + '<container name="container" id="id_add" tag="body"/>', + 'container' + ), 'containerName' => 'container', 'structureElement' => [ 'attributes' => [ @@ -122,7 +125,8 @@ class ContainerTest extends \PHPUnit_Framework_TestCase ], 'referenceContainer' => [ 'elementCurrent' => $this->getElement( - '<referenceContainer name="reference" htmlTag="span" htmlId="id_add" htmlClass="new" label="Add"/>' + '<referenceContainer name="reference" htmlTag="span" htmlId="id_add" htmlClass="new" label="Add"/>', + 'referenceContainer' ), 'containerName' => 'reference', 'structureElement' => [], @@ -140,14 +144,15 @@ class ContainerTest extends \PHPUnit_Framework_TestCase /** * @param string $xml + * @param string $elementType * @return \Magento\Framework\View\Layout\Element */ - protected function getElement($xml) + protected function getElement($xml, $elementType) { $xml = simplexml_load_string( '<parent_element>' . $xml . '</parent_element>', 'Magento\Framework\View\Layout\Element' ); - return current($xml->children()); + return $xml->{$elementType}; } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php index 67ed4e08e4cbf9341795dfd6d2dec22bfe62c268..145c8f6992e9167ec631c92fdb132f38386afac4 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/Layout/Reader/UiComponentTest.php @@ -70,7 +70,9 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase ['attributes' => ['group' => '', 'component' => 'listing']] ); $scheduleStructure->expects($this->once())->method('setElementToIfconfigList')->with( - $element->getAttribute('name'), 'config_path', 'scope' + $element->getAttribute('name'), + 'config_path', + 'scope' ); $this->model->interpret($this->context, $element); } @@ -80,7 +82,8 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase return [ [ $this->getElement( - '<ui_component name="cms_block_listing" component="listing" ifconfig="config_path"/>' + '<ui_component name="cms_block_listing" component="listing" ifconfig="config_path"/>', + 'ui_component' ), ] ]; @@ -88,14 +91,15 @@ class UiComponentTest extends \PHPUnit_Framework_TestCase /** * @param string $xml + * @param string $elementType * @return \Magento\Framework\View\Layout\Element */ - protected function getElement($xml) + protected function getElement($xml, $elementType) { $xml = simplexml_load_string( '<parent_element>' . $xml . '</parent_element>', 'Magento\Framework\View\Layout\Element' ); - return current($xml->children()); + return $xml->{$elementType}; } } diff --git a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php index efbe7b23a727f76496a3565330a3288e8852a447..ab17c14b9b3bad2f86e6a312ccf9aa7ba36be98f 100644 --- a/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php +++ b/lib/internal/Magento/Framework/View/Test/Unit/TemplateEngine/PhpTest.php @@ -56,7 +56,6 @@ class PhpTest extends \PHPUnit_Framework_TestCase * * Expect an exception if the specified file does not exist. * @expectedException \Exception - * @expectedExceptionMessage include(This_is_not_a_file): failed to open stream: No such file or directory */ public function testRenderException() { diff --git a/lib/internal/Magento/Framework/Webapi/Request.php b/lib/internal/Magento/Framework/Webapi/Request.php index e40112ce2d6466e70b881460ec6b6a1c867172ab..fdd688a313e51a83d6cd1bf3ec3d78bc5b61e22e 100644 --- a/lib/internal/Magento/Framework/Webapi/Request.php +++ b/lib/internal/Magento/Framework/Webapi/Request.php @@ -39,4 +39,22 @@ class Request extends HttpRequest implements RequestInterface $pathInfo = preg_replace('#\?.*#', '', $pathInfo); $this->setPathInfo($pathInfo); } + + /** + * {@inheritdoc} + * + * Added CGI environment support. + */ + public function getHeader($header, $default = false) + { + $headerValue = parent::getHeader($header, $default); + if ($headerValue == false) { + /** Workaround for hhvm environment */ + $header = 'REDIRECT_HTTP_' . strtoupper(str_replace('-', '_', $header)); + if (isset($_SERVER[$header])) { + $headerValue = $_SERVER[$header]; + } + } + return $headerValue; + } } diff --git a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php index ba0091bc725a7e94f6073f2ea2fb21bbac36ca6d..34f3936ce563c3b399eb280640bb532025ba507b 100644 --- a/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php +++ b/lib/internal/Magento/Framework/Webapi/Rest/Request/Deserializer/Json.php @@ -52,10 +52,10 @@ class Json implements \Magento\Framework\Webapi\Rest\Request\DeserializerInterfa throw new \Magento\Framework\Webapi\Exception(new Phrase('Decoding error.')); } else { throw new \Magento\Framework\Webapi\Exception( - new Phrase( + (string)(new Phrase( 'Decoding error: %1%2%3%4', [PHP_EOL, $e->getMessage(), PHP_EOL, $e->getTraceAsString()] - ) + )) ); } } diff --git a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php index 06d50d55d388e6a390971e730228fcf82aa97da1..a248687ce6b24b07864012cc33f9b5bf9210cf09 100644 --- a/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php +++ b/setup/src/Magento/Setup/Test/Unit/Controller/ConsoleControllerTest.php @@ -132,7 +132,7 @@ class ConsoleControllerTest extends \PHPUnit_Framework_TestCase { $errorMessage = 'Missing route matches; unsure how to retrieve action'; $event = $this->getMock('Zend\Mvc\MvcEvent'); - $exception = $this->getMock('Magento\Setup\Exception', [], [$errorMessage]); + $exception = $this->getMock('Magento\Setup\Exception', ['getCode'], [$errorMessage]); $event->expects($this->once())->method('getRouteMatch')->willThrowException($exception); $this->consoleLogger->expects($this->once())->method('log')->with($errorMessage); $this->controller->onDispatch($event);