diff --git a/app/code/Magento/Checkout/Controller/Cart/CouponPost.php b/app/code/Magento/Checkout/Controller/Cart/CouponPost.php index 2b3f65728068b..0498b22d550e7 100644 --- a/app/code/Magento/Checkout/Controller/Cart/CouponPost.php +++ b/app/code/Magento/Checkout/Controller/Cart/CouponPost.php @@ -90,26 +90,17 @@ public function execute() if ($codeLength) { $escaper = $this->_objectManager->get(\Magento\Framework\Escaper::class); + $coupon = $this->couponFactory->create(); + $coupon->load($couponCode, 'code'); if (!$itemsCount) { - if ($isCodeLengthValid) { - $coupon = $this->couponFactory->create(); - $coupon->load($couponCode, 'code'); - if ($coupon->getId()) { - $this->_checkoutSession->getQuote()->setCouponCode($couponCode)->save(); - $this->messageManager->addSuccess( - __( - 'You used coupon code "%1".', - $escaper->escapeHtml($couponCode) - ) - ); - } else { - $this->messageManager->addError( - __( - 'The coupon code "%1" is not valid.', - $escaper->escapeHtml($couponCode) - ) - ); - } + if ($isCodeLengthValid && $coupon->getId()) { + $this->_checkoutSession->getQuote()->setCouponCode($couponCode)->save(); + $this->messageManager->addSuccess( + __( + 'You used coupon code "%1".', + $escaper->escapeHtml($couponCode) + ) + ); } else { $this->messageManager->addError( __( @@ -119,7 +110,7 @@ public function execute() ); } } else { - if ($isCodeLengthValid && $couponCode == $cartQuote->getCouponCode()) { + if ($isCodeLengthValid && $coupon->getId() && $couponCode == $cartQuote->getCouponCode()) { $this->messageManager->addSuccess( __( 'You used coupon code "%1".', diff --git a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php index 16ffb7c2b1437..93100df3d8c32 100644 --- a/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php +++ b/app/code/Magento/Checkout/Test/Unit/Controller/Cart/CouponPostTest.php @@ -69,6 +69,16 @@ class CouponPostTest extends \PHPUnit_Framework_TestCase */ protected $quoteRepository; + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $redirect; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject + */ + private $redirectFactory; + /** * @return void */ @@ -204,6 +214,12 @@ public function testExecuteWithGoodCouponAndItems() ->method('getCouponCode') ->willReturn('OLDCODE'); + $coupon = $this->getMock(\Magento\SalesRule\Model\Coupon::class, [], [], '', false); + $this->couponFactory->expects($this->once()) + ->method('create') + ->willReturn($coupon); + $coupon->expects($this->once())->method('load')->willReturnSelf(); + $coupon->expects($this->once())->method('getId')->willReturn(1); $this->quote->expects($this->any()) ->method('getItemsCount') ->willReturn(1); diff --git a/app/code/Magento/Eav/Model/AttributeManagement.php b/app/code/Magento/Eav/Model/AttributeManagement.php index 8d8674bcca0e7..102aafbd39fb1 100644 --- a/app/code/Magento/Eav/Model/AttributeManagement.php +++ b/app/code/Magento/Eav/Model/AttributeManagement.php @@ -6,10 +6,14 @@ */ namespace Magento\Eav\Model; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Exception\InputException; use Magento\Framework\Exception\NoSuchEntityException; use Magento\Framework\Exception\StateException; +/** + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterface { /** @@ -19,6 +23,7 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa /** * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection + * @deprecated please use instead \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory */ protected $attributeCollection; @@ -47,6 +52,11 @@ class AttributeManagement implements \Magento\Eav\Api\AttributeManagementInterfa */ protected $attributeResource; + /** + * @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory + */ + private $attributeCollectionFactory; + /** * @param \Magento\Eav\Api\AttributeSetRepositoryInterface $setRepository * @param \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $attributeCollection @@ -154,11 +164,26 @@ public function getAttributes($entityType, $attributeSetId) if (!$attributeSet->getAttributeSetId() || $attributeSet->getEntityTypeId() != $requiredEntityTypeId) { throw NoSuchEntityException::singleField('attributeSetId', $attributeSetId); } - - $attributeCollection = $this->attributeCollection - ->setAttributeSetFilter($attributeSet->getAttributeSetId()) - ->load(); + /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $attributeCollection */ + $attributeCollection = $this->getCollectionFactory()->create(); + $attributeCollection->setAttributeSetFilter($attributeSet->getAttributeSetId())->load(); return $attributeCollection->getItems(); } + + /** + * Retrieve collection factory + * + * @deprecated + * @return \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory + */ + private function getCollectionFactory() + { + if ($this->attributeCollectionFactory === null) { + $this->attributeCollectionFactory = ObjectManager::getInstance()->create( + \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory::class + ); + } + return $this->attributeCollectionFactory; + } } diff --git a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php index 88118e0b0f70f..c45c575dffc2f 100644 --- a/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php +++ b/app/code/Magento/Eav/Test/Unit/Model/AttributeManagementTest.php @@ -371,6 +371,24 @@ public function testGetAttributes() $entityType = 'type'; $attributeSetId = 148; + $attributeCollectionFactoryMock = $this->getMock( + \Magento\Eav\Model\ResourceModel\Entity\Attribute\CollectionFactory::class, + ['create'], + [], + '', + false + ); + $attributeCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->attributeCollectionMock); + + $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + $objectManager->setBackwardCompatibleProperty( + $this->model, + 'attributeCollectionFactory', + $attributeCollectionFactoryMock + ); + $attributeSetMock = $this->getMock(\Magento\Eav\Api\Data\AttributeSetInterface::class, [], [], '', false); $this->setRepositoryMock->expects($this->once()) ->method('get') diff --git a/app/code/Magento/Sales/Model/Order/Payment.php b/app/code/Magento/Sales/Model/Order/Payment.php index a0f56d6ea9a73..3cd5ecde21366 100644 --- a/app/code/Magento/Sales/Model/Order/Payment.php +++ b/app/code/Magento/Sales/Model/Order/Payment.php @@ -1289,7 +1289,7 @@ public function getAuthorizationTransaction() */ public function isCaptureFinal($amountToCapture) { - $total = $this->getOrder()->getTotalDue(); + $total = $this->getOrder()->getBaseTotalDue(); return $this->formatAmount($total, true) == $this->formatAmount($amountToCapture, true); } diff --git a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php index f97e3be1dcb6d..7f058b7c05053 100644 --- a/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php +++ b/app/code/Magento/Sales/Test/Unit/Model/Order/PaymentTest.php @@ -1548,7 +1548,7 @@ public function testIsCaptureFinal() $partialAmount = 12.00; $this->orderMock->expects(static::exactly(2)) - ->method('getTotalDue') + ->method('getBaseTotalDue') ->willReturn($amount); static::assertFalse($this->payment->isCaptureFinal($partialAmount)); diff --git a/app/code/Magento/Swatches/Helper/Data.php b/app/code/Magento/Swatches/Helper/Data.php index 68a18ef8be6a1..a973a822c4101 100644 --- a/app/code/Magento/Swatches/Helper/Data.php +++ b/app/code/Magento/Swatches/Helper/Data.php @@ -63,6 +63,13 @@ class Data */ protected $imageHelper; + /** + * Product metadata pool + * + * @var \Magento\Framework\EntityManager\MetadataPool + */ + private $metadataPool; + /** * Data key which should populated to Attribute entity from "additional_data" field * @@ -196,7 +203,13 @@ public function loadVariationByFallback(Product $parentProduct, array $attribute } $productCollection = $this->productCollectionFactory->create(); - $this->addFilterByParent($productCollection, $parentProduct->getId()); + + $productLinkedFiled = $this->getMetadataPool() + ->getMetadata(\Magento\Catalog\Api\Data\ProductInterface::class) + ->getLinkField(); + $parentId = $parentProduct->getData($productLinkedFiled); + + $this->addFilterByParent($productCollection, $parentId); $configurableAttributes = $this->getAttributesFromConfigurable($parentProduct); $allAttributesArray = []; @@ -491,4 +504,19 @@ public function isTextSwatch(Attribute $attribute) } return $attribute->getData(Swatch::SWATCH_INPUT_TYPE_KEY) == Swatch::SWATCH_INPUT_TYPE_TEXT; } + + /** + * Get product metadata pool. + * + * @return \Magento\Framework\EntityManager\MetadataPool + * @deprecared + */ + protected function getMetadataPool() + { + if (!$this->metadataPool) { + $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance() + ->get(\Magento\Framework\EntityManager\MetadataPool::class); + } + return $this->metadataPool; + } } diff --git a/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php b/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php index 6cf79dae309a5..e5f2f887836ef 100644 --- a/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Swatches/Test/Unit/Helper/DataTest.php @@ -46,6 +46,9 @@ class DataTest extends \PHPUnit_Framework_TestCase /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Api\ProductRepositoryInterface */ protected $productRepoMock; + /** @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\EntityManager\MetadataPool*/ + private $metaDataPoolMock; + protected function setUp() { $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); @@ -108,7 +111,13 @@ protected function setUp() '', false ); - + $this->metaDataPoolMock = $this->getMock( + \Magento\Framework\EntityManager\MetadataPool::class, + [], + [], + '', + false + ); $this->swatchHelperObject = $this->objectManager->getObject( \Magento\Swatches\Helper\Data::class, [ @@ -120,6 +129,11 @@ protected function setUp() 'imageHelper' => $this->imageHelperMock, ] ); + $this->objectManager->setBackwardCompatibleProperty( + $this->swatchHelperObject, + 'metadataPool', + $this->metaDataPoolMock + ); } public function dataForAdditionalData() @@ -246,12 +260,16 @@ public function dataForVariationWithSwatchImage() */ public function testLoadVariationByFallback($product) { + $metadataMock = $this->getMock(\Magento\Framework\EntityManager\EntityMetadataInterface::class); + $this->metaDataPoolMock->expects($this->once())->method('getMetadata')->willReturn($metadataMock); + $metadataMock->expects($this->once())->method('getLinkField')->willReturn('id'); + $this->getSwatchAttributes($product); $this->prepareVariationCollection(); $this->productCollectionMock->method('getFirstItem')->willReturn($this->productMock); - $this->productMock->method('getId')->willReturn(95); + $this->productMock->method('getData')->with('id')->willReturn(95); $this->productModelFactoryMock->method('create')->willReturn($this->productMock); $this->productMock->method('load')->with(95)->will($this->returnSelf()); diff --git a/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/ThemeId.php b/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/ThemeId.php index f5197dd7d0435..dc048d41612b8 100644 --- a/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/ThemeId.php +++ b/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/ThemeId.php @@ -10,6 +10,10 @@ */ namespace Magento\Widget\Model\ResourceModel\Widget\Instance\Options; +/** + * @deprecated created new class that correctly loads theme options and whose name follows naming convention + * @see \Magento\Widget\Model\ResourceModel\Widget\Instance\Options\Themes + */ class ThemeId implements \Magento\Framework\Option\ArrayInterface { /** diff --git a/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/Themes.php b/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/Themes.php new file mode 100644 index 0000000000000..403dfeb40ff2e --- /dev/null +++ b/app/code/Magento/Widget/Model/ResourceModel/Widget/Instance/Options/Themes.php @@ -0,0 +1,41 @@ +themeCollectionFactory = $themeCollectionFactory; + } + + /** + * Return array of options as value-label pairs + * + * @return array Format: array('' => '', ...) + */ + public function toOptionArray() + { + // Load only visible themes that are used in frontend area + return $this->themeCollectionFactory->create()->loadRegisteredThemes()->toOptionHash(); + } +} diff --git a/app/code/Magento/Widget/Test/Unit/Model/ResourceModel/Widget/Instance/Options/ThemesTest.php b/app/code/Magento/Widget/Test/Unit/Model/ResourceModel/Widget/Instance/Options/ThemesTest.php new file mode 100644 index 0000000000000..e3854a5990132 --- /dev/null +++ b/app/code/Magento/Widget/Test/Unit/Model/ResourceModel/Widget/Instance/Options/ThemesTest.php @@ -0,0 +1,55 @@ +themeCollectionMock = $this->getMock(ThemeCollection::class, [], [], '', false); + $this->themeCollectionFactoryMock = $this->getMock(ThemeCollectionFactory::class, ['create'], [], '', false); + $this->model = new Themes( + $this->themeCollectionFactoryMock + ); + } + + public function testToOptionArray() + { + $expectedResult = [ + 1 => 'Theme Label', + ]; + $this->themeCollectionFactoryMock->expects($this->once()) + ->method('create') + ->willReturn($this->themeCollectionMock); + + $this->themeCollectionMock->expects($this->once())->method('loadRegisteredThemes')->willReturnSelf(); + $this->themeCollectionMock->expects($this->once())->method('toOptionHash')->willReturn($expectedResult); + + $this->assertEquals($expectedResult, $this->model->toOptionArray()); + } +} diff --git a/app/code/Magento/Widget/view/adminhtml/layout/adminhtml_widget_instance_block.xml b/app/code/Magento/Widget/view/adminhtml/layout/adminhtml_widget_instance_block.xml index 2d9cf935afa0d..db73e302f4a76 100644 --- a/app/code/Magento/Widget/view/adminhtml/layout/adminhtml_widget_instance_block.xml +++ b/app/code/Magento/Widget/view/adminhtml/layout/adminhtml_widget_instance_block.xml @@ -52,7 +52,7 @@ Design Theme theme_id options - + 1 diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout.less index 3804721026db5..d861d4dcae256 100644 --- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout.less +++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/checkout/_checkout.less @@ -23,8 +23,7 @@ & when (@media-common = true) { - .checkout-index-index, - .checkout-onepage-success { + .checkout-index-index { .page-title-wrapper { &:extend(.abs-visually-hidden all); } @@ -61,6 +60,14 @@ margin-left: 0; } } + + .checkout-onepage-success { + &:extend(.abs-add-clearfix all); + + .print { + display: none; + } + } } // @@ -87,4 +94,12 @@ .lib-layout-column(2, 1, @checkout-wrapper__columns); padding-right: @indent__l; } + + .checkout-onepage-success { + .print { + display: block; + float: right; + margin: 22px 0 0; + } + } } diff --git a/app/design/frontend/Magento/blank/Magento_Rma/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Rma/web/css/source/_module.less index a8d0bf8b58482..6596fe2fd7976 100644 --- a/app/design/frontend/Magento/blank/Magento_Rma/web/css/source/_module.less +++ b/app/design/frontend/Magento/blank/Magento_Rma/web/css/source/_module.less @@ -158,11 +158,12 @@ .block-returns-tracking { .block-title { .action { - margin: 12px 0 0 30px; + margin: 0 0 0 30px; + } - &.track { - float: right; - } + .actions-track { + float: right; + margin-top: 12px; } } } diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less index f037c1c5777cb..a1109523d26b5 100644 --- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less +++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/checkout/_checkout.less @@ -27,8 +27,7 @@ & when (@media-common = true) { - .checkout-index-index, - .checkout-onepage-success { + .checkout-index-index { .page-title-wrapper { &:extend(.abs-visually-hidden all); } @@ -66,6 +65,14 @@ margin-left: 0; } } + + .checkout-onepage-success { + &:extend(.abs-add-clearfix all); + + .print { + display: none; + } + } } // @@ -96,4 +103,12 @@ .lib-layout-column(2, 1, @checkout-wrapper__columns); padding-right: @indent__l; } + + .checkout-onepage-success { + .print { + display: block; + float: right; + margin: 23px 0 0; + } + } } diff --git a/app/design/frontend/Magento/luma/Magento_Rma/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Rma/web/css/source/_module.less index cfec28464244e..c7e955e69c3a6 100644 --- a/app/design/frontend/Magento/luma/Magento_Rma/web/css/source/_module.less +++ b/app/design/frontend/Magento/luma/Magento_Rma/web/css/source/_module.less @@ -176,11 +176,12 @@ .block-returns-tracking { .block-title { .action { - margin: 12px 0 0 30px; + margin: 0 0 0 30px; + } - &.track { - float: right; - } + .actions-track { + float: right; + margin-top: 12px; } } } diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php index 54bf06f70b5f1..da1ec8f71a112 100644 --- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php +++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Constraint/AssertAddedProductAttributeOnProductForm.php @@ -13,9 +13,11 @@ use Magento\Catalog\Test\Fixture\CatalogProductAttribute; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductEdit; use Magento\Catalog\Test\Page\Adminhtml\CatalogProductIndex; +use Magento\Mtf\Client\BrowserInterface; /** * Check attribute on product form. + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class AssertAddedProductAttributeOnProductForm extends AbstractConstraint { @@ -45,6 +47,13 @@ class AssertAddedProductAttributeOnProductForm extends AbstractConstraint */ protected $catalogProductEdit; + /** + * Locator for attributes section. + * + * @var string + */ + protected $attributes = '[data-index="attributes"]'; + /** * Add this attribute to Default attribute Template. Create product and Assert that created attribute * is displayed on product form (Products > Inventory > Catalog). @@ -66,6 +75,7 @@ public function processAssert( CatalogProductEdit $catalogProductEdit, CatalogProductAttribute $attribute, CatalogAttributeSet $attributeSet, + BrowserInterface $browser, CatalogProductAttribute $productAttributeOriginal = null ) { $this->fixtureFactory = $fixtureFactory; @@ -92,7 +102,9 @@ public function processAssert( $catalogProductAttribute = ($productAttributeOriginal !== null) ? array_merge($productAttributeOriginal->getData(), $attribute->getData()) : $attribute->getData(); - $catalogProductEdit->getProductForm()->openSection(self::ATTRIBUTES); + if ($browser->find($this->attributes)->isVisible()) { + $catalogProductEdit->getProductForm()->openSection(self::ATTRIBUTES); + } \PHPUnit_Framework_Assert::assertTrue( $catalogProductEdit->getProductForm()->checkAttributeLabel($catalogProductAttribute), diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php index cad6dda904598..ce8f5a4cbfd99 100644 --- a/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php +++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment.php @@ -8,7 +8,6 @@ use Magento\Mtf\Block\Block; use Magento\Mtf\Fixture\InjectableFixture; -use Magento\Payment\Test\Fixture\CreditCard; /** * Checkout payment block. @@ -90,7 +89,12 @@ public function selectPaymentMethod(array $payment, InjectableFixture $creditCar } catch (\Exception $exception) { throw new \Exception('Such payment method is absent.'); } - + $browser = $this->browser; + $browser->waitUntil( + function () use ($browser, $paymentSelector) { + return $browser->find($paymentSelector); + } + ); $paymentRadioButton = $this->_rootElement->find($paymentSelector); if ($paymentRadioButton->isVisible()) { $paymentRadioButton->click(); diff --git a/dev/tests/functional/tests/app/Magento/Tax/Test/Handler/Curl/RemoveTaxRule.php b/dev/tests/functional/tests/app/Magento/Tax/Test/Handler/Curl/RemoveTaxRule.php index 31ca2396f0782..3e69145b42b34 100644 --- a/dev/tests/functional/tests/app/Magento/Tax/Test/Handler/Curl/RemoveTaxRule.php +++ b/dev/tests/functional/tests/app/Magento/Tax/Test/Handler/Curl/RemoveTaxRule.php @@ -39,9 +39,9 @@ class RemoveTaxRule extends Curl public function persist(FixtureInterface $fixture = null) { $this->taxRuleGridUrl = $_ENV['app_backend_url'] . 'tax/rule/index/'; - $curl = $this->_getCurl($this->taxRuleGridUrl); + $curl = $this->getCurl($this->taxRuleGridUrl); $response = $curl->read(); - $this->_removeTaxRules($response); + $this->removeTaxRules($response); $curl->close(); return $response; } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php index 50a5657a47830..2a03872f4be6b 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Block/Adminhtml/Widget/WidgetGrid.php @@ -7,12 +7,20 @@ namespace Magento\Widget\Test\Block\Adminhtml\Widget; use Magento\Backend\Test\Block\Widget\Grid as AbstractGrid; +use Magento\Mtf\Client\Locator; /** * Widget grid on the Widget Instance Index page. */ class WidgetGrid extends AbstractGrid { + /** + * Selector for not empty options at select element. + * + * @var string + */ + private $notEmptyOptionsSelector = 'option:not([value=""])'; + /** * Locator value for link in action column. * @@ -36,5 +44,28 @@ class WidgetGrid extends AbstractGrid 'title' => [ 'selector' => 'input[name="title"]', ], + 'theme_id' => [ + 'selector' => 'select[name="theme_id"]', + 'input' => 'select', + ], ]; + + /** + * Returns values of theme_id filter. + * + * @return array + */ + public function getThemeIdValues() + { + $values = []; + $themeFilter = $this->filters['theme_id']; + $strategy = empty($themeFilter['strategy']) ? Locator::SELECTOR_CSS : $themeFilter['strategy']; + $element = $this->_rootElement->find($themeFilter['selector'], $strategy, $themeFilter['input']); + $options = $element->getElements($this->notEmptyOptionsSelector); + foreach ($options as $option) { + $values[] = $option->getText(); + } + + return $values; + } } diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertThemeFilterValuesOnWidgetGrid.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertThemeFilterValuesOnWidgetGrid.php new file mode 100644 index 0000000000000..31ebfd87c252b --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertThemeFilterValuesOnWidgetGrid.php @@ -0,0 +1,48 @@ +getThemeId(); + } + $widgetInstanceIndex->open(); + $actualValues = $widgetInstanceIndex->getWidgetGrid()->getThemeIdValues(); + \PHPUnit_Framework_Assert::assertEmpty( + array_diff($expectedValues, $actualValues), + 'Widget grid theme filter doesn\'t contain all possible values from created widgets.' + ); + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Widget grid theme filter contains all possible values from created widgets.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetInGrid.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetInGrid.php index 5382d544a94b9..2cc675f79fbd3 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetInGrid.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetInGrid.php @@ -11,7 +11,7 @@ use Magento\Mtf\Constraint\AbstractConstraint; /** - * Class AssertWidgetInGrid + * Assert widget is present in widget grid. */ class AssertWidgetInGrid extends AbstractConstraint { @@ -20,7 +20,10 @@ class AssertWidgetInGrid extends AbstractConstraint /* end tags */ /** - * Assert widget availability in widget grid + * Assert widget availability in widget grid. + * Verifying such fields as: + * - title + * - theme_id * * @param Widget $widget * @param WidgetInstanceIndex $widgetInstanceIndex @@ -28,7 +31,7 @@ class AssertWidgetInGrid extends AbstractConstraint */ public function processAssert(Widget $widget, WidgetInstanceIndex $widgetInstanceIndex) { - $filter = ['title' => $widget->getTitle()]; + $filter = ['title' => $widget->getTitle(), 'theme_id' => $widget->getThemeId()]; $widgetInstanceIndex->open(); \PHPUnit_Framework_Assert::assertTrue( $widgetInstanceIndex->getWidgetGrid()->isRowVisible($filter), @@ -37,7 +40,7 @@ public function processAssert(Widget $widget, WidgetInstanceIndex $widgetInstanc } /** - * Returns a string representation of the object + * Returns a string representation of the object. * * @return string */ diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetsInGrid.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetsInGrid.php new file mode 100644 index 0000000000000..bc61b3ef66f51 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetsInGrid.php @@ -0,0 +1,48 @@ +processAssert($widget, $widgetInstanceIndex); + } + } + + /** + * Returns a string representation of the object. + * + * @return string + */ + public function toString() + { + return 'Widgets are present in widget grid.'; + } +} diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php index 4c9e61cdb873d..54520d0786a52 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Handler/Widget/Curl.php @@ -27,6 +27,7 @@ class Curl extends AbstractCurl protected $mappingData = [ 'code' => [ 'CMS Page Link' => 'cms_page_link', + 'Recently Viewed Products' => 'recently_viewed', ], 'block' => [ 'Main Content Area' => 'content', diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml b/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml index dc39ed7fa1259..4a8972bfd8dbb 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Repository/Widget.xml @@ -25,5 +25,20 @@ cmsPageLink + + + Recently Viewed Products + Title_%isolation% + Magento Blank + + all_store_views + + + for_viewed_products + + + recentlyViewedProducts + + diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetEntityTest.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetEntityTest.php index 6358ac8821f26..cc02293ff8fdd 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetEntityTest.php +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetEntityTest.php @@ -48,7 +48,7 @@ public function test(Widget $widget, array $caches = []) // Preconditions $this->caches = $caches; $this->adjustCacheSettings(); - + // Steps $this->widgetInstanceIndex->open(); $this->widgetInstanceIndex->getPageActionsBlock()->addNew(); diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetsEntityTest.php b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetsEntityTest.php new file mode 100644 index 0000000000000..5269c315f78fc --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetsEntityTest.php @@ -0,0 +1,57 @@ +createByCode('widget', ['dataset' => $widget]); + $widget->persist(); + $widgetInstances[] = $widget; + } + + return ['widgets' => $widgetInstances]; + } + + /** + * Delete all widgets. + * + * @return void + */ + public function tearDown() + { + $this->objectManager->create(\Magento\Widget\Test\TestStep\DeleteAllWidgetsStep::class)->run(); + } +} diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetsEntityTest.xml b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetsEntityTest.xml new file mode 100644 index 0000000000000..484ea26cf5253 --- /dev/null +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/TestCase/CreateWidgetsEntityTest.xml @@ -0,0 +1,18 @@ + + + + + + severity:S3 + default + recently_viewed_products_on_blank_theme + + + + + diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/etc/di.xml b/dev/tests/functional/tests/app/Magento/Widget/Test/etc/di.xml index 122a9659cf2b6..c1595838b4f63 100644 --- a/dev/tests/functional/tests/app/Magento/Widget/Test/etc/di.xml +++ b/dev/tests/functional/tests/app/Magento/Widget/Test/etc/di.xml @@ -66,4 +66,14 @@ S1 + + + S3 + + + + + S3 + + diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php new file mode 100644 index 0000000000000..a6031429c6602 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php @@ -0,0 +1,39 @@ +_objectManager->create(\Magento\Checkout\Model\Session::class); + $quote = $session->getQuote(); + $quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true); + $inputData = [ + 'remove' => 0, + 'coupon_code' => 'test' + ]; + $this->getRequest()->setPostValue($inputData); + $this->dispatch( + 'checkout/cart/couponPost/' + ); + + $this->assertSessionMessages( + $this->equalTo(['The coupon code "test" is not valid.']), + \Magento\Framework\Message\MessageInterface::TYPE_ERROR + ); + } +} diff --git a/dev/tests/integration/testsuite/Magento/Eav/Model/AttributeManagementTest.php b/dev/tests/integration/testsuite/Magento/Eav/Model/AttributeManagementTest.php new file mode 100644 index 0000000000000..82d83938db148 --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Eav/Model/AttributeManagementTest.php @@ -0,0 +1,76 @@ +objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + $this->model = $this->objectManager->create(\Magento\Eav\Api\AttributeManagementInterface::class); + } + + /** + * Verify that collection in service used correctly + */ + public function testGetList() + { + $productAttributeSetId = $this->getAttributeSetId( + \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE + ); + $productAttributes = $this->model->getAttributes( + \Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE, + $productAttributeSetId + ); + // Verify that result contains only product attributes + $this->verifyAttributeSetIds($productAttributes, $productAttributeSetId); + + $categoryAttributeSetId = $this->getAttributeSetId( + \Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE + ); + $categoryAttributes = $this->model->getAttributes( + \Magento\Catalog\Api\Data\CategoryAttributeInterface::ENTITY_TYPE_CODE, + $categoryAttributeSetId + ); + // Verify that result contains only category attributes + $this->verifyAttributeSetIds($categoryAttributes, $categoryAttributeSetId); + } + + /** + * @param string $entityTypeCode + * @return int + */ + private function getAttributeSetId($entityTypeCode) + { + /** @var \Magento\Eav\Model\Config $eavConfig */ + $eavConfig = $this->objectManager->create(\Magento\Eav\Model\Config::class); + return $eavConfig->getEntityType($entityTypeCode)->getDefaultAttributeSetId(); + } + + /** + * @param array $items + * @param string $attributeSetId + * @return void + */ + private function verifyAttributeSetIds(array $items, $attributeSetId) + { + /** @var \Magento\Eav\Model\Entity\Attribute\AbstractAttribute $item */ + foreach ($items as $item) { + $this->assertEquals($attributeSetId, $item->getAttributeSetId()); + } + } +}