diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php index 3421f31a706889dd010310e334be7247974be457..f04d5a436e27b76a197e1cfb4112978656138a7b 100644 --- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php +++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Grid.php @@ -114,8 +114,6 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended */ protected function _prepareCollection() { - parent::_prepareCollection(); - $store = $this->_getStore(); $collection = $this->_productFactory->create()->getCollection()->addAttributeToSelect( 'sku' @@ -184,6 +182,9 @@ class Grid extends \Magento\Backend\Block\Widget\Grid\Extended $this->setCollection($collection); $this->getCollection()->addWebsiteNamesToResult(); + + parent::_prepareCollection(); + return $this; } diff --git a/app/code/Magento/Catalog/Block/Product/View/Gallery.php b/app/code/Magento/Catalog/Block/Product/View/Gallery.php index 7f4ad758fa71335386ad4dfd1dd2d0fc4b5805d0..0edeba7d807ac8e4c1be154d236bbff7c93a87b5 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Gallery.php +++ b/app/code/Magento/Catalog/Block/Product/View/Gallery.php @@ -121,9 +121,9 @@ class Gallery extends \Magento\Catalog\Block\Product\View\AbstractView } if (empty($imagesItems)) { $imagesItems[] = [ - 'thumb' => $this->_imageHelper->getDefaultPlaceholderUrl('thumbnail'), - 'img' => $this->_imageHelper->getDefaultPlaceholderUrl('image'), - 'full' => $this->_imageHelper->getDefaultPlaceholderUrl('image'), + 'thumb' => $this->getImage($this->getProduct(), 'product_thumbnail_image')->getImageUrl(), + 'img' => $this->getImage($this->getProduct(), 'product_base_image')->getImageUrl(), + 'full' => $this->getImage($this->getProduct(), 'product_page_image_large')->getImageUrl(), 'caption' => '', 'position' => '0', 'isMain' => true, diff --git a/app/code/Magento/Catalog/Helper/Image.php b/app/code/Magento/Catalog/Helper/Image.php index e29b0496d1779037c51ff3d58d09ae91b6dc5ff2..eb5e7142d3094f5457fde615bc4987a8df912ab1 100644 --- a/app/code/Magento/Catalog/Helper/Image.php +++ b/app/code/Magento/Catalog/Helper/Image.php @@ -433,6 +433,9 @@ class Image extends AbstractHelper * * @param null|string $placeholder * @return string + * + * @deprecated Returns only default placeholder. + * Does not take into account custom placeholders set in Configuration. */ public function getPlaceholder($placeholder = null) { @@ -544,6 +547,9 @@ class Image extends AbstractHelper /** * @param null|string $placeholder * @return string + * + * @deprecated Returns only default placeholder. + * Does not take into account custom placeholders set in Configuration. */ public function getDefaultPlaceholderUrl($placeholder = null) { diff --git a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php index 2ec8137d768bf292dc50d0e7ce98bbd773ab9a65..5ed18d15b2f304cdc9ca6e89a7bcc09e2a5c3590 100644 --- a/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php +++ b/app/code/Magento/Catalog/Model/System/Config/Backend/Catalog/Url/Rewrite/Suffix.php @@ -93,10 +93,27 @@ class Suffix extends \Magento\Framework\App\Config\Value { if ($this->isValueChanged()) { $this->updateSuffixForUrlRewrites(); + if ($this->isCategorySuffixChanged()) { + $this->cacheTypeList->invalidate([ + \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER, + \Magento\Framework\App\Cache\Type\Collection::TYPE_IDENTIFIER + ]); + } } return parent::afterSave(); } + /** + * Check is category suffix changed + * + * @return bool + */ + private function isCategorySuffixChanged() + { + return $this->isValueChanged() + && ($this->getPath() == CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX); + } + /** * Update suffix for url rewrites * diff --git a/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php new file mode 100644 index 0000000000000000000000000000000000000000..7ceb21436b56a1c69e2fae723caaf70c41642be1 --- /dev/null +++ b/app/code/Magento/Catalog/Test/Unit/Model/System/Config/Backend/Catalog/Url/Rewrite/SuffixTest.php @@ -0,0 +1,138 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\Catalog\Test\Unit\Model\System\Config\Backend\Catalog\Url\Rewrite; + +class SuffixTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Model\Context + */ + protected $context; + + /** + * @var \Magento\Framework\Event\ManagerInterface + */ + protected $eventDispatcher; + + /** + * @var \Magento\Framework\Registry + */ + protected $registry; + + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + protected $config; + + /** + * @var \Magento\Framework\App\Cache\TypeListInterface + */ + protected $cacheTypeList; + + /** + * @var \Magento\UrlRewrite\Helper\UrlRewrite + */ + protected $urlRewriteHelper; + + /** + * @var \Magento\Store\Model\StoreManagerInterface + */ + protected $storeManager; + + /** + * @var \Magento\Framework\App\ResourceConnection + */ + protected $appResource; + + /** + * @var \Magento\UrlRewrite\Model\UrlFinderInterface + */ + protected $urlFinder; + + /** + * @var \Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix + */ + protected $suffixModel; + + public function setUp() + { + $this->eventDispatcher = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->setMethods(['dispatch']) + ->getMock(); + $this->eventDispatcher->method('dispatch')->willReturnSelf(); + $this->context = $this->getMockBuilder('\Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->setMethods(['getEventDispatcher']) + ->getMock(); + $this->context->method('getEventDispatcher')->willReturn($this->eventDispatcher); + + $this->registry = $this->getMock('\Magento\Framework\Registry'); + $this->config = $this->getMock('\Magento\Framework\App\Config\ScopeConfigInterface'); + $this->cacheTypeList = $this->getMockBuilder('\Magento\Framework\App\Cache\TypeList') + ->disableOriginalConstructor() + ->setMethods(['invalidate']) + ->getMock(); + + $this->urlRewriteHelper = $this->getMockBuilder('\Magento\UrlRewrite\Helper\UrlRewrite') + ->disableOriginalConstructor() + ->getMock(); + $this->storeManager = $this->getMockBuilder('\Magento\Store\Model\StoreManager') + ->disableOriginalConstructor() + ->setMethods(['getStores']) + ->getMock(); + $this->storeManager->method('getStores')->willReturn([]); + + $this->appResource =$this->getMockBuilder('\Magento\Framework\App\ResourceConnection') + ->disableOriginalConstructor() + ->getMock(); + $this->urlFinder =$this->getMockBuilder('\Magento\UrlRewrite\Model\UrlFinderInterface') + ->setMethods(['findAllByData', 'findOneByData']) + ->getMock(); + $this->urlFinder->method('findAllByData')->willReturn([]); + + $this->suffixModel = new \Magento\Catalog\Model\System\Config\Backend\Catalog\Url\Rewrite\Suffix( + $this->context, + $this->registry, + $this->config, + $this->cacheTypeList, + $this->urlRewriteHelper, + $this->storeManager, + $this->appResource, + $this->urlFinder + ); + } + + public function testAfterSaveCleanCache() + { + $this->suffixModel->setValue('new'); + $this->suffixModel->setPath(\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX); + $this->cacheTypeList->expects($this->exactly(2))->method('invalidate')->withConsecutive( + [$this->equalTo([ + \Magento\Framework\App\Cache\Type\Block::TYPE_IDENTIFIER, + \Magento\Framework\App\Cache\Type\Collection::TYPE_IDENTIFIER + ])], + [$this->equalTo('config')] + ); + $this->suffixModel->afterSave(); + } + + public function testAfterSaveWithoutChanges() + { + $this->suffixModel->setValue(''); + $this->suffixModel->setPath(\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator::XML_PATH_CATEGORY_URL_SUFFIX); + $this->cacheTypeList->expects($this->never())->method('invalidate'); + $this->suffixModel->afterSave(); + } + + public function testAfterSaveProduct() + { + $this->suffixModel->setValue('new'); + $this->suffixModel->setPath(\Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::XML_PATH_PRODUCT_URL_SUFFIX); + $this->cacheTypeList->expects($this->once())->method('invalidate')->with('config'); + $this->suffixModel->afterSave(); + } +} diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php index 06c55a765ad3ee07f611b0a3a31b238ec9baa459..a618ca4703370c4961e8e90727b084d13bd8418f 100644 --- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php +++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php @@ -480,6 +480,11 @@ class AdvancedPricing extends AbstractModifier 'dataType' => Number::NAME, 'label' => __('Quantity'), 'dataScope' => 'price_qty', + 'validation' => [ + 'required-entry' => true, + 'validate-greater-than-zero' => true, + 'validate-digits' => true, + ], ], ], ], @@ -497,6 +502,11 @@ class AdvancedPricing extends AbstractModifier 'addbefore' => $this->locator->getStore() ->getBaseCurrency() ->getCurrencySymbol(), + 'validation' => [ + 'required-entry' => true, + 'validate-greater-than-zero' => true, + 'validate-number' => true, + ], ], ], ], diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml index 8b8c5bd7adc9effd1d058ee4a1063bc9db2094a5..85793a2073d76224a467e97621766b079ffe63b3 100644 --- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml +++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml @@ -185,6 +185,7 @@ </item> <item name="template" xsi:type="string">ui/form/field</item> <item name="source" xsi:type="string">category</item> + <item name="label" xsi:type="string" translate="true">Description</item> <item name="wysiwyg" xsi:type="boolean">true</item> <item name="dataScope" xsi:type="string">description</item> <item name="sortOrder" xsi:type="number">50</item> @@ -217,6 +218,7 @@ <item name="sortOrder" xsi:type="number">70</item> <item name="dataType" xsi:type="string">string</item> <item name="formElement" xsi:type="string">select</item> + <item name="label" xsi:type="string" translate="true">Display Mode</item> </item> </argument> </field> @@ -244,7 +246,6 @@ <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> <item name="required" xsi:type="boolean">true</item> <item name="sortOrder" xsi:type="number">90</item> - <item name="label" xsi:type="string" translate="true">Sort Products By</item> </item> </argument> <field name="available_sort_by"> @@ -253,6 +254,7 @@ <item name="additionalClasses" xsi:type="string">admin__field-default</item> <item name="formElement" xsi:type="string">multiselect</item> <item name="source" xsi:type="string">category</item> + <item name="label" xsi:type="string" translate="true">Available Product Listing Sort By</item> </item> </argument> </field> @@ -279,7 +281,6 @@ <item name="config" xsi:type="array"> <item name="breakLine" xsi:type="boolean">true</item> <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> - <item name="label" xsi:type="string" translate="true">Default Product Sorting</item> <item name="required" xsi:type="boolean">true</item> <item name="sortOrder" xsi:type="number">100</item> </item> @@ -290,6 +291,7 @@ <item name="additionalClasses" xsi:type="string">admin__field-default</item> <item name="formElement" xsi:type="string">select</item> <item name="source" xsi:type="string">category</item> + <item name="label" xsi:type="string" translate="true">Default Product Listing Sort By</item> </item> </argument> </field> @@ -316,7 +318,6 @@ <item name="config" xsi:type="array"> <item name="breakLine" xsi:type="boolean">true</item> <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> - <item name="label" xsi:type="string" translate="true">Layered Navigation Price Step</item> <item name="required" xsi:type="boolean">true</item> <item name="sortOrder" xsi:type="number">110</item> </item> @@ -327,6 +328,7 @@ <item name="additionalClasses" xsi:type="string">admin__field-small</item> <item name="formElement" xsi:type="string">input</item> <item name="source" xsi:type="string">category</item> + <item name="label" xsi:type="string" translate="true">Layered Navigation Price Step</item> <item name="addbefore" xsi:type="string">$</item> </item> </argument> @@ -362,7 +364,6 @@ <item name="type" xsi:type="string">group</item> <item name="config" xsi:type="array"> <item name="component" xsi:type="string">Magento_Ui/js/form/components/group</item> - <item name="label" xsi:type="string" translate="true">URL Key</item> <item name="required" xsi:type="boolean">false</item> <item name="sortOrder" xsi:type="number">120</item> </item> @@ -372,6 +373,7 @@ <item name="config" xsi:type="array"> <item name="formElement" xsi:type="string">input</item> <item name="source" xsi:type="string">category</item> + <item name="label" xsi:type="string" translate="true">URL Key</item> <item name="sortOrder" xsi:type="number">10</item> <item name="imports" xsi:type="array"> <item name="disabled" xsi:type="string">${ $.provider }:data.use_default.url_key</item> diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml index dea0f99387dd16801fd9f6db8e7987e3dc150f30..578a58fb4d48de7f58ec8d093aa959f5a0a7c914 100644 --- a/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml +++ b/app/code/Magento/Catalog/view/frontend/templates/product/list.phtml @@ -89,7 +89,7 @@ $_helper = $this->helper('Magento\Catalog\Helper\Output'); </button> </form> <?php else: ?> - <?php if ($_product->getIsSalable()): ?> + <?php if ($_product->isAvailable()): ?> <div class="stock available"><span><?php /* @escapeNotVerified */ echo __('In stock') ?></span></div> <?php else: ?> <div class="stock unavailable"><span><?php /* @escapeNotVerified */ echo __('Out of stock') ?></span></div> diff --git a/app/code/Magento/CatalogInventory/Model/Stock.php b/app/code/Magento/CatalogInventory/Model/Stock.php index 85523616e89cd22d324af38656cd0a522c160874..1c38e53d1201ccd7d04efa15e31895a0501caeda 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock.php +++ b/app/code/Magento/CatalogInventory/Model/Stock.php @@ -24,7 +24,7 @@ class Stock extends AbstractExtensibleModel implements StockInterface * * @var string */ - protected $eventPrefix = 'cataloginventory_stock'; + protected $_eventPrefix = 'cataloginventory_stock'; /** * Parameter name in event diff --git a/app/code/Magento/CatalogInventory/Model/Stock/Item.php b/app/code/Magento/CatalogInventory/Model/Stock/Item.php index 7a84ffec7d1c598920eb17ece8c50acef053bca0..2757f8e5edcf3f0ad653779b6bd61120c31b3491 100644 --- a/app/code/Magento/CatalogInventory/Model/Stock/Item.php +++ b/app/code/Magento/CatalogInventory/Model/Stock/Item.php @@ -32,7 +32,7 @@ class Item extends AbstractExtensibleModel implements StockItemInterface * * @var string */ - protected $eventPrefix = 'cataloginventory_stock_item'; + protected $_eventPrefix = 'cataloginventory_stock_item'; const WEBSITE_ID = 'website_id'; diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php index 7c037f86515feb43510312b4ab1927567a8a44a1..5b2c1e3366e02f65a223d9f90cefc650e37c5d9d 100644 --- a/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Stock/ItemTest.php @@ -72,8 +72,18 @@ class ItemTest extends \PHPUnit_Framework_TestCase */ protected $storeId = 111; + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + private $eventDispatcher; + protected function setUp() { + $this->eventDispatcher = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->setMethods(['dispatch']) + ->getMock(); + $this->context = $this->getMock( '\Magento\Framework\Model\Context', ['getEventDispatcher'], @@ -81,6 +91,7 @@ class ItemTest extends \PHPUnit_Framework_TestCase '', false ); + $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventDispatcher); $this->registry = $this->getMock( '\Magento\Framework\Registry', @@ -457,4 +468,39 @@ class ItemTest extends \PHPUnit_Framework_TestCase ], ]; } + + /** + * We wan't to ensure that property $_eventPrefix used during event dispatching + * + * @param $eventName + * @param $methodName + * + * @dataProvider eventsDataProvider + */ + public function testDispatchEvents($eventName, $methodName) + { + $isCalledWithRightPrefix = 0; + $this->eventDispatcher->expects($this->any())->method('dispatch')->with( + $this->callback(function($arg) use (&$isCalledWithRightPrefix, $eventName) { + $isCalledWithRightPrefix |= ($arg === $eventName); + return true; + }), + $this->anything() + ); + + $this->item->$methodName(); + $this->assertEquals( + 1, + (int) $isCalledWithRightPrefix, + sprintf("Event %s doesn't dispatched", $eventName) + ); + } + + public function eventsDataProvider() + { + return [ + ['cataloginventory_stock_item_save_before', 'beforeSave'], + ['cataloginventory_stock_item_save_after', 'afterSave'], + ]; + } } diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php new file mode 100644 index 0000000000000000000000000000000000000000..48c532bba7045c2fc56a98aacbef395143880b34 --- /dev/null +++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/StockTest.php @@ -0,0 +1,132 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ +namespace Magento\CatalogInventory\Test\Unit\Model; + +/** + * Class StockTest + */ +class StockTest extends \PHPUnit_Framework_TestCase +{ + /** + * @var \Magento\Framework\Model\Context + */ + private $context; + + /** + * @var \Magento\Framework\Registry + */ + private $registry; + + /** + * @var Magento\Framework\Api\ExtensionAttributesFactory + */ + private $extensionFactory; + + /** + * @var \Magento\Framework\Model\ExtensionAttributesFactory + */ + private $customAttributeFactory; + + /** + * @var \Magento\Framework\Model\ResourceModel\AbstractResource + */ + private $resource; + + /** + * @var \Magento\Framework\Data\Collection\AbstractDb + */ + private $resourceCollection; + + /** + * @var PHPUnit_Framework_MockObject_MockObject + */ + private $eventDispatcher; + + /** + * @var \Magento\CatalogInventory\Model\Stock + */ + private $stockModel; + + public function setUp() + { + /** @var PHPUnit_Framework_MockObject_MockObject */ + $this->eventDispatcher = $this->getMockBuilder('\Magento\Framework\Event\ManagerInterface') + ->disableOriginalConstructor() + ->setMethods(['dispatch']) + ->getMock(); + + $this->context = $this->getMockBuilder('\Magento\Framework\Model\Context') + ->disableOriginalConstructor() + ->setMethods(['getEventDispatcher']) + ->getMock(); + $this->context->expects($this->any())->method('getEventDispatcher')->willReturn($this->eventDispatcher); + + $this->registry = $this->getMockBuilder('\Magento\Framework\Registry') + ->disableOriginalConstructor() + ->getMock(); + + $this->extensionFactory = $this->getMockBuilder('Magento\Framework\Api\ExtensionAttributesFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->customAttributeFactory = $this->getMockBuilder('Magento\Framework\Api\AttributeValueFactory') + ->disableOriginalConstructor() + ->getMock(); + + $this->resource = $this->getMockBuilder('\Magento\Framework\Model\ResourceModel\AbstractResource') + ->disableOriginalConstructor() + ->setMethods(['getIdFieldName']) + ->getMockForAbstractClass(); + + $this->resourceCollection = $this->getMockBuilder('\Magento\Framework\Data\Collection\AbstractDb') + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $this->stockModel = new \Magento\CatalogInventory\Model\Stock( + $this->context, + $this->registry, + $this->extensionFactory, + $this->customAttributeFactory, + $this->resource, + $this->resourceCollection + ); + } + + /** + * We wan't to ensure that property $_eventPrefix used during event dispatching + * + * @param $eventName + * @param $methodName + * + * @dataProvider eventsDataProvider + */ + public function testDispatchEvents($eventName, $methodName) + { + $isCalledWithRightPrefix = 0; + $this->eventDispatcher->expects($this->any())->method('dispatch')->with( + $this->callback(function($arg) use (&$isCalledWithRightPrefix, $eventName) { + $isCalledWithRightPrefix |= ($arg === $eventName); + return true; + }), + $this->anything() + ); + + $this->stockModel->$methodName(); + $this->assertEquals( + 1, + (int) $isCalledWithRightPrefix, + sprintf("Event %s doesn't dispatched", $eventName) + ); + } + + public function eventsDataProvider() + { + return [ + ['cataloginventory_stock_save_before', 'beforeSave'], + ['cataloginventory_stock_save_after', 'afterSave'], + ]; + } +} diff --git a/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php b/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php index 51eae4a970cf85bac3db42d9f9a4fb0eedb4ec1f..50b570cc366ee8a8bd84208ffce200fcd6ef31c3 100644 --- a/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php +++ b/app/code/Magento/Reports/Model/ResourceModel/Review/Customer/Collection.php @@ -83,7 +83,7 @@ class Collection extends \Magento\Review\Model\ResourceModel\Review\Collection $this->getSelect()->reset( \Magento\Framework\DB\Select::COLUMNS )->joinInner( - ['customer' => $connection->getTableName('customer_entity')], + ['customer' => $this->getTable('customer_entity')], 'customer.entity_id = detail.customer_id', [] )->columns( diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php index 02f19ce4bce4c3c4e490704ae4a44d17f0117158..eff593ac8d0bf7a3761b2a74f7e8ab928d5ac713 100755 --- a/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Backend/Test/Block/Widget/Grid.php @@ -293,7 +293,7 @@ abstract class Grid extends Block if ($selectItem->isVisible()) { $selectItem->click(); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } } diff --git a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php index 47a424af9fbd886f99a3cc75560de658e69a79d2..704404e665ac1c394d9d28621a0dcb9139dd4047 100644 --- a/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Bundle/Test/Constraint/AssertBundleProductPage.php @@ -25,6 +25,9 @@ class AssertBundleProductPage extends AssertProductPage $priceData = $this->product->getDataFieldConfig('price')['source']->getPriceData(); $priceView = $this->product->getPriceView(); $priceBlock = $this->productView->getPriceBlock(); + if (!$priceBlock->isVisible()) { + return "Price block for '{$this->product->getName()}' product' is not visible."; + } if ($this->product->hasData('special_price')) { $priceLow = $priceBlock->getPrice(); diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php index ab016aaa882c354c2c8f83374f148a46b30f065a..9884d0c3f4115ff23ce27c7bd13478f85eb259ad 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertCategoryPage.php @@ -161,6 +161,13 @@ class AssertCategoryPage extends AbstractConstraint { $errorMessage = []; + if (!$this->categoryViewPage->getViewBlock()->isVisible()) { + $errorMessage[] = + 'Category Content is not visible.' + . "Skipped verifying Content settings for category {$categoryData['name']}."; + return $errorMessage; + } + if (isset($categoryData['description'])) { $description = $this->categoryViewPage->getViewBlock()->getDescription(); if ($categoryData['description'] != $description) { diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php index 928c89e29ffb5018c0fa8027a23bf8fc65113a51..e99b63d5b8ce7727b93cc3ef2898ef6ba95caf01 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertProductPage.php @@ -82,20 +82,24 @@ class AssertProductPage extends AbstractAssertForm } /** - * Verify displayed product name on product page(front-end) equals passed from fixture + * Verify displayed product name on Storefront product page equals to the passed from fixture * * @return string|null */ protected function verifyName() { - $fixtureProductName = $this->product->getName(); - $formProductName = $this->productView->getProductName(); + $expectedName = $this->product->getName(); + try { + $actualName = $this->productView->getProductName(); + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + return "Could not find product '{$this->product->getName()}' name on the page.\n" . $e->getMessage(); + } - if ($fixtureProductName == $formProductName) { + if ($expectedName == $actualName) { return null; } - return "Displayed product name on product page(front-end) not equals passed from fixture. " - . "Actual: {$formProductName}, expected: {$fixtureProductName}."; + return "Product name on Storefront product '{$this->product->getName()}' page is unexpected. " + . "Actual: {$actualName}, expected: {$expectedName}."; } /** @@ -110,12 +114,15 @@ class AssertProductPage extends AbstractAssertForm } $priceBlock = $this->productView->getPriceBlock(); - $formPrice = $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(); - $fixturePrice = number_format($this->product->getPrice(), 2, '.', ''); + if (!$priceBlock->isVisible()) { + return "Price block for '{$this->product->getName()}' product' is not visible."; + } + $actualPrice = $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(); + $expectedPrice = number_format($this->product->getPrice(), 2, '.', ''); - if ($fixturePrice != $formPrice) { - return "Displayed product price on product page(front-end) not equals passed from fixture. " - . "Actual: {$fixturePrice}, expected: {$formPrice}."; + if ($expectedPrice != $actualPrice) { + return "Displayed product price on Storefront product '{$this->product->getName()}' page is unexpected. " + . "Actual: {$actualPrice}, expected: {$expectedPrice}."; } return null; } @@ -130,14 +137,18 @@ class AssertProductPage extends AbstractAssertForm if (!$this->product->hasData('special_price')) { return null; } - $fixtureProductSpecialPrice = $this->product->getSpecialPrice(); - $fixtureProductSpecialPrice = number_format($fixtureProductSpecialPrice, 2); - $formProductSpecialPrice = $this->productView->getPriceBlock()->getSpecialPrice(); - if ($fixtureProductSpecialPrice == $formProductSpecialPrice) { + $expectedSpecialPrice = $this->product->getSpecialPrice(); + $expectedSpecialPrice = number_format($expectedSpecialPrice, 2); + $priceBlock = $this->productView->getPriceBlock(); + if (!$priceBlock->isVisible()) { + return "Price block for '{$this->product->getName()}' product' is not visible."; + } + $actualSpecialPrice = $priceBlock->getSpecialPrice(); + if ($expectedSpecialPrice == $actualSpecialPrice) { return null; } - return "Displayed product special price on product page(front-end) not equals passed from fixture. " - . "Actual: {$formProductSpecialPrice}, expected: {$fixtureProductSpecialPrice}."; + return "Displayed product special price on Storefront product '{$this->product->getName()}' page is unexpected." + . "Actual: {$actualSpecialPrice}, expected: {$expectedSpecialPrice}."; } /** @@ -147,14 +158,18 @@ class AssertProductPage extends AbstractAssertForm */ protected function verifySku() { - $fixtureProductSku = $this->product->getSku(); - $formProductSku = $this->productView->getProductSku(); + $expectedSku = $this->product->getSku(); + try { + $actualSku = $this->productView->getProductSku(); + } catch (\PHPUnit_Extensions_Selenium2TestCase_WebDriverException $e) { + return "Could not find product {$this->product->getName()}' SKU on the page.\n" . $e->getMessage(); + } - if ($fixtureProductSku === null || $fixtureProductSku == $formProductSku) { + if ($expectedSku === null || $expectedSku == $actualSku) { return null; } - return "Displayed product sku on product page(front-end) not equals passed from fixture. " - . "Actual: {$formProductSku}, expected: {$fixtureProductSku}."; + return "Displayed product SKU on Storefront product '{$this->product->getName()}' page is unexpected. " + . "Actual: {$actualSku}, expected: {$expectedSku}."; } /** @@ -164,14 +179,14 @@ class AssertProductPage extends AbstractAssertForm */ protected function verifyDescription() { - $fixtureProductDescription = $this->product->getDescription(); - $formProductDescription = $this->productView->getProductDescription(); + $expectedDescription = $this->product->getDescription(); + $actualDescription = $this->productView->getProductDescription(); - if ($fixtureProductDescription === null || $fixtureProductDescription == $formProductDescription) { + if ($expectedDescription === null || $expectedDescription == $actualDescription) { return null; } - return "Displayed product description on product page(front-end) not equals passed from fixture. " - . "Actual: {$formProductDescription}, expected: {$fixtureProductDescription}."; + return "Displayed product description on Storefront product '{$this->product->getName()}' page is unexpected. " + . "Actual: {$actualDescription}, expected: {$expectedDescription}."; } /** @@ -181,14 +196,14 @@ class AssertProductPage extends AbstractAssertForm */ protected function verifyShortDescription() { - $fixtureShortDescription = $this->product->getShortDescription(); - $formProductShortDescription = $this->productView->getProductShortDescription(); + $expected = $this->product->getShortDescription(); + $actual = $this->productView->getProductShortDescription(); - if ($fixtureShortDescription === null || $fixtureShortDescription == $formProductShortDescription) { + if ($expected === null || $expected == $actual) { return null; } - return "Displayed product short description on product page(front-end) not equals passed from fixture. " - . "Actual: {$formProductShortDescription}, expected: {$fixtureShortDescription}."; + return "Displayed short description on Storefront product '{$this->product->getName()}' page is unexpected. " + . "Actual: {$actual}, expected: {$expected}."; } /** diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/DeleteCompareProductsTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/DeleteCompareProductsTest.xml index d2e437b994e5f81681a9c3d10079ad2b5de04ee4..883e7cdf6032c5813759db3d613378c34f04c277 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/DeleteCompareProductsTest.xml +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Product/DeleteCompareProductsTest.xml @@ -7,14 +7,14 @@ --> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../vendor/magento/mtf/etc/variations.xsd"> <testCase name="Magento\Catalog\Test\TestCase\Product\DeleteCompareProductsTest" summary="Delete Compare Products" ticketId="MAGETWO-26161"> - <variation name="DeleteCompareProductsTestVariation1"> + <variation name="DeleteCompareProductsTestVariation1_NotLoggedIn"> <data name="products" xsi:type="string">catalogProductSimple::simple_for_composite_products,catalogProductVirtual::default,downloadableProduct::default,groupedProduct::grouped_product_with_price,configurableProduct::default,bundleProduct::bundle_dynamic_product,bundleProduct::bundle_fixed_product</data> <data name="removeProductIndex" xsi:type="string">1</data> <data name="isCustomerLoggedIn" xsi:type="string">No</data> <constraint name="Magento\Catalog\Test\Constraint\AssertProductCompareSuccessRemoveMessage" /> <constraint name="Magento\Catalog\Test\Constraint\AssertProductIsNotVisibleInComparePage" /> </variation> - <variation name="DeleteCompareProductsTestVariation2"> + <variation name="DeleteCompareProductsTestVariation2_LoggedIn"> <data name="products" xsi:type="string">catalogProductSimple::simple_for_composite_products,catalogProductVirtual::default,downloadableProduct::default,groupedProduct::grouped_product_with_price,configurableProduct::default,bundleProduct::bundle_dynamic_product,bundleProduct::bundle_fixed_product</data> <data name="removeProductIndex" xsi:type="string">6</data> <data name="isCustomerLoggedIn" xsi:type="string">Yes</data> diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php index ac7823b41eede69f82b85c0e957a02cc97eb39be..4bb5d80b6d6720c3f5b26319c541b172ede0ec01 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedCatalogPage.php @@ -49,6 +49,10 @@ class AssertCatalogPriceRuleAppliedCatalogPage extends AbstractConstraint $categoryName = $product->getCategoryIds()[0]; $cmsIndexPage->getTopmenu()->selectCategoryByName($categoryName); $priceBlock = $catalogCategoryViewPage->getListProductBlock()->getProductItem($product)->getPriceBlock(); + \PHPUnit_Framework_Assert::assertTrue( + $priceBlock->isVisible(), + 'Price block is not displayed for product ' . $product->getName() + ); $actualPrice['regular'] = (float)$priceBlock->getOldPrice(); $actualPrice['special'] = (float)$priceBlock->getSpecialPrice(); $actualPrice['discount_amount'] = $actualPrice['regular'] - $actualPrice['special']; diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php index 7b4028e8029b2f7a73864bf30fbe733a21d7ac90..bee31130bec3cd12b60f421682ba5d4650bd5f64 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedOnepageCheckout.php @@ -67,6 +67,8 @@ class AssertCatalogPriceRuleAppliedOnepageCheckout extends AbstractConstraint $expectedPrices, $actualPrices, 'Wrong total cart prices are displayed.' + . "\nExpected: " . implode(PHP_EOL, $expectedPrices) + . "\nActual: " . implode(PHP_EOL, $actualPrices) . "\n" ); } diff --git a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php index 4570814dc9d2788045ea3ec24d25a6d77dff1e1c..08721cf49238f70c4fdec4f1bf85ea96b1440168 100644 --- a/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php +++ b/dev/tests/functional/tests/app/Magento/CatalogRule/Test/Constraint/AssertCatalogPriceRuleAppliedShoppingCart.php @@ -68,6 +68,8 @@ class AssertCatalogPriceRuleAppliedShoppingCart extends AbstractConstraint $expectedPrices, $actualPrices, 'Wrong total cart prices are displayed.' + . "\nExpected: " . implode(PHP_EOL, $expectedPrices) + . "\nActual: " . implode(PHP_EOL, $actualPrices) . "\n" ); } diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php index 0a8a18ab57e23ad3bd80bef25b2278be5e0ff9e4..cc89afe1e6134e0c02a23079e53a9fe56392b6f6 100644 --- a/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Cms/Test/Block/Adminhtml/Page/Grid.php @@ -102,7 +102,7 @@ class Grid extends DataGrid $rowItem->find($this->selectAction)->click(); $rowItem->find($this->previewCmsPage)->click(); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } } } diff --git a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php index cb70e6143afe7c24d2d7dbcabc1da489b07abb07..62d6c72efe8c6aa8d0a8ed4aff4594316318c9e3 100644 --- a/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php +++ b/dev/tests/functional/tests/app/Magento/ConfigurableProduct/Test/Constraint/AssertConfigurableProductPage.php @@ -41,6 +41,9 @@ class AssertConfigurableProductPage extends AssertProductPage protected function verifyPrice() { $priceBlock = $this->productView->getPriceBlock(); + if (!$priceBlock->isVisible()) { + return "Price block for '{$this->product->getName()}' product' is not visible."; + } $formPrice = $priceBlock->isOldPriceVisible() ? $priceBlock->getOldPrice() : $priceBlock->getPrice(); $fixturePrice = $this->getLowestConfigurablePrice(); diff --git a/dev/tests/functional/tests/app/Magento/PageCache/Test/Block/Cache/Grid.php b/dev/tests/functional/tests/app/Magento/PageCache/Test/Block/Cache/Grid.php index ad67b5fb49acfceb8252c32ff7cf9a38c9173e88..4398f42cb11f28d8907924685a232b58b1177eba 100644 --- a/dev/tests/functional/tests/app/Magento/PageCache/Test/Block/Cache/Grid.php +++ b/dev/tests/functional/tests/app/Magento/PageCache/Test/Block/Cache/Grid.php @@ -26,7 +26,7 @@ class Grid extends ParentGrid if ($selectItem->isVisible()) { $selectItem->click(); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php index 2f5bbe75084c1b609b3df6e01e0f1ca3df4f8f3c..30853af1345ce94fdfe349c2d020193c79cf5a82 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/Block/Adminhtml/Refresh/Statistics/Grid.php @@ -35,7 +35,7 @@ class Grid extends AbstractGrid if ($selectItem->isVisible()) { $selectItem->click(); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } } } diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php index 0f353c38b6f3486bb4742e6be9c2ca5fbc950430..3f45a0541fe7c1eaa4e1d0e0182d67c430c1fd5f 100644 --- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/ViewedProductsReportEntityTest.php @@ -11,6 +11,7 @@ use Magento\Mtf\TestCase\Injectable; use Magento\Mtf\Fixture\FixtureFactory; use Magento\Reports\Test\Page\Adminhtml\ProductReportView; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\Cms\Test\Page\CmsIndex; /** * Preconditions: @@ -62,10 +63,17 @@ class ViewedProductsReportEntityTest extends Injectable * @var CatalogProductIndex */ protected $catalogProductIndexPage; + /** + * Catalog product index page + * + * @var CmsIndex + */ + protected $cmsIndex; /** * Inject pages * + * @param CmsIndex $cmsIndex * @param ProductReportView $productReportView * @param FixtureFactory $fixtureFactory * @param BrowserInterface $browser @@ -73,11 +81,13 @@ class ViewedProductsReportEntityTest extends Injectable * @return void */ public function __inject( + CmsIndex $cmsIndex, ProductReportView $productReportView, FixtureFactory $fixtureFactory, BrowserInterface $browser, CatalogProductIndex $catalogProductIndexPage ) { + $this->cmsIndex = $cmsIndex; $this->productReportView = $productReportView; $this->fixtureFactory = $fixtureFactory; $this->browser = $browser; @@ -140,6 +150,7 @@ class ViewedProductsReportEntityTest extends Injectable foreach ($products as $key => $product) { for ($i = 0; $i < $total[$key]; $i++) { $this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html'); + $this->assertEquals($product->getName(), $this->cmsIndex->getTitleBlock()->getTitle(), 'Could not open product page'); } } } diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php index 00ce972e29fc9c6c8b8812bd536583781dcef0af..0596428fd57f91dc20b9488bd66904b72ec3f084 100644 --- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php +++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/StatusGrid.php @@ -54,7 +54,7 @@ class StatusGrid extends \Magento\Backend\Test\Block\Widget\Grid if ($selectItem->isVisible()) { $selectItem->click(); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } } diff --git a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php index 8fce1bb52b967ca7990bc2c97a9802f335d6fe65..6485de1e81d43519d2d1cff4a50f7d5742b04d7f 100644 --- a/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php +++ b/dev/tests/functional/tests/app/Magento/Ui/Test/Block/Adminhtml/DataGrid.php @@ -234,7 +234,7 @@ class DataGrid extends Grid if ($rowItem->isVisible()) { $this->clickEditLink($rowItem); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } $this->waitLoader(); } @@ -252,7 +252,7 @@ class DataGrid extends Grid if ($rowItem->isVisible()) { $rowItem->find($this->selectItem)->click(); } else { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found by filter\n" . print_r($filter, true)); } $this->waitLoader(); } @@ -354,7 +354,7 @@ class DataGrid extends Grid } } while ($this->nextPage()); if (!$selectItem->isVisible()) { - throw new \Exception('Searched item was not found.'); + throw new \Exception("Searched item was not found\n" . print_r($item, true)); } } }