diff --git a/app/code/Magento/Ups/Model/Carrier.php b/app/code/Magento/Ups/Model/Carrier.php
index 3fed1210e0c8e..018302bd51fc2 100644
--- a/app/code/Magento/Ups/Model/Carrier.php
+++ b/app/code/Magento/Ups/Model/Carrier.php
@@ -884,7 +884,7 @@ protected function _parseXmlResponse($xmlResponse)
if ($successConversion) {
$costArr[$code] = $cost;
- $priceArr[$code] = $this->getMethodPrice(floatval($cost), $code);
+ $priceArr[$code] = $this->getMethodPrice((float)$cost, $code);
}
}
}
diff --git a/app/code/Magento/Weee/view/frontend/requirejs-config.js b/app/code/Magento/Weee/view/frontend/requirejs-config.js
index 49dfb6b9d469b..94c59da65216d 100644
--- a/app/code/Magento/Weee/view/frontend/requirejs-config.js
+++ b/app/code/Magento/Weee/view/frontend/requirejs-config.js
@@ -6,7 +6,8 @@
var config = {
map: {
'*': {
- 'taxToggle': 'Magento_Weee/tax-toggle'
+ 'taxToggle': 'Magento_Weee/js/tax-toggle',
+ 'Magento_Weee/tax-toggle': 'Magento_Weee/js/tax-toggle'
}
}
};
diff --git a/app/code/Magento/Weee/view/frontend/web/tax-toggle.js b/app/code/Magento/Weee/view/frontend/web/js/tax-toggle.js
similarity index 100%
rename from app/code/Magento/Weee/view/frontend/web/tax-toggle.js
rename to app/code/Magento/Weee/view/frontend/web/js/tax-toggle.js
diff --git a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Image.php b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Image.php
index 02a897d44b3c6..26fb8cd283ec1 100644
--- a/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Image.php
+++ b/app/code/Magento/Wishlist/Block/Customer/Wishlist/Item/Column/Image.php
@@ -3,18 +3,54 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
-/**
- * Wishlist block customer item cart column
- *
- * @author Magento Core Team
- */
namespace Magento\Wishlist\Block\Customer\Wishlist\Item\Column;
+use Magento\Framework\App\ObjectManager;
+use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
+
/**
+ * Wishlist block customer item cart column
+ *
* @api
* @since 100.0.2
*/
class Image extends \Magento\Wishlist\Block\Customer\Wishlist\Item\Column
{
+ /**
+ * @var ItemResolverInterface
+ */
+ private $itemResolver;
+
+ /**
+ * @param \Magento\Catalog\Block\Product\Context $context
+ * @param \Magento\Framework\App\Http\Context $httpContext
+ * @param array|null $data
+ * @param ItemResolverInterface|null $itemResolver
+ */
+ public function __construct(
+ \Magento\Catalog\Block\Product\Context $context,
+ \Magento\Framework\App\Http\Context $httpContext,
+ array $data = [],
+ ItemResolverInterface $itemResolver = null
+ ) {
+ $this->itemResolver = $itemResolver ?: ObjectManager::getInstance()->get(ItemResolverInterface::class);
+ parent::__construct(
+ $context,
+ $httpContext,
+ $data
+ );
+ }
+
+ /**
+ * Identify the product from which thumbnail should be taken.
+ *
+ * @param \Magento\Wishlist\Model\Item $item
+ * @return \Magento\Catalog\Model\Product
+ */
+ public function getProductForThumbnail(\Magento\Wishlist\Model\Item $item): \Magento\Catalog\Model\Product
+ {
+ return $this->itemResolver->getFinalProduct($item);
+ }
}
diff --git a/app/code/Magento/Wishlist/CustomerData/Wishlist.php b/app/code/Magento/Wishlist/CustomerData/Wishlist.php
index d7dd27874d365..84e4857ffeb29 100644
--- a/app/code/Magento/Wishlist/CustomerData/Wishlist.php
+++ b/app/code/Magento/Wishlist/CustomerData/Wishlist.php
@@ -5,8 +5,10 @@
*/
namespace Magento\Wishlist\CustomerData;
+use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
use Magento\Catalog\Model\Product\Image\NotLoadInfoImageException;
use Magento\Customer\CustomerData\SectionSourceInterface;
+use Magento\Framework\App\ObjectManager;
/**
* Wishlist section
@@ -38,22 +40,30 @@ class Wishlist implements SectionSourceInterface
*/
protected $block;
+ /**
+ * @var ItemResolverInterface
+ */
+ private $itemResolver;
+
/**
* @param \Magento\Wishlist\Helper\Data $wishlistHelper
* @param \Magento\Wishlist\Block\Customer\Sidebar $block
* @param \Magento\Catalog\Helper\ImageFactory $imageHelperFactory
* @param \Magento\Framework\App\ViewInterface $view
+ * @param ItemResolverInterface|null $itemResolver
*/
public function __construct(
\Magento\Wishlist\Helper\Data $wishlistHelper,
\Magento\Wishlist\Block\Customer\Sidebar $block,
\Magento\Catalog\Helper\ImageFactory $imageHelperFactory,
- \Magento\Framework\App\ViewInterface $view
+ \Magento\Framework\App\ViewInterface $view,
+ ItemResolverInterface $itemResolver = null
) {
$this->wishlistHelper = $wishlistHelper;
$this->imageHelperFactory = $imageHelperFactory;
$this->block = $block;
$this->view = $view;
+ $this->itemResolver = $itemResolver ?: ObjectManager::getInstance()->get(ItemResolverInterface::class);
}
/**
@@ -122,7 +132,7 @@ protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem)
{
$product = $wishlistItem->getProduct();
return [
- 'image' => $this->getImageData($product),
+ 'image' => $this->getImageData($this->itemResolver->getFinalProduct($wishlistItem)),
'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem),
'product_name' => $product->getName(),
'product_price' => $this->block->getProductPriceHtml(
@@ -147,14 +157,6 @@ protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem)
*/
protected function getImageData($product)
{
- /*Set variant product if it is configurable product.
- It will show variant product image in sidebar instead of configurable product image.*/
- $simpleOption = $product->getCustomOption('simple_product');
- if ($simpleOption !== null) {
- $optionProduct = $simpleOption->getProduct();
- $product = $optionProduct;
- }
-
/** @var \Magento\Catalog\Helper\Image $helper */
$helper = $this->imageHelperFactory->create()
->init($product, 'wishlist_sidebar_block');
diff --git a/app/code/Magento/Wishlist/Helper/Data.php b/app/code/Magento/Wishlist/Helper/Data.php
index 968a7f1db8c39..7eef535382b7f 100644
--- a/app/code/Magento/Wishlist/Helper/Data.php
+++ b/app/code/Magento/Wishlist/Helper/Data.php
@@ -570,7 +570,7 @@ public function calculate()
) {
$count = $collection->getItemsQty();
} else {
- $count = $collection->getSize();
+ $count = $collection->count();
}
$this->_customerSession->setWishlistDisplayType(
$this->scopeConfig->getValue(
diff --git a/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php b/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php
index 225026f31a994..d3b710f229527 100644
--- a/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php
+++ b/app/code/Magento/Wishlist/Model/ResourceModel/Item/Collection.php
@@ -307,6 +307,7 @@ protected function _assignProducts()
$checkInStock = $this->_productInStock && !$this->stockConfiguration->isShowOutOfStock();
+ /** @var \Magento\Wishlist\Model\Item $item */
foreach ($this as $item) {
$product = $productCollection->getItemById($item->getProductId());
if ($product) {
@@ -320,7 +321,7 @@ protected function _assignProducts()
$item->setPrice($product->getPrice());
}
} else {
- $item->isDeleted(true);
+ $this->removeItemByKey($item->getId());
}
}
diff --git a/app/code/Magento/Wishlist/Model/Wishlist.php b/app/code/Magento/Wishlist/Model/Wishlist.php
index 12da947ee3e25..6a5a7c45383f5 100644
--- a/app/code/Magento/Wishlist/Model/Wishlist.php
+++ b/app/code/Magento/Wishlist/Model/Wishlist.php
@@ -582,7 +582,7 @@ public function setStore($store)
*/
public function getItemsCount()
{
- return $this->getItemCollection()->getSize();
+ return $this->getItemCollection()->count();
}
/**
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml
index 3f4c8eb764c1d..b9ea513288c81 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddMultipleStoreProductsToWishlistTest.xml
@@ -76,20 +76,17 @@
-
+
-
-
-
+
-
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontConfigurableProductChildImageShouldBeShownOnWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontConfigurableProductChildImageShouldBeShownOnWishlistTest.xml
new file mode 100644
index 0000000000000..a9804e56a56d7
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontConfigurableProductChildImageShouldBeShownOnWishlistTest.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php b/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php
index 9ecd58b44f0e5..7a7c982ce0497 100644
--- a/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/CustomerData/WishlistTest.php
@@ -8,7 +8,7 @@
use Magento\Catalog\Helper\Image;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Type\AbstractType;
-use Magento\Catalog\Pricing\Price\ConfiguredPriceInterface;
+use Magento\Catalog\Model\Product\Configuration\Item\ItemResolverInterface;
use Magento\Framework\App\ViewInterface;
use Magento\Framework\Pricing\Render;
use Magento\Wishlist\Block\Customer\Sidebar;
@@ -23,21 +23,39 @@
*/
class WishlistTest extends \PHPUnit\Framework\TestCase
{
- /** @var Wishlist */
- protected $model;
+ /**
+ * @var Wishlist
+ */
+ private $model;
+
+ /**
+ * @var Data|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $wishlistHelperMock;
- /** @var Data|\PHPUnit_Framework_MockObject_MockObject */
- protected $wishlistHelperMock;
+ /**
+ * @var Sidebar|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $sidebarMock;
- /** @var Sidebar|\PHPUnit_Framework_MockObject_MockObject */
- protected $sidebarMock;
+ /**
+ * @var Image|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $catalogImageHelperMock;
- /** @var Image|\PHPUnit_Framework_MockObject_MockObject */
- protected $catalogImageHelperMock;
+ /**
+ * @var ViewInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $viewMock;
- /** @var ViewInterface|\PHPUnit_Framework_MockObject_MockObject */
- protected $viewMock;
+ /**
+ * @var \Magento\Catalog\Block\Product\ImageBuilder|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $itemResolver;
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
$this->wishlistHelperMock = $this->getMockBuilder(\Magento\Wishlist\Helper\Data::class)
@@ -60,11 +78,14 @@ protected function setUp()
->method('create')
->willReturn($this->catalogImageHelperMock);
+ $this->itemResolver = $this->createMock(ItemResolverInterface::class);
+
$this->model = new Wishlist(
$this->wishlistHelperMock,
$this->sidebarMock,
$imageHelperFactory,
- $this->viewMock
+ $this->viewMock,
+ $this->itemResolver
);
}
@@ -158,6 +179,10 @@ public function testGetSectionData()
->method('getProduct')
->willReturn($productMock);
+ $this->itemResolver->expects($this->once())
+ ->method('getFinalProduct')
+ ->willReturn($productMock);
+
$this->catalogImageHelperMock->expects($this->once())
->method('init')
->with($productMock, 'wishlist_sidebar_block', [])
@@ -343,6 +368,10 @@ public function testGetSectionDataWithTwoItems()
->method('getProduct')
->willReturn($productMock);
+ $this->itemResolver->expects($this->exactly(2))
+ ->method('getFinalProduct')
+ ->willReturn($productMock);
+
$this->catalogImageHelperMock->expects($this->exactly(2))
->method('init')
->with($productMock, 'wishlist_sidebar_block', [])
diff --git a/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml b/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml
index 1008f5f377df5..2eb4664991e99 100644
--- a/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml
+++ b/app/code/Magento/Wishlist/view/frontend/templates/item/column/image.phtml
@@ -13,5 +13,5 @@ $item = $block->getItem();
$product = $item->getProduct();
?>
- = $block->getImage($product, 'wishlist_thumbnail')->toHtml() ?>
+ = $block->getImage($block->getProductForThumbnail($item), 'wishlist_thumbnail')->toHtml() ?>
diff --git a/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml b/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml
index 00fb87b411fe0..84b607adb6362 100644
--- a/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml
+++ b/app/code/Magento/Wishlist/view/frontend/templates/sidebar.phtml
@@ -31,7 +31,7 @@ $wishlistHelper = $this->helper('Magento\Wishlist\Helper\Data');
-
+
diff --git a/app/design/adminhtml/Magento/backend/Magento_Backend/layout/default.xml b/app/design/adminhtml/Magento/backend/Magento_Backend/layout/default.xml
index da16bde107673..337d63369b160 100644
--- a/app/design/adminhtml/Magento/backend/Magento_Backend/layout/default.xml
+++ b/app/design/adminhtml/Magento/backend/Magento_Backend/layout/default.xml
@@ -7,6 +7,7 @@
-->
+
diff --git a/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less b/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less
index 59675de698787..6dbef05ea2389 100644
--- a/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less
+++ b/app/design/adminhtml/Magento/backend/web/css/source/forms/_fields.less
@@ -183,10 +183,13 @@
.admin__field-label {
color: @field-label__color;
- cursor: pointer;
margin: 0;
text-align: right;
+ label {
+ cursor: pointer;
+ }
+
+ br {
display: none;
}
@@ -207,7 +210,7 @@
overflow: hidden;
}
- span {
+ label {
display: inline-block;
line-height: @field-label__line-height;
vertical-align: middle;
@@ -225,7 +228,7 @@
.required > &, // ToDo UI: change classes 'required' to '_required'.
._required > & {
- > span {
+ > label {
&:after {
color: @validation__color;
content: '*';
@@ -512,7 +515,7 @@
position: absolute;
top: 0;
- span {
+ label {
&:before {
display: block;
}
@@ -527,7 +530,7 @@
}
& > .admin__field-label {
- span {
+ label {
&:before {
display: none;
}
diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_cart.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_cart.less
index bb14a3c2521b0..d3d15019f0e87 100644
--- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_cart.less
+++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_cart.less
@@ -305,7 +305,7 @@
white-space: nowrap;
width: 33%;
- &:before {
+ &[data-th]:before {
content: attr(data-th) ':';
display: block;
font-weight: @font-weight__bold;
diff --git a/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/_email.less b/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/_email.less
index 84adec39c8892..215d7d8b322b4 100644
--- a/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/_email.less
+++ b/app/design/frontend/Magento/blank/Magento_Sales/web/css/source/_email.less
@@ -203,7 +203,8 @@
text-align: center;
}
- .item-price {
+ .item-price,
+ .item-subtotal {
text-align: right;
}
diff --git a/app/design/frontend/Magento/blank/web/css/source/_email-base.less b/app/design/frontend/Magento/blank/web/css/source/_email-base.less
index 29f6fd0dcbcfc..f9b779d761576 100644
--- a/app/design/frontend/Magento/blank/web/css/source/_email-base.less
+++ b/app/design/frontend/Magento/blank/web/css/source/_email-base.less
@@ -160,8 +160,8 @@ body {
.main {
margin: 0 auto;
+ max-width: @email-body__width;
text-align: left; // Necessary to prevent all text from centering in Outlook 2003
- width: @email-body__width;
}
.header {
diff --git a/app/design/frontend/Magento/blank/web/css/source/_extends.less b/app/design/frontend/Magento/blank/web/css/source/_extends.less
index c177f91e9e7e8..6df78859a1a80 100644
--- a/app/design/frontend/Magento/blank/web/css/source/_extends.less
+++ b/app/design/frontend/Magento/blank/web/css/source/_extends.less
@@ -846,7 +846,7 @@
white-space: nowrap;
width: 33%;
- &:before {
+ &[data-th]:before {
content: attr(data-th) ':';
display: block;
font-weight: @font-weight__bold;
diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_cart.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_cart.less
index 4b8db9202b195..10b917635bd40 100644
--- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_cart.less
+++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_cart.less
@@ -464,7 +464,7 @@
white-space: nowrap;
width: 33%;
- &:before {
+ &[data-th]:before {
content: attr(data-th);
display: block;
font-weight: @font-weight__semibold;
diff --git a/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_email.less b/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_email.less
index 9a3f433618c36..3f19d1020bab9 100644
--- a/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_email.less
+++ b/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_email.less
@@ -207,7 +207,8 @@
text-align: center;
}
- .item-price {
+ .item-price,
+ .item-subtotal {
text-align: right;
}
diff --git a/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_module.less
index 692f91ef463b1..a0f734b05cbd1 100644
--- a/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Sales/web/css/source/_module.less
@@ -482,7 +482,7 @@
.options-label + .item-options-container,
.item-options-container + .item-options-container {
- &:before {
+ &[data-th]:before {
content: attr(data-th) ':';
display: block;
font-weight: @font-weight__bold;
diff --git a/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less
index edb096360b5e0..dee6f8e09fc76 100644
--- a/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Theme/web/css/source/_module.less
@@ -435,6 +435,17 @@
}
}
+//
+// Mobile
+// _____________________________________________
+
+.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
+ .cms-page-view .page-main {
+ padding-top: 41px;
+ position: relative;
+ }
+}
+
//
// Desktop
// _____________________________________________
diff --git a/app/design/frontend/Magento/luma/web/css/source/_extends.less b/app/design/frontend/Magento/luma/web/css/source/_extends.less
index 760ec9ed861a9..8d1ce2b2f896e 100644
--- a/app/design/frontend/Magento/luma/web/css/source/_extends.less
+++ b/app/design/frontend/Magento/luma/web/css/source/_extends.less
@@ -3,6 +3,8 @@
// * See COPYING.txt for license details.
// */
+@_column-number: 1;
+
//
// List default styles reset
// ---------------------------------------------
@@ -705,7 +707,7 @@
// ---------------------------------------------
@abs-form-field-revert-column-1: {
- .lib-form-field-column-number(@_column-number: 1);
+ .lib-form-field-column-number(@_column-number);
};
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
@@ -760,7 +762,7 @@
white-space: nowrap;
width: 33%;
- &:before {
+ &[data-th]:before {
content: attr(data-th) ':';
display: block;
font-weight: @font-weight__bold;
diff --git a/dev/tests/acceptance/tests/_data/lorem_ipsum.docx b/dev/tests/acceptance/tests/_data/lorem_ipsum.docx
new file mode 100644
index 0000000000000..488f64e86b6ff
Binary files /dev/null and b/dev/tests/acceptance/tests/_data/lorem_ipsum.docx differ
diff --git a/dev/tests/acceptance/tests/_data/lorem_ipsum.txt b/dev/tests/acceptance/tests/_data/lorem_ipsum.txt
new file mode 100644
index 0000000000000..64cb8d023361a
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/lorem_ipsum.txt
@@ -0,0 +1,9 @@
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc venenatis cursus eros, eu congue risus eleifend ut. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean aliquet mi diam, at consequat ex imperdiet eu. Nullam vulputate sollicitudin libero, tristique ullamcorper ante pretium eget. Nunc vehicula, risus ut hendrerit ornare, tortor est mattis urna, vitae egestas arcu tellus quis est. Sed mollis est sem. Aenean rhoncus ultricies sapien, id tempus elit lobortis ac. Pellentesque condimentum gravida purus a pretium. Nulla sed sapien mattis, auctor lacus quis, volutpat metus. Nunc mattis diam elit, viverra tincidunt nisl faucibus eu. Duis ac nisl tellus. Aenean eros lectus, malesuada in ex non, pharetra aliquam odio. Aenean ultricies pharetra mauris, ac rutrum quam posuere at. Phasellus et tempor turpis, ut sodales turpis. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
+
+Sed fringilla orci at elit gravida, posuere varius elit eleifend. Nam libero dui, rutrum ac massa et, dictum egestas massa. Fusce rutrum, neque vitae vestibulum mattis, magna orci dictum turpis, ut laoreet eros urna lacinia ipsum. Donec eget ultrices eros. Duis sollicitudin ante est. Maecenas semper pellentesque scelerisque. Vestibulum eu venenatis tellus. Etiam nec massa sem. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Etiam blandit molestie justo, non euismod dolor aliquet ac. Duis consectetur enim in arcu suscipit, in tempus nisi commodo.
+
+Donec sed venenatis nunc. Proin velit leo, porta eget erat elementum, dapibus posuere odio. Nam varius lectus eu cursus tristique. Ut tempus libero vehicula, iaculis augue sit amet, vestibulum justo. Vivamus porta diam vitae malesuada vestibulum. Donec mi dolor, semper at rutrum eget, vehicula non orci. Nunc dolor urna, laoreet et egestas vitae, sodales quis ipsum. Vivamus aliquet viverra enim cursus tincidunt. Pellentesque vel laoreet mi. Aenean ut rhoncus orci. Donec a purus venenatis, tempor dolor in, facilisis ex. Sed nec metus convallis, viverra nisl nec, luctus arcu. Integer blandit arcu a est posuere pharetra.
+
+Aliquam ultricies lectus ac mauris luctus, a viverra neque rhoncus. Vestibulum id velit eu nisl efficitur lobortis. Sed id metus at ipsum imperdiet porta. Quisque in quam in turpis fermentum condimentum. Phasellus sagittis risus eu tempus scelerisque. Vivamus dapibus sem odio, vitae fermentum sem viverra et. Quisque sit amet cursus neque, vel hendrerit risus. Integer ut diam porta, volutpat risus in, iaculis diam. Suspendisse vulputate non quam et finibus.
+
+Donec blandit, sem ut posuere dignissim, dolor lorem egestas magna, vel faucibus dui metus eget orci. Nullam ipsum lacus, imperdiet at nisl sed, condimentum dignissim lectus. Nunc orci libero, tincidunt a molestie vel, dapibus at mi. Quisque scelerisque sem quis massa suscipit, sit amet suscipit arcu volutpat. In tincidunt lacus in porttitor mattis. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Morbi rutrum gravida orci quis porta.
\ No newline at end of file
diff --git a/dev/tests/acceptance/tests/_data/magento-again.jpg b/dev/tests/acceptance/tests/_data/magento-again.jpg
new file mode 100644
index 0000000000000..c377daf8fb0b3
Binary files /dev/null and b/dev/tests/acceptance/tests/_data/magento-again.jpg differ
diff --git a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertDeviceDataIsPresentInBraintreeRequest.php b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertDeviceDataIsPresentInBraintreeRequest.php
index 7eb53d728b079..40ae920a6bbde 100644
--- a/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertDeviceDataIsPresentInBraintreeRequest.php
+++ b/dev/tests/functional/tests/app/Magento/Braintree/Test/Constraint/AssertDeviceDataIsPresentInBraintreeRequest.php
@@ -17,7 +17,7 @@ class AssertDeviceDataIsPresentInBraintreeRequest extends AbstractConstraint
/**
* Log file name.
*/
- const FILE_NAME = 'debug.log';
+ const FILE_NAME = 'payment.log';
/**
* Device data pattern for regular expression.
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php
index 9331c2c987549..61142adc8f9b3 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.php
@@ -28,7 +28,7 @@ class ProductForm extends FormSections
*
* @var string
*/
- protected $attribute = './/*[contains(@class,"label")]/span[text()="%s"]';
+ protected $attribute = './/*[contains(@class,"label")]/label[text()="%s"]';
/**
* Product new from date field on the product form
diff --git a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php
index 72a3b2b5f68d1..610387d9a39eb 100644
--- a/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php
+++ b/dev/tests/functional/tests/app/Magento/Reports/Test/TestCase/AbandonedCartsReportEntityTest.php
@@ -34,7 +34,7 @@ class AbandonedCartsReportEntityTest extends Injectable
{
/* tags */
const MVP = 'no';
- const STABLE = 'no';
+ const STABLE = 'yes';
/* end tags */
/**
diff --git a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml
index 02fcf3b19fbde..66ae1d8179af5 100644
--- a/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Store/Test/TestCase/DeleteStoreGroupEntityTest.xml
@@ -8,7 +8,7 @@
- severity:S3, stable:no
+ severity:S3
custom
Yes
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AbstractAssertWishlistProductDetails.php b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AbstractAssertWishlistProductDetails.php
index ba9fe67b5eb4c..2df4cc3078370 100644
--- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AbstractAssertWishlistProductDetails.php
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/Constraint/AbstractAssertWishlistProductDetails.php
@@ -16,6 +16,11 @@
*/
abstract class AbstractAssertWishlistProductDetails extends AbstractAssertForm
{
+ /**
+ * @inheritdoc
+ */
+ protected $skippedFields = ['sku'];
+
/**
* Assert product details.
*
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.xml
index fd80d385e4853..95e6a854ed266 100644
--- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/MoveProductFromShoppingCartToWishlistTest.xml
@@ -37,7 +37,6 @@
- stable:no
bundleProduct::bundle_dynamic_product
@@ -45,7 +44,6 @@
- stable:no
bundleProduct::bundle_fixed_product
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/CacheTest.php b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/CacheTest.php
index 0525c68b04d14..1b97fb2ad510c 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/CacheTest.php
+++ b/dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/CacheTest.php
@@ -72,7 +72,7 @@ public function testMassActionsInvalidTypes($action)
$this->getRequest()->setParams(['types' => ['invalid_type_1', 'invalid_type_2', 'config']]);
$this->dispatch('backend/admin/cache/' . $action);
$this->assertSessionMessages(
- $this->contains("Specified cache type(s) don't exist: invalid_type_1, invalid_type_2"),
+ $this->contains("Specified cache type(s) don't exist: invalid_type_1, invalid_type_2"),
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php
new file mode 100644
index 0000000000000..8476542c8f054
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Controller/Adminhtml/Invoice/CreateTest.php
@@ -0,0 +1,149 @@
+getMockBuilder(BraintreeAdapterFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->adapter = $this->getMockBuilder(BraintreeAdapter::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $adapterFactory->method('create')
+ ->willReturn($this->adapter);
+
+ $this->_objectManager->addSharedInstance($adapterFactory, BraintreeAdapterFactory::class);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ $this->_objectManager->removeSharedInstance(BraintreeAdapterFactory::class);
+ parent::tearDown();
+ }
+
+ /**
+ * Checks a case when non default Merchant Account ID should be send to Braintree
+ * during creation second partial invoice.
+ *
+ * @magentoConfigFixture default_store payment/braintree/merchant_account_id Magneto
+ * @magentoConfigFixture current_store payment/braintree/merchant_account_id USA_Merchant
+ * @magentoDataFixture Magento/Braintree/Fixtures/partial_invoice.php
+ */
+ public function testCreatePartialInvoiceWithNonDefaultMerchantAccount()
+ {
+ $order = $this->getOrder('100000002');
+
+ $this->adapter->method('sale')
+ ->with(self::callback(function ($request) {
+ self::assertEquals('USA_Merchant', $request['merchantAccountId']);
+ return true;
+ }))
+ ->willReturn($this->getTransactionStub());
+
+ $uri = 'backend/sales/order_invoice/save/order_id/' . $order->getEntityId();
+ $this->prepareRequest($uri);
+ $this->dispatch($uri);
+
+ self::assertSessionMessages(
+ self::equalTo(['The invoice has been created.']),
+ MessageInterface::TYPE_SUCCESS
+ );
+ }
+
+ /**
+ * Creates stub for Braintree capture Transaction.
+ *
+ * @return Successful
+ */
+ private function getTransactionStub(): Successful
+ {
+ $transaction = $this->getMockBuilder(Transaction::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $transaction->status = 'submitted_for_settlement';
+ $response = new Successful();
+ $response->success = true;
+ $response->transaction = $transaction;
+
+ return $response;
+ }
+
+ /**
+ * Gets order by increment ID.
+ *
+ * @param string $incrementId
+ * @return OrderInterface
+ */
+ private function getOrder(string $incrementId): OrderInterface
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('increment_id', $incrementId)
+ ->create();
+
+ /** @var OrderRepositoryInterface $repository */
+ $repository = $this->_objectManager->get(OrderRepositoryInterface::class);
+ $items = $repository->getList($searchCriteria)
+ ->getItems();
+
+ return array_pop($items);
+ }
+
+ /**
+ * Prepares POST request for invoice creation.
+ *
+ * @param string $uri
+ */
+ private function prepareRequest(string $uri)
+ {
+ /** @var FormKey $formKey */
+ $formKey = $this->_objectManager->get(FormKey::class);
+ $request = $this->getRequest();
+ $request->setMethod('POST');
+ $request->setParam('form_key', $formKey->getFormKey());
+ $request->setRequestUri($uri);
+ $request->setPostValue(
+ [
+ 'invoice' => [
+ 'capture_case' => 'online'
+ ]
+ ]
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/order.php b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/order.php
new file mode 100644
index 0000000000000..ceb90710ed5e7
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/order.php
@@ -0,0 +1,57 @@
+create(Address::class, ['data' => $addressData]);
+$billingAddress->setAddressType('billing');
+
+$shippingAddress = clone $billingAddress;
+$shippingAddress->setId(null)
+ ->setAddressType('shipping');
+
+/** @var OrderItem $orderItem */
+$orderItem = $objectManager->create(OrderItem::class);
+$orderItem->setProductId($product->getId())
+ ->setQtyOrdered(2)
+ ->setBasePrice($product->getPrice())
+ ->setPrice($product->getPrice())
+ ->setRowTotal($product->getPrice())
+ ->setProductType('simple');
+
+require __DIR__ . '/payment.php';
+
+$order = $objectManager->create(Order::class);
+$order->setIncrementId('100000002')
+ ->setSubtotal($product->getPrice() * 2)
+ ->setBaseSubtotal($product->getPrice() * 2)
+ ->setCustomerEmail('admin@example.com')
+ ->setCustomerIsGuest(true)
+ ->setBillingAddress($billingAddress)
+ ->setShippingAddress($shippingAddress)
+ ->setStoreId(
+ $objectManager->get(StoreManagerInterface::class)->getStore()
+ ->getId()
+ )
+ ->addItem($orderItem)
+ ->setPayment($payment);
+
+/** @var OrderRepositoryInterface $orderRepository */
+$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
+$orderRepository->save($order);
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/order_rollback.php b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/order_rollback.php
new file mode 100644
index 0000000000000..a2da0b639e98d
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/order_rollback.php
@@ -0,0 +1,28 @@
+get(SearchCriteriaBuilder::class);
+$searchCriteria = $searchCriteriaBuilder->addFilter('increment_id', '100000002')
+ ->create();
+
+/** @var OrderRepositoryInterface $orderRepository */
+$orderRepository = $objectManager->get(OrderRepositoryInterface::class);
+$items = $orderRepository->getList($searchCriteria)
+ ->getItems();
+
+foreach ($items as $item) {
+ $orderRepository->delete($item);
+}
+
+require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_rollback.php';
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/partial_invoice.php b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/partial_invoice.php
new file mode 100644
index 0000000000000..22b954515f3b5
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/partial_invoice.php
@@ -0,0 +1,47 @@
+get(InvoiceService::class);
+$invoice = $invoiceService->prepareInvoice($order);
+$invoice->setIncrementId('100000002');
+$invoice->register();
+
+$items = $invoice->getAllItems();
+$item = array_pop($items);
+$item->setQty(1);
+$invoice->setTotalQty(1);
+
+$items = $order->getAllItems();
+/** @var \Magento\Sales\Api\Data\OrderItemInterface $item */
+$item = array_pop($items);
+$item->setQtyInvoiced(1);
+$invoice->collectTotals();
+
+/** @var InvoiceRepositoryInterface $invoiceRepository */
+$invoiceRepository = $objectManager->get(InvoiceRepositoryInterface::class);
+$invoice = $invoiceRepository->save($invoice);
+
+/** @var TransactionRepositoryInterface $transactionRepository */
+$transactionRepository = $objectManager->get(TransactionRepositoryInterface::class);
+$transaction = $transactionRepository->create();
+$transaction->setTxnType('capture');
+$transaction->setPaymentId($order->getPayment()->getEntityId());
+$transaction->setOrderId($order->getEntityId());
+$transactionRepository->save($transaction);
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/partial_invoice_rollback.php b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/partial_invoice_rollback.php
new file mode 100644
index 0000000000000..1ed4438f87db2
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/partial_invoice_rollback.php
@@ -0,0 +1,28 @@
+get(SearchCriteriaBuilder::class);
+$searchCriteria = $searchCriteriaBuilder->addFilter('increment_id', '%10000000%', 'like')
+ ->create();
+
+/** @var InvoiceRepositoryInterface $invoiceRepository */
+$invoiceRepository = $objectManager->get(InvoiceRepositoryInterface::class);
+$items = $invoiceRepository->getList($searchCriteria)
+ ->getItems();
+
+foreach ($items as $item) {
+ $invoiceRepository->delete($item);
+}
+
+require __DIR__ . '/order_rollback.php';
diff --git a/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/payment.php b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/payment.php
new file mode 100644
index 0000000000000..a4285b963bffa
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Braintree/Fixtures/payment.php
@@ -0,0 +1,29 @@
+setPaymentMethodCode(ConfigProvider::CODE);
+/** @var OrderPaymentExtensionInterfaceFactory $paymentExtensionFactory */
+$paymentExtensionFactory = $objectManager->get(OrderPaymentExtensionInterfaceFactory::class);
+$extensionAttributes = $paymentExtensionFactory->create();
+$extensionAttributes->setVaultPaymentToken($token);
+
+/** @var Payment $payment */
+$payment = $objectManager->create(Payment::class);
+$payment->setMethod(ConfigProvider::CODE);
+$payment->setExtensionAttributes($extensionAttributes);
+$payment->setAuthorizationTransaction(true);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
new file mode 100644
index 0000000000000..c97dc821913f9
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
@@ -0,0 +1,50 @@
+objectManager = Bootstrap::getObjectManager();
+ }
+ /**
+ * Tests rendered gallery block.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ * @magentoAppArea frontend
+ */
+ public function testHtml()
+ {
+ /** @var ProductRepositoryInterface $productRepository */
+ $productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ /** @var ProductInterface $product */
+ $product = $productRepository->get('simple');
+ /** @var LayoutInterface $layout */
+ $layout = $this->objectManager->get(LayoutInterface::class);
+ /** @var Gallery $block */
+ $block = $layout->createBlock(Gallery::class);
+ $block->setData('product', $product);
+ $block->setTemplate("Magento_Catalog::product/view/gallery.phtml");
+
+ $showCaption = $block->getVar('gallery/caption');
+
+ self::assertContains('"showCaption": ' . $showCaption, $block->toHtml());
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductGettersTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductGettersTest.php
index 6ea7c19dce91e..1ed0057ca2486 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductGettersTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductGettersTest.php
@@ -217,7 +217,7 @@ public function testGetAttributeTextArray()
$expected = [
'Option 2',
'Option 3',
- 'Option 4 "!@#$%^&*'
+ 'Option 4 "!@#$%^&*'
];
self::assertEquals(
$expected,
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php
index 562dd35a2338a..62a918b7e3c5a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php
@@ -550,6 +550,9 @@ public function testGetOptions()
'4-2-radio' => 40000.00
];
foreach ($options as $option) {
+ if (!$option->getValues()) {
+ continue;
+ }
foreach ($option->getValues() as $value) {
$this->assertEquals($expectedValue[$value->getSku()], floatval($value->getPrice()));
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_apostrophe.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_apostrophe.php
index 4da1519c0366a..dda5c80137f61 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_apostrophe.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_apostrophe.php
@@ -8,8 +8,11 @@
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$categoryFirst = $objectManager->create(\Magento\Catalog\Model\Category::class);
-$categoryFirst->setName('Category 1')
- ->setPath('1/2')
+$categoryFirst->isObjectNew(true);
+$categoryFirst->setId(523)
+ ->setName('Parent Apostrophe Category')
+ ->setParentId(2)
+ ->setPath('1/2/523')
->setLevel(2)
->setAvailableSortBy('name')
->setDefaultSortBy('name')
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes.php
index ccf91282ab1f6..8f4add8144859 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes.php
@@ -8,8 +8,11 @@
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$categoryFirst = $objectManager->create(\Magento\Catalog\Model\Category::class);
-$categoryFirst->setName('Category 1')
- ->setPath('1/2')
+$categoryFirst->isObjectNew(true);
+$categoryFirst->setId(523)
+ ->setName('Parent Doublequotes Category')
+ ->setParentId(2)
+ ->setPath('1/2/523')
->setLevel(2)
->setAvailableSortBy('name')
->setDefaultSortBy('name')
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes_rollback.php
new file mode 100644
index 0000000000000..134f3d844e00b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/catalog_category_with_doublequotes_rollback.php
@@ -0,0 +1,26 @@
+get(\Magento\Framework\Registry::class);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var \Magento\Catalog\Model\ResourceModel\Product\Collection $collection */
+$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+$collection
+ ->addAttributeToFilter('level', 2)
+ ->load()
+ ->delete();
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php
index 059b784978a22..61b549f7729d1 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_options.php
@@ -86,7 +86,18 @@
'sku' => '4-2-radio',
],
]
- ]
+ ],
+ [
+ 'previous_group' => 'text',
+ 'title' => 'Test Field',
+ 'type' => 'field',
+ 'is_require' => 1,
+ 'sort_order' => 0,
+ 'price' => 1,
+ 'price_type' => 'fixed',
+ 'sku' => '1-text',
+ 'max_characters' => 100,
+ ],
];
$options = [];
diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key.php
new file mode 100644
index 0000000000000..cae23dcc9c674
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key.php
@@ -0,0 +1,30 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+require __DIR__ . '/../_files/product_with_category.php';
+
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = $objectManager->get(ProductRepositoryInterface::class);
+$product->setStoreId(1);
+$product->setUrlKey('store-1-key');
+$product = $productRepository->save($product);
+$linkManagement->assignProductToCategories($product->getSku(), [Category::TREE_ROOT_ID, $category->getEntityId()]);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key_rollback.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key_rollback.php
new file mode 100644
index 0000000000000..517e9121a6d1e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key_rollback.php
@@ -0,0 +1,21 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+require __DIR__ . '/../_files/product_with_category_rollback.php';
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandlerTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandlerTest.php
new file mode 100644
index 0000000000000..402db06a0bbc9
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Observer/UrlRewriteHandlerTest.php
@@ -0,0 +1,111 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->handler = $this->objectManager->get(UrlRewriteHandler::class);
+ }
+
+ /**
+ * Checks category URLs rewrites generation with enabled `Use Categories Path for Product URLs` option and
+ * store's specific product URL key.
+ *
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/CatalogUrlRewrite/Fixtures/product_custom_url_key.php
+ * @magentoConfigFixture admin_store catalog/seo/product_use_categories 1
+ */
+ public function testGenerateProductUrlRewrites()
+ {
+ $product = $this->getProduct('p002');
+ $category = $this->getCategory('category 1');
+ // change the category scope to the global
+ $category->setStoreId(0)
+ ->setChangedProductIds([$product->getId()])
+ ->setAffectedProductIds([$product->getId()])
+ ->setAnchorsAbove(false);
+
+ $generatedUrls = $this->handler->generateProductUrlRewrites($category);
+ $actual = array_values(array_map(function (UrlRewrite $urlRewrite) {
+ return $urlRewrite->getRequestPath();
+ }, $generatedUrls));
+
+ $expected = [
+ 'store-1-key.html', // the Default store
+ 'cat-1/store-1-key.html', // the Default store with Category URL key
+ '/store-1-key.html', // an anchor URL the Default store
+ 'p002.html', // the Secondary store
+ 'cat-1-2/p002.html', // the Secondary store with Category URL key
+ '/p002.html', // an anchor URL the Secondary store
+ ];
+ self::assertEquals($expected, $actual, 'Generated URLs rewrites do not match.');
+ }
+
+ /**
+ * Gets category by name.
+ *
+ * @param string $name
+ * @return CategoryInterface
+ */
+ private function getCategory(string $name): CategoryInterface
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
+ ->create();
+ /** @var CategoryListInterface $repository */
+ $repository = $this->objectManager->get(CategoryListInterface::class);
+ $items = $repository->getList($searchCriteria)
+ ->getItems();
+
+ return array_pop($items);
+ }
+
+ /**
+ * Gets product by SKU.
+ *
+ * @param string $sku
+ * @return ProductInterface
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
+ */
+ private function getProduct(string $sku): ProductInterface
+ {
+ /** @var ProductRepositoryInterface $productRepository */
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ return $productRepository->get($sku);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/_files/product_with_category.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/_files/product_with_category.php
index 236a80a3e66f9..4c55bf47484b6 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/_files/product_with_category.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/_files/product_with_category.php
@@ -65,7 +65,7 @@
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
-$productRepository->save($product);
+$product = $productRepository->save($product);
/** @var CategoryLinkManagementInterface $linkManagement */
$linkManagement = $objectManager->get(CategoryLinkManagementInterface::class);
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php
index 67874d9f3974a..068a9c3529c15 100644
--- a/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php
+++ b/dev/tests/integration/testsuite/Magento/Checkout/Controller/CartTest.php
@@ -11,8 +11,12 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Checkout\Model\Session;
+use Magento\Checkout\Model\Session as CheckoutSession;
use Magento\Customer\Model\ResourceModel\CustomerRepository;
use Magento\Framework\Data\Form\FormKey;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Quote\Model\Quote;
+use Magento\Quote\Api\CartRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Request;
use Magento\Customer\Model\Session as CustomerSession;
@@ -25,6 +29,28 @@
*/
class CartTest extends \Magento\TestFramework\TestCase\AbstractController
{
+ /** @var CheckoutSession */
+ private $checkoutSession;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->checkoutSession = $this->_objectManager->get(CheckoutSession::class);
+ $this->_objectManager->addSharedInstance($this->checkoutSession, CheckoutSession::class);
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ $this->_objectManager->removeSharedInstance(CheckoutSession::class);
+ parent::tearDown();
+ }
+
/**
* Test for \Magento\Checkout\Controller\Cart::configureAction() with simple product
*
@@ -32,8 +58,8 @@ class CartTest extends \Magento\TestFramework\TestCase\AbstractController
*/
public function testConfigureActionWithSimpleProduct()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $session CheckoutSession */
+ $session = $this->_objectManager->create(CheckoutSession::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
@@ -63,19 +89,20 @@ public function testConfigureActionWithSimpleProduct()
/**
* Test for \Magento\Checkout\Controller\Cart::configureAction() with simple product and custom option
*
- * @magentoDataFixture Magento/Checkout/_files/quote_with_simple_product_and_custom_option.php
+ * @magentoDataFixture Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php
*/
public function testConfigureActionWithSimpleProductAndCustomOption()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var Quote $quote */
+ $quote = $this->getQuote('test_order_item_with_custom_options');
+ $this->checkoutSession->setQuoteId($quote->getId());
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
/** @var $product \Magento\Catalog\Model\Product */
- $product = $productRepository->get('simple');
+ $product = $productRepository->get('simple_with_custom_options');
- $quoteItem = $this->_getQuoteItemIdByProductId($session->getQuote(), $product->getId());
+ $quoteItem = $this->_getQuoteItemIdByProductId($quote, $product->getId());
$this->assertNotNull($quoteItem, 'Cannot get quote item for simple product with custom option');
$this->dispatch(
@@ -112,8 +139,8 @@ public function testConfigureActionWithSimpleProductAndCustomOption()
*/
public function testConfigureActionWithBundleProduct()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $session CheckoutSession */
+ $session = $this->_objectManager->create(CheckoutSession::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
@@ -147,8 +174,8 @@ public function testConfigureActionWithBundleProduct()
*/
public function testConfigureActionWithDownloadableProduct()
{
- /** @var $session \Magento\Checkout\Model\Session */
- $session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $session CheckoutSession */
+ $session = $this->_objectManager->create(CheckoutSession::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
@@ -201,8 +228,8 @@ public function testUpdatePostAction()
$productId = $product->getId();
$originalQuantity = 1;
$updatedQuantity = 2;
- /** @var $checkoutSession \Magento\Checkout\Model\Session */
- $checkoutSession = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
+ /** @var $checkoutSession CheckoutSession */
+ $checkoutSession = $this->_objectManager->create(CheckoutSession::class);
$quoteItem = $this->_getQuoteItemIdByProductId($checkoutSession->getQuote(), $productId);
/** @var FormKey $formKey */
@@ -235,6 +262,26 @@ public function testUpdatePostAction()
$this->assertEquals($updatedQuantity, $quoteItem->getQty(), "Invalid quote item quantity");
}
+ /**
+ * Gets quote by reserved order id.
+ *
+ * @param string $reservedOrderId
+ * @return Quote
+ */
+ private function getQuote($reservedOrderId)
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId)
+ ->create();
+
+ /** @var CartRepositoryInterface $quoteRepository */
+ $quoteRepository = $this->_objectManager->get(CartRepositoryInterface::class);
+ $items = $quoteRepository->getList($searchCriteria)->getItems();
+
+ return array_pop($items);
+ }
+
/**
* Gets \Magento\Quote\Model\Quote\Item from \Magento\Quote\Model\Quote by product id
*
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php
new file mode 100644
index 0000000000000..ad4234f266baa
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/cart_with_simple_product_and_custom_options.php
@@ -0,0 +1,46 @@
+create(ProductRepositoryInterface::class);
+$product = $productRepository->get('simple_with_custom_options');
+
+$options = [];
+/** @var $option Option */
+foreach ($product->getOptions() as $option) {
+ switch ($option->getGroupByType()) {
+ case ProductCustomOptionInterface::OPTION_GROUP_SELECT:
+ $value = key($option->getValues());
+ break;
+ default:
+ $value = 'test';
+ break;
+ }
+ $options[$option->getId()] = $value;
+}
+
+$requestInfo = new DataObject(['qty' => 1, 'options' => $options]);
+
+/** @var $cart \Magento\Checkout\Model\Cart */
+$quote = Bootstrap::getObjectManager()->create(Quote::class);
+$quote->setReservedOrderId('test_order_item_with_custom_options');
+$quote->addProduct($product, $requestInfo);
+$quote->save();
+
+/** @var $objectManager \Magento\TestFramework\ObjectManager */
+$objectManager = Bootstrap::getObjectManager();
+$objectManager->removeSharedInstance(Session::class);
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php
index d8f905f7d4284..78fa4733a2562 100644
--- a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/Model/Product/Type/ConfigurableTest.php
@@ -157,6 +157,19 @@ public function testGetConfigurableAttributes()
}
}
+ /**
+ * @magentoAppIsolation enabled
+ * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable_custom.php
+ */
+ public function testGetConfigurableAttributesWithSourceModel()
+ {
+ $collection = $this->model->getConfigurableAttributes($this->product);
+ /** @var \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Attribute $configurableAttribute */
+ $configurableAttribute = $collection->getFirstItem();
+ $attribute = $this->_getAttributeByCode('test_configurable_with_sm');
+ $this->assertSameSize($attribute->getSource()->getAllOptions(), $configurableAttribute->getOptions());
+ }
+
/**
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable.php
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_with_source_model.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_with_source_model.php
new file mode 100644
index 0000000000000..2c4713ac6b16e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_with_source_model.php
@@ -0,0 +1,37 @@
+create(\Magento\Eav\Setup\EavSetup::class);
+$eavSetup->addAttribute(
+ \Magento\Catalog\Model\Product::ENTITY,
+ 'test_configurable_with_sm',
+ [
+ 'group' => 'General',
+ 'type' => 'varchar',
+ 'backend' => '',
+ 'frontend' => '',
+ 'label' => 'Test configurable with source model',
+ 'input' => 'select',
+ 'source' => \Magento\Catalog\Model\Category\Attribute\Source\Mode::class,
+ 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_GLOBAL,
+ 'visible' => true,
+ 'required' => false,
+ 'user_defined' => true,
+ 'default' => '',
+ 'searchable' => false,
+ 'filterable' => false,
+ 'comparable' => false,
+ 'visible_on_front' => false,
+ 'used_in_product_listing' => true,
+ 'unique' => false,
+ 'apply_to' => ''
+ ]
+);
+
+$eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);
+$eavConfig->clear();
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_with_source_model_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_with_source_model_rollback.php
new file mode 100644
index 0000000000000..8930f4da7f686
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/configurable_attribute_with_source_model_rollback.php
@@ -0,0 +1,21 @@
+get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+$eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);
+$attribute = $eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'test_configurable_with_sm');
+if ($attribute instanceof \Magento\Eav\Model\Entity\Attribute\AbstractAttribute && $attribute->getId()) {
+ $attribute->delete();
+}
+$eavConfig->clear();
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_custom.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_custom.php
new file mode 100644
index 0000000000000..56306c9f94c26
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_custom.php
@@ -0,0 +1,91 @@
+create(\Magento\Catalog\Setup\CategorySetup::class);
+
+$eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);
+$attribute = $eavConfig->getAttribute(\Magento\Catalog\Model\Product::ENTITY, 'test_configurable_with_sm');
+$options = $attribute->getOptions();
+
+$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+$attributeValues = [];
+$associatedProductIds = [];
+$attributeSetId = $installer->getAttributeSetId(\Magento\Catalog\Model\Product::ENTITY, 'Default');
+
+foreach ($options as $key => $option) {
+ $productId = $key + 10;
+
+ $product = $objectManager->create(\Magento\Catalog\Model\Product::class);
+ $product->setTypeId(Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
+ ->setId($productId)
+ ->setAttributeSetId($attributeSetId)
+ ->setWebsiteIds([1])
+ ->setName('Configurable Option ' . $option->getLabel())
+ ->setSku('simple_' . $productId)
+ ->setPrice($productId)
+ ->setTestConfigurableWithSm($option->getValue())
+ ->setVisibility(Magento\Catalog\Model\Product\Visibility::VISIBILITY_NOT_VISIBLE)
+ ->setStatus(Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
+ ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]);
+ $product = $productRepository->save($product);
+
+ $stockItem = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Item::class);
+ $stockItem->load($productId, 'product_id');
+ if (!$stockItem->getProductId()) {
+ $stockItem->setProductId($productId);
+ }
+ $stockItem->setUseConfigManageStock(1);
+ $stockItem->setQty(1000);
+ $stockItem->setIsQtyDecimal(0);
+ $stockItem->setIsInStock(1);
+ $stockItem->save();
+
+ $attributeValues[] = [
+ 'label' => 'test',
+ 'attribute_id' => $attribute->getId(),
+ 'value_index' => $option->getValue(),
+ ];
+ $associatedProductIds[] = $product->getId();
+}
+
+$optionsFactory = $objectManager->create(\Magento\ConfigurableProduct\Helper\Product\Options\Factory::class);
+$configurableAttributesData = [
+ [
+ 'attribute_id' => $attribute->getId(),
+ 'code' => $attribute->getAttributeCode(),
+ 'label' => $attribute->getStoreLabel(),
+ 'position' => '0',
+ 'values' => $attributeValues,
+ ],
+];
+$configurableOptions = $optionsFactory->create($configurableAttributesData);
+
+$product = $objectManager->create(\Magento\Catalog\Model\Product::class);
+$extensionConfigurableAttributes = $product->getExtensionAttributes();
+$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions);
+$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds);
+$product->setExtensionAttributes($extensionConfigurableAttributes);
+
+$product->setTypeId(\Magento\ConfigurableProduct\Model\Product\Type\Configurable::TYPE_CODE)
+ ->setId(1)
+ ->setAttributeSetId($attributeSetId)
+ ->setWebsiteIds([1])
+ ->setName('Configurable Product')
+ ->setSku('configurable')
+ ->setVisibility(Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
+ ->setStatus(Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED)
+ ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 1]);
+$productRepository->save($product);
+
+$categoryLinkManagement = $objectManager->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class);
+$categoryLinkManagement->assignProductToCategories(
+ $product->getSku(),
+ [2]
+);
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_custom_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_custom_rollback.php
new file mode 100644
index 0000000000000..1b7c2b76d0479
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_custom_rollback.php
@@ -0,0 +1,34 @@
+get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+foreach (['simple_10', 'simple_11', 'simple_12', 'configurable'] as $sku) {
+ try {
+ $product = $productRepository->get($sku, true);
+
+ $stockStatus = $objectManager->create(\Magento\CatalogInventory\Model\Stock\Status::class);
+ $stockStatus->load($product->getEntityId(), 'product_id');
+ $stockStatus->delete();
+
+ if ($product->getId()) {
+ $productRepository->delete($product);
+ }
+ } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ //Product already removed
+ }
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require __DIR__ . '/configurable_attribute_with_source_model_rollback.php';
diff --git a/dev/tests/integration/testsuite/Magento/Cron/Observer/ProcessCronQueueObserverTest.php b/dev/tests/integration/testsuite/Magento/Cron/Observer/ProcessCronQueueObserverTest.php
index cdeb67afca471..99be1bcbae379 100644
--- a/dev/tests/integration/testsuite/Magento/Cron/Observer/ProcessCronQueueObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cron/Observer/ProcessCronQueueObserverTest.php
@@ -27,7 +27,7 @@ protected function setUp()
}
/**
- * @magentoConfigFixture current_store crontab/default/jobs/catalog_product_alert/schedule/cron_expr 8 * * * *
+ * @magentoConfigFixture current_store crontab/default/jobs/catalog_product_alert/schedule/cron_expr * * * * *
*/
public function testDispatchScheduled()
{
@@ -35,6 +35,7 @@ public function testDispatchScheduled()
\Magento\Cron\Model\ResourceModel\Schedule\Collection::class
);
$collection->addFieldToFilter('status', \Magento\Cron\Model\Schedule::STATUS_PENDING);
+ $collection->addFieldToFilter('job_code', 'catalog_product_alert');
$this->assertGreaterThan(0, $collection->count(), 'Cron has failed to schedule tasks for itself for future.');
}
diff --git a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php
index 28f744aa4142f..e1a1df2b50a51 100644
--- a/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php
+++ b/dev/tests/integration/testsuite/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRatesTest.php
@@ -42,85 +42,4 @@ public function testFetchRatesActionWithNonexistentService()
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
}
-
- /**
- * Test save action with nonexistent service
- */
- public function testFetchRatesActionWithServiceErrors()
- {
- $this->runActionWithMockedImportService(['We can\'t retrieve a rate from url']);
-
- $this->assertSessionMessages(
- $this->contains('Click "Save" to apply the rates we found.'),
- \Magento\Framework\Message\MessageInterface::TYPE_WARNING
- );
- }
-
- /**
- * Test save action with nonexistent service
- */
- public function testFetchRatesActionWithoutServiceErrors()
- {
- $this->runActionWithMockedImportService();
-
- $this->assertSessionMessages(
- $this->contains('Click "Save" to apply the rates we found.'),
- \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
- );
- }
-
- /**
- * Run fetchRates with mocked external import service
- *
- * @param array $messages messages from external import service
- */
- protected function runActionWithMockedImportService(array $messages = [])
- {
- $importServiceMock = $this->getMockBuilder(\Magento\Directory\Model\Currency\Import\Webservicex::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $importServiceMock->method('fetchRates')
- ->willReturn(['USD' => ['USD' => 1]]);
-
- $importServiceMock->method('getMessages')
- ->willReturn($messages);
-
- $backendSessionMock = $this->getMockBuilder(\Magento\Backend\Model\Session::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $importServiceFactoryMock = $this->getMockBuilder(\Magento\Directory\Model\Currency\Import\Factory::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $importServiceFactoryMock->method('create')
- ->willReturn($importServiceMock);
-
- $objectManagerMock = $this->getMockBuilder(\Magento\Framework\ObjectManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $objectManagerMap = [
- [\Magento\Directory\Model\Currency\Import\Factory::class, $importServiceFactoryMock],
- [\Magento\Backend\Model\Session::class, $backendSessionMock]
- ];
-
- $objectManagerMock->method('get')
- ->will($this->returnValueMap($objectManagerMap));
-
- $context = $this->_objectManager->create(
- \Magento\Backend\App\Action\Context::class,
- ["objectManager" => $objectManagerMock]
- );
- $registry = $this->_objectManager->get(\Magento\Framework\Registry::class);
-
- $this->getRequest()->setParam('rate_services', 'webservicex');
-
- $action = new \Magento\CurrencySymbol\Controller\Adminhtml\System\Currency\FetchRates(
- $context,
- $registry
- );
- $action->execute();
- }
}
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php
index 4f9fa437dcd52..5425af856bd9f 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerMetadataTest.php
@@ -11,6 +11,9 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\TestFramework\Helper\CacheCleaner;
+/**
+ * @magentoAppIsolation enabled
+ */
class CustomerMetadataTest extends \PHPUnit\Framework\TestCase
{
/** @var CustomerRepositoryInterface */
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php
index 3d469dc653128..167f654162ad8 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/CustomerRegistryTest.php
@@ -13,6 +13,7 @@
/**
* Test for \Magento\Customer\Model\CustomerRegistry
+ * @magentoAppIsolation enabled
*/
class CustomerRegistryTest extends \PHPUnit\Framework\TestCase
{
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/GroupRegistryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/GroupRegistryTest.php
index cf5939d0a331d..a9842a2b7226a 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/GroupRegistryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/GroupRegistryTest.php
@@ -8,6 +8,7 @@
/**
* Test for \Magento\Customer\Model\GroupRegistry
+ * @magentoAppIsolation enabled
*/
class GroupRegistryTest extends \PHPUnit\Framework\TestCase
{
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/AddressRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/AddressRepositoryTest.php
index 9b66d3e3f452b..2b74a58288600 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/AddressRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/AddressRepositoryTest.php
@@ -20,6 +20,7 @@
* @SuppressWarnings(PHPMD.TooManyMethods)
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @magentoAppIsolation enabled
*/
class AddressRepositoryTest extends \PHPUnit\Framework\TestCase
{
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php
index fe9037e4ffd2b..e777313f13fe8 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/CustomerRepositoryTest.php
@@ -15,6 +15,7 @@
* Checks Customer insert, update, search with repository
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @magentoAppIsolation enabled
*/
class CustomerRepositoryTest extends \PHPUnit\Framework\TestCase
{
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php
index 016efd60ce786..b1e394db11674 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/Grid/CollectionTest.php
@@ -12,6 +12,7 @@
/**
* Customer grid collection tests.
+ * @magentoAppIsolation enabled
*/
class CollectionTest extends \Magento\TestFramework\Indexer\TestCase
{
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/GroupRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/GroupRepositoryTest.php
index 9d86b72ec28be..ae2cc2c9d078c 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/GroupRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/ResourceModel/GroupRepositoryTest.php
@@ -11,6 +11,7 @@
/**
* Integration test for \Magento\Customer\Model\ResourceModel\GroupRepository
+ * @magentoAppIsolation enabled
*/
class GroupRepositoryTest extends \PHPUnit\Framework\TestCase
{
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php
index 0d5a5f262d1a6..55ed0c6321b1b 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Model/VisitorTest.php
@@ -7,6 +7,9 @@
use Magento\TestFramework\Helper\Bootstrap;
+/**
+ * @magentoAppIsolation enabled
+ */
class VisitorTest extends \PHPUnit\Framework\TestCase
{
/**
diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php
deleted file mode 100644
index ee323ace6d78e..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Directory/Model/ObserverTest.php
+++ /dev/null
@@ -1,90 +0,0 @@
-objectManager = Bootstrap::getObjectManager();
-
- $this->scopeConfig = $this->objectManager->create(\Magento\Framework\App\MutableScopeConfig::class);
- $this->scopeConfig->setValue(Observer::IMPORT_ENABLE, 1, ScopeInterface::SCOPE_STORE);
- $this->scopeConfig->setValue(Observer::CRON_STRING_PATH, 'cron-string-path', ScopeInterface::SCOPE_STORE);
- $this->scopeConfig->setValue(Observer::IMPORT_SERVICE, 'webservicex', ScopeInterface::SCOPE_STORE);
-
- $this->configResource = $this->objectManager->get(\Magento\Config\Model\ResourceModel\Config::class);
- $this->configResource->saveConfig(
- $this->baseCurrencyPath,
- $this->baseCurrency,
- ScopeInterface::SCOPE_STORE,
- 0
- );
-
- $this->observer = $this->objectManager->create(\Magento\Directory\Model\Observer::class);
- }
-
- public function testScheduledUpdateCurrencyRates()
- {
- //skipping test if service is unavailable
- $url = str_replace('{{CURRENCY_FROM}}', 'USD',
- \Magento\Directory\Model\Currency\Import\Webservicex::CURRENCY_CONVERTER_URL
- );
- $url = str_replace('{{CURRENCY_TO}}', 'GBP', $url);
- try {
- file_get_contents($url);
- } catch (\PHPUnit\Framework\Exception $e) {
- $this->markTestSkipped('http://www.webservicex.net is unavailable ');
- }
-
- $allowedCurrencies = 'USD,GBP,EUR';
- $this->configResource->saveConfig(
- $this->allowedCurrenciesPath,
- $allowedCurrencies,
- ScopeInterface::SCOPE_STORE,
- 0
- );
- $this->observer->scheduledUpdateCurrencyRates(null);
- /** @var Currency $currencyResource */
- $currencyResource = $this->objectManager
- ->create(\Magento\Directory\Model\CurrencyFactory::class)
- ->create()
- ->getResource();
- $rates = $currencyResource->getCurrencyRates($this->baseCurrency, explode(',', $allowedCurrencies));
- $this->assertNotEmpty($rates);
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Eav/Model/Validator/Attribute/BackendTest.php b/dev/tests/integration/testsuite/Magento/Eav/Model/Validator/Attribute/BackendTest.php
index b3c4323ed67dd..3784c8aae7e98 100644
--- a/dev/tests/integration/testsuite/Magento/Eav/Model/Validator/Attribute/BackendTest.php
+++ b/dev/tests/integration/testsuite/Magento/Eav/Model/Validator/Attribute/BackendTest.php
@@ -9,6 +9,9 @@
*/
namespace Magento\Eav\Model\Validator\Attribute;
+/**
+ * @magentoAppIsolation enabled
+ */
class BackendTest extends \PHPUnit\Framework\TestCase
{
/**
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php
index 4b2c59b433afa..6806c2cfd060f 100644
--- a/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Framework/Api/ExtensionAttribute/JoinProcessorTest.php
@@ -17,6 +17,7 @@
* Class to test the JoinProcessor functionality
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @magentoAppIsolation enabled
*/
class JoinProcessorTest extends \PHPUnit\Framework\TestCase
{
@@ -144,55 +145,55 @@ public function testProcess()
private function getConfig()
{
return [\Magento\Catalog\Api\Data\ProductInterface::class => [
- 'review_id' => [
- Converter::DATA_TYPE => 'string',
- Converter::RESOURCE_PERMISSIONS => [],
- Converter::JOIN_DIRECTIVE => [
- Converter::JOIN_REFERENCE_TABLE => "reviews",
- Converter::JOIN_REFERENCE_FIELD => "product_id",
- Converter::JOIN_FIELDS => [
- [
- Converter::JOIN_FIELD => "review_id",
- Converter::JOIN_FIELD_COLUMN => "db_review_id",
- ],
+ 'review_id' => [
+ Converter::DATA_TYPE => 'string',
+ Converter::RESOURCE_PERMISSIONS => [],
+ Converter::JOIN_DIRECTIVE => [
+ Converter::JOIN_REFERENCE_TABLE => "reviews",
+ Converter::JOIN_REFERENCE_FIELD => "product_id",
+ Converter::JOIN_FIELDS => [
+ [
+ Converter::JOIN_FIELD => "review_id",
+ Converter::JOIN_FIELD_COLUMN => "db_review_id",
],
- Converter::JOIN_ON_FIELD => "id",
],
+ Converter::JOIN_ON_FIELD => "id",
],
- ], \Magento\Customer\Api\Data\CustomerInterface::class => [
- 'library_card_id' => [
- Converter::DATA_TYPE => 'string',
- Converter::RESOURCE_PERMISSIONS => [],
- Converter::JOIN_DIRECTIVE => [
- Converter::JOIN_REFERENCE_TABLE => "library_account",
- Converter::JOIN_FIELDS => [
- [
- Converter::JOIN_FIELD => "library_card_id",
- Converter::JOIN_FIELD_COLUMN => "",
- ],
+ ],
+ ], \Magento\Customer\Api\Data\CustomerInterface::class => [
+ 'library_card_id' => [
+ Converter::DATA_TYPE => 'string',
+ Converter::RESOURCE_PERMISSIONS => [],
+ Converter::JOIN_DIRECTIVE => [
+ Converter::JOIN_REFERENCE_TABLE => "library_account",
+ Converter::JOIN_FIELDS => [
+ [
+ Converter::JOIN_FIELD => "library_card_id",
+ Converter::JOIN_FIELD_COLUMN => "",
],
- Converter::JOIN_ON_FIELD => "customer_id",
],
+ Converter::JOIN_ON_FIELD => "customer_id",
],
- 'reviews' => [
- Converter::DATA_TYPE => 'Magento\Reviews\Api\Data\Reviews[]',
- Converter::RESOURCE_PERMISSIONS => [],
- Converter::JOIN_DIRECTIVE => [
- Converter::JOIN_REFERENCE_TABLE => "reviews",
- Converter::JOIN_FIELDS => [
- [
- Converter::JOIN_FIELD => "comment",
- Converter::JOIN_FIELD_COLUMN => "",
- ],
- [
- Converter::JOIN_FIELD => "rating",
- Converter::JOIN_FIELD_COLUMN => "",
- ],
+ ],
+ 'reviews' => [
+ Converter::DATA_TYPE => 'Magento\Reviews\Api\Data\Reviews[]',
+ Converter::RESOURCE_PERMISSIONS => [],
+ Converter::JOIN_DIRECTIVE => [
+ Converter::JOIN_REFERENCE_TABLE => "reviews",
+ Converter::JOIN_FIELDS => [
+ [
+ Converter::JOIN_FIELD => "comment",
+ Converter::JOIN_FIELD_COLUMN => "",
+ ],
+ [
+ Converter::JOIN_FIELD => "rating",
+ Converter::JOIN_FIELD_COLUMN => "",
],
- Converter::JOIN_ON_FIELD => "customer_id",
],
+ Converter::JOIN_ON_FIELD => "customer_id",
],
],
+ ],
];
}
diff --git a/dev/tests/integration/testsuite/Magento/Framework/App/Filesystem/CreatePdfFileTest.php b/dev/tests/integration/testsuite/Magento/Framework/App/Filesystem/CreatePdfFileTest.php
new file mode 100644
index 0000000000000..d97a57589bc59
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Framework/App/Filesystem/CreatePdfFileTest.php
@@ -0,0 +1,53 @@
+get(FileFactory::class);
+ /** @var Filesystem $filesystem */
+ $filesystem = $objectManager->get(Filesystem::class);
+ $filename = 'test.pdf';
+ $contentType = 'application/pdf';
+ $fileContent = ['type' => 'string', 'value' => ''];
+ $response = $fileFactory->create($filename, $fileContent, DirectoryList::VAR_DIR, $contentType);
+ /** @var ContentType $contentTypeHeader */
+ $contentTypeHeader = $response->getHeader('Content-type');
+
+ /* Check the system returns the correct type */
+ self::assertEquals("Content-Type: $contentType", $contentTypeHeader->toString());
+
+ $varDirectory = $filesystem->getDirectoryRead(DirectoryList::VAR_DIR);
+ $varDirectory->isFile($filename);
+
+ /* Check the file is generated */
+ self::assertTrue($varDirectory->isFile($filename));
+
+ /* Check the file is removed after generation if the corresponding option is set */
+ $fileContent = ['type' => 'string', 'value' => '', 'rm' => true];
+ $fileFactory->create($filename, $fileContent, DirectoryList::VAR_DIR, $contentType);
+
+ self::assertFalse($varDirectory->isFile($filename));
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Framework/Filter/TruncateFilterTest.php b/dev/tests/integration/testsuite/Magento/Framework/Filter/TruncateFilterTest.php
new file mode 100644
index 0000000000000..01fd999d4ab30
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Framework/Filter/TruncateFilterTest.php
@@ -0,0 +1,65 @@
+create(
+ TruncateFilter::class,
+ [
+ 'length' => $length,
+ 'etc' => $etc,
+ 'breakWords' => $breakWords,
+ ]
+ );
+ $result = $truncateFilter->filter($string);
+ $this->assertEquals($expectedValue, $result->getValue());
+ $this->assertEquals($expectedRemainder, $result->getRemainder());
+ }
+
+ /**
+ * @return array
+ */
+ public function truncateDataProvider() : array
+ {
+ return [
+ '1' => [
+ '12...',
+ '34567890',
+ '1234567890',
+ ],
+ '2' => [
+ '123..',
+ ' 456 789',
+ '123 456 789',
+ 8,
+ '..',
+ false,
+ ],
+ ];
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php
index 0b0071beb5133..356117f2b3dc8 100644
--- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php
+++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteManagementTest.php
@@ -3,10 +3,18 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Quote\Model;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product\Type;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Quote\Api\CartManagementInterface;
+use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\ObjectManager;
/**
* Class for testing QuoteManagement model
@@ -14,79 +22,120 @@
class QuoteManagementTest extends \PHPUnit\Framework\TestCase
{
/**
- * Create order with product that has child items
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var CartManagementInterface
+ */
+ private $cartManagement;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->objectManager = Bootstrap::getObjectManager();
+
+ $this->cartManagement = $this->objectManager->create(CartManagementInterface::class);
+ }
+
+ /**
+ * Creates order with product that has child items.
*
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
*/
public function testSubmit()
{
- /**
- * Preconditions:
- * Load quote with Bundle product that has at least two child products
- */
- $objectManager = Bootstrap::getObjectManager();
- /** @var \Magento\Quote\Model\Quote $quote */
- $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
- $quote->load('test01', 'reserved_order_id');
-
- /** Execute SUT */
- /** @var \Magento\Quote\Api\CartManagementInterface $model */
- $cartManagement = $objectManager->create(\Magento\Quote\Api\CartManagementInterface::class);
- /** @var \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */
- $orderRepository = $objectManager->create(\Magento\Sales\Api\OrderRepositoryInterface::class);
- $orderId = $cartManagement->placeOrder($quote->getId());
+ $quote = $this->getQuote('test01');
+ $orderId = $this->cartManagement->placeOrder($quote->getId());
+
+ /** @var OrderRepositoryInterface $orderRepository */
+ $orderRepository = $this->objectManager->create(OrderRepositoryInterface::class);
$order = $orderRepository->get($orderId);
- /** Check if SUT caused expected effects */
$orderItems = $order->getItems();
- $this->assertCount(3, $orderItems);
+ self::assertCount(3, $orderItems);
foreach ($orderItems as $orderItem) {
if ($orderItem->getProductType() == Type::TYPE_SIMPLE) {
- $this->assertNotEmpty($orderItem->getParentItem(), 'Parent is not set for child product');
- $this->assertNotEmpty($orderItem->getParentItemId(), 'Parent is not set for child product');
+ self::assertNotEmpty($orderItem->getParentItem(), 'Parent is not set for child product');
+ self::assertNotEmpty($orderItem->getParentItemId(), 'Parent is not set for child product');
}
}
}
/**
- * Create order with product that has child items and one of them was deleted
+ * Tries to create order with product that has child items and one of them was deleted.
*
* @magentoAppArea adminhtml
* @magentoAppIsolation enabled
* @magentoDataFixture Magento/Sales/_files/quote_with_bundle.php
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Some of the products below do not have all the required options.
*/
public function testSubmitWithDeletedItem()
{
- /**
- * Preconditions:
- * Load quote with Bundle product that have at least to child products
- */
- $objectManager = Bootstrap::getObjectManager();
- /** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
- $productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+ /** @var ProductRepositoryInterface $productRepository */
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
$product = $productRepository->get('simple-2');
$productRepository->delete($product);
- /** @var \Magento\Quote\Model\Quote $quote */
- $quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
- $quote->load('test01', 'reserved_order_id');
-
- /** Execute SUT */
- /** @var \Magento\Quote\Api\CartManagementInterface $model */
- $cartManagement = $objectManager->create(\Magento\Quote\Api\CartManagementInterface::class);
- /** @var \Magento\Sales\Api\OrderRepositoryInterface $orderRepository */
- $orderRepository = $objectManager->create(\Magento\Sales\Api\OrderRepositoryInterface::class);
- $orderId = $cartManagement->placeOrder($quote->getId());
- $order = $orderRepository->get($orderId);
+ $quote = $this->getQuote('test01');
- /** Check if SUT caused expected effects */
- $orderItems = $order->getItems();
- $this->assertCount(2, $orderItems);
- foreach ($orderItems as $orderItem) {
- if ($orderItem->getProductType() == Type::TYPE_SIMPLE) {
- $this->assertNotEmpty($orderItem->getParentItem(), 'Parent is not set for child product');
- $this->assertNotEmpty($orderItem->getParentItemId(), 'Parent is not set for child product');
- }
- }
+ $this->cartManagement->placeOrder($quote->getId());
+ }
+
+ /**
+ * Tries to create order with item of stock during checkout.
+ *
+ * @magentoDataFixture Magento/Sales/_files/quote.php
+ * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedExceptionMessage Some of the products are out of stock.
+ * @magentoDbIsolation enabled
+ */
+ public function testSubmitWithItemOutOfStock()
+ {
+ $this->makeProductOutOfStock('simple');
+ $quote = $this->getQuote('test01');
+ $this->cartManagement->placeOrder($quote->getId());
+ }
+
+ /**
+ * Gets quote by reserved order ID.
+ *
+ * @param string $reservedOrderId
+ * @return Quote
+ */
+ private function getQuote(string $reservedOrderId): Quote
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('reserved_order_id', $reservedOrderId)
+ ->create();
+
+ /** @var CartRepositoryInterface $quoteRepository */
+ $quoteRepository = $this->objectManager->get(CartRepositoryInterface::class);
+ $items = $quoteRepository->getList($searchCriteria)
+ ->getItems();
+
+ return array_pop($items);
+ }
+
+ /**
+ * Makes provided product as out of stock.
+ *
+ * @param string $sku
+ * @return void
+ */
+ private function makeProductOutOfStock(string $sku)
+ {
+ /** @var ProductRepositoryInterface $productRepository */
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $product = $productRepository->get($sku);
+ $extensionAttributes = $product->getExtensionAttributes();
+ $stockItem = $extensionAttributes->getStockItem();
+ $stockItem->setIsInStock(false);
+ $productRepository->save($product);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php
index bcd7fef9c3c93..802358c2c83c7 100644
--- a/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Quote/Model/QuoteTest.php
@@ -3,12 +3,14 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Quote\Model;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\ProductRepository;
use Magento\Customer\Api\Data\CustomerInterfaceFactory;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Quote\Api\Data\CartInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -49,7 +51,7 @@ public function testCollectTotalsWithVirtual()
$quote->load('test01', 'reserved_order_id');
$productRepository = $this->objectManager->create(
- \Magento\Catalog\Api\ProductRepositoryInterface::class
+ ProductRepositoryInterface::class
);
$product = $productRepository->get('virtual-product', false, null, true);
$quote->addProduct($product);
@@ -318,7 +320,7 @@ public function testAddProductUpdateItem()
$productStockQty = 100;
$productRepository = $this->objectManager->create(
- \Magento\Catalog\Api\ProductRepositoryInterface::class
+ ProductRepositoryInterface::class
);
$product = $productRepository->get('simple-1', false, null, true);
@@ -474,7 +476,7 @@ public function testGetItemById()
$quoteItem = $this->objectManager->create(\Magento\Quote\Model\Quote\Item::class);
- $productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+ $productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$product = $productRepository->get('simple');
$quoteItem->setProduct($product);
@@ -488,21 +490,77 @@ public function testGetItemById()
/**
* Tests of quotes merging.
*
+ * @param int|null $guestItemGiftMessageId
+ * @param int|null $customerItemGiftMessageId
+ * @param int|null $guestOrderGiftMessageId
+ * @param int|null $customerOrderGiftMessageId
+ * @param int|null $expectedItemGiftMessageId
+ * @param int|null $expectedOrderGiftMessageId
+ *
* @magentoDataFixture Magento/Sales/_files/quote.php
+ * @dataProvider giftMessageDataProvider
+ * @throws LocalizedException
*/
- public function testMerge()
- {
- $giftMessageId = 1;
+ public function testMerge(
+ $guestItemGiftMessageId,
+ $customerItemGiftMessageId,
+ $guestOrderGiftMessageId,
+ $customerOrderGiftMessageId,
+ $expectedItemGiftMessageId,
+ $expectedOrderGiftMessageId
+ ) {
+ $productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ $product = $productRepository->get('simple', false, null, true);
/** @var Quote $quote */
$guestQuote = $this->getQuote('test01');
- $guestQuote->setGiftMessageId($giftMessageId);
+ $guestQuote->setGiftMessageId($guestOrderGiftMessageId);
/** @var Quote $customerQuote */
$customerQuote = $this->objectManager->create(Quote::class);
+ $customerQuote->setReservedOrderId('test02')
+ ->setStoreId($guestQuote->getStoreId())
+ ->addProduct($product);
+ $customerQuote->setGiftMessageId($customerOrderGiftMessageId);
+
+ $guestItem = $guestQuote->getItemByProduct($product);
+ $guestItem->setGiftMessageId($guestItemGiftMessageId);
+
+ $customerItem = $customerQuote->getItemByProduct($product);
+ $customerItem->setGiftMessageId($customerItemGiftMessageId);
+
$customerQuote->merge($guestQuote);
+ $mergedItemItem = $customerQuote->getItemByProduct($product);
+
+ self::assertEquals($expectedOrderGiftMessageId, $customerQuote->getGiftMessageId());
+ self::assertEquals($expectedItemGiftMessageId, $mergedItemItem->getGiftMessageId());
+ }
- self::assertEquals($giftMessageId, $customerQuote->getGiftMessageId());
+ /**
+ * Provides order- and item-level gift message Id.
+ *
+ * @return array
+ */
+ public function giftMessageDataProvider(): array
+ {
+ return [
+ [
+ 'guestItemId' => null,
+ 'customerItemId' => 1,
+ 'guestOrderId' => null,
+ 'customerOrderId' => 11,
+ 'expectedItemId' => 1,
+ 'expectedOrderId' => 11
+ ],
+ [
+ 'guestItemId' => 1,
+ 'customerItemId' => 2,
+ 'guestOrderId' => 11,
+ 'customerOrderId' => 22,
+ 'expectedItemId' => 1,
+ 'expectedOrderId' => 11
+ ]
+ ];
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php
index b8446839c8c99..895f7b846f4d2 100644
--- a/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php
+++ b/dev/tests/integration/testsuite/Magento/Reports/Block/Adminhtml/Shopcart/Abandoned/GridTest.php
@@ -7,6 +7,7 @@
use Magento\Quote\Model\Quote;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\View\LayoutInterface;
/**
* Test class for \Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid
@@ -22,10 +23,10 @@ class GridTest extends \Magento\Reports\Block\Adminhtml\Shopcart\GridTestAbstrac
*/
public function testGridContent()
{
- /** @var \Magento\Framework\View\LayoutInterface $layout */
- $layout = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class);
+ /** @var LayoutInterface $layout */
+ $layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
/** @var Grid $grid */
- $grid = $layout->createBlock(\Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid::class);
+ $grid = $layout->createBlock(Grid::class);
$grid->getRequest()->setParams(['filter' => base64_encode(urlencode('email=customer@example.com'))]);
$result = $grid->getPreparedCollection();
@@ -35,4 +36,17 @@ public function testGridContent()
$this->assertEquals('customer@example.com', $quote->getCustomerEmail());
$this->assertEquals(10.00, $quote->getSubtotal());
}
+
+ /**
+ * @return void
+ */
+ public function testPageSizeIsSetToNullWhenExportCsvFile()
+ {
+ /** @var LayoutInterface $layout */
+ $layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
+ /** @var Grid $grid */
+ $grid = $layout->createBlock(Grid::class);
+ $grid->getCsvFile();
+ $this->assertNull($grid->getCollection()->getPageSize());
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/NameTest.php b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/NameTest.php
new file mode 100644
index 0000000000000..5be1e7bbce0d7
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Items/Column/NameTest.php
@@ -0,0 +1,56 @@
+create(\Magento\Framework\View\LayoutInterface::class);
+ /** @var $block \Magento\Sales\Block\Adminhtml\Items\AbstractItems */
+ $this->block = $layout->createBlock(Name::class, 'block');
+ }
+
+ /**
+ * @return void
+ */
+ public function testTruncateString()
+ {
+ $remainder = '';
+ $this->assertEquals(
+ '12345',
+ $this->block->truncateString('1234567890', 5, '', $remainder)
+ );
+ }
+
+ /**
+ * @return void
+ */
+ public function testGetFormattedOption()
+ {
+ $this->assertEquals(
+ [
+ 'value' => '1234567890123456789012345678901234567890123456789012345',
+ 'remainder' => '67890',
+ ],
+ $this->block->getFormattedOption(
+ '123456789012345678901234567890123456789012345678901234567890'
+ )
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddCommentTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddCommentTest.php
deleted file mode 100644
index 020c9f51bb10f..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddCommentTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::comment';
- $this->uri = 'backend/sales/order/addcomment';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddressSaveTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddressSaveTest.php
deleted file mode 100644
index 9cdd84a5971f3..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddressSaveTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::actions_edit';
- $this->uri = 'backend/sales/order/addresssave';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddressTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddressTest.php
deleted file mode 100644
index 73e46b513287f..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/AddressTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::actions_edit';
- $this->uri = 'backend/sales/order/address';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CancelTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CancelTest.php
deleted file mode 100644
index c24191fe5e45e..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CancelTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::cancel';
- $this->uri = 'backend/sales/order/cancel';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php
deleted file mode 100644
index 70fbb2ee9a5bd..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/EmailTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::email';
- $this->uri = 'backend/sales/order/email';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/HoldTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/HoldTest.php
deleted file mode 100644
index 4c90939d75b2d..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/HoldTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::hold';
- $this->uri = 'backend/sales/order/hold';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/ReviewPaymentTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/ReviewPaymentTest.php
deleted file mode 100644
index 96d197628584a..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/ReviewPaymentTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::review_payment';
- $this->uri = 'backend/sales/order/reviewpayment';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/UnholdTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/UnholdTest.php
deleted file mode 100644
index 351801d8a0558..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/UnholdTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::unhold';
- $this->uri = 'backend/sales/order/unhold';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/ViewTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/ViewTest.php
deleted file mode 100644
index 0374edfaad9d9..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/ViewTest.php
+++ /dev/null
@@ -1,16 +0,0 @@
-resource = 'Magento_Sales::actions_view';
- $this->uri = 'backend/sales/order/view';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Transactions/FetchTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Transactions/FetchTest.php
deleted file mode 100644
index 7b9481db7997a..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Transactions/FetchTest.php
+++ /dev/null
@@ -1,18 +0,0 @@
-resource = 'Magento_Sales::transactions_fetch';
- $this->uri = 'backend/sales/transactions/fetch';
- parent::setUp();
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressRepositoryTest.php
index 872661a24b7c4..7a38c14685073 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Model/Order/AddressRepositoryTest.php
@@ -49,8 +49,6 @@ protected function setUp()
*/
public function testGetListWithMultipleFiltersAndSorting()
{
- $this->markTestSkipped('To be fixed in MAGETWO-91166');
-
$filter1 = $this->filterBuilder
->setField('postcode')
->setConditionType('neq')
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php b/dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php
index 6c27c334d6ef4..6d75cd8b07e06 100644
--- a/dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/Model/Rule/Action/Discount/CartFixedTest.php
@@ -90,6 +90,36 @@ public function applyFixedDiscountDataProvider()
];
}
+ /**
+ * Tests that coupon with wildcard symbols in code can be successfully applied.
+ *
+ * @magentoDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
+ */
+ public function testCouponCodeWithWildcard()
+ {
+ $expectedDiscount = '-5.00';
+ $couponCode = '2?ds5!2d';
+ $cartId = $this->cartManagement->createEmptyCart();
+ $productPrice = 10;
+
+ $product = $this->createProduct($productPrice);
+
+ /** @var CartItemInterface $quoteItem */
+ $quoteItem = Bootstrap::getObjectManager()->create(CartItemInterface::class);
+ $quoteItem->setQuoteId($cartId);
+ $quoteItem->setProduct($product);
+ $quoteItem->setQty(1);
+ $this->cartItemRepository->save($quoteItem);
+
+ $this->couponManagement->set($cartId, $couponCode);
+
+ /** @var GuestCartTotalRepositoryInterface $cartTotalRepository */
+ $cartTotalRepository = Bootstrap::getObjectManager()->get(GuestCartTotalRepositoryInterface::class);
+ $total = $cartTotalRepository->get($cartId);
+
+ $this->assertEquals($expectedDiscount, $total->getBaseDiscountAmount());
+ }
+
/**
* Returns simple product with given price.
*
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard.php
new file mode 100644
index 0000000000000..9005284f984cf
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard.php
@@ -0,0 +1,45 @@
+create(Rule::class);
+$salesRule->setData(
+ [
+ 'name' => '5$ fixed discount on whole cart',
+ 'is_active' => 1,
+ 'customer_group_ids' => [GroupManagement::NOT_LOGGED_IN_ID],
+ 'coupon_type' => Rule::COUPON_TYPE_SPECIFIC,
+ 'conditions' => [],
+ 'simple_action' => Rule::CART_FIXED_ACTION,
+ 'discount_amount' => 5,
+ 'discount_step' => 0,
+ 'stop_rules_processing' => 1,
+ 'website_ids' => [
+ $objectManager->get(StoreManagerInterface::class)->getWebsite()->getId(),
+ ],
+ ]
+);
+$objectManager->get(\Magento\SalesRule\Model\ResourceModel\Rule::class)->save($salesRule);
+
+// Create coupon and assign "15$ fixed discount" rule to this coupon.
+$coupon = $objectManager->create(Coupon::class);
+$coupon->setRuleId($salesRule->getId())
+ ->setCode('2?ds5!2d')
+ ->setType(0);
+
+/** @var CouponRepositoryInterface $couponRepository */
+$couponRepository = $objectManager->get(CouponRepositoryInterface::class);
+$couponRepository->save($coupon);
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php
new file mode 100644
index 0000000000000..776c302210351
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_code_with_wildcard_rollback.php
@@ -0,0 +1,46 @@
+get(RuleRepositoryInterface::class);
+ $ruleRepository->deleteById($salesRule->getRuleId());
+}
+
+$coupon = $objectManager->create(Coupon::class);
+$coupon->loadByCode('2?ds5!2d');
+if ($coupon->getCouponId()) {
+ /** @var CouponRepositoryInterface $couponRepository */
+ $couponRepository = $objectManager->get(CouponRepositoryInterface::class);
+ $couponRepository->deleteById($coupon->getCouponId());
+}
+
+function getSalesRule(string $name)
+{
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
+ ->create();
+
+ /** @var RuleRepositoryInterface $ruleRepository */
+ $ruleRepository = Bootstrap::getObjectManager()->get(RuleRepositoryInterface::class);
+ $items = $ruleRepository->getList($searchCriteria)
+ ->getItems();
+
+ return array_pop($items);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php
index 54734e5a01c1b..bd6c900cf203c 100644
--- a/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php
+++ b/dev/tests/integration/testsuite/Magento/Tax/Model/Sales/Total/Quote/SetupUtil.php
@@ -143,6 +143,7 @@ class SetupUtil
'discount_amount' => 40,
'discount_step' => 0,
'stop_rules_processing' => 1,
+ 'apply_to_shipping' => 0,
'website_ids' => [1],
];
diff --git a/dev/tests/integration/testsuite/Magento/Tax/_files/scenarios/including_tax_apply_tax_after_discount.php b/dev/tests/integration/testsuite/Magento/Tax/_files/scenarios/including_tax_apply_tax_after_discount.php
new file mode 100644
index 0000000000000..a341344ddbb95
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Tax/_files/scenarios/including_tax_apply_tax_after_discount.php
@@ -0,0 +1,131 @@
+ [
+ SetupUtil::CONFIG_OVERRIDES => [
+ Config::CONFIG_XML_PATH_APPLY_AFTER_DISCOUNT => 1,
+ Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX => 1,
+ Config::CONFIG_XML_PATH_SHIPPING_INCLUDES_TAX => 1,
+ Config::CONFIG_XML_PATH_SHIPPING_TAX_CLASS => SetupUtil::SHIPPING_TAX_CLASS,
+ Config::XML_PATH_ALGORITHM => Calculation::CALC_ROW_BASE,
+ ],
+ SetupUtil::TAX_RATE_OVERRIDES => [
+ SetupUtil::TAX_RATE_TX => 10,
+ SetupUtil::TAX_STORE_RATE => 10,
+ SetupUtil::TAX_RATE_SHIPPING => 10
+ ],
+ SetupUtil::TAX_RULE_OVERRIDES => [
+ [
+ //tax rule for product
+ 'code' => 'Product Tax Rule',
+ 'product_tax_class_ids' => [SetupUtil::PRODUCT_TAX_CLASS_1],
+ ],
+ [
+ //tax rule for shipping
+ 'code' => 'Shipping Tax Rule',
+ 'product_tax_class_ids' => [SetupUtil::SHIPPING_TAX_CLASS],
+ 'tax_rate_ids' => [SetupUtil::TAX_RATE_SHIPPING],
+ ],
+ ],
+ ],
+ 'quote_data' => [
+ 'billing_address' => [
+ 'region_id' => SetupUtil::REGION_TX,
+ ],
+ 'shipping_address' => [
+ 'region_id' => SetupUtil::REGION_TX,
+ ],
+ 'items' => [
+ [
+ 'sku' => 'simple1',
+ 'price' => 29,
+ 'qty' => 1,
+ ],
+ ],
+ 'shipping_method' => 'flatrate_flatrate',
+ 'shopping_cart_rules' => [
+ [
+ 'discount_amount' => 50,
+ 'apply_to_shipping' => 1,
+ ],
+ ],
+ ],
+ 'expected_results' => [
+ 'address_data' => [
+ 'subtotal' => 26.36,
+ 'base_subtotal' => 26.36,
+ 'subtotal_incl_tax' => 29,
+ 'base_subtotal_incl_tax' => 29,
+ 'tax_amount' => 1.69,
+ 'base_tax_amount' => 1.69,
+ 'shipping_amount' => 4.55,
+ 'base_shipping_amount' => 4.55,
+ 'shipping_incl_tax' => 5,
+ 'base_shipping_incl_tax' => 5,
+ 'shipping_tax_amount' => 0.25,
+ 'base_shipping_tax_amount' => 0.25,
+ 'discount_amount' => -15.455,
+ 'base_discount_amount' => -15.455,
+ 'discount_tax_compensation_amount' => 1.2,
+ 'base_discount_tax_compensation_amount' => 1.2,
+ 'shipping_discount_tax_compensation_amount' => 0.2,
+ 'base_shipping_discount_tax_compensation_amount' => 0.2,
+ 'grand_total' => 18.545,
+ 'base_grand_total' => 18.545,
+ 'applied_taxes' => [
+ SetupUtil::TAX_RATE_TX => [
+ 'percent' => 10,
+ 'amount' => 1.44,
+ 'base_amount' => 1.44,
+ 'rates' => [
+ [
+ 'code' => SetupUtil::TAX_RATE_TX,
+ 'title' => SetupUtil::TAX_RATE_TX,
+ 'percent' => 10,
+ ],
+ ],
+ ],
+ SetupUtil::TAX_RATE_SHIPPING => [
+ 'percent' => 10,
+ 'amount' => 0.25,
+ 'base_amount' => 0.25,
+ 'rates' => [
+ [
+ 'code' => SetupUtil::TAX_RATE_SHIPPING,
+ 'title' => SetupUtil::TAX_RATE_SHIPPING,
+ 'percent' => 10,
+ ],
+ ],
+ ],
+ ],
+ ],
+ 'items_data' => [
+ 'simple1' => [
+ 'row_total' => 26.36,
+ 'base_row_total' => 26.36,
+ 'tax_percent' => 10,
+ 'price' => 26.36,
+ 'base_price' => 26.36,
+ 'price_incl_tax' => 29,
+ 'base_price_incl_tax' => 29,
+ 'row_total_incl_tax' => 29,
+ 'base_row_total_incl_tax' => 29,
+ 'tax_amount' => 1.44,
+ 'base_tax_amount' => 1.44,
+ 'discount_amount' => 13.18,
+ 'base_discount_amount' => 13.18,
+ 'discount_percent' => 50,
+ 'discount_tax_compensation_amount' => 1.2,
+ 'base_discount_tax_compensation_amount' => 1.2,
+ ],
+ ],
+ ],
+];
diff --git a/dev/tests/integration/testsuite/Magento/Tax/_files/tax_calculation_data_aggregated.php b/dev/tests/integration/testsuite/Magento/Tax/_files/tax_calculation_data_aggregated.php
index c47d348cedda5..f22b48a259685 100644
--- a/dev/tests/integration/testsuite/Magento/Tax/_files/tax_calculation_data_aggregated.php
+++ b/dev/tests/integration/testsuite/Magento/Tax/_files/tax_calculation_data_aggregated.php
@@ -30,3 +30,4 @@
require_once __DIR__ . '/scenarios/multi_tax_rule_total_calculate_subtotal_yes.php';
require_once __DIR__ . '/scenarios/multi_tax_rule_two_row_calculate_subtotal_yes_row.php';
require_once __DIR__ . '/scenarios/multi_tax_rule_two_row_calculate_subtotal_yes_total.php';
+require_once __DIR__ . '/scenarios/including_tax_apply_tax_after_discount.php';
diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Category/TreeTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Category/TreeTest.php
index ba7ed7b8c1c14..a9631272cdf39 100644
--- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Category/TreeTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Block/Catalog/Category/TreeTest.php
@@ -16,7 +16,7 @@ class TreeTest extends \PHPUnit\Framework\TestCase
/**
* @var \Magento\UrlRewrite\Block\Catalog\Category\Tree
*/
- private $_treeBlock;
+ private $treeBlock;
/**
* Set up
@@ -24,7 +24,7 @@ class TreeTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
parent::setUp();
- $this->_treeBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+ $this->treeBlock = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\View\LayoutInterface::class
)->createBlock(
\Magento\UrlRewrite\Block\Catalog\Category\Tree::class
@@ -39,7 +39,7 @@ protected function setUp()
*/
public function testGetTreeArray()
{
- $tree = $this->_treeBlock->getTreeArray();
+ $tree = $this->treeBlock->getTreeArray();
$this->assertEquals(false, $tree['is_active']);
$this->assertEquals('Root', (string)$tree['name']);
$this->assertEquals(true, $tree['expanded']);
@@ -54,13 +54,12 @@ public function testGetTreeArray()
*/
public function testGetTreeArrayApostropheReplaced()
{
- $this->markTestSkipped('To be fixed in MAGETWO-91166');
- $tree = $this->_treeBlock->getTreeArray();
+ $tree = $this->treeBlock->getTreeArray(523);
- $this->assertNotContains('\'', $tree['children'][0]['children'][0]['children'][0]['name']);
+ $this->assertNotContains('\'', $tree[0]['name']);
$this->assertEquals(
''Category 6'',
- $tree['children'][0]['children'][0]['children'][0]['name']
+ $tree[0]['name']
);
}
@@ -72,13 +71,12 @@ public function testGetTreeArrayApostropheReplaced()
*/
public function testGetTreeArrayDoubleQuotesReplaced()
{
- $this->markTestSkipped('To be fixed in MAGETWO-91166');
- $tree = $this->_treeBlock->getTreeArray();
+ $tree = $this->treeBlock->getTreeArray(523);
- $this->assertNotContains('\"', $tree['children'][0]['children'][0]['children'][0]['name']);
+ $this->assertNotContains('\"', $tree[0]['name']);
$this->assertEquals(
'"Category 6"',
- $tree['children'][0]['children'][0]['children'][0]['name']
+ $tree[0]['name']
);
}
@@ -90,7 +88,7 @@ public function testGetLoadTreeUrl()
$row = new \Magento\Framework\DataObject(['id' => 1]);
$this->assertStringStartsWith(
'http://localhost/index.php',
- $this->_treeBlock->getLoadTreeUrl($row),
+ $this->treeBlock->getLoadTreeUrl($row),
'Tree load URL is invalid'
);
}
@@ -100,7 +98,7 @@ public function testGetLoadTreeUrl()
*/
public function testGetCategoryCollection()
{
- $collection = $this->_treeBlock->getCategoryCollection();
+ $collection = $this->treeBlock->getCategoryCollection();
$this->assertInstanceOf(\Magento\Catalog\Model\ResourceModel\Category\Collection::class, $collection);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Vault/_files/token.php b/dev/tests/integration/testsuite/Magento/Vault/_files/token.php
index 396b2a5c20536..e1e0a31da4f5f 100644
--- a/dev/tests/integration/testsuite/Magento/Vault/_files/token.php
+++ b/dev/tests/integration/testsuite/Magento/Vault/_files/token.php
@@ -23,4 +23,4 @@
/** @var PaymentTokenRepository $tokenRepository */
$tokenRepository = $objectManager->create(PaymentTokenRepository::class);
-$tokenRepository->save($token);
+$token = $tokenRepository->save($token);
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php
index 48cc6cea49156..4999e379e1d0a 100644
--- a/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/Controller/IndexTest.php
@@ -122,6 +122,7 @@ public function testAddActionProductNameXss()
}
/**
+ * @magentoDbIsolation disabled
* @magentoDataFixture Magento/Wishlist/_files/wishlist_with_product_qty_increments.php
*/
public function testAllcartAction()
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php b/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php
index 99f9aa4991b5e..b684da05dd254 100644
--- a/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/Model/WishlistTest.php
@@ -6,6 +6,7 @@
namespace Magento\Wishlist\Model;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product\Attribute\Source\Status as ProductStatus;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject;
@@ -85,4 +86,39 @@ public function testAddNewItemInvalidWishlistItemConfiguration()
);
$this->wishlist->addNewItem($product);
}
+
+ /**
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/Wishlist/_files/wishlist.php
+ */
+ public function testGetItemCollection()
+ {
+ $productSku = 'simple';
+ $customerId = 1;
+
+ $this->wishlist->loadByCustomerId($customerId, true);
+ $itemCollection = $this->wishlist->getItemCollection();
+ /** @var \Magento\Wishlist\Model\Item $item */
+ $item = $itemCollection->getFirstItem();
+ $this->assertEquals($productSku, $item->getProduct()->getSku());
+ }
+
+ /**
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/Wishlist/_files/wishlist.php
+ */
+ public function testGetItemCollectionWithDisabledProduct()
+ {
+ $productSku = 'simple';
+ $customerId = 1;
+
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $product = $productRepository->get($productSku);
+ $product->setStatus(ProductStatus::STATUS_DISABLED);
+ $productRepository->save($product);
+
+ $this->wishlist->loadByCustomerId($customerId, true);
+ $itemCollection = $this->wishlist->getItemCollection();
+ $this->assertEmpty($itemCollection->getItems());
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_rollback.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_rollback.php
new file mode 100644
index 0000000000000..6b1afb6ffa509
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_rollback.php
@@ -0,0 +1,24 @@
+get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
+$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
+$wishlist->loadByCustomerId(1);
+$wishlist->delete();
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_rollback.php';
+require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';
diff --git a/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments_rollback.php b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments_rollback.php
new file mode 100644
index 0000000000000..15e23f0e31b56
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Wishlist/_files/wishlist_with_product_qty_increments_rollback.php
@@ -0,0 +1,24 @@
+get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var \Magento\Wishlist\Model\Wishlist $wishlist */
+$wishlist = $objectManager->create(\Magento\Wishlist\Model\Wishlist::class);
+$wishlist->loadByCustomerId(1);
+$wishlist->delete();
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require __DIR__ . '/../../../Magento/Catalog/_files/product_special_price_rollback.php';
+require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js
index 44f06279dcbef..91cb4480039d1 100644
--- a/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Checkout/frontend/js/model/cart/totals-processor/default.test.js
@@ -106,6 +106,8 @@ define([
});
it('estimateTotals if data wasn\'t cached and request was successfully sent', function () {
+ var deferral = new $.Deferred();
+
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'isChanged').and.returnValue(true);
spyOn(mocks['Magento_Customer/js/customer-data'], 'get').and.returnValue(
ko.observable({
@@ -117,9 +119,9 @@ define([
data.shippingMethodCode = mocks['Magento_Checkout/js/model/quote'].shippingMethod()['method_code'];
data.shippingCarrierCode = mocks['Magento_Checkout/js/model/quote'].shippingMethod()['carrier_code'];
- return new $.Deferred().resolve(result);
+ return deferral.resolve(result);
});
- expect(defaultProcessor.estimateTotals(address)).toBeUndefined();
+ expect(defaultProcessor.estimateTotals(address)).toBe(deferral);
expect(mocks['Magento_Checkout/js/model/quote'].setTotals).toHaveBeenCalledWith(totals);
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(0)[0]).toBe(true);
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(1)[0]).toBe(false);
@@ -129,6 +131,8 @@ define([
});
it('estimateTotals if data wasn\'t cached and request returns error', function () {
+ var deferral = new $.Deferred();
+
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'isChanged').and.returnValue(true);
spyOn(mocks['Magento_Customer/js/customer-data'], 'get').and.returnValue(
ko.observable({
@@ -137,9 +141,9 @@ define([
);
spyOn(mocks['Magento_Checkout/js/model/cart/cache'], 'get');
spyOn(mocks['mage/storage'], 'post').and.callFake(function () {
- return new $.Deferred().reject('Error Message');
+ return deferral.reject('Error Message');
});
- expect(defaultProcessor.estimateTotals(address)).toBeUndefined();
+ expect(defaultProcessor.estimateTotals(address)).toBe(deferral);
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(0)[0]).toBe(true);
expect(mocks['Magento_Checkout/js/model/totals'].isLoading.calls.argsFor(1)[0]).toBe(false);
expect(mocks['mage/storage'].post).toHaveBeenCalled();
diff --git a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js
index 5d90d6088ba90..19b4baaff05ae 100644
--- a/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js
+++ b/dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/validation/rules.test.js
@@ -15,7 +15,7 @@ define([
var value = '',
params = [1,3];
- expect(rules['range-words'].handler(value, params)).toBe(false);
+ expect(rules['range-words'].handler(value, params)).toBe(true);
});
it('Check on redundant words', function () {
diff --git a/dev/tests/static/testsuite/Magento/Test/Less/_files/blacklist/old.txt b/dev/tests/static/testsuite/Magento/Test/Less/_files/blacklist/old.txt
index db5c1cab06655..70764344de69b 100644
--- a/dev/tests/static/testsuite/Magento/Test/Less/_files/blacklist/old.txt
+++ b/dev/tests/static/testsuite/Magento/Test/Less/_files/blacklist/old.txt
@@ -23,3 +23,4 @@ app/design/adminhtml/Magento/backend/web/mui/clearless/_sprites.less
app/design/adminhtml/Magento/backend/web/mui/styles/_abstract.less
app/design/adminhtml/Magento/backend/web/mui/styles/_table.less
app/design/adminhtml/Magento/backend/web/mui/styles/_vars.less
+app/design/frontend/Magento/blank/web/css/source/_email-base.less
diff --git a/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php b/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php
index 3ea43cbccd24f..99dd972dc26ea 100644
--- a/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php
+++ b/lib/internal/Magento/Framework/Api/AbstractExtensibleObject.php
@@ -74,7 +74,7 @@ public function getCustomAttribute($attributeCode)
*/
public function getCustomAttributes()
{
- return isset($this->_data[self::CUSTOM_ATTRIBUTES]) ? $this->_data[self::CUSTOM_ATTRIBUTES] : [];
+ return $this->_data[self::CUSTOM_ATTRIBUTES] ?? [];
}
/**
@@ -129,7 +129,7 @@ public function setCustomAttribute($attributeCode, $attributeValue)
*/
protected function getCustomAttributesCodes()
{
- return isset($this->customAttributesCodes) ? $this->customAttributesCodes : [];
+ return $this->customAttributesCodes ?? [];
}
/**
diff --git a/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php b/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php
index b907246139d42..9cc0ddab3bfcb 100644
--- a/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php
+++ b/lib/internal/Magento/Framework/Api/AbstractSimpleObject.php
@@ -34,7 +34,7 @@ public function __construct(array $data = [])
*/
protected function _get($key)
{
- return isset($this->_data[$key]) ? $this->_data[$key] : null;
+ return $this->_data[$key] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Api/ImageProcessor.php b/lib/internal/Magento/Framework/Api/ImageProcessor.php
index e2c5f8c4083b9..4642a742576df 100644
--- a/lib/internal/Magento/Framework/Api/ImageProcessor.php
+++ b/lib/internal/Magento/Framework/Api/ImageProcessor.php
@@ -172,7 +172,7 @@ public function processImageContent($entityType, $imageContent)
*/
protected function getMimeTypeExtension($mimeType)
{
- return isset($this->mimeTypeExtensionMap[$mimeType]) ? $this->mimeTypeExtensionMap[$mimeType] : '';
+ return $this->mimeTypeExtensionMap[$mimeType] ?? '';
}
/**
diff --git a/lib/internal/Magento/Framework/Api/Search/Document.php b/lib/internal/Magento/Framework/Api/Search/Document.php
index d60458a6e5585..7454fa7974ece 100644
--- a/lib/internal/Magento/Framework/Api/Search/Document.php
+++ b/lib/internal/Magento/Framework/Api/Search/Document.php
@@ -33,9 +33,7 @@ public function setId($id)
*/
public function getCustomAttribute($attributeCode)
{
- return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode])
- ? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]
- : null;
+ return $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php b/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php
index b663a3a2f733c..e127dfd4b1624 100644
--- a/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php
+++ b/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/FilterProcessor.php
@@ -114,6 +114,6 @@ private function getCustomFilterForField($field)
*/
private function getFieldMapping($field)
{
- return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
+ return $this->fieldMapping[$field] ?? $field;
}
}
diff --git a/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/JoinProcessor.php b/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/JoinProcessor.php
index b8e52334bee1f..207325042c737 100644
--- a/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/JoinProcessor.php
+++ b/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/JoinProcessor.php
@@ -121,6 +121,6 @@ private function getCustomJoin($field)
*/
private function getFieldMapping($field)
{
- return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
+ return $this->fieldMapping[$field] ?? $field;
}
}
diff --git a/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php b/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php
index 7598c4eb4abdc..9c18b8c1a9ae5 100644
--- a/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php
+++ b/lib/internal/Magento/Framework/Api/SearchCriteria/CollectionProcessor/SortingProcessor.php
@@ -59,7 +59,7 @@ public function process(SearchCriteriaInterface $searchCriteria, AbstractDb $col
*/
private function getFieldMapping($field)
{
- return isset($this->fieldMapping[$field]) ? $this->fieldMapping[$field] : $field;
+ return $this->fieldMapping[$field] ?? $field;
}
/**
diff --git a/lib/internal/Magento/Framework/App/ActionFlag.php b/lib/internal/Magento/Framework/App/ActionFlag.php
index 657c2ede9262d..55201504c968f 100644
--- a/lib/internal/Magento/Framework/App/ActionFlag.php
+++ b/lib/internal/Magento/Framework/App/ActionFlag.php
@@ -65,9 +65,7 @@ public function get($action, $flag = '')
$action = $this->_request->getActionName();
}
if ('' === $flag) {
- return isset(
- $this->_flags[$this->_getControllerKey()]
- ) ? $this->_flags[$this->_getControllerKey()] : [];
+ return $this->_flags[$this->_getControllerKey()] ?? [];
} elseif (isset($this->_flags[$this->_getControllerKey()][$action][$flag])) {
return $this->_flags[$this->_getControllerKey()][$action][$flag];
} else {
diff --git a/lib/internal/Magento/Framework/App/AreaList.php b/lib/internal/Magento/Framework/App/AreaList.php
index 7c123f7ff9d60..fb28d09d5fe09 100644
--- a/lib/internal/Magento/Framework/App/AreaList.php
+++ b/lib/internal/Magento/Framework/App/AreaList.php
@@ -88,7 +88,7 @@ public function getCodeByFrontName($frontName)
*/
public function getFrontName($areaCode)
{
- return isset($this->_areas[$areaCode]['frontName']) ? $this->_areas[$areaCode]['frontName'] : null;
+ return $this->_areas[$areaCode]['frontName'] ?? null;
}
/**
@@ -111,7 +111,7 @@ public function getCodes()
*/
public function getDefaultRouter($areaCode)
{
- return isset($this->_areas[$areaCode]['router']) ? $this->_areas[$areaCode]['router'] : null;
+ return $this->_areas[$areaCode]['router'] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/App/Config/Initial.php b/lib/internal/Magento/Framework/App/Config/Initial.php
index 1933682346ad3..b65c9a2f53489 100644
--- a/lib/internal/Magento/Framework/App/Config/Initial.php
+++ b/lib/internal/Magento/Framework/App/Config/Initial.php
@@ -72,9 +72,9 @@ public function getData($scope)
list($scopeType, $scopeCode) = array_pad(explode('|', $scope), 2, null);
if (ScopeConfigInterface::SCOPE_TYPE_DEFAULT == $scopeType) {
- return isset($this->_data[$scopeType]) ? $this->_data[$scopeType] : [];
+ return $this->_data[$scopeType] ?? [];
} elseif ($scopeCode) {
- return isset($this->_data[$scopeType][$scopeCode]) ? $this->_data[$scopeType][$scopeCode] : [];
+ return $this->_data[$scopeType][$scopeCode] ?? [];
}
return [];
}
diff --git a/lib/internal/Magento/Framework/App/DefaultPath/DefaultPath.php b/lib/internal/Magento/Framework/App/DefaultPath/DefaultPath.php
index 61d0aa138f9a4..8a4188aed9605 100644
--- a/lib/internal/Magento/Framework/App/DefaultPath/DefaultPath.php
+++ b/lib/internal/Magento/Framework/App/DefaultPath/DefaultPath.php
@@ -32,6 +32,6 @@ public function __construct(array $parts)
*/
public function getPart($code)
{
- return isset($this->_parts[$code]) ? $this->_parts[$code] : null;
+ return $this->_parts[$code] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/App/DeploymentConfig.php b/lib/internal/Magento/Framework/App/DeploymentConfig.php
index 92bb3fdbbc54f..615c295675adc 100644
--- a/lib/internal/Magento/Framework/App/DeploymentConfig.php
+++ b/lib/internal/Magento/Framework/App/DeploymentConfig.php
@@ -70,7 +70,7 @@ public function get($key = null, $defaultValue = null)
if ($key === null) {
return $this->flatData;
}
- return isset($this->flatData[$key]) ? $this->flatData[$key] : $defaultValue;
+ return $this->flatData[$key] ?? $defaultValue;
}
/**
diff --git a/lib/internal/Magento/Framework/App/Http/Context.php b/lib/internal/Magento/Framework/App/Http/Context.php
index a5eba2753b510..79a15110234cd 100644
--- a/lib/internal/Magento/Framework/App/Http/Context.php
+++ b/lib/internal/Magento/Framework/App/Http/Context.php
@@ -84,9 +84,7 @@ public function unsValue($name)
*/
public function getValue($name)
{
- return isset($this->data[$name])
- ? $this->data[$name]
- : (isset($this->default[$name]) ? $this->default[$name] : null);
+ return $this->data[$name] ?? ($this->default[$name] ?? null);
}
/**
diff --git a/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php b/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php
index 979ea1c429590..19a89681a2d5f 100644
--- a/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php
+++ b/lib/internal/Magento/Framework/App/Response/Http/FileFactory.php
@@ -59,6 +59,7 @@ public function create(
$dir = $this->_filesystem->getDirectoryWrite($baseDir);
$isFile = false;
$file = null;
+ $fileContent = $this->getFileContent($content);
if (is_array($content)) {
if (!isset($content['type']) || !isset($content['value'])) {
throw new \InvalidArgumentException("Invalid arguments. Keys 'type' and 'value' are required.");
@@ -76,7 +77,7 @@ public function create(
->setHeader('Pragma', 'public', true)
->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)
->setHeader('Content-type', $contentType, true)
- ->setHeader('Content-Length', $contentLength === null ? strlen($content) : $contentLength, true)
+ ->setHeader('Content-Length', $contentLength === null ? strlen($fileContent) : $contentLength, true)
->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"', true)
->setHeader('Last-Modified', date('r'), true);
@@ -88,7 +89,8 @@ public function create(
echo $stream->read(1024);
}
} else {
- $dir->writeFile($fileName, $content);
+ $dir->writeFile($fileName, $fileContent);
+ $file = $fileName;
$stream = $dir->openFile($fileName, 'r');
while (!$stream->eof()) {
echo $stream->read(1024);
@@ -102,4 +104,19 @@ public function create(
}
return $this->_response;
}
+
+ /**
+ * Returns file content for writing.
+ *
+ * @param string|array $content
+ * @return string|array
+ */
+ private function getFileContent($content)
+ {
+ if (isset($content['type']) && $content['type'] === 'string') {
+ return $content['value'];
+ }
+
+ return $content;
+ }
}
diff --git a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
index 9c746177d6f7d..88b2995179d4d 100644
--- a/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
+++ b/lib/internal/Magento/Framework/Component/ComponentRegistrar.php
@@ -68,7 +68,7 @@ public function getPaths($type)
public function getPath($type, $componentName)
{
self::validateType($type);
- return isset(self::$paths[$type][$componentName]) ? self::$paths[$type][$componentName] : null;
+ return self::$paths[$type][$componentName] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Config/View.php b/lib/internal/Magento/Framework/Config/View.php
index ef9c39e221e86..05863caeec2b6 100644
--- a/lib/internal/Magento/Framework/Config/View.php
+++ b/lib/internal/Magento/Framework/Config/View.php
@@ -71,7 +71,7 @@ public function __construct(
public function getVars($module)
{
$this->initData();
- return isset($this->data['vars'][$module]) ? $this->data['vars'][$module] : [];
+ return $this->data['vars'][$module] ?? [];
}
/**
@@ -110,7 +110,7 @@ public function getVarValue($module, $var)
public function getMediaEntities($module, $mediaType)
{
$this->initData();
- return isset($this->data['media'][$module][$mediaType]) ? $this->data['media'][$module][$mediaType] : [];
+ return $this->data['media'][$module][$mediaType] ?? [];
}
/**
@@ -124,9 +124,7 @@ public function getMediaEntities($module, $mediaType)
public function getMediaAttributes($module, $mediaType, $mediaId)
{
$this->initData();
- return isset($this->data['media'][$module][$mediaType][$mediaId])
- ? $this->data['media'][$module][$mediaType][$mediaId]
- : [];
+ return $this->data['media'][$module][$mediaType][$mediaId] ?? [];
}
/**
@@ -163,7 +161,7 @@ protected function getIdAttributes()
public function getExcludedFiles()
{
$items = $this->getItems();
- return isset($items['file']) ? $items['file'] : [];
+ return $items['file'] ?? [];
}
/**
@@ -174,7 +172,7 @@ public function getExcludedFiles()
public function getExcludedDir()
{
$items = $this->getItems();
- return isset($items['directory']) ? $items['directory'] : [];
+ return $items['directory'] ?? [];
}
/**
@@ -185,7 +183,7 @@ public function getExcludedDir()
protected function getItems()
{
$this->initData();
- return isset($this->data['exclude']) ? $this->data['exclude'] : [];
+ return $this->data['exclude'] ?? [];
}
/**
diff --git a/lib/internal/Magento/Framework/Config/etc/view.xsd b/lib/internal/Magento/Framework/Config/etc/view.xsd
index 20b6a7d4fbfd2..b908862b02147 100644
--- a/lib/internal/Magento/Framework/Config/etc/view.xsd
+++ b/lib/internal/Magento/Framework/Config/etc/view.xsd
@@ -49,13 +49,13 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
diff --git a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
index 2274fde82b818..1449d6d2a6456 100644
--- a/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
+++ b/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php
@@ -483,7 +483,7 @@ public function rawFetchRow($sql, $field = null)
if (empty($field)) {
return $row;
} else {
- return isset($row[$field]) ? $row[$field] : false;
+ return $row[$field] ?? false;
}
}
diff --git a/lib/internal/Magento/Framework/DB/Select/OrderRenderer.php b/lib/internal/Magento/Framework/DB/Select/OrderRenderer.php
index 36a075b9af8c9..dfe9c8949c353 100644
--- a/lib/internal/Magento/Framework/DB/Select/OrderRenderer.php
+++ b/lib/internal/Magento/Framework/DB/Select/OrderRenderer.php
@@ -40,12 +40,12 @@ public function render(Select $select, $sql = '')
$order = [];
foreach ($select->getPart(Select::ORDER) as $term) {
if (is_array($term)) {
- if (is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
+ if (is_numeric($term[0]) && (string)(int)$term[0] == $term[0]) {
$order[] = (int)trim($term[0]) . ' ' . $term[1];
} else {
$order[] = $this->quote->quoteIdentifier($term[0]) . ' ' . $term[1];
}
- } elseif (is_numeric($term) && strval(intval($term)) == $term) {
+ } elseif (is_numeric($term) && (string)(int)$term == $term) {
$order[] = (int)trim($term);
} else {
$order[] = $this->quote->quoteIdentifier($term);
diff --git a/lib/internal/Magento/Framework/Data/AbstractCriteria.php b/lib/internal/Magento/Framework/Data/AbstractCriteria.php
index c90ed2b03bf3d..d4811b79980a9 100644
--- a/lib/internal/Magento/Framework/Data/AbstractCriteria.php
+++ b/lib/internal/Magento/Framework/Data/AbstractCriteria.php
@@ -274,7 +274,7 @@ public function getLimit()
*/
public function getPart($name, $default = null)
{
- return isset($this->data[$name]) ? $this->data[$name] : $default;
+ return $this->data[$name] ?? $default;
}
/**
diff --git a/lib/internal/Magento/Framework/Data/AbstractDataObject.php b/lib/internal/Magento/Framework/Data/AbstractDataObject.php
index 5916100ffbbfa..da04fecc447cc 100644
--- a/lib/internal/Magento/Framework/Data/AbstractDataObject.php
+++ b/lib/internal/Magento/Framework/Data/AbstractDataObject.php
@@ -50,6 +50,6 @@ public function toArray()
*/
protected function get($key)
{
- return isset($this->data[$key]) ? $this->data[$key] : null;
+ return $this->data[$key] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/Data/Collection.php b/lib/internal/Magento/Framework/Data/Collection.php
index f8b82d3122234..71ec8c1aa8379 100644
--- a/lib/internal/Magento/Framework/Data/Collection.php
+++ b/lib/internal/Magento/Framework/Data/Collection.php
@@ -851,7 +851,7 @@ public function count()
*/
public function getFlag($flag)
{
- return isset($this->_flags[$flag]) ? $this->_flags[$flag] : null;
+ return $this->_flags[$flag] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php b/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php
index 3048be4d5dc1b..2a68432207b23 100644
--- a/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php
+++ b/lib/internal/Magento/Framework/Data/Form/Element/Checkboxes.php
@@ -121,13 +121,13 @@ public function getChecked($value)
return;
}
if (!is_array($checked)) {
- $checked = [strval($checked)];
+ $checked = [(string)$checked];
} else {
foreach ($checked as $k => $v) {
- $checked[$k] = strval($v);
+ $checked[$k] = (string)$v;
}
}
- if (in_array(strval($value), $checked)) {
+ if (in_array((string)$value, $checked)) {
return 'checked';
}
return;
@@ -141,13 +141,13 @@ public function getDisabled($value)
{
if ($disabled = $this->getData('disabled')) {
if (!is_array($disabled)) {
- $disabled = [strval($disabled)];
+ $disabled = [(string)$disabled];
} else {
foreach ($disabled as $k => $v) {
- $disabled[$k] = strval($v);
+ $disabled[$k] = (string)$v;
}
}
- if (in_array(strval($value), $disabled)) {
+ if (in_array((string)$value, $disabled)) {
return 'disabled';
}
}
diff --git a/lib/internal/Magento/Framework/Data/Structure.php b/lib/internal/Magento/Framework/Data/Structure.php
index 9d540e8a49f08..a977d3448ec26 100644
--- a/lib/internal/Magento/Framework/Data/Structure.php
+++ b/lib/internal/Magento/Framework/Data/Structure.php
@@ -166,7 +166,7 @@ public function createElement($elementId, array $data)
*/
public function getElement($elementId)
{
- return isset($this->_elements[$elementId]) ? $this->_elements[$elementId] : false;
+ return $this->_elements[$elementId] ?? false;
}
/**
@@ -456,9 +456,7 @@ public function getChildId($parentId, $alias)
*/
public function getChildren($parentId)
{
- return isset(
- $this->_elements[$parentId][self::CHILDREN]
- ) ? $this->_elements[$parentId][self::CHILDREN] : [];
+ return $this->_elements[$parentId][self::CHILDREN] ?? [];
}
/**
@@ -469,7 +467,7 @@ public function getChildren($parentId)
*/
public function getParentId($childId)
{
- return isset($this->_elements[$childId][self::PARENT]) ? $this->_elements[$childId][self::PARENT] : false;
+ return $this->_elements[$childId][self::PARENT] ?? false;
}
/**
diff --git a/lib/internal/Magento/Framework/Event.php b/lib/internal/Magento/Framework/Event.php
index 4c116d0a33629..c7b15a8eb0722 100644
--- a/lib/internal/Magento/Framework/Event.php
+++ b/lib/internal/Magento/Framework/Event.php
@@ -88,7 +88,7 @@ public function dispatch()
*/
public function getName()
{
- return isset($this->_data['name']) ? $this->_data['name'] : null;
+ return $this->_data['name'] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Filesystem/Io/File.php b/lib/internal/Magento/Framework/Filesystem/Io/File.php
index 60a94d5b430e9..2e724260ff543 100644
--- a/lib/internal/Magento/Framework/Filesystem/Io/File.php
+++ b/lib/internal/Magento/Framework/Filesystem/Io/File.php
@@ -228,7 +228,7 @@ public function streamStat($part = null, $default = null)
}
$stat = @fstat($this->_streamHandler);
if ($part !== null) {
- return isset($stat[$part]) ? $stat[$part] : $default;
+ return $stat[$part] ?? $default;
}
return $stat;
}
diff --git a/lib/internal/Magento/Framework/Filter/AbstractFactory.php b/lib/internal/Magento/Framework/Filter/AbstractFactory.php
index 2a0ae0ba15e42..c30b07aa09061 100644
--- a/lib/internal/Magento/Framework/Filter/AbstractFactory.php
+++ b/lib/internal/Magento/Framework/Filter/AbstractFactory.php
@@ -68,7 +68,7 @@ public function canCreateFilter($alias)
*/
public function isShared($class)
{
- return isset($this->shared[$class]) ? $this->shared[$class] : $this->shareByDefault;
+ return $this->shared[$class] ?? $this->shareByDefault;
}
/**
diff --git a/lib/internal/Magento/Framework/Filter/Factory.php b/lib/internal/Magento/Framework/Filter/Factory.php
index a5e5978a83f06..dbe037ecbbbd1 100644
--- a/lib/internal/Magento/Framework/Filter/Factory.php
+++ b/lib/internal/Magento/Framework/Filter/Factory.php
@@ -32,6 +32,7 @@ class Factory extends AbstractFactory
'decrypt' => \Magento\Framework\Filter\Decrypt::class,
'translit' => \Magento\Framework\Filter\Translit::class,
'translitUrl' => \Magento\Framework\Filter\TranslitUrl::class,
+ 'truncateFilter' => \Magento\Framework\Filter\TruncateFilter::class,
];
/**
diff --git a/lib/internal/Magento/Framework/Filter/FilterManager.php b/lib/internal/Magento/Framework/Filter/FilterManager.php
index 52c9d017ad11c..ca5d998af833f 100644
--- a/lib/internal/Magento/Framework/Filter/FilterManager.php
+++ b/lib/internal/Magento/Framework/Filter/FilterManager.php
@@ -21,6 +21,7 @@
* @method string removeTags(string $value, $params = array())
* @method string stripTags(string $value, $params = array())
* @method string truncate(string $value, $params = array())
+ * @method string truncateFilter(string $value, $params = array())
* @method string encrypt(string $value, $params = array())
* @method string decrypt(string $value, $params = array())
* @method string translit(string $value)
diff --git a/lib/internal/Magento/Framework/Filter/Input.php b/lib/internal/Magento/Framework/Filter/Input.php
index 39c7a54786edb..6da748fcbeb9f 100644
--- a/lib/internal/Magento/Framework/Filter/Input.php
+++ b/lib/internal/Magento/Framework/Filter/Input.php
@@ -183,7 +183,7 @@ public function getFilters($name = null)
if (null === $name) {
return $this->_filters;
} else {
- return isset($this->_filters[$name]) ? $this->_filters[$name] : null;
+ return $this->_filters[$name] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/Filter/Translit.php b/lib/internal/Magento/Framework/Filter/Translit.php
index 7a84a6e33af18..a6162aa7a7fff 100644
--- a/lib/internal/Magento/Framework/Filter/Translit.php
+++ b/lib/internal/Magento/Framework/Filter/Translit.php
@@ -409,7 +409,7 @@ public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $
$convertConfig = $config->getValue('url/convert', 'default');
if ($convertConfig) {
foreach ($convertConfig as $configValue) {
- $this->convertTable[strval($configValue['from'])] = strval($configValue['to']);
+ $this->convertTable[(string)$configValue['from']] = (string)$configValue['to'];
}
}
}
diff --git a/lib/internal/Magento/Framework/Filter/Truncate.php b/lib/internal/Magento/Framework/Filter/Truncate.php
index fd4fbe9910427..a4dd35b302705 100644
--- a/lib/internal/Magento/Framework/Filter/Truncate.php
+++ b/lib/internal/Magento/Framework/Filter/Truncate.php
@@ -10,6 +10,9 @@
*
* Truncate a string to a certain length if necessary, appending the $etc string.
* $remainder will contain the string that has been replaced with $etc.
+ *
+ * @deprecated
+ * @see \Magento\Framework\Filter\TruncateFilter
*/
class Truncate implements \Zend_Filter_Interface
{
diff --git a/lib/internal/Magento/Framework/Filter/TruncateFilter.php b/lib/internal/Magento/Framework/Filter/TruncateFilter.php
new file mode 100644
index 0000000000000..c8667a7d49f26
--- /dev/null
+++ b/lib/internal/Magento/Framework/Filter/TruncateFilter.php
@@ -0,0 +1,111 @@
+stringUtils = $stringUtils;
+ $this->resultFactory = $resultFactory;
+ $this->length = $length;
+ $this->etc = $etc;
+ $this->breakWords = $breakWords;
+ }
+
+ /**
+ * Filter value
+ *
+ * @param mixed $string
+ * @return Result
+ */
+ public function filter($string) : Result
+ {
+ /** @var Result $result */
+ $result = $this->resultFactory->create(['value' => $string, 'remainder' => '']);
+ $length = $this->length;
+ if (0 == $length) {
+ $result->setValue('');
+
+ return $result;
+ }
+
+ $originalLength = $this->stringUtils->strlen($string);
+ if ($originalLength > $length) {
+ $length -= $this->stringUtils->strlen($this->etc);
+ if ($length <= 0) {
+ $result->setValue('');
+
+ return $result;
+ }
+ $preparedString = $string;
+ $preparedLength = $length;
+ if (!$this->breakWords) {
+ $preparedString = preg_replace(
+ '/\s+?(\S+)?$/u',
+ '',
+ $this->stringUtils->substr($string, 0, $length + 1)
+ );
+ $preparedLength = $this->stringUtils->strlen($preparedString);
+ }
+ $result->setRemainder($this->stringUtils->substr($string, $preparedLength, $originalLength));
+ $result->setValue($this->stringUtils->substr($preparedString, 0, $length) . $this->etc);
+
+ return $result;
+ }
+
+ return $result;
+ }
+}
diff --git a/lib/internal/Magento/Framework/Filter/TruncateFilter/Result.php b/lib/internal/Magento/Framework/Filter/TruncateFilter/Result.php
new file mode 100644
index 0000000000000..801ce355f5eb9
--- /dev/null
+++ b/lib/internal/Magento/Framework/Filter/TruncateFilter/Result.php
@@ -0,0 +1,76 @@
+value = $value;
+ $this->remainder = $remainder;
+ }
+
+ /**
+ * Set result value
+ *
+ * @param string $value
+ * @return void
+ */
+ public function setValue(string $value)
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * Get value
+ *
+ * @return string
+ */
+ public function getValue() : string
+ {
+ return $this->value;
+ }
+
+ /**
+ * Set remainder
+ *
+ * @param string $remainder
+ * @return void
+ */
+ public function setRemainder(string $remainder)
+ {
+ $this->remainder = $remainder;
+ }
+
+ /**
+ * Get remainder
+ *
+ * @return string
+ */
+ public function getRemainder() : string
+ {
+ return $this->remainder;
+ }
+}
diff --git a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php
index 489755a2846fc..718b08190d8be 100644
--- a/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php
+++ b/lib/internal/Magento/Framework/Interception/PluginList/PluginList.php
@@ -268,7 +268,7 @@ public function getNext($type, $method, $code = '__self')
$this->_inheritPlugins($type);
}
$key = $type . '_' . lcfirst($method) . '_' . $code;
- return isset($this->_processed[$key]) ? $this->_processed[$key] : null;
+ return $this->_processed[$key] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Message/Collection.php b/lib/internal/Magento/Framework/Message/Collection.php
index fb8351c5a04ba..b1e3088a703f7 100644
--- a/lib/internal/Magento/Framework/Message/Collection.php
+++ b/lib/internal/Magento/Framework/Message/Collection.php
@@ -142,7 +142,7 @@ public function getItems()
*/
public function getItemsByType($type)
{
- return isset($this->messages[$type]) ? $this->messages[$type] : [];
+ return $this->messages[$type] ?? [];
}
/**
diff --git a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php
index db919c80e251c..5963f5f942374 100644
--- a/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php
+++ b/lib/internal/Magento/Framework/Model/AbstractExtensibleModel.php
@@ -151,9 +151,7 @@ public function getCustomAttributes()
public function getCustomAttribute($attributeCode)
{
$this->initializeCustomAttributes();
- return isset($this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode])
- ? $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]
- : null;
+ return $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Module/FullModuleList.php b/lib/internal/Magento/Framework/Module/FullModuleList.php
index 5ad5b05a413ef..c6e403dee0898 100644
--- a/lib/internal/Magento/Framework/Module/FullModuleList.php
+++ b/lib/internal/Magento/Framework/Module/FullModuleList.php
@@ -55,7 +55,7 @@ public function getAll()
public function getOne($name)
{
$data = $this->getAll();
- return isset($data[$name]) ? $data[$name] : null;
+ return $data[$name] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Module/ModuleList.php b/lib/internal/Magento/Framework/Module/ModuleList.php
index 406aa9efd31a0..6ee061cffb3d0 100644
--- a/lib/internal/Magento/Framework/Module/ModuleList.php
+++ b/lib/internal/Magento/Framework/Module/ModuleList.php
@@ -90,7 +90,7 @@ public function getAll()
public function getOne($name)
{
$enabled = $this->getAll();
- return isset($enabled[$name]) ? $enabled[$name] : null;
+ return $enabled[$name] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Module/ModuleResource.php b/lib/internal/Magento/Framework/Module/ModuleResource.php
index ed740d459060e..9f7ac2a1b393c 100644
--- a/lib/internal/Magento/Framework/Module/ModuleResource.php
+++ b/lib/internal/Magento/Framework/Module/ModuleResource.php
@@ -84,7 +84,7 @@ public function getDbVersion($moduleName)
return false;
}
$this->_loadVersion('db');
- return isset(self::$schemaVersions[$moduleName]) ? self::$schemaVersions[$moduleName] : false;
+ return self::$schemaVersions[$moduleName] ?? false;
}
/**
@@ -116,7 +116,7 @@ public function getDataVersion($moduleName)
return false;
}
$this->_loadVersion('data');
- return isset(self::$dataVersions[$moduleName]) ? self::$dataVersions[$moduleName] : false;
+ return self::$dataVersions[$moduleName] ?? false;
}
/**
diff --git a/lib/internal/Magento/Framework/Module/PackageInfo.php b/lib/internal/Magento/Framework/Module/PackageInfo.php
index 7edb0c04ebf98..0dce507ba26f4 100644
--- a/lib/internal/Magento/Framework/Module/PackageInfo.php
+++ b/lib/internal/Magento/Framework/Module/PackageInfo.php
@@ -283,6 +283,6 @@ public function getConflict($moduleName)
public function getVersion($moduleName)
{
$this->load();
- return isset($this->modulePackageVersionMap[$moduleName]) ? $this->modulePackageVersionMap[$moduleName] : '';
+ return $this->modulePackageVersionMap[$moduleName] ?? '';
}
}
diff --git a/lib/internal/Magento/Framework/Mview/View/Subscription.php b/lib/internal/Magento/Framework/Mview/View/Subscription.php
index 4f5c65c799be8..653d68502e384 100644
--- a/lib/internal/Magento/Framework/Mview/View/Subscription.php
+++ b/lib/internal/Magento/Framework/Mview/View/Subscription.php
@@ -202,10 +202,10 @@ protected function buildStatement($event, $changelog)
break;
case Trigger::EVENT_UPDATE:
+ $tableName = $this->resource->getTableName($this->getTableName());
$trigger = "INSERT IGNORE INTO %s (%s) VALUES (NEW.%s);";
-
- if ($this->connection->isTableExists($this->getTableName())
- && $describe = $this->connection->describeTable($this->getTableName())
+ if ($this->connection->isTableExists($tableName) &&
+ $describe = $this->connection->describeTable($tableName)
) {
$columnNames = array_column($describe, 'COLUMN_NAME');
$columnNames = array_diff($columnNames, $this->ignoredUpdateColumns);
@@ -213,7 +213,7 @@ protected function buildStatement($event, $changelog)
$columns = [];
foreach ($columnNames as $columnName) {
$columns[] = sprintf(
- 'NEW.%1$s != OLD.%1$s',
+ 'NEW.%1$s <=> OLD.%1$s',
$this->connection->quoteIdentifier($columnName)
);
}
diff --git a/lib/internal/Magento/Framework/Notification/MessageList.php b/lib/internal/Magento/Framework/Notification/MessageList.php
index 8fb91890b2ff0..ac753b48c8944 100644
--- a/lib/internal/Magento/Framework/Notification/MessageList.php
+++ b/lib/internal/Magento/Framework/Notification/MessageList.php
@@ -72,7 +72,7 @@ protected function _loadMessages()
public function getMessageByIdentity($identity)
{
$this->_loadMessages();
- return isset($this->_messages[$identity]) ? $this->_messages[$identity] : null;
+ return $this->_messages[$identity] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Polymorphous.php b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Polymorphous.php
index ebb7d76dcb63c..0c1a2128560f8 100644
--- a/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Polymorphous.php
+++ b/lib/internal/Magento/Framework/ObjectManager/Test/Unit/Factory/Fixture/Polymorphous.php
@@ -26,6 +26,6 @@ public function __construct()
*/
public function getArg($key)
{
- return isset($this->args[$key]) ? $this->args[$key] : null;
+ return $this->args[$key] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/Phrase/Renderer/Placeholder.php b/lib/internal/Magento/Framework/Phrase/Renderer/Placeholder.php
index 4ba8c747fa12c..fd1b0c18ead17 100644
--- a/lib/internal/Magento/Framework/Phrase/Renderer/Placeholder.php
+++ b/lib/internal/Magento/Framework/Phrase/Renderer/Placeholder.php
@@ -40,6 +40,6 @@ public function render(array $source, array $arguments)
*/
private function keyToPlaceholder($key)
{
- return '%' . (is_int($key) ? strval($key + 1) : $key);
+ return '%' . (is_int($key) ? (string)($key + 1) : $key);
}
}
diff --git a/lib/internal/Magento/Framework/Pricing/Amount/Base.php b/lib/internal/Magento/Framework/Pricing/Amount/Base.php
index 2664ccc54944c..d055819a4a126 100644
--- a/lib/internal/Magento/Framework/Pricing/Amount/Base.php
+++ b/lib/internal/Magento/Framework/Pricing/Amount/Base.php
@@ -105,9 +105,7 @@ public function getBaseAmount()
*/
public function getAdjustmentAmount($adjustmentCode)
{
- return isset($this->adjustmentAmounts[$adjustmentCode])
- ? $this->adjustmentAmounts[$adjustmentCode]
- : false;
+ return $this->adjustmentAmounts[$adjustmentCode] ?? false;
}
/**
diff --git a/lib/internal/Magento/Framework/Pricing/Price/Pool.php b/lib/internal/Magento/Framework/Pricing/Price/Pool.php
index b460113fc32c8..dfdd0c52681e1 100644
--- a/lib/internal/Magento/Framework/Pricing/Price/Pool.php
+++ b/lib/internal/Magento/Framework/Pricing/Price/Pool.php
@@ -141,6 +141,6 @@ public function offsetUnset($offset)
*/
public function offsetGet($offset)
{
- return isset($this->prices[$offset]) ? $this->prices[$offset] : null;
+ return $this->prices[$offset] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/Search/Response/Aggregation.php b/lib/internal/Magento/Framework/Search/Response/Aggregation.php
index 9cb7a364ff21c..ea72597c53034 100644
--- a/lib/internal/Magento/Framework/Search/Response/Aggregation.php
+++ b/lib/internal/Magento/Framework/Search/Response/Aggregation.php
@@ -47,7 +47,7 @@ public function getIterator()
*/
public function getBucket($bucketName)
{
- return isset($this->buckets[$bucketName]) ? $this->buckets[$bucketName] : null;
+ return $this->buckets[$bucketName] ?? null;
}
/**
diff --git a/lib/internal/Magento/Framework/Session/SessionManager.php b/lib/internal/Magento/Framework/Session/SessionManager.php
index ecf169cb0bc88..b855b05a38354 100644
--- a/lib/internal/Magento/Framework/Session/SessionManager.php
+++ b/lib/internal/Magento/Framework/Session/SessionManager.php
@@ -476,7 +476,7 @@ protected function _addHost()
*/
protected function _getHosts()
{
- return isset($_SESSION[self::HOST_KEY]) ? $_SESSION[self::HOST_KEY] : [];
+ return $_SESSION[self::HOST_KEY] ?? [];
}
/**
diff --git a/lib/internal/Magento/Framework/System/Ftp.php b/lib/internal/Magento/Framework/System/Ftp.php
index 4b6432a863ebe..8bf898965cbc3 100644
--- a/lib/internal/Magento/Framework/System/Ftp.php
+++ b/lib/internal/Magento/Framework/System/Ftp.php
@@ -105,6 +105,12 @@ public function validateConnectionString($string)
if ($data['scheme'] != 'ftp') {
throw new \Exception("Support for scheme unsupported: '{$data['scheme']}'");
}
+
+ // Decode user & password strings from URL
+ foreach (array_intersect(array_keys($data), ['user','pass']) as $key) {
+ $data[$key] = urldecode($data[$key]);
+ }
+
return $data;
}
diff --git a/lib/internal/Magento/Framework/Url.php b/lib/internal/Magento/Framework/Url.php
index 2982edaa4766f..5a02beb798ed0 100644
--- a/lib/internal/Magento/Framework/Url.php
+++ b/lib/internal/Magento/Framework/Url.php
@@ -1074,7 +1074,7 @@ function ($match) {
if ($match[1] == '?') {
return isset($match[3]) ? '?' : '';
} elseif ($match[1] == '&' || $match[1] == '&') {
- return isset($match[3]) ? $match[3] : '';
+ return $match[3] ?? '';
}
}
},
diff --git a/lib/internal/Magento/Framework/Validator/Exception.php b/lib/internal/Magento/Framework/Validator/Exception.php
index c70ecfabb52af..370f66c424b01 100644
--- a/lib/internal/Magento/Framework/Validator/Exception.php
+++ b/lib/internal/Magento/Framework/Validator/Exception.php
@@ -84,6 +84,6 @@ public function getMessages($type = '')
}
return $allMessages;
}
- return isset($this->messages[$type]) ? $this->messages[$type] : [];
+ return $this->messages[$type] ?? [];
}
}
diff --git a/lib/internal/Magento/Framework/View/Asset/PropertyGroup.php b/lib/internal/Magento/Framework/View/Asset/PropertyGroup.php
index ad86dfca47a25..4fe8f48d6b723 100644
--- a/lib/internal/Magento/Framework/View/Asset/PropertyGroup.php
+++ b/lib/internal/Magento/Framework/View/Asset/PropertyGroup.php
@@ -45,6 +45,6 @@ public function getProperties()
*/
public function getProperty($name)
{
- return isset($this->properties[$name]) ? $this->properties[$name] : null;
+ return $this->properties[$name] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/View/BlockPool.php b/lib/internal/Magento/Framework/View/BlockPool.php
index c50af9d5bbc5f..dff280057fdaf 100644
--- a/lib/internal/Magento/Framework/View/BlockPool.php
+++ b/lib/internal/Magento/Framework/View/BlockPool.php
@@ -72,6 +72,6 @@ public function get($name = null)
return $this->blocks;
}
- return isset($this->blocks[$name]) ? $this->blocks[$name] : null;
+ return $this->blocks[$name] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/View/DataSourcePool.php b/lib/internal/Magento/Framework/View/DataSourcePool.php
index 24bdb6639981b..94f4f1dceae97 100644
--- a/lib/internal/Magento/Framework/View/DataSourcePool.php
+++ b/lib/internal/Magento/Framework/View/DataSourcePool.php
@@ -80,7 +80,7 @@ public function get($name = null)
return $this->dataSources;
}
- return isset($this->dataSources[$name]) ? $this->dataSources[$name] : null;
+ return $this->dataSources[$name] ?? null;
}
/**
@@ -107,6 +107,6 @@ public function assign($dataName, $namespace, $alias)
*/
public function getNamespaceData($namespace)
{
- return isset($this->assignments[$namespace]) ? $this->assignments[$namespace] : [];
+ return $this->assignments[$namespace] ?? [];
}
}
diff --git a/lib/internal/Magento/Framework/View/Design/Theme/Validator.php b/lib/internal/Magento/Framework/View/Design/Theme/Validator.php
index 06c78e7125040..04e775d730b56 100644
--- a/lib/internal/Magento/Framework/View/Design/Theme/Validator.php
+++ b/lib/internal/Magento/Framework/View/Design/Theme/Validator.php
@@ -118,7 +118,7 @@ public function addDataValidators($dataKey, $validators)
public function getErrorMessages($dataKey = null)
{
if ($dataKey) {
- return isset($this->_errorMessages[$dataKey]) ? $this->_errorMessages[$dataKey] : [];
+ return $this->_errorMessages[$dataKey] ?? [];
}
return $this->_errorMessages;
}
diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php
index 4430d18db1e70..7312f7546df9b 100644
--- a/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php
+++ b/lib/internal/Magento/Framework/View/Element/UiComponent/Context.php
@@ -208,7 +208,7 @@ public function getFiltersParams()
public function getFilterParam($key, $defaultValue = null)
{
$filter = $this->getFiltersParams();
- return isset($filter[$key]) ? $filter[$key] : $defaultValue;
+ return $filter[$key] ?? $defaultValue;
}
/**
diff --git a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php
index b2288a47f8f83..baa4e94eed978 100644
--- a/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php
+++ b/lib/internal/Magento/Framework/View/Element/UiComponent/DataProvider/DataProvider.php
@@ -181,7 +181,7 @@ public function getMeta()
*/
public function getFieldSetMetaInfo($fieldSetName)
{
- return isset($this->meta[$fieldSetName]) ? $this->meta[$fieldSetName] : [];
+ return $this->meta[$fieldSetName] ?? [];
}
/**
@@ -190,7 +190,7 @@ public function getFieldSetMetaInfo($fieldSetName)
*/
public function getFieldsMetaInfo($fieldSetName)
{
- return isset($this->meta[$fieldSetName]['children']) ? $this->meta[$fieldSetName]['children'] : [];
+ return $this->meta[$fieldSetName]['children'] ?? [];
}
/**
@@ -200,9 +200,7 @@ public function getFieldsMetaInfo($fieldSetName)
*/
public function getFieldMetaInfo($fieldSetName, $fieldName)
{
- return isset($this->meta[$fieldSetName]['children'][$fieldName])
- ? $this->meta[$fieldSetName]['children'][$fieldName]
- : [];
+ return $this->meta[$fieldSetName]['children'][$fieldName] ?? [];
}
/**
@@ -291,7 +289,7 @@ public function getData()
*/
public function getConfigData()
{
- return isset($this->data['config']) ? $this->data['config'] : [];
+ return $this->data['config'] ?? [];
}
/**
diff --git a/lib/internal/Magento/Framework/View/Layout/Generic.php b/lib/internal/Magento/Framework/View/Layout/Generic.php
index b83545ff3c439..b527d1a817a96 100644
--- a/lib/internal/Magento/Framework/View/Layout/Generic.php
+++ b/lib/internal/Magento/Framework/View/Layout/Generic.php
@@ -200,6 +200,6 @@ protected function createChildFormComponent(UiComponentInterface $childComponent
*/
protected function getConfig($name)
{
- return isset($this->data['config'][$name]) ? $this->data['config'][$name] : null;
+ return $this->data['config'][$name] ?? null;
}
}
diff --git a/lib/internal/Magento/Framework/View/Layout/ScheduledStructure.php b/lib/internal/Magento/Framework/View/Layout/ScheduledStructure.php
index 25a04845a0728..3193e10282fd4 100644
--- a/lib/internal/Magento/Framework/View/Layout/ScheduledStructure.php
+++ b/lib/internal/Magento/Framework/View/Layout/ScheduledStructure.php
@@ -146,7 +146,7 @@ public function unsetElementToSort($elementName)
*/
public function getElementToSort($elementName, array $default = [])
{
- return isset($this->elementsToSort[$elementName]) ? $this->elementsToSort[$elementName] : $default;
+ return $this->elementsToSort[$elementName] ?? $default;
}
/**
@@ -257,7 +257,7 @@ public function unsetElement($elementName)
*/
public function getElementToMove($elementName, $default = null)
{
- return isset($this->scheduledMoves[$elementName]) ? $this->scheduledMoves[$elementName] : $default;
+ return $this->scheduledMoves[$elementName] ?? $default;
}
/**
@@ -370,7 +370,7 @@ public function unsetStructureElement($elementName)
*/
public function getStructureElementData($elementName, $default = null)
{
- return isset($this->scheduledData[$elementName]) ? $this->scheduledData[$elementName] : $default;
+ return $this->scheduledData[$elementName] ?? $default;
}
/**
@@ -524,6 +524,6 @@ public function populateWithArray(array $data)
*/
private function getArrayValueByKey($key, array $array)
{
- return isset($array[$key]) ? $array[$key] : [];
+ return $array[$key] ?? [];
}
}
diff --git a/lib/internal/Magento/Framework/View/Page/Config.php b/lib/internal/Magento/Framework/View/Page/Config.php
index 058cad00320cd..226abc538112b 100644
--- a/lib/internal/Magento/Framework/View/Page/Config.php
+++ b/lib/internal/Magento/Framework/View/Page/Config.php
@@ -542,7 +542,7 @@ public function setElementAttribute($elementType, $attribute, $value)
public function getElementAttribute($elementType, $attribute)
{
$this->build();
- return isset($this->elements[$elementType][$attribute]) ? $this->elements[$elementType][$attribute] : null;
+ return $this->elements[$elementType][$attribute] ?? null;
}
/**
@@ -552,7 +552,7 @@ public function getElementAttribute($elementType, $attribute)
public function getElementAttributes($elementType)
{
$this->build();
- return isset($this->elements[$elementType]) ? $this->elements[$elementType] : [];
+ return $this->elements[$elementType] ?? [];
}
/**
diff --git a/lib/internal/Magento/Framework/View/Test/Unit/Url/_files/sourceImport.css b/lib/internal/Magento/Framework/View/Test/Unit/Url/_files/sourceImport.css
index d7ce9e81258db..420083613705f 100644
--- a/lib/internal/Magento/Framework/View/Test/Unit/Url/_files/sourceImport.css
+++ b/lib/internal/Magento/Framework/View/Test/Unit/Url/_files/sourceImport.css
@@ -2,8 +2,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-body {background: url(body.gif);}
@import url(../recursive.css);
-p {background: url(1.gif?param);}
@import url("deep/recursive.css");
+body {background: url(body.gif);}
+p {background: url(1.gif?param);}
h1 {background: url('../h1.gif#param');} h2 {background: url(../images/h2.gif?test);}
diff --git a/lib/internal/Magento/Framework/Xml/Generator.php b/lib/internal/Magento/Framework/Xml/Generator.php
index 975073e443d0e..f165793c2e2a4 100644
--- a/lib/internal/Magento/Framework/Xml/Generator.php
+++ b/lib/internal/Magento/Framework/Xml/Generator.php
@@ -146,8 +146,6 @@ public function setIndexedArrayItemName($name)
*/
protected function _getIndexedArrayItemName()
{
- return isset($this->_defaultIndexedArrayItemName)
- ? $this->_defaultIndexedArrayItemName
- : self::DEFAULT_ENTITY_ITEM_NAME;
+ return $this->_defaultIndexedArrayItemName ?? self::DEFAULT_ENTITY_ITEM_NAME;
}
}
diff --git a/lib/web/css/docs/docs.css b/lib/web/css/docs/docs.css
index beb18b8b2194a..a3a372ad4eeb9 100644
--- a/lib/web/css/docs/docs.css
+++ b/lib/web/css/docs/docs.css
@@ -4187,7 +4187,7 @@ select {
color: #000066;
}
.example-message-4:before {
- background: #green;
+ background: green;
width: 30px;
content: '';
display: block;
@@ -4230,7 +4230,7 @@ select {
border: 5px solid transparent;
height: 0;
width: 0;
- border-left-color: #green;
+ border-left-color: green;
left: 30px;
}
.example-message-4 > *:first-child:after {
diff --git a/lib/web/mage/adminhtml/form.js b/lib/web/mage/adminhtml/form.js
index 8f658f8fad738..32586d2115b30 100644
--- a/lib/web/mage/adminhtml/form.js
+++ b/lib/web/mage/adminhtml/form.js
@@ -494,7 +494,8 @@ define([
inputs.each(function (item) {
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
if ((!item.type || item.type != 'hidden') && !($(item.id + '_inherit') && $(item.id + '_inherit').checked) && //eslint-disable-line
- !(currentConfig['can_edit_price'] != undefined && !currentConfig['can_edit_price']) //eslint-disable-line
+ !(currentConfig['can_edit_price'] != undefined && !currentConfig['can_edit_price']) && //eslint-disable-line
+ !item.id.endsWith('_inherit')
) {
item.disabled = false;
jQuery(item).removeClass('ignore-validate');
diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php
index 1ec9d486a5a22..04ec83a3d0ca2 100644
--- a/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php
+++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/Cache.php
@@ -26,11 +26,13 @@ class Cache implements ConfigOptionsListInterface
const INPUT_KEY_CACHE_BACKEND_REDIS_SERVER = 'cache-backend-redis-server';
const INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE = 'cache-backend-redis-db';
const INPUT_KEY_CACHE_BACKEND_REDIS_PORT = 'cache-backend-redis-port';
+ const INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD = 'cache-backend-redis-password';
const CONFIG_PATH_CACHE_BACKEND = 'cache/frontend/default/backend';
const CONFIG_PATH_CACHE_BACKEND_SERVER = 'cache/frontend/default/backend_options/server';
const CONFIG_PATH_CACHE_BACKEND_DATABASE = 'cache/frontend/default/backend_options/database';
const CONFIG_PATH_CACHE_BACKEND_PORT = 'cache/frontend/default/backend_options/port';
+ const CONFIG_PATH_CACHE_BACKEND_PASSWORD = 'cache/frontend/default/backend_options/password';
/**
* @var array
@@ -38,7 +40,8 @@ class Cache implements ConfigOptionsListInterface
private $defaultConfigValues = [
self::INPUT_KEY_CACHE_BACKEND_REDIS_SERVER => '127.0.0.1',
self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE => '0',
- self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => '6379'
+ self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => '6379',
+ self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => ''
];
/**
@@ -55,6 +58,7 @@ class Cache implements ConfigOptionsListInterface
self::INPUT_KEY_CACHE_BACKEND_REDIS_SERVER => self::CONFIG_PATH_CACHE_BACKEND_SERVER,
self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE => self::CONFIG_PATH_CACHE_BACKEND_DATABASE,
self::INPUT_KEY_CACHE_BACKEND_REDIS_PORT => self::CONFIG_PATH_CACHE_BACKEND_PORT,
+ self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_CACHE_BACKEND_PASSWORD
];
/**
@@ -102,6 +106,12 @@ public function getOptions()
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_CACHE_BACKEND_PORT,
'Redis server listen port'
+ ),
+ new TextConfigOption(
+ self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD,
+ TextConfigOption::FRONTEND_WIZARD_TEXT,
+ self::CONFIG_PATH_CACHE_BACKEND_PASSWORD,
+ 'Redis server password'
)
];
}
@@ -190,6 +200,13 @@ private function validateRedisConfig(array $options, DeploymentConfig $deploymen
self::CONFIG_PATH_CACHE_BACKEND_DATABASE,
$this->getDefaultConfigValue(self::INPUT_KEY_CACHE_BACKEND_REDIS_DATABASE)
);
+
+ $config['password'] = isset($options[self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD])
+ ? $options[self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD]
+ : $deploymentConfig->get(
+ self::CONFIG_PATH_CACHE_BACKEND_PASSWORD,
+ $this->getDefaultConfigValue(self::INPUT_KEY_CACHE_BACKEND_REDIS_PASSWORD)
+ );
return $this->redisValidator->isValidConnection($config);
}
diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php b/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php
index be1cc5b010185..944c543495751 100644
--- a/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php
+++ b/setup/src/Magento/Setup/Model/ConfigOptionsList/PageCache.php
@@ -27,12 +27,14 @@ class PageCache implements ConfigOptionsListInterface
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE = 'page-cache-redis-db';
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT = 'page-cache-redis-port';
const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA = 'page-cache-redis-compress-data';
+ const INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD = 'page-cache-redis-password';
const CONFIG_PATH_PAGE_CACHE_BACKEND = 'cache/frontend/page_cache/backend';
const CONFIG_PATH_PAGE_CACHE_BACKEND_SERVER = 'cache/frontend/page_cache/backend_options/server';
const CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE = 'cache/frontend/page_cache/backend_options/database';
const CONFIG_PATH_PAGE_CACHE_BACKEND_PORT = 'cache/frontend/page_cache/backend_options/port';
const CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA = 'cache/frontend/page_cache/backend_options/compress_data';
+ const CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD = 'cache/frontend/page_cache/backend_options/password';
/**
* @var array
@@ -41,7 +43,8 @@ class PageCache implements ConfigOptionsListInterface
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER => '127.0.0.1',
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE => '1',
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT => '6379',
- self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => '0'
+ self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => '0',
+ self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => ''
];
/**
@@ -58,7 +61,8 @@ class PageCache implements ConfigOptionsListInterface
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_SERVER => self::CONFIG_PATH_PAGE_CACHE_BACKEND_SERVER,
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE => self::CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE,
self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PORT => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PORT,
- self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA
+ self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_COMPRESS_DATA => self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA,
+ self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD => self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD
];
/**
@@ -112,6 +116,12 @@ public function getOptions()
TextConfigOption::FRONTEND_WIZARD_TEXT,
self::CONFIG_PATH_PAGE_CACHE_BACKEND_COMPRESS_DATA,
'Set to 1 to compress the full page cache (use 0 to disable)'
+ ),
+ new TextConfigOption(
+ self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD,
+ TextConfigOption::FRONTEND_WIZARD_TEXT,
+ self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD,
+ 'Redis server password'
)
];
}
@@ -201,6 +211,13 @@ private function validateRedisConfig(array $options, DeploymentConfig $deploymen
self::CONFIG_PATH_PAGE_CACHE_BACKEND_DATABASE,
$this->getDefaultConfigValue(self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_DATABASE)
);
+
+ $config['password'] = isset($options[self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD])
+ ? $options[self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD]
+ : $deploymentConfig->get(
+ self::CONFIG_PATH_PAGE_CACHE_BACKEND_PASSWORD,
+ $this->getDefaultConfigValue(self::INPUT_KEY_PAGE_CACHE_BACKEND_REDIS_PASSWORD)
+ );
return $this->redisValidator->isValidConnection($config);
}
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php
index ef0ea3e988364..39b95953c6347 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/CacheTest.php
@@ -39,7 +39,7 @@ protected function setUp()
public function testGetOptions()
{
$options = $this->configOptionsList->getOptions();
- $this->assertCount(4, $options);
+ $this->assertCount(5, $options);
$this->assertArrayHasKey(0, $options);
$this->assertInstanceOf(SelectConfigOption::class, $options[0]);
@@ -56,6 +56,10 @@ public function testGetOptions()
$this->assertArrayHasKey(3, $options);
$this->assertInstanceOf(TextConfigOption::class, $options[3]);
$this->assertEquals('cache-backend-redis-port', $options[3]->getName());
+
+ $this->assertArrayHasKey(4, $options);
+ $this->assertInstanceOf(TextConfigOption::class, $options[4]);
+ $this->assertEquals('cache-backend-redis-password', $options[4]->getName());
}
public function testCreateConfigCacheRedis()
@@ -70,7 +74,8 @@ public function testCreateConfigCacheRedis()
'backend_options' => [
'server' => '',
'port' => '',
- 'database' => ''
+ 'database' => '',
+ 'password' => ''
]
]
]
@@ -92,7 +97,8 @@ public function testCreateConfigWithRedisConfig()
'backend_options' => [
'server' => 'localhost',
'port' => '1234',
- 'database' => '5'
+ 'database' => '5',
+ 'password' => ''
]
]
]
@@ -118,7 +124,7 @@ public function testValidateWithValidInput()
];
$this->validatorMock->expects($this->once())
->method('isValidConnection')
- ->with(['host'=>'localhost', 'db'=>'', 'port'=>''])
+ ->with(['host'=>'localhost', 'db'=>'', 'port'=>'', 'password'=> ''])
->willReturn(true);
$errors = $this->configOptionsList->validate($options, $this->deploymentConfigMock);
diff --git a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php
index e654bea9ac1c5..ed0e567820ad1 100644
--- a/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php
+++ b/setup/src/Magento/Setup/Test/Unit/Model/ConfigOptionsList/PageCacheTest.php
@@ -39,7 +39,7 @@ protected function setUp()
public function testGetOptions()
{
$options = $this->configList->getOptions();
- $this->assertCount(5, $options);
+ $this->assertCount(6, $options);
$this->assertArrayHasKey(0, $options);
$this->assertInstanceOf(SelectConfigOption::class, $options[0]);
@@ -60,6 +60,10 @@ public function testGetOptions()
$this->assertArrayHasKey(4, $options);
$this->assertInstanceOf(TextConfigOption::class, $options[4]);
$this->assertEquals('page-cache-redis-compress-data', $options[4]->getName());
+
+ $this->assertArrayHasKey(5, $options);
+ $this->assertInstanceOf(TextConfigOption::class, $options[5]);
+ $this->assertEquals('page-cache-redis-password', $options[5]->getName());
}
public function testCreateConfigWithRedis()
@@ -75,7 +79,8 @@ public function testCreateConfigWithRedis()
'server'=> '',
'port' => '',
'database' => '',
- 'compress_data' => ''
+ 'compress_data' => '',
+ 'password' => ''
]
]
]
@@ -98,7 +103,8 @@ public function testCreateConfigWithRedisConfiguration()
'server' => 'foo.bar',
'port' => '9000',
'database' => '6',
- 'compress_data' => '1'
+ 'compress_data' => '1',
+ 'password' => ''
]
]
]