From 8b56ad0b2a875103d0f3ec9ab741fe8b09b7d9c2 Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Sat, 23 Feb 2019 20:24:25 -0500
Subject: [PATCH 0001/1978] Separate buy request creation into extensible
builder
This allows product type graphql modules a method for managing how inputs are
mapped when buy requests are created.
---
.../Model/Cart/AddSimpleProductToCart.php | 71 +++----------------
.../Cart/BuyRequest/BuyRequestBuilder.php | 42 +++++++++++
.../BuyRequestDataProviderInterface.php | 13 ++++
.../CustomizableOptionsDataProvider.php | 42 +++++++++++
.../Cart/BuyRequest/DefaultDataProvider.php | 41 +++++++++++
.../Magento/QuoteGraphQl/etc/graphql/di.xml | 8 +++
6 files changed, 156 insertions(+), 61 deletions(-)
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
index 1b32866ed883c..4f0d5b3637c01 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
@@ -15,6 +15,7 @@
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Quote\Model\Quote;
+use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestBuilder;
/**
* Add simple product to cart
@@ -29,28 +30,28 @@ class AddSimpleProductToCart
private $arrayManager;
/**
- * @var DataObjectFactory
+ * @var ProductRepositoryInterface
*/
- private $dataObjectFactory;
+ private $productRepository;
/**
- * @var ProductRepositoryInterface
+ * @var BuyRequestBuilder
*/
- private $productRepository;
+ private $buyRequestBuilder;
/**
* @param ArrayManager $arrayManager
- * @param DataObjectFactory $dataObjectFactory
* @param ProductRepositoryInterface $productRepository
+ * @param BuyRequestBuilder $buyRequestBuilder
*/
public function __construct(
ArrayManager $arrayManager,
- DataObjectFactory $dataObjectFactory,
- ProductRepositoryInterface $productRepository
+ ProductRepositoryInterface $productRepository,
+ BuyRequestBuilder $buyRequestBuilder
) {
$this->arrayManager = $arrayManager;
- $this->dataObjectFactory = $dataObjectFactory;
$this->productRepository = $productRepository;
+ $this->buyRequestBuilder = $buyRequestBuilder;
}
/**
@@ -66,8 +67,6 @@ public function __construct(
public function execute(Quote $cart, array $cartItemData): void
{
$sku = $this->extractSku($cartItemData);
- $qty = $this->extractQty($cartItemData);
- $customizableOptions = $this->extractCustomizableOptions($cartItemData);
try {
$product = $this->productRepository->get($sku);
@@ -76,7 +75,7 @@ public function execute(Quote $cart, array $cartItemData): void
}
try {
- $result = $cart->addProduct($product, $this->createBuyRequest($qty, $customizableOptions));
+ $result = $cart->addProduct($product, $this->buyRequestBuilder->build($cartItemData));
} catch (\Exception $e) {
throw new GraphQlInputException(
__(
@@ -106,54 +105,4 @@ private function extractSku(array $cartItemData): string
}
return (string)$sku;
}
-
- /**
- * Extract Qty from cart item data
- *
- * @param array $cartItemData
- * @return float
- * @throws GraphQlInputException
- */
- private function extractQty(array $cartItemData): float
- {
- $qty = $this->arrayManager->get('data/qty', $cartItemData);
- if (!isset($qty)) {
- throw new GraphQlInputException(__('Missing key "qty" in cart item data'));
- }
- return (float)$qty;
- }
-
- /**
- * Extract Customizable Options from cart item data
- *
- * @param array $cartItemData
- * @return array
- */
- private function extractCustomizableOptions(array $cartItemData): array
- {
- $customizableOptions = $this->arrayManager->get('customizable_options', $cartItemData, []);
-
- $customizableOptionsData = [];
- foreach ($customizableOptions as $customizableOption) {
- $customizableOptionsData[$customizableOption['id']] = $customizableOption['value'];
- }
- return $customizableOptionsData;
- }
-
- /**
- * Format GraphQl input data to a shape that buy request has
- *
- * @param float $qty
- * @param array $customOptions
- * @return DataObject
- */
- private function createBuyRequest(float $qty, array $customOptions): DataObject
- {
- return $this->dataObjectFactory->create([
- 'data' => [
- 'qty' => $qty,
- 'options' => $customOptions,
- ],
- ]);
- }
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php
new file mode 100644
index 0000000000000..492dd18f14e03
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php
@@ -0,0 +1,42 @@
+dataObjectFactory = $dataObjectFactory;
+ $this->providers = $providers;
+ }
+
+ public function build(array $cartItemData): DataObject
+ {
+ $requestData = [];
+ foreach ($this->providers as $provider) {
+ $requestData = array_merge($requestData, $provider->execute($cartItemData));
+ }
+
+ return $this->dataObjectFactory->create(['data' => $requestData]);
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php
new file mode 100644
index 0000000000000..adfc5b13b762c
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php
@@ -0,0 +1,13 @@
+arrayManager = $arrayManager;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function execute(array $cartItemData): array
+ {
+ $customizableOptions = $this->arrayManager->get('customizable_options', $cartItemData, []);
+
+ $customizableOptionsData = [];
+ foreach ($customizableOptions as $customizableOption) {
+ $customizableOptionsData[$customizableOption['id']] = $customizableOption['value'];
+ }
+
+ return ['options' => $customizableOptionsData];
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
new file mode 100644
index 0000000000000..3185510e42865
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
@@ -0,0 +1,41 @@
+arrayManager = $arrayManager;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function execute(array $cartItemData): array
+ {
+ $qty = $this->arrayManager->get('data/qty', $cartItemData);
+ if (!isset($qty)) {
+ throw new GraphQlInputException(__('Missing key "qty" in cart item data'));
+ }
+
+ return ['qty' => (float)$qty];
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml b/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml
index 86bc954ae4ac4..b51d33b6577c8 100644
--- a/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml
+++ b/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml
@@ -8,4 +8,12 @@
+
+
+
+ - Magento\QuoteGraphQl\Model\Cart\BuyRequest\DefaultDataProvider
+ - Magento\QuoteGraphQl\Model\Cart\BuyRequest\CustomizableOptionsDataProvider
+
+
+
From 77b636ec3c08a77be2b0bc37f29d942ecbb5b20d Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Sun, 24 Feb 2019 10:20:36 -0500
Subject: [PATCH 0002/1978] Mutation for adding bundled products to cart
Partial resolution for magento/graphlql-ce#143
---
.../Model/Cart/BundleOptionDataProvider.php | 136 ++++++++++++
.../Cart/BuyRequest/BundleDataProvider.php | 43 ++++
.../Model/Resolver/BundleOption.php | 39 ++++
app/code/Magento/BundleGraphQl/composer.json | 2 +
app/code/Magento/BundleGraphQl/etc/di.xml | 7 +
.../Magento/BundleGraphQl/etc/graphql/di.xml | 7 +
.../Magento/BundleGraphQl/etc/schema.graphqls | 44 ++++
.../Bundle/AddBundleProductToCartTest.php | 193 ++++++++++++++++++
8 files changed, 471 insertions(+)
create mode 100644 app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php
create mode 100644 app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php
create mode 100644 app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
diff --git a/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php b/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php
new file mode 100644
index 0000000000000..8db1c64c23c42
--- /dev/null
+++ b/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php
@@ -0,0 +1,136 @@
+pricingHelper = $pricingHelper;
+ $this->serializer = $serializer;
+ $this->configuration = $configuration;
+ }
+
+ /**
+ * @param Item $item
+ * @return array
+ */
+ public function getData(Item $item): array
+ {
+ $options = [];
+ $product = $item->getProduct();
+
+ /** @var \Magento\Bundle\Model\Product\Type $typeInstance */
+ $typeInstance = $product->getTypeInstance();
+
+ $optionsQuoteItemOption = $item->getOptionByCode('bundle_option_ids');
+ $bundleOptionsIds = $optionsQuoteItemOption
+ ? $this->serializer->unserialize($optionsQuoteItemOption->getValue())
+ : [];
+
+ if ($bundleOptionsIds) {
+ /** @var \Magento\Bundle\Model\ResourceModel\Option\Collection $optionsCollection */
+ $optionsCollection = $typeInstance->getOptionsByIds($bundleOptionsIds, $product);
+
+ $selectionsQuoteItemOption = $item->getOptionByCode('bundle_selection_ids');
+
+ $bundleSelectionIds = $this->serializer->unserialize($selectionsQuoteItemOption->getValue());
+
+ if (!empty($bundleSelectionIds)) {
+ $selectionsCollection = $typeInstance->getSelectionsByIds($bundleSelectionIds, $product);
+ $bundleOptions = $optionsCollection->appendSelections($selectionsCollection, true);
+
+ $options = $this->buildBundleOptions($bundleOptions, $item);
+ }
+ }
+
+ return $options;
+ }
+
+ /**
+ * @param \Magento\Bundle\Model\Option[] $bundleOptions
+ * @param Item $item
+ * @return array
+ */
+ private function buildBundleOptions(array $bundleOptions, Item $item): array
+ {
+ $options = [];
+ foreach ($bundleOptions as $bundleOption) {
+ if (!$bundleOption->getSelections()) {
+ continue;
+ }
+
+ $options[] = [
+ 'id' => $bundleOption->getId(),
+ 'label' => $bundleOption->getTitle(),
+ 'type' => $bundleOption->getType(),
+ 'values' => $this->buildBundleOptionValues($bundleOption->getSelections(), $item),
+ ];
+ }
+
+ return $options;
+ }
+
+ /**
+ * @param Product[] $selections
+ * @param Item $item
+ * @return array
+ */
+ private function buildBundleOptionValues(array $selections, Item $item): array
+ {
+ $values = [];
+
+ $product = $item->getProduct();
+ foreach ($selections as $selection) {
+ $qty = (float) $this->configuration->getSelectionQty($product, $selection->getSelectionId());
+ if (!$qty) {
+ continue;
+ }
+
+ $selectionPrice = $this->configuration->getSelectionFinalPrice($item, $selection);
+
+ $values[] = [
+ 'id' => $selection->getSelectionId(),
+ 'label' => $selection->getName(),
+ 'quantity' => $qty,
+ 'price' => $this->pricingHelper->currency($selectionPrice, false, false),
+ ];
+ }
+
+ return $values;
+ }
+}
diff --git a/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php b/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php
new file mode 100644
index 0000000000000..72a72dd5b3bcf
--- /dev/null
+++ b/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php
@@ -0,0 +1,43 @@
+arrayManager = $arrayManager;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function execute(array $cartItemData): array
+ {
+ $bundleOptions = [];
+ $bundleInputs = $this->arrayManager->get('bundle_options', $cartItemData) ?? [];
+ foreach ($bundleInputs as $bundleInput) {
+ $bundleOptions['bundle_option'][$bundleInput['id']] = $bundleInput['value'];
+ $bundleOptions['bundle_option_qty'][$bundleInput['id']] = $bundleInput['quantity'];
+ }
+
+ return $bundleOptions;
+ }
+}
diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php b/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php
new file mode 100644
index 0000000000000..9bccbf936f18d
--- /dev/null
+++ b/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php
@@ -0,0 +1,39 @@
+dataProvider = $bundleOptionDataProvider;
+ }
+
+ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
+ {
+ if (!isset($value['model'])) {
+ throw new GraphQlInputException(__('Value must contain "model" property.'));
+ }
+ return $this->dataProvider->getData($value['model']);
+ }
+}
diff --git a/app/code/Magento/BundleGraphQl/composer.json b/app/code/Magento/BundleGraphQl/composer.json
index aea55cb5c644c..5e0adf0ceb169 100644
--- a/app/code/Magento/BundleGraphQl/composer.json
+++ b/app/code/Magento/BundleGraphQl/composer.json
@@ -7,6 +7,8 @@
"magento/module-catalog": "*",
"magento/module-bundle": "*",
"magento/module-catalog-graph-ql": "*",
+ "magento/module-quote": "*",
+ "magento/module-quote-graph-ql": "*",
"magento/module-store": "*",
"magento/framework": "*"
},
diff --git a/app/code/Magento/BundleGraphQl/etc/di.xml b/app/code/Magento/BundleGraphQl/etc/di.xml
index 4f41f3cb8dc80..15acad7c6bf06 100644
--- a/app/code/Magento/BundleGraphQl/etc/di.xml
+++ b/app/code/Magento/BundleGraphQl/etc/di.xml
@@ -16,4 +16,11 @@
+
+
+
+ - BundleCartItem
+
+
+
diff --git a/app/code/Magento/BundleGraphQl/etc/graphql/di.xml b/app/code/Magento/BundleGraphQl/etc/graphql/di.xml
index 50a2e32b8c9d5..5484d57b7c741 100644
--- a/app/code/Magento/BundleGraphQl/etc/graphql/di.xml
+++ b/app/code/Magento/BundleGraphQl/etc/graphql/di.xml
@@ -13,6 +13,13 @@
+
+
+
+ - Magento\BundleGraphQl\Model\Cart\BuyRequest\BundleDataProvider
+
+
+
diff --git a/app/code/Magento/BundleGraphQl/etc/schema.graphqls b/app/code/Magento/BundleGraphQl/etc/schema.graphqls
index edde6079dfb2f..3848cabff22e5 100644
--- a/app/code/Magento/BundleGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/BundleGraphQl/etc/schema.graphqls
@@ -1,6 +1,50 @@
# Copyright © Magento, Inc. All rights reserved.
# See COPYING.txt for license details.
+type Mutation {
+ addBundleProductsToCart(input: AddBundleProductsToCartInput): AddBundleProductsToCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\AddSimpleProductsToCart")
+}
+
+input AddBundleProductsToCartInput {
+ cart_id: String!
+ cartItems: [BundleProductCartItemInput!]!
+}
+
+input BundleProductCartItemInput {
+ data: CartItemInput!
+ bundle_options:[BundleOptionInput!]!
+ customizable_options:[CustomizableOptionInput!]
+}
+
+input BundleOptionInput {
+ id: Int!
+ quantity: Float!
+ value: [String!]!
+}
+
+type AddBundleProductsToCartOutput {
+ cart: Cart!
+}
+
+type BundleCartItem implements CartItemInterface {
+ customizable_options: [SelectedCustomizableOption]! @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\CustomizableOptions")
+ bundle_options: [SelectedBundleOption!]! @resolver(class: "Magento\\BundleGraphQl\\Model\\Resolver\\BundleOption")
+}
+
+type SelectedBundleOption {
+ id: Int!
+ label: String!
+ type: String!
+ values: [SelectedBundleOptionValue!]!
+}
+
+type SelectedBundleOptionValue {
+ id: Int!
+ label: String!
+ quantity: Float!
+ price: Float!
+}
+
type BundleItem @doc(description: "BundleItem defines an individual item in a bundle product") {
option_id: Int @doc(description: "An ID assigned to each type of item in a bundle product")
title: String @doc(description: "The display name of the item")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
new file mode 100644
index 0000000000000..7905484ec51df
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
@@ -0,0 +1,193 @@
+quoteResource = $objectManager->get(QuoteResource::class);
+ $this->quote = $objectManager->create(Quote::class);
+ $this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
+ $this->productRepository = $objectManager->get(ProductRepositoryInterface::class);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Bundle/_files/product_1.php
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
+ */
+ public function testAddBundleProductToCart()
+ {
+ $sku = 'bundle-product';
+
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_1',
+ 'reserved_order_id'
+ );
+
+ $product = $this->productRepository->get($sku);
+
+ /** @var $typeInstance \Magento\Bundle\Model\Product\Type */
+ $typeInstance = $product->getTypeInstance();
+ $typeInstance->setStoreFilter($product->getStoreId(), $product);
+ /** @var $option \Magento\Bundle\Model\Option */
+ $option = $typeInstance->getOptionsCollection($product)->getFirstItem();
+ /** @var \Magento\Catalog\Model\Product $selection */
+ $selection = $typeInstance->getSelectionsCollection([$option->getId()], $product)->getFirstItem();
+ $optionId = $option->getId();
+ $selectionId = $selection->getSelectionId();
+
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+
+ $query = <<graphQlQuery($query);
+
+ $this->assertArrayHasKey('addBundleProductsToCart', $response);
+ $this->assertArrayHasKey('cart', $response['addBundleProductsToCart']);
+ $cart = $response['addBundleProductsToCart']['cart'];
+ $this->assertEquals($maskedQuoteId, $cart['cart_id']);
+ $bundleItem = current($cart['items']);
+ $this->assertEquals($sku, $bundleItem['product']['sku']);
+ $bundleItemOption = current($bundleItem['bundle_options']);
+ $this->assertEquals($optionId, $bundleItemOption['id']);
+ $this->assertEquals($option->getTitle(), $bundleItemOption['label']);
+ $this->assertEquals($option->getType(), $bundleItemOption['type']);
+ $value = current($bundleItemOption['values']);
+ $this->assertEquals($selection->getSelectionId(), $value['id']);
+ $this->assertEquals((float) $selection->getSelectionPriceValue(), $value['price']);
+ $this->assertEquals(1, $value['quantity']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Bundle/_files/product_1.php
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
+ * @expectedException \Exception
+ * @expectedExceptionMessage Please select all required options
+ */
+ public function testAddBundleToCartWithoutOptions()
+ {
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_order_1',
+ 'reserved_order_id'
+ );
+
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+
+ $query = <<graphQlQuery($query);
+ }
+}
From 55ea3fc961152dbdc00a8c20b37720da59f3169e Mon Sep 17 00:00:00 2001
From: Sascha Grossenbacher
Date: Tue, 26 Mar 2019 17:48:10 +0100
Subject: [PATCH 0003/1978] Use new MessageQueueConfig interface, update unit
tests
---
.../MysqlMq/Model/Driver/Bulk/Exchange.php | 16 +++++++-
.../Magento/MysqlMq/Model/Driver/Exchange.php | 16 +++++++-
app/code/Magento/MysqlMq/Setup/Recurring.php | 7 ++--
.../Unit/Model/Driver/Bulk/ExchangeTest.php | 38 +++++++++++++++++--
.../MysqlMq/Test/Unit/Setup/RecurringTest.php | 31 ++++++---------
5 files changed, 76 insertions(+), 32 deletions(-)
diff --git a/app/code/Magento/MysqlMq/Model/Driver/Bulk/Exchange.php b/app/code/Magento/MysqlMq/Model/Driver/Bulk/Exchange.php
index 247a44667be06..73c6a89ef0d63 100644
--- a/app/code/Magento/MysqlMq/Model/Driver/Bulk/Exchange.php
+++ b/app/code/Magento/MysqlMq/Model/Driver/Bulk/Exchange.php
@@ -6,7 +6,7 @@
namespace Magento\MysqlMq\Model\Driver\Bulk;
use Magento\Framework\MessageQueue\Bulk\ExchangeInterface;
-use Magento\Framework\MessageQueue\ConfigInterface as MessageQueueConfig;
+use Magento\Framework\MessageQueue\Topology\ConfigInterface as MessageQueueConfig;
use Magento\MysqlMq\Model\QueueManagement;
/**
@@ -41,7 +41,19 @@ public function __construct(MessageQueueConfig $messageQueueConfig, QueueManagem
*/
public function enqueue($topic, array $envelopes)
{
- $queueNames = $this->messageQueueConfig->getQueuesByTopic($topic);
+ $queueNames = [];
+ $exchanges = $this->messageQueueConfig->getExchanges();
+ foreach ($exchanges as $exchange) {
+ // @todo Is there a more reliable way to identify MySQL exchanges?
+ if ($exchange->getConnection() == 'db') {
+ foreach ($exchange->getBindings() as $binding) {
+ // This only supports exact matching of topics.
+ if ($binding->getTopic() == $topic) {
+ $queueNames[] = $binding->getDestination();
+ }
+ }
+ }
+ }
$messages = array_map(
function ($envelope) {
return $envelope->getBody();
diff --git a/app/code/Magento/MysqlMq/Model/Driver/Exchange.php b/app/code/Magento/MysqlMq/Model/Driver/Exchange.php
index b6050c6b3d0b6..85e53c847f87b 100644
--- a/app/code/Magento/MysqlMq/Model/Driver/Exchange.php
+++ b/app/code/Magento/MysqlMq/Model/Driver/Exchange.php
@@ -7,7 +7,7 @@
use Magento\Framework\MessageQueue\EnvelopeInterface;
use Magento\Framework\MessageQueue\ExchangeInterface;
-use Magento\Framework\MessageQueue\ConfigInterface as MessageQueueConfig;
+use Magento\Framework\MessageQueue\Topology\ConfigInterface as MessageQueueConfig;
use Magento\MysqlMq\Model\QueueManagement;
class Exchange implements ExchangeInterface
@@ -43,7 +43,19 @@ public function __construct(MessageQueueConfig $messageQueueConfig, QueueManagem
*/
public function enqueue($topic, EnvelopeInterface $envelope)
{
- $queueNames = $this->messageQueueConfig->getQueuesByTopic($topic);
+ $queueNames = [];
+ $exchanges = $this->messageQueueConfig->getExchanges();
+ foreach ($exchanges as $exchange) {
+ // @todo Is there a more reliable way to identify MySQL exchanges?
+ if ($exchange->getConnection() == 'db') {
+ foreach ($exchange->getBindings() as $binding) {
+ // This only supports exact matching of topics.
+ if ($binding->getTopic() == $topic) {
+ $queueNames[] = $binding->getDestination();
+ }
+ }
+ }
+ }
$this->queueManagement->addMessageToQueues($topic, $envelope->getBody(), $queueNames);
return null;
}
diff --git a/app/code/Magento/MysqlMq/Setup/Recurring.php b/app/code/Magento/MysqlMq/Setup/Recurring.php
index db3a39bf5fbd0..f6f21ae4da329 100644
--- a/app/code/Magento/MysqlMq/Setup/Recurring.php
+++ b/app/code/Magento/MysqlMq/Setup/Recurring.php
@@ -8,7 +8,7 @@
use Magento\Framework\Setup\InstallSchemaInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
-use Magento\Framework\MessageQueue\ConfigInterface as MessageQueueConfig;
+use Magento\Framework\MessageQueue\Topology\ConfigInterface as MessageQueueConfig;
/**
* Class Recurring
@@ -35,10 +35,9 @@ public function install(SchemaSetupInterface $setup, ModuleContextInterface $con
{
$setup->startSetup();
- $binds = $this->messageQueueConfig->getBinds();
$queues = [];
- foreach ($binds as $bind) {
- $queues[] = $bind[MessageQueueConfig::BIND_QUEUE];
+ foreach ($this->messageQueueConfig->getQueues() as $queue) {
+ $queues[] = $queue->getName();
}
$connection = $setup->getConnection();
$existingQueues = $connection->fetchCol($connection->select()->from($setup->getTable('queue'), 'name'));
diff --git a/app/code/Magento/MysqlMq/Test/Unit/Model/Driver/Bulk/ExchangeTest.php b/app/code/Magento/MysqlMq/Test/Unit/Model/Driver/Bulk/ExchangeTest.php
index 452825058c9d8..b7eba352ed253 100644
--- a/app/code/Magento/MysqlMq/Test/Unit/Model/Driver/Bulk/ExchangeTest.php
+++ b/app/code/Magento/MysqlMq/Test/Unit/Model/Driver/Bulk/ExchangeTest.php
@@ -12,7 +12,7 @@
class ExchangeTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var \Magento\Framework\MessageQueue\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\MessageQueue\Topology\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $messageQueueConfig;
@@ -33,7 +33,7 @@ class ExchangeTest extends \PHPUnit\Framework\TestCase
*/
protected function setUp()
{
- $this->messageQueueConfig = $this->getMockBuilder(\Magento\Framework\MessageQueue\ConfigInterface::class)
+ $this->messageQueueConfig = $this->getMockBuilder(\Magento\Framework\MessageQueue\Topology\ConfigInterface::class)
->disableOriginalConstructor()->getMock();
$this->queueManagement = $this->getMockBuilder(\Magento\MysqlMq\Model\QueueManagement::class)
->disableOriginalConstructor()->getMock();
@@ -56,10 +56,40 @@ protected function setUp()
public function testEnqueue()
{
$topicName = 'topic.name';
- $queueNames = ['queue0', 'queue1'];
+ $queueNames = ['queue0'];
+
+ $binding1 = $this->createMock(\Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItem\BindingInterface::class);
+ $binding1->expects($this->once())
+ ->method('getTopic')
+ ->willReturn($topicName);
+ $binding1->expects($this->once())
+ ->method('getDestination')
+ ->willReturn($queueNames[0]);
+
+ $binding2 = $this->createMock(\Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItem\BindingInterface::class);
+ $binding2->expects($this->once())
+ ->method('getTopic')
+ ->willReturn('different.topic');
+ $binding2->expects($this->never())
+ ->method('getDestination');
+
+ $exchange1 = $this->createMock(\Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItemInterface::class);
+ $exchange1->expects($this->once())
+ ->method('getConnection')
+ ->willReturn('db');
+ $exchange1->expects($this->once())
+ ->method('getBindings')
+ ->willReturn([$binding1, $binding2]);
+ $exchange2 = $this->createMock(\Magento\Framework\MessageQueue\Topology\Config\ExchangeConfigItemInterface::class);
+ $exchange2->expects($this->once())
+ ->method('getConnection')
+ ->willReturn('amqp');
+ $exchange2->expects($this->never())
+ ->method('getBindings');
+
$envelopeBody = 'serializedMessage';
$this->messageQueueConfig->expects($this->once())
- ->method('getQueuesByTopic')->with($topicName)->willReturn($queueNames);
+ ->method('getExchanges')->willReturn([$exchange1, $exchange2]);
$envelope = $this->getMockBuilder(\Magento\Framework\MessageQueue\EnvelopeInterface::class)
->disableOriginalConstructor()->getMock();
$envelope->expects($this->once())->method('getBody')->willReturn($envelopeBody);
diff --git a/app/code/Magento/MysqlMq/Test/Unit/Setup/RecurringTest.php b/app/code/Magento/MysqlMq/Test/Unit/Setup/RecurringTest.php
index e2e7ad3c4c92d..03ec3c82c2d14 100644
--- a/app/code/Magento/MysqlMq/Test/Unit/Setup/RecurringTest.php
+++ b/app/code/Magento/MysqlMq/Test/Unit/Setup/RecurringTest.php
@@ -24,7 +24,7 @@ class RecurringTest extends \PHPUnit\Framework\TestCase
private $model;
/**
- * @var \Magento\Framework\MessageQueue\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\MessageQueue\Topology\ConfigInterface|\PHPUnit_Framework_MockObject_MockObject
*/
private $messageQueueConfig;
@@ -34,7 +34,7 @@ class RecurringTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->objectManager = new ObjectManager($this);
- $this->messageQueueConfig = $this->getMockBuilder(\Magento\Framework\MessageQueue\ConfigInterface::class)
+ $this->messageQueueConfig = $this->getMockBuilder(\Magento\Framework\MessageQueue\Topology\ConfigInterface::class)
->getMockForAbstractClass();
$this->model = $this->objectManager->getObject(
\Magento\MysqlMq\Setup\Recurring::class,
@@ -49,23 +49,14 @@ protected function setUp()
*/
public function testInstall()
{
- $binds = [
- 'first_bind' => [
- 'queue' => 'queue_name_1',
- 'exchange' => 'magento-db',
- 'topic' => 'queue.topic.1'
- ],
- 'second_bind' => [
- 'queue' => 'queue_name_2',
- 'exchange' => 'magento-db',
- 'topic' => 'queue.topic.2'
- ],
- 'third_bind' => [
- 'queue' => 'queue_name_3',
- 'exchange' => 'magento-db',
- 'topic' => 'queue.topic.3'
- ]
- ];
+ for ($i = 1; $i <=3; $i++) {
+ $queue = $this->createMock(\Magento\Framework\MessageQueue\Topology\Config\QueueConfigItemInterface::class);
+ $queue->expects($this->once())
+ ->method('getName')
+ ->willReturn('queue_name_'. $i);
+ $queues[] = $queue;
+ }
+
$dbQueues = [
'queue_name_1',
'queue_name_2',
@@ -81,7 +72,7 @@ public function testInstall()
->getMockForAbstractClass();
$setup->expects($this->once())->method('startSetup')->willReturnSelf();
- $this->messageQueueConfig->expects($this->once())->method('getBinds')->willReturn($binds);
+ $this->messageQueueConfig->expects($this->once())->method('getQueues')->willReturn($queues);
$connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
->getMockForAbstractClass();
$setup->expects($this->once())->method('getConnection')->willReturn($connection);
From 8403ff643fadd7338ff9273b11c17278f7d70450 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Wed, 3 Apr 2019 16:05:19 +0300
Subject: [PATCH 0004/1978] Convert ShoppingCartPagerTest to MFTF and marking
the variations as migrated
---
.../AssertCartPagerTextActionGroup.xml | 24 ++++
.../Manage20ProductsActionGroup.xml | 134 ++++++++++++++++++
...ShoppingCartWithMoreThan20ProductsTest.xml | 53 +++++++
...ingPagerShoppingCartWith20ProductsTest.xml | 37 +++++
...PagerForOneItemPerPageAnd2ProductsTest.xml | 46 ++++++
.../Test/TestCase/ShoppingCartPagerTest.xml | 4 +
6 files changed, 298 insertions(+)
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml
new file mode 100644
index 0000000000000..0236f213435b1
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml
new file mode 100644
index 0000000000000..132c46e8ba612
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
new file mode 100644
index 0000000000000..89d6d654f1444
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
new file mode 100644
index 0000000000000..e9f83bb9cc167
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
new file mode 100644
index 0000000000000..4e3bd22ccde51
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml
index 8b6b69b73b894..27e9583db5fd2 100644
--- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml
@@ -9,12 +9,14 @@
severity:S2
+ mftf_migrated:yes
severity:S2
default_number_of_items_per_page_on_shopping_cart
catalogProductSimple::default
+ mftf_migrated:yes
@@ -22,11 +24,13 @@
severity:S2
catalogProductSimple::default
1
+ mftf_migrated:yes
severity:S2
one_item_per_page_on_shopping_cart
+ mftf_migrated:yes
From 64cdcebc9ef1513e555c7d22bbb5495aca1cd41c Mon Sep 17 00:00:00 2001
From: eduard13
Date: Thu, 11 Apr 2019 19:24:17 +0300
Subject: [PATCH 0005/1978] Refactoring the Action Groups by best practices
---
...tIsNotVisibleCartPagerTextActionGroup.xml} | 7 ----
...ssertIsVisibleCartPagerTextActionGroup.xml | 17 ++++++++++
...refrontAdd20ProductsToCartActionGroup.xml} | 22 -------------
.../StorefrontDelete20ProductsActionGroup.xml | 32 +++++++++++++++++++
4 files changed, 49 insertions(+), 29 deletions(-)
rename app/code/Magento/Checkout/Test/Mftf/ActionGroup/{AssertCartPagerTextActionGroup.xml => AssertIsNotVisibleCartPagerTextActionGroup.xml} (68%)
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml
rename app/code/Magento/Checkout/Test/Mftf/ActionGroup/{Manage20ProductsActionGroup.xml => StorefrontAdd20ProductsToCartActionGroup.xml} (80%)
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml
similarity index 68%
rename from app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml
rename to app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml
index 0236f213435b1..d08a6f3cf5053 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertCartPagerTextActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml
@@ -7,13 +7,6 @@
-->
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml
new file mode 100644
index 0000000000000..f1793ecd640b4
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml
similarity index 80%
rename from app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml
rename to app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml
index 132c46e8ba612..b4662afffec69 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/Manage20ProductsActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml
@@ -109,26 +109,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml
new file mode 100644
index 0000000000000..f3db7f989d31d
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 489e329de82838b469ca532eab6ab2168b5433d8 Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Tue, 30 Apr 2019 13:23:51 +0300
Subject: [PATCH 0006/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Added error processing
---
.../Model/Order/Shipment/TrackRepository.php | 28 ++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
index 5bcf579a1cbf4..b9911518ad58c 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Sales\Model\Order\Shipment;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
@@ -14,7 +16,12 @@
use Magento\Sales\Api\Data\ShipmentTrackSearchResultInterfaceFactory;
use Magento\Sales\Api\ShipmentTrackRepositoryInterface;
use Magento\Sales\Model\Spi\ShipmentTrackResourceInterface;
+use \Magento\Sales\Model\OrderRepository;
+use \Magento\Framework\App\ObjectManager;
+/**
+ * Repository of shipment tracking information
+ */
class TrackRepository implements ShipmentTrackRepositoryInterface
{
/**
@@ -37,23 +44,32 @@ class TrackRepository implements ShipmentTrackRepositoryInterface
*/
private $collectionProcessor;
+ /**
+ * @var OrderRepository
+ */
+ private $orderRepository;
+
/**
* @param ShipmentTrackResourceInterface $trackResource
* @param ShipmentTrackInterfaceFactory $trackFactory
* @param ShipmentTrackSearchResultInterfaceFactory $searchResultFactory
* @param CollectionProcessorInterface $collectionProcessor
+ * @param OrderRepository $orderRepository
*/
public function __construct(
ShipmentTrackResourceInterface $trackResource,
ShipmentTrackInterfaceFactory $trackFactory,
ShipmentTrackSearchResultInterfaceFactory $searchResultFactory,
- CollectionProcessorInterface $collectionProcessor
+ CollectionProcessorInterface $collectionProcessor,
+ OrderRepository $orderRepository = null
) {
$this->trackResource = $trackResource;
$this->trackFactory = $trackFactory;
$this->searchResultFactory = $searchResultFactory;
$this->collectionProcessor = $collectionProcessor;
+ $this->orderRepository = $orderRepository ?:
+ ObjectManager::getInstance()->get(OrderRepository::class);
}
/**
@@ -95,6 +111,16 @@ public function delete(ShipmentTrackInterface $entity)
*/
public function save(ShipmentTrackInterface $entity)
{
+ $shipmentCollection = $this->orderRepository->get($entity['order_id'])->getShipmentsCollection();
+ $shipmentId = [];
+ foreach ($shipmentCollection as $shipment) {
+ $shipmentId[] = $shipment->getId();
+ }
+
+ if (array_search($entity['parent_id'], $shipmentId) === false) {
+ throw new CouldNotSaveException(__('The shipment doesn\'t belong to the order.'));
+ }
+
try {
$this->trackResource->save($entity);
} catch (\Exception $e) {
From c22cbba6b5c022b4fdcb23b38a8462b22bb4187d Mon Sep 17 00:00:00 2001
From: Vital_Pantsialeyeu
Date: Tue, 14 May 2019 17:58:16 +0300
Subject: [PATCH 0007/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Added API-functional test
---
.../Sales/Service/V1/ShipmentAddTrackTest.php | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
index 054f91a295fd9..e170cd96ea82e 100644
--- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Sales\Service\V1;
use Magento\Framework\Webapi\Rest\Request;
@@ -74,6 +76,48 @@ public function testShipmentAddTrack()
self::assertNotEmpty($result[ShipmentTrackInterface::ENTITY_ID]);
self::assertEquals($shipment->getId(), $result[ShipmentTrackInterface::PARENT_ID]);
}
+
+ /**
+ * Shipment Tracking throw an error if order doesn't exist.
+ *
+ * @magentoApiDataFixture Magento/Sales/_files/shipment.php
+ */
+ public function testShipmentTrackWithFailedOrderId()
+ {
+ /** @var \Magento\Sales\Model\Order $order */
+ $orderCollection = $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Collection::class);
+ $order = $orderCollection->getLastItem();
+ $failedOrderId = $order->getId() + 999999;
+ $shipmentCollection = $this->objectManager->get(Collection::class);
+ /** @var \Magento\Sales\Model\Order\Shipment $shipment */
+ $shipment = $shipmentCollection->getFirstItem();
+ $trackData = [
+ ShipmentTrackInterface::ENTITY_ID => null,
+ ShipmentTrackInterface::ORDER_ID => $failedOrderId,
+ ShipmentTrackInterface::PARENT_ID => $shipment->getId(),
+ ShipmentTrackInterface::WEIGHT => 20,
+ ShipmentTrackInterface::QTY => 5,
+ ShipmentTrackInterface::TRACK_NUMBER => 2,
+ ShipmentTrackInterface::DESCRIPTION => 'Shipment description',
+ ShipmentTrackInterface::TITLE => 'Shipment title',
+ ShipmentTrackInterface::CARRIER_CODE => Track::CUSTOM_CARRIER_CODE,
+ ];
+ $expectedMessage = 'The entity that was requested doesn\'t exist. Verify the entity and try again.';
+
+ try {
+ $this->_webApiCall($this->getServiceInfo(), ['entity' => $trackData]);
+ } catch (\SoapFault $e) {
+ $this->assertContains(
+ $expectedMessage,
+ $e->getMessage(),
+ 'SoapFault does not contain expected message.'
+ );
+ } catch (\Exception $e) {
+ $errorObj = $this->processRestExceptionResult($e);
+ $this->assertEquals($expectedMessage, $errorObj['message']);
+ }
+ }
+
/**
* Returns details about API endpoints and services.
*
From adce9d933f26541b906b2161e9b9e1551586f94a Mon Sep 17 00:00:00 2001
From: Vital_Pantsialeyeu
Date: Thu, 23 May 2019 14:01:07 +0300
Subject: [PATCH 0008/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Added API-functional test
---
.../Magento/Sales/Service/V1/ShipmentAddTrackTest.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
index e170cd96ea82e..c25956a4858ec 100644
--- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
@@ -81,13 +81,15 @@ public function testShipmentAddTrack()
* Shipment Tracking throw an error if order doesn't exist.
*
* @magentoApiDataFixture Magento/Sales/_files/shipment.php
+ * @magentoApiDataFixture Magento/Sales/_files/order_list.php
*/
public function testShipmentTrackWithFailedOrderId()
{
/** @var \Magento\Sales\Model\Order $order */
$orderCollection = $this->objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Collection::class);
$order = $orderCollection->getLastItem();
- $failedOrderId = $order->getId() + 999999;
+ // Order ID from Magento/Sales/_files/order_list.php
+ $failedOrderId = $order->getId();
$shipmentCollection = $this->objectManager->get(Collection::class);
/** @var \Magento\Sales\Model\Order\Shipment $shipment */
$shipment = $shipmentCollection->getFirstItem();
@@ -102,7 +104,7 @@ public function testShipmentTrackWithFailedOrderId()
ShipmentTrackInterface::TITLE => 'Shipment title',
ShipmentTrackInterface::CARRIER_CODE => Track::CUSTOM_CARRIER_CODE,
];
- $expectedMessage = 'The entity that was requested doesn\'t exist. Verify the entity and try again.';
+ $expectedMessage = 'The shipment doesn\'t belong to the order.';
try {
$this->_webApiCall($this->getServiceInfo(), ['entity' => $trackData]);
From 0105e4c59d5606662a100580c4627e29f6f999cf Mon Sep 17 00:00:00 2001
From: Denis Kopylov
Date: Thu, 23 May 2019 17:11:41 +0300
Subject: [PATCH 0009/1978] [Catalog|Sales] Fix wrong behavior of grid row
click event
---
.../web/catalog/category/assign-products.js | 19 +-
.../adminhtml/web/order/create/scripts.js | 445 +++++++++---------
lib/web/mage/adminhtml/grid.js | 89 ++--
3 files changed, 293 insertions(+), 260 deletions(-)
diff --git a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/assign-products.js b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/assign-products.js
index 829c04c13106d..598bde9106231 100644
--- a/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/assign-products.js
+++ b/app/code/Magento/Catalog/view/adminhtml/web/catalog/category/assign-products.js
@@ -51,15 +51,28 @@ define([
*/
function categoryProductRowClick(grid, event) {
var trElement = Event.findElement(event, 'tr'),
- isInput = Event.element(event).tagName === 'INPUT',
+ eventElement = Event.element(event),
+ isInputCheckbox = eventElement.tagName === 'INPUT' && eventElement.type === 'checkbox',
+ isInputPosition = grid.targetElement
+ && grid.targetElement.tagName === 'INPUT'
+ && grid.targetElement.name === 'position',
checked = false,
checkbox = null;
- if (trElement) {
+ if (eventElement.tagName === 'LABEL'
+ && trElement.querySelector('#' + eventElement.htmlFor)
+ && trElement.querySelector('#' + eventElement.htmlFor).type === 'checkbox'
+ ) {
+ event.stopPropagation();
+ trElement.querySelector('#' + eventElement.htmlFor).trigger('click');
+ return;
+ }
+
+ if (trElement && !isInputPosition) {
checkbox = Element.getElementsBySelector(trElement, 'input');
if (checkbox[0]) {
- checked = isInput ? checkbox[0].checked : !checkbox[0].checked;
+ checked = isInputCheckbox ? checkbox[0].checked : !checkbox[0].checked;
gridJsObject.setCheckboxChecked(checkbox[0], checked);
}
}
diff --git a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js
index c508a5ecdfa58..d6221b8914449 100644
--- a/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js
+++ b/app/code/Magento/Sales/view/adminhtml/web/order/create/scripts.js
@@ -19,17 +19,17 @@ define([
window.AdminOrder = new Class.create();
AdminOrder.prototype = {
- initialize : function(data){
- if(!data) data = {};
- this.loadBaseUrl = false;
- this.customerId = data.customer_id ? data.customer_id : false;
- this.storeId = data.store_id ? data.store_id : false;
- this.quoteId = data['quote_id'] ? data['quote_id'] : false;
- this.currencyId = false;
+ initialize: function (data) {
+ if (!data) data = {};
+ this.loadBaseUrl = false;
+ this.customerId = data.customer_id ? data.customer_id : false;
+ this.storeId = data.store_id ? data.store_id : false;
+ this.quoteId = data['quote_id'] ? data['quote_id'] : false;
+ this.currencyId = false;
this.currencySymbol = data.currency_symbol ? data.currency_symbol : '';
- this.addresses = data.addresses ? data.addresses : $H({});
+ this.addresses = data.addresses ? data.addresses : $H({});
this.shippingAsBilling = data.shippingAsBilling ? data.shippingAsBilling : false;
- this.gridProducts = $H({});
+ this.gridProducts = $H({});
this.gridProductsGift = $H({});
this.billingAddressContainer = '';
this.shippingAddressContainer = '';
@@ -55,10 +55,10 @@ define([
}
});
- jQuery.async('#order-items', (function(){
+ jQuery.async('#order-items', (function () {
this.dataArea = new OrderFormArea('data', $(this.getAreaId('data')), this);
this.itemsArea = Object.extend(new OrderFormArea('items', $(this.getAreaId('items')), this), {
- addControlButton: function(button){
+ addControlButton: function (button) {
var controlButtonArea = $(this.node).select('.actions')[0];
if (typeof controlButtonArea != 'undefined') {
var buttons = controlButtonArea.childElements();
@@ -75,7 +75,7 @@ define([
var searchButtonId = 'add_products',
searchButton = new ControlButton(jQuery.mage.__('Add Products'), searchButtonId),
searchAreaId = this.getAreaId('search');
- searchButton.onClick = function() {
+ searchButton.onClick = function () {
$(searchAreaId).show();
var el = this;
window.setTimeout(function () {
@@ -84,13 +84,13 @@ define([
};
if (jQuery('#' + this.getAreaId('items')).is(':visible')) {
- this.dataArea.onLoad = this.dataArea.onLoad.wrap(function(proceed) {
+ this.dataArea.onLoad = this.dataArea.onLoad.wrap(function (proceed) {
proceed();
this._parent.itemsArea.setNode($(this._parent.getAreaId('items')));
this._parent.itemsArea.onLoad();
});
- this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function(proceed) {
+ this.itemsArea.onLoad = this.itemsArea.onLoad.wrap(function (proceed) {
proceed();
if ($(searchAreaId) && !$(searchAreaId).visible() && !$(searchButtonId)) {
this.addControlButton(searchButton);
@@ -102,35 +102,35 @@ define([
}).bind(this));
jQuery('#edit_form')
- .on('submitOrder', function(){
+ .on('submitOrder', function () {
jQuery(this).trigger('realOrder');
})
.on('realOrder', this._realSubmit.bind(this));
},
- areasLoaded: function(){
+ areasLoaded: function () {
},
- itemsLoaded: function(){
+ itemsLoaded: function () {
},
- dataLoaded: function(){
+ dataLoaded: function () {
this.dataShow();
},
- setLoadBaseUrl : function(url){
+ setLoadBaseUrl: function (url) {
this.loadBaseUrl = url;
},
- setAddresses : function(addresses){
+ setAddresses: function (addresses) {
this.addresses = addresses;
},
- addExcludedPaymentMethod : function(method){
+ addExcludedPaymentMethod: function (method) {
this.excludedPaymentMethods.push(method);
},
- setCustomerId : function(id){
+ setCustomerId: function (id) {
this.customerId = id;
this.loadArea('header', true);
$(this.getAreaId('header')).callback = 'setCustomerAfter';
@@ -138,18 +138,17 @@ define([
$('reset_order_top_button').show();
},
- setCustomerAfter : function () {
+ setCustomerAfter: function () {
this.customerSelectorHide();
if (this.storeId) {
$(this.getAreaId('data')).callback = 'dataLoaded';
this.loadArea(['data'], true);
- }
- else {
+ } else {
this.storeSelectorShow();
}
},
- setStoreId : function(id){
+ setStoreId: function (id) {
this.storeId = id;
this.storeSelectorHide();
this.sidebarShow();
@@ -158,26 +157,25 @@ define([
this.loadArea(['header', 'data'], true);
},
- setCurrencyId : function(id){
+ setCurrencyId: function (id) {
this.currencyId = id;
//this.loadArea(['sidebar', 'data'], true);
this.loadArea(['data'], true);
},
- setCurrencySymbol : function(symbol){
+ setCurrencySymbol: function (symbol) {
this.currencySymbol = symbol;
},
- selectAddress : function(el, container){
+ selectAddress: function (el, container) {
id = el.value;
if (id.length == 0) {
id = '0';
}
- if(this.addresses[id]){
+ if (this.addresses[id]) {
this.fillAddressFields(container, this.addresses[id]);
- }
- else{
+ } else {
this.fillAddressFields(container, {});
}
@@ -187,7 +185,7 @@ define([
this.resetPaymentMethod();
if (this.isShippingField(container) && !this.isShippingMethodReseted) {
this.resetShippingMethod(data);
- } else{
+ } else {
this.saveData(data);
}
},
@@ -313,13 +311,13 @@ define([
});
},
- fillAddressFields: function(container, data){
+ fillAddressFields: function (container, data) {
var regionIdElem = false;
var regionIdElemValue = false;
var fields = $(container).select('input', 'select', 'textarea');
var re = /[^\[]*\[[^\]]*\]\[([^\]]*)\](\[(\d)\])?/;
- for(var i=0;i 0) {
@@ -606,29 +610,39 @@ define([
input.disabled = !checkbox.checked || input.hasClassName('input-inactive');
- Event.observe(input,'keyup', this.productGridRowInputChange.bind(this));
- Event.observe(input,'change',this.productGridRowInputChange.bind(this));
+ Event.observe(input, 'keyup', this.productGridRowInputChange.bind(this));
+ Event.observe(input, 'change', this.productGridRowInputChange.bind(this));
}
}
},
- productGridRowInputChange : function(event){
+ productGridRowInputChange: function (event) {
var element = Event.element(event);
- if (element && element.checkboxElement && element.checkboxElement.checked){
- if (element.name!='giftmessage' || element.checked) {
+ if (element && element.checkboxElement && element.checkboxElement.checked) {
+ if (element.name != 'giftmessage' || element.checked) {
this.gridProducts.get(element.checkboxElement.value)[element.name] = element.value;
- } else if (element.name=='giftmessage' && this.gridProducts.get(element.checkboxElement.value)[element.name]) {
- delete(this.gridProducts.get(element.checkboxElement.value)[element.name]);
+ } else if (element.name == 'giftmessage' && this.gridProducts.get(element.checkboxElement.value)[element.name]) {
+ delete (this.gridProducts.get(element.checkboxElement.value)[element.name]);
}
}
},
- productGridRowClick : function(grid, event){
+ productGridRowClick: function (grid, event) {
var trElement = Event.findElement(event, 'tr');
var qtyElement = trElement.select('input[name="qty"]')[0];
var eventElement = Event.element(event);
- var isInputCheckbox = eventElement.tagName == 'INPUT' && eventElement.type == 'checkbox';
- var isInputQty = eventElement.tagName == 'INPUT' && eventElement.name == 'qty';
+
+ if (eventElement.tagName === 'LABEL'
+ && trElement.querySelector('#' + eventElement.htmlFor)
+ && trElement.querySelector('#' + eventElement.htmlFor).type === 'checkbox'
+ ) {
+ event.stopPropagation();
+ trElement.querySelector('#' + eventElement.htmlFor).trigger('click');
+ return;
+ }
+
+ var isInputCheckbox = (eventElement.tagName === 'INPUT' && eventElement.type === 'checkbox');
+ var isInputQty = grid.targetElement && grid.targetElement.tagName === 'INPUT' && grid.targetElement.name === 'qty';
if (trElement && !isInputQty) {
var checkbox = Element.select(trElement, 'input[type="checkbox"]')[0];
var confLink = Element.select(trElement, 'a')[0];
@@ -650,10 +664,10 @@ define([
if (!priceBase) {
this.productPriceBase[productId] = 0;
} else {
- this.productPriceBase[productId] = parseFloat(priceBase[1].replace(/,/g,''));
+ this.productPriceBase[productId] = parseFloat(priceBase[1].replace(/,/g, ''));
}
}
- productConfigure.setConfirmCallback(listType, function() {
+ productConfigure.setConfirmCallback(listType, function () {
// sync qty of popup and qty of grid
var confirmedCurrentQty = productConfigure.getCurrentConfirmedQtyElement();
if (qtyElement && confirmedCurrentQty && !isNaN(confirmedCurrentQty.value)) {
@@ -669,12 +683,12 @@ define([
// and set checkbox checked
grid.setCheckboxChecked(checkbox, true);
}.bind(this));
- productConfigure.setCancelCallback(listType, function() {
+ productConfigure.setCancelCallback(listType, function () {
if (!$(productConfigure.confirmedCurrentId) || !$(productConfigure.confirmedCurrentId).innerHTML) {
grid.setCheckboxChecked(checkbox, false);
}
});
- productConfigure.setShowWindowCallback(listType, function() {
+ productConfigure.setShowWindowCallback(listType, function () {
// sync qty of grid and qty of popup
var formCurrentQty = productConfigure.getCurrentFormQtyElement();
if (formCurrentQty && qtyElement && !isNaN(qtyElement.value)) {
@@ -690,7 +704,7 @@ define([
/**
* Is need to summarize price
*/
- _isSummarizePrice: function(elm) {
+ _isSummarizePrice: function (elm) {
if (elm && elm.hasAttribute('summarizePrice')) {
this.summarizePrice = parseInt(elm.readAttribute('summarizePrice'));
}
@@ -717,9 +731,9 @@ define([
}
return 0;
};
- for(var i = 0; i < elms.length; i++) {
+ for (var i = 0; i < elms.length; i++) {
if (elms[i].type == 'select-one' || elms[i].type == 'select-multiple') {
- for(var ii = 0; ii < elms[i].options.length; ii++) {
+ for (var ii = 0; ii < elms[i].options.length; ii++) {
if (elms[i].options[ii].selected) {
if (this._isSummarizePrice(elms[i].options[ii])) {
productPrice += getPrice(elms[i].options[ii]);
@@ -728,8 +742,7 @@ define([
}
}
}
- }
- else if (((elms[i].type == 'checkbox' || elms[i].type == 'radio') && elms[i].checked)
+ } else if (((elms[i].type == 'checkbox' || elms[i].type == 'radio') && elms[i].checked)
|| ((elms[i].type == 'file' || elms[i].type == 'text' || elms[i].type == 'textarea' || elms[i].type == 'hidden')
&& Form.Element.getValue(elms[i]))
) {
@@ -748,9 +761,9 @@ define([
return productPrice;
},
- productGridCheckboxCheck : function(grid, element, checked){
+ productGridCheckboxCheck: function (grid, element, checked) {
if (checked) {
- if(element.inputElements) {
+ if (element.inputElements) {
this.gridProducts.set(element.value, {});
var product = this.gridProducts.get(element.value);
for (var i = 0; i < element.inputElements.length; i++) {
@@ -765,36 +778,36 @@ define([
if (input.checked || input.name != 'giftmessage') {
product[input.name] = input.value;
} else if (product[input.name]) {
- delete(product[input.name]);
+ delete (product[input.name]);
}
}
}
} else {
- if(element.inputElements){
- for(var i = 0; i < element.inputElements.length; i++) {
+ if (element.inputElements) {
+ for (var i = 0; i < element.inputElements.length; i++) {
element.inputElements[i].disabled = true;
}
}
this.gridProducts.unset(element.value);
}
- grid.reloadParams = {'products[]':this.gridProducts.keys()};
+ grid.reloadParams = {'products[]': this.gridProducts.keys()};
},
/**
* Submit configured products to quote
*/
- productGridAddSelected : function(){
- if(this.productGridShowButton) Element.show(this.productGridShowButton);
- var area = ['search', 'items', 'shipping_method', 'totals', 'giftmessage','billing_method'];
+ productGridAddSelected: function () {
+ if (this.productGridShowButton) Element.show(this.productGridShowButton);
+ var area = ['search', 'items', 'shipping_method', 'totals', 'giftmessage', 'billing_method'];
// prepare additional fields and filtered items of products
var fieldsPrepare = {};
var itemsFilter = [];
var products = this.gridProducts.toObject();
for (var productId in products) {
itemsFilter.push(productId);
- var paramKey = 'item['+productId+']';
+ var paramKey = 'item[' + productId + ']';
for (var productParamKey in products[productId]) {
- paramKey += '['+productParamKey+']';
+ paramKey += '[' + productParamKey + ']';
fieldsPrepare[paramKey] = products[productId][productParamKey];
}
}
@@ -804,47 +817,47 @@ define([
this.gridProducts = $H({});
},
- selectCustomer : function(grid, event){
+ selectCustomer: function (grid, event) {
var element = Event.findElement(event, 'tr');
- if (element.title){
+ if (element.title) {
this.setCustomerId(element.title);
}
},
- customerSelectorHide : function(){
+ customerSelectorHide: function () {
this.hideArea('customer-selector');
},
- customerSelectorShow : function(){
+ customerSelectorShow: function () {
this.showArea('customer-selector');
},
- storeSelectorHide : function(){
+ storeSelectorHide: function () {
this.hideArea('store-selector');
},
- storeSelectorShow : function(){
+ storeSelectorShow: function () {
this.showArea('store-selector');
},
- dataHide : function(){
+ dataHide: function () {
this.hideArea('data');
},
- dataShow : function(){
+ dataShow: function () {
if ($('submit_order_top_button')) {
$('submit_order_top_button').show();
}
this.showArea('data');
},
- clearShoppingCart : function(confirmMessage){
+ clearShoppingCart: function (confirmMessage) {
var self = this;
confirm({
content: confirmMessage,
actions: {
- confirm: function() {
+ confirm: function () {
self.collectElementsValue = false;
order.sidebarApplyChanges({'sidebar[empty_customer_cart]': 1});
self.collectElementsValue = true;
@@ -853,12 +866,12 @@ define([
});
},
- sidebarApplyChanges : function(auxiliaryParams) {
+ sidebarApplyChanges: function (auxiliaryParams) {
if ($(this.getAreaId('sidebar'))) {
var data = {};
if (this.collectElementsValue) {
var elems = $(this.getAreaId('sidebar')).select('input');
- for (var i=0; i < elems.length; i++) {
+ for (var i = 0; i < elems.length; i++) {
if (elems[i].getValue()) {
data[elems[i].name] = elems[i].getValue();
}
@@ -870,20 +883,20 @@ define([
}
}
data.reset_shipping = true;
- this.loadArea(['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true, data);
+ this.loadArea(['sidebar', 'items', 'shipping_method', 'billing_method', 'totals', 'giftmessage'], true, data);
}
},
- sidebarHide : function(){
- if(this.storeId === false && $('page:left') && $('page:container')){
+ sidebarHide: function () {
+ if (this.storeId === false && $('page:left') && $('page:container')) {
$('page:left').hide();
$('page:container').removeClassName('container');
$('page:container').addClassName('container-collapsed');
}
},
- sidebarShow : function(){
- if($('page:left') && $('page:container')){
+ sidebarShow: function () {
+ if ($('page:left') && $('page:container')) {
$('page:left').show();
$('page:container').removeClassName('container-collapsed');
$('page:container').addClassName('container');
@@ -904,7 +917,7 @@ define([
for (var i in params) {
if (params[i] === null) {
unset(params[i]);
- } else if (typeof(params[i]) == 'boolean') {
+ } else if (typeof (params[i]) == 'boolean') {
params[i] = params[i] ? 1 : 0;
}
}
@@ -913,15 +926,15 @@ define([
fields.push(new Element('input', {type: 'hidden', name: name, value: params[name]}));
}
// add additional fields before triggered submit
- productConfigure.setBeforeSubmitCallback(listType, function() {
+ productConfigure.setBeforeSubmitCallback(listType, function () {
productConfigure.addFields(fields);
}.bind(this));
// response handler
- productConfigure.setOnLoadIFrameCallback(listType, function(response) {
+ productConfigure.setOnLoadIFrameCallback(listType, function (response) {
if (!response.ok) {
return;
}
- this.loadArea(['items', 'shipping_method', 'billing_method','totals', 'giftmessage'], true);
+ this.loadArea(['items', 'shipping_method', 'billing_method', 'totals', 'giftmessage'], true);
}.bind(this));
// show item configuration
itemId = itemId ? itemId : productId;
@@ -929,17 +942,17 @@ define([
return false;
},
- removeSidebarItem : function(id, from){
- this.loadArea(['sidebar_'+from], 'sidebar_data_'+from, {remove_item:id, from:from});
+ removeSidebarItem: function (id, from) {
+ this.loadArea(['sidebar_' + from], 'sidebar_data_' + from, {remove_item: id, from: from});
},
- itemsUpdate : function(){
- var area = ['sidebar', 'items', 'shipping_method', 'billing_method','totals', 'giftmessage'];
+ itemsUpdate: function () {
+ var area = ['sidebar', 'items', 'shipping_method', 'billing_method', 'totals', 'giftmessage'];
// prepare additional fields
var fieldsPrepare = {update_items: 1};
var info = $('order-items_grid').select('input', 'select', 'textarea');
- for(var i=0; i 0;
//Hash with grid data
- this.gridData = this.getGridDataHash(predefinedData);
+ this.gridData = this.getGridDataHash(predefinedData);
//Hidden input data holder
- this.hiddenDataHolder = $(hiddenDataHolder);
+ this.hiddenDataHolder = $(hiddenDataHolder);
this.hiddenDataHolder.value = this.serializeObject();
this.grid = grid;
@@ -1439,7 +1452,7 @@ define([
*/
rowClick: function (grid, event) {
var trElement = Event.findElement(event, 'tr'),
- isInput = Event.element(event).tagName == 'INPUT', //eslint-disable-line eqeqeq
+ isInput = Event.element(event).tagName == 'INPUT', //eslint-disable-line eqeqeq
checkbox, checked;
if (trElement) {
From 66c4798fb31a0999358d7e19d3dce073665e304e Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Thu, 23 May 2019 18:32:12 +0300
Subject: [PATCH 0010/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- The translate for exception was added
---
.../Model/Order/Shipment/TrackRepository.php | 24 +++++++++++++------
app/code/Magento/Sales/i18n/en_US.csv | 1 +
2 files changed, 18 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
index b9911518ad58c..c8fc9e5fc5600 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
@@ -16,8 +16,9 @@
use Magento\Sales\Api\Data\ShipmentTrackSearchResultInterfaceFactory;
use Magento\Sales\Api\ShipmentTrackRepositoryInterface;
use Magento\Sales\Model\Spi\ShipmentTrackResourceInterface;
-use \Magento\Sales\Model\OrderRepository;
+use \Magento\Sales\Api\OrderRepositoryInterface;
use \Magento\Framework\App\ObjectManager;
+use Psr\Log\LoggerInterface;
/**
* Repository of shipment tracking information
@@ -45,31 +46,39 @@ class TrackRepository implements ShipmentTrackRepositoryInterface
private $collectionProcessor;
/**
- * @var OrderRepository
+ * @var OrderRepositoryInterface
*/
private $orderRepository;
+ /**
+ * @var LoggerInterface
+ */
+ private $logger;
+
/**
* @param ShipmentTrackResourceInterface $trackResource
* @param ShipmentTrackInterfaceFactory $trackFactory
* @param ShipmentTrackSearchResultInterfaceFactory $searchResultFactory
* @param CollectionProcessorInterface $collectionProcessor
- * @param OrderRepository $orderRepository
+ * @param OrderRepositoryInterface|null $orderRepository
+ * @param LoggerInterface|null $logger
*/
public function __construct(
ShipmentTrackResourceInterface $trackResource,
ShipmentTrackInterfaceFactory $trackFactory,
ShipmentTrackSearchResultInterfaceFactory $searchResultFactory,
CollectionProcessorInterface $collectionProcessor,
- OrderRepository $orderRepository = null
+ OrderRepositoryInterface $orderRepository = null,
+ LoggerInterface $logger = null
) {
-
$this->trackResource = $trackResource;
$this->trackFactory = $trackFactory;
$this->searchResultFactory = $searchResultFactory;
$this->collectionProcessor = $collectionProcessor;
$this->orderRepository = $orderRepository ?:
- ObjectManager::getInstance()->get(OrderRepository::class);
+ ObjectManager::getInstance()->get(OrderRepositoryInterface::class);
+ $this->logger = $logger ?:
+ ObjectManager::getInstance()->get(LoggerInterface::class);
}
/**
@@ -118,7 +127,8 @@ public function save(ShipmentTrackInterface $entity)
}
if (array_search($entity['parent_id'], $shipmentId) === false) {
- throw new CouldNotSaveException(__('The shipment doesn\'t belong to the order.'));
+ $this->logger->error('The shipment doesn\'t belong to the order.');
+ throw new CouldNotSaveException(__('Could not save the shipment tracking.'));
}
try {
diff --git a/app/code/Magento/Sales/i18n/en_US.csv b/app/code/Magento/Sales/i18n/en_US.csv
index c5657f3a309f7..662781204f78b 100644
--- a/app/code/Magento/Sales/i18n/en_US.csv
+++ b/app/code/Magento/Sales/i18n/en_US.csv
@@ -797,3 +797,4 @@ Created,Created
Refunds,Refunds
"Allow Zero GrandTotal for Creditmemo","Allow Zero GrandTotal for Creditmemo"
"Allow Zero GrandTotal","Allow Zero GrandTotal"
+"Could not save the shipment tracking"
\ No newline at end of file
From 6daa19b40fdd586664de9193c4a880d5202dda75 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Tue, 28 May 2019 10:15:28 +0300
Subject: [PATCH 0011/1978] Small adjustments
---
...PagerShoppingCartWithMoreThan20ProductsTest.xml | 14 +++++++-------
...tMissingPagerShoppingCartWith20ProductsTest.xml | 8 ++++----
...gCartPagerForOneItemPerPageAnd2ProductsTest.xml | 8 ++++----
.../Test/TestCase/ShoppingCartPagerTest.xml | 12 ++++--------
4 files changed, 19 insertions(+), 23 deletions(-)
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
index 89d6d654f1444..06893679a5948 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
@@ -31,6 +31,13 @@
+
+
+
+
+
+
+
@@ -42,12 +49,5 @@
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
index e9f83bb9cc167..57a45112a668b 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
@@ -24,14 +24,14 @@
+
+
+
+
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
index 4e3bd22ccde51..fd2169a9dbfd7 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
@@ -31,10 +31,6 @@
-
-
-
-
@@ -42,5 +38,9 @@
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml
index 27e9583db5fd2..e03351de7a2b1 100644
--- a/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Checkout/Test/TestCase/ShoppingCartPagerTest.xml
@@ -8,29 +8,25 @@
- severity:S2
- mftf_migrated:yes
+ severity:S2,mftf_migrated:yes
- severity:S2
+ severity:S2,mftf_migrated:yes
default_number_of_items_per_page_on_shopping_cart
catalogProductSimple::default
- mftf_migrated:yes
- severity:S2
+ severity:S2,mftf_migrated:yes
catalogProductSimple::default
1
- mftf_migrated:yes
- severity:S2
+ severity:S2,mftf_migrated:yes
one_item_per_page_on_shopping_cart
- mftf_migrated:yes
From 4b62b6524eee31f4dbdb579bf51405c2a8579e43 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Wed, 29 May 2019 10:29:58 +0300
Subject: [PATCH 0012/1978] Refactoring the Action Group naming
---
...onGroup.xml => AssertTextIsVisibleOnPageActionGroup.xml} | 6 +++---
...rontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml | 2 +-
...ntShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
rename app/code/Magento/Checkout/Test/Mftf/ActionGroup/{AssertIsVisibleCartPagerTextActionGroup.xml => AssertTextIsVisibleOnPageActionGroup.xml} (70%)
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
similarity index 70%
rename from app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml
rename to app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
index f1793ecd640b4..0eb584d4c2242 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsVisibleCartPagerTextActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
@@ -7,11 +7,11 @@
-->
-
+
-
-
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
index 06893679a5948..0c9411db4f5ca 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
@@ -40,7 +40,7 @@
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
index fd2169a9dbfd7..5ba1b0122c6e6 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
@@ -39,7 +39,7 @@
-
+
From b39ae28f96dd1d12d7494c888c378a45d7457fb9 Mon Sep 17 00:00:00 2001
From: Stsiapan Korf
Date: Thu, 30 May 2019 10:53:14 +0000
Subject: [PATCH 0013/1978] MAGETWO-98703: CSV file is not exported
- Change message
---
.../ImportExport/Controller/Adminhtml/Export/Export.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php
index 13c22a976e798..c111a9dd22948 100644
--- a/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php
+++ b/app/code/Magento/ImportExport/Controller/Adminhtml/Export/Export.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\ImportExport\Controller\Adminhtml\Export;
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
@@ -85,7 +87,10 @@ public function execute()
$this->messagePublisher->publish('import_export.export', $dataObject);
$this->messageManager->addSuccessMessage(
- __('Message is added to queue, wait to get your file soon')
+ __(
+ 'Message is added to queue, wait to get your file soon.'
+ . ' Make sure your cron job is running to export the file'
+ )
);
} catch (\Exception $e) {
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
From cd0618ae7885208e8cab4fac92b8d8bac87dd749 Mon Sep 17 00:00:00 2001
From: Vital_Pantsialeyeu
Date: Mon, 3 Jun 2019 17:26:13 +0300
Subject: [PATCH 0014/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Added API-functional test
---
.../testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
index c25956a4858ec..5b7b1bf606932 100644
--- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
@@ -104,7 +104,7 @@ public function testShipmentTrackWithFailedOrderId()
ShipmentTrackInterface::TITLE => 'Shipment title',
ShipmentTrackInterface::CARRIER_CODE => Track::CUSTOM_CARRIER_CODE,
];
- $expectedMessage = 'The shipment doesn\'t belong to the order.';
+ $expectedMessage = 'Could not save the shipment tracking.';
try {
$this->_webApiCall($this->getServiceInfo(), ['entity' => $trackData]);
From e4062ebe6fb4ed4fd0b9253be543cfbe6e585b7b Mon Sep 17 00:00:00 2001
From: eduard13
Date: Wed, 5 Jun 2019 18:14:51 +0300
Subject: [PATCH 0015/1978] Refactoring the Tests, Action Groups by removing
the not needed Action Groups
---
...rtIsNotVisibleCartPagerTextActionGroup.xml | 2 +-
.../AssertTextIsVisibleOnPageActionGroup.xml | 3 +-
...orefrontAdd20ProductsToCartActionGroup.xml | 112 ----------------
.../StorefrontAddProductToCartActionGroup.xml | 13 ++
.../StorefrontDelete20ProductsActionGroup.xml | 32 -----
.../StorefrontOpenCartPageActionGroup.xml | 14 ++
.../StorefrontRemoveCartItemActionGroup.xml | 13 ++
.../Test/Mftf/Page/CheckoutCartPage.xml | 1 +
.../Section/StorefrontCartToolbarSection.xml | 17 +++
...ShoppingCartWithMoreThan20ProductsTest.xml | 121 +++++++++++++++---
...ingPagerShoppingCartWith20ProductsTest.xml | 106 ++++++++++++++-
...PagerForOneItemPerPageAnd2ProductsTest.xml | 5 +-
12 files changed, 270 insertions(+), 169 deletions(-)
delete mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml
delete mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontRemoveCartItemActionGroup.xml
create mode 100644 app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCartToolbarSection.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml
index d08a6f3cf5053..2072cb6df1dc1 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertIsNotVisibleCartPagerTextActionGroup.xml
@@ -12,6 +12,6 @@
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
index 0eb584d4c2242..8f1920a28d9f1 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
@@ -10,8 +10,9 @@
+
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml
deleted file mode 100644
index b4662afffec69..0000000000000
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAdd20ProductsToCartActionGroup.xml
+++ /dev/null
@@ -1,112 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml
new file mode 100644
index 0000000000000..f2d4088370a2b
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml
deleted file mode 100644
index f3db7f989d31d..0000000000000
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontDelete20ProductsActionGroup.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml
new file mode 100644
index 0000000000000..fe1e48e00c5bb
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontOpenCartPageActionGroup.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontRemoveCartItemActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontRemoveCartItemActionGroup.xml
new file mode 100644
index 0000000000000..f2d4088370a2b
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontRemoveCartItemActionGroup.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutCartPage.xml b/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutCartPage.xml
index a77b07a129dce..cf7f2baeb4b26 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutCartPage.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Page/CheckoutCartPage.xml
@@ -9,6 +9,7 @@
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCartToolbarSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCartToolbarSection.xml
new file mode 100644
index 0000000000000..ff40449369530
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontCartToolbarSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
index 0c9411db4f5ca..41554db6d3a4f 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
@@ -22,30 +22,121 @@
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
-
-
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
index 57a45112a668b..aeeb8a0d718e8 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontMissingPagerShoppingCartWith20ProductsTest.xml
@@ -21,15 +21,111 @@
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
index 5ba1b0122c6e6..2b6c31a941efe 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
@@ -21,7 +21,6 @@
-
@@ -34,13 +33,13 @@
-
-
+
+
From 86ac6e56e190a4407189352bbbdbdd8b850ad921 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Wed, 5 Jun 2019 18:50:49 +0300
Subject: [PATCH 0016/1978] Removing not needed ActionGroup. Adjusting the Test
---
.../StorefrontAddProductToCartActionGroup.xml | 13 -------------
...kPagerShoppingCartWithMoreThan20ProductsTest.xml | 1 -
2 files changed, 14 deletions(-)
delete mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml
deleted file mode 100644
index f2d4088370a2b..0000000000000
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontAddProductToCartActionGroup.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
index 41554db6d3a4f..08922c019bdcd 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
@@ -108,7 +108,6 @@
-
From 89dd87d5a150edccb542085b51c3b5bfdf6592f7 Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Fri, 7 Jun 2019 18:04:29 +0300
Subject: [PATCH 0017/1978] Convert NewCustomerPasswordComplexityTest
---
.../StorefrontFillRegistryFormActionGroup.xml | 31 +++++++++++++++++
.../StorefrontSeeHeaderLinksActionGroup.xml | 19 +++++++++++
.../Mftf/Section/StorefrontHeaderSection.xml | 16 +++++++++
.../NewCustomerPasswordComplexityTest.xml | 33 +++++++++++++++++++
4 files changed, 99 insertions(+)
create mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml
create mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml
create mode 100644 app/code/Magento/Cms/Test/Mftf/Section/StorefrontHeaderSection.xml
create mode 100644 app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml
new file mode 100644
index 0000000000000..0a1440937a554
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml
new file mode 100644
index 0000000000000..b70560ad2cd86
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Section/StorefrontHeaderSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/StorefrontHeaderSection.xml
new file mode 100644
index 0000000000000..fefde1e6035f3
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/Section/StorefrontHeaderSection.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml b/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
new file mode 100644
index 0000000000000..a414878997021
--- /dev/null
+++ b/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 100a81eb41648eabb41c2d77059368750916758e Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Fri, 7 Jun 2019 18:32:45 +0300
Subject: [PATCH 0018/1978] Refactoring
---
.../Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml b/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
index a414878997021..29135332d6125 100644
--- a/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
+++ b/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
@@ -23,7 +23,7 @@
-
+
From ce6ef8b47ce93e36cb32dd9658dc8d32a7caf91d Mon Sep 17 00:00:00 2001
From: Aliaksei Yakimovich2
Date: Mon, 17 Jun 2019 18:06:15 +0300
Subject: [PATCH 0019/1978] MC-15523: Watermark is possible to set up for
swatch image type
- Removed config section for swatches watermark image;
---
.../Mftf/Test/AdminWatermarkUploadTest.xml | 16 -----
app/code/Magento/Swatches/etc/config.xml | 5 --
app/code/Magento/Swatches/etc/di.xml | 33 ---------
.../ui_component/design_config_form.xml | 72 -------------------
4 files changed, 126 deletions(-)
delete mode 100644 app/code/Magento/Swatches/Test/Mftf/Test/AdminWatermarkUploadTest.xml
delete mode 100644 app/code/Magento/Swatches/view/adminhtml/ui_component/design_config_form.xml
diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminWatermarkUploadTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminWatermarkUploadTest.xml
deleted file mode 100644
index e9df186bae5e6..0000000000000
--- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminWatermarkUploadTest.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Swatches/etc/config.xml b/app/code/Magento/Swatches/etc/config.xml
index 65b36558c2796..6b487821dd462 100644
--- a/app/code/Magento/Swatches/etc/config.xml
+++ b/app/code/Magento/Swatches/etc/config.xml
@@ -21,10 +21,5 @@
-
-
- stretch
-
-
diff --git a/app/code/Magento/Swatches/etc/di.xml b/app/code/Magento/Swatches/etc/di.xml
index 5292bfafb6a0f..ca24f1afe8b46 100644
--- a/app/code/Magento/Swatches/etc/di.xml
+++ b/app/code/Magento/Swatches/etc/di.xml
@@ -40,39 +40,6 @@
-
-
-
- -
-
- design/watermark/swatch_image_size
- - other_settings/watermark/swatch_image
-
- -
-
- design/watermark/swatch_image_imageOpacity
- - other_settings/watermark/swatch_image
-
- -
-
- design/watermark/swatch_image_image
- - other_settings/watermark/swatch_image
- - Magento\Theme\Model\Design\Backend\Image
- -
-
- system/filesystem/media
- - 1
- - catalog/product/watermark
-
- -
-
- media
- - 1
- - catalog/product/watermark
-
-
- -
-
- design/watermark/swatch_image_position
- - other_settings/watermark/swatch_image
-
-
-
-
swatch-attribute-list
diff --git a/app/code/Magento/Swatches/view/adminhtml/ui_component/design_config_form.xml b/app/code/Magento/Swatches/view/adminhtml/ui_component/design_config_form.xml
deleted file mode 100644
index b38e8ecc6e201..0000000000000
--- a/app/code/Magento/Swatches/view/adminhtml/ui_component/design_config_form.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
From 1d70b8d7c219ae7ba4f3065f0974d2efc7556fe2 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Tue, 11 Jun 2019 22:43:11 +0400
Subject: [PATCH 0020/1978] MAGETWO-98703: CSV file is not exported
- Added automated test
---
...ageAfterAddingExportingFileToQueueTest.xml | 45 +++++++++++++++++++
1 file changed, 45 insertions(+)
create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml
new file mode 100644
index 0000000000000..f947efff9f2c9
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml
@@ -0,0 +1,45 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 3333179e9f3bff83e873a353f4e374baa4cc3b0d Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Wed, 19 Jun 2019 14:36:11 +0300
Subject: [PATCH 0021/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Added translation
---
app/code/Magento/Sales/i18n/en_US.csv | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/i18n/en_US.csv b/app/code/Magento/Sales/i18n/en_US.csv
index 662781204f78b..a881a59b535fd 100644
--- a/app/code/Magento/Sales/i18n/en_US.csv
+++ b/app/code/Magento/Sales/i18n/en_US.csv
@@ -797,4 +797,4 @@ Created,Created
Refunds,Refunds
"Allow Zero GrandTotal for Creditmemo","Allow Zero GrandTotal for Creditmemo"
"Allow Zero GrandTotal","Allow Zero GrandTotal"
-"Could not save the shipment tracking"
\ No newline at end of file
+"Could not save the shipment tracking","Could not save the shipment tracking"
\ No newline at end of file
From f358005a86a3face6392fc0f53d623888e75e532 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Sun, 23 Jun 2019 21:42:19 +0300
Subject: [PATCH 0022/1978] Add test for admin user role update functionality
---
.../AssertAdminUserIsInGridActionGroup.xml | 14 +++++
...ertUserRoleRestrictedAccessActionGroup.xml | 15 +++++
...ssertUserSuccessSaveMessageActionGroup.xml | 14 +++++
.../AdminDeleteUserRoleActionGroup.xml | 18 ++++++
.../AdminNavigateToUserRolesActionGroup.xml | 16 +++++
.../AdminOpenUserEditPageActionGroup.xml | 19 ++++++
.../AdminUpdateUserRoleActionGroup.xml | 21 +++++++
.../User/Test/Mftf/Data/UserRoleData.xml | 5 ++
.../Mftf/Section/AdminDeleteRoleSection.xml | 3 +
.../Mftf/Section/AdminUserGridSection.xml | 1 +
.../Mftf/Test/AdminUpdateUserRoleTest.xml | 60 +++++++++++++++++++
11 files changed, 186 insertions(+)
create mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
create mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
create mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml
create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml
create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml
create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
create mode 100644 app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
new file mode 100644
index 0000000000000..bb73606a92b93
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
new file mode 100644
index 0000000000000..b98731e117e1f
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml
new file mode 100644
index 0000000000000..2d451875c6358
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml
new file mode 100644
index 0000000000000..24d652313c544
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml
new file mode 100644
index 0000000000000..d86bc7d11dbbf
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
new file mode 100644
index 0000000000000..ff7871cc1d5fe
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
new file mode 100644
index 0000000000000..c7f5078832cf5
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
index 1c18ca13b9731..3f437e4c0ad8f 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
@@ -24,4 +24,9 @@
Custom
['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails','Magento_Backend::system','Magento_Backend::system_other_settings','Magento_AdminNotification::adminnotification','Magento_AdminNotification::show_list']
+
+ Sales
+ Custom
+ ['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails']
+
diff --git a/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml
index 1b55d09d0597e..0ddf5010432ce 100644
--- a/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml
+++ b/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml
@@ -10,8 +10,11 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
+
diff --git a/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml
index c21a8b875e95b..ad2be384e0bad 100644
--- a/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml
+++ b/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml
@@ -13,6 +13,7 @@
+
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
new file mode 100644
index 0000000000000..b528b907867ab
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From e3a482370db7f9784fa4a4e353a80098cc183d9e Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Mon, 24 Jun 2019 10:59:28 +0300
Subject: [PATCH 0023/1978] Code refactoring of AdminUpdateUserRoleTest
---
.../AssertAdminUserIsInGridActionGroup.xml | 10 ++++-
.../AdminOpenUserEditPageActionGroup.xml | 7 ++-
.../AdminUpdateUserRoleActionGroup.xml | 19 +++++---
.../Mftf/Section/AdminUserGridSection.xml | 1 -
.../Mftf/Test/AdminUpdateUserRoleTest.xml | 45 ++++++++++++-------
5 files changed, 56 insertions(+), 26 deletions(-)
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
index bb73606a92b93..01e6b67b59a6c 100644
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
@@ -9,6 +9,14 @@
-
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
index ff7871cc1d5fe..a32027a6ac182 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
@@ -8,11 +8,14 @@
+
+
+
-
+
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
index c7f5078832cf5..313bf0b215d68 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
@@ -9,13 +9,18 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml
index ad2be384e0bad..c21a8b875e95b 100644
--- a/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml
+++ b/app/code/Magento/User/Test/Mftf/Section/AdminUserGridSection.xml
@@ -13,7 +13,6 @@
-
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
index b528b907867ab..35f4a6e133c95 100644
--- a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
@@ -24,6 +24,14 @@
+
+
+
+
+
+
+
+
@@ -32,29 +40,36 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
-
-
+
+
+
+
- -->
-
- -->
+
\ No newline at end of file
From 983e5fbd97f36bd22cc4491b676ccb46b769557b Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Mon, 24 Jun 2019 17:43:48 +0300
Subject: [PATCH 0024/1978] Code refactoring of AdminUpdateUserRoleTest
---
.../Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml | 1 -
.../Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml
index 0ddf5010432ce..a3a82f6ce38e0 100644
--- a/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml
+++ b/app/code/Magento/User/Test/Mftf/Section/AdminDeleteRoleSection.xml
@@ -11,7 +11,6 @@
-
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
index 35f4a6e133c95..3e7bb3e1889ef 100644
--- a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
@@ -12,7 +12,7 @@
-
+
@@ -64,7 +64,7 @@
-
+
From 2ea850138272a59bc6acc116ff2ac9dbc413f8cb Mon Sep 17 00:00:00 2001
From: eduard13
Date: Tue, 25 Jun 2019 08:29:57 +0300
Subject: [PATCH 0025/1978] Covering the create backend order getting an out of
stock product
---
...sertAdminProductStockStatusActionGroup.xml | 19 +++++++
.../Catalog/Test/Mftf/Data/ProductData.xml | 3 ++
.../Data/ProductExtensionAttributeData.xml | 3 ++
.../Catalog/Test/Mftf/Data/StockItemData.xml | 4 ++
.../AdminSelectPaymentMethodActionGroup.xml | 20 +++++++
.../Test/Mftf/Data/PaymentMethodData.xml | 4 ++
.../Mftf/Metadata/payment_method-meta.xml | 14 +++++
.../AdminCreateOrderWithSimpleProductTest.xml | 54 +++++++++++++++++++
.../Test/TestCase/CreateOrderBackendTest.xml | 1 +
9 files changed, 122 insertions(+)
create mode 100644 app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml
create mode 100644 app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml
create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml
new file mode 100644
index 0000000000000..56c088887cd4b
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 33dab7ee8fd7e..f882a3cfe9900 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -39,6 +39,9 @@
Pursuit Lumaflex™ Tone Band
x™
+
+ EavStock25
+
100
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductExtensionAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductExtensionAttributeData.xml
index 5a6a0b5dd9518..2576d8cdd7022 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductExtensionAttributeData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductExtensionAttributeData.xml
@@ -26,4 +26,7 @@
Qty_777
+
+ Qty_25
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/StockItemData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/StockItemData.xml
index 32f4dc1404dd7..bef0b9f56eab6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/StockItemData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/StockItemData.xml
@@ -40,4 +40,8 @@
777
true
+
+ 25
+ true
+
diff --git a/app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml b/app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml
new file mode 100644
index 0000000000000..aabb7245492f8
--- /dev/null
+++ b/app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Payment/Test/Mftf/Data/PaymentMethodData.xml b/app/code/Magento/Payment/Test/Mftf/Data/PaymentMethodData.xml
index 14c8bd0fecde7..eeae53d082443 100644
--- a/app/code/Magento/Payment/Test/Mftf/Data/PaymentMethodData.xml
+++ b/app/code/Magento/Payment/Test/Mftf/Data/PaymentMethodData.xml
@@ -11,4 +11,8 @@
checkmo
+
+
+ CashOnDeliveryEnableConfigData
+
diff --git a/app/code/Magento/Payment/Test/Mftf/Metadata/payment_method-meta.xml b/app/code/Magento/Payment/Test/Mftf/Metadata/payment_method-meta.xml
index 39506a682038f..3ad3a0e1c60de 100644
--- a/app/code/Magento/Payment/Test/Mftf/Metadata/payment_method-meta.xml
+++ b/app/code/Magento/Payment/Test/Mftf/Metadata/payment_method-meta.xml
@@ -11,4 +11,18 @@
string
+
+
+
+
+
+ string
+
+
+ string
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
new file mode 100644
index 0000000000000..86dcc227946b5
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml
index c4e03b94d2ada..408b0fdcbb40f 100644
--- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml
@@ -8,6 +8,7 @@
+ mftf_migrated:yes
catalogProductSimple::product_with_qty_25
default
US_address_1_without_email
From 97927cd29832fdc114576bf9d95584ee07bdeaa0 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Tue, 25 Jun 2019 09:33:12 +0300
Subject: [PATCH 0026/1978] Reusing existing ActionGroup for selecting the cash
on delivery method
---
.../AdminSelectPaymentMethodActionGroup.xml | 20 -------------------
.../AdminCreateOrderWithSimpleProductTest.xml | 5 +----
2 files changed, 1 insertion(+), 24 deletions(-)
delete mode 100644 app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml
diff --git a/app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml b/app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml
deleted file mode 100644
index aabb7245492f8..0000000000000
--- a/app/code/Magento/Payment/Test/Mftf/ActionGroup/AdminSelectPaymentMethodActionGroup.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
index 86dcc227946b5..041fed644f859 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
@@ -34,10 +34,7 @@
-
-
-
-
+
From 2b70fe8e112f538ead0e8af519f9ee136803ba58 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Tue, 25 Jun 2019 14:35:33 +0400
Subject: [PATCH 0027/1978] MAGETWO-98703: CSV file is not exported
- Added validation message to 'exportAllProducts' actionGroup
---
.../ActionGroup/AdminExportActionGroup.xml | 2 +-
...ageAfterAddingExportingFileToQueueTest.xml | 45 -------------------
2 files changed, 1 insertion(+), 46 deletions(-)
delete mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml
diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml
index 65588daa96cc4..d628667df5937 100644
--- a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml
+++ b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml
@@ -34,7 +34,7 @@
-
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml
deleted file mode 100644
index f947efff9f2c9..0000000000000
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckTheMessageAfterAddingExportingFileToQueueTest.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From 9bea49f2e5e1b41c18aa4bf0b12510e083a5f1e4 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Tue, 25 Jun 2019 17:13:01 +0400
Subject: [PATCH 0028/1978] MC-15523: Watermark is possible to set up for
swatch image type
- Added automated test script
---
.../AdminSetUpWatermarkForSwatchImageTest.xml | 57 +++++++++++++++++++
.../Mftf/Section/AdminDesignConfigSection.xml | 4 ++
2 files changed, 61 insertions(+)
create mode 100644 app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml
diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml
new file mode 100644
index 0000000000000..66043a51db183
--- /dev/null
+++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
index c2652f33f7606..a65dcc5a1aa14 100644
--- a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
+++ b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
@@ -31,5 +31,9 @@
+
+
+
+
From b2a48682e7ea2e3a3c88724104e629d408118fc6 Mon Sep 17 00:00:00 2001
From: Stsiapan Korf
Date: Thu, 27 Jun 2019 12:14:12 +0000
Subject: [PATCH 0029/1978] MAGETWO-98703: CSV file is not exported
- Fix CR comments
---
app/code/Magento/ImportExport/i18n/en_US.csv | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/ImportExport/i18n/en_US.csv b/app/code/Magento/ImportExport/i18n/en_US.csv
index d7680a71ac5f7..7075c69a3c29c 100644
--- a/app/code/Magento/ImportExport/i18n/en_US.csv
+++ b/app/code/Magento/ImportExport/i18n/en_US.csv
@@ -123,3 +123,4 @@ Summary,Summary
"New product data is added to existing product data entries in the database. All fields except SKU can be updated.","New product data is added to existing product data entries in the database. All fields except SKU can be updated."
"All existing product data is replaced with the imported new data. Exercise caution when replacing data. All existing product data will be completely cleared and all references in the system will be lost. ","All existing product data is replaced with the imported new data. Exercise caution when replacing data. All existing product data will be completely cleared and all references in the system will be lost. "
"Any entities in the import data that match existing entities in the database are deleted from the database.","Any entities in the import data that match existing entities in the database are deleted from the database."
+"Message is added to queue, wait to get your file soon. Make sure your cron job is running to export the file","Message is added to queue, wait to get your file soon. Make sure your cron job is running to export the file"
From 9077c1cc0f09088a1624180d9da0fcb613172d19 Mon Sep 17 00:00:00 2001
From: Tomash Khamlai
Date: Thu, 27 Jun 2019 17:45:48 +0300
Subject: [PATCH 0030/1978] Update AddBundleProductToCartTest.php
---
.../Magento/GraphQl/Bundle/AddBundleProductToCartTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
index 7905484ec51df..b1574c06c2d63 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
@@ -80,7 +80,7 @@ public function testAddBundleProductToCart()
mutation {
addBundleProductsToCart(input:{
cart_id:"{$maskedQuoteId}"
- cartItems:[
+ cart_items:[
{
data:{
sku:"{$sku}"
@@ -163,7 +163,7 @@ public function testAddBundleToCartWithoutOptions()
mutation {
addBundleProductsToCart(input:{
cart_id:"{$maskedQuoteId}"
- cartItems:[
+ cart_items:[
{
data:{
sku:"bundle-product"
From 438733108448fa37c1971741e4782ad673c79507 Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Thu, 27 Jun 2019 18:07:59 -0400
Subject: [PATCH 0031/1978] fix static tests
---
.../Model/Cart/BundleOptionDataProvider.php | 9 +++++++++
.../Model/Cart/BuyRequest/BundleDataProvider.php | 3 +++
.../BundleGraphQl/Model/Resolver/BundleOption.php | 7 +++++++
app/code/Magento/BundleGraphQl/etc/module.xml | 1 +
.../Model/Cart/AddSimpleProductToCart.php | 2 +-
.../Model/Cart/BuyRequest/BuyRequestBuilder.php | 13 +++++++++++++
.../BuyRequest/BuyRequestDataProviderInterface.php | 9 +++++++++
.../BuyRequest/CustomizableOptionsDataProvider.php | 3 +++
.../Model/Cart/BuyRequest/DefaultDataProvider.php | 3 +++
.../GraphQl/Bundle/AddBundleProductToCartTest.php | 3 +++
10 files changed, 52 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php b/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php
index 8db1c64c23c42..5cdfdc88e7dc1 100644
--- a/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php
+++ b/app/code/Magento/BundleGraphQl/Model/Cart/BundleOptionDataProvider.php
@@ -13,6 +13,9 @@
use Magento\Framework\Pricing\Helper\Data;
use Magento\Framework\Serialize\SerializerInterface;
+/**
+ * Data provider for bundled product options
+ */
class BundleOptionDataProvider
{
/**
@@ -46,6 +49,8 @@ public function __construct(
}
/**
+ * Extract data for a bundled cart item
+ *
* @param Item $item
* @return array
*/
@@ -82,6 +87,8 @@ public function getData(Item $item): array
}
/**
+ * Build bundle product options based on current selection
+ *
* @param \Magento\Bundle\Model\Option[] $bundleOptions
* @param Item $item
* @return array
@@ -106,6 +113,8 @@ private function buildBundleOptions(array $bundleOptions, Item $item): array
}
/**
+ * Build bundle product option values based on current selection
+ *
* @param Product[] $selections
* @param Item $item
* @return array
diff --git a/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php b/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php
index 72a72dd5b3bcf..37a9309092166 100644
--- a/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php
+++ b/app/code/Magento/BundleGraphQl/Model/Cart/BuyRequest/BundleDataProvider.php
@@ -10,6 +10,9 @@
use Magento\Framework\Stdlib\ArrayManager;
use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestDataProviderInterface;
+/**
+ * Data provider for bundle product buy requests
+ */
class BundleDataProvider implements BuyRequestDataProviderInterface
{
/**
diff --git a/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php b/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php
index 9bccbf936f18d..6b64310fcb1e3 100644
--- a/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php
+++ b/app/code/Magento/BundleGraphQl/Model/Resolver/BundleOption.php
@@ -13,6 +13,9 @@
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
+/**
+ * Resolver for bundle product options
+ */
class BundleOption implements ResolverInterface
{
/**
@@ -29,6 +32,10 @@ public function __construct(
$this->dataProvider = $bundleOptionDataProvider;
}
+ /**
+ * @inheritdoc
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
if (!isset($value['model'])) {
diff --git a/app/code/Magento/BundleGraphQl/etc/module.xml b/app/code/Magento/BundleGraphQl/etc/module.xml
index 352a46d7c171e..8d6725054867e 100644
--- a/app/code/Magento/BundleGraphQl/etc/module.xml
+++ b/app/code/Magento/BundleGraphQl/etc/module.xml
@@ -8,6 +8,7 @@
+
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
index 13079c86f48d7..3f6cc42614030 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
@@ -114,4 +114,4 @@ private function extractQuantity(array $cartItemData): float
}
return $quantity;
}
-}
\ No newline at end of file
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php
index 492dd18f14e03..90f32e96a5fde 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestBuilder.php
@@ -10,6 +10,9 @@
use Magento\Framework\DataObject;
use Magento\Framework\DataObjectFactory;
+/**
+ * Build buy request for adding products to cart
+ */
class BuyRequestBuilder
{
/**
@@ -22,6 +25,10 @@ class BuyRequestBuilder
*/
private $dataObjectFactory;
+ /**
+ * @param DataObjectFactory $dataObjectFactory
+ * @param array $providers
+ */
public function __construct(
DataObjectFactory $dataObjectFactory,
array $providers = []
@@ -30,6 +37,12 @@ public function __construct(
$this->providers = $providers;
}
+ /**
+ * Build buy request for adding product to cart
+ *
+ * @param array $cartItemData
+ * @return DataObject
+ */
public function build(array $cartItemData): DataObject
{
$requestData = [];
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php
index adfc5b13b762c..e606c6b225da2 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/BuyRequestDataProviderInterface.php
@@ -7,7 +7,16 @@
namespace Magento\QuoteGraphQl\Model\Cart\BuyRequest;
+/**
+ * Provide buy request data from add to cart item request
+ */
interface BuyRequestDataProviderInterface
{
+ /**
+ * Provide buy request data from add to cart item request
+ *
+ * @param array $cartItemData
+ * @return array
+ */
public function execute(array $cartItemData): array;
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
index a6b4ae00ab602..d777fbb039350 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
@@ -9,6 +9,9 @@
use Magento\Framework\Stdlib\ArrayManager;
+/**
+ * Extract buy request elements require for custom options
+ */
class CustomizableOptionsDataProvider implements BuyRequestDataProviderInterface
{
/**
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
index 3185510e42865..6ef1679a3382c 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
@@ -10,6 +10,9 @@
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\Stdlib\ArrayManager;
+/**
+ * Provides QTY buy request data for adding products to cart
+ */
class DefaultDataProvider implements BuyRequestDataProviderInterface
{
/**
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
index b1574c06c2d63..a8e75d7778f82 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
@@ -14,6 +14,9 @@
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
use Magento\Quote\Model\ResourceModel\Quote as QuoteResource;
+/**
+ * Test adding bundled products to cart
+ */
class AddBundleProductToCartTest extends GraphQlAbstract
{
/**
From 840fbedd4560beb5ed708a263e493b6bb6115aec Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Thu, 27 Jun 2019 18:09:52 -0400
Subject: [PATCH 0032/1978] Rename DefaultDataProvider QuantityDataProvider
The name now reflects the purpose
---
.../{DefaultDataProvider.php => QuantityDataProvider.php} | 2 +-
app/code/Magento/QuoteGraphQl/etc/graphql/di.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
rename app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/{DefaultDataProvider.php => QuantityDataProvider.php} (93%)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
similarity index 93%
rename from app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
rename to app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
index 6ef1679a3382c..a3c5c33342724 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/DefaultDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
@@ -13,7 +13,7 @@
/**
* Provides QTY buy request data for adding products to cart
*/
-class DefaultDataProvider implements BuyRequestDataProviderInterface
+class QuantityDataProvider implements BuyRequestDataProviderInterface
{
/**
* @var ArrayManager
diff --git a/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml b/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml
index cd1408f445180..88f97d32b71d0 100644
--- a/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml
+++ b/app/code/Magento/QuoteGraphQl/etc/graphql/di.xml
@@ -13,7 +13,7 @@
- - Magento\QuoteGraphQl\Model\Cart\BuyRequest\DefaultDataProvider
+ - Magento\QuoteGraphQl\Model\Cart\BuyRequest\QuantityDataProvider
- Magento\QuoteGraphQl\Model\Cart\BuyRequest\CustomizableOptionsDataProvider
From 989038c543a75f5438a351799e91379e0613a59b Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Thu, 27 Jun 2019 18:38:21 -0400
Subject: [PATCH 0033/1978] Update tests for current schema mutation function
---
.../Bundle/AddBundleProductToCartTest.php | 33 ++++++++++++++-----
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
index a8e75d7778f82..21fd88519d22e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
@@ -87,7 +87,7 @@ public function testAddBundleProductToCart()
{
data:{
sku:"{$sku}"
- qty:1
+ quantity:1
}
bundle_options:[
{
@@ -102,10 +102,9 @@ public function testAddBundleProductToCart()
]
}) {
cart {
- cart_id
items {
id
- qty
+ quantity
product {
sku
}
@@ -128,12 +127,11 @@ public function testAddBundleProductToCart()
}
QUERY;
- $response = $this->graphQlQuery($query);
+ $response = $this->graphQlMutation($query);
$this->assertArrayHasKey('addBundleProductsToCart', $response);
$this->assertArrayHasKey('cart', $response['addBundleProductsToCart']);
$cart = $response['addBundleProductsToCart']['cart'];
- $this->assertEquals($maskedQuoteId, $cart['cart_id']);
$bundleItem = current($cart['items']);
$this->assertEquals($sku, $bundleItem['product']['sku']);
$bundleItemOption = current($bundleItem['bundle_options']);
@@ -170,7 +168,7 @@ public function testAddBundleToCartWithoutOptions()
{
data:{
sku:"bundle-product"
- qty:1
+ quantity:1
}
bundle_options:[
{
@@ -185,12 +183,31 @@ public function testAddBundleToCartWithoutOptions()
]
}) {
cart {
- cart_id
+ items {
+ id
+ quantity
+ product {
+ sku
+ }
+ ... on BundleCartItem {
+ bundle_options {
+ id
+ label
+ type
+ values {
+ id
+ label
+ price
+ quantity
+ }
+ }
+ }
+ }
}
}
}
QUERY;
- $this->graphQlQuery($query);
+ $this->graphQlMutation($query);
}
}
From 226cbf75320bab7bd3d5e69d5107a1df7cbc442b Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Thu, 27 Jun 2019 21:47:00 -0400
Subject: [PATCH 0034/1978] Update add to cart with extendible buy request
builder
---
.../Model/Cart/AddSimpleProductToCart.php | 41 ++++---------------
.../CustomizableOptionsDataProvider.php | 28 +++++++++++--
.../Cart/BuyRequest/QuantityDataProvider.php | 4 +-
3 files changed, 35 insertions(+), 38 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
index 3f6cc42614030..f029305c118fa 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AddSimpleProductToCart.php
@@ -12,6 +12,7 @@
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Quote\Model\Quote;
+use Magento\QuoteGraphQl\Model\Cart\BuyRequest\BuyRequestBuilder;
/**
* Add simple product to cart
@@ -19,25 +20,25 @@
class AddSimpleProductToCart
{
/**
- * @var CreateBuyRequest
+ * @var ProductRepositoryInterface
*/
- private $createBuyRequest;
+ private $productRepository;
/**
- * @var ProductRepositoryInterface
+ * @var BuyRequestBuilder
*/
- private $productRepository;
+ private $buyRequestBuilder;
/**
* @param ProductRepositoryInterface $productRepository
- * @param CreateBuyRequest $createBuyRequest
+ * @param BuyRequestBuilder $buyRequestBuilder
*/
public function __construct(
ProductRepositoryInterface $productRepository,
- CreateBuyRequest $createBuyRequest
+ BuyRequestBuilder $buyRequestBuilder
) {
$this->productRepository = $productRepository;
- $this->createBuyRequest = $createBuyRequest;
+ $this->buyRequestBuilder = $buyRequestBuilder;
}
/**
@@ -53,8 +54,6 @@ public function __construct(
public function execute(Quote $cart, array $cartItemData): void
{
$sku = $this->extractSku($cartItemData);
- $quantity = $this->extractQuantity($cartItemData);
- $customizableOptions = $cartItemData['customizable_options'] ?? [];
try {
$product = $this->productRepository->get($sku);
@@ -63,7 +62,7 @@ public function execute(Quote $cart, array $cartItemData): void
}
try {
- $result = $cart->addProduct($product, $this->createBuyRequest->execute($quantity, $customizableOptions));
+ $result = $cart->addProduct($product, $this->buyRequestBuilder->build($cartItemData));
} catch (\Exception $e) {
throw new GraphQlInputException(
__(
@@ -92,26 +91,4 @@ private function extractSku(array $cartItemData): string
}
return (string)$cartItemData['data']['sku'];
}
-
- /**
- * Extract quantity from cart item data
- *
- * @param array $cartItemData
- * @return float
- * @throws GraphQlInputException
- */
- private function extractQuantity(array $cartItemData): float
- {
- if (!isset($cartItemData['data']['quantity'])) {
- throw new GraphQlInputException(__('Missed "qty" in cart item data'));
- }
- $quantity = (float)$cartItemData['data']['quantity'];
-
- if ($quantity <= 0) {
- throw new GraphQlInputException(
- __('Please enter a number greater than 0 in this field.')
- );
- }
- return $quantity;
- }
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
index d777fbb039350..70e536411f947 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
@@ -33,13 +33,33 @@ public function __construct(
*/
public function execute(array $cartItemData): array
{
- $customizableOptions = $this->arrayManager->get('customizable_options', $cartItemData, []);
+ $customizableOptionsData = $this->arrayManager->get('customizable_options', $cartItemData, []);
- $customizableOptionsData = [];
- foreach ($customizableOptions as $customizableOption) {
- $customizableOptionsData[$customizableOption['id']] = $customizableOption['value'];
+ $customizableOptions = [];
+ foreach ($customizableOptionsData as $customizableOption) {
+ if (isset($customizableOption['value_string'])) {
+ $customizableOptions[$customizableOption['id']] = $this->convertCustomOptionValue(
+ $customizableOption['value_string']
+ );
+ }
}
return ['options' => $customizableOptionsData];
}
+
+ /**
+ * Convert custom options value
+ *
+ * @param string $value
+ * @return string|array
+ */
+ private function convertCustomOptionValue(string $value)
+ {
+ $value = trim($value);
+ if (substr($value, 0, 1) === "[" &&
+ substr($value, strlen($value) - 1, 1) === "]") {
+ return explode(',', substr($value, 1, -1));
+ }
+ return $value;
+ }
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
index a3c5c33342724..d02b7cdb17d2e 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
@@ -34,9 +34,9 @@ public function __construct(
*/
public function execute(array $cartItemData): array
{
- $qty = $this->arrayManager->get('data/qty', $cartItemData);
+ $qty = $this->arrayManager->get('data/quantity', $cartItemData);
if (!isset($qty)) {
- throw new GraphQlInputException(__('Missing key "qty" in cart item data'));
+ throw new GraphQlInputException(__('Missing key "quantity" in cart item data'));
}
return ['qty' => (float)$qty];
From 1f2aedaedb58661746207d959d67635dfb6cd0ae Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Thu, 27 Jun 2019 22:31:54 -0400
Subject: [PATCH 0035/1978] Fix qty validation and custom option buy request
provider
---
.../Cart/BuyRequest/CustomizableOptionsDataProvider.php | 2 +-
.../Model/Cart/BuyRequest/QuantityDataProvider.php | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
index 70e536411f947..bc7b16a12b581 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/CustomizableOptionsDataProvider.php
@@ -44,7 +44,7 @@ public function execute(array $cartItemData): array
}
}
- return ['options' => $customizableOptionsData];
+ return ['options' => $customizableOptions];
}
/**
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
index d02b7cdb17d2e..6202ed04c1d60 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/BuyRequest/QuantityDataProvider.php
@@ -38,7 +38,14 @@ public function execute(array $cartItemData): array
if (!isset($qty)) {
throw new GraphQlInputException(__('Missing key "quantity" in cart item data'));
}
+ $qty = (float)$qty;
- return ['qty' => (float)$qty];
+ if ($qty <= 0) {
+ throw new GraphQlInputException(
+ __('Please enter a number greater than 0 in this field.')
+ );
+ }
+
+ return ['qty' => $qty];
}
}
From a9ca7a9858b4e07e88dc71930d05a07158209e6b Mon Sep 17 00:00:00 2001
From: Evgeny Petrov
Date: Mon, 1 Jul 2019 17:02:59 +0300
Subject: [PATCH 0036/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
---
.../SearchAdapter/Query/Builder/Match.php | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
index afd383c13421f..f8f70170de155 100644
--- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
+++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Elasticsearch\SearchAdapter\Query\Builder;
use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider;
@@ -80,7 +82,8 @@ public function __construct(
*/
public function build(array $selectQuery, RequestQueryInterface $requestQuery, $conditionType)
{
- $queryValue = $this->prepareQuery($requestQuery->getValue(), $conditionType);
+ $preparedValue = $this->prepareValue($requestQuery->getValue());
+ $queryValue = $this->prepareQuery($preparedValue, $conditionType);
$queries = $this->buildQueries($requestQuery->getMatches(), $queryValue);
$requestQueryBoost = $requestQuery->getBoost() ?: 1;
foreach ($queries as $query) {
@@ -113,6 +116,19 @@ protected function prepareQuery($queryValue, $conditionType)
];
}
+ /**
+ * Removes special query characters which are cause of mysql error: '(', ')', '?'
+ *
+ * @param string $queryValue
+ * @return string
+ */
+ private function prepareValue($queryValue)
+ {
+ $pattern = '/(\(|\)|\?)/';
+ $replace = '';
+ return preg_replace($pattern, $replace, $queryValue);
+ }
+
/**
* Creates valid ElasticSearch search conditions from Match queries.
*
From ff714873a9f30fdaec4b7b61948f5f22b6e1abae Mon Sep 17 00:00:00 2001
From: eduard13
Date: Tue, 2 Jul 2019 22:30:49 +0300
Subject: [PATCH 0037/1978] Covering the Reorder functionality for an Out of
Stock product
---
...ntCustomerElementNotVisibleActionGroup.xml | 16 ++++++
...vigateToCustomerAccountPageActionGroup.xml | 17 ++++++
...AdminCreateOrderAndCheckTheReorderTest.xml | 57 +++++++++++++++++++
.../Test/TestCase/CreateOrderBackendTest.xml | 1 +
4 files changed, 91 insertions(+)
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
create mode 100644 app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml
new file mode 100644
index 0000000000000..d6d66f9f2b708
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
new file mode 100644
index 0000000000000..ce7b023f1d57d
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
new file mode 100644
index 0000000000000..147d6ff85cecf
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml
index 408b0fdcbb40f..b1e3b9a9d9f1e 100644
--- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestCase/CreateOrderBackendTest.xml
@@ -25,6 +25,7 @@
+ mftf_migrated:yes
catalogProductSimple::default_qty_1
default
US_address_1_without_email
From 02821fcbf2ed25a8e5133b75e8390096e39caa1e Mon Sep 17 00:00:00 2001
From: eduard13
Date: Tue, 2 Jul 2019 22:59:31 +0300
Subject: [PATCH 0038/1978] Improving the quantity usage
---
app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml | 1 +
.../Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 65a9d93cc6ac6..4f7a4622b450f 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -40,6 +40,7 @@
x™
+ 25
EavStock25
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 147d6ff85cecf..757550efcf83a 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -32,7 +32,7 @@
-
+
From 8421886d6e79a21f1cde45337d6e190ef2ee7a09 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 4 Jul 2019 13:44:26 +0400
Subject: [PATCH 0039/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Added automated test script.
---
.../AdminProductAttributeActionGroup.xml | 6 ++
.../AdminCreateProductAttributeSection.xml | 1 +
.../Test/Mftf/Data/CatalogSearchData.xml | 9 +-
.../Mftf/Metadata/catalog_search-meta.xml | 3 +
...ontElasticsearchSearchInvalidValueTest.xml | 96 +++++++++++++++++++
5 files changed, 113 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index ed0c4387cdedf..c9ef3db45f5b7 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -163,6 +163,7 @@
+
@@ -236,6 +237,11 @@
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
index 9b75f7e6908a2..8e10e1f302373 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
@@ -49,6 +49,7 @@
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
index 6868456079110..58e2929090059 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
@@ -11,6 +11,9 @@
DefaultMinQueryLength
+
+ DefaultSearchEngine
+
SetMinQueryLengthToOne
@@ -23,5 +26,7 @@
1
-
-
\ No newline at end of file
+
+ true
+
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
index 7405377249aa4..7e880262d5922 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
@@ -14,6 +14,9 @@
boolean
+
+ boolean
+
diff --git a/app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
new file mode 100644
index 0000000000000..cf6e94f905aba
--- /dev/null
+++ b/app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From d32285cb23f2047777176bc7b2a6b4ab1685df3d Mon Sep 17 00:00:00 2001
From: mmularski
Date: Fri, 5 Jul 2019 13:40:43 +0200
Subject: [PATCH 0040/1978] Issue-709. Convert CreateAdminUserEntityTest to
MFTF
---
.../AdminCreateUserActionGroup.xml | 26 +++++++++++-
.../Magento/User/Test/Mftf/Data/UserData.xml | 32 ++++++++++++++
.../Mftf/Section/AdminNewUserFormSection.xml | 1 +
.../Test/AdminCreateActiveUserEntityTest.xml | 42 +++++++++++++++++++
.../AdminCreateInactiveUserEntityTest.xml | 41 ++++++++++++++++++
5 files changed, 140 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/User/Test/Mftf/Test/AdminCreateActiveUserEntityTest.xml
create mode 100644 app/code/Magento/User/Test/Mftf/Test/AdminCreateInactiveUserEntityTest.xml
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserActionGroup.xml
index d550d855fcdd0..bcc7ec78e87a5 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminCreateUserActionGroup.xml
@@ -36,7 +36,6 @@
-
@@ -50,9 +49,32 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserData.xml b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
index e665736ae28f1..636dd877bb639 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
@@ -74,4 +74,36 @@
- 1
+
+ AdminUser
+ FirstName
+ LastName
+ admin@example.com
+ 123123q
+ 123123q
+ en_US
+ English (United States)
+ 1
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
+ Administrators
+
+ - 1
+
+
+
+ AdminUser
+ FirstName
+ LastName
+ admin@example.com
+ 123123q
+ 123123q
+ en_US
+ English (United States)
+ 0
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
+ Administrators
+
+ - 1
+
+
diff --git a/app/code/Magento/User/Test/Mftf/Section/AdminNewUserFormSection.xml b/app/code/Magento/User/Test/Mftf/Section/AdminNewUserFormSection.xml
index 9b030b216ce2c..79195067315db 100644
--- a/app/code/Magento/User/Test/Mftf/Section/AdminNewUserFormSection.xml
+++ b/app/code/Magento/User/Test/Mftf/Section/AdminNewUserFormSection.xml
@@ -19,6 +19,7 @@
+
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminCreateActiveUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminCreateActiveUserEntityTest.xml
new file mode 100644
index 0000000000000..1cc2294a3d33e
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminCreateActiveUserEntityTest.xml
@@ -0,0 +1,42 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminCreateInactiveUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminCreateInactiveUserEntityTest.xml
new file mode 100644
index 0000000000000..0768f3c6e240e
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminCreateInactiveUserEntityTest.xml
@@ -0,0 +1,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 019f8dc91394681f4b5b9adccabb7ac51cdf79da Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Tue, 9 Jul 2019 21:37:09 -0400
Subject: [PATCH 0041/1978] Prevent updates to child cart items via
updateCartItems mutation
---
.../Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php
index db6a43513cc30..cd687d86d87ce 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/UpdateCartItems.php
@@ -105,6 +105,11 @@ private function processCartItems(Quote $cart, array $items): void
$itemId = (int)$item['cart_item_id'];
$customizableOptions = $item['customizable_options'] ?? [];
+ $cartItem = $cart->getItemById($itemId);
+ if ($cartItem && $cartItem->getParentItemId()) {
+ throw new GraphQlInputException(__('Child items may not be updated.'));
+ }
+
if (count($customizableOptions) === 0 && !isset($item['quantity'])) {
throw new GraphQlInputException(__('Required parameter "quantity" for "cart_items" is missing.'));
}
From b2a112e34df2be7080e30bed2cd47f2362b6b7f9 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Sun, 21 Jul 2019 09:27:27 +0300
Subject: [PATCH 0042/1978] Reformatting the code and adjusting the name of
ActionGroup
---
.../ActionGroup/AssertAdminProductStockStatusActionGroup.xml | 5 +++--
.../ActionGroup/NavigateToCustomerAccountPageActionGroup.xml | 2 +-
...ml => StorefrontCustomerElementNotVisibleActionGroup.xml} | 2 +-
.../Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 4 ++--
.../Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml | 2 +-
5 files changed, 8 insertions(+), 7 deletions(-)
rename app/code/Magento/Customer/Test/Mftf/ActionGroup/{AssertStorefrontCustomerElementNotVisibleActionGroup.xml => StorefrontCustomerElementNotVisibleActionGroup.xml} (87%)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml
index 56c088887cd4b..887845b1b51a5 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AssertAdminProductStockStatusActionGroup.xml
@@ -6,7 +6,7 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
@@ -14,6 +14,7 @@
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
index ce7b023f1d57d..51ce4a6f3b2ac 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
@@ -9,7 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml
similarity index 87%
rename from app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml
rename to app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml
index d6d66f9f2b708..7b77b7ecd0787 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertStorefrontCustomerElementNotVisibleActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml
@@ -7,7 +7,7 @@
-->
-
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 757550efcf83a..741d146ceb406 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -34,7 +34,7 @@
-
+
@@ -44,7 +44,7 @@
-
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
index 041fed644f859..ebfe808ec63ac 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
@@ -34,7 +34,7 @@
-
+
From 526d2d217a80a74d23b633c88ef76ce2108bf362 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Mon, 22 Jul 2019 07:28:34 +0300
Subject: [PATCH 0043/1978] Refactoring ActionGroups
---
.../StorefrontCustomerElementNotVisibleActionGroup.xml | 7 ++-----
...ontNavigateToCustomerOrdersHistoryPageActionGroup.xml} | 7 ++-----
.../Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 8 ++------
3 files changed, 6 insertions(+), 16 deletions(-)
rename app/code/Magento/Customer/Test/Mftf/ActionGroup/{NavigateToCustomerAccountPageActionGroup.xml => StorefrontNavigateToCustomerOrdersHistoryPageActionGroup.xml} (64%)
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml
index 7b77b7ecd0787..12a0b8f47c5fa 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerElementNotVisibleActionGroup.xml
@@ -7,10 +7,7 @@
-->
-
-
-
-
-
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontNavigateToCustomerOrdersHistoryPageActionGroup.xml
similarity index 64%
rename from app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
rename to app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontNavigateToCustomerOrdersHistoryPageActionGroup.xml
index 51ce4a6f3b2ac..40a79b87b01a9 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateToCustomerAccountPageActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontNavigateToCustomerOrdersHistoryPageActionGroup.xml
@@ -7,11 +7,8 @@
-->
-
-
-
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 741d146ceb406..21e2c7593c38a 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -41,12 +41,8 @@
-
-
-
-
-
-
+
+
From 9bd092973395e74b098da1f603ded1c4dbc5cf77 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Mon, 22 Jul 2019 10:09:15 +0300
Subject: [PATCH 0044/1978] Disabling the payment method after testing
---
.../Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 1 +
.../Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml | 1 +
2 files changed, 2 insertions(+)
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 21e2c7593c38a..4599fa3e0831a 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -46,6 +46,7 @@
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
index ebfe808ec63ac..bca87cbae77e7 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
@@ -44,6 +44,7 @@
+
From 611b6c00511112b83d7d961b87093e8acbed8cd3 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Mon, 22 Jul 2019 14:48:23 +0300
Subject: [PATCH 0045/1978] Adding the test title
---
.../Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 4599fa3e0831a..6ac7be5757a76 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -10,7 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
-
+
From dc0c2e6d3b7e5958e265572f52d1d458cc0b0665 Mon Sep 17 00:00:00 2001
From: eduard13
Date: Tue, 23 Jul 2019 10:16:46 +0300
Subject: [PATCH 0046/1978] Refactoring the Action Groups
---
...p.xml => AssertToolbarTextIsVisibleInCartActionGroup.xml} | 5 ++---
...frontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml | 3 +--
...ontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml | 3 +--
3 files changed, 4 insertions(+), 7 deletions(-)
rename app/code/Magento/Checkout/Test/Mftf/ActionGroup/{AssertTextIsVisibleOnPageActionGroup.xml => AssertToolbarTextIsVisibleInCartActionGroup.xml} (71%)
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertToolbarTextIsVisibleInCartActionGroup.xml
similarity index 71%
rename from app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
rename to app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertToolbarTextIsVisibleInCartActionGroup.xml
index 8f1920a28d9f1..6ede2a0dd5388 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertTextIsVisibleOnPageActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertToolbarTextIsVisibleInCartActionGroup.xml
@@ -7,12 +7,11 @@
-->
-
+
-
-
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
index 08922c019bdcd..787fedc8469cf 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCheckPagerShoppingCartWithMoreThan20ProductsTest.xml
@@ -131,9 +131,8 @@
-
+
-
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
index 2b6c31a941efe..64080c6b6d6a6 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontShoppingCartPagerForOneItemPerPageAnd2ProductsTest.xml
@@ -37,9 +37,8 @@
-
+
-
From be264871ab9c90510e0552885b4e1e6eabfe361d Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Tue, 23 Jul 2019 21:27:59 -0400
Subject: [PATCH 0047/1978] Add test updating bundle cart item quantity
---
.../Bundle/AddBundleProductToCartTest.php | 61 +++++++++++++++++++
.../_files/quote_with_bundle_and_options.php | 10 ++-
...quote_with_bundle_and_options_rollback.php | 2 +-
3 files changed, 71 insertions(+), 2 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
index 21fd88519d22e..826083b0b3378 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Bundle/AddBundleProductToCartTest.php
@@ -144,6 +144,67 @@ public function testAddBundleProductToCart()
$this->assertEquals(1, $value['quantity']);
}
+ /**
+ * @magentoApiDataFixture Magento/Bundle/_files/quote_with_bundle_and_options.php
+ * @dataProvider dataProviderTestUpdateBundleItemQuantity
+ */
+ public function testUpdateBundleItemQuantity(int $quantity)
+ {
+ $this->quoteResource->load(
+ $this->quote,
+ 'test_cart_with_bundle_and_options',
+ 'reserved_order_id'
+ );
+
+ $item = current($this->quote->getAllVisibleItems());
+
+ $maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
+ $mutation = <<getId()}
+ quantity: {$quantity}
+ }
+ }
+ ) {
+ cart {
+ items {
+ id
+ quantity
+ product {
+ sku
+ }
+ }
+ }
+ }
+}
+QUERY;
+
+ $response = $this->graphQlMutation($mutation);
+
+ $this->assertArrayHasKey('updateCartItems', $response);
+ $this->assertArrayHasKey('cart', $response['updateCartItems']);
+ $cart = $response['updateCartItems']['cart'];
+ if ($quantity === 0) {
+ $this->assertCount(0, $cart['items']);
+ return;
+ }
+
+ $bundleItem = current($cart['items']);
+ $this->assertEquals($quantity, $bundleItem['quantity']);
+ }
+
+ public function dataProviderTestUpdateBundleItemQuantity(): array
+ {
+ return [
+ [2],
+ [0],
+ ];
+ }
+
/**
* @magentoApiDataFixture Magento/Bundle/_files/product_1.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options.php
index 03949115ea62c..c79e943ba4be3 100644
--- a/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options.php
+++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options.php
@@ -8,7 +8,7 @@
use Magento\TestFramework\Helper\Bootstrap;
-require __DIR__ . 'product_with_multiple_options.php';
+require __DIR__ . '/product_with_multiple_options.php';
$objectManager = Bootstrap::getObjectManager();
@@ -49,6 +49,14 @@
$cart->getQuote()->setReservedOrderId('test_cart_with_bundle_and_options');
$cart->save();
+/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
+$quoteIdMask = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->create(\Magento\Quote\Model\QuoteIdMaskFactory::class)
+ ->create();
+$quoteIdMask->setQuoteId($cart->getQuote()->getId());
+$quoteIdMask->setDataChanges(true);
+$quoteIdMask->save();
+
/** @var $objectManager \Magento\TestFramework\ObjectManager */
$objectManager = Bootstrap::getObjectManager();
$objectManager->removeSharedInstance(\Magento\Checkout\Model\Session::class);
diff --git a/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options_rollback.php b/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options_rollback.php
index d32d6fab33319..591aec9190f9f 100644
--- a/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Bundle/_files/quote_with_bundle_and_options_rollback.php
@@ -22,7 +22,7 @@
$quoteIdMask = $objectManager->create(\Magento\Quote\Model\QuoteIdMask::class);
$quoteIdMask->delete($quote->getId());
-require __DIR__ . 'product_with_multiple_options_rollback.php';
+require __DIR__ . '/product_with_multiple_options_rollback.php';
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
From a90961f48324307984e53a851cb4f8502706b071 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 24 Jul 2019 16:20:16 +0300
Subject: [PATCH 0048/1978] [WIP] issue-310-code-refactoring ()
---
...ertUserRoleRestrictedAccessActionGroup.xml | 1 -
.../AdminNavigateToUserRolesActionGroup.xml | 16 --------
.../AdminOpenAdminUsersPageActionGroup.xml} | 6 +--
.../AdminOpenUserEditPageActionGroup.xml | 23 +++++------
.../User/Test/Mftf/Data/UserRoleData.xml | 2 +-
.../Mftf/Test/AdminUpdateUserRoleTest.xml | 39 ++++++++++---------
.../TestCase/UpdateAdminUserEntityTest.xml | 1 +
7 files changed, 38 insertions(+), 50 deletions(-)
delete mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml
rename app/code/Magento/{Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml => User/Test/Mftf/ActionGroup/AdminOpenAdminUsersPageActionGroup.xml} (62%)
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
index b98731e117e1f..4d9166751ee15 100644
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
@@ -9,7 +9,6 @@
-
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml
deleted file mode 100644
index d86bc7d11dbbf..0000000000000
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminNavigateToUserRolesActionGroup.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenAdminUsersPageActionGroup.xml
similarity index 62%
rename from app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml
rename to app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenAdminUsersPageActionGroup.xml
index 2d451875c6358..e24bb67aa2d2d 100644
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserSuccessSaveMessageActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenAdminUsersPageActionGroup.xml
@@ -5,10 +5,10 @@
* See COPYING.txt for license details.
*/
-->
-
-
-
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
index a32027a6ac182..55247e9f6178f 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
@@ -9,14 +9,15 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
index 3f437e4c0ad8f..8e46f314110a7 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
@@ -25,7 +25,7 @@
['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails','Magento_Backend::system','Magento_Backend::system_other_settings','Magento_AdminNotification::adminnotification','Magento_AdminNotification::show_list']
- Sales
+ Sales Role
Custom
['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails']
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
index 3e7bb3e1889ef..0d4bebcc97372 100644
--- a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
@@ -18,7 +18,7 @@
-
+
@@ -27,49 +27,52 @@
-
+
-
-
-
+
-
-
+
+
+
-
+
+
+
+
-
-
+
-
-
+
+
+
-
+
-
-
-
+
+
+
+
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.xml b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.xml
index a89d1ede80112..88dc1dc9f6295 100644
--- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/UpdateAdminUserEntityTest.xml
@@ -8,6 +8,7 @@
+ mftf_migrated:yes
severity:S3
custom_admin_with_default_role
role::role_sales
From 60cc64dfcd54338bb604027b634f56bcde9bcb2a Mon Sep 17 00:00:00 2001
From: eduard13
Date: Thu, 25 Jul 2019 11:13:49 +0300
Subject: [PATCH 0049/1978] Fixing and providing a possibility to go to Admin
Edit CMS Page directly by using page_id
---
.../ActionGroup/AdminOpenCmsPageActionGroup.xml | 16 ++++++++++++++++
.../Cms/Test/Mftf/Page/AdminCmsPageEditPage.xml | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
create mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml
create mode 100644 app/code/Magento/Cms/Test/Mftf/Page/AdminCmsPageEditPage.xml
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml
new file mode 100644
index 0000000000000..7e907b5b395a4
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/AdminOpenCmsPageActionGroup.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsPageEditPage.xml b/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsPageEditPage.xml
new file mode 100644
index 0000000000000..978b6d6a6d261
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/Page/AdminCmsPageEditPage.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
From af53138724451b0af5c8b52729089bd30a53678a Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Thu, 25 Jul 2019 16:38:28 +0300
Subject: [PATCH 0050/1978] Remove the space before "/>?"
---
.../AssertAdminUserIsInGridActionGroup.xml | 8 ++++----
.../AssertUserRoleRestrictedAccessActionGroup.xml | 2 +-
.../ActionGroup/AdminOpenUserEditPageActionGroup.xml | 8 ++++----
.../ActionGroup/AdminUpdateUserRoleActionGroup.xml | 12 ++++++------
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
index 01e6b67b59a6c..f32c9dc0c75c4 100644
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
@@ -12,11 +12,11 @@
-
+
-
-
+
+
-
+
\ No newline at end of file
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
index 4d9166751ee15..0747eab31588e 100644
--- a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
@@ -9,6 +9,6 @@
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
index 55247e9f6178f..f7348d914f37f 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminOpenUserEditPageActionGroup.xml
@@ -11,11 +11,11 @@
-
-
-
+
+
+
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
index 313bf0b215d68..9ec4f2ef6a354 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminUpdateUserRoleActionGroup.xml
@@ -11,16 +11,16 @@
-
+
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
From 45742cd6cebd7ac158fe8f60dbbd0d2aef0e4af2 Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Sat, 27 Jul 2019 09:37:25 -0400
Subject: [PATCH 0051/1978] Remove looped item save
CartItemRepositoryInterface::save trigger quote collection and save. The update
cart items resolver accepts multiple quote items and save the quote. Saving
each quote item increases the quote save by the number of items passed in the
update request.
---
app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php b/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php
index b18c6ad662335..81a7779eb98b5 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/UpdateCartItem.php
@@ -117,7 +117,6 @@ private function updateItemQuantity(int $itemId, Quote $cart, float $quantity)
}
$cartItem->setQty($quantity);
$this->validateCartItem($cartItem);
- $this->cartItemRepository->save($cartItem);
}
/**
From 7c9b5f7fe45ba39d64f782b609efc370ea2684e3 Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Tue, 30 Jul 2019 12:43:39 +0300
Subject: [PATCH 0052/1978] refactoring
---
.../StorefrontClickHeaderLinkActionGroup.xml | 17 ++++++++++
.../StorefrontFillRegistryFormActionGroup.xml | 31 -------------------
.../StorefrontSeeHeaderLinksActionGroup.xml | 3 --
...teAccountPasswordComplexityActionGroup.xml | 17 ++++++++++
.../Customer/Test/Mftf/Data/CustomerData.xml | 20 ++++++++++++
.../StorefrontCustomerCreateFormSection.xml | 1 +
.../NewCustomerPasswordComplexityTest.xml | 24 +++++++++++---
.../NewCustomerPasswordComplexityTest.xml | 2 ++
8 files changed, 77 insertions(+), 38 deletions(-)
create mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontClickHeaderLinkActionGroup.xml
delete mode 100644 app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertMessageCustomerCreateAccountPasswordComplexityActionGroup.xml
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontClickHeaderLinkActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontClickHeaderLinkActionGroup.xml
new file mode 100644
index 0000000000000..46c06e909b4d9
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontClickHeaderLinkActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml
deleted file mode 100644
index 0a1440937a554..0000000000000
--- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontFillRegistryFormActionGroup.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml
index b70560ad2cd86..3155cca583d59 100644
--- a/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml
+++ b/app/code/Magento/Cms/Test/Mftf/ActionGroup/StorefrontSeeHeaderLinksActionGroup.xml
@@ -11,9 +11,6 @@
-
-
-
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertMessageCustomerCreateAccountPasswordComplexityActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertMessageCustomerCreateAccountPasswordComplexityActionGroup.xml
new file mode 100644
index 0000000000000..9d7dbc604f59d
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertMessageCustomerCreateAccountPasswordComplexityActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml b/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
index 5904067aea639..77bf6277d9c21 100644
--- a/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Data/CustomerData.xml
@@ -271,4 +271,24 @@
US_Address_TX
US_Address_NY_Not_Default_Address
+
+ 1
+ John.Doe@example.com
+ John
+ Doe
+ John Doe
+ 123123
+ 0
+ 0
+
+
+ 1
+ John.Doe@example.com
+ John
+ Doe
+ John Doe
+ 123123qa
+ 0
+ 0
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml
index 8881a2a012ce8..5a731b2c3f0ed 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerCreateFormSection.xml
@@ -17,6 +17,7 @@
+
diff --git a/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml b/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
index 29135332d6125..ccd97f83cd0a6 100644
--- a/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
+++ b/app/code/Magento/Security/Test/Mftf/Test/NewCustomerPasswordComplexityTest.xml
@@ -21,12 +21,28 @@
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/NewCustomerPasswordComplexityTest.xml b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/NewCustomerPasswordComplexityTest.xml
index a169a3f175cc6..7b6f3e981714c 100644
--- a/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/NewCustomerPasswordComplexityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Security/Test/TestCase/NewCustomerPasswordComplexityTest.xml
@@ -16,6 +16,7 @@
123123
123123
+ mftf_migrated:yes
severity:S1
@@ -26,6 +27,7 @@
123123qa
123123qa
+ mftf_migrated:yes
From 0b8deef2c17e326d06cf06e41b14bd044dcf60ae Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 31 Jul 2019 17:11:24 +0300
Subject: [PATCH 0053/1978] Working on the test
---
.../AdminOpenConfigurationPageActionGroup.xml | 14 +++++++
.../AdminConfigurationAdminSectionPage.xml | 12 ++++++
.../Mftf/Test/LockAdminUserEntityTest.xml | 38 +++++++++++++++++++
3 files changed, 64 insertions(+)
create mode 100644 app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml
create mode 100644 app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
create mode 100644 app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml
new file mode 100644
index 0000000000000..69972ea238b5e
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
new file mode 100644
index 0000000000000..fe704162ddac7
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml
new file mode 100644
index 0000000000000..6777573570783
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From c3097eab3398cdf56a59abc9adee38e95c536a20 Mon Sep 17 00:00:00 2001
From: vital_pantsialeyeu
Date: Thu, 1 Aug 2019 19:39:21 +0300
Subject: [PATCH 0054/1978] MC-18822: Increase test coverage for Content
functional area
- Integration test for MC-11441
---
.../Newsletter/Controller/SubscriberTest.php | 87 +++++++++++++++----
1 file changed, 70 insertions(+), 17 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
index 9dbf5c4d2a2a9..35f9cb4a5a11c 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
@@ -3,8 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Newsletter\Controller;
+use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Framework\App\RequestInterface;
+use Magento\Framework\Data\Form\FormKey;
+use Magento\Newsletter\Model\ResourceModel\Subscriber as SubscriberLoader;
+use Magento\Newsletter\Model\Subscriber;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\AbstractController;
@@ -13,11 +20,6 @@
*/
class SubscriberTest extends AbstractController
{
- protected function setUp()
- {
- parent::setUp();
- }
-
public function testNewAction()
{
$this->getRequest()->setMethod('POST');
@@ -34,9 +36,7 @@ public function testNewAction()
public function testNewActionUnusedEmail()
{
$this->getRequest()->setMethod('POST');
- $this->getRequest()->setPostValue([
- 'email' => 'not_used@example.com',
- ]);
+ $this->getRequest()->setPostValue(['email' => 'not_used@example.com']);
$this->dispatch('newsletter/subscriber/new');
@@ -50,15 +50,11 @@ public function testNewActionUnusedEmail()
public function testNewActionUsedEmail()
{
$this->getRequest()->setMethod('POST');
- $this->getRequest()->setPostValue([
- 'email' => 'customer@example.com',
- ]);
+ $this->getRequest()->setPostValue(['email' => 'customer@example.com']);
$this->dispatch('newsletter/subscriber/new');
- $this->assertSessionMessages($this->equalTo([
- 'Thank you for your subscription.',
- ]));
+ $this->assertSessionMessages($this->equalTo(['Thank you for your subscription.']));
$this->assertRedirect($this->anything());
}
@@ -68,9 +64,7 @@ public function testNewActionUsedEmail()
public function testNewActionOwnerEmail()
{
$this->getRequest()->setMethod('POST');
- $this->getRequest()->setPostValue([
- 'email' => 'customer@example.com',
- ]);
+ $this->getRequest()->setPostValue(['email' => 'customer@example.com']);
$this->login(1);
$this->dispatch('newsletter/subscriber/new');
@@ -79,6 +73,65 @@ public function testNewActionOwnerEmail()
$this->assertRedirect($this->anything());
}
+ /**
+ * Check that Customer still subscribed for newsletters emails after registration.
+ *
+ * @magentoConfigFixture ccustomer/create/account_confirm 1
+ */
+ public function testCreatePosWithSubscribeEmailAction()
+ {
+ $subscriber = Bootstrap::getObjectManager()->create(Subscriber::class);
+ $customerEmail = 'subscribeemail@example.com';
+ // Subscribe by email
+ $subscriber->subscribe($customerEmail);
+ $subscriber->loadByEmail($customerEmail);
+ $subscriber->confirm($subscriber->getSubscriberConfirmCode());
+
+ // Create customer
+ $this->fillRequestWithAccountDataAndFormKey($customerEmail);
+ $this->dispatch('customer/account/createPost');
+ $this->dispatch('customer/account/confirm');
+
+ $customerRepository = Bootstrap::getObjectManager()->get(CustomerRepositoryInterface::class);
+ /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
+ $customer = $customerRepository->get($customerEmail);
+ $subscriberResource = Bootstrap::getObjectManager()
+ ->create(SubscriberLoader::class);
+
+ // check customer subscribed to newsletter
+ $this->assertTrue($subscriberResource->loadByCustomerData($customer)['subscriber_status'] === "1");
+ }
+
+ /**
+ * Customer Data.
+ *
+ * @param string $email
+ * @return void
+ */
+ private function fillRequestWithAccountDataAndFormKey($email)
+ {
+ Bootstrap::getObjectManager()->get(RequestInterface::class)
+ ->setMethod('POST')
+ ->setParam('firstname', 'firstname1')
+ ->setParam('lastname', 'lastname1')
+ ->setParam('company', '')
+ ->setParam('email', $email)
+ ->setParam('password', '_Password1')
+ ->setParam('password_confirmation', '_Password1')
+ ->setParam('telephone', '5123334444')
+ ->setParam('street', ['1234 fake street', ''])
+ ->setParam('city', 'Austin')
+ ->setParam('region_id', 57)
+ ->setParam('region', '')
+ ->setParam('postcode', '78701')
+ ->setParam('country_id', 'US')
+ ->setParam('default_billing', '1')
+ ->setParam('default_shipping', '1')
+ ->setParam('is_subscribed', '0')
+ ->setPostValue('create_address', true)
+ ->setParam('form_key', Bootstrap::getObjectManager()->get(FormKey::class)->getFormKey());
+ }
+
/**
* Login the user
*
From 4f660a1d2def3cb6030b23afff4c0acc01ad1080 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Mon, 5 Aug 2019 17:22:59 +0300
Subject: [PATCH 0055/1978] Add action group to configure 'Maximum Login
Failures to Lockout Account'
---
.../AdminExpandSecurityTabActionGroup.xml | 16 +++++++++++++++
... AdminOpenAdminSectionPageActionGroup.xml} | 4 ++--
...ginFailuresToLockoutAccountActionGroup.xml | 20 +++++++++++++++++++
.../AdminConfigurationAdminSectionPage.xml | 2 +-
.../Config/Test/Mftf/Section/AdminSection.xml | 2 ++
.../Mftf/Test/LockAdminUserEntityTest.xml | 6 +++++-
6 files changed, 46 insertions(+), 4 deletions(-)
create mode 100644 app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml
rename app/code/Magento/Config/Test/Mftf/ActionGroup/{AdminOpenConfigurationPageActionGroup.xml => AdminOpenAdminSectionPageActionGroup.xml} (70%)
create mode 100644 app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml
new file mode 100644
index 0000000000000..76a1c9291f4e8
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenAdminSectionPageActionGroup.xml
similarity index 70%
rename from app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml
rename to app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenAdminSectionPageActionGroup.xml
index 69972ea238b5e..df78c374623a1 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigurationPageActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenAdminSectionPageActionGroup.xml
@@ -7,8 +7,8 @@
-->
-
-
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
new file mode 100644
index 0000000000000..02c528009ea87
--- /dev/null
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
index fe704162ddac7..02879ad1fc708 100644
--- a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
+++ b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/Config/Test/Mftf/Section/AdminSection.xml b/app/code/Magento/Config/Test/Mftf/Section/AdminSection.xml
index 7b6c9f8ab3b79..4aea038bec716 100644
--- a/app/code/Magento/Config/Test/Mftf/Section/AdminSection.xml
+++ b/app/code/Magento/Config/Test/Mftf/Section/AdminSection.xml
@@ -13,5 +13,7 @@
+
+
diff --git a/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml
index 6777573570783..c1e5154ba98e3 100644
--- a/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/LockAdminUserEntityTest.xml
@@ -32,7 +32,11 @@
-
+
+
+
+
+
\ No newline at end of file
From 63cdff53653a0787fff90659dc36b1246e886a41 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Tue, 6 Aug 2019 12:01:59 +0300
Subject: [PATCH 0056/1978] Finish the test
---
...> AdminOpenConfigAdminPageActionGroup.xml} | 4 +--
...ginFailuresToLockoutAccountActionGroup.xml | 2 +-
...ctionPage.xml => AdminConfigAdminPage.xml} | 2 +-
.../Magento/User/Test/Mftf/Data/UserData.xml | 35 ++++++++++++++++++-
.../Mftf/Test/LockAdminUserEntityTest.xml | 35 +++++++++++++++++--
5 files changed, 70 insertions(+), 8 deletions(-)
rename app/code/Magento/Config/Test/Mftf/ActionGroup/{AdminOpenAdminSectionPageActionGroup.xml => AdminOpenConfigAdminPageActionGroup.xml} (72%)
rename app/code/Magento/Config/Test/Mftf/Page/{AdminConfigurationAdminSectionPage.xml => AdminConfigAdminPage.xml} (73%)
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenAdminSectionPageActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml
similarity index 72%
rename from app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenAdminSectionPageActionGroup.xml
rename to app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml
index df78c374623a1..361f4fd1fa91b 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenAdminSectionPageActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml
@@ -7,8 +7,8 @@
-->
-
-
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
index 02c528009ea87..1dd05b7c45ddc 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
@@ -10,7 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
diff --git a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigAdminPage.xml
similarity index 73%
rename from app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
rename to app/code/Magento/Config/Test/Mftf/Page/AdminConfigAdminPage.xml
index 02879ad1fc708..661bb734bcbe4 100644
--- a/app/code/Magento/Config/Test/Mftf/Page/AdminConfigurationAdminSectionPage.xml
+++ b/app/code/Magento/Config/Test/Mftf/Page/AdminConfigAdminPage.xml
@@ -6,7 +6,7 @@
*/
-->
-
+
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserData.xml b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
index d465851c62373..b8dd8f30346fa 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
@@ -108,7 +108,40 @@
- 1
-
+
+ admin_user_with_correct_password
+ John
+ Doe
+ admin@example.com
+ 123123q
+ 123123q
+ en_US
+ English (United States)
+ true
+ Active
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
+ Administrators
+
+ - 1
+
+
+
+ admin_user_with_correct_password
+ John
+ Doe
+ admin@example.com
+ 123123123q
+ 123123123q
+ en_US
+ English (United States)
+ true
+ Active
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
+ Administrators
+
+ - 1
+
+
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
From eb60f826cf874da58b241c94f6b50d980bbfbd53 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Tue, 6 Aug 2019 13:25:15 +0300
Subject: [PATCH 0057/1978] Code refactoring
---
.../AdminExpandSecurityTabActionGroup.xml | 2 --
.../AdminOpenConfigAdminPageActionGroup.xml | 4 ++--
...imumLoginFailuresToLockoutAccountActionGroup.xml | 1 -
app/code/Magento/User/Test/Mftf/Data/UserData.xml | 13 -------------
...ityTest.xml => AdminLockAdminUserEntityTest.xml} | 4 ++--
.../User/Test/TestCase/LockAdminUserEntityTest.xml | 1 +
6 files changed, 5 insertions(+), 20 deletions(-)
rename app/code/Magento/User/Test/Mftf/Test/{LockAdminUserEntityTest.xml => AdminLockAdminUserEntityTest.xml} (98%)
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml
index 76a1c9291f4e8..5f9f35ceb8d0d 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminExpandSecurityTabActionGroup.xml
@@ -12,5 +12,3 @@
-
-
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml
index 361f4fd1fa91b..6d4fba179ecf4 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminOpenConfigAdminPageActionGroup.xml
@@ -8,7 +8,7 @@
-
+
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
index 1dd05b7c45ddc..ada58e9f4225e 100644
--- a/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
+++ b/app/code/Magento/Config/Test/Mftf/ActionGroup/AdminSetMaximumLoginFailuresToLockoutAccountActionGroup.xml
@@ -17,4 +17,3 @@
-
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserData.xml b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
index b8dd8f30346fa..e5c6a48497626 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
@@ -127,20 +127,7 @@
admin_user_with_correct_password
- John
- Doe
- admin@example.com
123123123q
- 123123123q
- en_US
- English (United States)
- true
- Active
- {{_ENV.MAGENTO_ADMIN_PASSWORD}}
- Administrators
-
- - 1
-
-
+
@@ -68,4 +68,4 @@
-
\ No newline at end of file
+
diff --git a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/LockAdminUserEntityTest.xml b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/LockAdminUserEntityTest.xml
index 052197e3db33c..f89f94ba03e73 100644
--- a/dev/tests/functional/tests/app/Magento/User/Test/TestCase/LockAdminUserEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/User/Test/TestCase/LockAdminUserEntityTest.xml
@@ -24,6 +24,7 @@
honey boo boo
7
+ mftf_migrated:yes
From 0fa8549b13e72e40481d1225d3ce1c32a7c15e49 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Tue, 6 Aug 2019 16:50:14 +0300
Subject: [PATCH 0058/1978] Code refactoring
---
.../Test/Mftf/Test/AdminLockAdminUserEntityTest.xml | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
index 06c7d429a625a..4a021597ce405 100644
--- a/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
@@ -35,7 +35,9 @@
-
+
+
+
@@ -48,16 +50,12 @@
-
-
-
-
-
+
-
+
From 06d06f1824c374af835fe2e5d222f8c7e5b2f9f0 Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Sun, 11 Aug 2019 17:18:18 +0200
Subject: [PATCH 0059/1978] Added Unit Test for Actions Block. Use FQCN. Reduce
Code-Smell
---
.../Block/Grid/Renderer/Actions.php | 32 +++++----
.../Unit/Block/Grid/Renderer/ActionsTest.php | 70 +++++++++++++++++++
2 files changed, 88 insertions(+), 14 deletions(-)
create mode 100644 app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
index 82f70d92e4930..ab591702ceae6 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
@@ -1,4 +1,6 @@
_urlHelper = $urlHelper;
parent::__construct($context, $data);
}
@@ -40,16 +44,16 @@ public function __construct(
* @param \Magento\Framework\DataObject $row
* @return string
*/
- public function render(\Magento\Framework\DataObject $row)
+ public function render(DataObject $row) : string
{
- $readDetailsHtml = $row->getUrl() ? '' .
__('Read Details') . ' ' : '';
- $markAsReadHtml = !$row->getIsRead() ? '' . __(
'Mark as Read'
) . ' ' : '';
@@ -63,8 +67,8 @@ public function render(\Magento\Framework\DataObject $row)
'*/*/remove/',
[
'_current' => true,
- 'id' => $row->getId(),
- \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
+ 'id' => $row->getData('id'),
+ ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
]
),
__('Are you sure?'),
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
new file mode 100644
index 0000000000000..4ffbcd56e8dcb
--- /dev/null
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
@@ -0,0 +1,70 @@
+getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
+ $escaperMock->expects($this->once())->method('escapeUrl')->willReturn('https://magento.com');
+
+ /** @var UrlInterface | \PHPUnit_Framework_MockObject_MockObject $urlBuilder */
+ $urlBuilder = $this->getMockBuilder(UrlInterface::class)->getMock();
+ $urlBuilder->expects($this->once())->method('getUrl')->willReturn('http://magento.com');
+
+ /** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
+ $contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
+ $contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
+ $contextMock->expects($this->once())->method('getUrlBuilder')->willReturn($urlBuilder);
+
+ /** @var Data | \PHPUnit_Framework_MockObject_MockObject $urlHelperMock */
+ $urlHelperMock = $this->getMockBuilder(Data::class)->disableOriginalConstructor()->getMock();
+ $urlHelperMock->expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');
+
+ $this->sut = new Actions($contextMock, $urlHelperMock);
+
+ }
+
+ public function test_should_render_message_when_urlIsGiven() : void
+ {
+ $dataObject = new DataObject();
+ $dataObject->setdata('url', 'https://magento.com');
+ $dataObject->setdata('is_read', true);
+ $dataObject->setdata('id', 1);
+
+ $actual = $this->sut->render($dataObject);
+ $expected = <<Read DetailsRemove
+HTML;
+
+ $this->assertEquals($actual, $expected);
+ }
+}
From cae8810baaee949298eccee884d2a6f97fcd3898 Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Sun, 11 Aug 2019 17:19:19 +0200
Subject: [PATCH 0060/1978] Added Unit Test for Notice Block. Added strict type
hint. Removed Code-Smell
---
.../Block/Grid/Renderer/Notice.php | 13 +++--
.../Unit/Block/Grid/Renderer/NoticeTest.php | 56 +++++++++++++++++++
2 files changed, 65 insertions(+), 4 deletions(-)
create mode 100644 app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
index ccc1b98a228ce..8de85cf1b241f 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
@@ -1,4 +1,6 @@
' .
- $this->escapeHtml($row->getTitle()) .
+ $this->escapeHtml($row->getData('title')) .
'' .
- ($row->getDescription() ? ' ' . $this->escapeHtml($row->getDescription()) : '');
+ ($row->getData('description') ? ' ' . $this->escapeHtml($row->getData('description')) : '');
}
}
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
new file mode 100644
index 0000000000000..4ed41a79bdaa8
--- /dev/null
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
@@ -0,0 +1,56 @@
+getMockBuilder(Escaper::class)->disableOriginalConstructor()->getMock();
+ $escaperMock->expects($this->exactly(2))->method('escapeHtml')->willReturn('Some random html
');
+
+ /** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
+ $contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
+ $contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
+
+ $this->sut = new Notice($contextMock);
+
+ }
+
+ public function test_should_render_notice() : void
+ {
+ $dataObject = new DataObject();
+ $dataObject->setData('title', 'A great Title');
+ $dataObject->setData('description', 'Handy description right here');
+
+ $actual = $this->sut->render($dataObject);
+ $expected = 'Some random html
Some random html
';
+
+ $this->assertEquals($actual, $expected);
+ }
+}
From 32f9293b28fc9a212a506e5e45cad538983f07ef Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Sun, 11 Aug 2019 17:20:19 +0200
Subject: [PATCH 0061/1978] Added Unit Test for Severity Block. Use FQCN. Added
strict type hints
---
.../Block/Grid/Renderer/Severity.php | 22 +++--
.../Unit/Block/Grid/Renderer/SeverityTest.php | 87 +++++++++++++++++++
2 files changed, 101 insertions(+), 8 deletions(-)
create mode 100644 app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
index 033fa52c55081..69c9d1994e764 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
@@ -1,4 +1,6 @@
_notice = $notice;
}
@@ -36,12 +39,14 @@ public function __construct(
* @param \Magento\Framework\DataObject $row
* @return string
*/
- public function render(\Magento\Framework\DataObject $row)
+ public function render(DataObject $row) : string
{
$class = '';
$value = '';
- switch ($row->getData($this->getColumn()->getIndex())) {
+ $column = $this->getColumn();
+ $index = $column->getData('index');
+ switch ($row->getData($index)) {
case MessageInterface::SEVERITY_CRITICAL:
$class = 'critical';
$value = $this->_notice->getSeverities(MessageInterface::SEVERITY_CRITICAL);
@@ -59,6 +64,7 @@ public function render(\Magento\Framework\DataObject $row)
$value = $this->_notice->getSeverities(MessageInterface::SEVERITY_NOTICE);
break;
}
+
return '' . $value . ' ';
}
}
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
new file mode 100644
index 0000000000000..2791d6d6ce15e
--- /dev/null
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
@@ -0,0 +1,87 @@
+getMockBuilder(Inbox::class)->disableOriginalConstructor()->getMock();
+
+ /** @var Context | \PHPUnit_Framework_MockObject_MockObject $contextMock */
+ $contextMock = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
+
+ $this->sut = new Severity($contextMock, $inboxMock);
+ }
+
+ public function test_should_render_severity() : void
+ {
+ /** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */
+ $columnMock = $this->getMockBuilder(Column::class)->disableOriginalConstructor()->getMock();
+ $columnMock->expects($this->exactly(5))->method('getData')->with($this->equalTo('index'))->willReturn('a magic index');
+ $this->sut->setColumn($columnMock);
+ $dataObject = new DataObject();
+
+ // Test critical severity
+ $dataObject->setData('a magic index', 1);
+ $actual = $this->sut->render($dataObject);
+ $expected = ' ';
+
+ $this->assertEquals($actual, $expected);
+
+ // Test major severity
+ $dataObject->setData('a magic index', 2);
+ $actual = $this->sut->render($dataObject);
+ $expected = ' ';
+
+ $this->assertEquals($actual, $expected);
+
+ // Test minor severity
+ $dataObject->setData('a magic index', 3);
+ $actual = $this->sut->render($dataObject);
+ $expected = ' ';
+
+ $this->assertEquals($actual, $expected);
+
+ // Test notice severity
+ $dataObject->setData('a magic index', 4);
+ $actual = $this->sut->render($dataObject);
+ $expected = ' ';
+
+ $this->assertEquals($actual, $expected);
+
+ // Test default severity
+ $dataObject->setData('a magic index', 5);
+ $actual = $this->sut->render($dataObject);
+ $expected = ' ';
+
+ $this->assertEquals($actual, $expected);
+ }
+}
From 3188cac632b7b54d9afd78f0d3993930d469b946 Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Sun, 11 Aug 2019 17:43:59 +0200
Subject: [PATCH 0062/1978] Fix CS
---
.../Test/Unit/Block/Grid/Renderer/ActionsTest.php | 13 ++++++++-----
.../Test/Unit/Block/Grid/Renderer/NoticeTest.php | 3 +--
.../Test/Unit/Block/Grid/Renderer/SeverityTest.php | 14 +++++++-------
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
index 4ffbcd56e8dcb..781734186ce6b 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/ActionsTest.php
@@ -1,5 +1,5 @@
expects($this->once())->method('getEncodedUrl')->willReturn('http://magento.com');
$this->sut = new Actions($contextMock, $urlHelperMock);
-
}
- public function test_should_render_message_when_urlIsGiven() : void
+ public function testShouldRenderMessageWhenUrlIsGiven() : void
{
$dataObject = new DataObject();
$dataObject->setdata('url', 'https://magento.com');
$dataObject->setdata('is_read', true);
$dataObject->setdata('id', 1);
- $actual = $this->sut->render($dataObject);
+ $actual = $this->sut->render($dataObject);
+
+ // Ignoring Code Style at this point due to the long HEREDOC
+ // phpcs:disable
$expected = <<Read DetailsRemove
HTML;
+ // phpcs:enable
$this->assertEquals($actual, $expected);
}
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
index 4ed41a79bdaa8..7b4b0a0f66e96 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/NoticeTest.php
@@ -39,10 +39,9 @@ protected function setUp() : void
$contextMock->expects($this->once())->method('getEscaper')->willReturn($escaperMock);
$this->sut = new Notice($contextMock);
-
}
- public function test_should_render_notice() : void
+ public function testShouldRenderNotice() : void
{
$dataObject = new DataObject();
$dataObject->setData('title', 'A great Title');
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
index 2791d6d6ce15e..f42c740ca8fee 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
@@ -41,44 +41,44 @@ protected function setUp() : void
$this->sut = new Severity($contextMock, $inboxMock);
}
- public function test_should_render_severity() : void
+ public function testShouldRenderSeverity() : void
{
/** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */
$columnMock = $this->getMockBuilder(Column::class)->disableOriginalConstructor()->getMock();
- $columnMock->expects($this->exactly(5))->method('getData')->with($this->equalTo('index'))->willReturn('a magic index');
+ $columnMock->expects($this->exactly(5))->method('getData')->with($this->equalTo('index'))->willReturn('index');
$this->sut->setColumn($columnMock);
$dataObject = new DataObject();
// Test critical severity
- $dataObject->setData('a magic index', 1);
+ $dataObject->setData('index', 1);
$actual = $this->sut->render($dataObject);
$expected = ' ';
$this->assertEquals($actual, $expected);
// Test major severity
- $dataObject->setData('a magic index', 2);
+ $dataObject->setData('index', 2);
$actual = $this->sut->render($dataObject);
$expected = ' ';
$this->assertEquals($actual, $expected);
// Test minor severity
- $dataObject->setData('a magic index', 3);
+ $dataObject->setData('index', 3);
$actual = $this->sut->render($dataObject);
$expected = ' ';
$this->assertEquals($actual, $expected);
// Test notice severity
- $dataObject->setData('a magic index', 4);
+ $dataObject->setData('index', 4);
$actual = $this->sut->render($dataObject);
$expected = ' ';
$this->assertEquals($actual, $expected);
// Test default severity
- $dataObject->setData('a magic index', 5);
+ $dataObject->setData('index', 5);
$actual = $this->sut->render($dataObject);
$expected = ' ';
From c2155d5c01a158656a00a921ae15cf145de779cd Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Sun, 11 Aug 2019 18:32:49 +0200
Subject: [PATCH 0063/1978] Fixed PHP CS
---
.../AdminNotification/Block/Grid/Renderer/Actions.php | 1 +
.../Magento/AdminNotification/Block/Grid/Renderer/Notice.php | 5 +++++
.../AdminNotification/Block/Grid/Renderer/Severity.php | 5 +++++
3 files changed, 11 insertions(+)
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
index ab591702ceae6..2db5bfec92395 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
@@ -18,6 +18,7 @@
/**
* Renderer class for action in the admin notifications grid
+ *
* @package Magento\AdminNotification\Block\Grid\Renderer
*/
class Actions extends AbstractRenderer
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
index 8de85cf1b241f..34919258dbc6c 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
@@ -12,6 +12,11 @@
use Magento\Backend\Block\Widget\Grid\Column\Renderer\AbstractRenderer;
use Magento\Framework\DataObject;
+/**
+ * Renderer class for notice in the admin notifications grid
+ *
+ * @package Magento\AdminNotification\Block\Grid\Renderer
+ */
class Notice extends AbstractRenderer
{
/**
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
index 69c9d1994e764..bf26bc15813e1 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
@@ -15,6 +15,11 @@
use Magento\Framework\DataObject;
use Magento\Framework\Notification\MessageInterface;
+/**
+ * Renderer class for severity in the admin notifications grid
+ *
+ * @package Magento\AdminNotification\Block\Grid\Renderer
+ */
class Severity extends AbstractRenderer
{
/**
From d0659f5d5304a282074741fa9bf4cbd13bf2bac0 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 13 Aug 2019 14:00:16 -0500
Subject: [PATCH 0064/1978] MC-18685: Remove custom layout updates from admin
---
.../Magento/Cms/Api/Data/PageInterface.php | 2 +
.../Adminhtml/Page/PostDataProcessor.php | 1 +
.../Cms/Controller/Adminhtml/Page/Save.php | 16 +-
.../Cms/Controller/Page/SaveManager.php | 102 +++++++++
app/code/Magento/Cms/Helper/Page.php | 22 +-
.../Page/CustomLayout/CustomLayoutManager.php | 195 ++++++++++++++++++
.../Data/CustomLayoutSelected.php | 51 +++++
.../Data/CustomLayoutSelectedInterface.php | 29 +++
.../Page/CustomLayoutManagerInterface.php | 58 ++++++
.../Magento/Cms/Model/Page/DataProvider.php | 41 +++-
.../Magento/Cms/Model/Page/IdentityMap.php | 72 +++++++
app/code/Magento/Cms/Model/PageRepository.php | 45 ++--
.../Cms/Observer/PageValidatorObserver.php | 45 ++++
app/code/Magento/Cms/etc/db_schema.xml | 2 +
.../Magento/Cms/etc/db_schema_whitelist.json | 3 +-
app/code/Magento/Cms/etc/di.xml | 6 +
app/code/Magento/Cms/etc/events.xml | 3 +
app/code/Magento/Cms/etc/webapi.xml | 4 +-
.../adminhtml/ui_component/cms_page_form.xml | 21 ++
.../Magento/Webapi/Model/Config/Converter.php | 17 +-
.../Magento/Webapi/Model/ServiceMetadata.php | 5 +-
app/code/Magento/Webapi/Model/Soap/Config.php | 2 +-
app/code/Magento/Webapi/etc/webapi_base.xsd | 1 +
.../Magento/Cms/Api/PageRepositoryTest.php | 126 +++++++++++
.../Cms/Controller/Adminhtml/PageSaveTest.php | 113 ++++++++++
.../Model/Page/CustomLayoutManagerTest.php | 91 ++++++++
.../Magento/Cms/Model/PageRepositoryTest.php | 98 ---------
.../User/_files/user_with_custom_role.php | 40 ++++
.../_files/user_with_custom_role_rollback.php | 28 +++
29 files changed, 1098 insertions(+), 141 deletions(-)
create mode 100644 app/code/Magento/Cms/Controller/Page/SaveManager.php
create mode 100644 app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
create mode 100644 app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelected.php
create mode 100644 app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelectedInterface.php
create mode 100644 app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
create mode 100644 app/code/Magento/Cms/Model/Page/IdentityMap.php
create mode 100644 app/code/Magento/Cms/Observer/PageValidatorObserver.php
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
delete mode 100644 dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role.php
create mode 100644 dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role_rollback.php
diff --git a/app/code/Magento/Cms/Api/Data/PageInterface.php b/app/code/Magento/Cms/Api/Data/PageInterface.php
index 032f4916a85e4..50fa8cf0db2d1 100644
--- a/app/code/Magento/Cms/Api/Data/PageInterface.php
+++ b/app/code/Magento/Cms/Api/Data/PageInterface.php
@@ -145,6 +145,8 @@ public function getCustomRootTemplate();
/**
* Get custom layout update xml
*
+ * @deprecated Existing updates are applied, new are not accepted.
+ * @see \Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelectedInterface
* @return string|null
*/
public function getCustomLayoutUpdateXml();
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
index 9b8933c8dba2e..20c33a2927101 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
@@ -64,6 +64,7 @@ public function __construct(
*/
public function filter($data)
{
+ unset($data['layout_update_selected']);
$filterRules = [];
foreach (['custom_theme_from', 'custom_theme_to'] as $dateField) {
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 37cb45753174f..1412a86cf0fd0 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -102,16 +102,16 @@ public function execute()
$model->setData($data);
- $this->_eventManager->dispatch(
- 'cms_page_prepare_save',
- ['page' => $model, 'request' => $this->getRequest()]
- );
+ try {
+ $this->_eventManager->dispatch(
+ 'cms_page_prepare_save',
+ ['page' => $model, 'request' => $this->getRequest()]
+ );
- if (!$this->dataProcessor->validate($data)) {
- return $resultRedirect->setPath('*/*/edit', ['page_id' => $model->getId(), '_current' => true]);
- }
+ if (!$this->dataProcessor->validate($data)) {
+ return $resultRedirect->setPath('*/*/edit', ['page_id' => $model->getId(), '_current' => true]);
+ }
- try {
$this->pageRepository->save($model);
$this->messageManager->addSuccessMessage(__('You saved the page.'));
return $this->processResultRedirect($model, $resultRedirect, $data);
diff --git a/app/code/Magento/Cms/Controller/Page/SaveManager.php b/app/code/Magento/Cms/Controller/Page/SaveManager.php
new file mode 100644
index 0000000000000..bbd80b72a049d
--- /dev/null
+++ b/app/code/Magento/Cms/Controller/Page/SaveManager.php
@@ -0,0 +1,102 @@
+pageRepository = $pageRepository;
+ $this->authorization = $authorization;
+ }
+
+ /**
+ * User saves a page (bew or existing).
+ *
+ * @param \Magento\Cms\Api\Data\PageInterface $page
+ * @return \Magento\Cms\Api\Data\PageInterface
+ * @throws LocalizedException
+ */
+ public function save(\Magento\Cms\Api\Data\PageInterface $page): \Magento\Cms\Api\Data\PageInterface
+ {
+ $this->validatePage($page);
+
+ return $this->pageRepository->save($page);
+ }
+
+ /**
+ * Validate page data received from a user.
+ *
+ * @param PageInterface $page
+ * @return void
+ * @throws LocalizedException When validation failed.
+ */
+ public function validatePage(\Magento\Cms\Api\Data\PageInterface $page): void
+ {
+ //Validate design changes.
+ if (!$this->authorization->isAllowed('Magento_Cms::save_design')) {
+ $notAllowed = false;
+ if (!$page->getId()) {
+ if ($page->getLayoutUpdateXml()
+ || $page->getPageLayout()
+ || $page->getCustomTheme()
+ || $page->getCustomLayoutUpdateXml()
+ || $page->getCustomThemeFrom()
+ || $page->getCustomThemeTo()
+ ) {
+ //Not allowed to set design properties value for new pages.
+ $notAllowed = true;
+ }
+ } else {
+ $savedPage = $this->pageRepository->getById($page->getId());
+ if ($page->getLayoutUpdateXml() !== $savedPage->getLayoutUpdateXml()
+ || $page->getPageLayout() !== $savedPage->getPageLayout()
+ || $page->getCustomTheme() !== $savedPage->getCustomTheme()
+ || $page->getCustomThemeTo() !== $savedPage->getCustomThemeTo()
+ || $page->getCustomThemeFrom() !== $savedPage->getCustomThemeFrom()
+ || $page->getCustomLayoutUpdateXml() !== $savedPage->getCustomLayoutUpdateXml()
+ ) {
+ //Not allowed to update design settings.
+ $notAllowed = true;
+ }
+ }
+
+ if ($notAllowed) {
+ throw new AuthorizationException(
+ __('You are not allowed to change CMS pages design settings')
+ );
+ }
+ }
+ }
+}
diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php
index 70e9437235ac3..bf263d94aaca7 100644
--- a/app/code/Magento/Cms/Helper/Page.php
+++ b/app/code/Magento/Cms/Helper/Page.php
@@ -5,7 +5,9 @@
*/
namespace Magento\Cms\Helper;
+use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
use Magento\Framework\App\Action\Action;
+use Magento\Framework\App\ObjectManager;
/**
* CMS Page Helper
@@ -76,6 +78,11 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper
*/
protected $resultPageFactory;
+ /**
+ * @var CustomLayoutManagerInterface
+ */
+ private $customLayoutManager;
+
/**
* Constructor
*
@@ -88,6 +95,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper
* @param \Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ * @param CustomLayoutManagerInterface|null $customLayoutManager
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -99,7 +107,8 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Framework\Escaper $escaper,
- \Magento\Framework\View\Result\PageFactory $resultPageFactory
+ \Magento\Framework\View\Result\PageFactory $resultPageFactory,
+ ?CustomLayoutManagerInterface $customLayoutManager = null
) {
$this->messageManager = $messageManager;
$this->_page = $page;
@@ -109,6 +118,8 @@ public function __construct(
$this->_localeDate = $localeDate;
$this->_escaper = $escaper;
$this->resultPageFactory = $resultPageFactory;
+ $this->customLayoutManager = $customLayoutManager
+ ?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
parent::__construct($context);
}
@@ -152,7 +163,14 @@ public function prepareResultPage(Action $action, $pageId = null)
$resultPage = $this->resultPageFactory->create();
$this->setLayoutType($inRange, $resultPage);
$resultPage->addHandle('cms_page_view');
- $resultPage->addPageLayoutHandles(['id' => str_replace('/', '_', $this->_page->getIdentifier())]);
+ $pageHandles = ['id' => str_replace('/', '_', $this->_page->getIdentifier())];
+ //Selected custom updates.
+ $customLayoutHandle = $this->customLayoutManager->fetchHandle($this->_page->getId());
+ if ($customLayoutHandle) {
+ $pageHandles = array_merge($pageHandles, $customLayoutHandle);
+ }
+
+ $resultPage->addPageLayoutHandles($pageHandles);
$this->_eventManager->dispatch(
'cms_page_render',
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
new file mode 100644
index 0000000000000..8d8dbe06a6078
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
@@ -0,0 +1,195 @@
+pageRepository = $pageRepository;
+ $this->pageFactory = $factory;
+ $this->identityMap = $identityMap;
+ $this->fileCollector = $fileCollector;
+ $this->themeFactory = $themeFactory;
+ $this->design = $design;
+ }
+
+ /**
+ * Find page model by ID.
+ *
+ * @param int $id
+ * @return PageModel
+ * @throws NoSuchEntityException
+ */
+ private function findPage(int $id): PageModel
+ {
+ if (!$page = $this->identityMap->get($id)) {
+ /** @var PageModel $page */
+ $this->pageRepository->load($page = $this->pageFactory->create(), $id);
+ if (!$page->getIdentifier()) {
+ throw NoSuchEntityException::singleField('id', $id);
+ }
+ }
+
+ return $page;
+ }
+
+ /**
+ * Adopt page's identifier to be used as layout handle.
+ *
+ * @param PageModel $page
+ * @return string
+ */
+ private function sanitizeIdentifier(PageModel $page): string
+ {
+ return str_replace('/', '_', $page->getIdentifier());
+ }
+
+ /**
+ * Save new custom layout file value for a page.
+ *
+ * @param int $pageId
+ * @param string|null $layoutFile
+ * @throws LocalizedException
+ * @throws \InvalidArgumentException When invalid file was selected.
+ * @throws NoSuchEntityException
+ */
+ private function saveLayout(int $pageId, ?string $layoutFile): void
+ {
+ $page = $this->findPage($pageId);
+ if ($layoutFile !== null && !in_array($layoutFile, $this->fetchAvailableFiles($pageId), true)) {
+ throw new \InvalidArgumentException(
+ $layoutFile .' is not available for page #' .$pageId
+ );
+ }
+
+ $page->setData('layout_update_selected', $layoutFile);
+ $this->pageRepository->save($page);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function save(CustomLayoutSelectedInterface $layout): void
+ {
+ $this->saveLayout($layout->getPageId(), $layout->getLayoutFileId());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function deleteFor(int $pageId): void
+ {
+ $this->saveLayout($pageId, null);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function fetchAvailableFiles(int $pageId): array
+ {
+ $page = $this->findPage($pageId);
+ $identifier = $this->sanitizeIdentifier($page);
+ $layoutFiles = $this->fileCollector->getFiles(
+ $this->themeFactory->create($this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND)),
+ 'cms_page_view_selectable_' .$identifier .'_*.xml'
+ );
+
+ return array_filter(
+ array_map(
+ function (File $file) use ($identifier) : ?string
+ {
+ preg_match(
+ '/selectable\_' .preg_quote($identifier) .'\_([a-z0-9]+)/i',
+ $file->getName(),
+ $selectable
+ );
+ if (!empty($selectable[1])) {
+ return $selectable[1];
+ }
+
+ return null;
+ },
+ $layoutFiles
+ )
+ );
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function fetchHandle(int $pageId): ?array
+ {
+ $page = $this->findPage($pageId);
+
+ return $page['layout_update_selected']
+ ? ['selectable' => $this->sanitizeIdentifier($page) .'_' .$page['layout_update_selected']] : null;
+ }
+}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelected.php b/app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelected.php
new file mode 100644
index 0000000000000..fc29ebd72e802
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelected.php
@@ -0,0 +1,51 @@
+pageId = $pageId;
+ $this->layoutFile = $layoutFile;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getPageId(): int
+ {
+ return $this->pageId;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getLayoutFileId(): string
+ {
+ return $this->layoutFile;
+ }
+}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelectedInterface.php b/app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelectedInterface.php
new file mode 100644
index 0000000000000..68bac57e98d56
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/Data/CustomLayoutSelectedInterface.php
@@ -0,0 +1,29 @@
+collection = $pageCollectionFactory->create();
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
$this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class);
$this->meta = $this->prepareMeta($this->meta);
+ $this->request = $request ?? ObjectManager::getInstance()->get(RequestInterface::class);
+ $this->customLayoutManager = $customLayoutManager
+ ?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
}
/**
@@ -134,6 +152,27 @@ public function getMeta()
$meta = array_merge_recursive($meta, $designMeta);
}
+ //List of custom layout files available for current page.
+ $options = [['label' => 'Use default', 'value' => '']];
+ if ($this->getRequestFieldName() && ($pageId = (int)$this->request->getParam($this->getRequestFieldName()))) {
+ //We must have a specific page selected.
+ foreach ($this->customLayoutManager->fetchAvailableFiles($pageId) as $layoutFile) {
+ $options[] = ['label' => $layoutFile, 'value' => $layoutFile];
+ }
+ }
+ $customLayoutMeta = [
+ 'design' => [
+ 'children' => [
+ 'custom_layout_update_select' => [
+ 'arguments' => [
+ 'data' => ['options' => $options]
+ ]
+ ]
+ ]
+ ]
+ ];
+ $meta = array_merge_recursive($meta, $customLayoutMeta);
+
return $meta;
}
}
diff --git a/app/code/Magento/Cms/Model/Page/IdentityMap.php b/app/code/Magento/Cms/Model/Page/IdentityMap.php
new file mode 100644
index 0000000000000..249010fbf90ce
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Page/IdentityMap.php
@@ -0,0 +1,72 @@
+getId()) {
+ throw new \InvalidArgumentException('Cannot add non-persisted page to identity map');
+ }
+ $this->pages[$page->getId()] = $page;
+ }
+
+ /**
+ * Find a loaded page by ID.
+ *
+ * @param int $id
+ * @return Page|null
+ */
+ public function get(int $id): ?Page
+ {
+ if (array_key_exists($id, $this->pages)) {
+ return $this->pages[$id];
+ }
+
+ return null;
+ }
+
+ /**
+ * Remove the page from the list.
+ *
+ * @param int $id
+ * @return void
+ */
+ public function remove(int $id): void
+ {
+ unset($this->pages[$id]);
+ }
+
+ /**
+ * Clear the list.
+ *
+ * @return void
+ */
+ public function clear(): void
+ {
+ $this->pages = [];
+ }
+}
diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php
index e6777659d7d88..2fc16e871cce7 100644
--- a/app/code/Magento/Cms/Model/PageRepository.php
+++ b/app/code/Magento/Cms/Model/PageRepository.php
@@ -8,6 +8,7 @@
use Magento\Cms\Api\Data;
use Magento\Cms\Api\PageRepositoryInterface;
+use Magento\Cms\Model\Page\IdentityMap;
use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\App\ObjectManager;
@@ -82,6 +83,11 @@ class PageRepository implements PageRepositoryInterface
*/
private $authorization;
+ /**
+ * @var IdentityMap
+ */
+ private $identityMap;
+
/**
* @param ResourcePage $resource
* @param PageFactory $pageFactory
@@ -92,6 +98,7 @@ class PageRepository implements PageRepositoryInterface
* @param DataObjectProcessor $dataObjectProcessor
* @param StoreManagerInterface $storeManager
* @param CollectionProcessorInterface $collectionProcessor
+ * @param IdentityMap|null $identityMap
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -103,7 +110,8 @@ public function __construct(
DataObjectHelper $dataObjectHelper,
DataObjectProcessor $dataObjectProcessor,
StoreManagerInterface $storeManager,
- CollectionProcessorInterface $collectionProcessor = null
+ CollectionProcessorInterface $collectionProcessor = null,
+ ?IdentityMap $identityMap = null
) {
$this->resource = $resource;
$this->pageFactory = $pageFactory;
@@ -114,6 +122,7 @@ public function __construct(
$this->dataObjectProcessor = $dataObjectProcessor;
$this->storeManager = $storeManager;
$this->collectionProcessor = $collectionProcessor ?: $this->getCollectionProcessor();
+ $this->identityMap = $identityMap ?? ObjectManager::getInstance()->get(IdentityMap::class);
}
/**
@@ -158,33 +167,18 @@ public function save(\Magento\Cms\Api\Data\PageInterface $page)
$page->setStoreId($storeId);
}
try {
- //Validate changing of design.
- $userType = $this->getUserContext()->getUserType();
- if ((
- $userType === UserContextInterface::USER_TYPE_ADMIN
- || $userType === UserContextInterface::USER_TYPE_INTEGRATION
- )
- && !$this->getAuthorization()->isAllowed('Magento_Cms::save_design')
+ //Persisted data
+ $savedPage = $page->getId() ? $this->getById($page->getId()) : null;
+
+ //Custom layout update must be selected from available files
+ if ($page->getCustomLayoutUpdateXml()
+ && (!$savedPage || $page->getCustomLayoutUpdateXml() !== $savedPage->getCustomLayoutUpdateXml())
) {
- if (!$page->getId()) {
- $page->setLayoutUpdateXml(null);
- $page->setPageLayout(null);
- $page->setCustomTheme(null);
- $page->setCustomLayoutUpdateXml(null);
- $page->setCustomThemeTo(null);
- $page->setCustomThemeFrom(null);
- } else {
- $savedPage = $this->getById($page->getId());
- $page->setLayoutUpdateXml($savedPage->getLayoutUpdateXml());
- $page->setPageLayout($savedPage->getPageLayout());
- $page->setCustomTheme($savedPage->getCustomTheme());
- $page->setCustomLayoutUpdateXml($savedPage->getCustomLayoutUpdateXml());
- $page->setCustomThemeTo($savedPage->getCustomThemeTo());
- $page->setCustomThemeFrom($savedPage->getCustomThemeFrom());
- }
+ throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
}
$this->resource->save($page);
+ $this->identityMap->add($page);
} catch (\Exception $exception) {
throw new CouldNotSaveException(
__('Could not save the page: %1', $exception->getMessage()),
@@ -208,6 +202,8 @@ public function getById($pageId)
if (!$page->getId()) {
throw new NoSuchEntityException(__('The CMS page with the "%1" ID doesn\'t exist.', $pageId));
}
+ $this->identityMap->add($page);
+
return $page;
}
@@ -245,6 +241,7 @@ public function delete(\Magento\Cms\Api\Data\PageInterface $page)
{
try {
$this->resource->delete($page);
+ $this->identityMap->remove($page->getId());
} catch (\Exception $exception) {
throw new CouldNotDeleteException(
__('Could not delete the page: %1', $exception->getMessage())
diff --git a/app/code/Magento/Cms/Observer/PageValidatorObserver.php b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
new file mode 100644
index 0000000000000..af0d30f450432
--- /dev/null
+++ b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
@@ -0,0 +1,45 @@
+saveManager = $saveManager;
+ }
+
+ /**
+ * @inheritDoc
+ * @throws LocalizedException
+ */
+ public function execute(Observer $observer)
+ {
+ /** @var PageInterface $page */
+ $page = $observer->getEvent()->getData('page');
+ $this->saveManager->validatePage($page);
+ }
+}
diff --git a/app/code/Magento/Cms/etc/db_schema.xml b/app/code/Magento/Cms/etc/db_schema.xml
index 1e64c905badd8..e0cf534e8354c 100644
--- a/app/code/Magento/Cms/etc/db_schema.xml
+++ b/app/code/Magento/Cms/etc/db_schema.xml
@@ -68,6 +68,8 @@
comment="Page Custom Template"/>
+
diff --git a/app/code/Magento/Cms/etc/db_schema_whitelist.json b/app/code/Magento/Cms/etc/db_schema_whitelist.json
index 8da44baf71719..fe0e9c1f2e22e 100644
--- a/app/code/Magento/Cms/etc/db_schema_whitelist.json
+++ b/app/code/Magento/Cms/etc/db_schema_whitelist.json
@@ -50,7 +50,8 @@
"custom_layout_update_xml": true,
"custom_theme_from": true,
"custom_theme_to": true,
- "meta_title": true
+ "meta_title": true,
+ "layout_update_selected": true
},
"index": {
"CMS_PAGE_IDENTIFIER": true,
diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml
index e41f500915916..0af2fa29fb762 100644
--- a/app/code/Magento/Cms/etc/di.xml
+++ b/app/code/Magento/Cms/etc/di.xml
@@ -235,4 +235,10 @@
+
+
+
+ Magento\Framework\View\Layout\File\Collector\Aggregated\Proxy
+
+
diff --git a/app/code/Magento/Cms/etc/events.xml b/app/code/Magento/Cms/etc/events.xml
index d6b9ad4ee0248..1ad847e215ccc 100644
--- a/app/code/Magento/Cms/etc/events.xml
+++ b/app/code/Magento/Cms/etc/events.xml
@@ -36,4 +36,7 @@
+
+
+
diff --git a/app/code/Magento/Cms/etc/webapi.xml b/app/code/Magento/Cms/etc/webapi.xml
index 5b66d0e3ed879..8cf0cb767d9be 100644
--- a/app/code/Magento/Cms/etc/webapi.xml
+++ b/app/code/Magento/Cms/etc/webapi.xml
@@ -20,8 +20,8 @@
-
-
+
+
diff --git a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_form.xml b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_form.xml
index dd58d17cbf577..396923a2b6f3b 100644
--- a/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_form.xml
+++ b/app/code/Magento/Cms/view/adminhtml/ui_component/cms_page_form.xml
@@ -249,6 +249,7 @@
+ - true
-
- page
@@ -259,6 +260,26 @@
layout_update_xml
+
+
+ -
+
- page
+
+
+
+ text
+ Custom Layout Update
+
+
+ List of layout files with an update handle "selectable"
+ matching *PageIdentifier*_*UpdateID*.
+ <br/>
+ See Magento documentation for more information
+
+
+ layout_update_selected
+
+
diff --git a/app/code/Magento/Webapi/Model/Config/Converter.php b/app/code/Magento/Webapi/Model/Config/Converter.php
index 837a0f84423ad..3ce79a83b176b 100644
--- a/app/code/Magento/Webapi/Model/Config/Converter.php
+++ b/app/code/Magento/Webapi/Model/Config/Converter.php
@@ -50,16 +50,22 @@ public function convert($source)
$service = $route->getElementsByTagName('service')->item(0);
$serviceClass = $service->attributes->getNamedItem('class')->nodeValue;
$serviceMethod = $service->attributes->getNamedItem('method')->nodeValue;
+ //WSDL method name which may differ from an actual method used.
$soapMethod = $serviceMethod;
if ($soapOperationNode = $route->attributes->getNamedItem('soapOperation')) {
$soapMethod = trim($soapOperationNode->nodeValue);
}
+ //WSDL class name which may differ from an actual class used.
+ $soapService = $serviceClass;
+ if ($soapServiceNode = $route->attributes->getNamedItem('soapService')) {
+ $soapService = trim($soapServiceNode->nodeValue);
+ }
$url = trim($route->attributes->getNamedItem('url')->nodeValue);
$version = $this->convertVersion($url);
$serviceClassData = [];
- if (isset($result[self::KEY_SERVICES][$serviceClass][$version])) {
- $serviceClassData = $result[self::KEY_SERVICES][$serviceClass][$version];
+ if (isset($result[self::KEY_SERVICES][$soapService][$version])) {
+ $serviceClassData = $result[self::KEY_SERVICES][$soapService][$version];
}
$resources = $route->getElementsByTagName('resource');
@@ -110,13 +116,18 @@ public function convert($source)
if (isset($serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_SECURE])) {
$serviceSecure = $serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_SECURE];
}
+ //Real method to use when performing operations.
if (!isset($serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_REAL_SERVICE_METHOD])) {
$serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_REAL_SERVICE_METHOD] = $serviceMethod;
}
+ //Real class to initialize when performing operations.
+ if (!isset($serviceClassData[self::KEY_METHODS][$soapMethod]['real_class'])) {
+ $serviceClassData[self::KEY_METHODS][$soapMethod]['real_class'] = $serviceClass;
+ }
$serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_SECURE] = $serviceSecure || $secure;
$serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_DATA_PARAMETERS] = $serviceData;
- $result[self::KEY_SERVICES][$serviceClass][$version] = $serviceClassData;
+ $result[self::KEY_SERVICES][$soapService][$version] = $serviceClassData;
}
return $result;
}
diff --git a/app/code/Magento/Webapi/Model/ServiceMetadata.php b/app/code/Magento/Webapi/Model/ServiceMetadata.php
index 36f5819b03c98..d2bd08267128a 100644
--- a/app/code/Magento/Webapi/Model/ServiceMetadata.php
+++ b/app/code/Magento/Webapi/Model/ServiceMetadata.php
@@ -118,12 +118,15 @@ protected function initServicesMetadata()
$methods = [];
foreach ($serviceData[Converter::KEY_METHODS] as $methodName => $methodMetadata) {
$services[$serviceName][self::KEY_SERVICE_METHODS][$methodName] = [
+ //Method to use for the operation. May differ from the operation's name.
self::KEY_METHOD => $methodMetadata[Converter::KEY_REAL_SERVICE_METHOD],
self::KEY_IS_REQUIRED => (bool)$methodMetadata[Converter::KEY_SECURE],
self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_SECURE],
self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES],
self::KEY_METHOD_ALIAS => $methodName,
- self::KEY_ROUTE_PARAMS => $methodMetadata[Converter::KEY_DATA_PARAMETERS]
+ self::KEY_ROUTE_PARAMS => $methodMetadata[Converter::KEY_DATA_PARAMETERS],
+ //Class to initialize for the operation. May differ from the operation's name.
+ 'real_class' => $methodMetadata['real_class']
];
$services[$serviceName][self::KEY_CLASS] = $serviceClass;
$methods[] = $methodMetadata[Converter::KEY_REAL_SERVICE_METHOD];
diff --git a/app/code/Magento/Webapi/Model/Soap/Config.php b/app/code/Magento/Webapi/Model/Soap/Config.php
index 190280ff8f004..94b3dad48b1ce 100644
--- a/app/code/Magento/Webapi/Model/Soap/Config.php
+++ b/app/code/Magento/Webapi/Model/Soap/Config.php
@@ -74,7 +74,7 @@ protected function getSoapOperations($requestedServices)
foreach ($this->getRequestedSoapServices($requestedServices) as $serviceName => $serviceData) {
foreach ($serviceData[ServiceMetadata::KEY_SERVICE_METHODS] as $methodData) {
$method = $methodData[ServiceMetadata::KEY_METHOD];
- $class = $serviceData[ServiceMetadata::KEY_CLASS];
+ $class = $methodData['real_class'];
$operation = $methodData[ServiceMetadata::KEY_METHOD_ALIAS];
$operationName = $serviceName . ucfirst($operation);
$this->soapOperations[$operationName] = [
diff --git a/app/code/Magento/Webapi/etc/webapi_base.xsd b/app/code/Magento/Webapi/etc/webapi_base.xsd
index 7d1a5a14ba78f..b38efae2a3435 100644
--- a/app/code/Magento/Webapi/etc/webapi_base.xsd
+++ b/app/code/Magento/Webapi/etc/webapi_base.xsd
@@ -30,6 +30,7 @@
+
diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
index c40d1918cca67..3470c507c4e5b 100644
--- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
@@ -5,11 +5,16 @@
*/
namespace Magento\Cms\Api;
+use Magento\Authorization\Model\Role;
+use Magento\Authorization\Model\Rules;
+use Magento\Authorization\Model\RoleFactory;
+use Magento\Authorization\Model\RulesFactory;
use Magento\Cms\Api\Data\PageInterface;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\Api\SortOrderBuilder;
+use Magento\Integration\Api\AdminTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\WebapiAbstract;
@@ -47,6 +52,21 @@ class PageRepositoryTest extends WebapiAbstract
*/
protected $currentPage;
+ /**
+ * @var RoleFactory
+ */
+ private $roleFactory;
+
+ /**
+ * @var RulesFactory
+ */
+ private $rulesFactory;
+
+ /**
+ * @var AdminTokenServiceInterface
+ */
+ private $adminTokens;
+
/**
* Execute per test initialization.
*/
@@ -57,6 +77,9 @@ public function setUp()
$this->dataObjectHelper = Bootstrap::getObjectManager()->create(\Magento\Framework\Api\DataObjectHelper::class);
$this->dataObjectProcessor = Bootstrap::getObjectManager()
->create(\Magento\Framework\Reflection\DataObjectProcessor::class);
+ $this->roleFactory = Bootstrap::getObjectManager()->get(RoleFactory::class);
+ $this->rulesFactory = Bootstrap::getObjectManager()->get(RulesFactory::class);
+ $this->adminTokens = Bootstrap::getObjectManager()->get(AdminTokenServiceInterface::class);
}
/**
@@ -379,4 +402,107 @@ private function deletePageByIdentifier($pageId)
$this->_webApiCall($serviceInfo, [PageInterface::PAGE_ID => $pageId]);
}
+
+ /**
+ * Check that extra authorization is required for the design properties.
+ *
+ * @magentoApiDataFixture Magento/User/_files/user_with_custom_role.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ //Updating our admin user's role to allow saving pages but not their design settings.
+ /** @var Role $role */
+ $role = $this->roleFactory->create();
+ $role->load('test_custom_role', 'role_name');
+ /** @var Rules $rules */
+ $rules = $this->rulesFactory->create();
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Cms::page']);
+ $rules->saveRel();
+ //Using the admin user with custom role.
+ $token = $this->adminTokens->createAdminAccessToken('customRoleUser', \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
+
+ $id = 'test-cms-page';
+ $serviceInfo = [
+ 'rest' => [
+ 'resourcePath' => self::RESOURCE_PATH,
+ 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
+ 'token' => $token,
+ ],
+ 'soap' => [
+ 'service' => self::SERVICE_NAME,
+ 'serviceVersion' => self::SERVICE_VERSION,
+ 'operation' => self::SERVICE_NAME . 'Save',
+ 'token' => $token
+ ],
+ ];
+ $requestData = [
+ 'page' => [
+ PageInterface::IDENTIFIER => $id,
+ PageInterface::TITLE => 'Page title',
+ PageInterface::CUSTOM_THEME => 1
+ ],
+ ];
+
+ //Creating new page with design settings.
+ $exceptionMessage = null;
+ try {
+ $this->_webApiCall($serviceInfo, $requestData);
+ } catch (\Throwable $exception) {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ $exceptionMessage = $restResponse['message'];
+ } else {
+ //SOAP
+ $exceptionMessage = $exception->getMessage();
+ }
+ }
+ //We don't have the permissions.
+ $this->assertEquals('You are not allowed to change CMS pages design settings', $exceptionMessage);
+
+ //Updating the user role to allow access to design properties.
+ /** @var Rules $rules */
+ $rules = Bootstrap::getObjectManager()->create(Rules::class);
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Cms::page', 'Magento_Cms::save_design']);
+ $rules->saveRel();
+ //Making the same request with design settings.
+ $result = $this->_webApiCall($serviceInfo, $requestData);
+ $this->assertArrayHasKey('id', $result);
+ //Page must be saved.
+ $this->currentPage = $this->pageRepository->getById($result['id']);
+ $this->assertEquals($id, $this->currentPage->getIdentifier());
+ $this->assertEquals(1, $this->currentPage->getCustomTheme());
+ $requestData['page']['id'] = $this->currentPage->getId();
+
+ //Updating our role to remove design properties access.
+ /** @var Rules $rules */
+ $rules = Bootstrap::getObjectManager()->create(Rules::class);
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Cms::page']);
+ $rules->saveRel();
+ //Updating the page but with the same design properties values.
+ $result = $this->_webApiCall($serviceInfo, $requestData);
+ //We haven't changed the design so operation is successful.
+ $this->assertArrayHasKey('id', $result);
+
+ //Changing a design property.
+ $requestData['page'][PageInterface::CUSTOM_THEME] = 2;
+ $exceptionMessage = null;
+ try {
+ $this->_webApiCall($serviceInfo, $requestData);
+ } catch (\Throwable $exception) {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ $exceptionMessage = $restResponse['message'];
+ } else {
+ //SOAP
+ $exceptionMessage = $exception->getMessage();
+ }
+ }
+ //We don't have permissions to do that.
+ $this->assertEquals('You are not allowed to change CMS pages design settings', $exceptionMessage);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php
new file mode 100644
index 0000000000000..17c28a76d394d
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php
@@ -0,0 +1,113 @@
+aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
+ }
+
+ /**
+ * Check whether additional authorization is required for the design fields.
+ *
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ //Expected list of sessions messages collected throughout the controller calls.
+ $sessionMessages = ['You are not allowed to change CMS pages design settings'];
+ //Test page data.
+ $id = 'test-page';
+ $requestData = [
+ PageInterface::IDENTIFIER => $id,
+ PageInterface::TITLE => 'Page title',
+ PageInterface::CUSTOM_THEME => '1'
+ ];
+
+ //Creating a new page with design properties without the required permissions.
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Cms::save_design');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->dispatch($this->uri);
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+
+ //Trying again with the permissions.
+ $this->aclBuilder->getAcl()->allow(null, ['Magento_Cms::save', 'Magento_Cms::save_design']);
+ $this->getRequest()->setDispatched(false);
+ $this->dispatch($this->uri);
+ /** @var Page $page */
+ $page = Bootstrap::getObjectManager()->create(PageInterface::class);
+ $page->load($id, PageInterface::IDENTIFIER);
+ $this->assertNotEmpty($page->getId());
+ $this->assertEquals(1, $page->getCustomTheme());
+ $requestData['page_id'] = $page->getId();
+ $this->getRequest()->setPostValue($requestData);
+
+ //Updating the page without the permissions but not touching design settings.
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Cms::save_design');
+ $this->getRequest()->setDispatched(false);
+ $this->dispatch($this->uri);
+ $this->assertSessionMessages(self::equalTo($sessionMessages), MessageInterface::TYPE_ERROR);
+
+ //Updating design settings without the permissions.
+ $requestData[PageInterface::CUSTOM_THEME] = '2';
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setDispatched(false);
+ $this->dispatch($this->uri);
+ $sessionMessages[] = $sessionMessages[0];
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
new file mode 100644
index 0000000000000..7b2f0b8cbd57c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
@@ -0,0 +1,91 @@
+getMockForAbstractClass(CollectorInterface::class);
+ $fileCollector->method('getFiles')
+ ->willReturn($files);
+
+ $this->manager = $objectManager->create(
+ CustomLayoutManagerInterface::class,
+ ['fileCollector' => $fileCollector]
+ );
+ $this->pageFactory = $objectManager->get(PageFactory::class);
+ }
+
+ /**
+ * Test updating a page's custom layout.
+ *
+ * @magentoDataFixture Magento/Cms/_files/pages.php
+ * @return void
+ */
+ public function testCustomLayout(): void
+ {
+ /** @var Page $page */
+ $page = $this->pageFactory->create();
+ $page->load('page100', 'identifier');
+ $pageId = (int)$page->getId();
+
+ //Invalid file ID
+ $exceptionRaised = null;
+ try {
+ $this->manager->save(new CustomLayoutSelected($pageId, 'some_file'));
+ } catch (\Throwable $exception) {
+ $exceptionRaised = $exception;
+ }
+ $this->assertNotEmpty($exceptionRaised);
+ $this->assertInstanceOf(\InvalidArgumentException::class, $exceptionRaised);
+
+ //Set file ID
+ $this->manager->save(new CustomLayoutSelected($pageId, 'select2'));
+
+ //Test handles
+ $this->assertEquals(['selectable' => 'page100_select2'], $this->manager->fetchHandle($pageId));
+
+ //Removing custom file
+ $this->manager->deleteFor($pageId);
+
+ //Test handles
+ $this->assertNull($this->manager->fetchHandle($pageId));
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
deleted file mode 100644
index cd4674f95d722..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
+++ /dev/null
@@ -1,98 +0,0 @@
-repo = Bootstrap::getObjectManager()->create(PageRepositoryInterface::class);
- $this->auth = Bootstrap::getObjectManager()->get(Auth::class);
- $this->criteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
- $this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
- }
-
- /**
- * @inheritDoc
- */
- protected function tearDown()
- {
- parent::tearDown();
-
- $this->auth->logout();
- }
-
- /**
- * Test authorization when saving page's design settings.
- *
- * @magentoDataFixture Magento/Cms/_files/pages.php
- * @magentoAppArea adminhtml
- * @magentoDbIsolation enabled
- * @magentoAppIsolation enabled
- */
- public function testSaveDesign()
- {
- $pages = $this->repo->getList(
- $this->criteriaBuilder->addFilter('identifier', 'page_design_blank')->create()
- )->getItems();
- $page = array_pop($pages);
- $this->auth->login(TestBootstrap::ADMIN_NAME, TestBootstrap::ADMIN_PASSWORD);
-
- //Admin doesn't have access to page's design.
- $this->aclBuilder->getAcl()->deny(null, 'Magento_Cms::save_design');
-
- $page->setCustomTheme('test');
- $page = $this->repo->save($page);
- $this->assertNotEquals('test', $page->getCustomTheme());
-
- //Admin has access to page' design.
- $this->aclBuilder->getAcl()->allow(null, ['Magento_Cms::save', 'Magento_Cms::save_design']);
-
- $page->setCustomTheme('test');
- $page = $this->repo->save($page);
- $this->assertEquals('test', $page->getCustomTheme());
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role.php b/dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role.php
new file mode 100644
index 0000000000000..867832df20240
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role.php
@@ -0,0 +1,40 @@
+get(RoleFactory::class)->create();
+$role->setName('test_custom_role');
+$role->setData('role_name', $role->getName());
+$role->setRoleType(\Magento\Authorization\Model\Acl\Role\Group::ROLE_TYPE);
+$role->setUserType((string)\Magento\Authorization\Model\UserContextInterface::USER_TYPE_ADMIN);
+$role->save();
+/** @var Rules $rules */
+$rules = Bootstrap::getObjectManager()->get(RulesFactory::class)->create();
+$rules->setRoleId($role->getId());
+//Granted all permissions.
+$rules->setResources([Bootstrap::getObjectManager()->get(\Magento\Framework\Acl\RootResource::class)->getId()]);
+$rules->saveRel();
+
+/** @var User $user */
+$user = Bootstrap::getObjectManager()->create(User::class);
+$user->setFirstname("John")
+ ->setLastname("Doe")
+ ->setUsername('customRoleUser')
+ ->setPassword(\Magento\TestFramework\Bootstrap::ADMIN_PASSWORD)
+ ->setEmail('adminUser@example.com')
+ ->setIsActive(1)
+ ->setRoleId($role->getId());
+$user->save();
diff --git a/dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role_rollback.php b/dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role_rollback.php
new file mode 100644
index 0000000000000..f3c061236a1c3
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/User/_files/user_with_custom_role_rollback.php
@@ -0,0 +1,28 @@
+create(User::class);
+$user->load('customRoleUser', 'username');
+$user->delete();
+/** @var Role $role */
+$role = Bootstrap::getObjectManager()->get(RoleFactory::class)->create();
+$role->load('test_custom_role', 'role_name');
+/** @var Rules $rules */
+$rules = Bootstrap::getObjectManager()->get(RulesFactory::class)->create();
+$rules->load($role->getId(), 'role_id');
+$rules->delete();
+$role->delete();
From 13766411fd92f97cd2e0c4ebaaf3af16bda29985 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 14 Aug 2019 12:43:58 -0500
Subject: [PATCH 0065/1978] MC-18685: Remove custom layout updates from admin
---
.../Adminhtml/Page/PostDataProcessor.php | 3 +-
.../Page/CustomLayout/CustomLayoutManager.php | 3 +-
app/code/Magento/Cms/Model/PageRepository.php | 2 +-
.../Cms/Observer/PageValidatorObserver.php | 1 +
.../Test/Unit/Model/PageRepositoryTest.php | 268 ------------------
app/code/Magento/Cms/etc/webapi.xml | 4 +-
.../Magento/Webapi/Model/Config/Converter.php | 17 +-
.../Magento/Webapi/Model/ServiceMetadata.php | 5 +-
app/code/Magento/Webapi/Model/Soap/Config.php | 2 +-
app/code/Magento/Webapi/etc/webapi_base.xsd | 1 -
.../Magento/Cms/Api/PageRepositoryTest.php | 5 +-
11 files changed, 15 insertions(+), 296 deletions(-)
delete mode 100644 app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
index 20c33a2927101..c46bcb8f247aa 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
@@ -12,8 +12,7 @@
use Magento\Framework\Config\Dom\ValidationSchemaException;
/**
- * Class PostDataProcessor
- * @package Magento\Cms\Controller\Adminhtml\Page
+ * Controller helper for user input.
*/
class PostDataProcessor
{
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
index 8d8dbe06a6078..ae9bda5d04f69 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
@@ -164,8 +164,7 @@ public function fetchAvailableFiles(int $pageId): array
return array_filter(
array_map(
- function (File $file) use ($identifier) : ?string
- {
+ function (File $file) use ($identifier) : ?string {
preg_match(
'/selectable\_' .preg_quote($identifier) .'\_([a-z0-9]+)/i',
$file->getName(),
diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php
index 2fc16e871cce7..09de8c7c086f6 100644
--- a/app/code/Magento/Cms/Model/PageRepository.php
+++ b/app/code/Magento/Cms/Model/PageRepository.php
@@ -273,7 +273,7 @@ private function getCollectionProcessor()
{
if (!$this->collectionProcessor) {
$this->collectionProcessor = \Magento\Framework\App\ObjectManager::getInstance()->get(
- 'Magento\Cms\Model\Api\SearchCriteria\PageCollectionProcessor'
+ \Magento\Cms\Model\Api\SearchCriteria\PageCollectionProcessor::class
);
}
return $this->collectionProcessor;
diff --git a/app/code/Magento/Cms/Observer/PageValidatorObserver.php b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
index af0d30f450432..3c87c505cde60 100644
--- a/app/code/Magento/Cms/Observer/PageValidatorObserver.php
+++ b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
@@ -34,6 +34,7 @@ public function __construct(SaveManager $saveManager)
/**
* @inheritDoc
+ *
* @throws LocalizedException
*/
public function execute(Observer $observer)
diff --git a/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php b/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php
deleted file mode 100644
index 61001794e2a0b..0000000000000
--- a/app/code/Magento/Cms/Test/Unit/Model/PageRepositoryTest.php
+++ /dev/null
@@ -1,268 +0,0 @@
-pageResource = $this->getMockBuilder(\Magento\Cms\Model\ResourceModel\Page::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->dataObjectProcessor = $this->getMockBuilder(\Magento\Framework\Reflection\DataObjectProcessor::class)
- ->disableOriginalConstructor()
- ->getMock();
- $pageFactory = $this->getMockBuilder(\Magento\Cms\Model\PageFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $pageDataFactory = $this->getMockBuilder(\Magento\Cms\Api\Data\PageInterfaceFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $pageSearchResultFactory = $this->getMockBuilder(\Magento\Cms\Api\Data\PageSearchResultsInterfaceFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $collectionFactory = $this->getMockBuilder(\Magento\Cms\Model\ResourceModel\Page\CollectionFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $store->expects($this->any())->method('getId')->willReturn(0);
- $this->storeManager->expects($this->any())->method('getStore')->willReturn($store);
-
- $this->page = $this->getMockBuilder(\Magento\Cms\Model\Page::class)->disableOriginalConstructor()->getMock();
- $this->pageData = $this->getMockBuilder(\Magento\Cms\Api\Data\PageInterface::class)
- ->getMock();
- $this->pageSearchResult = $this->getMockBuilder(\Magento\Cms\Api\Data\PageSearchResultsInterface::class)
- ->getMock();
- $this->collection = $this->getMockBuilder(\Magento\Cms\Model\ResourceModel\Page\Collection::class)
- ->disableOriginalConstructor()
- ->setMethods(['getSize', 'setCurPage', 'setPageSize', 'load', 'addOrder'])
- ->getMock();
-
- $pageFactory->expects($this->any())
- ->method('create')
- ->willReturn($this->page);
- $pageDataFactory->expects($this->any())
- ->method('create')
- ->willReturn($this->pageData);
- $pageSearchResultFactory->expects($this->any())
- ->method('create')
- ->willReturn($this->pageSearchResult);
- $collectionFactory->expects($this->any())
- ->method('create')
- ->willReturn($this->collection);
- /**
- * @var \Magento\Cms\Model\PageFactory $pageFactory
- * @var \Magento\Cms\Api\Data\PageInterfaceFactory $pageDataFactory
- * @var \Magento\Cms\Api\Data\PageSearchResultsInterfaceFactory $pageSearchResultFactory
- * @var \Magento\Cms\Model\ResourceModel\Page\CollectionFactory $collectionFactory
- */
-
- $this->dataHelper = $this->getMockBuilder(\Magento\Framework\Api\DataObjectHelper::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->collectionProcessor = $this->getMockBuilder(CollectionProcessorInterface::class)
- ->getMockForAbstractClass();
-
- $this->repository = new PageRepository(
- $this->pageResource,
- $pageFactory,
- $pageDataFactory,
- $collectionFactory,
- $pageSearchResultFactory,
- $this->dataHelper,
- $this->dataObjectProcessor,
- $this->storeManager,
- $this->collectionProcessor
- );
- }
-
- /**
- * @test
- */
- public function testSave()
- {
- $this->pageResource->expects($this->once())
- ->method('save')
- ->with($this->page)
- ->willReturnSelf();
- $this->assertEquals($this->page, $this->repository->save($this->page));
- }
-
- /**
- * @test
- */
- public function testDeleteById()
- {
- $pageId = '123';
-
- $this->page->expects($this->once())
- ->method('getId')
- ->willReturn(true);
- $this->page->expects($this->once())
- ->method('load')
- ->with($pageId)
- ->willReturnSelf();
- $this->pageResource->expects($this->once())
- ->method('delete')
- ->with($this->page)
- ->willReturnSelf();
-
- $this->assertTrue($this->repository->deleteById($pageId));
- }
-
- /**
- * @test
- *
- * @expectedException \Magento\Framework\Exception\CouldNotSaveException
- */
- public function testSaveException()
- {
- $this->pageResource->expects($this->once())
- ->method('save')
- ->with($this->page)
- ->willThrowException(new \Exception());
- $this->repository->save($this->page);
- }
-
- /**
- * @test
- *
- * @expectedException \Magento\Framework\Exception\CouldNotDeleteException
- */
- public function testDeleteException()
- {
- $this->pageResource->expects($this->once())
- ->method('delete')
- ->with($this->page)
- ->willThrowException(new \Exception());
- $this->repository->delete($this->page);
- }
-
- /**
- * @test
- *
- * @expectedException \Magento\Framework\Exception\NoSuchEntityException
- */
- public function testGetByIdException()
- {
- $pageId = '123';
-
- $this->page->expects($this->once())
- ->method('getId')
- ->willReturn(false);
- $this->page->expects($this->once())
- ->method('load')
- ->with($pageId)
- ->willReturnSelf();
- $this->repository->getById($pageId);
- }
-
- /**
- * @test
- */
- public function testGetList()
- {
- $total = 10;
-
- /** @var \Magento\Framework\Api\SearchCriteriaInterface $criteria */
- $criteria = $this->getMockBuilder(\Magento\Framework\Api\SearchCriteriaInterface::class)->getMock();
-
- $this->collection->addItem($this->page);
- $this->collection->expects($this->once())
- ->method('getSize')
- ->willReturn($total);
-
- $this->collectionProcessor->expects($this->once())
- ->method('process')
- ->with($criteria, $this->collection)
- ->willReturnSelf();
-
- $this->pageSearchResult->expects($this->once())
- ->method('setSearchCriteria')
- ->with($criteria)
- ->willReturnSelf();
- $this->pageSearchResult->expects($this->once())
- ->method('setTotalCount')
- ->with($total)
- ->willReturnSelf();
- $this->pageSearchResult->expects($this->once())
- ->method('setItems')
- ->with([$this->page])
- ->willReturnSelf();
- $this->assertEquals($this->pageSearchResult, $this->repository->getList($criteria));
- }
-}
diff --git a/app/code/Magento/Cms/etc/webapi.xml b/app/code/Magento/Cms/etc/webapi.xml
index 8cf0cb767d9be..5b66d0e3ed879 100644
--- a/app/code/Magento/Cms/etc/webapi.xml
+++ b/app/code/Magento/Cms/etc/webapi.xml
@@ -20,8 +20,8 @@
-
-
+
+
diff --git a/app/code/Magento/Webapi/Model/Config/Converter.php b/app/code/Magento/Webapi/Model/Config/Converter.php
index 3ce79a83b176b..837a0f84423ad 100644
--- a/app/code/Magento/Webapi/Model/Config/Converter.php
+++ b/app/code/Magento/Webapi/Model/Config/Converter.php
@@ -50,22 +50,16 @@ public function convert($source)
$service = $route->getElementsByTagName('service')->item(0);
$serviceClass = $service->attributes->getNamedItem('class')->nodeValue;
$serviceMethod = $service->attributes->getNamedItem('method')->nodeValue;
- //WSDL method name which may differ from an actual method used.
$soapMethod = $serviceMethod;
if ($soapOperationNode = $route->attributes->getNamedItem('soapOperation')) {
$soapMethod = trim($soapOperationNode->nodeValue);
}
- //WSDL class name which may differ from an actual class used.
- $soapService = $serviceClass;
- if ($soapServiceNode = $route->attributes->getNamedItem('soapService')) {
- $soapService = trim($soapServiceNode->nodeValue);
- }
$url = trim($route->attributes->getNamedItem('url')->nodeValue);
$version = $this->convertVersion($url);
$serviceClassData = [];
- if (isset($result[self::KEY_SERVICES][$soapService][$version])) {
- $serviceClassData = $result[self::KEY_SERVICES][$soapService][$version];
+ if (isset($result[self::KEY_SERVICES][$serviceClass][$version])) {
+ $serviceClassData = $result[self::KEY_SERVICES][$serviceClass][$version];
}
$resources = $route->getElementsByTagName('resource');
@@ -116,18 +110,13 @@ public function convert($source)
if (isset($serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_SECURE])) {
$serviceSecure = $serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_SECURE];
}
- //Real method to use when performing operations.
if (!isset($serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_REAL_SERVICE_METHOD])) {
$serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_REAL_SERVICE_METHOD] = $serviceMethod;
}
- //Real class to initialize when performing operations.
- if (!isset($serviceClassData[self::KEY_METHODS][$soapMethod]['real_class'])) {
- $serviceClassData[self::KEY_METHODS][$soapMethod]['real_class'] = $serviceClass;
- }
$serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_SECURE] = $serviceSecure || $secure;
$serviceClassData[self::KEY_METHODS][$soapMethod][self::KEY_DATA_PARAMETERS] = $serviceData;
- $result[self::KEY_SERVICES][$soapService][$version] = $serviceClassData;
+ $result[self::KEY_SERVICES][$serviceClass][$version] = $serviceClassData;
}
return $result;
}
diff --git a/app/code/Magento/Webapi/Model/ServiceMetadata.php b/app/code/Magento/Webapi/Model/ServiceMetadata.php
index d2bd08267128a..36f5819b03c98 100644
--- a/app/code/Magento/Webapi/Model/ServiceMetadata.php
+++ b/app/code/Magento/Webapi/Model/ServiceMetadata.php
@@ -118,15 +118,12 @@ protected function initServicesMetadata()
$methods = [];
foreach ($serviceData[Converter::KEY_METHODS] as $methodName => $methodMetadata) {
$services[$serviceName][self::KEY_SERVICE_METHODS][$methodName] = [
- //Method to use for the operation. May differ from the operation's name.
self::KEY_METHOD => $methodMetadata[Converter::KEY_REAL_SERVICE_METHOD],
self::KEY_IS_REQUIRED => (bool)$methodMetadata[Converter::KEY_SECURE],
self::KEY_IS_SECURE => $methodMetadata[Converter::KEY_SECURE],
self::KEY_ACL_RESOURCES => $methodMetadata[Converter::KEY_ACL_RESOURCES],
self::KEY_METHOD_ALIAS => $methodName,
- self::KEY_ROUTE_PARAMS => $methodMetadata[Converter::KEY_DATA_PARAMETERS],
- //Class to initialize for the operation. May differ from the operation's name.
- 'real_class' => $methodMetadata['real_class']
+ self::KEY_ROUTE_PARAMS => $methodMetadata[Converter::KEY_DATA_PARAMETERS]
];
$services[$serviceName][self::KEY_CLASS] = $serviceClass;
$methods[] = $methodMetadata[Converter::KEY_REAL_SERVICE_METHOD];
diff --git a/app/code/Magento/Webapi/Model/Soap/Config.php b/app/code/Magento/Webapi/Model/Soap/Config.php
index 94b3dad48b1ce..190280ff8f004 100644
--- a/app/code/Magento/Webapi/Model/Soap/Config.php
+++ b/app/code/Magento/Webapi/Model/Soap/Config.php
@@ -74,7 +74,7 @@ protected function getSoapOperations($requestedServices)
foreach ($this->getRequestedSoapServices($requestedServices) as $serviceName => $serviceData) {
foreach ($serviceData[ServiceMetadata::KEY_SERVICE_METHODS] as $methodData) {
$method = $methodData[ServiceMetadata::KEY_METHOD];
- $class = $methodData['real_class'];
+ $class = $serviceData[ServiceMetadata::KEY_CLASS];
$operation = $methodData[ServiceMetadata::KEY_METHOD_ALIAS];
$operationName = $serviceName . ucfirst($operation);
$this->soapOperations[$operationName] = [
diff --git a/app/code/Magento/Webapi/etc/webapi_base.xsd b/app/code/Magento/Webapi/etc/webapi_base.xsd
index b38efae2a3435..7d1a5a14ba78f 100644
--- a/app/code/Magento/Webapi/etc/webapi_base.xsd
+++ b/app/code/Magento/Webapi/etc/webapi_base.xsd
@@ -30,7 +30,6 @@
-
diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
index 3470c507c4e5b..7456846cb2d2d 100644
--- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
@@ -422,7 +422,10 @@ public function testSaveDesign(): void
$rules->setResources(['Magento_Cms::page']);
$rules->saveRel();
//Using the admin user with custom role.
- $token = $this->adminTokens->createAdminAccessToken('customRoleUser', \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
+ $token = $this->adminTokens->createAdminAccessToken(
+ 'customRoleUser',
+ \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
+ );
$id = 'test-cms-page';
$serviceInfo = [
From c235efb4e13e983ccacb36f95183595b8f09fcee Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 14 Aug 2019 13:17:30 -0500
Subject: [PATCH 0066/1978] MC-18685: Remove custom layout updates from admin
---
.../{SaveManager.php => Authorization.php} | 25 +++-------
app/code/Magento/Cms/Model/PageRepository.php | 40 ----------------
.../Magento/Cms/Observer/PageAclPlugin.php | 47 +++++++++++++++++++
.../Cms/Observer/PageValidatorObserver.php | 14 +++---
app/code/Magento/Cms/etc/webapi_rest/di.xml | 12 +++++
app/code/Magento/Cms/etc/webapi_soap/di.xml | 12 +++++
6 files changed, 84 insertions(+), 66 deletions(-)
rename app/code/Magento/Cms/Controller/Page/{SaveManager.php => Authorization.php} (79%)
create mode 100644 app/code/Magento/Cms/Observer/PageAclPlugin.php
create mode 100644 app/code/Magento/Cms/etc/webapi_rest/di.xml
create mode 100644 app/code/Magento/Cms/etc/webapi_soap/di.xml
diff --git a/app/code/Magento/Cms/Controller/Page/SaveManager.php b/app/code/Magento/Cms/Controller/Page/Authorization.php
similarity index 79%
rename from app/code/Magento/Cms/Controller/Page/SaveManager.php
rename to app/code/Magento/Cms/Controller/Page/Authorization.php
index bbd80b72a049d..f223a5c4d164c 100644
--- a/app/code/Magento/Cms/Controller/Page/SaveManager.php
+++ b/app/code/Magento/Cms/Controller/Page/Authorization.php
@@ -15,9 +15,9 @@
use Magento\Framework\Exception\LocalizedException;
/**
- * Manages CMS pages modification initiated by users.
+ * Authorization for saving a page.
*/
-class SaveManager
+class Authorization
{
/**
* @var PageRepositoryInterface
@@ -42,27 +42,14 @@ public function __construct(
}
/**
- * User saves a page (bew or existing).
- *
- * @param \Magento\Cms\Api\Data\PageInterface $page
- * @return \Magento\Cms\Api\Data\PageInterface
- * @throws LocalizedException
- */
- public function save(\Magento\Cms\Api\Data\PageInterface $page): \Magento\Cms\Api\Data\PageInterface
- {
- $this->validatePage($page);
-
- return $this->pageRepository->save($page);
- }
-
- /**
- * Validate page data received from a user.
+ * Authorize user before updating a page.
*
* @param PageInterface $page
* @return void
- * @throws LocalizedException When validation failed.
+ * @throws AuthorizationException
+ * @throws LocalizedException When it is impossible to perform authorization for given page.
*/
- public function validatePage(\Magento\Cms\Api\Data\PageInterface $page): void
+ public function authorizeFor(PageInterface $page): void
{
//Validate design changes.
if (!$this->authorization->isAllowed('Magento_Cms::save_design')) {
diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php
index 09de8c7c086f6..4492ea55da3a2 100644
--- a/app/code/Magento/Cms/Model/PageRepository.php
+++ b/app/code/Magento/Cms/Model/PageRepository.php
@@ -19,8 +19,6 @@
use Magento\Cms\Model\ResourceModel\Page as ResourcePage;
use Magento\Cms\Model\ResourceModel\Page\CollectionFactory as PageCollectionFactory;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Framework\AuthorizationInterface;
-use Magento\Authorization\Model\UserContextInterface;
/**
* Class PageRepository
@@ -73,16 +71,6 @@ class PageRepository implements PageRepositoryInterface
*/
private $collectionProcessor;
- /**
- * @var UserContextInterface
- */
- private $userContext;
-
- /**
- * @var AuthorizationInterface
- */
- private $authorization;
-
/**
* @var IdentityMap
*/
@@ -125,34 +113,6 @@ public function __construct(
$this->identityMap = $identityMap ?? ObjectManager::getInstance()->get(IdentityMap::class);
}
- /**
- * Get user context.
- *
- * @return UserContextInterface
- */
- private function getUserContext(): UserContextInterface
- {
- if (!$this->userContext) {
- $this->userContext = ObjectManager::getInstance()->get(UserContextInterface::class);
- }
-
- return $this->userContext;
- }
-
- /**
- * Get authorization service.
- *
- * @return AuthorizationInterface
- */
- private function getAuthorization(): AuthorizationInterface
- {
- if (!$this->authorization) {
- $this->authorization = ObjectManager::getInstance()->get(AuthorizationInterface::class);
- }
-
- return $this->authorization;
- }
-
/**
* Save Page data
*
diff --git a/app/code/Magento/Cms/Observer/PageAclPlugin.php b/app/code/Magento/Cms/Observer/PageAclPlugin.php
new file mode 100644
index 0000000000000..c8dc98f6f2807
--- /dev/null
+++ b/app/code/Magento/Cms/Observer/PageAclPlugin.php
@@ -0,0 +1,47 @@
+authorization = $authorization;
+ }
+
+ /**
+ * Authorize saving before it is executed.
+ *
+ * @param PageRepositoryInterface $subject
+ * @param PageInterface $page
+ * @return array
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ public function beforeSave(PageRepositoryInterface $subject, PageInterface $page): array
+ {
+ $this->authorization->authorizeFor($page);
+
+ return [$page];
+ }
+}
diff --git a/app/code/Magento/Cms/Observer/PageValidatorObserver.php b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
index 3c87c505cde60..d245e9a519f1f 100644
--- a/app/code/Magento/Cms/Observer/PageValidatorObserver.php
+++ b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
@@ -9,7 +9,7 @@
namespace Magento\Cms\Observer;
use Magento\Cms\Api\Data\PageInterface;
-use Magento\Cms\Controller\Page\SaveManager;
+use Magento\Cms\Controller\Page\Authorization;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;
@@ -20,16 +20,16 @@
class PageValidatorObserver implements ObserverInterface
{
/**
- * @var SaveManager
+ * @var Authorization
*/
- private $saveManager;
+ private $authorization;
/**
- * @param SaveManager $saveManager
+ * @param Authorization $authorization
*/
- public function __construct(SaveManager $saveManager)
+ public function __construct(Authorization $authorization)
{
- $this->saveManager = $saveManager;
+ $this->authorization = $authorization;
}
/**
@@ -41,6 +41,6 @@ public function execute(Observer $observer)
{
/** @var PageInterface $page */
$page = $observer->getEvent()->getData('page');
- $this->saveManager->validatePage($page);
+ $this->authorization->authorizeFor($page);
}
}
diff --git a/app/code/Magento/Cms/etc/webapi_rest/di.xml b/app/code/Magento/Cms/etc/webapi_rest/di.xml
new file mode 100644
index 0000000000000..686305f2ed300
--- /dev/null
+++ b/app/code/Magento/Cms/etc/webapi_rest/di.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/etc/webapi_soap/di.xml b/app/code/Magento/Cms/etc/webapi_soap/di.xml
new file mode 100644
index 0000000000000..686305f2ed300
--- /dev/null
+++ b/app/code/Magento/Cms/etc/webapi_soap/di.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
From f73e7a464461c0705423760c885728165eeafae6 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 15 Aug 2019 12:13:36 -0500
Subject: [PATCH 0067/1978] MC-18685: Remove custom layout updates from admin
---
.../Adminhtml/Product/Authorization.php | 88 +++++++++++
.../Controller/Adminhtml/Product/Builder.php | 3 +
.../Product/Initialization/Helper.php | 15 +-
app/code/Magento/Catalog/Model/Product.php | 56 -------
.../Catalog/Plugin/ProductAuthorization.php | 49 ++++++
.../Magento/Catalog/etc/webapi_rest/di.xml | 3 +
.../Magento/Catalog/etc/webapi_soap/di.xml | 3 +
.../Api/ProductRepositoryInterfaceTest.php | 141 +++++++++++++++++-
.../Magento/Cms/Api/PageRepositoryTest.php | 1 -
.../Controller/Adminhtml/ProductTest.php | 99 +++++++++++-
10 files changed, 390 insertions(+), 68 deletions(-)
create mode 100644 app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
create mode 100644 app/code/Magento/Catalog/Plugin/ProductAuthorization.php
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
new file mode 100644
index 0000000000000..d49c499930022
--- /dev/null
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
@@ -0,0 +1,88 @@
+authorization = $authorization;
+ $this->productFactory = $factory;
+ }
+
+ /**
+ * Authorize saving of a product.
+ *
+ * @throws AuthorizationException
+ * @throws NoSuchEntityException When product with invalid ID given.
+ * @param ProductInterface|Product $product
+ * @return void
+ */
+ public function authorizeSavingOf(ProductInterface $product): void
+ {
+ if (!$this->authorization->isAllowed('Magento_Catalog::edit_product_design')) {
+ $notAllowed = false;
+ if (!$product->getId()) {
+ if ($product->getData('custom_design')
+ || $product->getData('page_layout')
+ || $product->getData('options_container')
+ || $product->getData('custom_layout_update')
+ || $product->getData('custom_design_from')
+ || $product->getData('custom_design_to')
+ ) {
+ $notAllowed = true;
+ }
+ } else {
+ /** @var Product $savedProduct */
+ $savedProduct = $this->productFactory->create();
+ $savedProduct->load($product->getId());
+ if ($savedProduct->getSku()) {
+ throw NoSuchEntityException::singleField('id', $product->getId());
+ }
+ if ($product->getData('custom_design') != $savedProduct->getData('custom_design')
+ || $product->getData('page_layout') != $savedProduct->getData('page_layout')
+ || $product->getData('options_container') != $savedProduct->getData('options_container')
+ || $product->getData('custom_layout_update') != $savedProduct->getData('custom_layout_update')
+ || $product->getData('custom_design_from') != $savedProduct->getData('custom_design_from')
+ || $product->getData('custom_design_to') != $savedProduct->getData('custom_design_to')
+ ) {
+ $notAllowed = true;
+ }
+ }
+
+ if ($notAllowed) {
+ throw new AuthorizationException(__('Not allowed to edit the product\'s design attributes'));
+ }
+ }
+ }
+}
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php
index 78ad9f423871f..1f959a22b1ba1 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Builder.php
@@ -115,6 +115,9 @@ public function build(RequestInterface $request): ProductInterface
$store = $this->storeFactory->create();
$store->load($storeId);
+ $this->registry->unregister('product');
+ $this->registry->unregister('current_product');
+ $this->registry->unregister('current_store');
$this->registry->register('product', $product);
$this->registry->register('current_product', $product);
$this->registry->register('current_store', $store);
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
index f11d16755ef0d..2494412326075 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
@@ -17,6 +17,7 @@
use Magento\Catalog\Model\Product\LinkTypeProvider;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
+use Magento\Catalog\Controller\Adminhtml\Product\Authorization as ProductAuthorization;
/**
* Product helper
@@ -96,6 +97,11 @@ class Helper
*/
private $attributeFilter;
+ /**
+ * @var ProductAuthorization
+ */
+ private $productAuthorization;
+
/**
* Constructor
*
@@ -123,7 +129,8 @@ public function __construct(
ProductLinkFactory $productLinkFactory = null,
ProductRepositoryInterface $productRepository = null,
LinkTypeProvider $linkTypeProvider = null,
- AttributeFilter $attributeFilter = null
+ AttributeFilter $attributeFilter = null,
+ ?ProductAuthorization $productAuthorization = null
) {
$this->request = $request;
$this->storeManager = $storeManager;
@@ -138,6 +145,7 @@ public function __construct(
$this->productRepository = $productRepository ?: $objectManager->get(ProductRepositoryInterface::class);
$this->linkTypeProvider = $linkTypeProvider ?: $objectManager->get(LinkTypeProvider::class);
$this->attributeFilter = $attributeFilter ?: $objectManager->get(AttributeFilter::class);
+ $this->productAuthorization = $productAuthorization ?? $objectManager->get(ProductAuthorization::class);
}
/**
@@ -228,7 +236,10 @@ public function initializeFromData(\Magento\Catalog\Model\Product $product, arra
public function initialize(\Magento\Catalog\Model\Product $product)
{
$productData = $this->request->getPost('product', []);
- return $this->initializeFromData($product, $productData);
+ $product = $this->initializeFromData($product, $productData);
+ $this->productAuthorization->authorizeSavingOf($product);
+
+ return $product;
}
/**
diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php
index fc9fffb2a7e9a..93f5da70d40ea 100644
--- a/app/code/Magento/Catalog/Model/Product.php
+++ b/app/code/Magento/Catalog/Model/Product.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Catalog\Model;
-use Magento\Authorization\Model\UserContextInterface;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Api\Data\ProductAttributeMediaGalleryEntryInterface;
use Magento\Catalog\Api\Data\ProductInterface;
@@ -15,7 +14,6 @@
use Magento\Framework\Api\AttributeValueFactory;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\AuthorizationInterface;
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Pricing\SaleableInterface;
@@ -355,16 +353,6 @@ class Product extends \Magento\Catalog\Model\AbstractModel implements
*/
private $filterCustomAttribute;
- /**
- * @var UserContextInterface
- */
- private $userContext;
-
- /**
- * @var AuthorizationInterface
- */
- private $authorization;
-
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
@@ -872,34 +860,6 @@ public function getAttributes($groupId = null, $skipSuper = false)
return $attributes;
}
- /**
- * Get user context.
- *
- * @return UserContextInterface
- */
- private function getUserContext(): UserContextInterface
- {
- if (!$this->userContext) {
- $this->userContext = ObjectManager::getInstance()->get(UserContextInterface::class);
- }
-
- return $this->userContext;
- }
-
- /**
- * Get authorization service.
- *
- * @return AuthorizationInterface
- */
- private function getAuthorization(): AuthorizationInterface
- {
- if (!$this->authorization) {
- $this->authorization = ObjectManager::getInstance()->get(AuthorizationInterface::class);
- }
-
- return $this->authorization;
- }
-
/**
* Check product options and type options and save them, too
*
@@ -917,22 +877,6 @@ public function beforeSave()
$this->getTypeInstance()->beforeSave($this);
- //Validate changing of design.
- $userType = $this->getUserContext()->getUserType();
- if ((
- $userType === UserContextInterface::USER_TYPE_ADMIN
- || $userType === UserContextInterface::USER_TYPE_INTEGRATION
- )
- && !$this->getAuthorization()->isAllowed('Magento_Catalog::edit_product_design')
- ) {
- $this->setData('custom_design', $this->getOrigData('custom_design'));
- $this->setData('page_layout', $this->getOrigData('page_layout'));
- $this->setData('options_container', $this->getOrigData('options_container'));
- $this->setData('custom_layout_update', $this->getOrigData('custom_layout_update'));
- $this->setData('custom_design_from', $this->getOrigData('custom_design_from'));
- $this->setData('custom_design_to', $this->getOrigData('custom_design_to'));
- }
-
$hasOptions = false;
$hasRequiredOptions = false;
diff --git a/app/code/Magento/Catalog/Plugin/ProductAuthorization.php b/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
new file mode 100644
index 0000000000000..2de7c1d5bc681
--- /dev/null
+++ b/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
@@ -0,0 +1,49 @@
+authorization = $authorization;
+ }
+
+ /**
+ * Authorize saving of a product.
+ *
+ * @param ProductRepositoryInterface $subject
+ * @param ProductInterface $product
+ * @param bool $saveOptions
+ * @throws LocalizedException
+ * @return array
+ */
+ public function beforeSave(ProductRepositoryInterface $subject, ProductInterface $product, $saveOptions): array
+ {
+ $this->authorization->authorizeSavingOf($product);
+
+ return [$product, $saveOptions];
+ }
+}
diff --git a/app/code/Magento/Catalog/etc/webapi_rest/di.xml b/app/code/Magento/Catalog/etc/webapi_rest/di.xml
index 44cdd473bf74e..4a7d2c7481576 100644
--- a/app/code/Magento/Catalog/etc/webapi_rest/di.xml
+++ b/app/code/Magento/Catalog/etc/webapi_rest/di.xml
@@ -22,4 +22,7 @@
+
+
+
diff --git a/app/code/Magento/Catalog/etc/webapi_soap/di.xml b/app/code/Magento/Catalog/etc/webapi_soap/di.xml
index 44cdd473bf74e..4a7d2c7481576 100644
--- a/app/code/Magento/Catalog/etc/webapi_soap/di.xml
+++ b/app/code/Magento/Catalog/etc/webapi_soap/di.xml
@@ -22,4 +22,7 @@
+
+
+
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
index 3e935e1d7ae9b..58ad18dcaf29c 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
@@ -7,9 +7,14 @@
namespace Magento\Catalog\Api;
+use Magento\Authorization\Model\Role;
+use Magento\Authorization\Model\Rules;
+use Magento\Authorization\Model\RoleFactory;
+use Magento\Authorization\Model\RulesFactory;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\CatalogInventory\Api\Data\StockItemInterface;
use Magento\Downloadable\Model\Link;
+use Magento\Integration\Api\AdminTokenServiceInterface;
use Magento\Store\Model\Store;
use Magento\Store\Model\Website;
use Magento\Store\Model\WebsiteRepository;
@@ -55,6 +60,33 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract
],
];
+ /**
+ * @var RoleFactory
+ */
+ private $roleFactory;
+
+ /**
+ * @var RulesFactory
+ */
+ private $rulesFactory;
+
+ /**
+ * @var AdminTokenServiceInterface
+ */
+ private $adminTokens;
+
+ /**
+ * @inheritDoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->roleFactory = Bootstrap::getObjectManager()->get(RoleFactory::class);
+ $this->rulesFactory = Bootstrap::getObjectManager()->get(RulesFactory::class);
+ $this->adminTokens = Bootstrap::getObjectManager()->get(AdminTokenServiceInterface::class);
+ }
+
/**
* @magentoApiDataFixture Magento/Catalog/_files/products_related.php
*/
@@ -726,9 +758,10 @@ public function testUpdateWithExtensionAttributes(): void
/**
* @param array $product
+ * @param string|null $token
* @return array|bool|float|int|string
*/
- protected function updateProduct($product)
+ protected function updateProduct($product, ?string $token = null)
{
if (isset($product['custom_attributes'])) {
for ($i=0; $i self::SERVICE_NAME . 'Save',
],
];
+ if ($token) {
+ $serviceInfo['rest']['token'] = $serviceInfo['soap']['token'] = $token;
+ }
$requestData = ['product' => $product];
$response = $this->_webApiCall($serviceInfo, $requestData);
return $response;
@@ -1135,7 +1171,6 @@ protected function getSimpleProductData($productData = [])
ProductInterface::TYPE_ID => 'simple',
ProductInterface::PRICE => 3.62,
ProductInterface::STATUS => 1,
- ProductInterface::TYPE_ID => 'simple',
ProductInterface::ATTRIBUTE_SET_ID => 4,
'custom_attributes' => [
['attribute_code' => 'cost', 'value' => ''],
@@ -1147,9 +1182,10 @@ protected function getSimpleProductData($productData = [])
/**
* @param $product
* @param string|null $storeCode
+ * @param string|null $token
* @return mixed
*/
- protected function saveProduct($product, $storeCode = null)
+ protected function saveProduct($product, $storeCode = null, ?string $token = null)
{
if (isset($product['custom_attributes'])) {
for ($i=0; $i self::SERVICE_NAME . 'Save',
],
];
+ if ($token) {
+ $serviceInfo['rest']['token'] = $serviceInfo['soap']['token'] = $token;
+ }
$requestData = ['product' => $product];
return $this->_webApiCall($serviceInfo, $requestData, null, $storeCode);
}
@@ -1582,4 +1621,100 @@ private function assertMultiselectValue($productSku, $multiselectAttributeCode,
}
$this->assertEquals($expectedMultiselectValue, $multiselectValue);
}
+
+ /**
+ * Test design settings authorization
+ *
+ * @magentoApiDataFixture Magento/User/_files/user_with_custom_role.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ //Updating our admin user's role to allow saving products but not their design settings.
+ /** @var Role $role */
+ $role = $this->roleFactory->create();
+ $role->load('test_custom_role', 'role_name');
+ /** @var Rules $rules */
+ $rules = $this->rulesFactory->create();
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Catalog::products']);
+ $rules->saveRel();
+ //Using the admin user with custom role.
+ $token = $this->adminTokens->createAdminAccessToken(
+ 'customRoleUser',
+ \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
+ );
+
+ $productData = $this->getSimpleProductData();
+ $productData['custom_attributes'][] = ['attribute_code' => 'custom_design', 'value' => '1'];
+
+ //Creating new product with design settings.
+ $exceptionMessage = null;
+ try {
+ $this->saveProduct($productData, null, $token);
+ } catch (\Throwable $exception) {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ $exceptionMessage = $restResponse['message'];
+ } else {
+ //SOAP
+ $exceptionMessage = $exception->getMessage();
+ }
+ }
+ //We don't have the permissions.
+ $this->assertEquals('Not allowed to edit the product\'s design attributes', $exceptionMessage);
+
+ //Updating the user role to allow access to design properties.
+ /** @var Rules $rules */
+ $rules = Bootstrap::getObjectManager()->create(Rules::class);
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Catalog::products', 'Magento_Catalog::edit_product_design']);
+ $rules->saveRel();
+ //Making the same request with design settings.
+ $result = $this->saveProduct($productData, null, $token);
+ $this->assertArrayHasKey('id', $result);
+ //Product must be saved.
+ $productSaved = $this->getProduct($productData[ProductInterface::SKU]);
+ $savedCustomDesign = null;
+ foreach ($productSaved['custom_attributes'] as $customAttribute) {
+ if ($customAttribute['attribute_code'] === 'custom_design') {
+ $savedCustomDesign = $customAttribute['value'];
+ }
+ }
+ $this->assertEquals('1', $savedCustomDesign);
+ $productData = $productSaved;
+
+ //Updating our role to remove design properties access.
+ /** @var Rules $rules */
+ $rules = Bootstrap::getObjectManager()->create(Rules::class);
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Catalog::products']);
+ $rules->saveRel();
+ //Updating the product but with the same design properties values.
+ $result = $this->updateProduct($productData, $token);
+ //We haven't changed the design so operation is successful.
+ $this->assertArrayHasKey('id', $result);
+
+ //Changing a design property.
+ foreach ($productData['custom_attributes'] as &$customAttribute) {
+ if ($customAttribute['attribute_code'] === 'custom_design') {
+ $customAttribute['value'] = '2';
+ }
+ }
+ $exceptionMessage = null;
+ try {
+ $this->updateProduct($productData, $token);
+ } catch (\Throwable $exception) {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ $exceptionMessage = $restResponse['message'];
+ } else {
+ //SOAP
+ $exceptionMessage = $exception->getMessage();
+ }
+ }
+ //We don't have permissions to do that.
+ $this->assertEquals('Not allowed to edit the product\'s design attributes', $exceptionMessage);
+ }
}
diff --git a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
index 7456846cb2d2d..66cb91e528dff 100644
--- a/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php
@@ -490,7 +490,6 @@ public function testSaveDesign(): void
$result = $this->_webApiCall($serviceInfo, $requestData);
//We haven't changed the design so operation is successful.
$this->assertArrayHasKey('id', $result);
-
//Changing a design property.
$requestData['page'][PageInterface::CUSTOM_THEME] = 2;
$exceptionMessage = null;
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index acec996d0c406..547b282474fe6 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -5,17 +5,41 @@
*/
namespace Magento\Catalog\Controller\Adminhtml;
+use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Message\Manager;
use Magento\Framework\App\Request\Http as HttpRequest;
-use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\ProductRepository;
+use Magento\Catalog\Model\ProductRepositoryFactory;
use Magento\Framework\Message\MessageInterface;
+use Magento\TestFramework\Helper\Bootstrap;
/**
* @magentoAppArea adminhtml
*/
class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
+ /**
+ * @var Builder
+ */
+ private $aclBuilder;
+
+ /**
+ * @var ProductRepositoryFactory
+ */
+ private $repositoryFactory;
+
+ /**
+ * @inheritDoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
+ $this->repositoryFactory = Bootstrap::getObjectManager()->get(ProductRepositoryFactory::class);
+ }
+
/**
* Test calling save with invalid product's ID.
*/
@@ -39,7 +63,8 @@ public function testSaveActionWithDangerRequest()
public function testSaveActionAndNew()
{
$this->getRequest()->setPostValue(['back' => 'new']);
- $repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class);
+ /** @var ProductRepository $repository */
+ $repository = $this->repositoryFactory->create();
$product = $repository->get('simple');
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
@@ -59,7 +84,8 @@ public function testSaveActionAndNew()
public function testSaveActionAndDuplicate()
{
$this->getRequest()->setPostValue(['back' => 'duplicate']);
- $repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class);
+ /** @var ProductRepository $repository */
+ $repository = $this->repositoryFactory->create();
$product = $repository->get('simple');
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
@@ -130,7 +156,8 @@ public function testIndexAction()
*/
public function testEditAction()
{
- $repository = $this->_objectManager->create(\Magento\Catalog\Model\ProductRepository::class);
+ /** @var ProductRepository $repository */
+ $repository = $this->repositoryFactory->create();
$product = $repository->get('simple');
$this->dispatch('backend/catalog/product/edit/id/' . $product->getEntityId());
$body = $this->getResponse()->getBody();
@@ -349,10 +376,70 @@ public function saveActionTierPriceDataProvider()
*/
private function getProductData(array $tierPrice)
{
- $productRepositoryInterface = $this->_objectManager->get(ProductRepositoryInterface::class);
- $product = $productRepositoryInterface->get('tier_prices')->getData();
+ /** @var ProductRepository $repo */
+ $repo = $this->repositoryFactory->create();
+ $product = $repo->get('tier_prices')->getData();
$product['tier_price'] = $tierPrice;
unset($product['entity_id']);
return $product;
}
+
+ /**
+ * Check whether additional authorization is required for the design fields.
+ *
+ * @magentoDbIsolation enabled
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ $requestData = [
+ 'product' => [
+ 'type' => 'simple',
+ 'sku' => 'simple',
+ 'store' => '0',
+ 'set' => '4',
+ 'back' => 'edit',
+ 'product' => [],
+ 'is_downloadable' => '0',
+ 'affect_configurable_product_attributes' => '1',
+ 'new_variation_attribute_set_id' => '4',
+ 'use_default' => [
+ 'gift_message_available' => '0',
+ 'gift_wrapping_available' => '0'
+ ],
+ 'configurable_matrix_serialized' => '[]',
+ 'associated_product_ids_serialized' => '[]'
+ ]
+ ];
+ $uri = 'backend/catalog/product/save';
+
+ //Trying to update product's design settings without proper permissions.
+ //Expected list of sessions messages collected throughout the controller calls.
+ $sessionMessages = ['Not allowed to edit the product\'s design attributes'];
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_product_design');
+ $requestData['product']['custom_design'] = '1';
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->dispatch($uri);
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+
+ //Trying again with the permissions.
+ $this->aclBuilder->getAcl()->allow(null, ['Magento_Catalog::products', 'Magento_Catalog::edit_product_design']);
+ $this->getRequest()->setDispatched(false);
+ $this->dispatch($uri);
+ /** @var ProductRepository $repo */
+ $repo = $this->repositoryFactory->create();
+ $product = $repo->get('simple');
+ $this->assertNotEmpty($product->getCustomDesign());
+ $this->assertEquals(1, $product->getCustomDesign());
+ //No new error messages
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+ }
}
From a0b1277bb78db8127d4ed091e8dc9c7461e2c660 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 15 Aug 2019 15:59:20 -0500
Subject: [PATCH 0068/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Source/LayoutUpdate.php | 37 ++++++
.../Product/Attribute/Source/LayoutUpdate.php | 58 ++++++++++
.../Data/UpdateCustomLayoutAttributes.php | 105 ++++++++++++++++++
.../Product/Form/Modifier/Eav.php | 10 +-
.../Source/SpecificSourceInterface.php | 28 +++++
5 files changed, 236 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
create mode 100644 app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
create mode 100644 app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
create mode 100644 app/code/Magento/Eav/Model/Entity/Attribute/Source/SpecificSourceInterface.php
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
new file mode 100644
index 0000000000000..2030e05b74925
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -0,0 +1,37 @@
+ 'Use default', 'value' => '']];
+
+ return $options;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getOptionsFor(CustomAttributesDataInterface $entity): array
+ {
+ return $this->getAllOptions();
+ }
+}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
new file mode 100644
index 0000000000000..214348890cf2a
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -0,0 +1,58 @@
+optionsText[$default] = $defaultText;
+
+ return [['label' => $defaultText, 'value' => $default]];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getOptionText($value)
+ {
+ if (is_scalar($value) && array_key_exists($value, $this->optionsText)) {
+ return $this->optionsText[$value];
+ }
+
+ return false;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getOptionsFor(CustomAttributesDataInterface $entity): array
+ {
+ $options = $this->getAllOptions();
+
+ return $options;
+ }
+}
diff --git a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
new file mode 100644
index 0000000000000..0701d4e4b2b06
--- /dev/null
+++ b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
@@ -0,0 +1,105 @@
+moduleDataSetup = $moduleDataSetup;
+ $this->categorySetupFactory = $categorySetupFactory;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public static function getDependencies()
+ {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getAliases()
+ {
+ return [];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function apply()
+ {
+ /** @var CategorySetup $eavSetup */
+ $eavSetup = $this->categorySetupFactory->create(['setup' => $this->moduleDataSetup]);
+ $eavSetup->addAttribute(
+ Product::ENTITY,
+ 'custom_layout_update_file',
+ [
+ 'type' => 'varchar',
+ 'label' => 'Custom Layout Update',
+ 'input' => 'select',
+ 'source' => \Magento\Catalog\Model\Product\Attribute\Source\LayoutUpdate::class,
+ 'required' => false,
+ 'sort_order' => 51,
+ 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
+ 'group' => 'Design',
+ 'is_used_in_grid' => false,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false
+ ]
+ );
+
+ $eavSetup->addAttribute(
+ Category::ENTITY,
+ 'custom_layout_update_file',
+ [
+ 'type' => 'varchar',
+ 'label' => 'Custom Layout Update',
+ 'input' => 'select',
+ 'source' => \Magento\Catalog\Model\Category\Attribute\Source\LayoutUpdate::class,
+ 'required' => false,
+ 'sort_order' => 51,
+ 'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
+ 'group' => 'Custom Design',
+ 'is_used_in_grid' => false,
+ 'is_visible_in_grid' => false,
+ 'is_filterable_in_grid' => false
+ ]
+ );
+ }
+}
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
index 5d1e853cef3d1..2da985601761d 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
@@ -18,6 +18,7 @@
use Magento\Eav\Api\Data\AttributeGroupInterface;
use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory as GroupCollectionFactory;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
@@ -686,11 +687,17 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC
'sortOrder' => $sortOrder * self::SORT_ORDER_MULTIPLIER,
]
);
+ $product = $this->locator->getProduct();
// TODO: Refactor to $attribute->getOptions() when MAGETWO-48289 is done
$attributeModel = $this->getAttributeModel($attribute);
if ($attributeModel->usesSource()) {
- $options = $attributeModel->getSource()->getAllOptions(true, true);
+ $source = $attributeModel->getSource();
+ if ($source instanceof SpecificSourceInterface) {
+ $options = $source->getOptionsFor($product);
+ } else {
+ $options = $attributeModel->getSource()->getAllOptions(true, true);
+ }
foreach ($options as &$option) {
$option['__disableTmpl'] = true;
}
@@ -717,7 +724,6 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC
$meta = $this->arrayManager->merge($configPath, $meta, ['componentType' => Field::NAME]);
}
- $product = $this->locator->getProduct();
if (in_array($attributeCode, $this->attributesToDisable)
|| $product->isLockedAttribute($attributeCode)) {
$meta = $this->arrayManager->merge($configPath, $meta, ['disabled' => true]);
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/SpecificSourceInterface.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/SpecificSourceInterface.php
new file mode 100644
index 0000000000000..c6422962f6b1b
--- /dev/null
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/SpecificSourceInterface.php
@@ -0,0 +1,28 @@
+
Date: Fri, 16 Aug 2019 10:22:42 +0300
Subject: [PATCH 0069/1978] MC-17149: UI components configuration incorrect
(overlapping text labels)
---
.../Product/Form/Modifier/AdvancedPricing.php | 34 +++++++++++++++---
.../Product/Form/Modifier/Categories.php | 4 +--
.../Product/Form/Modifier/Eav.php | 4 ++-
.../Product/Form/Modifier/General.php | 5 ++-
.../Form/Modifier/ScheduleDesignUpdate.php | 9 +++--
.../Product/Form/Modifier/TierPrice.php | 2 +-
.../adminhtml/ui_component/category_form.xml | 4 +--
.../Form/Modifier/AdvancedInventory.php | 13 +++----
.../adminhtml/ui_component/product_form.xml | 16 ---------
.../Form/Modifier/ProductUrlRewrite.php | 25 +++++++------
.../view/base/ui_component/customer_form.xml | 3 +-
.../Product/Modifier/GiftMessage.php | 36 ++++++++++---------
.../backend/web/css/source/forms/_fields.less | 1 -
13 files changed, 87 insertions(+), 69 deletions(-)
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
index 9ad75b5fda923..3ea6a3cdfe656 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
@@ -149,6 +149,7 @@ public function modifyMeta(array $meta)
$this->specialPriceDataToInline();
$this->customizeTierPrice();
+ $this->customizePrice();
if (isset($this->meta['advanced-pricing'])) {
$this->addAdvancedPriceLink();
@@ -197,6 +198,29 @@ protected function preparePriceFields($fieldCode)
return $this;
}
+ /**
+ * Customize price field.
+ *
+ * @return $this
+ */
+ private function customizePrice()
+ {
+ $pathFrom = $this->arrayManager->findPath('price', $this->meta, null, 'children');
+
+ if ($pathFrom) {
+ $this->meta = $this->arrayManager->merge(
+ $this->arrayManager->slicePath($pathFrom, 0, -2) . '/arguments/data/config',
+ $this->meta,
+ [
+ 'label' => false,
+ 'required' => false,
+ ]
+ );
+ }
+
+ return $this;
+ }
+
/**
* Customize tier price field
*
@@ -573,12 +597,11 @@ private function specialPriceDataToInline()
$this->arrayManager->slicePath($pathFrom, 0, -2) . '/arguments/data/config',
$this->meta,
[
- 'label' => __('Special Price From'),
+ 'label' => false,
+ 'required' => false,
'additionalClasses' => 'admin__control-grouped-date',
'breakLine' => false,
'component' => 'Magento_Ui/js/form/components/group',
- 'scopeLabel' =>
- $this->arrayManager->get($pathFrom . '/arguments/data/config/scopeLabel', $this->meta),
]
);
$this->meta = $this->arrayManager->merge(
@@ -586,8 +609,9 @@ private function specialPriceDataToInline()
$this->meta,
[
'label' => __('Special Price From'),
- 'scopeLabel' => null,
- 'additionalClasses' => 'admin__field-date'
+ 'scopeLabel' =>
+ $this->arrayManager->get($pathFrom . '/arguments/data/config/scopeLabel', $this->meta),
+ 'additionalClasses' => 'admin__field-date',
]
);
$this->meta = $this->arrayManager->merge(
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php
index 5f1907344ce83..8c040b42c5029 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Categories.php
@@ -243,13 +243,13 @@ protected function customizeCategoriesField(array $meta)
'arguments' => [
'data' => [
'config' => [
- 'label' => __('Categories'),
+ 'label' => false,
+ 'required' => false,
'dataScope' => '',
'breakLine' => false,
'formElement' => 'container',
'componentType' => 'container',
'component' => 'Magento_Ui/js/form/components/group',
- 'scopeLabel' => __('[GLOBAL]'),
'disabled' => $this->locator->getProduct()->isLockedAttribute($fieldCode),
],
],
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
index 5d1e853cef3d1..f944b6ebde75c 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
@@ -858,7 +858,9 @@ public function setupAttributeContainerMeta(ProductAttributeInterface $attribute
'arguments/data/config',
$containerMeta,
[
- 'component' => 'Magento_Ui/js/form/components/group'
+ 'component' => 'Magento_Ui/js/form/components/group',
+ 'label' => false,
+ 'required' => false,
]
);
}
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
index 91c74a2da5048..325eb5433f4ea 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
@@ -239,6 +239,8 @@ protected function customizeWeightField(array $meta)
$containerPath . static::META_CONFIG_PATH,
$meta,
[
+ 'label' => false,
+ 'required' => false,
'component' => 'Magento_Ui/js/form/components/group',
]
);
@@ -314,7 +316,8 @@ protected function customizeNewDateRangeField(array $meta)
$fromContainerPath . self::META_CONFIG_PATH,
$meta,
[
- 'label' => __('Set Product as New From'),
+ 'label' => false,
+ 'required' => false,
'additionalClasses' => 'admin__control-grouped-date',
'breakLine' => false,
'component' => 'Magento_Ui/js/form/components/group',
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdate.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdate.php
index b2f453e8d8ccb..3b01106619640 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdate.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/ScheduleDesignUpdate.php
@@ -37,7 +37,8 @@ public function __construct(ArrayManager $arrayManager)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
+ *
* @since 101.0.0
*/
public function modifyMeta(array $meta)
@@ -47,7 +48,8 @@ public function modifyMeta(array $meta)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
+ *
* @since 101.0.0
*/
public function modifyData(array $data)
@@ -96,7 +98,8 @@ protected function customizeDateRangeField(array $meta)
$fromContainerPath . self::META_CONFIG_PATH,
$meta,
[
- 'label' => __('Schedule Update From'),
+ 'label' => false,
+ 'required' => false,
'additionalClasses' => 'admin__control-grouped-date',
'breakLine' => false,
'component' => 'Magento_Ui/js/form/components/group',
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php
index a529580e29239..9c5fffc5db9b9 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/TierPrice.php
@@ -115,7 +115,7 @@ private function getUpdatedTierPriceStructure(array $priceMeta)
'dataType' => Price::NAME,
'component' => 'Magento_Ui/js/form/components/group',
'label' => __('Price'),
- 'enableLabel' => true,
+ 'showLabel' => false,
'dataScope' => '',
'additionalClasses' => 'control-grouped',
'sortOrder' => isset($priceMeta['arguments']['data']['config']['sortOrder'])
diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml
index 6ce43132ef48a..5e761a665030a 100644
--- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml
+++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml
@@ -527,10 +527,7 @@
- group
-
- admin__control-grouped-date
- - Schedule Update From
- - false
- false
- - [STORE VIEW]
@@ -540,6 +537,7 @@
string
Schedule Update From
+ [STORE VIEW]
diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php
index 7386f133b569a..22896c5e47567 100644
--- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php
+++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php
@@ -85,7 +85,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyData(array $data)
{
@@ -163,7 +163,7 @@ private function getData(StockItemInterface $stockItem)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyMeta(array $meta)
{
@@ -175,6 +175,8 @@ public function modifyMeta(array $meta)
}
/**
+ * Modify UI Quantity and Stock status attribute meta.
+ *
* @return void
*/
private function prepareMeta()
@@ -183,10 +185,6 @@ private function prepareMeta()
$pathField = $this->arrayManager->findPath($fieldCode, $this->meta, null, 'children');
if ($pathField) {
- $labelField = $this->arrayManager->get(
- $this->arrayManager->slicePath($pathField, 0, -2) . '/arguments/data/config/label',
- $this->meta
- );
$fieldsetPath = $this->arrayManager->slicePath($pathField, 0, -4);
$this->meta = $this->arrayManager->merge(
@@ -214,10 +212,9 @@ private function prepareMeta()
'formElement' => 'container',
'componentType' => 'container',
'component' => "Magento_Ui/js/form/components/group",
- 'label' => $labelField,
+ 'label' => false,
'breakLine' => false,
'dataScope' => $fieldCode,
- 'scopeLabel' => '[GLOBAL]',
'source' => 'product_details',
'sortOrder' => (int) $this->arrayManager->get(
$this->arrayManager->slicePath($pathField, 0, -2) . '/arguments/data/config/sortOrder',
diff --git a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml
index 0a7f0fdc32d40..7e5863bd2f616 100644
--- a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml
+++ b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml
@@ -35,9 +35,7 @@
-
- container
- - Manage Stock
- stock_data
- - [GLOBAL]
@@ -112,9 +110,7 @@
-
- container
- - Out-of-Stock Threshold
- stock_data
- - [GLOBAL]
-
- ${$.provider}:data.product.stock_data.manage_stock
@@ -274,9 +270,7 @@
-
- container
- - Maximum Qty Allowed in Shopping Cart
- stock_data
- - [GLOBAL]
@@ -373,9 +367,7 @@
-
- container
- - Backorders
- stock_data
- - [GLOBAL]
-
- ${$.provider}:data.product.stock_data.manage_stock
@@ -438,9 +430,7 @@
-
- container
- - Notify for Quantity Below
- stock_data
- - [GLOBAL]
-
- ${$.provider}:data.product.stock_data.manage_stock
@@ -495,9 +485,7 @@
-
- container
- - Enable Qty Increments
- stock_data
- - [GLOBAL]
@@ -554,9 +542,7 @@
-
- container
- - Qty Increments
- stock_data
- - [GLOBAL]
-
- ${$.provider}:data.product.stock_data.enable_qty_increments
@@ -615,9 +601,7 @@
-
- container
- - Stock Status
- quantity_and_stock_status
- - [GLOBAL]
-
- ${$.provider}:data.product.stock_data.manage_stock
diff --git a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php
index bcb5154e35501..10791eae5405f 100644
--- a/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php
+++ b/app/code/Magento/CatalogUrlRewrite/Ui/DataProvider/Product/Form/Modifier/ProductUrlRewrite.php
@@ -53,7 +53,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyMeta(array $meta)
{
@@ -65,7 +65,7 @@ public function modifyMeta(array $meta)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyData(array $data)
{
@@ -95,16 +95,21 @@ protected function addUrlRewriteCheckbox(array $meta)
ScopeInterface::SCOPE_STORE,
$this->locator->getProduct()->getStoreId()
);
-
- $meta = $this->arrayManager->merge($containerPath, $meta, [
- 'arguments' => [
- 'data' => [
- 'config' => [
- 'component' => 'Magento_Ui/js/form/components/group',
+ $meta = $this->arrayManager->merge(
+ $containerPath,
+ $meta,
+ [
+ 'arguments' => [
+ 'data' => [
+ 'config' => [
+ 'component' => 'Magento_Ui/js/form/components/group',
+ 'label' => false,
+ 'required' => false,
+ ],
],
],
- ],
- ]);
+ ]
+ );
$checkbox['arguments']['data']['config'] = [
'componentType' => Field::NAME,
diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml
index 5fb8b17dbb8c5..663e28bf987cc 100644
--- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml
+++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml
@@ -152,8 +152,6 @@
- group
-
-
- Group
- - true
- false
- true
@@ -166,6 +164,7 @@
+ true
number
diff --git a/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php b/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php
index e3d617eac1cd2..fe2479d778992 100644
--- a/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php
+++ b/app/code/Magento/GiftMessage/Ui/DataProvider/Product/Modifier/GiftMessage.php
@@ -53,7 +53,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyData(array $data)
{
@@ -73,7 +73,7 @@ public function modifyData(array $data)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function modifyMeta(array $meta)
{
@@ -101,24 +101,28 @@ protected function customizeAllowGiftMessageField(array $meta)
'children'
);
$fieldPath = $this->arrayManager->findPath(static::FIELD_MESSAGE_AVAILABLE, $meta, null, 'children');
- $groupConfig = $this->arrayManager->get($containerPath, $meta);
$fieldConfig = $this->arrayManager->get($fieldPath, $meta);
- $meta = $this->arrayManager->merge($containerPath, $meta, [
- 'arguments' => [
- 'data' => [
- 'config' => [
- 'formElement' => 'container',
- 'componentType' => 'container',
- 'component' => 'Magento_Ui/js/form/components/group',
- 'label' => $groupConfig['arguments']['data']['config']['label'],
- 'breakLine' => false,
- 'sortOrder' => $fieldConfig['arguments']['data']['config']['sortOrder'],
- 'dataScope' => '',
+ $meta = $this->arrayManager->merge(
+ $containerPath,
+ $meta,
+ [
+ 'arguments' => [
+ 'data' => [
+ 'config' => [
+ 'formElement' => 'container',
+ 'componentType' => 'container',
+ 'component' => 'Magento_Ui/js/form/components/group',
+ 'label' => false,
+ 'required' => false,
+ 'breakLine' => false,
+ 'sortOrder' => $fieldConfig['arguments']['data']['config']['sortOrder'],
+ 'dataScope' => '',
+ ],
],
],
- ],
- ]);
+ ]
+ );
$meta = $this->arrayManager->merge(
$containerPath,
$meta,
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 08aeb35d7adb2..66c9086c15aa7 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
@@ -545,7 +545,6 @@
& > .admin__field-label {
#mix-grid .column(@field-label-grid__column, @field-grid__columns);
cursor: pointer;
- background: @color-white;
left: 0;
position: absolute;
top: 0;
From 8d588c0090850f54932997ea9dddb53469773ec8 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 16 Aug 2019 12:05:52 -0500
Subject: [PATCH 0070/1978] MC-18685: Remove custom layout updates from admin
---
.../Cms/Controller/Adminhtml/Page/Save.php | 25 +++-
.../Page/CustomLayout/CustomLayoutManager.php | 117 +++------------
.../CustomLayout/CustomLayoutRepository.php | 139 ++++++++++++++++++
.../Page/CustomLayoutManagerInterface.php | 41 ++----
.../Page/CustomLayoutRepositoryInterface.php | 50 +++++++
app/code/Magento/Cms/etc/di.xml | 1 +
.../Model/Page/CustomLayoutManagerTest.php | 42 +++---
.../Model/Page/CustomLayoutRepositoryTest.php | 100 +++++++++++++
8 files changed, 362 insertions(+), 153 deletions(-)
create mode 100644 app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
create mode 100644 app/code/Magento/Cms/Model/Page/CustomLayoutRepositoryInterface.php
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 1412a86cf0fd0..ff64fc8ec7ee9 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -8,8 +8,11 @@
use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Backend\App\Action;
use Magento\Cms\Model\Page;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Exception\LocalizedException;
+use Magento\Cms\Model\Page\CustomLayoutRepositoryInterface;
+use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelected;
/**
* Save CMS page action.
@@ -43,6 +46,11 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
*/
private $pageRepository;
+ /**
+ * @var CustomLayoutRepositoryInterface
+ */
+ private $customLayoutRepository;
+
/**
* @param Action\Context $context
* @param PostDataProcessor $dataProcessor
@@ -55,15 +63,16 @@ public function __construct(
PostDataProcessor $dataProcessor,
DataPersistorInterface $dataPersistor,
\Magento\Cms\Model\PageFactory $pageFactory = null,
- \Magento\Cms\Api\PageRepositoryInterface $pageRepository = null
+ \Magento\Cms\Api\PageRepositoryInterface $pageRepository = null,
+ ?CustomLayoutRepositoryInterface $customLayoutRepository = null
) {
$this->dataProcessor = $dataProcessor;
$this->dataPersistor = $dataPersistor;
- $this->pageFactory = $pageFactory
- ?: \Magento\Framework\App\ObjectManager::getInstance()->get(\Magento\Cms\Model\PageFactory::class);
+ $this->pageFactory = $pageFactory ?: ObjectManager::getInstance()->get(\Magento\Cms\Model\PageFactory::class);
$this->pageRepository = $pageRepository
- ?: \Magento\Framework\App\ObjectManager::getInstance()
- ->get(\Magento\Cms\Api\PageRepositoryInterface::class);
+ ?: ObjectManager::getInstance()->get(\Magento\Cms\Api\PageRepositoryInterface::class);
+ $this->customLayoutRepository = $customLayoutRepository
+ ?? ObjectManager::getInstance()->get(CustomLayoutRepositoryInterface::class);
parent::__construct($context);
}
@@ -112,7 +121,13 @@ public function execute()
return $resultRedirect->setPath('*/*/edit', ['page_id' => $model->getId(), '_current' => true]);
}
+ $customLayoutFile = (string)$this->getRequest()->getParam('layout_update_selected');
$this->pageRepository->save($model);
+ if ($customLayoutFile) {
+ $this->customLayoutRepository->save(new CustomLayoutSelected($model->getId(), $customLayoutFile));
+ } else {
+ $this->customLayoutRepository->deleteFor($model->getId());
+ }
$this->messageManager->addSuccessMessage(__('You saved the page.'));
return $this->processResultRedirect($model, $resultRedirect, $data);
} catch (LocalizedException $e) {
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
index ae9bda5d04f69..8bf902f009bc8 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
@@ -8,40 +8,22 @@
namespace Magento\Cms\Model\Page\CustomLayout;
+use Magento\Cms\Api\Data\PageInterface;
+use Magento\Cms\Api\PageRepositoryInterface;
use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelectedInterface;
use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
-use Magento\Cms\Model\ResourceModel\Page;
-use Magento\Cms\Model\Page as PageModel;
-use Magento\Cms\Model\PageFactory as PageModelFactory;
-use Magento\Cms\Model\Page\IdentityMap;
use Magento\Framework\App\Area;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\File;
use Magento\Framework\View\File\CollectorInterface;
+use Magento\Framework\View\Result\Page as PageLayout;
/**
* @inheritDoc
*/
class CustomLayoutManager implements CustomLayoutManagerInterface
{
- /**
- * @var Page
- */
- private $pageRepository;
-
- /**
- * @var PageModelFactory;
- */
- private $pageFactory;
-
- /**
- * @var IdentityMap
- */
- private $identityMap;
-
/**
* @var CollectorInterface
*/
@@ -58,104 +40,44 @@ class CustomLayoutManager implements CustomLayoutManagerInterface
private $design;
/**
- * @param Page $pageRepository
- * @param PageModelFactory $factory
- * @param IdentityMap $identityMap
+ * @var PageRepositoryInterface
+ */
+ private $pageRepository;
+
+ /**
* @param CollectorInterface $fileCollector
* @param FlyweightFactory $themeFactory
* @param DesignInterface $design
+ * @param PageRepositoryInterface $pageRepository
*/
public function __construct(
- Page $pageRepository,
- PageModelFactory $factory,
- IdentityMap $identityMap,
CollectorInterface $fileCollector,
FlyweightFactory $themeFactory,
- DesignInterface $design
+ DesignInterface $design,
+ PageRepositoryInterface $pageRepository
) {
- $this->pageRepository = $pageRepository;
- $this->pageFactory = $factory;
- $this->identityMap = $identityMap;
$this->fileCollector = $fileCollector;
$this->themeFactory = $themeFactory;
$this->design = $design;
- }
-
- /**
- * Find page model by ID.
- *
- * @param int $id
- * @return PageModel
- * @throws NoSuchEntityException
- */
- private function findPage(int $id): PageModel
- {
- if (!$page = $this->identityMap->get($id)) {
- /** @var PageModel $page */
- $this->pageRepository->load($page = $this->pageFactory->create(), $id);
- if (!$page->getIdentifier()) {
- throw NoSuchEntityException::singleField('id', $id);
- }
- }
-
- return $page;
+ $this->pageRepository = $pageRepository;
}
/**
* Adopt page's identifier to be used as layout handle.
*
- * @param PageModel $page
+ * @param PageInterface $page
* @return string
*/
- private function sanitizeIdentifier(PageModel $page): string
+ private function sanitizeIdentifier(PageInterface $page): string
{
return str_replace('/', '_', $page->getIdentifier());
}
- /**
- * Save new custom layout file value for a page.
- *
- * @param int $pageId
- * @param string|null $layoutFile
- * @throws LocalizedException
- * @throws \InvalidArgumentException When invalid file was selected.
- * @throws NoSuchEntityException
- */
- private function saveLayout(int $pageId, ?string $layoutFile): void
- {
- $page = $this->findPage($pageId);
- if ($layoutFile !== null && !in_array($layoutFile, $this->fetchAvailableFiles($pageId), true)) {
- throw new \InvalidArgumentException(
- $layoutFile .' is not available for page #' .$pageId
- );
- }
-
- $page->setData('layout_update_selected', $layoutFile);
- $this->pageRepository->save($page);
- }
-
/**
* @inheritDoc
*/
- public function save(CustomLayoutSelectedInterface $layout): void
+ public function fetchAvailableFiles(PageInterface $page): array
{
- $this->saveLayout($layout->getPageId(), $layout->getLayoutFileId());
- }
-
- /**
- * @inheritDoc
- */
- public function deleteFor(int $pageId): void
- {
- $this->saveLayout($pageId, null);
- }
-
- /**
- * @inheritDoc
- */
- public function fetchAvailableFiles(int $pageId): array
- {
- $page = $this->findPage($pageId);
$identifier = $this->sanitizeIdentifier($page);
$layoutFiles = $this->fileCollector->getFiles(
$this->themeFactory->create($this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND)),
@@ -184,11 +106,12 @@ function (File $file) use ($identifier) : ?string {
/**
* @inheritDoc
*/
- public function fetchHandle(int $pageId): ?array
+ public function applyUpdate(PageLayout $layout, CustomLayoutSelectedInterface $layoutSelected): void
{
- $page = $this->findPage($pageId);
+ $page = $this->pageRepository->getById($layoutSelected->getPageId());
- return $page['layout_update_selected']
- ? ['selectable' => $this->sanitizeIdentifier($page) .'_' .$page['layout_update_selected']] : null;
+ $layout->addPageLayoutHandles(
+ ['selectable' => $this->sanitizeIdentifier($page) .'_' .$layoutSelected->getLayoutFileId()]
+ );
}
}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
new file mode 100644
index 0000000000000..9365bb31e970a
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
@@ -0,0 +1,139 @@
+pageRepository = $pageRepository;
+ $this->pageFactory = $factory;
+ $this->identityMap = $identityMap;
+ $this->manager = $manager;
+ }
+
+ /**
+ * Find page model by ID.
+ *
+ * @param int $id
+ * @return PageModel
+ * @throws NoSuchEntityException
+ */
+ private function findPage(int $id): PageModel
+ {
+ if (!$page = $this->identityMap->get($id)) {
+ /** @var PageModel $page */
+ $this->pageRepository->load($page = $this->pageFactory->create(), $id);
+ if (!$page->getIdentifier()) {
+ throw NoSuchEntityException::singleField('id', $id);
+ }
+ }
+
+ return $page;
+ }
+
+ /**
+ * Save new custom layout file value for a page.
+ *
+ * @param int $pageId
+ * @param string|null $layoutFile
+ * @throws LocalizedException
+ * @throws \InvalidArgumentException When invalid file was selected.
+ * @throws NoSuchEntityException
+ */
+ private function saveLayout(int $pageId, ?string $layoutFile): void
+ {
+ $page = $this->findPage($pageId);
+ if ($layoutFile !== null && !in_array($layoutFile, $this->manager->fetchAvailableFiles($page), true)) {
+ throw new \InvalidArgumentException(
+ $layoutFile .' is not available for page #' .$pageId
+ );
+ }
+
+ if ($page->getData('layout_update_selected') != $layoutFile) {
+ $page->setData('layout_update_selected', $layoutFile);
+ $this->pageRepository->save($page);
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function save(CustomLayoutSelectedInterface $layout): void
+ {
+ $this->saveLayout($layout->getPageId(), $layout->getLayoutFileId());
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function deleteFor(int $pageId): void
+ {
+ $this->saveLayout($pageId, null);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getFor(int $pageId): CustomLayoutSelectedInterface
+ {
+ $page = $this->findPage($pageId);
+ if (!$page['layout_update_selected']) {
+ throw new NoSuchEntityException(
+ __('Page "%id" doesn\'t have custom layout assigned', ['id' => $page->getIdentifier()])
+ );
+ }
+
+ return new CustomLayoutSelected($pageId, $page['layout_update_selected']);
+ }
+}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php b/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
index 5c1c8662f9d9c..8d66ff36c846e 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
@@ -8,51 +8,30 @@
namespace Magento\Cms\Model\Page;
+use Magento\Cms\Api\Data\PageInterface;
use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelectedInterface;
-use Magento\Framework\Exception\LocalizedException;
-use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\View\Result\Page as View;
/**
* Manage custom layout files for CMS pages.
*/
interface CustomLayoutManagerInterface
{
- /**
- * Save layout file to be used when rendering given page.
- *
- * @throws LocalizedException When failed to save new value.
- * @throws \InvalidArgumentException When invalid file was selected.
- * @throws NoSuchEntityException When given page is not found.
- * @param CustomLayoutSelectedInterface $layout
- * @return void
- */
- public function save(CustomLayoutSelectedInterface $layout): void;
-
- /**
- * Do not use custom layout update when rendering the page.
- *
- * @throws NoSuchEntityException When given page is not found.
- * @throws LocalizedException When failed to remove existing value.
- * @param int $pageId
- * @return void
- */
- public function deleteFor(int $pageId): void;
-
/**
* List of available custom files for the given page.
*
- * @throws NoSuchEntityException When given page is not found.
- * @param int $pageId
+ * @param PageInterface $page
* @return string[]
*/
- public function fetchAvailableFiles(int $pageId): array;
+ public function fetchAvailableFiles(PageInterface $page): array;
+
/**
- * Get handles according to the page's settings.
+ * Apply the page's layout settings.
*
- * @throws NoSuchEntityException When given page is not found.
- * @param int $pageId
- * @return array|null With keys as handle IDs and values as handles.
+ * @param View $layout
+ * @param CustomLayoutSelectedInterface $layoutSelected
+ * @return void
*/
- public function fetchHandle(int $pageId): ?array;
+ public function applyUpdate(View $layout, CustomLayoutSelectedInterface $layoutSelected): void;
}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayoutRepositoryInterface.php b/app/code/Magento/Cms/Model/Page/CustomLayoutRepositoryInterface.php
new file mode 100644
index 0000000000000..80eb39b7ab20f
--- /dev/null
+++ b/app/code/Magento/Cms/Model/Page/CustomLayoutRepositoryInterface.php
@@ -0,0 +1,50 @@
+Magento\Framework\View\Layout\File\Collector\Aggregated\Proxy
+
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
index 7b2f0b8cbd57c..7e405725a2d8b 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
@@ -15,12 +15,18 @@
use PHPUnit\Framework\TestCase;
use Magento\Framework\View\File\CollectorInterface;
use Magento\Framework\View\File;
+use Magento\Framework\View\Result\PageFactory as PageResultFactory;
/**
* Test the manager.
*/
class CustomLayoutManagerTest extends TestCase
{
+ /**
+ * @var CustomLayoutRepositoryInterface
+ */
+ private $repo;
+
/**
* @var CustomLayoutManagerInterface
*/
@@ -31,12 +37,18 @@ class CustomLayoutManagerTest extends TestCase
*/
private $pageFactory;
+ /**
+ * @var PageResultFactory
+ */
+ private $resultFactory;
+
/**
* @inheritDoc
*/
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
+ $this->resultFactory = $objectManager->get(PageResultFactory::class);
//Mocking available list of files for the page.
$files = [
new File('cms_page_view_selectable_page100_select1.xml', 'test'),
@@ -50,6 +62,10 @@ protected function setUp()
CustomLayoutManagerInterface::class,
['fileCollector' => $fileCollector]
);
+ $this->repo = $objectManager->create(
+ CustomLayoutRepositoryInterface::class,
+ ['manager' => $this->manager]
+ );
$this->pageFactory = $objectManager->get(PageFactory::class);
}
@@ -57,35 +73,21 @@ protected function setUp()
* Test updating a page's custom layout.
*
* @magentoDataFixture Magento/Cms/_files/pages.php
+ * @throws \Throwable
* @return void
*/
- public function testCustomLayout(): void
+ public function testCustomLayoutUpdate(): void
{
/** @var Page $page */
$page = $this->pageFactory->create();
$page->load('page100', 'identifier');
$pageId = (int)$page->getId();
-
- //Invalid file ID
- $exceptionRaised = null;
- try {
- $this->manager->save(new CustomLayoutSelected($pageId, 'some_file'));
- } catch (\Throwable $exception) {
- $exceptionRaised = $exception;
- }
- $this->assertNotEmpty($exceptionRaised);
- $this->assertInstanceOf(\InvalidArgumentException::class, $exceptionRaised);
-
//Set file ID
- $this->manager->save(new CustomLayoutSelected($pageId, 'select2'));
-
- //Test handles
- $this->assertEquals(['selectable' => 'page100_select2'], $this->manager->fetchHandle($pageId));
-
- //Removing custom file
- $this->manager->deleteFor($pageId);
+ $this->repo->save(new CustomLayoutSelected($pageId, 'select2'));
//Test handles
- $this->assertNull($this->manager->fetchHandle($pageId));
+ $result = $this->resultFactory->create();
+ $this->manager->applyUpdate($result, $this->repo->getFor($pageId));
+ $this->assertContains('___selectable_page100_select2', $result->getLayout()->getUpdate()->getHandles());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
new file mode 100644
index 0000000000000..4736774ea0f02
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
@@ -0,0 +1,100 @@
+getMockForAbstractClass(CollectorInterface::class);
+ $fileCollector->method('getFiles')
+ ->willReturn($files);
+
+ $manager = $objectManager->create(
+ CustomLayoutManagerInterface::class,
+ ['fileCollector' => $fileCollector]
+ );
+ $this->repo = $objectManager->create(CustomLayoutRepositoryInterface::class, ['manager' => $manager]);
+ $this->pageFactory = $objectManager->get(PageFactory::class);
+ }
+
+ /**
+ * Test updating a page's custom layout.
+ *
+ * @magentoDataFixture Magento/Cms/_files/pages.php
+ * @return void
+ */
+ public function testCustomLayout(): void
+ {
+ /** @var Page $page */
+ $page = $this->pageFactory->create();
+ $page->load('page100', 'identifier');
+ $pageId = (int)$page->getId();
+
+ //Invalid file ID
+ $exceptionRaised = null;
+ try {
+ $this->repo->save(new CustomLayoutSelected($pageId, 'some_file'));
+ } catch (\Throwable $exception) {
+ $exceptionRaised = $exception;
+ }
+ $this->assertNotEmpty($exceptionRaised);
+ $this->assertInstanceOf(\InvalidArgumentException::class, $exceptionRaised);
+
+ //Set file ID
+ $this->repo->save(new CustomLayoutSelected($pageId, 'select2'));
+
+ //Test saved
+ $saved = $this->repo->getFor($pageId);
+ $this->assertEquals('select2', $saved->getLayoutFileId());
+
+ //Removing custom file
+ $this->repo->deleteFor($pageId);
+
+ //Test saved
+ $notFound = false;
+ try {
+ $this->repo->getFor($pageId);
+ } catch (NoSuchEntityException $exception) {
+ $notFound = true;
+ }
+ $this->assertTrue($notFound);
+ }
+}
From a3c2ed1f0eb05eb223327e5881cab6a5af8a120c Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 16 Aug 2019 14:23:54 -0500
Subject: [PATCH 0071/1978] MC-18685: Remove custom layout updates from admin
---
.../Cms/Controller/Adminhtml/Page/Save.php | 9 ++-
.../Magento/Cms/Model/Page/DataProvider.php | 24 ++++++-
.../{PageSaveTest.php => PageDesignTest.php} | 54 +++++++++++++-
.../Cms/Model/Page/DataProviderTest.php | 72 +++++++++++++++++++
.../Cms/_files/pages_with_layout_xml.php | 25 +++++++
.../_files/pages_with_layout_xml_rollback.php | 26 +++++++
6 files changed, 205 insertions(+), 5 deletions(-)
rename dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/{PageSaveTest.php => PageDesignTest.php} (61%)
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index ff64fc8ec7ee9..974bc044e3ab0 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -95,6 +95,14 @@ public function execute()
if (empty($data['page_id'])) {
$data['page_id'] = null;
}
+ //Either use existing custom layout XML or use a file.
+ $customLayoutFile = (string)$this->getRequest()->getParam('layout_update_selected');
+ if ($customLayoutFile !== '_existing_') {
+ $data['custom_layout_update_xml'] = null;
+ } else {
+ $customLayoutFile = null;
+ }
+
/** @var \Magento\Cms\Model\Page $model */
$model = $this->pageFactory->create();
@@ -121,7 +129,6 @@ public function execute()
return $resultRedirect->setPath('*/*/edit', ['page_id' => $model->getId(), '_current' => true]);
}
- $customLayoutFile = (string)$this->getRequest()->getParam('layout_update_selected');
$this->pageRepository->save($model);
if ($customLayoutFile) {
$this->customLayoutRepository->save(new CustomLayoutSelected($model->getId(), $customLayoutFile));
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
index bf961c0420e2f..801440eaf0bcc 100644
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ b/app/code/Magento/Cms/Model/Page/DataProvider.php
@@ -108,6 +108,10 @@ public function getData()
/** @var $page \Magento\Cms\Model\Page */
foreach ($items as $page) {
$this->loadedData[$page->getId()] = $page->getData();
+ if ($page->getCustomLayoutUpdateXml()) {
+ //Deprecated layout update exists.
+ $this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_';
+ }
}
$data = $this->dataPersistor->get('cms_page');
@@ -115,6 +119,9 @@ public function getData()
$page = $this->collection->getNewEmptyItem();
$page->setData($data);
$this->loadedData[$page->getId()] = $page->getData();
+ if ($page->getCustomLayoutUpdateXml()) {
+ $this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_';
+ }
$this->dataPersistor->clear('cms_page');
}
@@ -153,10 +160,23 @@ public function getMeta()
}
//List of custom layout files available for current page.
- $options = [['label' => 'Use default', 'value' => '']];
+ $options = [['label' => 'No update', 'value' => '']];
if ($this->getRequestFieldName() && ($pageId = (int)$this->request->getParam($this->getRequestFieldName()))) {
//We must have a specific page selected.
- foreach ($this->customLayoutManager->fetchAvailableFiles($pageId) as $layoutFile) {
+ //Finding our page.
+ $found = null;
+ /** @var \Magento\Cms\Model\Page $page */
+ foreach ($this->collection->getItems() as $page) {
+ if ($page->getId() == $pageId) {
+ $found = $page;
+ break;
+ }
+ }
+ //If custom layout XML is set then displaying this special option.
+ if ($page->getCustomLayoutUpdateXml()) {
+ $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
+ }
+ foreach ($this->customLayoutManager->fetchAvailableFiles($found) as $layoutFile) {
$options[] = ['label' => $layoutFile, 'value' => $layoutFile];
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
similarity index 61%
rename from dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php
rename to dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
index 17c28a76d394d..1d47ebc8aeca6 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageSaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
@@ -9,7 +9,9 @@
namespace Magento\Cms\Controller\Adminhtml;
use Magento\Cms\Api\Data\PageInterface;
+use Magento\Cms\Api\GetPageByIdentifierInterface;
use Magento\Cms\Model\Page;
+use Magento\Cms\Model\PageFactory;
use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
@@ -17,11 +19,11 @@
use Magento\TestFramework\TestCase\AbstractBackendController;
/**
- * Test the saving CMS pages via admin area interface.
+ * Test the saving CMS pages design via admin area interface.
*
* @magentoAppArea adminhtml
*/
-class PageSaveTest extends AbstractBackendController
+class PageDesignTest extends AbstractBackendController
{
/**
* @var string
@@ -43,6 +45,11 @@ class PageSaveTest extends AbstractBackendController
*/
private $aclBuilder;
+ /**
+ * @var GetPageByIdentifierInterface
+ */
+ private $pageRetriever;
+
/**
* @inheritDoc
*/
@@ -51,6 +58,7 @@ protected function setUp()
parent::setUp();
$this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
+ $this->pageRetriever = Bootstrap::getObjectManager()->get(GetPageByIdentifierInterface::class);
}
/**
@@ -110,4 +118,46 @@ public function testSaveDesign(): void
MessageInterface::TYPE_ERROR
);
}
+
+ /**
+ * Test that custom layout update fields are dealt with properly.
+ *
+ * @magentoDataFixture Magento/Cms/_files/pages_with_layout_xml.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveLayoutXml(): void
+ {
+ $page = $this->pageRetriever->execute('test_custom_layout_page_1', 0);
+ $requestData = [
+ Page::PAGE_ID => $page->getId(),
+ PageInterface::IDENTIFIER => 'test_custom_layout_page_1',
+ PageInterface::TITLE => 'Page title',
+ PageInterface::CUSTOM_LAYOUT_UPDATE_XML => $page->getCustomLayoutUpdateXml(),
+ 'layout_update_selected' => '_existing_'
+ ];
+
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->dispatch($this->uri);
+ $this->getRequest()->setDispatched(false);
+
+ $updated = $this->pageRetriever->execute('test_custom_layout_page_1', 0);
+ $this->assertEquals($updated->getCustomLayoutUpdateXml(), $page->getCustomLayoutUpdateXml());
+
+ $requestData = [
+ Page::PAGE_ID => $page->getId(),
+ PageInterface::IDENTIFIER => 'test_custom_layout_page_1',
+ PageInterface::TITLE => 'Page title',
+ PageInterface::CUSTOM_LAYOUT_UPDATE_XML => $page->getCustomLayoutUpdateXml(),
+ 'layout_update_selected' => ''
+ ];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->dispatch($this->uri);
+ $this->getRequest()->setDispatched(false);
+
+ $updated = $this->pageRetriever->execute('test_custom_layout_page_1', 0);
+ $this->assertEmpty($updated->getCustomLayoutUpdateXml());
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
new file mode 100644
index 0000000000000..115e39269edba
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
@@ -0,0 +1,72 @@
+pageFactory = $objectManager->get(PageModelFactory::class);
+ $this->provider = $objectManager->create(
+ DataProvider::class,
+ [
+ 'name' => 'test',
+ 'primaryFieldName' => 'page_id',
+ 'requestFieldName' => 'page_id'
+ ]
+ );
+ }
+
+ /**
+ * Check that custom layout date is handled properly.
+ *
+ * @magentoDataFixture Magento/Cms/_files/pages_with_layout_xml.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testCustomLayoutData(): void
+ {
+ $data = $this->provider->getData();
+ $page1Data = null;
+ $page2Data = null;
+ foreach ($data as $pageData) {
+ if ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_1') {
+ $page1Data = $pageData;
+ } elseif ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_2') {
+ $page2Data = $pageData;
+ }
+ }
+ $this->assertNotEmpty($page1Data);
+ $this->assertNotEmpty($page2Data);
+ $this->assertEquals('_existing_', $page1Data['layout_update_selected']);
+ $this->assertEquals(null, $page2Data['layout_update_selected']);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
new file mode 100644
index 0000000000000..c5e6986277ed0
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
@@ -0,0 +1,25 @@
+get(PageModelFactory::class);
+/** @var PageModel $page */
+$page = $pageFactory->create();
+$page->setIdentifier('test_custom_layout_page_1');
+$page->setTitle('Test Page');
+$page->setCustomLayoutUpdateXml('tst');
+$page->save();
+/** @var PageModel $page2 */
+$page2 = $pageFactory->create();
+$page2->setIdentifier('test_custom_layout_page_2');
+$page2->setTitle('Test Page 2');
+$page2->save();
diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php
new file mode 100644
index 0000000000000..ca9195256af8c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php
@@ -0,0 +1,26 @@
+get(PageModelFactory::class);
+/** @var PageModel $page */
+$page = $pageFactory->create();
+$page->load('test_custom_layout_page_1', PageModel::IDENTIFIER);
+if ($page->getId()) {
+ $page->delete();
+}
+/** @var PageModel $page2 */
+$page2 = $pageFactory->create();
+$page2->load('test_custom_layout_page_2', PageModel::IDENTIFIER);
+if ($page2->getId()) {
+ $page2->delete();
+}
From e12ee95aa33c5a27dbbad616d0b2890e8955f338 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 16 Aug 2019 16:03:38 -0500
Subject: [PATCH 0072/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Backend/LayoutUpdate.php | 41 +++++++++++++++++++
.../Attribute/Backend/LayoutUpdate.php | 41 +++++++++++++++++++
.../Data/UpdateCustomLayoutAttributes.php | 2 +
3 files changed, 84 insertions(+)
create mode 100644 app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
create mode 100644 app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
new file mode 100644
index 0000000000000..c34bddbe11d33
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -0,0 +1,41 @@
+ \Magento\Catalog\Model\Product\Attribute\Source\LayoutUpdate::class,
'required' => false,
'sort_order' => 51,
+ 'backend' => \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::class,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Design',
'is_used_in_grid' => false,
@@ -94,6 +95,7 @@ public function apply()
'source' => \Magento\Catalog\Model\Category\Attribute\Source\LayoutUpdate::class,
'required' => false,
'sort_order' => 51,
+ 'backend' => \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::class,
'global' => \Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface::SCOPE_STORE,
'group' => 'Custom Design',
'is_used_in_grid' => false,
From 270fb51d4ccb157c6f65dc2db384dc9642977c8e Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 16 Aug 2019 16:25:47 -0500
Subject: [PATCH 0073/1978] MC-18685: Remove custom layout updates from admin
---
.../Magento/Cms/Api/Data/PageInterface.php | 2 +
.../Magento/Cms/Model/PageRepositoryTest.php | 71 +++++++++++++++++++
2 files changed, 73 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
diff --git a/app/code/Magento/Cms/Api/Data/PageInterface.php b/app/code/Magento/Cms/Api/Data/PageInterface.php
index 50fa8cf0db2d1..38d8feb953319 100644
--- a/app/code/Magento/Cms/Api/Data/PageInterface.php
+++ b/app/code/Magento/Cms/Api/Data/PageInterface.php
@@ -298,6 +298,8 @@ public function setCustomRootTemplate($customRootTemplate);
*
* @param string $customLayoutUpdateXml
* @return \Magento\Cms\Api\Data\PageInterface
+ * @deprecated Existing updates are applied, new are not accepted.
+ * @see \Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelectedInterface
*/
public function setCustomLayoutUpdateXml($customLayoutUpdateXml);
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
new file mode 100644
index 0000000000000..5bbb8b870aad5
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
@@ -0,0 +1,71 @@
+repo = Bootstrap::getObjectManager()->get(PageRepositoryInterface::class);
+ $this->retriever = Bootstrap::getObjectManager()->get(GetPageByIdentifierInterface::class);
+ }
+
+ /**
+ * Test that the field is deprecated.
+ *
+ * @throws \Throwable
+ * @magentoDataFixture Magento/Cms/_files/pages_with_layout_xml.php
+ * @return void
+ */
+ public function testSaveUpdateXml(): void
+ {
+ $page = $this->retriever->execute('test_custom_layout_page_1', 0);
+ $page->setTitle($page->getTitle() .'TEST');
+
+ //Is successfully saved without changes to the custom layout xml.
+ $page = $this->repo->save($page);
+
+ //New value is not accepted.
+ $page->setCustomLayoutUpdateXml($page->getCustomLayoutUpdateXml() .'TEST');
+ $forbidden = false;
+ try {
+ $page = $this->repo->save($page);
+ } catch (CouldNotSaveException $exception) {
+ $forbidden = true;
+ }
+ $this->assertTrue($forbidden);
+
+ //Can be removed
+ $page->setCustomLayoutUpdateXml(null);
+ $page = $this->repo->save($page);
+ $this->assertEmpty($page->getCustomLayoutUpdateXml());
+ }
+}
From fcbe98e798706e54b785098b8c84c3b5b3c24dd6 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 19 Aug 2019 09:57:15 -0500
Subject: [PATCH 0074/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Cms/Helper/Page.php | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php
index bf263d94aaca7..634833ff45a23 100644
--- a/app/code/Magento/Cms/Helper/Page.php
+++ b/app/code/Magento/Cms/Helper/Page.php
@@ -6,8 +6,10 @@
namespace Magento\Cms\Helper;
use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
+use Magento\Cms\Model\Page\CustomLayoutRepositoryInterface;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\NoSuchEntityException;
/**
* CMS Page Helper
@@ -83,6 +85,11 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper
*/
private $customLayoutManager;
+ /**
+ * @var CustomLayoutRepositoryInterface
+ */
+ private $customLayoutRepo;
+
/**
* Constructor
*
@@ -108,7 +115,8 @@ public function __construct(
\Magento\Framework\Stdlib\DateTime\TimezoneInterface $localeDate,
\Magento\Framework\Escaper $escaper,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
- ?CustomLayoutManagerInterface $customLayoutManager = null
+ ?CustomLayoutManagerInterface $customLayoutManager = null,
+ ?CustomLayoutRepositoryInterface $customLayoutRepo = null
) {
$this->messageManager = $messageManager;
$this->_page = $page;
@@ -120,6 +128,8 @@ public function __construct(
$this->resultPageFactory = $resultPageFactory;
$this->customLayoutManager = $customLayoutManager
?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
+ $this->customLayoutRepo = $customLayoutRepo
+ ?? ObjectManager::getInstance()->get(CustomLayoutRepositoryInterface::class);
parent::__construct($context);
}
@@ -165,9 +175,10 @@ public function prepareResultPage(Action $action, $pageId = null)
$resultPage->addHandle('cms_page_view');
$pageHandles = ['id' => str_replace('/', '_', $this->_page->getIdentifier())];
//Selected custom updates.
- $customLayoutHandle = $this->customLayoutManager->fetchHandle($this->_page->getId());
- if ($customLayoutHandle) {
- $pageHandles = array_merge($pageHandles, $customLayoutHandle);
+ try {
+ $this->customLayoutManager->applyUpdate($resultPage, $this->customLayoutRepo->getFor($this->_page->getId()));
+ } catch (NoSuchEntityException $exception) {
+ //No custom layout selected
}
$resultPage->addPageLayoutHandles($pageHandles);
From c9060b41f1c603d1b7ee6cd30fa603ed3673bce1 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Fri, 16 Aug 2019 17:56:36 +0300
Subject: [PATCH 0075/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Grand totals correct rounding added.
---
.../Quote/Model/Quote/Address/Total/Grand.php | 57 +++++++++++++------
.../Model/Quote/Address/Total/GrandTest.php | 45 ++++++++++++---
2 files changed, 77 insertions(+), 25 deletions(-)
diff --git a/app/code/Magento/Quote/Model/Quote/Address/Total/Grand.php b/app/code/Magento/Quote/Model/Quote/Address/Total/Grand.php
index 13f41f909d43f..2cefec2c9035a 100644
--- a/app/code/Magento/Quote/Model/Quote/Address/Total/Grand.php
+++ b/app/code/Magento/Quote/Model/Quote/Address/Total/Grand.php
@@ -3,43 +3,64 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Quote\Model\Quote\Address\Total;
-class Grand extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Pricing\PriceCurrencyInterface as PriceRounder;
+use Magento\Quote\Api\Data\ShippingAssignmentInterface as ShippingAssignment;
+use Magento\Quote\Model\Quote;
+use Magento\Quote\Model\Quote\Address\Total;
+
+/**
+ * Collect grand totals.
+ */
+class Grand extends AbstractTotal
{
+ /**
+ * @var PriceRounder
+ */
+ private $priceRounder;
+
+ /**
+ * @param PriceRounder|null $priceRounder
+ */
+ public function __construct(?PriceRounder $priceRounder)
+ {
+ $this->priceRounder = $priceRounder?: ObjectManager::getInstance()->get(PriceRounder::class);
+ }
+
/**
* Collect grand total address amount
*
- * @param \Magento\Quote\Model\Quote $quote
- * @param \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment
- * @param \Magento\Quote\Model\Quote\Address\Total $total
- * @return $this
+ * @param Quote $quote
+ * @param ShippingAssignment $shippingAssignment
+ * @param Total $total
+ * @return Grand
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function collect(
- \Magento\Quote\Model\Quote $quote,
- \Magento\Quote\Api\Data\ShippingAssignmentInterface $shippingAssignment,
- \Magento\Quote\Model\Quote\Address\Total $total
- ) {
- $grandTotal = $total->getGrandTotal();
- $baseGrandTotal = $total->getBaseGrandTotal();
+ public function collect(Quote $quote, ShippingAssignment $shippingAssignment, Total $total): Grand
+ {
$totals = array_sum($total->getAllTotalAmounts());
$baseTotals = array_sum($total->getAllBaseTotalAmounts());
+ $grandTotal = $this->priceRounder->roundPrice($total->getGrandTotal() + $totals, 4);
+ $baseGrandTotal = $this->priceRounder->roundPrice($total->getBaseGrandTotal() + $baseTotals, 4);
- $total->setGrandTotal($grandTotal + $totals);
- $total->setBaseGrandTotal($baseGrandTotal + $baseTotals);
+ $total->setGrandTotal($grandTotal);
+ $total->setBaseGrandTotal($baseGrandTotal);
return $this;
}
/**
* Add grand total information to address
*
- * @param \Magento\Quote\Model\Quote $quote
- * @param \Magento\Quote\Model\Quote\Address\Total $total
- * @return $this
+ * @param Quote $quote
+ * @param Total $total
+ * @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Quote\Address\Total $total)
+ public function fetch(Quote $quote, Total $total): array
{
return [
'code' => $this->getCode(),
diff --git a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php
index 34c51f294c05f..6771583b5bbb0 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/Quote/Address/Total/GrandTest.php
@@ -6,18 +6,43 @@
namespace Magento\Quote\Test\Unit\Model\Quote\Address\Total;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Quote\Model\Quote\Address\Total\Grand;
+use Magento\Framework\Pricing\PriceCurrencyInterface as PriceRounder;
+use PHPUnit_Framework_MockObject_MockObject as ObjectMock;
+use PHPUnit\Framework\TestCase;
-class GrandTest extends \PHPUnit\Framework\TestCase
+/**
+ * Grand totals collector test.
+ */
+class GrandTest extends TestCase
{
/**
- * @var \Magento\Quote\Model\Quote\Address\Total\Grand
+ * @var PriceRounder|ObjectMock
+ */
+ private $priceRounder;
+
+ /**
+ * @var Grand
*/
- protected $model;
+ private $model;
+ /**
+ * @inheritDoc
+ */
protected function setUp()
{
- $objectManager = new ObjectManager($this);
- $this->model = $objectManager->getObject(\Magento\Quote\Model\Quote\Address\Total\Grand::class);
+ $this->priceRounder = $this->getMockBuilder(PriceRounder::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['roundPrice'])
+ ->getMockForAbstractClass();
+
+ $helper = new ObjectManager($this);
+ $this->model = $helper->getObject(
+ Grand::class,
+ [
+ 'priceRounder' => $this->priceRounder,
+ ]
+ );
}
public function testCollect()
@@ -27,14 +52,20 @@ public function testCollect()
$grandTotal = 6.4; // 1 + 2 + 3.4
$grandTotalBase = 15.7; // 4 + 5 + 6.7
- $totalMock = $this->createPartialMock(\Magento\Quote\Model\Quote\Address\Total::class, [
+ $this->priceRounder->expects($this->at(0))->method('roundPrice')->willReturn($grandTotal + 2);
+ $this->priceRounder->expects($this->at(1))->method('roundPrice')->willReturn($grandTotalBase + 2);
+
+ $totalMock = $this->createPartialMock(
+ \Magento\Quote\Model\Quote\Address\Total::class,
+ [
'getAllTotalAmounts',
'getAllBaseTotalAmounts',
'setGrandTotal',
'setBaseGrandTotal',
'getGrandTotal',
'getBaseGrandTotal'
- ]);
+ ]
+ );
$totalMock->expects($this->once())->method('getGrandTotal')->willReturn(2);
$totalMock->expects($this->once())->method('getBaseGrandTotal')->willReturn(2);
$totalMock->expects($this->once())->method('getAllTotalAmounts')->willReturn($totals);
From 7432d2d59b4d0da1866df8cd75a30fe1870f3dac Mon Sep 17 00:00:00 2001
From: Evgeny Petrov
Date: Wed, 21 Aug 2019 16:05:59 +0300
Subject: [PATCH 0076/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
---
.../SearchAdapter/Query/Builder/Match.php | 16 +---------------
.../Framework/DB/Helper/Mysql/Fulltext.php | 2 +-
2 files changed, 2 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
index f8f70170de155..a1d2d63096e46 100644
--- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
+++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
@@ -82,8 +82,7 @@ public function __construct(
*/
public function build(array $selectQuery, RequestQueryInterface $requestQuery, $conditionType)
{
- $preparedValue = $this->prepareValue($requestQuery->getValue());
- $queryValue = $this->prepareQuery($preparedValue, $conditionType);
+ $queryValue = $this->prepareQuery($requestQuery->getValue(), $conditionType);
$queries = $this->buildQueries($requestQuery->getMatches(), $queryValue);
$requestQueryBoost = $requestQuery->getBoost() ?: 1;
foreach ($queries as $query) {
@@ -116,19 +115,6 @@ protected function prepareQuery($queryValue, $conditionType)
];
}
- /**
- * Removes special query characters which are cause of mysql error: '(', ')', '?'
- *
- * @param string $queryValue
- * @return string
- */
- private function prepareValue($queryValue)
- {
- $pattern = '/(\(|\)|\?)/';
- $replace = '';
- return preg_replace($pattern, $replace, $queryValue);
- }
-
/**
* Creates valid ElasticSearch search conditions from Match queries.
*
diff --git a/lib/internal/Magento/Framework/DB/Helper/Mysql/Fulltext.php b/lib/internal/Magento/Framework/DB/Helper/Mysql/Fulltext.php
index 5c50faf71a854..1493e89e08645 100644
--- a/lib/internal/Magento/Framework/DB/Helper/Mysql/Fulltext.php
+++ b/lib/internal/Magento/Framework/DB/Helper/Mysql/Fulltext.php
@@ -19,7 +19,7 @@ class Fulltext
*
* @var string
*/
- const SPECIAL_CHARACTERS = '-+<>*()~';
+ const SPECIAL_CHARACTERS = '-+<>*()~?';
/**
* FULLTEXT search in MySQL search mode "natural language"
From ef93c70aef566175173241f16fa54e6059300bf1 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Wed, 21 Aug 2019 16:49:52 +0300
Subject: [PATCH 0077/1978] MC-15523: Watermark is possible to set up for
swatch image type
- Updated automated test script
---
.../Test/AdminSetUpWatermarkForSwatchImageTest.xml | 12 ++++++------
.../Test/Mftf/Section/AdminDesignConfigSection.xml | 5 +----
2 files changed, 7 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml
index 66043a51db183..569952019b29b 100644
--- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml
+++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminSetUpWatermarkForSwatchImageTest.xml
@@ -44,14 +44,14 @@
-
-
-
-
-
+
+
+
+
+
-
+
diff --git a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
index a65dcc5a1aa14..cf420598ca44e 100644
--- a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
+++ b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
@@ -31,9 +31,6 @@
-
-
-
-
+
From 4d62ac8a56828fa7702381ba2f0b651a6266e099 Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Fri, 28 Jun 2019 16:20:22 +0300
Subject: [PATCH 0078/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Fix CR comments
---
.../Model/Order/Shipment/TrackRepository.php | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
index c8fc9e5fc5600..93396976565ea 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
@@ -16,8 +16,8 @@
use Magento\Sales\Api\Data\ShipmentTrackSearchResultInterfaceFactory;
use Magento\Sales\Api\ShipmentTrackRepositoryInterface;
use Magento\Sales\Model\Spi\ShipmentTrackResourceInterface;
-use \Magento\Sales\Api\OrderRepositoryInterface;
-use \Magento\Framework\App\ObjectManager;
+use Magento\Sales\Model\ResourceModel\Order\Shipment\CollectionFactory;
+use Magento\Framework\App\ObjectManager;
use Psr\Log\LoggerInterface;
/**
@@ -46,9 +46,9 @@ class TrackRepository implements ShipmentTrackRepositoryInterface
private $collectionProcessor;
/**
- * @var OrderRepositoryInterface
+ * @var CollectionFactory
*/
- private $orderRepository;
+ private $shipmentCollection;
/**
* @var LoggerInterface
@@ -60,7 +60,7 @@ class TrackRepository implements ShipmentTrackRepositoryInterface
* @param ShipmentTrackInterfaceFactory $trackFactory
* @param ShipmentTrackSearchResultInterfaceFactory $searchResultFactory
* @param CollectionProcessorInterface $collectionProcessor
- * @param OrderRepositoryInterface|null $orderRepository
+ * @param CollectionFactory|null $shipmentCollection
* @param LoggerInterface|null $logger
*/
public function __construct(
@@ -68,15 +68,15 @@ public function __construct(
ShipmentTrackInterfaceFactory $trackFactory,
ShipmentTrackSearchResultInterfaceFactory $searchResultFactory,
CollectionProcessorInterface $collectionProcessor,
- OrderRepositoryInterface $orderRepository = null,
+ CollectionFactory $shipmentCollection = null,
LoggerInterface $logger = null
) {
$this->trackResource = $trackResource;
$this->trackFactory = $trackFactory;
$this->searchResultFactory = $searchResultFactory;
$this->collectionProcessor = $collectionProcessor;
- $this->orderRepository = $orderRepository ?:
- ObjectManager::getInstance()->get(OrderRepositoryInterface::class);
+ $this->shipmentCollection = $shipmentCollection ?:
+ ObjectManager::getInstance()->get(CollectionFactory::class);
$this->logger = $logger ?:
ObjectManager::getInstance()->get(LoggerInterface::class);
}
@@ -120,9 +120,9 @@ public function delete(ShipmentTrackInterface $entity)
*/
public function save(ShipmentTrackInterface $entity)
{
- $shipmentCollection = $this->orderRepository->get($entity['order_id'])->getShipmentsCollection();
+ $shipments = $this->shipmentCollection->create()->addFieldToFilter('order_id', $entity['order_id']);
$shipmentId = [];
- foreach ($shipmentCollection as $shipment) {
+ foreach ($shipments->getItems() as $shipment) {
$shipmentId[] = $shipment->getId();
}
From 41cb1fcf99b3f758c03bb383a79547c38c8aa9b1 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Fri, 23 Aug 2019 16:35:48 +0300
Subject: [PATCH 0079/1978] Code refactoring
---
.../User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
index 4a021597ce405..bcf6d2cc0b7ea 100644
--- a/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
@@ -19,9 +19,13 @@
+
+
+
+
@@ -36,7 +40,7 @@
-
+
From 62111e3f2f1d7ec12e17f59dd959f69689403b68 Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Mon, 26 Aug 2019 17:03:45 +0300
Subject: [PATCH 0080/1978] createShipmentEntityTest
---
...eatedShipmentInShipmentsTabActionGroup.xml | 18 +++++
...sertShipmentInShipmentsGridActionGroup.xml | 27 +++++++
.../AdminAssertShipmentItemsActionGroup.xml | 22 ++++++
...CreateShipmentFromOrderPageActionGroup.xml | 29 +++++++
.../AssertThereIsNoShipButtonActionGroup.xml | 15 ++++
.../Test/Mftf/Page/AdminShipmentsGridPage.xml | 14 ++++
.../Section/AdminShipmentItemsSection.xml | 1 +
.../AdminShipmentPaymentShippingSection.xml | 2 +-
.../Section/AdminShipmentsGridSection.xml | 19 +++++
.../AdminCreatePartialShipmentEntityTest.xml | 74 ++++++++++++++++++
.../Test/AdminCreateShipmentEntityTest.xml | 75 +++++++++++++++++++
.../TestCase/CreateShipmentEntityTest.xml | 3 +-
12 files changed, 297 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertCreatedShipmentInShipmentsTabActionGroup.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentInShipmentsGridActionGroup.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentItemsActionGroup.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminCreateShipmentFromOrderPageActionGroup.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/ActionGroup/AssertThereIsNoShipButtonActionGroup.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentsGridPage.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentsGridSection.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml
create mode 100644 app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml
diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertCreatedShipmentInShipmentsTabActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertCreatedShipmentInShipmentsTabActionGroup.xml
new file mode 100644
index 0000000000000..1a7d3355e4ee4
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertCreatedShipmentInShipmentsTabActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentInShipmentsGridActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentInShipmentsGridActionGroup.xml
new file mode 100644
index 0000000000000..de293c24a9c5d
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentInShipmentsGridActionGroup.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentItemsActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentItemsActionGroup.xml
new file mode 100644
index 0000000000000..c4a0b4536fe20
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminAssertShipmentItemsActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminCreateShipmentFromOrderPageActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminCreateShipmentFromOrderPageActionGroup.xml
new file mode 100644
index 0000000000000..0e1358651c58a
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AdminCreateShipmentFromOrderPageActionGroup.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AssertThereIsNoShipButtonActionGroup.xml b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AssertThereIsNoShipButtonActionGroup.xml
new file mode 100644
index 0000000000000..10521769c5070
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/ActionGroup/AssertThereIsNoShipButtonActionGroup.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentsGridPage.xml b/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentsGridPage.xml
new file mode 100644
index 0000000000000..61aad55401248
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/Page/AdminShipmentsGridPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentItemsSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentItemsSection.xml
index 0345c3f2949f4..3630de8978924 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentItemsSection.xml
+++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentItemsSection.xml
@@ -16,5 +16,6 @@
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentPaymentShippingSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentPaymentShippingSection.xml
index 48c7106c2d65e..eb94014d7a50c 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentPaymentShippingSection.xml
+++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentPaymentShippingSection.xml
@@ -17,7 +17,7 @@
-
+
\ No newline at end of file
diff --git a/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentsGridSection.xml b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentsGridSection.xml
new file mode 100644
index 0000000000000..84aed3052c736
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/Section/AdminShipmentsGridSection.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml
new file mode 100644
index 0000000000000..98fd20b3368c2
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml
new file mode 100644
index 0000000000000..6dfccc3171758
--- /dev/null
+++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml
index 06acf95effdbf..032651c818b91 100644
--- a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml
@@ -8,7 +8,7 @@
- test_type:extended_acceptance_test
+ test_type:extended_acceptance_test, mftf_migrated:yes
default
catalogProductSimple::default
1
@@ -38,6 +38,7 @@
+ mftf_migrated:yes
From 3cb1ab2dffd1b3290fd896704129f75a4f24dd54 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 26 Aug 2019 15:30:57 -0500
Subject: [PATCH 0081/1978] MC-18685: Remove custom layout updates from admin
---
.../Page/CustomLayout/CustomLayoutManager.php | 62 +++++++++++++------
app/code/Magento/Cms/etc/di.xml | 5 --
.../Model/Page/CustomLayoutManagerTest.php | 19 +++---
.../Model/Page/CustomLayoutRepositoryTest.php | 22 ++++---
.../Framework/View/Model/Layout/Merge.php | 15 +++++
5 files changed, 80 insertions(+), 43 deletions(-)
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
index 8bf902f009bc8..d11d86433152d 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
@@ -15,20 +15,15 @@
use Magento\Framework\App\Area;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
use Magento\Framework\View\DesignInterface;
-use Magento\Framework\View\File;
-use Magento\Framework\View\File\CollectorInterface;
use Magento\Framework\View\Result\Page as PageLayout;
+use Magento\Framework\View\Model\Layout\Merge as LayoutProcessor;
+use Magento\Framework\View\Model\Layout\MergeFactory as LayoutProcessorFactory;
/**
* @inheritDoc
*/
class CustomLayoutManager implements CustomLayoutManagerInterface
{
- /**
- * @var CollectorInterface
- */
- private $fileCollector;
-
/**
* @var FlyweightFactory
*/
@@ -45,21 +40,31 @@ class CustomLayoutManager implements CustomLayoutManagerInterface
private $pageRepository;
/**
- * @param CollectorInterface $fileCollector
+ * @var LayoutProcessorFactory
+ */
+ private $layoutProcessorFactory;
+
+ /**
+ * @var LayoutProcessor|null
+ */
+ private $layoutProcessor;
+
+ /**
* @param FlyweightFactory $themeFactory
* @param DesignInterface $design
* @param PageRepositoryInterface $pageRepository
+ * @param LayoutProcessorFactory $layoutProcessorFactory
*/
public function __construct(
- CollectorInterface $fileCollector,
FlyweightFactory $themeFactory,
DesignInterface $design,
- PageRepositoryInterface $pageRepository
+ PageRepositoryInterface $pageRepository,
+ LayoutProcessorFactory $layoutProcessorFactory
) {
- $this->fileCollector = $fileCollector;
$this->themeFactory = $themeFactory;
$this->design = $design;
$this->pageRepository = $pageRepository;
+ $this->layoutProcessorFactory = $layoutProcessorFactory;
}
/**
@@ -73,23 +78,42 @@ private function sanitizeIdentifier(PageInterface $page): string
return str_replace('/', '_', $page->getIdentifier());
}
+ /**
+ * Get the processor instance.
+ *
+ * @return LayoutProcessor
+ */
+ private function getLayoutProcessor(): LayoutProcessor
+ {
+ if (!$this->layoutProcessor) {
+ $this->layoutProcessor = $this->layoutProcessorFactory->create(
+ [
+ 'theme' => $this->themeFactory->create(
+ $this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND)
+ )
+ ]
+ );
+ $this->themeFactory = null;
+ $this->design = null;
+ }
+
+ return $this->layoutProcessor;
+ }
+
/**
* @inheritDoc
*/
public function fetchAvailableFiles(PageInterface $page): array
{
$identifier = $this->sanitizeIdentifier($page);
- $layoutFiles = $this->fileCollector->getFiles(
- $this->themeFactory->create($this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND)),
- 'cms_page_view_selectable_' .$identifier .'_*.xml'
- );
+ $handles = $this->getLayoutProcessor()->getAvailableHandles();
return array_filter(
array_map(
- function (File $file) use ($identifier) : ?string {
+ function (string $handle) use ($identifier) : ?string {
preg_match(
- '/selectable\_' .preg_quote($identifier) .'\_([a-z0-9]+)/i',
- $file->getName(),
+ '/^cms\_page\_view\_selectable\_' .preg_quote($identifier) .'\_([a-z0-9]+)/i',
+ $handle,
$selectable
);
if (!empty($selectable[1])) {
@@ -98,7 +122,7 @@ function (File $file) use ($identifier) : ?string {
return null;
},
- $layoutFiles
+ $handles
)
);
}
diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml
index ef95a004102ac..fdefa3fa0daee 100644
--- a/app/code/Magento/Cms/etc/di.xml
+++ b/app/code/Magento/Cms/etc/di.xml
@@ -236,10 +236,5 @@
-
-
- Magento\Framework\View\Layout\File\Collector\Aggregated\Proxy
-
-
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
index 7e405725a2d8b..966afa0febc1c 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
@@ -13,9 +13,9 @@
use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelected;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
-use Magento\Framework\View\File\CollectorInterface;
-use Magento\Framework\View\File;
use Magento\Framework\View\Result\PageFactory as PageResultFactory;
+use Magento\Framework\View\Model\Layout\MergeFactory;
+use Magento\Framework\View\Model\Layout\Merge;
/**
* Test the manager.
@@ -50,17 +50,18 @@ protected function setUp()
$objectManager = Bootstrap::getObjectManager();
$this->resultFactory = $objectManager->get(PageResultFactory::class);
//Mocking available list of files for the page.
- $files = [
- new File('cms_page_view_selectable_page100_select1.xml', 'test'),
- new File('cms_page_view_selectable_page100_select2.xml', 'test')
+ $handles = [
+ 'cms_page_view_selectable_page100_select1',
+ 'cms_page_view_selectable_page100_select2'
];
- $fileCollector = $this->getMockForAbstractClass(CollectorInterface::class);
- $fileCollector->method('getFiles')
- ->willReturn($files);
+ $processor = $this->getMockBuilder(Merge::class)->disableOriginalConstructor()->getMock();
+ $processor->method('getAvailableHandles')->willReturn($handles);
+ $processorFactory = $this->getMockBuilder(MergeFactory::class)->disableOriginalConstructor()->getMock();
+ $processorFactory->method('create')->willReturn($processor);
$this->manager = $objectManager->create(
CustomLayoutManagerInterface::class,
- ['fileCollector' => $fileCollector]
+ ['layoutProcessorFactory' => $processorFactory]
);
$this->repo = $objectManager->create(
CustomLayoutRepositoryInterface::class,
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
index 4736774ea0f02..12b436fd32411 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
@@ -12,10 +12,10 @@
use Magento\Cms\Model\PageFactory;
use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelected;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\View\Model\Layout\Merge;
+use Magento\Framework\View\Model\Layout\MergeFactory;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
-use Magento\Framework\View\File\CollectorInterface;
-use Magento\Framework\View\File;
/**
* Test the repository.
@@ -38,20 +38,22 @@ class CustomLayoutRepositoryTest extends TestCase
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
+
//Mocking available list of files for the page.
- $files = [
- new File('cms_page_view_selectable_page100_select1.xml', 'test'),
- new File('cms_page_view_selectable_page100_select2.xml', 'test')
+ $handles = [
+ 'cms_page_view_selectable_page100_select1',
+ 'cms_page_view_selectable_page100_select2'
];
- $fileCollector = $this->getMockForAbstractClass(CollectorInterface::class);
- $fileCollector->method('getFiles')
- ->willReturn($files);
-
+ $processor = $this->getMockBuilder(Merge::class)->disableOriginalConstructor()->getMock();
+ $processor->method('getAvailableHandles')->willReturn($handles);
+ $processorFactory = $this->getMockBuilder(MergeFactory::class)->disableOriginalConstructor()->getMock();
+ $processorFactory->method('create')->willReturn($processor);
$manager = $objectManager->create(
CustomLayoutManagerInterface::class,
- ['fileCollector' => $fileCollector]
+ ['layoutProcessorFactory' => $processorFactory]
);
$this->repo = $objectManager->create(CustomLayoutRepositoryInterface::class, ['manager' => $manager]);
+
$this->pageFactory = $objectManager->get(PageFactory::class);
}
diff --git a/lib/internal/Magento/Framework/View/Model/Layout/Merge.php b/lib/internal/Magento/Framework/View/Model/Layout/Merge.php
index d307935375f41..fe79976039a9c 100644
--- a/lib/internal/Magento/Framework/View/Model/Layout/Merge.php
+++ b/lib/internal/Magento/Framework/View/Model/Layout/Merge.php
@@ -382,6 +382,21 @@ public function getPageHandles()
return $this->pageHandles;
}
+ /**
+ * List of all available layout handles.
+ *
+ * @return string[]
+ */
+ public function getAvailableHandles(): array
+ {
+ $handles = [];
+ $nodes = $this->getFileLayoutUpdatesXml()->xpath('/layouts/handle[@id]');
+ foreach ($nodes as $node) {
+ $handles[] = (string)$node->attributes()->id;
+ }
+ return $handles;
+ }
+
/**
* Retrieve all design abstractions that exist in the system.
*
From af0558bad7cded65998aabfeefffdc5f53a9ba3a Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 26 Aug 2019 16:38:43 -0500
Subject: [PATCH 0082/1978] MC-18685: Remove custom layout updates from admin
---
.../Product/Attribute/LayoutUpdateManager.php | 140 ++++++++++++++++++
.../Product/Attribute/Source/LayoutUpdate.php | 24 +++
.../Product/Form/Modifier/LayoutUpdate.php | 56 +++++++
app/code/Magento/Catalog/etc/adminhtml/di.xml | 4 +
4 files changed, 224 insertions(+)
create mode 100644 app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
create mode 100644 app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
new file mode 100644
index 0000000000000..c0c0c444c6b8b
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -0,0 +1,140 @@
+themeFactory = $themeFactory;
+ $this->design = $design;
+ $this->layoutProcessorFactory = $layoutProcessorFactory;
+ }
+
+ /**
+ * Adopt product's SKU to be used as layout handle.
+ *
+ * @param ProductInterface $product
+ * @return string
+ */
+ private function sanitizeSku(ProductInterface $product): string
+ {
+ return rawurlencode($product->getSku());
+ }
+
+ /**
+ * Get the processor instance.
+ *
+ * @return LayoutProcessor
+ */
+ private function getLayoutProcessor(): LayoutProcessor
+ {
+ if (!$this->layoutProcessor) {
+ $this->layoutProcessor = $this->layoutProcessorFactory->create(
+ [
+ 'theme' => $this->themeFactory->create(
+ $this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND)
+ )
+ ]
+ );
+ $this->themeFactory = null;
+ $this->design = null;
+ }
+
+ return $this->layoutProcessor;
+ }
+
+ /**
+ * Fetch list of available files/handles for the product.
+ *
+ * @param ProductInterface $product
+ * @return string[]
+ */
+ public function fetchAvailableFiles(ProductInterface $product): array
+ {
+ $identifier = $this->sanitizeSku($product);
+ $handles = $this->getLayoutProcessor()->getAvailableHandles();
+
+ return array_filter(
+ array_map(
+ function (string $handle) use ($identifier) : ?string {
+ preg_match(
+ '/^catalog\_product\_view\_selectable\_' .preg_quote($identifier) .'\_([a-z0-9]+)/i',
+ $handle,
+ $selectable
+ );
+ if (!empty($selectable[1])) {
+ return $selectable[1];
+ }
+
+ return null;
+ },
+ $handles
+ )
+ );
+ }
+
+ /**
+ * Apply selected custom layout updates.
+ *
+ * If no update is selected none will apply.
+ *
+ * @param PageLayout $layout
+ * @param ProductInterface $product
+ * @return void
+ */
+ public function applyUpdate(PageLayout $layout, ProductInterface $product): void
+ {
+ if ($attribute = $product->getCustomAttribute('custom_layout_update_file')) {
+ $layout->addPageLayoutHandles(
+ ['selectable' => $this->sanitizeIdentifier($product) . '_' . $attribute->getValue()]
+ );
+ }
+ }
+}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index 214348890cf2a..d63e77286498b 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -8,6 +8,7 @@
namespace Magento\Catalog\Model\Product\Attribute\Source;
+use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Framework\Api\CustomAttributesDataInterface;
@@ -22,6 +23,19 @@ class LayoutUpdate extends AbstractSource implements SpecificSourceInterface
*/
private $optionsText;
+ /**
+ * @var LayoutUpdateManager
+ */
+ private $manager;
+
+ /**
+ * @param LayoutUpdateManager $manager
+ */
+ public function __construct(LayoutUpdateManager $manager)
+ {
+ $this->manager = $manager;
+ }
+
/**
* @inheritDoc
*/
@@ -52,6 +66,16 @@ public function getOptionText($value)
public function getOptionsFor(CustomAttributesDataInterface $entity): array
{
$options = $this->getAllOptions();
+ if ($entity->getCustomAttribute('custom_layout_update')) {
+ $existingValue = '__existing__';
+ $existingLabel = 'Use existing';
+ $options[] = ['label' => $existingLabel, 'value' => $existingValue];
+ $this->optionsText[$existingValue] = $existingLabel;
+ }
+ foreach ($this->manager->fetchAvailableFiles($entity) as $handle) {
+ $options[] = ['label' => $handle, 'value' => $handle];
+ $this->optionsText[$handle] = $handle;
+ }
return $options;
}
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
new file mode 100644
index 0000000000000..92afe35c70bb5
--- /dev/null
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
@@ -0,0 +1,56 @@
+locator = $locator;
+ }
+
+ /**
+ * @inheritdoc
+ * @since 101.1.0
+ */
+ public function modifyData(array $data)
+ {
+ $product = $this->locator->getProduct();
+ if ($oldLayout = $product->getCustomAttribute('custom_layout_update')) {
+ if ($oldLayout->getValue()) {
+ $data[$product->getId()][AbstractModifier::DATA_SOURCE_DEFAULT]['custom_layout_update_file']
+ = '__existing__';
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function modifyMeta(array $meta)
+ {
+ return $meta;
+ }
+}
diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml
index c04cfb2dce00a..372b630c6aee9 100644
--- a/app/code/Magento/Catalog/etc/adminhtml/di.xml
+++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml
@@ -158,6 +158,10 @@
- Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\TierPrice
- 150
+ -
+
- Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\LayoutUpdate
+ - 160
+
From ffa865f1edcc7ffe4041ac84575ac7df32c043e6 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Tue, 27 Aug 2019 14:34:06 +0400
Subject: [PATCH 0083/1978] MC-18820: Increase test coverage for Admin
functional area
- Automation test for MC-6310
---
.../Mftf/Section/LocaleOptionsSection.xml | 1 +
.../Test/Mftf/Data/CatalogSearchData.xml | 9 ++-
.../Mftf/Metadata/catalog_search-meta.xml | 11 ++++
.../AdminElasticConnectionTestActionGroup.xml | 22 +++++++
...AdminCatalogSearchConfigurationSection.xml | 15 +++++
...frontElasticSearchForChineseLocaleTest.xml | 63 +++++++++++++++++++
6 files changed, 119 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
create mode 100644 app/code/Magento/Elasticsearch6/Test/Mftf/Section/AdminCatalogSearchConfigurationSection.xml
create mode 100644 app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/LocaleOptionsSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/LocaleOptionsSection.xml
index a460aaebf1051..bd2a345c99660 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/LocaleOptionsSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/LocaleOptionsSection.xml
@@ -12,5 +12,6 @@
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
index 6868456079110..7e86ade93ad44 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
@@ -23,5 +23,10 @@
1
-
-
\ No newline at end of file
+
+ DefaultCatalogSearchEngine
+
+
+ true
+
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
index 7405377249aa4..ce869f81a23df 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
@@ -29,4 +29,15 @@
+
+
+
+
+
+ boolean
+
+
+
+
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
new file mode 100644
index 0000000000000..e40bf3691e8db
--- /dev/null
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Section/AdminCatalogSearchConfigurationSection.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Section/AdminCatalogSearchConfigurationSection.xml
new file mode 100644
index 0000000000000..a6f35606ed79b
--- /dev/null
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Section/AdminCatalogSearchConfigurationSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml
new file mode 100644
index 0000000000000..1acdaa8ce2b33
--- /dev/null
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml
@@ -0,0 +1,63 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 9765c088c8654d0b3e909d1786e9bee68f2284d5 Mon Sep 17 00:00:00 2001
From: Mila Lesechko
Date: Tue, 27 Aug 2019 21:19:16 -0500
Subject: [PATCH 0084/1978] Convert DeleteProductsFromWishlistOnFrontendTest to
MFTF
---
...orefrontCustomerWishlistProductSection.xml | 1 +
...teBundleDynamicProductFromWishlistTest.xml | 95 +++++++++++
...leteBundleFixedProductFromWishlistTest.xml | 87 ++++++++++
...eteConfigurableProductFromWishlistTest.xml | 149 ++++++++++++++++++
...leteProductsFromWishlistOnFrontendTest.xml | 3 +
5 files changed, 335 insertions(+)
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml b/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml
index 0b6c2f1191c40..73a82e8976fc7 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml
@@ -24,5 +24,6 @@
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml
new file mode 100644
index 0000000000000..88621b241db89
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100.00
+
+
+ 100.00
+
+
+
+
+
+
+
+ True
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml
new file mode 100644
index 0000000000000..cb8b5b1de859f
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100.00
+
+
+ 100.00
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml
new file mode 100644
index 0000000000000..f23f09129cb63
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml
@@ -0,0 +1,149 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.00
+
+
+
+
+
+
+ 20.00
+
+
+
+
+
+
+ 30.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductsFromWishlistOnFrontendTest.xml b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductsFromWishlistOnFrontendTest.xml
index d6b930d999537..26593636d3fcb 100644
--- a/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductsFromWishlistOnFrontendTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Wishlist/Test/TestCase/DeleteProductsFromWishlistOnFrontendTest.xml
@@ -39,6 +39,7 @@
+ mftf_migrated:yes
bundleProduct::bundle_dynamic_product
- 1
@@ -46,6 +47,7 @@
+ mftf_migrated:yes
bundleProduct::bundle_fixed_product
- 1
@@ -53,6 +55,7 @@
+ mftf_migrated:yes
configurableProduct::default
- 1
From 20567da3428c0ee720c3c5804d6d36d0b6ead089 Mon Sep 17 00:00:00 2001
From: Mila Lesechko
Date: Tue, 27 Aug 2019 21:43:54 -0500
Subject: [PATCH 0085/1978] Convert MoveProductFromShoppingCartToWishlistTest
to MFTF
---
.../Section/CheckoutCartProductSection.xml | 1 +
...orefrontCustomerWishlistProductSection.xml | 3 +
...eProductFromShoppingCartToWishlistTest.xml | 164 ++++++++++++++++++
...eProductFromShoppingCartToWishlistTest.xml | 110 ++++++++++++
...eProductFromShoppingCartToWishlistTest.xml | 101 +++++++++++
...lProductFromShoppingCartToWishlistTest.xml | 71 ++++++++
...eProductFromShoppingCartToWishlistTest.xml | 5 +-
7 files changed, 454 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveConfigurableProductFromShoppingCartToWishlistTest.xml
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveDynamicBundleProductFromShoppingCartToWishlistTest.xml
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveFixedBundleProductFromShoppingCartToWishlistTest.xml
create mode 100644 app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveVirtualProductFromShoppingCartToWishlistTest.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml
index 3ab3fa5857b78..f028fae1f1f21 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartProductSection.xml
@@ -32,6 +32,7 @@
selector="//table[@id='shopping-cart-table']//tbody//tr[contains(@class,'item-actions')]//a[contains(@class,'action-delete')]"/>
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml b/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml
index 0b6c2f1191c40..dba0acfc29e8e 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Section/StorefrontCustomerWishlistProductSection.xml
@@ -24,5 +24,8 @@
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveConfigurableProductFromShoppingCartToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveConfigurableProductFromShoppingCartToWishlistTest.xml
new file mode 100644
index 0000000000000..317f937def3f1
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveConfigurableProductFromShoppingCartToWishlistTest.xml
@@ -0,0 +1,164 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 10.00
+
+
+
+
+
+
+ 20.00
+
+
+
+
+
+
+ 30.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveDynamicBundleProductFromShoppingCartToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveDynamicBundleProductFromShoppingCartToWishlistTest.xml
new file mode 100644
index 0000000000000..dcd69a61e596f
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveDynamicBundleProductFromShoppingCartToWishlistTest.xml
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100.00
+
+
+ 20.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveFixedBundleProductFromShoppingCartToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveFixedBundleProductFromShoppingCartToWishlistTest.xml
new file mode 100644
index 0000000000000..4d99b05e9aa6a
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveFixedBundleProductFromShoppingCartToWishlistTest.xml
@@ -0,0 +1,101 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ 100
+
+
+
+
+
+ 0
+ 100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveVirtualProductFromShoppingCartToWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveVirtualProductFromShoppingCartToWishlistTest.xml
new file mode 100644
index 0000000000000..baaae80f7d081
--- /dev/null
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontMoveVirtualProductFromShoppingCartToWishlistTest.xml
@@ -0,0 +1,71 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 40
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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 95e6a854ed266..aa3b646161a17 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
@@ -15,6 +15,7 @@
+ mftf_migrated:yes
catalogProductVirtual::default
@@ -29,7 +30,7 @@
- test_type:extended_acceptance_test
+ test_type:extended_acceptance_test, mftf_migrated:yes
configurableProduct::default
@@ -37,6 +38,7 @@
+ mftf_migrated:yes
bundleProduct::bundle_dynamic_product
@@ -44,6 +46,7 @@
+ mftf_migrated:yes
bundleProduct::bundle_fixed_product
From 18dabb18c584a56942660a525370fac3db2a7260 Mon Sep 17 00:00:00 2001
From: Mila Lesechko
Date: Tue, 27 Aug 2019 21:57:50 -0500
Subject: [PATCH 0086/1978] Convert ExpireSessionTest to MFTF
---
.../Test/Mftf/Data/CookieConfigData.xml | 16 +++++++
.../Mftf/Section/AdminLoginFormSection.xml | 1 +
.../Mftf/Test/AdminExpireAdminSessionTest.xml | 36 ++++++++++++++
.../Test/AdminExpireCustomerSessionTest.xml | 47 +++++++++++++++++++
.../Test/TestCase/ExpireSessionTest.xml | 2 +
5 files changed, 102 insertions(+)
create mode 100644 app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
create mode 100644 app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
diff --git a/app/code/Magento/Backend/Test/Mftf/Data/CookieConfigData.xml b/app/code/Magento/Backend/Test/Mftf/Data/CookieConfigData.xml
index 52a6c27a37ea8..a844e962202f8 100644
--- a/app/code/Magento/Backend/Test/Mftf/Data/CookieConfigData.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Data/CookieConfigData.xml
@@ -20,4 +20,20 @@
base
''
+
+ web/cookie/cookie_lifetime
+ 60
+
+
+ web/cookie/cookie_lifetime
+ 3600
+
+
+ admin/security/session_lifetime
+ 60
+
+
+ admin/security/session_lifetime
+ 7200
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminLoginFormSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminLoginFormSection.xml
index bd65dea89abc2..0ad63c0f0d23a 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminLoginFormSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminLoginFormSection.xml
@@ -13,5 +13,6 @@
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
new file mode 100644
index 0000000000000..1ed8cc9e9aa6d
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
new file mode 100644
index 0000000000000..9e3301e4a26a3
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml
index e67ceb99f2eef..195d1330ae78a 100644
--- a/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Backend/Test/TestCase/ExpireSessionTest.xml
@@ -8,12 +8,14 @@
+ mftf_migrated:yes
default_cookie_lifetime_60_seconds
default
60
+ mftf_migrated:yes
admin_session_lifetime_60_seconds
60
From ff7c3c9b8d9b1732cd5b69142a856ad27c0b839e Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 28 Aug 2019 13:27:16 +0300
Subject: [PATCH 0087/1978] Convert DeleteCategoryUrlRewriteEntityTest to MFTF
---
...dminDeleteCategoryUrlRewriteEntityTest.xml | 75 +++++++++++++++++++
.../DeleteCategoryUrlRewriteEntityTest.xml | 2 +
2 files changed, 77 insertions(+)
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml
new file mode 100644
index 0000000000000..d0e976a1f9e3d
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml
@@ -0,0 +1,75 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.xml b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.xml
index 56440e8a8492b..42f71b8d01f76 100644
--- a/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/UrlRewrite/Test/TestCase/DeleteCategoryUrlRewriteEntityTest.xml
@@ -8,6 +8,7 @@
+ mftf_migrated:yes
catalog/category/view/id/%category::default%
No
-
@@ -15,6 +16,7 @@
+ mftf_migrated:yes
catalog/category/view/id/%category::default%
No
example%isolation%.html
From f208cf5d0db47c13a70fe4e3cf7e3dd3763c6424 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 28 Aug 2019 16:32:48 +0300
Subject: [PATCH 0088/1978] Working on the test
---
...dminAddUrlRewriteForCmsPageActionGroup.xml | 40 ++++++++
.../Section/AdminUrlRewriteEditSection.xml | 1 +
...AdminDeleteCmsPageUrlRewriteEntityTest.xml | 99 +++++++++++++++++++
3 files changed, 140 insertions(+)
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForCmsPageActionGroup.xml
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCmsPageUrlRewriteEntityTest.xml
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForCmsPageActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForCmsPageActionGroup.xml
new file mode 100644
index 0000000000000..f46bd7f5e0386
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminAddUrlRewriteForCmsPageActionGroup.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+ Goes to the Admin Add URL Rewrite edit page. Fills in the provided URL details. Clicks on Save. Validates that the Success Message is present.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Section/AdminUrlRewriteEditSection.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Section/AdminUrlRewriteEditSection.xml
index 52939607f5377..5a55562e99334 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Section/AdminUrlRewriteEditSection.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Section/AdminUrlRewriteEditSection.xml
@@ -19,6 +19,7 @@
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCmsPageUrlRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCmsPageUrlRewriteEntityTest.xml
new file mode 100644
index 0000000000000..705786afa83bb
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCmsPageUrlRewriteEntityTest.xml
@@ -0,0 +1,99 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 4cfb89e852acd29a676f8bff8c9d614db0c29a83 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 28 Aug 2019 10:51:07 -0500
Subject: [PATCH 0089/1978] MC-18685: Remove custom layout updates from admin
---
.../Magento/Catalog/Helper/Product/View.php | 19 ++-
.../Attribute/Backend/Customlayoutupdate.php | 20 +++
.../Attribute/Backend/LayoutUpdate.php | 69 +++++++++-
.../Attribute/LayoutUpdateManager.php | 128 ++++++++++++++++++
.../Attribute/Source/LayoutUpdate.php | 2 +-
.../Catalog/Model/Category/DataProvider.php | 5 +
.../Attribute/Backend/LayoutUpdate.php | 67 ++++++++-
.../Product/Attribute/LayoutUpdateManager.php | 2 +-
.../Product/Attribute/Source/LayoutUpdate.php | 2 +-
...oduct_view_selectable_1_testupdateprod.xml | 25 ++++
.../templates/product/view/rev1.phtml | 8 ++
11 files changed, 336 insertions(+), 11 deletions(-)
create mode 100644 app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
create mode 100644 app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml
create mode 100644 app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml
diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php
index 74f40a18971d5..98b1cc01c11a7 100644
--- a/app/code/Magento/Catalog/Helper/Product/View.php
+++ b/app/code/Magento/Catalog/Helper/Product/View.php
@@ -6,6 +6,8 @@
namespace Magento\Catalog\Helper\Product;
+use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Result\Page as ResultPage;
/**
@@ -66,6 +68,11 @@ class View extends \Magento\Framework\App\Helper\AbstractHelper
*/
private $string;
+ /**
+ * @var LayoutUpdateManager
+ */
+ private $layoutUpdateManager;
+
/**
* Constructor
*
@@ -78,6 +85,7 @@ class View extends \Magento\Framework\App\Helper\AbstractHelper
* @param \Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator
* @param array $messageGroups
* @param \Magento\Framework\Stdlib\StringUtils|null $string
+ * @param LayoutUpdateManager|null $layoutUpdateManager
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
@@ -88,7 +96,8 @@ public function __construct(
\Magento\Framework\Message\ManagerInterface $messageManager,
\Magento\CatalogUrlRewrite\Model\CategoryUrlPathGenerator $categoryUrlPathGenerator,
array $messageGroups = [],
- \Magento\Framework\Stdlib\StringUtils $string = null
+ \Magento\Framework\Stdlib\StringUtils $string = null,
+ ?LayoutUpdateManager $layoutUpdateManager = null
) {
$this->_catalogSession = $catalogSession;
$this->_catalogDesign = $catalogDesign;
@@ -97,8 +106,9 @@ public function __construct(
$this->messageGroups = $messageGroups;
$this->messageManager = $messageManager;
$this->categoryUrlPathGenerator = $categoryUrlPathGenerator;
- $this->string = $string ?: \Magento\Framework\App\ObjectManager::getInstance()
- ->get(\Magento\Framework\Stdlib\StringUtils::class);
+ $this->string = $string ?: ObjectManager::getInstance()->get(\Magento\Framework\Stdlib\StringUtils::class);
+ $this->layoutUpdateManager = $layoutUpdateManager
+ ?? ObjectManager::getInstance()->get(LayoutUpdateManager::class);
parent::__construct($context);
}
@@ -204,6 +214,9 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
}
}
+ //Apply selected layout update
+ $this->layoutUpdateManager->applyUpdate($resultPage, $product);
+
$currentCategory = $this->_coreRegistry->registry('current_category');
$controllerClass = $this->_request->getFullActionName();
if ($controllerClass != 'catalog-product-view') {
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index a994446881189..2dc31e480055c 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Catalog\Model\Attribute\Backend;
+use Magento\Catalog\Model\AbstractModel;
+use Magento\Catalog\Model\Category;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Model\Layout\Update\ValidatorFactory;
use Magento\Eav\Model\Entity\Attribute\Exception;
@@ -63,4 +66,21 @@ public function validate($object)
}
return true;
}
+
+ /**
+ * @inheritDoc
+ * @param AbstractModel $object
+ * @throws LocalizedException
+ */
+ public function beforeSave($object)
+ {
+ $attributeName = $this->getAttribute()->getName();
+ if ($object->getData($attributeName)
+ && $object->getOrigData($attributeName) !== $object->getData($attributeName)
+ ) {
+ throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
+ }
+
+ return parent::beforeSave($object);
+ }
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index c34bddbe11d33..3447c91043b8e 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -10,12 +10,65 @@
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
+use Magento\Framework\Exception\LocalizedException;
/**
- * Allows to select a layout file to merge when rendering a category's page.
+ * Allows to select a layout file to merge when rendering the category's page.
*/
class LayoutUpdate extends AbstractBackend
{
+ private const VALUE_USE_UPDATE_XML = '__existing__';
+
+ /**
+ * @var LayoutUpdateManager
+ */
+ private $manager;
+
+ /**
+ * @param LayoutUpdateManager $manager
+ */
+ public function __construct(LayoutUpdateManager $manager)
+ {
+ $this->manager = $manager;
+ }
+
+ /**
+ * Extracts the attributes value from given entity.
+ *
+ * @throws LocalizedException
+ * @param Category $category
+ * @return string|null
+ */
+ private function extractValue(Category $category): ?string
+ {
+ $attrCode = $this->getAttribute()->getAttributeCode();
+ $value = $category->getData($attrCode);
+ if ($value
+ && $value !== self::VALUE_USE_UPDATE_XML
+ && !in_array($value, $this->manager->fetchAvailableFiles($category), true)
+ ) {
+ throw new LocalizedException(__('Selected layout update is not available'));
+ }
+ if (!$value) {
+ $value = null;
+ }
+
+ return $value;
+ }
+
+ /**
+ * Set value for the object.
+ *
+ * @param string|null $value
+ * @param Category $object
+ */
+ private function setValue(?string $value, Category $object): void
+ {
+ $attrCode = $this->getAttribute()->getAttributeCode();
+ $object->setData($attrCode, $value);
+ }
+
/**
* @inheritDoc
* @param Category $object
@@ -23,7 +76,9 @@ class LayoutUpdate extends AbstractBackend
public function validate($object)
{
$valid = parent::validate($object);
-
+ if ($valid) {
+ $this->extractValue($object);
+ }
return $valid;
}
@@ -31,10 +86,18 @@ public function validate($object)
/**
* @inheritDoc
* @param Category $object
+ * @throws LocalizedException
*/
public function beforeSave($object)
{
- parent::beforeSave($object);
+ $value = $this->extractValue($object);
+ if ($value !== self::VALUE_USE_UPDATE_XML) {
+ $object->setCustomAttribute('custom_layout_update', null);
+ $object->setData('custom_layout_update', null);
+ } else {
+ $value = null;
+ }
+ $this->setValue($value, $object);
return $this;
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
new file mode 100644
index 0000000000000..6bcf0ea0f442e
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
@@ -0,0 +1,128 @@
+themeFactory = $themeFactory;
+ $this->design = $design;
+ $this->layoutProcessorFactory = $layoutProcessorFactory;
+ }
+
+ /**
+ * Get the processor instance.
+ *
+ * @return LayoutProcessor
+ */
+ private function getLayoutProcessor(): LayoutProcessor
+ {
+ if (!$this->layoutProcessor) {
+ $this->layoutProcessor = $this->layoutProcessorFactory->create(
+ [
+ 'theme' => $this->themeFactory->create(
+ $this->design->getConfigurationDesignTheme(Area::AREA_FRONTEND)
+ )
+ ]
+ );
+ $this->themeFactory = null;
+ $this->design = null;
+ }
+
+ return $this->layoutProcessor;
+ }
+
+ /**
+ * Fetch list of available files/handles for the category.
+ *
+ * @param CategoryInterface $category
+ * @return string[]
+ */
+ public function fetchAvailableFiles(CategoryInterface $category): array
+ {
+ $handles = $this->getLayoutProcessor()->getAvailableHandles();
+
+ return array_filter(
+ array_map(
+ function (string $handle) use ($category) : ?string {
+ preg_match(
+ '/^catalog\_category\_view\_selectable\_' .$category->getId() .'\_([a-z0-9]+)/i',
+ $handle,
+ $selectable
+ );
+ if (!empty($selectable[1])) {
+ return $selectable[1];
+ }
+
+ return null;
+ },
+ $handles
+ )
+ );
+ }
+
+ /**
+ * Apply selected custom layout updates.
+ *
+ * If no update is selected none will apply.
+ *
+ * @param PageLayout $layout
+ * @param CategoryInterface $category
+ * @return void
+ */
+ public function applyUpdate(PageLayout $layout, CategoryInterface $category): void
+ {
+ if ($attribute = $category->getCustomAttribute('custom_layout_update_file')) {
+ $layout->addPageLayoutHandles(
+ ['selectable' => $category->getId() . '_' . $attribute->getValue()]
+ );
+ }
+ }
+}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index 2030e05b74925..f8281983df777 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -22,7 +22,7 @@ class LayoutUpdate extends AbstractSource implements SpecificSourceInterface
*/
public function getAllOptions()
{
- $options = [['label' => 'Use default', 'value' => '']];
+ $options = [['label' => 'No update', 'value' => '']];
return $options;
}
diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php
index c96b2aae36059..719e49449730f 100644
--- a/app/code/Magento/Catalog/Model/Category/DataProvider.php
+++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php
@@ -535,6 +535,11 @@ private function convertValues($category, $categoryData)
$categoryData[$attributeCode][0]['type'] = $mime;
}
}
+ if ($attributeCode === 'custom_layout_update_file') {
+ if (!empty($categoryData['custom_layout_update'])) {
+ $categoryData['custom_layout_update_file'] = '__existing__';
+ }
+ }
}
return $categoryData;
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index d8c9b7e2ae59f..6841900b30033 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -10,12 +10,65 @@
use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
+use Magento\Framework\Exception\LocalizedException;
/**
* Allows to select a layout file to merge when rendering the product's page.
*/
class LayoutUpdate extends AbstractBackend
{
+ private const VALUE_USE_UPDATE_XML = '__existing__';
+
+ /**
+ * @var LayoutUpdateManager
+ */
+ private $manager;
+
+ /**
+ * @param LayoutUpdateManager $manager
+ */
+ public function __construct(LayoutUpdateManager $manager)
+ {
+ $this->manager = $manager;
+ }
+
+ /**
+ * Extracts the attributes value from given entity.
+ *
+ * @throws LocalizedException
+ * @param Product $product
+ * @return string|null
+ */
+ private function extractValue(Product $product): ?string
+ {
+ $attrCode = $this->getAttribute()->getAttributeCode();
+ $value = $product->getData($attrCode);
+ if ($value
+ && $value !== self::VALUE_USE_UPDATE_XML
+ && !in_array($value, $this->manager->fetchAvailableFiles($product), true)
+ ) {
+ throw new LocalizedException(__('Selected layout update is not available'));
+ }
+ if (!$value) {
+ $value = null;
+ }
+
+ return $value;
+ }
+
+ /**
+ * Set value for the object.
+ *
+ * @param string|null $value
+ * @param Product $object
+ */
+ private function setValue(?string $value, Product $object): void
+ {
+ $attrCode = $this->getAttribute()->getAttributeCode();
+ $object->setData($attrCode, $value);
+ }
+
/**
* @inheritDoc
* @param Product $object
@@ -23,7 +76,9 @@ class LayoutUpdate extends AbstractBackend
public function validate($object)
{
$valid = parent::validate($object);
-
+ if ($valid) {
+ $this->extractValue($object);
+ }
return $valid;
}
@@ -31,10 +86,18 @@ public function validate($object)
/**
* @inheritDoc
* @param Product $object
+ * @throws LocalizedException
*/
public function beforeSave($object)
{
- parent::beforeSave($object);
+ $value = $this->extractValue($object);
+ if ($value !== self::VALUE_USE_UPDATE_XML) {
+ $object->setCustomAttribute('custom_layout_update', null);
+ $object->setData('custom_layout_update', null);
+ } else {
+ $value = null;
+ }
+ $this->setValue($value, $object);
return $this;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
index c0c0c444c6b8b..9fcd2c2c4c4d3 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -133,7 +133,7 @@ public function applyUpdate(PageLayout $layout, ProductInterface $product): void
{
if ($attribute = $product->getCustomAttribute('custom_layout_update_file')) {
$layout->addPageLayoutHandles(
- ['selectable' => $this->sanitizeIdentifier($product) . '_' . $attribute->getValue()]
+ ['selectable' => $this->sanitizeSku($product) . '_' . $attribute->getValue()]
);
}
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index d63e77286498b..d793e110ac25e 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -42,7 +42,7 @@ public function __construct(LayoutUpdateManager $manager)
public function getAllOptions()
{
$default = '';
- $defaultText = 'Use default';
+ $defaultText = 'No update';
$this->optionsText[$default] = $defaultText;
return [['label' => $defaultText, 'value' => $default]];
diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml
new file mode 100644
index 0000000000000..538ba470927f2
--- /dev/null
+++ b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml
@@ -0,0 +1,25 @@
+
+
+
+ TEST DDD
+
+
+
+
+
+ TEST 123
+
+
+
+
+ TESTY!!!
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml
new file mode 100644
index 0000000000000..ba933509b96a9
--- /dev/null
+++ b/app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml
@@ -0,0 +1,8 @@
+
+
+test my dust
From eb566be48767ab20e0ba0ee913d68011348eb28d Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 28 Aug 2019 10:52:21 -0500
Subject: [PATCH 0090/1978] MC-18685: Remove custom layout updates from admin
---
...oduct_view_selectable_1_testupdateprod.xml | 25 -------------------
.../templates/product/view/rev1.phtml | 8 ------
2 files changed, 33 deletions(-)
delete mode 100644 app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml
delete mode 100644 app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml
diff --git a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml b/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml
deleted file mode 100644
index 538ba470927f2..0000000000000
--- a/app/code/Magento/Catalog/view/frontend/layout/catalog_product_view_selectable_1_testupdateprod.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
- TEST DDD
-
-
-
-
-
- TEST 123
-
-
-
-
- TESTY!!!
-
-
-
-
-
diff --git a/app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml b/app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml
deleted file mode 100644
index ba933509b96a9..0000000000000
--- a/app/code/Magento/Catalog/view/frontend/templates/product/view/rev1.phtml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-test my dust
From 4674e41ea82a9e51bfb8b56c76a3533446d1c310 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 28 Aug 2019 21:12:41 +0300
Subject: [PATCH 0091/1978] Convert DeleteCmsPageUrlRewriteEntityTest to MFTF
---
.../Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.xml
index 8262d88bdff1a..ea9d49d662bdd 100644
--- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/DeleteCmsPageUrlRewriteEntityTest.xml
@@ -8,20 +8,20 @@
- severity:S2
+ severity:S2,mftf_migrated:yes
cms_default_no_redirect
- severity:S2
+ severity:S2,mftf_migrated:yes
cms_default_permanent_redirect
- severity:S2
+ severity:S2,mftf_migrated:yes
cms_default_temporary_redirect
From eca0a6aeed6237d625e0f30f7aad7e2ddc0a23bc Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 28 Aug 2019 13:35:48 -0500
Subject: [PATCH 0092/1978] MC-18685: Remove custom layout updates from admin
---
.../Catalog/Controller/Category/View.php | 17 +++++-
.../Magento/Catalog/Helper/Product/View.php | 6 +--
.../Attribute/LayoutUpdateManager.php | 12 +++--
.../Attribute/Source/LayoutUpdate.php | 53 +++++++++++++++++--
.../Catalog/Model/Category/DataProvider.php | 13 ++++-
app/code/Magento/Catalog/Model/Design.php | 39 +++++++++++---
.../Product/Attribute/LayoutUpdateManager.php | 13 +++--
.../Catalog/Model/ResourceModel/Category.php | 2 +
.../Data/UpdateCustomLayoutAttributes.php | 14 +++++
.../adminhtml/ui_component/category_form.xml | 9 ++++
10 files changed, 155 insertions(+), 23 deletions(-)
diff --git a/app/code/Magento/Catalog/Controller/Category/View.php b/app/code/Magento/Catalog/Controller/Category/View.php
index da3d99a8d2745..dff39008b539a 100644
--- a/app/code/Magento/Catalog/Controller/Category/View.php
+++ b/app/code/Magento/Catalog/Controller/Category/View.php
@@ -28,6 +28,7 @@
use Magento\Framework\View\Result\PageFactory;
use Magento\Store\Model\StoreManagerInterface;
use Psr\Log\LoggerInterface;
+use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
/**
* View a category on storefront. Needs to be accessible by POST because of the store switching.
@@ -94,6 +95,11 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter
*/
private $toolbarMemorizer;
+ /**
+ * @var LayoutUpdateManager
+ */
+ private $customLayoutManager;
+
/**
* Constructor
*
@@ -108,6 +114,7 @@ class View extends Action implements HttpGetActionInterface, HttpPostActionInter
* @param Resolver $layerResolver
* @param CategoryRepositoryInterface $categoryRepository
* @param ToolbarMemorizer|null $toolbarMemorizer
+ * @param LayoutUpdateManager|null $layoutUpdateManager
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -121,7 +128,8 @@ public function __construct(
ForwardFactory $resultForwardFactory,
Resolver $layerResolver,
CategoryRepositoryInterface $categoryRepository,
- ToolbarMemorizer $toolbarMemorizer = null
+ ToolbarMemorizer $toolbarMemorizer = null,
+ ?LayoutUpdateManager $layoutUpdateManager = null
) {
parent::__construct($context);
$this->_storeManager = $storeManager;
@@ -134,6 +142,8 @@ public function __construct(
$this->layerResolver = $layerResolver;
$this->categoryRepository = $categoryRepository;
$this->toolbarMemorizer = $toolbarMemorizer ?: $context->getObjectManager()->get(ToolbarMemorizer::class);
+ $this->customLayoutManager = $layoutUpdateManager
+ ?? $context->getObjectManager()->get(LayoutUpdateManager::class);
}
/**
@@ -258,5 +268,10 @@ private function applyLayoutUpdates(
$page->addPageLayoutHandles(['layout_update' => sha1($layoutUpdate)], null, false);
}
}
+
+ //Selected files
+ if ($settings->getPageLayoutHandles()) {
+ $page->addPageLayoutHandles($settings->getPageLayoutHandles());
+ }
}
}
diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php
index 98b1cc01c11a7..26776500438e5 100644
--- a/app/code/Magento/Catalog/Helper/Product/View.php
+++ b/app/code/Magento/Catalog/Helper/Product/View.php
@@ -213,9 +213,9 @@ public function initProductLayout(ResultPage $resultPage, $product, $params = nu
}
}
}
-
- //Apply selected layout update
- $this->layoutUpdateManager->applyUpdate($resultPage, $product);
+ if ($settings->getPageLayoutHandles()) {
+ $resultPage->addPageLayoutHandles($settings->getPageLayoutHandles());
+ }
$currentCategory = $this->_coreRegistry->registry('current_category');
$controllerClass = $this->_request->getFullActionName();
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
index 6bcf0ea0f442e..32d6068446a65 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
@@ -10,6 +10,7 @@
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Framework\App\Area;
+use Magento\Framework\DataObject;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\Model\Layout\Merge as LayoutProcessor;
@@ -109,20 +110,23 @@ function (string $handle) use ($category) : ?string {
}
/**
- * Apply selected custom layout updates.
+ * Extract selected custom layout settings.
*
* If no update is selected none will apply.
*
- * @param PageLayout $layout
* @param CategoryInterface $category
+ * @param DataObject $intoSettings
* @return void
*/
- public function applyUpdate(PageLayout $layout, CategoryInterface $category): void
+ public function extractCustomSettings(CategoryInterface $category, DataObject $intoSettings): void
{
if ($attribute = $category->getCustomAttribute('custom_layout_update_file')) {
- $layout->addPageLayoutHandles(
+ $handles = $intoSettings->getPageLayoutHandles() ?? [];
+ $handles = array_merge_recursive(
+ $handles,
['selectable' => $category->getId() . '_' . $attribute->getValue()]
);
+ $intoSettings->setPageLayoutHandles($handles);
}
}
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index f8281983df777..2375a5d36a0a8 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -8,6 +8,8 @@
namespace Magento\Catalog\Model\Category\Attribute\Source;
+use Magento\Catalog\Api\Data\CategoryInterface;
+use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Framework\Api\CustomAttributesDataInterface;
@@ -17,21 +19,66 @@
*/
class LayoutUpdate extends AbstractSource implements SpecificSourceInterface
{
+ /**
+ * @var string[]
+ */
+ private $optionsText;
+
+ /**
+ * @var LayoutUpdateManager
+ */
+ private $manager;
+
+ /**
+ * @param LayoutUpdateManager $manager
+ */
+ public function __construct(LayoutUpdateManager $manager)
+ {
+ $this->manager = $manager;
+ }
+
/**
* @inheritDoc
*/
public function getAllOptions()
{
- $options = [['label' => 'No update', 'value' => '']];
+ $default = '';
+ $defaultText = 'No update';
+ $this->optionsText[$default] = $defaultText;
- return $options;
+ return [['label' => $defaultText, 'value' => $default]];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getOptionText($value)
+ {
+ if (is_scalar($value) && array_key_exists($value, $this->optionsText)) {
+ return $this->optionsText[$value];
+ }
+
+ return false;
}
/**
* @inheritDoc
+ * @param CategoryInterface $entity
*/
public function getOptionsFor(CustomAttributesDataInterface $entity): array
{
- return $this->getAllOptions();
+ $options = $this->getAllOptions();
+ if ($entity->getCustomAttribute('custom_layout_update')) {
+ $existingValue = '__existing__';
+ $existingLabel = 'Use existing';
+ $options[] = ['label' => $existingLabel, 'value' => $existingValue];
+ $this->optionsText[$existingValue] = $existingLabel;
+ }
+ foreach ($this->manager->fetchAvailableFiles($entity) as $handle) {
+ $options[] = ['label' => $handle, 'value' => $handle];
+ $this->optionsText[$handle] = $handle;
+ }
+
+ return $options;
}
}
diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php
index 719e49449730f..cff85d6060e34 100644
--- a/app/code/Magento/Catalog/Model/Category/DataProvider.php
+++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php
@@ -15,6 +15,7 @@
use Magento\Catalog\Model\ResourceModel\Eav\Attribute as EavAttribute;
use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Eav\Model\Config;
+use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Eav\Model\Entity\Type;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -363,7 +364,16 @@ public function getAttributesMeta(Type $entityType)
: $value;
}
if ($attribute->usesSource()) {
- $meta[$code]['options'] = $attribute->getSource()->getAllOptions();
+ $source = $attribute->getSource();
+ if ($source instanceof SpecificSourceInterface) {
+ $options = $source->getOptionsFor($this->getCurrentCategory());
+ } else {
+ $options = $attribute->getSource()->getAllOptions();
+ }
+ foreach ($options as &$option) {
+ $option['__disableTmpl'] = true;
+ }
+ $meta[$code]['options'] = $options;
}
}
@@ -609,6 +619,7 @@ protected function getFieldsMap()
'custom_design',
'page_layout',
'custom_layout_update',
+ 'custom_layout_update_file'
],
'schedule_design_update' => [
'custom_design_from',
diff --git a/app/code/Magento/Catalog/Model/Design.php b/app/code/Magento/Catalog/Model/Design.php
index 853bbeac8eb38..854f8f5648926 100644
--- a/app/code/Magento/Catalog/Model/Design.php
+++ b/app/code/Magento/Catalog/Model/Design.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Catalog\Model;
+use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager as CategoryLayoutManager;
+use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager as ProductLayoutManager;
+use Magento\Framework\App\ObjectManager;
use \Magento\Framework\TranslateInterface;
/**
@@ -38,6 +41,16 @@ class Design extends \Magento\Framework\Model\AbstractModel
*/
private $translator;
+ /**
+ * @var CategoryLayoutManager
+ */
+ private $categoryLayoutUpdates;
+
+ /**
+ * @var ProductLayoutManager
+ */
+ private $productLayoutUpdates;
+
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
@@ -47,6 +60,8 @@ class Design extends \Magento\Framework\Model\AbstractModel
* @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
* @param array $data
* @param TranslateInterface|null $translator
+ * @param CategoryLayoutManager|null $categoryLayoutManager
+ * @param ProductLayoutManager|null $productLayoutManager
*/
public function __construct(
\Magento\Framework\Model\Context $context,
@@ -56,12 +71,17 @@ public function __construct(
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
- TranslateInterface $translator = null
+ TranslateInterface $translator = null,
+ ?CategoryLayoutManager $categoryLayoutManager = null,
+ ?ProductLayoutManager $productLayoutManager = null
) {
$this->_localeDate = $localeDate;
$this->_design = $design;
- $this->translator = $translator ?:
- \Magento\Framework\App\ObjectManager::getInstance()->get(TranslateInterface::class);
+ $this->translator = $translator ?? ObjectManager::getInstance()->get(TranslateInterface::class);
+ $this->categoryLayoutUpdates = $categoryLayoutManager
+ ?? ObjectManager::getInstance()->get(CategoryLayoutManager::class);
+ $this->productLayoutUpdates = $productLayoutManager
+ ?? ObjectManager::getInstance()->get(ProductLayoutManager::class);
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
@@ -81,12 +101,12 @@ public function applyCustomDesign($design)
/**
* Get custom layout settings
*
- * @param \Magento\Catalog\Model\Category|\Magento\Catalog\Model\Product $object
+ * @param Category|Product $object
* @return \Magento\Framework\DataObject
*/
public function getDesignSettings($object)
{
- if ($object instanceof \Magento\Catalog\Model\Product) {
+ if ($object instanceof Product) {
$currentCategory = $object->getCategory();
} else {
$currentCategory = $object;
@@ -97,7 +117,7 @@ public function getDesignSettings($object)
$category = $currentCategory->getParentDesignCategory($currentCategory);
}
- if ($object instanceof \Magento\Catalog\Model\Product) {
+ if ($object instanceof Product) {
if ($category && $category->getCustomApplyToProducts()) {
return $this->_mergeSettings($this->_extractSettings($category), $this->_extractSettings($object));
} else {
@@ -111,7 +131,7 @@ public function getDesignSettings($object)
/**
* Extract custom layout settings from category or product object
*
- * @param \Magento\Catalog\Model\Category|\Magento\Catalog\Model\Product $object
+ * @param Category|Product $object
* @return \Magento\Framework\DataObject
*/
protected function _extractSettings($object)
@@ -140,6 +160,11 @@ protected function _extractSettings($object)
)->setLayoutUpdates(
(array)$object->getCustomLayoutUpdate()
);
+ if ($object instanceof Category) {
+ $this->categoryLayoutUpdates->extractCustomSettings($object, $settings);
+ } elseif ($object instanceof Product) {
+ $this->productLayoutUpdates->extractCustomSettings($object, $settings);
+ }
}
return $settings;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
index 9fcd2c2c4c4d3..bcf655b25299c 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -8,8 +8,10 @@
namespace Magento\Catalog\Model\Product\Attribute;
+use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\Area;
+use Magento\Framework\DataObject;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\Model\Layout\Merge as LayoutProcessor;
@@ -121,20 +123,23 @@ function (string $handle) use ($identifier) : ?string {
}
/**
- * Apply selected custom layout updates.
+ * Extract selected custom layout settings.
*
* If no update is selected none will apply.
*
- * @param PageLayout $layout
* @param ProductInterface $product
+ * @param DataObject $intoSettings
* @return void
*/
- public function applyUpdate(PageLayout $layout, ProductInterface $product): void
+ public function extractCustomSettings(ProductInterface $product, DataObject $intoSettings): void
{
if ($attribute = $product->getCustomAttribute('custom_layout_update_file')) {
- $layout->addPageLayoutHandles(
+ $handles = $intoSettings->getPageLayoutHandles() ?? [];
+ $handles = array_merge_recursive(
+ $handles,
['selectable' => $this->sanitizeSku($product) . '_' . $attribute->getValue()]
);
+ $intoSettings->setPageLayoutHandles($handles);
}
}
}
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Category.php b/app/code/Magento/Catalog/Model/ResourceModel/Category.php
index 786cec391c460..bc414bf07a115 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Category.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Category.php
@@ -758,6 +758,8 @@ public function getParentDesignCategory($category)
'custom_layout_update'
)->addAttributeToSelect(
'custom_apply_to_products'
+ )->addAttributeToSelect(
+ 'custom_layout_update_file'
)->addFieldToFilter(
'entity_id',
['in' => $pathIds]
diff --git a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
index 4809316d8ff0e..386d9b246782d 100644
--- a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
+++ b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
@@ -103,5 +103,19 @@ public function apply()
'is_filterable_in_grid' => false
]
);
+
+ $eavSetup->updateAttribute(
+ Product::ENTITY,
+ 'custom_layout_update',
+ 'visible',
+ false
+ );
+
+ $eavSetup->updateAttribute(
+ Category::ENTITY,
+ 'custom_layout_update',
+ 'visible',
+ false
+ );
}
}
diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml
index 992093c4a6658..c3a0457bb848a 100644
--- a/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml
+++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/category_form.xml
@@ -489,6 +489,15 @@
+
+
+ string
+ Custom Layout Update
+
+ ${ $.parentName }.custom_use_parent_settings:checked || $.data.serviceDisabled
+
+
+
-
From b7eef40961df7b2cc7fbcbaac50a4785349026ae Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 28 Aug 2019 13:59:52 -0500
Subject: [PATCH 0093/1978] MC-18685: Remove custom layout updates from admin
---
.../Adminhtml/Category/Authorization.php | 82 +++++++++++++++++++
.../Controller/Adminhtml/Category/Save.php | 37 +++++----
app/code/Magento/Catalog/Model/Category.php | 68 +--------------
.../Observer/CategoryDesignAuthorization.php | 44 ++++++++++
.../Catalog/Plugin/CategoryAuthorization.php | 48 +++++++++++
app/code/Magento/Catalog/etc/events.xml | 3 +
.../Magento/Catalog/etc/webapi_rest/di.xml | 3 +
.../Magento/Catalog/etc/webapi_soap/di.xml | 3 +
8 files changed, 203 insertions(+), 85 deletions(-)
create mode 100644 app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
create mode 100644 app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php
create mode 100644 app/code/Magento/Catalog/Plugin/CategoryAuthorization.php
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
new file mode 100644
index 0000000000000..a062189628789
--- /dev/null
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
@@ -0,0 +1,82 @@
+authorization = $authorization;
+ $this->categoryFactory = $factory;
+ }
+
+ /**
+ * Authorize saving of a category.
+ *
+ * @throws AuthorizationException
+ * @throws NoSuchEntityException When a category with invalid ID given.
+ * @param CategoryInterface|Category $category
+ * @return void
+ */
+ public function authorizeSavingOf(CategoryInterface $category): void
+ {
+ if (!$this->authorization->isAllowed('Magento_Catalog::edit_category_design')) {
+ $notAllowed = false;
+ if (!$category->getId()) {
+ foreach (array_keys($category->getDesignAttributes()) as $attribute) {
+ if ($category->getData($attribute)) {
+ $notAllowed = true;
+ break;
+ }
+ }
+ } else {
+ /** @var Category $savedCategory */
+ $savedCategory = $this->categoryFactory->create();
+ $savedCategory->load($category->getId());
+ if ($savedCategory->getName()) {
+ throw NoSuchEntityException::singleField('id', $category->getId());
+ }
+ foreach (array_keys($category->getDesignAttributes()) as $attribute) {
+ if ($category->getData($attribute) != $savedCategory->getData($attribute)) {
+ $notAllowed = true;
+ break;
+ }
+ }
+ }
+
+ if ($notAllowed) {
+ throw new AuthorizationException(__('Not allowed to edit the category\'s design attributes'));
+ }
+ }
+ }
+}
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
index 77518fd9bf5cc..485e8e69e4bff 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
@@ -173,29 +173,30 @@ public function execute()
$products = json_decode($categoryPostData['category_products'], true);
$category->setPostedProducts($products);
}
- $this->_eventManager->dispatch(
- 'catalog_category_prepare_save',
- ['category' => $category, 'request' => $this->getRequest()]
- );
- /**
- * Check "Use Default Value" checkboxes values
- */
- if (isset($categoryPostData['use_default']) && !empty($categoryPostData['use_default'])) {
- foreach ($categoryPostData['use_default'] as $attributeCode => $attributeValue) {
- if ($attributeValue) {
- $category->setData($attributeCode, null);
+ try {
+ $this->_eventManager->dispatch(
+ 'catalog_category_prepare_save',
+ ['category' => $category, 'request' => $this->getRequest()]
+ );
+
+ /**
+ * Check "Use Default Value" checkboxes values
+ */
+ if (isset($categoryPostData['use_default']) && !empty($categoryPostData['use_default'])) {
+ foreach ($categoryPostData['use_default'] as $attributeCode => $attributeValue) {
+ if ($attributeValue) {
+ $category->setData($attributeCode, null);
+ }
}
}
- }
- /**
- * Proceed with $_POST['use_config']
- * set into category model for processing through validation
- */
- $category->setData('use_post_data_config', $useConfig);
+ /**
+ * Proceed with $_POST['use_config']
+ * set into category model for processing through validation
+ */
+ $category->setData('use_post_data_config', $useConfig);
- try {
$categoryResource = $category->getResource();
if ($category->hasCustomDesignTo()) {
$categoryResource->getAttribute('custom_design_from')->setMaxValue($category->getCustomDesignTo());
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 773ef9d536e01..d3c25b74acc41 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -5,13 +5,10 @@
*/
namespace Magento\Catalog\Model;
-use Magento\Authorization\Model\UserContextInterface;
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
use Magento\Framework\Api\AttributeValueFactory;
-use Magento\Framework\App\ObjectManager;
-use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Convert\ConvertArray;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Profiler;
@@ -131,6 +128,7 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
'page_layout',
'custom_layout_update',
'custom_apply_to_products',
+ 'custom_layout_update_file'
];
/**
@@ -214,16 +212,6 @@ class Category extends \Magento\Catalog\Model\AbstractModel implements
*/
protected $metadataService;
- /**
- * @var UserContextInterface
- */
- private $userContext;
-
- /**
- * @var AuthorizationInterface
- */
- private $authorization;
-
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
@@ -933,60 +921,6 @@ public function beforeDelete()
return parent::beforeDelete();
}
- /**
- * Get user context.
- *
- * @return UserContextInterface
- */
- private function getUserContext(): UserContextInterface
- {
- if (!$this->userContext) {
- $this->userContext = ObjectManager::getInstance()->get(UserContextInterface::class);
- }
-
- return $this->userContext;
- }
-
- /**
- * Get authorization service.
- *
- * @return AuthorizationInterface
- */
- private function getAuthorization(): AuthorizationInterface
- {
- if (!$this->authorization) {
- $this->authorization = ObjectManager::getInstance()->get(AuthorizationInterface::class);
- }
-
- return $this->authorization;
- }
-
- /**
- * @inheritDoc
- */
- public function beforeSave()
- {
- //Validate changing of design.
- $userType = $this->getUserContext()->getUserType();
- if ((
- $userType === UserContextInterface::USER_TYPE_ADMIN
- || $userType === UserContextInterface::USER_TYPE_INTEGRATION
- )
- && !$this->getAuthorization()->isAllowed('Magento_Catalog::edit_category_design')
- ) {
- foreach ($this->_designAttributes as $attributeCode) {
- $this->setData($attributeCode, $value = $this->getOrigData($attributeCode));
- if (!empty($this->_data[self::CUSTOM_ATTRIBUTES])
- && array_key_exists($attributeCode, $this->_data[self::CUSTOM_ATTRIBUTES])) {
- //In case custom attribute were used to update the entity.
- $this->_data[self::CUSTOM_ATTRIBUTES][$attributeCode]->setValue($value);
- }
- }
- }
-
- return parent::beforeSave();
- }
-
/**
* Retrieve anchors above
*
diff --git a/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php b/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php
new file mode 100644
index 0000000000000..b6486bd9256b1
--- /dev/null
+++ b/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php
@@ -0,0 +1,44 @@
+authorization = $authorization;
+ }
+
+ /**
+ * @inheritDoc
+ * @throws AuthorizationException
+ */
+ public function execute(Observer $observer)
+ {
+ /** @var CategoryInterface $category */
+ $category = $observer->getEvent()->getData('category');
+ $this->authorization->authorizeSavingOf($category);
+ }
+}
diff --git a/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php b/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php
new file mode 100644
index 0000000000000..1e4f2ddc38b82
--- /dev/null
+++ b/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php
@@ -0,0 +1,48 @@
+authorization = $authorization;
+ }
+
+ /**
+ * Authorize saving of a category.
+ *
+ * @param CategoryRepositoryInterface $subject
+ * @param CategoryInterface $category
+ * @throws LocalizedException
+ * @return array
+ */
+ public function beforeSave(CategoryRepositoryInterface $subject, CategoryInterface $category): array
+ {
+ $this->authorization->authorizeSavingOf($category);
+
+ return [$category];
+ }
+}
diff --git a/app/code/Magento/Catalog/etc/events.xml b/app/code/Magento/Catalog/etc/events.xml
index 5bcdc88369064..6bc2311dddd27 100644
--- a/app/code/Magento/Catalog/etc/events.xml
+++ b/app/code/Magento/Catalog/etc/events.xml
@@ -63,4 +63,7 @@
+
+
+
diff --git a/app/code/Magento/Catalog/etc/webapi_rest/di.xml b/app/code/Magento/Catalog/etc/webapi_rest/di.xml
index 4a7d2c7481576..bfbc05b12079d 100644
--- a/app/code/Magento/Catalog/etc/webapi_rest/di.xml
+++ b/app/code/Magento/Catalog/etc/webapi_rest/di.xml
@@ -25,4 +25,7 @@
+
+
+
diff --git a/app/code/Magento/Catalog/etc/webapi_soap/di.xml b/app/code/Magento/Catalog/etc/webapi_soap/di.xml
index 4a7d2c7481576..bfbc05b12079d 100644
--- a/app/code/Magento/Catalog/etc/webapi_soap/di.xml
+++ b/app/code/Magento/Catalog/etc/webapi_soap/di.xml
@@ -25,4 +25,7 @@
+
+
+
From 892cfc9285df75e42531c527636c1ce33ca23c40 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 28 Aug 2019 16:10:57 -0500
Subject: [PATCH 0094/1978] MC-18685: Remove custom layout updates from admin
---
.../Catalog/Controller/Adminhtml/Category.php | 8 +-
.../Adminhtml/Category/Authorization.php | 13 +-
.../Controller/Adminhtml/Category/Save.php | 10 +-
.../Adminhtml/Product/Authorization.php | 2 +-
app/code/Magento/Catalog/Model/Category.php | 2 +-
.../Catalog/Api/CategoryRepositoryTest.php | 162 +++++++++++++++++-
.../Controller/Adminhtml/CategoryTest.php | 91 +++++++++-
7 files changed, 269 insertions(+), 19 deletions(-)
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
index 1e0cb9f197a51..61fd714d518ba 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
@@ -71,8 +71,12 @@ protected function _initCategory($getRootInstead = false)
}
}
- $this->_objectManager->get(\Magento\Framework\Registry::class)->register('category', $category);
- $this->_objectManager->get(\Magento\Framework\Registry::class)->register('current_category', $category);
+ /** @var \Magento\Framework\Registry $registry */
+ $registry = $this->_objectManager->get(\Magento\Framework\Registry::class);
+ $registry->unregister('category');
+ $registry->unregister('current_category');
+ $registry->register('category', $category);
+ $registry->register('current_category', $category);
$this->_objectManager->get(\Magento\Cms\Model\Wysiwyg\Config::class)
->setStoreId($storeId);
return $category;
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
index a062189628789..023839a16ee89 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\CategoryFactory;
+use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -52,8 +53,14 @@ public function authorizeSavingOf(CategoryInterface $category): void
{
if (!$this->authorization->isAllowed('Magento_Catalog::edit_category_design')) {
$notAllowed = false;
+ $designAttributeCodes = array_map(
+ function (AttributeInterface $attribute) {
+ return $attribute->getAttributeCode();
+ },
+ $category->getDesignAttributes()
+ );
if (!$category->getId()) {
- foreach (array_keys($category->getDesignAttributes()) as $attribute) {
+ foreach ($designAttributeCodes as $attribute) {
if ($category->getData($attribute)) {
$notAllowed = true;
break;
@@ -63,10 +70,10 @@ public function authorizeSavingOf(CategoryInterface $category): void
/** @var Category $savedCategory */
$savedCategory = $this->categoryFactory->create();
$savedCategory->load($category->getId());
- if ($savedCategory->getName()) {
+ if (!$savedCategory->getName()) {
throw NoSuchEntityException::singleField('id', $category->getId());
}
- foreach (array_keys($category->getDesignAttributes()) as $attribute) {
+ foreach ($designAttributeCodes as $attribute) {
if ($category->getData($attribute) != $savedCategory->getData($attribute)) {
$notAllowed = true;
break;
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
index 485e8e69e4bff..95ef5e1279e1e 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
@@ -175,11 +175,6 @@ public function execute()
}
try {
- $this->_eventManager->dispatch(
- 'catalog_category_prepare_save',
- ['category' => $category, 'request' => $this->getRequest()]
- );
-
/**
* Check "Use Default Value" checkboxes values
*/
@@ -191,6 +186,11 @@ public function execute()
}
}
+ $this->_eventManager->dispatch(
+ 'catalog_category_prepare_save',
+ ['category' => $category, 'request' => $this->getRequest()]
+ );
+
/**
* Proceed with $_POST['use_config']
* set into category model for processing through validation
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
index d49c499930022..d1ee659ce8175 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
@@ -66,7 +66,7 @@ public function authorizeSavingOf(ProductInterface $product): void
/** @var Product $savedProduct */
$savedProduct = $this->productFactory->create();
$savedProduct->load($product->getId());
- if ($savedProduct->getSku()) {
+ if (!$savedProduct->getSku()) {
throw NoSuchEntityException::singleField('id', $product->getId());
}
if ($product->getData('custom_design') != $savedProduct->getData('custom_design')
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index d3c25b74acc41..3e8df99dcda84 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -749,7 +749,7 @@ public function getCustomDesignDate()
/**
* Retrieve design attributes array
*
- * @return array
+ * @return \Magento\Eav\Api\Data\AttributeInterface[]
*/
public function getDesignAttributes()
{
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
index 332e509d550ac..7e010d7631eed 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
@@ -6,10 +6,15 @@
*/
namespace Magento\Catalog\Api;
+use Magento\Authorization\Model\Role;
+use Magento\Authorization\Model\Rules;
+use Magento\Integration\Api\AdminTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\WebapiAbstract;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
use Magento\CatalogUrlRewrite\Model\CategoryUrlRewriteGenerator;
+use Magento\Authorization\Model\RoleFactory;
+use Magento\Authorization\Model\RulesFactory;
class CategoryRepositoryTest extends WebapiAbstract
{
@@ -18,6 +23,33 @@ class CategoryRepositoryTest extends WebapiAbstract
private $modelId = 333;
+ /**
+ * @var RoleFactory
+ */
+ private $roleFactory;
+
+ /**
+ * @var RulesFactory
+ */
+ private $rulesFactory;
+
+ /**
+ * @var AdminTokenServiceInterface
+ */
+ private $adminTokens;
+
+ /**
+ * @inheritDoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->roleFactory = Bootstrap::getObjectManager()->get(RoleFactory::class);
+ $this->rulesFactory = Bootstrap::getObjectManager()->get(RulesFactory::class);
+ $this->adminTokens = Bootstrap::getObjectManager()->get(AdminTokenServiceInterface::class);
+ }
+
/**
* @magentoApiDataFixture Magento/Catalog/_files/category_backend.php
*/
@@ -57,8 +89,10 @@ public function testInfoNoSuchEntityException()
}
/**
+ * Load category data.
+ *
* @param int $id
- * @return string
+ * @return array
*/
protected function getInfoCategory($id)
{
@@ -209,10 +243,11 @@ protected function getSimpleCategoryData($categoryData = [])
/**
* Create category process
*
- * @param $category
- * @return int
+ * @param array $category
+ * @param string|null $token
+ * @return array
*/
- protected function createCategory($category)
+ protected function createCategory(array $category, ?string $token = null)
{
$serviceInfo = [
'rest' => [
@@ -225,6 +260,9 @@ protected function createCategory($category)
'operation' => self::SERVICE_NAME . 'Save',
],
];
+ if ($token) {
+ $serviceInfo['rest']['token'] = $serviceInfo['soap']['token'] = $token;
+ }
$requestData = ['category' => $category];
return $this->_webApiCall($serviceInfo, $requestData);
}
@@ -251,7 +289,15 @@ protected function deleteCategory($id)
return $this->_webApiCall($serviceInfo, ['categoryId' => $id]);
}
- protected function updateCategory($id, $data)
+ /**
+ * Update given category via web API.
+ *
+ * @param int $id
+ * @param array $data
+ * @param string|null $token
+ * @return array
+ */
+ protected function updateCategory($id, $data, ?string $token = null)
{
$serviceInfo =
[
@@ -265,6 +311,7 @@ protected function updateCategory($id, $data)
'operation' => self::SERVICE_NAME . 'Save',
],
];
+ $serviceInfo['rest']['token'] = $serviceInfo['soap']['token'] = $token;
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
$data['id'] = $id;
@@ -272,7 +319,110 @@ protected function updateCategory($id, $data)
} else {
$data['id'] = $id;
return $this->_webApiCall($serviceInfo, ['id' => $id, 'category' => $data]);
- return $this->_webApiCall($serviceInfo, ['category' => $data]);
}
}
+
+ /**
+ * Test design settings authorization
+ *
+ * @magentoApiDataFixture Magento/User/_files/user_with_custom_role.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ //Updating our admin user's role to allow saving categories but not their design settings.
+ /** @var Role $role */
+ $role = $this->roleFactory->create();
+ $role->load('test_custom_role', 'role_name');
+ /** @var Rules $rules */
+ $rules = $this->rulesFactory->create();
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Catalog::categories']);
+ $rules->saveRel();
+ //Using the admin user with custom role.
+ $token = $this->adminTokens->createAdminAccessToken(
+ 'customRoleUser',
+ \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD
+ );
+
+ $categoryData = $this->getSimpleCategoryData();
+ $categoryData['custom_attributes'][] = ['attribute_code' => 'custom_layout_update_file', 'value' => 'test'];
+
+ //Creating new category with design settings.
+ $exceptionMessage = null;
+ try {
+ $this->createCategory($categoryData, $token);
+ } catch (\Throwable $exception) {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ $exceptionMessage = $restResponse['message'];
+ } else {
+ //SOAP
+ $exceptionMessage = $exception->getMessage();
+ }
+ }
+ //We don't have the permissions.
+ $this->assertEquals('Not allowed to edit the category\'s design attributes', $exceptionMessage);
+
+ //Updating the user role to allow access to design properties.
+ /** @var Rules $rules */
+ $rules = Bootstrap::getObjectManager()->create(Rules::class);
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
+ $rules->saveRel();
+ //Making the same request with design settings.
+ $categoryData = $this->getSimpleCategoryData();
+ foreach ($categoryData['custom_attributes'] as &$attribute) {
+ if ($attribute['attribute_code'] === 'custom_design') {
+ $attribute['value'] = 'test';
+ break;
+ }
+ }
+ $result = $this->createCategory($categoryData, $token);
+ $this->assertArrayHasKey('id', $result);
+ //Category must be saved.
+ $categorySaved = $this->getInfoCategory($result['id']);
+ $savedCustomDesign = null;
+ foreach ($categorySaved['custom_attributes'] as $customAttribute) {
+ if ($customAttribute['attribute_code'] === 'custom_design') {
+ $savedCustomDesign = $customAttribute['value'];
+ break;
+ }
+ }
+ $this->assertEquals('test', $savedCustomDesign);
+ $categoryData = $categorySaved;
+
+ //Updating our role to remove design properties access.
+ /** @var Rules $rules */
+ $rules = Bootstrap::getObjectManager()->create(Rules::class);
+ $rules->setRoleId($role->getId());
+ $rules->setResources(['Magento_Catalog::categories']);
+ $rules->saveRel();
+ //Updating the category but with the same design properties values.
+ $result = $this->updateCategory($categoryData['id'], $categoryData, $token);
+ //We haven't changed the design so operation is successful.
+ $this->assertArrayHasKey('id', $result);
+
+ //Changing a design property.
+ foreach ($categoryData['custom_attributes'] as &$customAttribute) {
+ if ($customAttribute['attribute_code'] === 'custom_design') {
+ $customAttribute['value'] = 'test2';
+ }
+ }
+ $exceptionMessage = null;
+ try {
+ $this->updateCategory($categoryData['id'], $categoryData, $token);
+ } catch (\Throwable $exception) {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ $exceptionMessage = $restResponse['message'];
+ } else {
+ //SOAP
+ $exceptionMessage = $exception->getMessage();
+ }
+ }
+ //We don't have permissions to do that.
+ $this->assertEquals('Not allowed to edit the category\'s design attributes', $exceptionMessage);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
index 1001d58ee8a67..a46657acf8fff 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
@@ -5,10 +5,14 @@
*/
namespace Magento\Catalog\Controller\Adminhtml;
+use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Store\Model\Store;
use Magento\Catalog\Model\ResourceModel\Product;
+use Magento\Catalog\Model\Category as CategoryModel;
+use Magento\Catalog\Model\CategoryFactory as CategoryModelFactory;
/**
* @magentoAppArea adminhtml
@@ -19,6 +23,15 @@ class CategoryTest extends \Magento\TestFramework\TestCase\AbstractBackendContro
* @var \Magento\Catalog\Model\ResourceModel\Product
*/
protected $productResource;
+ /**
+ * @var Builder
+ */
+ private $aclBuilder;
+
+ /**
+ * @var CategoryModelFactory
+ */
+ private $categoryFactory;
/**
* @inheritDoc
@@ -33,6 +46,8 @@ protected function setUp()
$this->productResource = Bootstrap::getObjectManager()->get(
Product::class
);
+ $this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
+ $this->categoryFactory = Bootstrap::getObjectManager()->get(CategoryModelFactory::class);
}
/**
@@ -61,7 +76,7 @@ public function testSaveAction($inputData, $defaultAttributes, $attributesSaved
if ($isSuccess) {
$this->assertSessionMessages(
$this->equalTo(['You saved the category.']),
- \Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
+ MessageInterface::TYPE_SUCCESS
);
}
@@ -555,4 +570,78 @@ private function getCategoryProductsCount(): int
$this->productResource->getConnection()->fetchAll($oldCategoryProducts)
);
}
+
+ /**
+ * Check whether additional authorization is required for the design fields.
+ *
+ * @magentoDbIsolation enabled
+ * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ /** @var $store \Magento\Store\Model\Store */
+ $store = Bootstrap::getObjectManager()->create(Store::class);
+ $store->load('fixturestore', 'code');
+ $storeId = $store->getId();
+ $requestData = [
+ 'id' => '2',
+ 'entity_id' => '2',
+ 'path' => '1/2',
+ 'name' => 'Custom Name',
+ 'is_active' => '0',
+ 'description' => 'Custom Description',
+ 'meta_title' => 'Custom Title',
+ 'meta_keywords' => 'Custom keywords',
+ 'meta_description' => 'Custom meta description',
+ 'include_in_menu' => '0',
+ 'url_key' => 'default-test-category',
+ 'display_mode' => 'PRODUCTS',
+ 'landing_page' => '1',
+ 'is_anchor' => true,
+ 'store_id' => $storeId,
+ 'use_config' => [
+ 'available_sort_by' => 1,
+ 'default_sort_by' => 1,
+ 'filter_price_range' => 1,
+ ],
+ ];
+ $uri = 'backend/catalog/category/save';
+
+ //Trying to update the category's design settings without proper permissions.
+ //Expected list of sessions messages collected throughout the controller calls.
+ $sessionMessages = ['Not allowed to edit the category\'s design attributes'];
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_category_design');
+ $requestData['custom_layout_update_file'] = 'test-file';
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('store', $requestData['store_id']);
+ $this->getRequest()->setParam('id', $requestData['id']);
+ $this->dispatch($uri);
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+
+ //Trying again with the permissions.
+ $requestData['custom_layout_update_file'] = null;
+ $requestData['custom_design'] = 'test-theme';
+ $this->aclBuilder->getAcl()->allow(null, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
+ $this->getRequest()->setDispatched(false);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('store', $requestData['store_id']);
+ $this->getRequest()->setParam('id', $requestData['id']);
+ $this->dispatch($uri);
+ /** @var CategoryModel $category */
+ $category = $this->categoryFactory->create();
+ $category->load(2);
+ $this->assertNotEmpty($category->getCustomDesign());
+ $this->assertEquals('test-theme', $category->getCustomDesign());
+ //No new error messages
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+ }
}
From 666a333d19152b86069f2a0e667fc61631141f3d Mon Sep 17 00:00:00 2001
From: Ravi Chandra
Date: Thu, 29 Aug 2019 17:44:27 +0530
Subject: [PATCH 0095/1978] Correct spelling
---
.../Magento/Sales/Model/ResourceModel/Status/Collection.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
index 23d835db603df..393494858a3bb 100644
--- a/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
+++ b/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
@@ -1,6 +1,6 @@
Date: Thu, 29 Aug 2019 17:46:44 +0530
Subject: [PATCH 0096/1978] update Correct spelling
---
.../Magento/Sales/Model/ResourceModel/Status/Collection.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
index 393494858a3bb..f429a62fc3f03 100644
--- a/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
+++ b/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
@@ -1,6 +1,6 @@
Date: Thu, 29 Aug 2019 16:46:38 +0200
Subject: [PATCH 0097/1978] add eav_attribute_option join for ordering by
sort_order column for attributes
---
.../Model/Entity/Attribute/Source/Table.php | 8 +++++-
.../ResourceModel/Entity/Attribute/Option.php | 27 +++++++++++++++++++
.../Entity/Attribute/Source/TableTest.php | 3 +++
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
index f9aa1a9ed3ba1..908f29069c429 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
@@ -213,7 +213,13 @@ public function addValueSortToCollection($collection, $dir = \Magento\Framework\
$valueExpr
);
- $collection->getSelect()->order("{$attribute->getAttributeCode()} {$dir}");
+ $this->_attrOptionFactory->create()->addOptionToCollection(
+ $collection,
+ $attribute,
+ $valueExpr
+ );
+
+ $collection->getSelect()->order("{$attribute->getAttributeCode()}_order {$dir}");
return $this;
}
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php
index 79c277dcb6a82..6dc51247fb3f3 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php
@@ -61,6 +61,33 @@ public function addOptionValueToCollection($collection, $attribute, $valueExpr)
return $this;
}
+ /**
+ * Add Join with option for collection select
+ *
+ * @param \Magento\Eav\Model\Entity\Collection\AbstractCollection $collection
+ * @param \Magento\Eav\Model\Entity\Attribute $attribute
+ * @param \Zend_Db_Expr $valueExpr
+ * @return $this
+ */
+ public function addOptionToCollection($collection, $attribute, $valueExpr)
+ {
+ $connection = $this->getConnection();
+ $attributeCode = $attribute->getAttributeCode();
+ $optionTable1 = $attributeCode . '_option_t1';
+ $tableJoinCond1 = "{$optionTable1}.option_id={$valueExpr}";
+ $valueExpr = $connection->getIfNullSql(
+ "{$optionTable1}.sort_order"
+ );
+
+ $collection->getSelect()->joinLeft(
+ [$optionTable1 => $this->getTable('eav_attribute_option')],
+ $tableJoinCond1,
+ ["{$attributeCode}_order" => $valueExpr]
+ );
+
+ return $this;
+ }
+
/**
* Retrieve Select for update Flat data
*
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
index b68446d22f910..49e7be7ecf594 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
@@ -314,6 +314,9 @@ public function testAddValueSortToCollection()
$attrOption->expects($this->once())->method('addOptionValueToCollection')
->with($collection, $this->abstractAttributeMock, $expr)
->willReturnSelf();
+ $attrOption->expects($this->once())->method('addOptionToCollection')
+ ->with($collection, $this->abstractAttributeMock, $expr)
+ ->willReturnSelf();
$select->expects($this->once())->method('order')->with("{$attributeCode} {$dir}");
$this->assertEquals($this->model, $this->model->addValueSortToCollection($collection, $dir));
From a047aca104cb76d743bb318887f6ff7530175d5d Mon Sep 17 00:00:00 2001
From: Tan Sezer
Date: Thu, 29 Aug 2019 17:02:43 +0200
Subject: [PATCH 0098/1978] add a line
---
app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
index 908f29069c429..ef7b4a69808bc 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
@@ -211,9 +211,7 @@ public function addValueSortToCollection($collection, $dir = \Magento\Framework\
$collection,
$attribute,
$valueExpr
- );
-
- $this->_attrOptionFactory->create()->addOptionToCollection(
+ )->addOptionToCollection(
$collection,
$attribute,
$valueExpr
From 952d12e423f2a02c0ead3a7fd8cd7588a15d0760 Mon Sep 17 00:00:00 2001
From: Tan Sezer
Date: Fri, 30 Aug 2019 11:24:37 +0200
Subject: [PATCH 0099/1978] fix unit test for ordering of attribute
---
.../Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
index 49e7be7ecf594..2997874f6ea34 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
@@ -317,7 +317,7 @@ public function testAddValueSortToCollection()
$attrOption->expects($this->once())->method('addOptionToCollection')
->with($collection, $this->abstractAttributeMock, $expr)
->willReturnSelf();
- $select->expects($this->once())->method('order')->with("{$attributeCode} {$dir}");
+ $select->expects($this->once())->method('order')->with("{$attributeCode}_order {$dir}");
$this->assertEquals($this->model, $this->model->addValueSortToCollection($collection, $dir));
}
From 08e5d5c1941d60c8cc4d2d7ffe9be2e7abb359a5 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 30 Aug 2019 09:16:41 -0500
Subject: [PATCH 0100/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/LayoutUpdateManager.php | 8 +-
.../Product/Attribute/LayoutUpdateManager.php | 6 +-
.../Data/UpdateCustomLayoutAttributes.php | 4 +-
.../integration/etc/di/preferences/ce.php | 2 +
.../Model/CategoryLayoutUpdateManager.php | 50 ++++++++++++
.../Controller/Adminhtml/CategoryTest.php | 78 ++++++++++++++++++-
.../Catalog/Controller/CategoryTest.php | 34 ++++++++
7 files changed, 174 insertions(+), 8 deletions(-)
create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/CategoryLayoutUpdateManager.php
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
index 32d6068446a65..69c5f961cb96f 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
@@ -88,6 +88,10 @@ private function getLayoutProcessor(): LayoutProcessor
*/
public function fetchAvailableFiles(CategoryInterface $category): array
{
+ if (!$category->getId()) {
+ return [];
+ }
+
$handles = $this->getLayoutProcessor()->getAvailableHandles();
return array_filter(
@@ -120,7 +124,9 @@ function (string $handle) use ($category) : ?string {
*/
public function extractCustomSettings(CategoryInterface $category, DataObject $intoSettings): void
{
- if ($attribute = $category->getCustomAttribute('custom_layout_update_file')) {
+ if ($category->getId()
+ && $attribute = $category->getCustomAttribute('custom_layout_update_file')
+ ) {
$handles = $intoSettings->getPageLayoutHandles() ?? [];
$handles = array_merge_recursive(
$handles,
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
index bcf655b25299c..1e0acdc989cdb 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -100,6 +100,10 @@ private function getLayoutProcessor(): LayoutProcessor
*/
public function fetchAvailableFiles(ProductInterface $product): array
{
+ if (!$product->getSku()) {
+ return [];
+ }
+
$identifier = $this->sanitizeSku($product);
$handles = $this->getLayoutProcessor()->getAvailableHandles();
@@ -133,7 +137,7 @@ function (string $handle) use ($identifier) : ?string {
*/
public function extractCustomSettings(ProductInterface $product, DataObject $intoSettings): void
{
- if ($attribute = $product->getCustomAttribute('custom_layout_update_file')) {
+ if ($product->getSku() && $attribute = $product->getCustomAttribute('custom_layout_update_file')) {
$handles = $intoSettings->getPageLayoutHandles() ?? [];
$handles = array_merge_recursive(
$handles,
diff --git a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
index 386d9b246782d..81fd35ccd3178 100644
--- a/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
+++ b/app/code/Magento/Catalog/Setup/Patch/Data/UpdateCustomLayoutAttributes.php
@@ -107,14 +107,14 @@ public function apply()
$eavSetup->updateAttribute(
Product::ENTITY,
'custom_layout_update',
- 'visible',
+ 'is_visible',
false
);
$eavSetup->updateAttribute(
Category::ENTITY,
'custom_layout_update',
- 'visible',
+ 'is_visible',
false
);
}
diff --git a/dev/tests/integration/etc/di/preferences/ce.php b/dev/tests/integration/etc/di/preferences/ce.php
index b8264ea977750..87ac54f4591eb 100644
--- a/dev/tests/integration/etc/di/preferences/ce.php
+++ b/dev/tests/integration/etc/di/preferences/ce.php
@@ -31,4 +31,6 @@
\Magento\TestFramework\Lock\Backend\DummyLocker::class,
\Magento\Framework\Session\SessionStartChecker::class => \Magento\TestFramework\Session\SessionStartChecker::class,
\Magento\Framework\HTTP\AsyncClientInterface::class => \Magento\TestFramework\HTTP\AsyncClientInterfaceMock::class,
+ \Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager::class =>
+ \Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager::class
];
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/CategoryLayoutUpdateManager.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/CategoryLayoutUpdateManager.php
new file mode 100644
index 0000000000000..48ff3a6496722
--- /dev/null
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/CategoryLayoutUpdateManager.php
@@ -0,0 +1,50 @@
+fakeFiles[$forCategoryId]);
+ } else {
+ $this->fakeFiles[$forCategoryId] = $files;
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function fetchAvailableFiles(CategoryInterface $category): array
+ {
+ if (array_key_exists($category->getId(), $this->fakeFiles)) {
+ return $this->fakeFiles[$category->getId()];
+ }
+
+ return parent::fetchAvailableFiles($category);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
index a46657acf8fff..94a37327fcc39 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
@@ -8,6 +8,7 @@
use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
+use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Store\Model\Store;
use Magento\Catalog\Model\ResourceModel\Product;
@@ -222,7 +223,7 @@ public function saveActionDataProvider()
'custom_design_from' => 1,
'custom_design_to' => 1,
'page_layout' => 1,
- 'custom_layout_update' => 1,
+ 'custom_layout_update' => null,
],
],
[
@@ -268,7 +269,6 @@ public function saveActionDataProvider()
'custom_design_from' => '5/21/2015',
'custom_design_to' => '5/29/2015',
'page_layout' => '',
- 'custom_layout_update' => '',
'use_config' => [
'available_sort_by' => 1,
'default_sort_by' => 1,
@@ -290,7 +290,6 @@ public function saveActionDataProvider()
'description' => true,
'meta_keywords' => true,
'meta_description' => true,
- 'custom_layout_update' => true,
'custom_design_from' => true,
'custom_design_to' => true,
'filter_price_range' => false
@@ -310,7 +309,6 @@ public function saveActionDataProvider()
'description' => 'Custom Description',
'meta_keywords' => 'Custom keywords',
'meta_description' => 'Custom meta description',
- 'custom_layout_update' => null,
'custom_design_from' => '2015-05-21 00:00:00',
'custom_design_to' => '2015-05-29 00:00:00',
'filter_price_range' => null
@@ -644,4 +642,76 @@ public function testSaveDesign(): void
MessageInterface::TYPE_ERROR
);
}
+ /**
+ * Test custom update files functionality.
+ *
+ * @magentoDbIsolation enabled
+ * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveCustomLayout(): void
+ {
+ $file = 'test_file';
+ /** @var $store \Magento\Store\Model\Store */
+ $store = Bootstrap::getObjectManager()->create(Store::class);
+ /** @var CategoryLayoutUpdateManager $layoutManager */
+ $layoutManager = Bootstrap::getObjectManager()->get(CategoryLayoutUpdateManager::class);
+ $layoutManager->setCategoryFakeFiles(2, [$file]);
+ $store->load('fixturestore', 'code');
+ $storeId = $store->getId();
+ $requestData = [
+ 'id' => '2',
+ 'entity_id' => '2',
+ 'path' => '1/2',
+ 'name' => 'Custom Name',
+ 'is_active' => '0',
+ 'description' => 'Custom Description',
+ 'meta_title' => 'Custom Title',
+ 'meta_keywords' => 'Custom keywords',
+ 'meta_description' => 'Custom meta description',
+ 'include_in_menu' => '0',
+ 'url_key' => 'default-test-category',
+ 'display_mode' => 'PRODUCTS',
+ 'landing_page' => '1',
+ 'is_anchor' => true,
+ 'store_id' => $storeId,
+ 'use_config' => [
+ 'available_sort_by' => 1,
+ 'default_sort_by' => 1,
+ 'filter_price_range' => 1,
+ ],
+ ];
+ $uri = 'backend/catalog/category/save';
+
+ //Saving a wrong file
+ $requestData['custom_layout_update_file'] = $file . 'INVALID';
+ $this->getRequest()->setDispatched(false);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('store', $requestData['store_id']);
+ $this->getRequest()->setParam('id', $requestData['id']);
+ $this->dispatch($uri);
+
+ //Checking that the value is not saved
+ /** @var CategoryModel $category */
+ $category = $this->categoryFactory->create();
+ $category->load($requestData['entity_id']);
+ $this->assertEmpty($category->getData('custom_layout_update_file'));
+
+ //Saving the correct file
+ $requestData['custom_layout_update_file'] = $file;
+ $this->getRequest()->setDispatched(false);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('store', $requestData['store_id']);
+ $this->getRequest()->setParam('id', $requestData['id']);
+ $this->dispatch($uri);
+
+ //Checking that the value is saved
+ /** @var CategoryModel $category */
+ $category = $this->categoryFactory->create();
+ $category->load($requestData['entity_id']);
+ $this->assertEquals($file, $category->getData('custom_layout_update_file'));
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
index 87b8d4a117e2d..070ef99c15a34 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
@@ -5,6 +5,10 @@
*/
namespace Magento\Catalog\Controller;
+use Magento\Catalog\Model\Category;
+use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
+use Magento\TestFramework\Helper\Bootstrap;
+
/**
* Test class for \Magento\Catalog\Controller\Category.
*
@@ -103,4 +107,34 @@ public function testViewActionInactiveCategory()
$this->assert404NotFound();
}
+
+ /**
+ * Check that custom layout update files is employed.
+ *
+ * @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories_with_product_ids.php
+ * @return void
+ */
+ public function testViewWithCustomUpdate(): void
+ {
+ //Setting a fake file for the category.
+ $file = 'test-file';
+ $categoryId = 5;
+ /** @var CategoryLayoutUpdateManager $layoutManager */
+ $layoutManager = Bootstrap::getObjectManager()->get(CategoryLayoutUpdateManager::class);
+ $layoutManager->setCategoryFakeFiles($categoryId, [$file]);
+ /** @var Category $category */
+ $category = Bootstrap::getObjectManager()->create(Category::class);
+ $category->load($categoryId);
+ //Updating the custom attribute.
+ $category->setData('custom_layout_update_file', $file);
+ $category->save();
+
+ //Viewing the category
+ $this->dispatch("catalog/category/view/id/$categoryId");
+ //Layout handles must contain the file.
+ $handles = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class)
+ ->getUpdate()
+ ->getHandles();
+ $this->assertContains("catalog_category_view_selectable_{$categoryId}_{$file}", $handles);
+ }
}
From 75aa85d4ce8c3b48ed0c46c269b2e452b31ccab4 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Mon, 2 Sep 2019 14:56:25 +0400
Subject: [PATCH 0101/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Added automated test script
---
.../Section/CheckoutCartSummarySection.xml | 2 +
...ValueWithFullDiscountUsingCartRuleTest.xml | 142 ++++++++++++++++++
.../Test/Mftf/Data/SalesRuleData.xml | 7 +
.../Tax/Test/Mftf/Data/TaxCodeData.xml | 6 +
4 files changed, 157 insertions(+)
create mode 100644 app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml
index 477451ef003ce..803e322d8105a 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml
@@ -33,5 +33,7 @@
+
+
diff --git a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
new file mode 100644
index 0000000000000..b1e11cbf07ff6
--- /dev/null
+++ b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -0,0 +1,142 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5.10
+
+
+ 5.10
+
+
+ 5.50
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
index c1ec728a6cfb9..a5287ad6468d1 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
@@ -89,6 +89,13 @@
Percent of product price discount
50
+
+ TestSalesRule
+ Main Website
+ 'NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'
+ Percent of product price discount
+ 100
+
CartPriceRule
Main Website
diff --git a/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml b/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
index 27c89162b5cea..f9afe84366d9e 100644
--- a/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
+++ b/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
@@ -26,6 +26,12 @@
*
8.375
+
+ New York
+ United States
+ *
+ 20.00
+
California
United States
From 89f7262a766dbc7b9c48ee4e33982dce733e2fe8 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 2 Sep 2019 17:25:19 +0400
Subject: [PATCH 0102/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
.../Mftf/ActionGroup/AdminProductAttributeActionGroup.xml | 4 ++--
.../Test/Mftf/Section/AdminCreateProductAttributeSection.xml | 1 -
.../Test/StrorefrontElasticsearchSearchInvalidValueTest.xml | 3 ++-
3 files changed, 4 insertions(+), 4 deletions(-)
rename app/code/Magento/{Search => Elasticsearch6}/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml (96%)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index 6b713ad2a991b..0c3172392435a 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -320,10 +320,10 @@
-
+
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
index 7b1dd6d565b40..462f721913b9c 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
@@ -49,7 +49,6 @@
-
diff --git a/app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
similarity index 96%
rename from app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
rename to app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
index cf6e94f905aba..4b68dbf95a529 100644
--- a/app/code/Magento/Search/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
@@ -11,6 +11,7 @@
+
@@ -49,7 +50,7 @@
-
+
From e5907065e80f35ef450fc94ef5a83a1ddec9928c Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Mon, 2 Sep 2019 22:02:40 +0200
Subject: [PATCH 0103/1978] Fixed Id Call due to model intercept.
---
.../Magento/AdminNotification/Block/Grid/Renderer/Actions.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
index 2db5bfec92395..af8ccf65dd769 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
@@ -54,7 +54,7 @@ public function render(DataObject $row) : string
$markAsReadHtml = !$row->getData('is_read') ? '' . __(
'Mark as Read'
) . ' ' : '';
@@ -68,7 +68,7 @@ public function render(DataObject $row) : string
'*/*/remove/',
[
'_current' => true,
- 'id' => $row->getData('id'),
+ 'id' => $row->getData('notification_id'),
ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
]
),
From 7a3f7e39fec24f681cc8d38c33871e9960b19477 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Tue, 3 Sep 2019 11:45:14 +0400
Subject: [PATCH 0104/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Updated automated test script
---
.../Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml
index 803e322d8105a..fe4a69a18082c 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutCartSummarySection.xml
@@ -9,6 +9,8 @@
+
+
@@ -33,7 +35,5 @@
-
-
From c9ba95e1bbf150a9592ffa19da4eca5cddf6f9b3 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 3 Sep 2019 15:00:19 -0500
Subject: [PATCH 0105/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Backend/Customlayoutupdate.php | 47 +++++++-
.../Attribute/Backend/LayoutUpdate.php | 7 +-
.../Attribute/Backend/LayoutUpdate.php | 7 +-
.../Backend/CustomlayoutupdateTest.php | 101 ++++++++++++++++++
4 files changed, 148 insertions(+), 14 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index 2dc31e480055c..83dbbae7dda57 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -6,10 +6,11 @@
namespace Magento\Catalog\Model\Attribute\Backend;
use Magento\Catalog\Model\AbstractModel;
-use Magento\Catalog\Model\Category;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Model\Layout\Update\ValidatorFactory;
use Magento\Eav\Model\Entity\Attribute\Exception;
+use Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate as CategoryLayoutUpdate;
+use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as ProductLayoutUpdate;
/**
* Layout update attribute backend
@@ -67,6 +68,36 @@ public function validate($object)
return true;
}
+ /**
+ * Extract an attribute value.
+ *
+ * @param AbstractModel $object
+ * @param string|null $attributeCode
+ * @return mixed
+ */
+ private function extractValue(AbstractModel $object, ?string $attributeCode = null)
+ {
+ $attributeCode = $attributeCode ?? $this->getAttribute()->getName();
+ $attribute = $object->getCustomAttribute($attributeCode);
+
+ return $object->getData($attributeCode) ?? $attribute ? $attribute->getValue() : null;
+ }
+
+ /**
+ * Put an attribute value.
+ *
+ * @param AbstractModel $object
+ * @param mixed $value
+ * @param string|null $attributeCode
+ * @return void
+ */
+ private function putValue(AbstractModel $object, $value, ?string $attributeCode = null): void
+ {
+ $attributeCode = $attributeCode ?? $this->getAttribute()->getName();
+ $object->setCustomAttribute($attributeCode, $value);
+ $object->setData($attributeCode, $value);
+ }
+
/**
* @inheritDoc
* @param AbstractModel $object
@@ -75,11 +106,19 @@ public function validate($object)
public function beforeSave($object)
{
$attributeName = $this->getAttribute()->getName();
- if ($object->getData($attributeName)
- && $object->getOrigData($attributeName) !== $object->getData($attributeName)
- ) {
+ $value = $this->extractValue($object);
+ //New values are not accepted
+ if ($value && $object->getOrigData($attributeName) !== $value) {
throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
}
+ //If custom file was selected we need to remove this attribute
+ $file = $this->extractValue($object, 'custom_layout_update_file');
+ if ($file
+ && $file !== CategoryLayoutUpdate::VALUE_USE_UPDATE_XML
+ && $file !== ProductLayoutUpdate::VALUE_USE_UPDATE_XML
+ ) {
+ $this->putValue($object, null);
+ }
return parent::beforeSave($object);
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index 3447c91043b8e..4ce590421dcaf 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -18,7 +18,7 @@
*/
class LayoutUpdate extends AbstractBackend
{
- private const VALUE_USE_UPDATE_XML = '__existing__';
+ public const VALUE_USE_UPDATE_XML = '__existing__';
/**
* @var LayoutUpdateManager
@@ -91,10 +91,7 @@ public function validate($object)
public function beforeSave($object)
{
$value = $this->extractValue($object);
- if ($value !== self::VALUE_USE_UPDATE_XML) {
- $object->setCustomAttribute('custom_layout_update', null);
- $object->setData('custom_layout_update', null);
- } else {
+ if ($value === self::VALUE_USE_UPDATE_XML) {
$value = null;
}
$this->setValue($value, $object);
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index 6841900b30033..590ae8c14e684 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -18,7 +18,7 @@
*/
class LayoutUpdate extends AbstractBackend
{
- private const VALUE_USE_UPDATE_XML = '__existing__';
+ public const VALUE_USE_UPDATE_XML = '__existing__';
/**
* @var LayoutUpdateManager
@@ -91,10 +91,7 @@ public function validate($object)
public function beforeSave($object)
{
$value = $this->extractValue($object);
- if ($value !== self::VALUE_USE_UPDATE_XML) {
- $object->setCustomAttribute('custom_layout_update', null);
- $object->setData('custom_layout_update', null);
- } else {
+ if ($value === self::VALUE_USE_UPDATE_XML) {
$value = null;
}
$this->setValue($value, $object);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
new file mode 100644
index 0000000000000..fa658706a78c2
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -0,0 +1,101 @@
+categoryFactory = Bootstrap::getObjectManager()->get(CategoryFactory::class);
+ $this->category = $this->categoryFactory->create();
+ $this->category->load(2);
+ $this->attribute = $this->category->getAttributes()['custom_layout_update']->getBackend();
+ }
+
+ /**
+ * Test that attribute cannot be modified but only removed completely.
+ *
+ * @return void
+ * @throws \Throwable
+ */
+ public function testImmutable(): void
+ {
+ //Value is empty
+ $this->category->setCustomAttribute('custom_layout_update', null);
+ $this->category->setOrigData('custom_layout_update', null);
+ $this->attribute->beforeSave($this->category);
+
+ //New value
+ $this->category->setCustomAttribute('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', null);
+ $caughtException = false;
+ try {
+ $this->attribute->beforeSave($this->category);
+ } catch (LocalizedException $exception) {
+ $caughtException = true;
+ }
+ $this->assertTrue($caughtException);
+ $this->category->setCustomAttribute('custom_layout_update', 'testNew');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $caughtException = false;
+ try {
+ $this->attribute->beforeSave($this->category);
+ } catch (LocalizedException $exception) {
+ $caughtException = true;
+ }
+ $this->assertTrue($caughtException);
+
+ //Removing a value
+ $this->category->setCustomAttribute('custom_layout_update', null);
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->attribute->beforeSave($this->category);
+ }
+
+ /**
+ * Check that custom layout update file's values erase the old attribute's value.
+ *
+ * @return void
+ */
+ public function testDependsOnNewUpdate(): void
+ {
+ $this->category->setCustomAttribute('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setCustomAttribute('custom_layout_update_file', 'new');
+ $this->attribute->beforeSave($this->category);
+ $this->assertEmpty($this->category->getCustomAttribute('custom_layout_update')->getValue());
+ $this->assertEquals('new', $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
+ }
+}
From 2b440370fb1d161c2f15e6b4b5435bc79bf4274d Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 3 Sep 2019 15:11:18 -0500
Subject: [PATCH 0106/1978] MC-18685: Remove custom layout updates from admin
---
.../Model/Attribute/Backend/Customlayoutupdate.php | 2 +-
.../Category/Attribute/Backend/LayoutUpdate.php | 4 +++-
.../Product/Attribute/Backend/LayoutUpdate.php | 4 +++-
.../Attribute/Backend/CustomlayoutupdateTest.php | 14 ++++++++++++++
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index 83dbbae7dda57..881fb3a57d3e7 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -80,7 +80,7 @@ private function extractValue(AbstractModel $object, ?string $attributeCode = nu
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
$attribute = $object->getCustomAttribute($attributeCode);
- return $object->getData($attributeCode) ?? $attribute ? $attribute->getValue() : null;
+ return $object->getData($attributeCode) ?? ($attribute ? $attribute->getValue() : null);
}
/**
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index 4ce590421dcaf..f84b718a4025f 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -43,7 +43,8 @@ public function __construct(LayoutUpdateManager $manager)
private function extractValue(Category $category): ?string
{
$attrCode = $this->getAttribute()->getAttributeCode();
- $value = $category->getData($attrCode);
+ $attrValue = $category->getCustomAttribute($attrCode);
+ $value = $category->getData($attrCode) ?? ($attrValue ? $attrValue->getValue() : null);
if ($value
&& $value !== self::VALUE_USE_UPDATE_XML
&& !in_array($value, $this->manager->fetchAvailableFiles($category), true)
@@ -66,6 +67,7 @@ private function extractValue(Category $category): ?string
private function setValue(?string $value, Category $object): void
{
$attrCode = $this->getAttribute()->getAttributeCode();
+ $object->setCustomAttribute($attrCode, $value);
$object->setData($attrCode, $value);
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index 590ae8c14e684..240c97fd66bd2 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -43,7 +43,8 @@ public function __construct(LayoutUpdateManager $manager)
private function extractValue(Product $product): ?string
{
$attrCode = $this->getAttribute()->getAttributeCode();
- $value = $product->getData($attrCode);
+ $attrValue = $product->getCustomAttribute($attrCode);
+ $value = $product->getData($attrCode) ?? ($attrValue ? $attrValue->getValue() : null);
if ($value
&& $value !== self::VALUE_USE_UPDATE_XML
&& !in_array($value, $this->manager->fetchAvailableFiles($product), true)
@@ -66,6 +67,7 @@ private function extractValue(Product $product): ?string
private function setValue(?string $value, Product $object): void
{
$attrCode = $this->getAttribute()->getAttributeCode();
+ $object->setCustomAttribute($attrCode, $value);
$object->setData($attrCode, $value);
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index fa658706a78c2..1a8133f675e19 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -13,6 +13,7 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
/**
* Test 'custom layout' attribute.
@@ -88,14 +89,27 @@ public function testImmutable(): void
* Check that custom layout update file's values erase the old attribute's value.
*
* @return void
+ * @throws \Throwable
*/
public function testDependsOnNewUpdate(): void
{
+ //New selected file value is set
$this->category->setCustomAttribute('custom_layout_update', 'test');
$this->category->setOrigData('custom_layout_update', 'test');
$this->category->setCustomAttribute('custom_layout_update_file', 'new');
$this->attribute->beforeSave($this->category);
$this->assertEmpty($this->category->getCustomAttribute('custom_layout_update')->getValue());
$this->assertEquals('new', $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
+
+ //Existing update chosen
+ $this->category->setCustomAttribute('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setCustomAttribute('custom_layout_update_file', '__existing__');
+ $this->attribute->beforeSave($this->category);
+ $this->assertEquals('test', $this->category->getCustomAttribute('custom_layout_update')->getValue());
+ /** @var AbstractBackend $fileAttribute */
+ $fileAttribute = $this->category->getAttributes()['custom_layout_update_file']->getBackend();
+ $fileAttribute->beforeSave($this->category);
+ $this->assertEquals(null, $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
}
}
From 333ed65f4efa5c2fc62ea710315af280c910eb10 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 3 Sep 2019 15:36:55 -0500
Subject: [PATCH 0107/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Source/LayoutUpdate.php | 2 +-
.../Catalog/Model/Category/DataProvider.php | 16 +++--
.../Product/Attribute/Source/LayoutUpdate.php | 2 +-
.../Product/Form/Modifier/LayoutUpdate.php | 2 +-
.../Catalog/Controller/CategoryTest.php | 11 ++--
.../Backend/CustomlayoutupdateTest.php | 5 +-
.../Model/Category/DataProviderTest.php | 66 +++++++++++++++----
7 files changed, 77 insertions(+), 27 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index 2375a5d36a0a8..1ef1e910978e1 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -69,7 +69,7 @@ public function getOptionsFor(CustomAttributesDataInterface $entity): array
{
$options = $this->getAllOptions();
if ($entity->getCustomAttribute('custom_layout_update')) {
- $existingValue = '__existing__';
+ $existingValue = \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
$existingLabel = 'Use existing';
$options[] = ['label' => $existingLabel, 'value' => $existingValue];
$this->optionsText[$existingValue] = $existingLabel;
diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php
index cff85d6060e34..bd377f4ab302e 100644
--- a/app/code/Magento/Catalog/Model/Category/DataProvider.php
+++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php
@@ -365,8 +365,9 @@ public function getAttributesMeta(Type $entityType)
}
if ($attribute->usesSource()) {
$source = $attribute->getSource();
- if ($source instanceof SpecificSourceInterface) {
- $options = $source->getOptionsFor($this->getCurrentCategory());
+ $currentCategory = $this->getCurrentCategory();
+ if ($source instanceof SpecificSourceInterface && $currentCategory) {
+ $options = $source->getOptionsFor($currentCategory);
} else {
$options = $attribute->getSource()->getAllOptions();
}
@@ -518,6 +519,12 @@ protected function filterFields($categoryData)
private function convertValues($category, $categoryData)
{
foreach ($category->getAttributes() as $attributeCode => $attribute) {
+ if ($attributeCode === 'custom_layout_update_file') {
+ if (!empty($categoryData['custom_layout_update'])) {
+ $categoryData['custom_layout_update_file']
+ = \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
+ }
+ }
if (!isset($categoryData[$attributeCode])) {
continue;
}
@@ -545,11 +552,6 @@ private function convertValues($category, $categoryData)
$categoryData[$attributeCode][0]['type'] = $mime;
}
}
- if ($attributeCode === 'custom_layout_update_file') {
- if (!empty($categoryData['custom_layout_update'])) {
- $categoryData['custom_layout_update_file'] = '__existing__';
- }
- }
}
return $categoryData;
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index d793e110ac25e..78e29002beb25 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -67,7 +67,7 @@ public function getOptionsFor(CustomAttributesDataInterface $entity): array
{
$options = $this->getAllOptions();
if ($entity->getCustomAttribute('custom_layout_update')) {
- $existingValue = '__existing__';
+ $existingValue = \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
$existingLabel = 'Use existing';
$options[] = ['label' => $existingLabel, 'value' => $existingValue];
$this->optionsText[$existingValue] = $existingLabel;
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
index 92afe35c70bb5..de0e640e09d76 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
@@ -39,7 +39,7 @@ public function modifyData(array $data)
if ($oldLayout = $product->getCustomAttribute('custom_layout_update')) {
if ($oldLayout->getValue()) {
$data[$product->getId()][AbstractModifier::DATA_SOURCE_DEFAULT]['custom_layout_update_file']
- = '__existing__';
+ = \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
index 070ef99c15a34..8b9af5483d563 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Catalog\Controller;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Model\Category;
use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
@@ -122,12 +123,12 @@ public function testViewWithCustomUpdate(): void
/** @var CategoryLayoutUpdateManager $layoutManager */
$layoutManager = Bootstrap::getObjectManager()->get(CategoryLayoutUpdateManager::class);
$layoutManager->setCategoryFakeFiles($categoryId, [$file]);
- /** @var Category $category */
- $category = Bootstrap::getObjectManager()->create(Category::class);
- $category->load($categoryId);
+ /** @var CategoryRepositoryInterface $categoryRepo */
+ $categoryRepo = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class);
+ $category = $categoryRepo->get($categoryId);
//Updating the custom attribute.
- $category->setData('custom_layout_update_file', $file);
- $category->save();
+ $category->setCustomAttribute('custom_layout_update_file', $file);
+ $categoryRepo->save($category);
//Viewing the category
$this->dispatch("catalog/category/view/id/$categoryId");
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index 1a8133f675e19..dbc14c7d25dae 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -104,7 +104,10 @@ public function testDependsOnNewUpdate(): void
//Existing update chosen
$this->category->setCustomAttribute('custom_layout_update', 'test');
$this->category->setOrigData('custom_layout_update', 'test');
- $this->category->setCustomAttribute('custom_layout_update_file', '__existing__');
+ $this->category->setCustomAttribute(
+ 'custom_layout_update_file',
+ \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML
+ );
$this->attribute->beforeSave($this->category);
$this->assertEquals('test', $this->category->getCustomAttribute('custom_layout_update')->getValue());
/** @var AbstractBackend $fileAttribute */
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
index b8e1f07364c28..e93761f9043b8 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
@@ -5,11 +5,14 @@
*/
namespace Magento\Catalog\Model\Category;
-use Magento\Catalog\Model\Category\DataProvider;
-use Magento\Eav\Model\Config as EavConfig;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\Registry;
+use PHPUnit\Framework\TestCase;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\CategoryFactory;
+use Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate;
-class DataProviderTest extends \PHPUnit\Framework\TestCase
+class DataProviderTest extends TestCase
{
/**
* @var DataProvider
@@ -17,18 +20,23 @@ class DataProviderTest extends \PHPUnit\Framework\TestCase
private $dataProvider;
/**
- * @var \Magento\Eav\Model\Entity\Type
+ * @var Registry
*/
- private $entityType;
+ private $registry;
/**
- * {@inheritDoc}
+ * @var CategoryFactory
*/
- protected function setUp()
+ private $categoryFactory;
+
+ /**
+ * Create subject instance.
+ *
+ * @return DataProvider
+ */
+ private function createDataProvider(): DataProvider
{
- parent::setUp();
- $objectManager = Bootstrap::getObjectManager();
- $this->dataProvider = $objectManager->create(
+ return Bootstrap::getObjectManager()->create(
DataProvider::class,
[
'name' => 'category_form_data_source',
@@ -36,8 +44,18 @@ protected function setUp()
'requestFieldName' => 'id'
]
);
+ }
- $this->entityType = $objectManager->create(EavConfig::class)->getEntityType('catalog_category');
+ /**
+ * {@inheritDoc}
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $objectManager = Bootstrap::getObjectManager();
+ $this->dataProvider = $this->createDataProvider();
+ $this->registry = $objectManager->get(Registry::class);
+ $this->categoryFactory = $objectManager->get(CategoryFactory::class);
}
/**
@@ -59,4 +77,30 @@ public function testGetMetaRequiredAttributes()
}
}
}
+
+ /**
+ * Check that custom layout update file attribute is processed correctly.
+ *
+ * @return void
+ */
+ public function testCustomLayoutFileAttribute(): void
+ {
+ //File has value
+ /** @var Category $category */
+ $category = $this->categoryFactory->create();
+ $category->load($id = 2);
+ $category->setData('custom_layout_update', null);
+ $category->setData('custom_layout_update_file', $file = 'test-file');
+ $this->registry->register('category', $category);
+ $data = $this->dataProvider->getData();
+ $this->assertEquals($file, $data[$id]['custom_layout_update_file']);
+
+ //File has no value, the deprecated attribute does.
+ $this->dataProvider = $this->createDataProvider();
+ $category->setData('custom_layout_update', $deprecated = 'test-deprecated');
+ $category->setData('custom_layout_update_file', null);
+ $data = $this->dataProvider->getData();
+ $this->assertEquals($deprecated, $data[$id]['custom_layout_update']);
+ $this->assertEquals(LayoutUpdate::VALUE_USE_UPDATE_XML, $data[$id]['custom_layout_update_file']);
+ }
}
From 1304bb49e1a8e2a91f946af2ac452ce003e496ff Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 3 Sep 2019 16:00:44 -0500
Subject: [PATCH 0108/1978] MC-18685: Remove custom layout updates from admin
---
.../Catalog/Model/CategoryRepositoryTest.php | 102 +++++++-----------
1 file changed, 38 insertions(+), 64 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
index f1e235f8c9bf2..e79023e49d4cf 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
@@ -7,14 +7,12 @@
namespace Magento\Catalog\Model;
-use Magento\Backend\Model\Auth;
use Magento\Catalog\Api\CategoryRepositoryInterface;
-use Magento\Catalog\Api\Data\CategoryInterface;
-use Magento\Catalog\Api\Data\CategoryInterfaceFactory;
-use Magento\Framework\Acl\Builder;
+use Magento\Catalog\Api\CategoryRepositoryInterfaceFactory;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
-use Magento\TestFramework\Bootstrap as TestBootstrap;
/**
* Provide tests for CategoryRepository model.
@@ -22,26 +20,14 @@
class CategoryRepositoryTest extends TestCase
{
/**
- * Test subject.
- *
- * @var CategoryRepositoryInterface
- */
- private $repo;
-
- /**
- * @var Auth
- */
- private $auth;
-
- /**
- * @var Builder
+ * @var CategoryLayoutUpdateManager
*/
- private $aclBuilder;
+ private $layoutManager;
/**
- * @var CategoryInterfaceFactory
+ * @var CategoryRepositoryInterfaceFactory
*/
- private $categoryFactory;
+ private $repositoryFactory;
/**
* Sets up common objects.
@@ -50,63 +36,51 @@ class CategoryRepositoryTest extends TestCase
*/
protected function setUp()
{
- $this->repo = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class);
- $this->auth = Bootstrap::getObjectManager()->get(Auth::class);
- $this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
- $this->categoryFactory = Bootstrap::getObjectManager()->get(CategoryInterfaceFactory::class);
+ $this->repositoryFactory = Bootstrap::getObjectManager()->get(CategoryRepositoryInterfaceFactory::class);
+ $this->layoutManager = Bootstrap::getObjectManager()->get(CategoryLayoutUpdateManager::class);
}
/**
- * @inheritDoc
+ * Create subject object.
+ *
+ * @return CategoryRepositoryInterface
*/
- protected function tearDown()
+ private function createRepo(): CategoryRepositoryInterface
{
- parent::tearDown();
-
- $this->auth->logout();
- $this->aclBuilder->resetRuntimeAcl();
+ return $this->repositoryFactory->create();
}
/**
- * Test authorization when saving category's design settings.
+ * Test that custom layout file attribute is saved.
*
+ * @return void
+ * @throws \Throwable
* @magentoDataFixture Magento/Catalog/_files/category.php
- * @magentoAppArea adminhtml
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
*/
- public function testSaveDesign()
+ public function testCustomLayout(): void
{
- $category = $this->repo->get(333);
- $this->auth->login(TestBootstrap::ADMIN_NAME, TestBootstrap::ADMIN_PASSWORD);
-
- //Admin doesn't have access to category's design.
- $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_category_design');
-
- $category->setCustomAttribute('custom_design', 2);
- $category = $this->repo->save($category);
- $customDesignAttribute = $category->getCustomAttribute('custom_design');
- $this->assertTrue(!$customDesignAttribute || !$customDesignAttribute->getValue());
-
- //Admin has access to category' design.
- $this->aclBuilder->getAcl()
- ->allow(null, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
-
- $category->setCustomAttribute('custom_design', 2);
- $category = $this->repo->save($category);
- $this->assertNotEmpty($category->getCustomAttribute('custom_design'));
- $this->assertEquals(2, $category->getCustomAttribute('custom_design')->getValue());
+ //New valid value
+ $repo = $this->createRepo();
+ $category = $repo->get(333);
+ $newFile = 'test';
+ $this->layoutManager->setCategoryFakeFiles(333, [$newFile]);
+ $category->setCustomAttribute('custom_layout_update_file', $newFile);
+ $repo->save($category);
+ $repo = $this->createRepo();
+ $category = $repo->get(333);
+ $this->assertEquals($newFile, $category->getCustomAttribute('custom_layout_update_file')->getValue());
- //Creating a new one
- /** @var CategoryInterface $newCategory */
- $newCategory = $this->categoryFactory->create();
- $newCategory->setName('new category without design');
- $newCategory->setParentId($category->getParentId());
- $newCategory->setIsActive(true);
- $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_category_design');
- $newCategory->setCustomAttribute('custom_design', 2);
- $newCategory = $this->repo->save($newCategory);
- $customDesignAttribute = $newCategory->getCustomAttribute('custom_design');
- $this->assertTrue(!$customDesignAttribute || !$customDesignAttribute->getValue());
+ //Setting non-existent value
+ $newFile = 'does not exist';
+ $category->setCustomAttribute('custom_layout_update_file', $newFile);
+ $caughtException = false;
+ try {
+ $repo->save($category);
+ } catch (LocalizedException $exception) {
+ $caughtException = true;
+ }
+ $this->assertTrue($caughtException);
}
}
From c7a746993cbb7d87e6cb3f4b83b7a69d895145c6 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 3 Sep 2019 16:53:17 -0500
Subject: [PATCH 0109/1978] MC-18685: Remove custom layout updates from admin
---
.../integration/etc/di/preferences/ce.php | 4 +-
.../Model/ProductLayoutUpdateManager.php | 50 +++++++++++++
.../Controller/Adminhtml/CategoryTest.php | 1 +
.../Controller/Adminhtml/ProductTest.php | 58 +++++++++++++++
.../Catalog/Controller/ProductTest.php | 37 ++++++++++
.../Catalog/Model/ProductRepositoryTest.php | 73 ++++++++++---------
.../Form/Modifier/LayoutUpdateTest.php | 66 +++++++++++++++++
7 files changed, 252 insertions(+), 37 deletions(-)
create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/ProductLayoutUpdateManager.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
diff --git a/dev/tests/integration/etc/di/preferences/ce.php b/dev/tests/integration/etc/di/preferences/ce.php
index 87ac54f4591eb..972f7fb3c669b 100644
--- a/dev/tests/integration/etc/di/preferences/ce.php
+++ b/dev/tests/integration/etc/di/preferences/ce.php
@@ -32,5 +32,7 @@
\Magento\Framework\Session\SessionStartChecker::class => \Magento\TestFramework\Session\SessionStartChecker::class,
\Magento\Framework\HTTP\AsyncClientInterface::class => \Magento\TestFramework\HTTP\AsyncClientInterfaceMock::class,
\Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager::class =>
- \Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager::class
+ \Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager::class,
+ \Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager::class =>
+ \Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager::class
];
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/ProductLayoutUpdateManager.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/ProductLayoutUpdateManager.php
new file mode 100644
index 0000000000000..6c8826583be70
--- /dev/null
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/ProductLayoutUpdateManager.php
@@ -0,0 +1,50 @@
+fakeFiles[$forProductId]);
+ } else {
+ $this->fakeFiles[$forProductId] = $files;
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function fetchAvailableFiles(ProductInterface $product): array
+ {
+ if (array_key_exists($product->getId(), $this->fakeFiles)) {
+ return $this->fakeFiles[$product->getId()];
+ }
+
+ return parent::fetchAvailableFiles($product);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
index 94a37327fcc39..8b54beeebbebf 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
@@ -642,6 +642,7 @@ public function testSaveDesign(): void
MessageInterface::TYPE_ERROR
);
}
+
/**
* Test custom update files functionality.
*
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index 547b282474fe6..67b6ec4e7d70f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Catalog\Controller\Adminhtml;
+use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Message\Manager;
@@ -12,6 +13,8 @@
use Magento\Catalog\Model\ProductRepository;
use Magento\Catalog\Model\ProductRepositoryFactory;
use Magento\Framework\Message\MessageInterface;
+use Magento\Store\Model\Store;
+use Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
/**
@@ -442,4 +445,59 @@ public function testSaveDesign(): void
MessageInterface::TYPE_ERROR
);
}
+
+ /**
+ * Test custom update files functionality.
+ *
+ * @magentoDbIsolation enabled
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveCustomLayout(): void
+ {
+ $file = 'test_file';
+ /** @var ProductRepository $repo */
+ $repo = $this->repositoryFactory->create();
+ $product = $repo->get('simple');
+ /** @var ProductLayoutUpdateManager $layoutManager */
+ $layoutManager = Bootstrap::getObjectManager()->get(ProductLayoutUpdateManager::class);
+ $layoutManager->setFakeFiles((int)$product->getId(), [$file]);
+ $requestData = [
+ 'product' => $product->getData()
+ ];
+ $uri = 'backend/catalog/product/save';
+
+ //Saving a wrong file
+ $requestData['product']['custom_layout_update_file'] = $file . 'INVALID';
+ $this->getRequest()->setDispatched(false);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('id', $product->getId());
+ $this->dispatch($uri);
+ $this->assertSessionMessages(
+ self::equalTo(['tst']),
+ MessageInterface::TYPE_ERROR
+ );
+
+ //Checking that the value is not saved
+ /** @var ProductRepository $repo */
+ $repo = $this->repositoryFactory->create();
+ $product = $repo->get('simple');
+ $this->assertEmpty($product->getData('custom_layout_update_file'));
+
+ //Saving the correct file
+ $requestData['product']['custom_layout_update_file'] = $file;
+ $this->getRequest()->setDispatched(false);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('id', $product->getId());
+ $this->dispatch($uri);
+
+ //Checking that the value is saved
+ /** @var ProductRepository $repo */
+ $repo = $this->repositoryFactory->create();
+ $product = $repo->get('simple');
+ $this->assertEquals($file, $product->getData('custom_layout_update_file'));
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php
index ca9db3f28a91b..b4987e425d6b5 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/ProductTest.php
@@ -9,6 +9,12 @@
*/
namespace Magento\Catalog\Controller;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
+use Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager;
+use Magento\TestFramework\Helper\Bootstrap;
+
/**
* @magentoAppIsolation enabled
*/
@@ -186,4 +192,35 @@ public function testImageActionNoImage()
$this->assert404NotFound();
}
+
+ /**
+ * Check that custom layout update files is employed.
+ *
+ * @magentoDataFixture Magento/Catalog/controllers/_files/products.php
+ * @return void
+ */
+ public function testViewWithCustomUpdate(): void
+ {
+ //Setting a fake file for the product.
+ $file = 'test-file';
+ /** @var ProductRepositoryInterface $repository */
+ $repository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
+ $sku = 'simple_product_1';
+ $product = $repository->get($sku);
+ $productId = $product->getId();
+ /** @var ProductLayoutUpdateManager $layoutManager */
+ $layoutManager = Bootstrap::getObjectManager()->get(ProductLayoutUpdateManager::class);
+ $layoutManager->setFakeFiles((int)$productId, [$file]);
+ //Updating the custom attribute.
+ $product->setCustomAttribute('custom_layout_update_file', $file);
+ $repository->save($product);
+
+ //Viewing the product
+ $this->dispatch("catalog/product/view/id/$productId");
+ //Layout handles must contain the file.
+ $handles = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class)
+ ->getUpdate()
+ ->getHandles();
+ $this->assertContains("catalog_product_view_selectable_{$sku}_{$file}", $handles);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php
index fa2a0e5cb34b7..fb07d08faca58 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ProductRepositoryTest.php
@@ -11,6 +11,8 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Bootstrap as TestBootstrap;
use Magento\Framework\Acl\Builder;
@@ -46,15 +48,10 @@ class ProductRepositoryTest extends \PHPUnit\Framework\TestCase
*/
private $productResource;
- /*
- * @var Auth
- */
- private $auth;
-
/**
- * @var Builder
+ * @var ProductLayoutUpdateManager
*/
- private $aclBuilder;
+ private $layoutManager;
/**
* Sets up common objects
@@ -63,21 +60,19 @@ protected function setUp()
{
$this->productRepository = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
$this->searchCriteriaBuilder = Bootstrap::getObjectManager()->get(SearchCriteriaBuilder::class);
- $this->auth = Bootstrap::getObjectManager()->get(Auth::class);
- $this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
$this->productFactory = Bootstrap::getObjectManager()->get(ProductFactory::class);
$this->productResource = Bootstrap::getObjectManager()->get(ProductResource::class);
+ $this->layoutManager = Bootstrap::getObjectManager()->get(ProductLayoutUpdateManager::class);
}
/**
- * @inheritDoc
+ * Create new subject instance.
+ *
+ * @return ProductRepositoryInterface
*/
- protected function tearDown()
+ private function createRepo(): ProductRepositoryInterface
{
- parent::tearDown();
-
- $this->auth->logout();
- $this->aclBuilder->resetRuntimeAcl();
+ return Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
}
/**
@@ -206,30 +201,36 @@ public function testUpdateProductSku()
}
/**
- * Test authorization when saving product's design settings.
+ * Test that custom layout file attribute is saved.
*
+ * @return void
+ * @throws \Throwable
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
- * @magentoAppArea adminhtml
+ * @magentoDbIsolation enabled
+ * @magentoAppIsolation enabled
*/
- public function testSaveDesign()
+ public function testCustomLayout(): void
{
- $product = $this->productRepository->get('simple');
- $this->auth->login(TestBootstrap::ADMIN_NAME, TestBootstrap::ADMIN_PASSWORD);
-
- //Admin doesn't have access to product's design.
- $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_product_design');
-
- $product->setCustomAttribute('custom_design', 2);
- $product = $this->productRepository->save($product);
- $this->assertEmpty($product->getCustomAttribute('custom_design'));
-
- //Admin has access to products' design.
- $this->aclBuilder->getAcl()
- ->allow(null, ['Magento_Catalog::products','Magento_Catalog::edit_product_design']);
-
- $product->setCustomAttribute('custom_design', 2);
- $product = $this->productRepository->save($product);
- $this->assertNotEmpty($product->getCustomAttribute('custom_design'));
- $this->assertEquals(2, $product->getCustomAttribute('custom_design')->getValue());
+ //New valid value
+ $repo = $this->createRepo();
+ $product = $repo->get('simple');
+ $newFile = 'test';
+ $this->layoutManager->setFakeFiles((int)$product->getId(), [$newFile]);
+ $product->setCustomAttribute('custom_layout_update_file', $newFile);
+ $repo->save($product);
+ $repo = $this->createRepo();
+ $product = $repo->get('simple');
+ $this->assertEquals($newFile, $product->getCustomAttribute('custom_layout_update_file')->getValue());
+
+ //Setting non-existent value
+ $newFile = 'does not exist';
+ $product->setCustomAttribute('custom_layout_update_file', $newFile);
+ $caughtException = false;
+ try {
+ $repo->save($product);
+ } catch (LocalizedException $exception) {
+ $caughtException = true;
+ }
+ $this->assertTrue($caughtException);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
new file mode 100644
index 0000000000000..4ec50dc26da5c
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
@@ -0,0 +1,66 @@
+locator = $this->getMockForAbstractClass(LocatorInterface::class);
+ $this->modifier = Bootstrap::getObjectManager()->create(LayoutUpdate::class, ['locator' => $this->locator]);
+ $this->repo = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
+ }
+
+ /**
+ * Test that data is being modified accordingly.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @return void
+ */
+ public function testModifyData(): void
+ {
+ $product = $this->repo->get('simple');
+ $this->locator->method('getProduct')->willReturn($product);
+ $product->setCustomAttribute('custom_layout_update', 'something');
+
+ $data = $this->modifier->modifyData([$product->getId() => ['product' => []]]);
+ $this->assertEquals(
+ LayoutUpdateAttribute::VALUE_USE_UPDATE_XML,
+ $data[$product->getId()]['product']['custom_layout_update_file']
+ );
+ }
+}
From b3f510d037dffb62b70fb14d7f3fba63b9670a43 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Wed, 4 Sep 2019 11:29:54 +0300
Subject: [PATCH 0110/1978] graphQl-890: Replaced usage of the CartItemQuantity
with the CartItemInterface
---
.../Magento/QuoteGraphQl/etc/schema.graphqls | 6 ++--
.../Customer/AddSimpleProductToCartTest.php | 30 +++++++++++++++++++
.../Guest/AddSimpleProductToCartTest.php | 30 +++++++++++++++++++
3 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index c458b5e9dc05d..d7741c392e9f7 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -216,14 +216,14 @@ interface CartAddressInterface @typeResolver(class: "\\Magento\\QuoteGraphQl\\Mo
type ShippingCartAddress implements CartAddressInterface {
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
- items_weight: Float
- cart_items: [CartItemQuantity]
+ items_weight: Float @deprecated
+ cart_items: [CartItemInterface]
}
type BillingCartAddress implements CartAddressInterface {
}
-type CartItemQuantity {
+type CartItemQuantity @deprecated(reason: "Use CartItemInterface instead") {
cart_item_id: Int!
quantity: Float!
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
index e1b93e0bdb857..19251b3741106 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
@@ -52,6 +52,22 @@ public function testAddSimpleProductToCart()
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
+ self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
+
+ self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
+ self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']);
+ self::assertEquals(10, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['value']);
+ self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['currency']);
+
+ self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
+ self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']);
+ self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['value']);
+ self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['currency']);
+
+ self::assertArrayHasKey('row_total_including_tax', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
+ self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']);
+ self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['value']);
+ self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['currency']);
}
/**
@@ -262,6 +278,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
product {
sku
}
+ prices {
+ price {
+ value
+ currency
+ }
+ row_total {
+ value
+ currency
+ }
+ row_total_including_tax {
+ value
+ currency
+ }
+ }
}
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
index 4deed99243f9d..cc7365fb7bcf2 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
@@ -47,6 +47,22 @@ public function testAddSimpleProductToCart()
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
+ self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
+
+ self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
+ self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']);
+ self::assertEquals(10, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['value']);
+ self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['currency']);
+
+ self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
+ self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']);
+ self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['value']);
+ self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['currency']);
+
+ self::assertArrayHasKey('row_total_including_tax', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
+ self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']);
+ self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['value']);
+ self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['currency']);
}
/**
@@ -231,6 +247,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
product {
sku
}
+ prices {
+ price {
+ value
+ currency
+ }
+ row_total {
+ value
+ currency
+ }
+ row_total_including_tax {
+ value
+ currency
+ }
+ }
}
}
}
From f7ab08e6103ad1a1b503b6226e9edad53f6e7700 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Wed, 4 Sep 2019 11:56:31 +0300
Subject: [PATCH 0111/1978] graphQl-890: fixed static tests
---
.../Customer/AddSimpleProductToCartTest.php | 30 ++++++++++++-------
.../Guest/AddSimpleProductToCartTest.php | 30 ++++++++++++-------
2 files changed, 40 insertions(+), 20 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
index 19251b3741106..f861b9db98fe7 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
@@ -55,19 +55,29 @@ public function testAddSimpleProductToCart()
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
- self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']);
- self::assertEquals(10, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['value']);
- self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['currency']);
+ $price = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price'];
+ self::assertArrayHasKey('value', $price);
+ self::assertEquals(10, $price['value']);
+ self::assertArrayHasKey('currency', $price);
+ self::assertEquals('USD', $price['currency']);
self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
- self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']);
- self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['value']);
- self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['currency']);
+ $rowTotal = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total'];
+ self::assertArrayHasKey('value', $rowTotal);
+ self::assertEquals(20, $rowTotal['value']);
+ self::assertArrayHasKey('currency', $rowTotal);
+ self::assertEquals('USD', $rowTotal['currency']);
- self::assertArrayHasKey('row_total_including_tax', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
- self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']);
- self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['value']);
- self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['currency']);
+ self::assertArrayHasKey(
+ 'row_total_including_tax',
+ $response['addSimpleProductsToCart']['cart']['items'][0]['prices']
+ );
+ $rowTotalIncludingTax =
+ $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax'];
+ self::assertArrayHasKey('value', $rowTotalIncludingTax);
+ self::assertEquals(20, $rowTotalIncludingTax['value']);
+ self::assertArrayHasKey('currency', $rowTotalIncludingTax);
+ self::assertEquals('USD', $rowTotalIncludingTax['currency']);
}
/**
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
index cc7365fb7bcf2..1a3a1c8a738e5 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
@@ -50,19 +50,29 @@ public function testAddSimpleProductToCart()
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
- self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']);
- self::assertEquals(10, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['value']);
- self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price']['currency']);
+ $price = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price'];
+ self::assertArrayHasKey('value', $price);
+ self::assertEquals(10, $price['value']);
+ self::assertArrayHasKey('currency', $price);
+ self::assertEquals('USD', $price['currency']);
self::assertArrayHasKey('row_total', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
- self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']);
- self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['value']);
- self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total']['currency']);
+ $rowTotal = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total'];
+ self::assertArrayHasKey('value', $rowTotal);
+ self::assertEquals(20, $rowTotal['value']);
+ self::assertArrayHasKey('currency', $rowTotal);
+ self::assertEquals('USD', $rowTotal['currency']);
- self::assertArrayHasKey('row_total_including_tax', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
- self::assertArrayHasKey('value', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']);
- self::assertEquals(20, $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['value']);
- self::assertEquals('USD', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax']['currency']);
+ self::assertArrayHasKey(
+ 'row_total_including_tax',
+ $response['addSimpleProductsToCart']['cart']['items'][0]['prices']
+ );
+ $rowTotalIncludingTax =
+ $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['row_total_including_tax'];
+ self::assertArrayHasKey('value', $rowTotalIncludingTax);
+ self::assertEquals(20, $rowTotalIncludingTax['value']);
+ self::assertArrayHasKey('currency', $rowTotalIncludingTax);
+ self::assertEquals('USD', $rowTotalIncludingTax['currency']);
}
/**
From ab5bc5d9f81beb38aa60cab17cfe38e1cb5f2b04 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 4 Sep 2019 16:14:32 +0400
Subject: [PATCH 0112/1978] MC-18820: Increase test coverage for Admin
functional area
- Automation test for MC-6310
---
.../ActionGroup/AdminElasticConnectionTestActionGroup.xml | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
index e40bf3691e8db..27b53b7c3e6dd 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
@@ -15,8 +15,9 @@
-
+
+
-
\ No newline at end of file
+
From cde61373e25ea844d6e28dba45ab5008c3b88d6c Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 4 Sep 2019 12:00:07 -0500
Subject: [PATCH 0113/1978] MC-18685: Remove custom layout updates from admin
---
.../Catalog/Controller/Adminhtml/Category.php | 18 +++--
.../Controller/Adminhtml/Category/Save.php | 4 +-
.../Product/Initialization/Helper.php | 12 ++-
.../Magento/Catalog/Helper/Product/View.php | 1 +
.../Attribute/Backend/LayoutUpdate.php | 1 +
.../Attribute/Source/LayoutUpdate.php | 1 +
.../Category/Authorization.php | 8 +-
app/code/Magento/Catalog/Model/Design.php | 2 +
app/code/Magento/Catalog/Model/Product.php | 4 +-
.../Attribute/Backend/LayoutUpdate.php | 1 +
.../Product/Authorization.php | 62 ++++++++-------
.../Observer/CategoryDesignAuthorization.php | 3 +-
.../Catalog/Plugin/CategoryAuthorization.php | 3 +-
.../Catalog/Plugin/ProductAuthorization.php | 3 +-
.../Adminhtml/Category/MoveTest.php | 3 -
.../Cms/Controller/Adminhtml/Page/Save.php | 38 ++++++---
.../Cms/Controller/Page/Authorization.php | 59 +++++++-------
app/code/Magento/Cms/Helper/Page.php | 7 +-
.../Page/CustomLayoutManagerInterface.php | 1 -
.../Magento/Cms/Model/Page/DataProvider.php | 1 +
.../Magento/Cms/Observer/PageAclPlugin.php | 1 +
.../Controller/Adminhtml/Page/SaveTest.php | 4 +-
app/code/Magento/Cms/composer.json | 3 +-
.../Catalog/Api/CategoryRepositoryTest.php | 77 +++++++++++--------
.../Api/ProductRepositoryInterfaceTest.php | 8 +-
.../Magento/Cms/Api/PageRepositoryTest.php | 2 +
.../Controller/Adminhtml/CategoryTest.php | 6 +-
27 files changed, 202 insertions(+), 131 deletions(-)
rename app/code/Magento/Catalog/{Controller/Adminhtml => Model}/Category/Authorization.php (92%)
rename app/code/Magento/Catalog/{Controller/Adminhtml => Model}/Product/Authorization.php (53%)
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
index 61fd714d518ba..c32ceb5109e7c 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category.php
@@ -40,6 +40,7 @@ public function __construct(
/**
* Initialize requested category and put it into registry.
+ *
* Root category can be returned, if inappropriate store/category is specified
*
* @param bool $getRootInstead
@@ -98,6 +99,7 @@ private function resolveCategoryId() : int
* Resolve store id
*
* Tries to take store id from store HTTP parameter
+ *
* @see Store
*
* @return int
@@ -142,13 +144,15 @@ protected function ajaxRequestResponse($category, $resultPage)
}
}
- $eventResponse = new \Magento\Framework\DataObject([
- 'content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml()
- . $resultPage->getLayout()->getBlock('category.tree')
- ->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'),
- 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(),
- 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml()
- ]);
+ $eventResponse = new \Magento\Framework\DataObject(
+ [
+ 'content' => $resultPage->getLayout()->getUiComponent('category_form')->getFormHtml()
+ . $resultPage->getLayout()->getBlock('category.tree')
+ ->getBreadcrumbsJavascript($breadcrumbsPath, 'editingCategoryBreadcrumbs'),
+ 'messages' => $resultPage->getLayout()->getMessagesBlock()->getGroupedHtml(),
+ 'toolbar' => $resultPage->getLayout()->getBlock('page.actions.toolbar')->toHtml()
+ ]
+ );
$this->_eventManager->dispatch(
'category_prepare_ajax_response',
['response' => $eventResponse, 'controller' => $this]
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
index 95ef5e1279e1e..9812dda73fd3e 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
@@ -211,7 +211,7 @@ public function execute()
__('The "%1" attribute is required. Enter and try again.', $attribute)
);
} else {
- throw new \Exception($error);
+ throw new \RuntimeException($error);
}
}
}
@@ -220,10 +220,12 @@ public function execute()
$category->save();
$this->messageManager->addSuccessMessage(__('You saved the category.'));
+ // phpcs:disable Magento2.Exceptions.ThrowCatch
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addExceptionMessage($e);
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$this->_getSession()->setCategoryData($categoryPostData);
+ // phpcs:disable Magento2.Exceptions.ThrowCatch
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(__('Something went wrong while saving the category.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
index 2494412326075..b3ee23c9caf58 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
@@ -17,7 +17,7 @@
use Magento\Catalog\Model\Product\LinkTypeProvider;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\Helper\AttributeFilter;
-use Magento\Catalog\Controller\Adminhtml\Product\Authorization as ProductAuthorization;
+use Magento\Catalog\Model\Product\Authorization as ProductAuthorization;
/**
* Product helper
@@ -116,6 +116,7 @@ class Helper
* @param ProductRepositoryInterface|null $productRepository
* @param LinkTypeProvider|null $linkTypeProvider
* @param AttributeFilter|null $attributeFilter
+ * @param ProductAuthorization|null $productAuthorization
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -459,9 +460,12 @@ private function fillProductOptions(Product $product, array $productOptions)
}
if (isset($customOptionData['values'])) {
- $customOptionData['values'] = array_filter($customOptionData['values'], function ($valueData) {
- return empty($valueData['is_delete']);
- });
+ $customOptionData['values'] = array_filter(
+ $customOptionData['values'],
+ function ($valueData) {
+ return empty($valueData['is_delete']);
+ }
+ );
}
$customOption = $this->customOptionFactory->create(['data' => $customOptionData]);
diff --git a/app/code/Magento/Catalog/Helper/Product/View.php b/app/code/Magento/Catalog/Helper/Product/View.php
index 26776500438e5..cf5b15cadc997 100644
--- a/app/code/Magento/Catalog/Helper/Product/View.php
+++ b/app/code/Magento/Catalog/Helper/Product/View.php
@@ -86,6 +86,7 @@ class View extends \Magento\Framework\App\Helper\AbstractHelper
* @param array $messageGroups
* @param \Magento\Framework\Stdlib\StringUtils|null $string
* @param LayoutUpdateManager|null $layoutUpdateManager
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\App\Helper\Context $context,
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index f84b718a4025f..ee10b170f0d84 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -73,6 +73,7 @@ private function setValue(?string $value, Category $object): void
/**
* @inheritDoc
+ *
* @param Category $object
*/
public function validate($object)
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index 1ef1e910978e1..648fe2c57290d 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -63,6 +63,7 @@ public function getOptionText($value)
/**
* @inheritDoc
+ *
* @param CategoryInterface $entity
*/
public function getOptionsFor(CustomAttributesDataInterface $entity): array
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php b/app/code/Magento/Catalog/Model/Category/Authorization.php
similarity index 92%
rename from app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
rename to app/code/Magento/Catalog/Model/Category/Authorization.php
index 023839a16ee89..a40db89e35906 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Category/Authorization.php
@@ -6,10 +6,10 @@
declare(strict_types=1);
-namespace Magento\Catalog\Controller\Adminhtml\Category;
+namespace Magento\Catalog\Model\Category;
use Magento\Catalog\Api\Data\CategoryInterface;
-use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Catalog\Model\CategoryFactory;
use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Framework\AuthorizationInterface;
@@ -46,7 +46,7 @@ public function __construct(AuthorizationInterface $authorization, CategoryFacto
*
* @throws AuthorizationException
* @throws NoSuchEntityException When a category with invalid ID given.
- * @param CategoryInterface|Category $category
+ * @param CategoryInterface|CategoryModel $category
* @return void
*/
public function authorizeSavingOf(CategoryInterface $category): void
@@ -67,7 +67,7 @@ function (AttributeInterface $attribute) {
}
}
} else {
- /** @var Category $savedCategory */
+ /** @var CategoryModel $savedCategory */
$savedCategory = $this->categoryFactory->create();
$savedCategory->load($category->getId());
if (!$savedCategory->getName()) {
diff --git a/app/code/Magento/Catalog/Model/Design.php b/app/code/Magento/Catalog/Model/Design.php
index 854f8f5648926..fed18a5a60913 100644
--- a/app/code/Magento/Catalog/Model/Design.php
+++ b/app/code/Magento/Catalog/Model/Design.php
@@ -17,6 +17,7 @@
*
* @author Magento Core Team
* @since 100.0.2
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Design extends \Magento\Framework\Model\AbstractModel
{
@@ -62,6 +63,7 @@ class Design extends \Magento\Framework\Model\AbstractModel
* @param TranslateInterface|null $translator
* @param CategoryLayoutManager|null $categoryLayoutManager
* @param ProductLayoutManager|null $productLayoutManager
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\Model\Context $context,
diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php
index 93f5da70d40ea..560a1fbacda41 100644
--- a/app/code/Magento/Catalog/Model/Product.php
+++ b/app/code/Magento/Catalog/Model/Product.php
@@ -825,10 +825,10 @@ public function getStoreIds()
}
foreach ($websiteIds as $websiteId) {
$websiteStores = $this->_storeManager->getWebsite($websiteId)->getStoreIds();
- $storeIds = array_merge($storeIds, $websiteStores);
+ $storeIds[] = $websiteStores;
}
}
- $this->setStoreIds($storeIds);
+ $this->setStoreIds(array_merge(...$storeIds));
}
return $this->getData('store_ids');
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index 240c97fd66bd2..e71e27cac6dd0 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -73,6 +73,7 @@ private function setValue(?string $value, Product $object): void
/**
* @inheritDoc
+ *
* @param Product $object
*/
public function validate($object)
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php b/app/code/Magento/Catalog/Model/Product/Authorization.php
similarity index 53%
rename from app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
rename to app/code/Magento/Catalog/Model/Product/Authorization.php
index d1ee659ce8175..9a5e8fc396dd5 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Product/Authorization.php
@@ -6,10 +6,10 @@
declare(strict_types=1);
-namespace Magento\Catalog\Controller\Adminhtml\Product;
+namespace Magento\Catalog\Model\Product;
use Magento\Catalog\Api\Data\ProductInterface;
-use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product as ProductModel;
use Magento\Catalog\Model\ProductFactory;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
@@ -40,47 +40,55 @@ public function __construct(AuthorizationInterface $authorization, ProductFactor
$this->productFactory = $factory;
}
+ /**
+ * Check whether the product has changed.
+ *
+ * @param ProductModel $product
+ * @param ProductModel|null $oldProduct
+ * @return bool
+ */
+ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProduct = null): bool
+ {
+ $designAttributes = [
+ 'custom_design',
+ 'page_layout',
+ 'options_container',
+ 'custom_layout_update',
+ 'custom_design_from',
+ 'custom_design_to',
+ 'custom_layout_update_file'
+ ];
+ foreach ($designAttributes as $designAttribute) {
+ $oldValue = $oldProduct ? $oldProduct->getData($designAttribute) : null;
+ if ($product->getData($designAttribute) != $oldValue) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Authorize saving of a product.
*
* @throws AuthorizationException
* @throws NoSuchEntityException When product with invalid ID given.
- * @param ProductInterface|Product $product
+ * @param ProductInterface|ProductModel $product
* @return void
*/
public function authorizeSavingOf(ProductInterface $product): void
{
if (!$this->authorization->isAllowed('Magento_Catalog::edit_product_design')) {
- $notAllowed = false;
- if (!$product->getId()) {
- if ($product->getData('custom_design')
- || $product->getData('page_layout')
- || $product->getData('options_container')
- || $product->getData('custom_layout_update')
- || $product->getData('custom_design_from')
- || $product->getData('custom_design_to')
- ) {
- $notAllowed = true;
- }
- } else {
- /** @var Product $savedProduct */
+ $savedProduct = null;
+ if ($product->getId()) {
+ /** @var ProductModel $savedProduct */
$savedProduct = $this->productFactory->create();
$savedProduct->load($product->getId());
if (!$savedProduct->getSku()) {
throw NoSuchEntityException::singleField('id', $product->getId());
}
- if ($product->getData('custom_design') != $savedProduct->getData('custom_design')
- || $product->getData('page_layout') != $savedProduct->getData('page_layout')
- || $product->getData('options_container') != $savedProduct->getData('options_container')
- || $product->getData('custom_layout_update') != $savedProduct->getData('custom_layout_update')
- || $product->getData('custom_design_from') != $savedProduct->getData('custom_design_from')
- || $product->getData('custom_design_to') != $savedProduct->getData('custom_design_to')
- ) {
- $notAllowed = true;
- }
}
-
- if ($notAllowed) {
+ if ($this->hasProductChanged($product, $savedProduct)) {
throw new AuthorizationException(__('Not allowed to edit the product\'s design attributes'));
}
}
diff --git a/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php b/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php
index b6486bd9256b1..94977485b95b3 100644
--- a/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php
+++ b/app/code/Magento/Catalog/Observer/CategoryDesignAuthorization.php
@@ -8,7 +8,7 @@
namespace Magento\Catalog\Observer;
use Magento\Catalog\Api\Data\CategoryInterface;
-use Magento\Catalog\Controller\Adminhtml\Category\Authorization;
+use Magento\Catalog\Model\Category\Authorization;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
use Magento\Framework\Exception\AuthorizationException;
@@ -33,6 +33,7 @@ public function __construct(Authorization $authorization)
/**
* @inheritDoc
+ *
* @throws AuthorizationException
*/
public function execute(Observer $observer)
diff --git a/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php b/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php
index 1e4f2ddc38b82..af2dccb96f937 100644
--- a/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php
+++ b/app/code/Magento/Catalog/Plugin/CategoryAuthorization.php
@@ -10,7 +10,7 @@
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\CategoryRepositoryInterface;
-use Magento\Catalog\Controller\Adminhtml\Category\Authorization;
+use Magento\Catalog\Model\Category\Authorization;
use Magento\Framework\Exception\LocalizedException;
/**
@@ -38,6 +38,7 @@ public function __construct(Authorization $authorization)
* @param CategoryInterface $category
* @throws LocalizedException
* @return array
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(CategoryRepositoryInterface $subject, CategoryInterface $category): array
{
diff --git a/app/code/Magento/Catalog/Plugin/ProductAuthorization.php b/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
index 2de7c1d5bc681..57a928731be93 100644
--- a/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
+++ b/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
@@ -10,7 +10,7 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
-use Magento\Catalog\Controller\Adminhtml\Product\Authorization;
+use Magento\Catalog\Model\Product\Authorization;
use Magento\Framework\Exception\LocalizedException;
/**
@@ -39,6 +39,7 @@ public function __construct(Authorization $authorization)
* @param bool $saveOptions
* @throws LocalizedException
* @return array
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(ProductRepositoryInterface $subject, ProductInterface $product, $saveOptions): array
{
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
index 746d3340a6605..7b151499d2d08 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
@@ -134,7 +134,6 @@ public function testExecuteWithGenericException()
->willReturn($categoryMock);
$this->objectManager->expects($this->any())
->method('get')
- ->withConsecutive([Registry::class], [Registry::class], [\Magento\Cms\Model\Wysiwyg\Config::class])
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
$categoryMock->expects($this->once())
->method('move')
@@ -208,7 +207,6 @@ public function testExecuteWithLocalizedException()
->willReturn($categoryMock);
$this->objectManager->expects($this->any())
->method('get')
- ->withConsecutive([Registry::class], [Registry::class], [\Magento\Cms\Model\Wysiwyg\Config::class])
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
$this->messageManager->expects($this->once())
->method('addExceptionMessage');
@@ -280,7 +278,6 @@ public function testSuccessfulCategorySave()
->willReturn($categoryMock);
$this->objectManager->expects($this->any())
->method('get')
- ->withConsecutive([Registry::class], [Registry::class], [\Magento\Cms\Model\Wysiwyg\Config::class])
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
$this->messageManager->expects($this->once())
->method('getMessages')
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 974bc044e3ab0..1e4896c449d59 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -16,6 +16,8 @@
/**
* Save CMS page action.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Save extends \Magento\Backend\App\Action implements HttpPostActionInterface
{
@@ -57,6 +59,7 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
* @param DataPersistorInterface $dataPersistor
* @param \Magento\Cms\Model\PageFactory|null $pageFactory
* @param \Magento\Cms\Api\PageRepositoryInterface|null $pageRepository
+ * @param CustomLayoutRepositoryInterface|null $customLayoutRepository
*/
public function __construct(
Action\Context $context,
@@ -103,7 +106,6 @@ public function execute()
$customLayoutFile = null;
}
-
/** @var \Magento\Cms\Model\Page $model */
$model = $this->pageFactory->create();
@@ -125,21 +127,12 @@ public function execute()
['page' => $model, 'request' => $this->getRequest()]
);
- if (!$this->dataProcessor->validate($data)) {
- return $resultRedirect->setPath('*/*/edit', ['page_id' => $model->getId(), '_current' => true]);
- }
-
- $this->pageRepository->save($model);
- if ($customLayoutFile) {
- $this->customLayoutRepository->save(new CustomLayoutSelected($model->getId(), $customLayoutFile));
- } else {
- $this->customLayoutRepository->deleteFor($model->getId());
- }
+ $this->savePage($model, $customLayoutFile);
$this->messageManager->addSuccessMessage(__('You saved the page.'));
return $this->processResultRedirect($model, $resultRedirect, $data);
} catch (LocalizedException $e) {
$this->messageManager->addExceptionMessage($e->getPrevious() ?: $e);
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
$this->messageManager->addExceptionMessage($e, __('Something went wrong while saving the page.'));
}
@@ -149,6 +142,27 @@ public function execute()
return $resultRedirect->setPath('*/*/');
}
+ /**
+ * Save the page.
+ *
+ * @param Page $page
+ * @param string|null $customLayoutFile
+ * @return void
+ * @throws \Throwable
+ */
+ private function savePage(Page $page, ?string $customLayoutFile): void
+ {
+ if (!$this->dataProcessor->validate($page->getData())) {
+ throw new \InvalidArgumentException('Page is invalid');
+ }
+ $this->pageRepository->save($page);
+ if ($customLayoutFile) {
+ $this->customLayoutRepository->save(new CustomLayoutSelected($page->getId(), $customLayoutFile));
+ } else {
+ $this->customLayoutRepository->deleteFor($page->getId());
+ }
+ }
+
/**
* Process result redirect
*
diff --git a/app/code/Magento/Cms/Controller/Page/Authorization.php b/app/code/Magento/Cms/Controller/Page/Authorization.php
index f223a5c4d164c..a5ac659dd80f6 100644
--- a/app/code/Magento/Cms/Controller/Page/Authorization.php
+++ b/app/code/Magento/Cms/Controller/Page/Authorization.php
@@ -41,6 +41,35 @@ public function __construct(
$this->authorization = $authorization;
}
+ /**
+ * Check whether the design fields have been changed.
+ *
+ * @param PageInterface $page
+ * @param PageInterface|null $oldPage
+ * @return bool
+ */
+ private function hasPageChanged(PageInterface $page, ?PageInterface $oldPage): bool
+ {
+ $oldUpdateXml = $oldPage ? $oldPage->getLayoutUpdateXml() : null;
+ $oldPageLayout = $oldPage ? $oldPage->getPageLayout() : null;
+ $oldCustomTheme = $oldPage ? $oldPage->getCustomTheme() : null;
+ $oldLayoutUpdate = $oldPage ? $oldPage->getCustomLayoutUpdateXml() : null;
+ $oldThemeFrom = $oldPage ? $oldPage->getCustomThemeFrom() : null;
+ $oldThemeTo = $oldPage ? $oldPage->getCustomThemeTo() : null;
+
+ if ($page->getLayoutUpdateXml() !== $oldUpdateXml
+ || $page->getPageLayout() !== $oldPageLayout
+ || $page->getCustomTheme() !== $oldCustomTheme
+ || $page->getCustomLayoutUpdateXml() !== $oldLayoutUpdate
+ || $page->getCustomThemeFrom() !== $oldThemeFrom
+ || $page->getCustomThemeTo() !== $oldThemeTo
+ ) {
+ return true;
+ }
+
+ return false;
+ }
+
/**
* Authorize user before updating a page.
*
@@ -53,33 +82,11 @@ public function authorizeFor(PageInterface $page): void
{
//Validate design changes.
if (!$this->authorization->isAllowed('Magento_Cms::save_design')) {
- $notAllowed = false;
- if (!$page->getId()) {
- if ($page->getLayoutUpdateXml()
- || $page->getPageLayout()
- || $page->getCustomTheme()
- || $page->getCustomLayoutUpdateXml()
- || $page->getCustomThemeFrom()
- || $page->getCustomThemeTo()
- ) {
- //Not allowed to set design properties value for new pages.
- $notAllowed = true;
- }
- } else {
- $savedPage = $this->pageRepository->getById($page->getId());
- if ($page->getLayoutUpdateXml() !== $savedPage->getLayoutUpdateXml()
- || $page->getPageLayout() !== $savedPage->getPageLayout()
- || $page->getCustomTheme() !== $savedPage->getCustomTheme()
- || $page->getCustomThemeTo() !== $savedPage->getCustomThemeTo()
- || $page->getCustomThemeFrom() !== $savedPage->getCustomThemeFrom()
- || $page->getCustomLayoutUpdateXml() !== $savedPage->getCustomLayoutUpdateXml()
- ) {
- //Not allowed to update design settings.
- $notAllowed = true;
- }
+ $oldPage = null;
+ if ($page->getId()) {
+ $oldPage = $this->pageRepository->getById($page->getId());
}
-
- if ($notAllowed) {
+ if ($this->hasPageChanged($page, $oldPage)) {
throw new AuthorizationException(
__('You are not allowed to change CMS pages design settings')
);
diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php
index 634833ff45a23..bbef6fc059c36 100644
--- a/app/code/Magento/Cms/Helper/Page.php
+++ b/app/code/Magento/Cms/Helper/Page.php
@@ -103,6 +103,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper
* @param \Magento\Framework\Escaper $escaper
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param CustomLayoutManagerInterface|null $customLayoutManager
+ * @param CustomLayoutRepositoryInterface|null $customLayoutRepo
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -176,7 +177,11 @@ public function prepareResultPage(Action $action, $pageId = null)
$pageHandles = ['id' => str_replace('/', '_', $this->_page->getIdentifier())];
//Selected custom updates.
try {
- $this->customLayoutManager->applyUpdate($resultPage, $this->customLayoutRepo->getFor($this->_page->getId()));
+ $this->customLayoutManager->applyUpdate(
+ $resultPage,
+ $this->customLayoutRepo->getFor($this->_page->getId())
+ );
+ // phpcs:disable Magento2.CodeAnalysis.EmptyBlock.DetectedCatch
} catch (NoSuchEntityException $exception) {
//No custom layout selected
}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php b/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
index 8d66ff36c846e..6f15fcef7f8f4 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayoutManagerInterface.php
@@ -25,7 +25,6 @@ interface CustomLayoutManagerInterface
*/
public function fetchAvailableFiles(PageInterface $page): array;
-
/**
* Apply the page's layout settings.
*
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
index 801440eaf0bcc..fb0b4eeefa84a 100644
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ b/app/code/Magento/Cms/Model/Page/DataProvider.php
@@ -59,6 +59,7 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider
* @param AuthorizationInterface|null $auth
* @param RequestInterface|null $request
* @param CustomLayoutManagerInterface|null $customLayoutManager
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
$name,
diff --git a/app/code/Magento/Cms/Observer/PageAclPlugin.php b/app/code/Magento/Cms/Observer/PageAclPlugin.php
index c8dc98f6f2807..b7e12fb7cb4b1 100644
--- a/app/code/Magento/Cms/Observer/PageAclPlugin.php
+++ b/app/code/Magento/Cms/Observer/PageAclPlugin.php
@@ -37,6 +37,7 @@ public function __construct(Authorization $authorization)
* @param PageInterface $page
* @return array
* @throws \Magento\Framework\Exception\LocalizedException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(PageRepositoryInterface $subject, PageInterface $page): array
{
diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
index 26b4055923107..bc6703eaf4426 100644
--- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
@@ -157,6 +157,7 @@ public function testSaveAction()
$this->pageRepository->expects($this->once())->method('getById')->with($this->pageId)->willReturn($page);
$page->expects($this->once())->method('setData');
+ $page->method('getId')->willReturn($this->pageId);
$this->pageRepository->expects($this->once())->method('save')->with($page);
$this->dataPersistorMock->expects($this->any())
@@ -235,6 +236,7 @@ public function testSaveAndContinue()
$page = $this->getMockBuilder(\Magento\Cms\Model\Page::class)
->disableOriginalConstructor()
->getMock();
+ $page->method('getId')->willReturn(1);
$this->pageFactory->expects($this->atLeastOnce())
->method('create')
->willReturn($page);
@@ -293,7 +295,7 @@ public function testSaveActionThrowsException()
$this->dataPersistorMock->expects($this->any())
->method('set')
- ->with('cms_page', ['page_id' => $this->pageId]);
+ ->with('cms_page', ['page_id' => $this->pageId, 'custom_layout_update_xml' => null]);
$this->resultRedirect->expects($this->atLeastOnce())
->method('setPath')
diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json
index d04587bbdd728..91036d31fdc2b 100644
--- a/app/code/Magento/Cms/composer.json
+++ b/app/code/Magento/Cms/composer.json
@@ -15,8 +15,7 @@
"magento/module-theme": "*",
"magento/module-ui": "*",
"magento/module-variable": "*",
- "magento/module-widget": "*",
- "magento/module-authorization": "*"
+ "magento/module-widget": "*"
},
"suggest": {
"magento/module-cms-sample-data": "*"
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
index 7e010d7631eed..510a4f1594fff 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
@@ -16,6 +16,11 @@
use Magento\Authorization\Model\RoleFactory;
use Magento\Authorization\Model\RulesFactory;
+/**
+ * Test repository web API.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class CategoryRepositoryTest extends WebapiAbstract
{
const RESOURCE_PATH = '/V1/categories';
@@ -323,23 +328,53 @@ protected function updateCategory($id, $data, ?string $token = null)
}
/**
- * Test design settings authorization
+ * Update admin role resources list.
*
- * @magentoApiDataFixture Magento/User/_files/user_with_custom_role.php
- * @throws \Throwable
+ * @param string $roleName
+ * @param string[] $resources
* @return void
*/
- public function testSaveDesign(): void
+ private function updateRoleResources(string $roleName, array $resources): void
{
- //Updating our admin user's role to allow saving categories but not their design settings.
/** @var Role $role */
$role = $this->roleFactory->create();
- $role->load('test_custom_role', 'role_name');
+ $role->load($roleName, 'role_name');
/** @var Rules $rules */
$rules = $this->rulesFactory->create();
$rules->setRoleId($role->getId());
- $rules->setResources(['Magento_Catalog::categories']);
+ $rules->setResources($resources);
$rules->saveRel();
+ }
+
+ /**
+ * Extract error returned by the server.
+ *
+ * @param \Throwable $exception
+ * @return string
+ */
+ private function extractCallExceptionMessage(\Throwable $exception): string
+ {
+ if ($restResponse = json_decode($exception->getMessage(), true)) {
+ //REST
+ return $restResponse['message'];
+ } else {
+ //SOAP
+ return $exception->getMessage();
+ }
+ }
+
+ /**
+ * Test design settings authorization
+ *
+ * @magentoApiDataFixture Magento/User/_files/user_with_custom_role.php
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesign(): void
+ {
+ //Updating our admin user's role to allow saving categories but not their design settings.
+ $roleName = 'test_custom_role';
+ $this->updateRoleResources($roleName, ['Magento_Catalog::categories']);
//Using the admin user with custom role.
$token = $this->adminTokens->createAdminAccessToken(
'customRoleUser',
@@ -354,23 +389,13 @@ public function testSaveDesign(): void
try {
$this->createCategory($categoryData, $token);
} catch (\Throwable $exception) {
- if ($restResponse = json_decode($exception->getMessage(), true)) {
- //REST
- $exceptionMessage = $restResponse['message'];
- } else {
- //SOAP
- $exceptionMessage = $exception->getMessage();
- }
+ $exceptionMessage = $this->extractCallExceptionMessage($exception);
}
//We don't have the permissions.
$this->assertEquals('Not allowed to edit the category\'s design attributes', $exceptionMessage);
//Updating the user role to allow access to design properties.
- /** @var Rules $rules */
- $rules = Bootstrap::getObjectManager()->create(Rules::class);
- $rules->setRoleId($role->getId());
- $rules->setResources(['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
- $rules->saveRel();
+ $this->updateRoleResources($roleName, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
//Making the same request with design settings.
$categoryData = $this->getSimpleCategoryData();
foreach ($categoryData['custom_attributes'] as &$attribute) {
@@ -394,11 +419,7 @@ public function testSaveDesign(): void
$categoryData = $categorySaved;
//Updating our role to remove design properties access.
- /** @var Rules $rules */
- $rules = Bootstrap::getObjectManager()->create(Rules::class);
- $rules->setRoleId($role->getId());
- $rules->setResources(['Magento_Catalog::categories']);
- $rules->saveRel();
+ $this->updateRoleResources($roleName, ['Magento_Catalog::categories']);
//Updating the category but with the same design properties values.
$result = $this->updateCategory($categoryData['id'], $categoryData, $token);
//We haven't changed the design so operation is successful.
@@ -414,13 +435,7 @@ public function testSaveDesign(): void
try {
$this->updateCategory($categoryData['id'], $categoryData, $token);
} catch (\Throwable $exception) {
- if ($restResponse = json_decode($exception->getMessage(), true)) {
- //REST
- $exceptionMessage = $restResponse['message'];
- } else {
- //SOAP
- $exceptionMessage = $exception->getMessage();
- }
+ $exceptionMessage = $this->extractCallExceptionMessage($exception);
}
//We don't have permissions to do that.
$this->assertEquals('Not allowed to edit the category\'s design attributes', $exceptionMessage);
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
index 58ad18dcaf29c..cb0c793356fee 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
@@ -764,11 +764,9 @@ public function testUpdateWithExtensionAttributes(): void
protected function updateProduct($product, ?string $token = null)
{
if (isset($product['custom_attributes'])) {
- for ($i=0; $iaclBuilder->getAcl()->allow(null, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
+ $this->aclBuilder->getAcl()
+ ->allow(null, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
$this->getRequest()->setDispatched(false);
$this->getRequest()->setPostValue($requestData);
$this->getRequest()->setParam('store', $requestData['store_id']);
From 1320f0e0f117ba5ed4783f176e7bdae95531be2c Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 4 Sep 2019 13:24:46 -0500
Subject: [PATCH 0114/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Catalog/Plugin/ProductAuthorization.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Plugin/ProductAuthorization.php b/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
index 57a928731be93..ce2fe19cf1aee 100644
--- a/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
+++ b/app/code/Magento/Catalog/Plugin/ProductAuthorization.php
@@ -41,8 +41,11 @@ public function __construct(Authorization $authorization)
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function beforeSave(ProductRepositoryInterface $subject, ProductInterface $product, $saveOptions): array
- {
+ public function beforeSave(
+ ProductRepositoryInterface $subject,
+ ProductInterface $product,
+ $saveOptions = false
+ ): array {
$this->authorization->authorizeSavingOf($product);
return [$product, $saveOptions];
From 9ab6d667a37b26aa8fb7dff48e6746d7f3399bc7 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 4 Sep 2019 14:59:29 -0500
Subject: [PATCH 0115/1978] MC-18685: Remove custom layout updates from admin
---
.../Adminhtml/Category/MoveTest.php | 8 +-
.../Page/Authorization.php | 4 +-
.../Magento/Cms/Model/Page/DataProvider.php | 12 +--
.../Magento/Cms/Observer/PageAclPlugin.php | 2 +-
.../Cms/Observer/PageValidatorObserver.php | 2 +-
.../Api/ProductRepositoryInterfaceTest.php | 8 +-
.../integration/etc/di/preferences/ce.php | 4 +-
.../Cms/Model/CustomLayoutManager.php | 52 +++++++++++
.../Magento/Cms/Controller/PageTest.php | 23 +++++
.../Cms/Model/Page/DataProviderTest.php | 88 ++++++++++++++++++-
.../Cms/_files/pages_with_layout_xml.php | 14 +++
.../_files/pages_with_layout_xml_rollback.php | 6 ++
12 files changed, 200 insertions(+), 23 deletions(-)
rename app/code/Magento/Cms/{Controller => Model}/Page/Authorization.php (95%)
create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Cms/Model/CustomLayoutManager.php
diff --git a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
index 7b151499d2d08..da58943bb3722 100644
--- a/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Controller/Adminhtml/Category/MoveTest.php
@@ -137,9 +137,7 @@ public function testExecuteWithGenericException()
->willReturnMap([[Registry::class, $registry], [\Magento\Cms\Model\Wysiwyg\Config::class, $wysiwygConfig]]);
$categoryMock->expects($this->once())
->method('move')
- ->willThrowException(new \Exception(
- __('Some exception')
- ));
+ ->willThrowException(new \Exception(__('Some exception')));
$this->messageManager->expects($this->once())
->method('addErrorMessage')
->with(__('There was a category move error.'));
@@ -234,9 +232,7 @@ public function testExecuteWithLocalizedException()
->willReturn(true);
$categoryMock->expects($this->once())
->method('move')
- ->willThrowException(new \Magento\Framework\Exception\LocalizedException(
- __($exceptionMessage)
- ));
+ ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__($exceptionMessage)));
$this->resultJsonFactoryMock
->expects($this->once())
->method('create')
diff --git a/app/code/Magento/Cms/Controller/Page/Authorization.php b/app/code/Magento/Cms/Model/Page/Authorization.php
similarity index 95%
rename from app/code/Magento/Cms/Controller/Page/Authorization.php
rename to app/code/Magento/Cms/Model/Page/Authorization.php
index a5ac659dd80f6..0ab63bb4901bc 100644
--- a/app/code/Magento/Cms/Controller/Page/Authorization.php
+++ b/app/code/Magento/Cms/Model/Page/Authorization.php
@@ -6,7 +6,7 @@
declare(strict_types=1);
-namespace Magento\Cms\Controller\Page;
+namespace Magento\Cms\Model\Page;
use Magento\Cms\Api\Data\PageInterface;
use Magento\Cms\Api\PageRepositoryInterface;
@@ -47,6 +47,8 @@ public function __construct(
* @param PageInterface $page
* @param PageInterface|null $oldPage
* @return bool
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
+ * @SuppressWarnings(PHPMD.NPathComplexity)
*/
private function hasPageChanged(PageInterface $page, ?PageInterface $oldPage): bool
{
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
index fb0b4eeefa84a..d1f148fe0198a 100644
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ b/app/code/Magento/Cms/Model/Page/DataProvider.php
@@ -174,11 +174,13 @@ public function getMeta()
}
}
//If custom layout XML is set then displaying this special option.
- if ($page->getCustomLayoutUpdateXml()) {
- $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
- }
- foreach ($this->customLayoutManager->fetchAvailableFiles($found) as $layoutFile) {
- $options[] = ['label' => $layoutFile, 'value' => $layoutFile];
+ if ($found) {
+ if ($found->getCustomLayoutUpdateXml()) {
+ $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
+ }
+ foreach ($this->customLayoutManager->fetchAvailableFiles($found) as $layoutFile) {
+ $options[] = ['label' => $layoutFile, 'value' => $layoutFile];
+ }
}
}
$customLayoutMeta = [
diff --git a/app/code/Magento/Cms/Observer/PageAclPlugin.php b/app/code/Magento/Cms/Observer/PageAclPlugin.php
index b7e12fb7cb4b1..c71fe0af396c0 100644
--- a/app/code/Magento/Cms/Observer/PageAclPlugin.php
+++ b/app/code/Magento/Cms/Observer/PageAclPlugin.php
@@ -10,7 +10,7 @@
use Magento\Cms\Api\Data\PageInterface;
use Magento\Cms\Api\PageRepositoryInterface;
-use Magento\Cms\Controller\Page\Authorization;
+use Magento\Cms\Model\Page\Authorization;
/**
* Perform additional authorization before saving a page.
diff --git a/app/code/Magento/Cms/Observer/PageValidatorObserver.php b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
index d245e9a519f1f..b4e5d2bc0e0a7 100644
--- a/app/code/Magento/Cms/Observer/PageValidatorObserver.php
+++ b/app/code/Magento/Cms/Observer/PageValidatorObserver.php
@@ -9,7 +9,7 @@
namespace Magento\Cms\Observer;
use Magento\Cms\Api\Data\PageInterface;
-use Magento\Cms\Controller\Page\Authorization;
+use Magento\Cms\Model\Page\Authorization;
use Magento\Framework\Event\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
index cb0c793356fee..c5014ed391fb3 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
@@ -1186,11 +1186,11 @@ protected function getSimpleProductData($productData = [])
protected function saveProduct($product, $storeCode = null, ?string $token = null)
{
if (isset($product['custom_attributes'])) {
- for ($i=0; $i
\Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager::class,
\Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager::class =>
- \Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager::class
+ \Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager::class,
+ \Magento\Cms\Model\Page\CustomLayoutManagerInterface::class =>
+ \Magento\TestFramework\Cms\Model\CustomLayoutManager::class
];
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Cms/Model/CustomLayoutManager.php b/dev/tests/integration/framework/Magento/TestFramework/Cms/Model/CustomLayoutManager.php
new file mode 100644
index 0000000000000..527454c297d48
--- /dev/null
+++ b/dev/tests/integration/framework/Magento/TestFramework/Cms/Model/CustomLayoutManager.php
@@ -0,0 +1,52 @@
+files[$forPageId]);
+ } else {
+ $this->files[$forPageId] = $files;
+ }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function fetchAvailableFiles(PageInterface $page): array
+ {
+ if (array_key_exists($page->getId(), $this->files)) {
+ return $this->files[$page->getId()];
+ }
+
+ return parent::fetchAvailableFiles($page);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php
index 8a0c715cfaf75..4600cd28fd3fc 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php
@@ -9,6 +9,10 @@
*/
namespace Magento\Cms\Controller;
+use Magento\Cms\Api\GetPageByIdentifierInterface;
+use Magento\Framework\View\LayoutInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+
class PageTest extends \Magento\TestFramework\TestCase\AbstractController
{
public function testViewAction()
@@ -62,4 +66,23 @@ public static function cmsPageWithSystemRouteFixture()
->setPageLayout('1column')
->save();
}
+
+ /**
+ * Check that custom handles are applied when rendering a page.
+ *
+ * @return void
+ * @throws \Throwable
+ * @magentoDataFixture Magento/Cms/_files/pages_with_layout_xml.php
+ */
+ public function testCustomHandles(): void
+ {
+ /** @var GetPageByIdentifierInterface $pageFinder */
+ $pageFinder = Bootstrap::getObjectManager()->get(GetPageByIdentifierInterface::class);
+ $page = $pageFinder->execute('test_custom_layout_page_3', 0);
+ $this->dispatch('/cms/page/view/page_id/' .$page->getId());
+ /** @var LayoutInterface $layout */
+ $layout = Bootstrap::getObjectManager()->get(LayoutInterface::class);
+ $handles = $layout->getUpdate()->getHandles();
+ $this->assertContains('cms_page_view_selectable_test_custom_layout_page_3_test_selected', $handles);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
index 115e39269edba..7524e454bc055 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
@@ -8,13 +8,17 @@
namespace Magento\Cms\Model\Page;
+use Magento\Cms\Api\GetPageByIdentifierInterface;
+use Magento\TestFramework\Cms\Model\CustomLayoutManager;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
use Magento\Cms\Model\Page as PageModel;
-use Magento\Cms\Model\PageFactory as PageModelFactory;
+use Magento\Framework\App\Request\Http as HttpRequest;
/**
* Test pages data provider.
+ *
+ * @magentoAppArea adminhtml
*/
class DataProviderTest extends TestCase
{
@@ -24,9 +28,19 @@ class DataProviderTest extends TestCase
private $provider;
/**
- * @var PageModelFactory
+ * @var GetPageByIdentifierInterface
*/
- private $pageFactory;
+ private $repo;
+
+ /**
+ * @var CustomLayoutManager
+ */
+ private $filesFaker;
+
+ /**
+ * @var HttpRequest
+ */
+ private $request;
/**
* @inheritDoc
@@ -34,7 +48,7 @@ class DataProviderTest extends TestCase
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
- $this->pageFactory = $objectManager->get(PageModelFactory::class);
+ $this->repo = $objectManager->get(GetPageByIdentifierInterface::class);
$this->provider = $objectManager->create(
DataProvider::class,
[
@@ -43,6 +57,8 @@ protected function setUp()
'requestFieldName' => 'page_id'
]
);
+ $this->filesFaker = $objectManager->get(CustomLayoutManager::class);
+ $this->request = $objectManager->get(HttpRequest::class);
}
/**
@@ -57,16 +73,80 @@ public function testCustomLayoutData(): void
$data = $this->provider->getData();
$page1Data = null;
$page2Data = null;
+ $page3Data = null;
foreach ($data as $pageData) {
if ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_1') {
$page1Data = $pageData;
} elseif ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_2') {
$page2Data = $pageData;
+ } elseif ($pageData[PageModel::IDENTIFIER] === 'test_custom_layout_page_3') {
+ $page3Data = $pageData;
}
}
$this->assertNotEmpty($page1Data);
$this->assertNotEmpty($page2Data);
$this->assertEquals('_existing_', $page1Data['layout_update_selected']);
$this->assertEquals(null, $page2Data['layout_update_selected']);
+ $this->assertEquals('test_selected', $page3Data['layout_update_selected']);
+ }
+
+ /**
+ * Check that proper meta for custom layout field is returned.
+ *
+ * @return void
+ * @throws \Throwable
+ * @magentoDataFixture Magento/Cms/_files/pages_with_layout_xml.php
+ */
+ public function testCustomLayoutMeta(): void
+ {
+ //Testing a page without layout xml
+ $page = $this->repo->execute('test_custom_layout_page_3', 0);
+ $this->filesFaker->fakeAvailableFiles((int)$page->getId(), ['test1', 'test2']);
+ $this->request->setParam('page_id', $page->getId());
+
+ $meta = $this->provider->getMeta();
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('custom_layout_update_select', $meta['design']['children']);
+ $this->assertArrayHasKey('arguments', $meta['design']['children']['custom_layout_update_select']);
+ $this->assertArrayHasKey('data', $meta['design']['children']['custom_layout_update_select']['arguments']);
+ $this->assertArrayHasKey(
+ 'options',
+ $meta['design']['children']['custom_layout_update_select']['arguments']['data']
+ );
+ $expectedList = [
+ ['label' => 'No update', 'value' => ''],
+ ['label' => 'test1', 'value' => 'test1'],
+ ['label' => 'test2', 'value' => 'test2']
+ ];
+ $metaList = $meta['design']['children']['custom_layout_update_select']['arguments']['data']['options'];
+ sort($expectedList);
+ sort($metaList);
+ $this->assertEquals($expectedList, $metaList);
+
+ //Page with old layout xml
+ $page = $this->repo->execute('test_custom_layout_page_1', 0);
+ $this->filesFaker->fakeAvailableFiles((int)$page->getId(), ['test3']);
+ $this->request->setParam('page_id', $page->getId());
+
+ $meta = $this->provider->getMeta();
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('custom_layout_update_select', $meta['design']['children']);
+ $this->assertArrayHasKey('arguments', $meta['design']['children']['custom_layout_update_select']);
+ $this->assertArrayHasKey('data', $meta['design']['children']['custom_layout_update_select']['arguments']);
+ $this->assertArrayHasKey(
+ 'options',
+ $meta['design']['children']['custom_layout_update_select']['arguments']['data']
+ );
+ $expectedList = [
+ ['label' => 'No update', 'value' => ''],
+ ['label' => 'Use existing layout update XML', 'value' => '_existing_'],
+ ['label' => 'test1', 'value' => 'test3'],
+ ];
+ $metaList = $meta['design']['children']['custom_layout_update_select']['arguments']['data']['options'];
+ sort($expectedList);
+ sort($metaList);
+ $this->assertEquals($expectedList, $metaList);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
index c5e6986277ed0..80f0c8757a579 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
@@ -17,9 +17,23 @@
$page->setIdentifier('test_custom_layout_page_1');
$page->setTitle('Test Page');
$page->setCustomLayoutUpdateXml('tst');
+$page->setIsActive(true);
+$page->setStoreId(0);
$page->save();
/** @var PageModel $page2 */
$page2 = $pageFactory->create();
$page2->setIdentifier('test_custom_layout_page_2');
$page2->setTitle('Test Page 2');
+$page->setIsActive(true);
+$page->setStoreId(0);
$page2->save();
+/** @var PageModel $page3 */
+$page3 = $pageFactory->create();
+$page3->setIdentifier('test_custom_layout_page_3');
+$page3->setTitle('Test Page 3');
+$page3->setData('layout_update_selected', 'test_selected');
+$page3->setStores([0]);
+$page3->setIsActive(1);
+$page3->setContent('Test Page ');
+$page3->setPageLayout('1column');
+$page3->save();
diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php
index ca9195256af8c..3217b94d7392b 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml_rollback.php
@@ -24,3 +24,9 @@
if ($page2->getId()) {
$page2->delete();
}
+/** @var PageModel $page3 */
+$page3 = $pageFactory->create();
+$page3->load('test_custom_layout_page_3', PageModel::IDENTIFIER);
+if ($page3->getId()) {
+ $page3->delete();
+}
From 62690aa5e6bcc40099ea2bec5cb70a80955de393 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 4 Sep 2019 16:11:17 -0500
Subject: [PATCH 0116/1978] MC-18685: Remove custom layout updates from admin
---
.../Model/Category/DataProviderTest.php | 83 +++++++++++++
.../Form/Modifier/LayoutUpdateTest.php | 114 ++++++++++++++++++
.../Cms/Model/Page/DataProviderTest.php | 2 +-
3 files changed, 198 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
index e93761f9043b8..e91aa01eb9046 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Catalog\Model\Category;
+use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Registry;
use PHPUnit\Framework\TestCase;
@@ -12,6 +13,11 @@
use Magento\Catalog\Model\CategoryFactory;
use Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate;
+/**
+ * @magentoDbIsolation enabled
+ * @magentoAppIsolation enabled
+ * @magentoAppArea adminhtml
+ */
class DataProviderTest extends TestCase
{
/**
@@ -29,6 +35,11 @@ class DataProviderTest extends TestCase
*/
private $categoryFactory;
+ /**
+ * @var CategoryLayoutUpdateManager
+ */
+ private $fakeFiles;
+
/**
* Create subject instance.
*
@@ -56,6 +67,7 @@ protected function setUp()
$this->dataProvider = $this->createDataProvider();
$this->registry = $objectManager->get(Registry::class);
$this->categoryFactory = $objectManager->get(CategoryFactory::class);
+ $this->fakeFiles = $objectManager->get(CategoryLayoutUpdateManager::class);
}
/**
@@ -103,4 +115,75 @@ public function testCustomLayoutFileAttribute(): void
$this->assertEquals($deprecated, $data[$id]['custom_layout_update']);
$this->assertEquals(LayoutUpdate::VALUE_USE_UPDATE_XML, $data[$id]['custom_layout_update_file']);
}
+
+ /**
+ * Check that proper options are returned for a category.
+ *
+ * @return void
+ */
+ public function testCustomLayoutMeta(): void
+ {
+ //Testing a category without layout xml
+ /** @var Category $category */
+ $category = $this->categoryFactory->create();
+ $category->load($id = 2);
+ $this->fakeFiles->setCategoryFakeFiles((int)$category->getId(), ['test1', 'test2']);
+ $this->registry->register('category', $category);
+
+ $meta = $this->dataProvider->getMeta();
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('custom_layout_update_file', $meta['design']['children']);
+ $this->assertArrayHasKey('arguments', $meta['design']['children']['custom_layout_update_file']);
+ $this->assertArrayHasKey('data', $meta['design']['children']['custom_layout_update_file']['arguments']);
+ $this->assertArrayHasKey(
+ 'config',
+ $meta['design']['children']['custom_layout_update_file']['arguments']['data']
+ );
+ $this->assertArrayHasKey(
+ 'options',
+ $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']
+ );
+ $expectedList = [
+ ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ ['label' => 'test1', 'value' => 'test1', '__disableTmpl' => true],
+ ['label' => 'test2', 'value' => 'test2', '__disableTmpl' => true]
+ ];
+ $list = $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']['options'];
+ sort($expectedList);
+ sort($list);
+ $this->assertEquals($expectedList, $list);
+
+ //Product with old layout xml
+ $category->setCustomAttribute('custom_layout_update', 'test');
+ $this->fakeFiles->setCategoryFakeFiles((int)$category->getId(), ['test3']);
+
+ $meta = $this->dataProvider->getMeta();
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('custom_layout_update_file', $meta['design']['children']);
+ $this->assertArrayHasKey('arguments', $meta['design']['children']['custom_layout_update_file']);
+ $this->assertArrayHasKey('data', $meta['design']['children']['custom_layout_update_file']['arguments']);
+ $this->assertArrayHasKey(
+ 'config',
+ $meta['design']['children']['custom_layout_update_file']['arguments']['data']
+ );
+ $this->assertArrayHasKey(
+ 'options',
+ $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']
+ );
+ $expectedList = [
+ ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ [
+ 'label' => 'Use existing',
+ 'value' => LayoutUpdate::VALUE_USE_UPDATE_XML,
+ '__disableTmpl' => true
+ ],
+ ['label' => 'test3', 'value' => 'test3', '__disableTmpl' => true],
+ ];
+ $list = $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']['options'];
+ sort($expectedList);
+ sort($list);
+ $this->assertEquals($expectedList, $list);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
index 4ec50dc26da5c..61e68561d9ee4 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
@@ -10,13 +10,20 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Locator\LocatorInterface;
+use Magento\Store\Api\Data\StoreInterface;
+use Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as LayoutUpdateAttribute;
+use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav as EavModifier;
/**
* Test the modifier.
+ *
+ * @magentoDbIsolation enabled
+ * @magentoAppIsolation enabled
+ * @magentoAppArea adminhtml
*/
class LayoutUpdateTest extends TestCase
{
@@ -35,14 +42,47 @@ class LayoutUpdateTest extends TestCase
*/
private $locator;
+ /**
+ * @var EavModifier
+ */
+ private $eavModifier;
+
+ /**
+ * @var ProductLayoutUpdateManager
+ */
+ private $fakeFiles;
+
/**
* @inheritDoc
*/
protected function setUp()
{
$this->locator = $this->getMockForAbstractClass(LocatorInterface::class);
+ $store = Bootstrap::getObjectManager()->create(StoreInterface::class);
+ $this->locator->method('getStore')->willReturn($store);
$this->modifier = Bootstrap::getObjectManager()->create(LayoutUpdate::class, ['locator' => $this->locator]);
$this->repo = Bootstrap::getObjectManager()->create(ProductRepositoryInterface::class);
+ $this->eavModifier = Bootstrap::getObjectManager()->create(
+ EavModifier::class,
+ [
+ 'locator' => $this->locator,
+ 'formElementMapper' => Bootstrap::getObjectManager()->create(
+ \Magento\Ui\DataProvider\Mapper\FormElement::class,
+ [
+ 'mappings' => [
+ "text" => "input",
+ "hidden" => "input",
+ "boolean" => "checkbox",
+ "media_image" => "image",
+ "price" => "input",
+ "weight" => "input",
+ "gallery" => "image"
+ ]
+ ]
+ )
+ ]
+ );
+ $this->fakeFiles = Bootstrap::getObjectManager()->get(ProductLayoutUpdateManager::class);
}
/**
@@ -50,6 +90,7 @@ protected function setUp()
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @return void
+ * @throws \Throwable
*/
public function testModifyData(): void
{
@@ -63,4 +104,77 @@ public function testModifyData(): void
$data[$product->getId()]['product']['custom_layout_update_file']
);
}
+
+ /**
+ * Check that entity specific options are returned.
+ *
+ * @return void
+ * @throws \Throwable
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ */
+ public function testEntitySpecificData(): void
+ {
+ //Testing a category without layout xml
+ $product = $this->repo->get('simple');
+ $this->locator->method('getProduct')->willReturn($product);
+ $this->fakeFiles->setFakeFiles((int)$product->getId(), ['test1', 'test2']);
+
+ $meta = $this->eavModifier->modifyMeta([]);
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('container_custom_layout_update_file', $meta['design']['children']);
+ $this->assertArrayHasKey('children', $meta['design']['children']['container_custom_layout_update_file']);
+ $this->assertArrayHasKey(
+ 'custom_layout_update_file',
+ $meta['design']['children']['container_custom_layout_update_file']['children']
+ );
+ $fieldMeta = $meta['design']['children']['container_custom_layout_update_file']['children'];
+ $fieldMeta = $fieldMeta['custom_layout_update_file'];
+ $this->assertArrayHasKey('arguments', $fieldMeta);
+ $this->assertArrayHasKey('data', $fieldMeta['arguments']);
+ $this->assertArrayHasKey('config', $fieldMeta['arguments']['data']);
+ $this->assertArrayHasKey('options', $fieldMeta['arguments']['data']['config']);
+ $expectedList = [
+ ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ ['label' => 'test1', 'value' => 'test1', '__disableTmpl' => true],
+ ['label' => 'test2', 'value' => 'test2', '__disableTmpl' => true]
+ ];
+ $list = $fieldMeta['arguments']['data']['config']['options'];
+ sort($expectedList);
+ sort($list);
+ $this->assertEquals($expectedList, $list);
+
+ //Product with old layout xml
+ $product->setCustomAttribute('custom_layout_update', 'test');
+ $this->fakeFiles->setFakeFiles((int)$product->getId(), ['test3']);
+
+ $meta = $this->eavModifier->modifyMeta([]);
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('container_custom_layout_update_file', $meta['design']['children']);
+ $this->assertArrayHasKey('children', $meta['design']['children']['container_custom_layout_update_file']);
+ $this->assertArrayHasKey(
+ 'custom_layout_update_file',
+ $meta['design']['children']['container_custom_layout_update_file']['children']
+ );
+ $fieldMeta = $meta['design']['children']['container_custom_layout_update_file']['children'];
+ $fieldMeta = $fieldMeta['custom_layout_update_file'];
+ $this->assertArrayHasKey('arguments', $fieldMeta);
+ $this->assertArrayHasKey('data', $fieldMeta['arguments']);
+ $this->assertArrayHasKey('config', $fieldMeta['arguments']['data']);
+ $this->assertArrayHasKey('options', $fieldMeta['arguments']['data']['config']);
+ $expectedList = [
+ ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ [
+ 'label' => 'Use existing',
+ 'value' => LayoutUpdateAttribute::VALUE_USE_UPDATE_XML,
+ '__disableTmpl' => true
+ ],
+ ['label' => 'test3', 'value' => 'test3', '__disableTmpl' => true],
+ ];
+ $list = $fieldMeta['arguments']['data']['config']['options'];
+ sort($expectedList);
+ sort($list);
+ $this->assertEquals($expectedList, $list);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
index 7524e454bc055..2d2d36178ada8 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
@@ -142,7 +142,7 @@ public function testCustomLayoutMeta(): void
$expectedList = [
['label' => 'No update', 'value' => ''],
['label' => 'Use existing layout update XML', 'value' => '_existing_'],
- ['label' => 'test1', 'value' => 'test3'],
+ ['label' => 'test3', 'value' => 'test3'],
];
$metaList = $meta['design']['children']['custom_layout_update_select']['arguments']['data']['options'];
sort($expectedList);
From 739fe4dc041d9721befb8ee2a4c783adadd57734 Mon Sep 17 00:00:00 2001
From: Evgeny Petrov
Date: Thu, 5 Sep 2019 11:32:02 +0300
Subject: [PATCH 0117/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
---
.../Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
index a1d2d63096e46..afd383c13421f 100644
--- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
+++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Match.php
@@ -3,8 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-declare(strict_types=1);
-
namespace Magento\Elasticsearch\SearchAdapter\Query\Builder;
use Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\AttributeProvider;
From 3b4166229afdeba2394a0a8241b0537780a66f96 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 5 Sep 2019 16:00:11 +0400
Subject: [PATCH 0118/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
.../AdminProductAttributeActionGroup.xml | 4 +--
.../Test/Mftf/Data/CatalogSearchData.xml | 6 -----
.../Mftf/Metadata/catalog_search-meta.xml | 3 ---
...ontElasticsearchSearchInvalidValueTest.xml | 25 ++++++++++++++-----
4 files changed, 21 insertions(+), 17 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index 0c3172392435a..42e0bb24c744f 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -213,7 +213,7 @@
-
+
@@ -320,7 +320,7 @@
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
index 58e2929090059..d631cfd29113d 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Data/CatalogSearchData.xml
@@ -11,9 +11,6 @@
DefaultMinQueryLength
-
- DefaultSearchEngine
-
SetMinQueryLengthToOne
@@ -26,7 +23,4 @@
1
-
- true
-
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
index 7e880262d5922..7405377249aa4 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Metadata/catalog_search-meta.xml
@@ -14,9 +14,6 @@
boolean
-
- boolean
-
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
index 4b68dbf95a529..55e31e91e9016 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
@@ -11,7 +11,7 @@
-
+
@@ -21,18 +21,25 @@
+
+
+
+
+
+
+
-
-
+
+
@@ -44,18 +51,19 @@
-
+
-
+
-
+
+
@@ -71,8 +79,13 @@
+
+
+
+
+
From 0cd1a774d391589aa0bc8fdb706d569ff57fdede Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Tue, 20 Aug 2019 10:31:28 +0400
Subject: [PATCH 0119/1978] MC-18822: Increase test coverage for Content
functional area
- Automation test for MC-6192
---
.../AdminProductAttributeSetActionGroup.xml | 10 +
.../Catalog/Test/Mftf/Data/ProductData.xml | 13 ++
.../Mftf/Section/AdminProductFormSection.xml | 1 +
.../StorefrontCategorySidebarSection.xml | 1 +
.../AdminAddOptionsToAttributeActionGroup.xml | 38 ++++
.../AdminConfigurableProductActionGroup.xml | 53 ++++++
.../Mftf/Data/ConfigurableProductData.xml | 45 +++++
...reateProductConfigurationsPanelSection.xml | 1 +
...CheckResultsOfColorAndOtherFiltersTest.xml | 172 ++++++++++++++++++
9 files changed, 334 insertions(+)
create mode 100644 app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
index e20b5f113a7ec..c67c2148673a5 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
@@ -64,6 +64,16 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 517ab253b8238..b8d7aa878230a 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -1165,6 +1165,19 @@
EavStock10
CustomAttributeProductAttribute
+
+ Simple1
+ simple
+ 4
+ 4
+ Simple1
+ 1.00
+ api-simple-product
+ 1
+ 111
+ EavStockItem
+ CustomAttributeCategoryIds
+
simple-product_
simple
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
index 80b4159167453..b8aa4aa0ce822 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
@@ -8,6 +8,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
index 1b7bbd58eea9f..406bea8d8aeab 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
@@ -8,6 +8,7 @@
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml
index e88f71ce23ac2..b8bdbdfe082c5 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml
@@ -8,6 +8,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Adds 5 provided Options to a new Attribute on the Configurable Product creation/edit page.
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
index a0a3a551c3d93..a1042141d9373 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
@@ -8,6 +8,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
index de6714a9b959e..1ec9909576432 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
@@ -64,6 +64,51 @@
+
+ configurable
+ configurable
+ 4
+ mySet
+ 4
+ Jacket
+ 1.00
+ 2
+ configurableurlkey
+ 1
+ 100
+ EavStockItem
+ CustomAttributeCategoryIds
+
+
+ configurable
+ configurable
+ 4
+ mySet
+ 4
+ Cardigan
+ 1.00
+ 2
+ configurableurlkey
+ 1
+ 100
+ EavStockItem
+ CustomAttributeCategoryIds
+
+
+ configurable
+ configurable
+ 4
+ mySet
+ 4
+ Pants
+ 1.00
+ 2
+ configurableurlkey
+ 1
+ 100
+ EavStockItem
+ CustomAttributeCategoryIds
+
configurable-product_
configurable
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml
index f3c628d002e7a..488b227c29cbd 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml
@@ -9,6 +9,7 @@
+
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
new file mode 100644
index 0000000000000..5b16f083067ee
--- /dev/null
+++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -0,0 +1,172 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 4d0d2743cf87d2b2f69ebb3a00613a443dbb575b Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Fri, 6 Sep 2019 15:09:35 +0300
Subject: [PATCH 0120/1978] DeleteEIntegrationEntity
---
.../AdminCreatesNewIntegrationActionGroup.xml | 22 +++++++
...dminDeleteIntegrationEntityActionGroup.xml | 17 ++++++
...gateToCreateIntegrationPageActionGroup.xml | 18 ++++++
...dminSearchIntegrationInGridActionGroup.xml | 23 ++++++++
...sageCreateIntegrationEntityActionGroup.xml | 19 ++++++
...letedIntegrationIsNotInGridActionGroup.xml | 17 ++++++
.../Mftf/Section/AdminIntegrationsSection.xml | 26 ++++++++
.../Test/AdminDeleteIntegrationEntityTest.xml | 59 +++++++++++++++++++
.../TestCase/DeleteIntegrationEntityTest.xml | 1 +
9 files changed, 202 insertions(+)
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
create mode 100644 app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
new file mode 100644
index 0000000000000..899ca8b7d7f4e
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml
new file mode 100644
index 0000000000000..87bcff8145184
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml
new file mode 100644
index 0000000000000..f31102419b665
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml
new file mode 100644
index 0000000000000..6e0b7dc3eb9d5
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml
new file mode 100644
index 0000000000000..e928149c7f08f
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml
new file mode 100644
index 0000000000000..895f147fa8834
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
new file mode 100644
index 0000000000000..4e43cd3babdf6
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
new file mode 100644
index 0000000000000..00dc9b320d7ad
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml
index 607c0abf4302e..a43b88469faae 100644
--- a/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Integration/Test/TestCase/DeleteIntegrationEntityTest.xml
@@ -11,6 +11,7 @@
default
+ mftf_migrated:yes
From 5f4254ee2a1047d9b4c66a1624f885bb59b19277 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Fri, 6 Sep 2019 16:47:04 +0400
Subject: [PATCH 0121/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Updated automated test script
---
...lValueWithFullDiscountUsingCartRuleTest.xml | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
index b1e11cbf07ff6..c8a8f6db850f9 100644
--- a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
+++ b/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -10,7 +10,7 @@
-
+
@@ -30,12 +30,8 @@
-
-
-
-
@@ -67,6 +63,8 @@
5.50
+
+
@@ -100,12 +98,8 @@
-
-
-
-
@@ -132,9 +126,9 @@
-
-
-
+
+
+
From 3e5cb451a2a18c9f00f0360fb83d0bcc6a4c1391 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Sat, 7 Sep 2019 10:52:51 -0500
Subject: [PATCH 0122/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Catalog/Model/Product.php | 5 ++++-
.../testsuite/Magento/Cms/Model/Page/DataProviderTest.php | 7 ++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product.php b/app/code/Magento/Catalog/Model/Product.php
index 560a1fbacda41..de0628d58df27 100644
--- a/app/code/Magento/Catalog/Model/Product.php
+++ b/app/code/Magento/Catalog/Model/Product.php
@@ -828,7 +828,10 @@ public function getStoreIds()
$storeIds[] = $websiteStores;
}
}
- $this->setStoreIds(array_merge(...$storeIds));
+ if ($storeIds) {
+ $storeIds = array_merge(...$storeIds);
+ }
+ $this->setStoreIds($storeIds);
}
return $this->getData('store_ids');
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
index 2d2d36178ada8..d2ca833f3923f 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
@@ -49,16 +49,17 @@ protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->repo = $objectManager->get(GetPageByIdentifierInterface::class);
+ $this->filesFaker = $objectManager->get(CustomLayoutManager::class);
+ $this->request = $objectManager->get(HttpRequest::class);
$this->provider = $objectManager->create(
DataProvider::class,
[
'name' => 'test',
'primaryFieldName' => 'page_id',
- 'requestFieldName' => 'page_id'
+ 'requestFieldName' => 'page_id',
+ 'customLayoutManager' => $this->filesFaker
]
);
- $this->filesFaker = $objectManager->get(CustomLayoutManager::class);
- $this->request = $objectManager->get(HttpRequest::class);
}
/**
From 06a2b7b1b30bb6747849e6cf66e739e0d817fd64 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Mon, 9 Sep 2019 11:58:50 +0300
Subject: [PATCH 0123/1978] MC-18165: Quick search with two chars shows all
products
---
.../ResourceModel/Fulltext/Collection.php | 45 ++++++++++++-------
.../StorefrontCatalogSearchActionGroup.xml | 20 ++++++++-
.../StorefrontCatalogSearchMainSection.xml | 2 +
.../Mftf/Test/SearchEntityResultsTest.xml | 19 +++++---
.../view/frontend/templates/form.mini.phtml | 3 +-
.../Search/view/frontend/web/js/form-mini.js | 2 +-
.../ResourceModel/Fulltext/CollectionTest.php | 5 ++-
7 files changed, 70 insertions(+), 26 deletions(-)
diff --git a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php
index 4f84f3868c6a3..a5be9dc2fd82b 100644
--- a/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php
+++ b/app/code/Magento/CatalogSearch/Model/ResourceModel/Fulltext/Collection.php
@@ -212,10 +212,8 @@ public function __construct(
DefaultFilterStrategyApplyCheckerInterface $defaultFilterStrategyApplyChecker = null
) {
$this->queryFactory = $catalogSearchData;
- if ($searchResultFactory === null) {
- $this->searchResultFactory = \Magento\Framework\App\ObjectManager::getInstance()
+ $this->searchResultFactory = $searchResultFactory ?? \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Api\Search\SearchResultFactory::class);
- }
parent::__construct(
$entityFactory,
$logger,
@@ -427,25 +425,40 @@ protected function _renderFiltersBefore()
return;
}
- $this->prepareSearchTermFilter();
- $this->preparePriceAggregation();
-
- $searchCriteria = $this->getSearchCriteriaResolver()->resolve();
- try {
- $this->searchResult = $this->getSearch()->search($searchCriteria);
- $this->_totalRecords = $this->getTotalRecordsResolver($this->searchResult)->resolve();
- } catch (EmptyRequestDataException $e) {
- /** @var \Magento\Framework\Api\Search\SearchResultInterface $searchResult */
- $this->searchResult = $this->searchResultFactory->create()->setItems([]);
- } catch (NonExistingRequestNameException $e) {
- $this->_logger->error($e->getMessage());
- throw new LocalizedException(__('An error occurred. For details, see the error log.'));
+ if ($this->searchRequestName != 'quick_search_container'
+ || strlen(trim($this->queryText))
+ ) {
+ $this->prepareSearchTermFilter();
+ $this->preparePriceAggregation();
+
+ $searchCriteria = $this->getSearchCriteriaResolver()->resolve();
+ try {
+ $this->searchResult = $this->getSearch()->search($searchCriteria);
+ $this->_totalRecords = $this->getTotalRecordsResolver($this->searchResult)->resolve();
+ } catch (EmptyRequestDataException $e) {
+ $this->searchResult = $this->createEmptyResult();
+ } catch (NonExistingRequestNameException $e) {
+ $this->_logger->error($e->getMessage());
+ throw new LocalizedException(__('An error occurred. For details, see the error log.'));
+ }
+ } else {
+ $this->searchResult = $this->createEmptyResult();
}
$this->getSearchResultApplier($this->searchResult)->apply();
parent::_renderFiltersBefore();
}
+ /**
+ * Create empty search result
+ *
+ * @return SearchResultInterface
+ */
+ private function createEmptyResult()
+ {
+ return $this->searchResultFactory->create()->setItems([]);
+ }
+
/**
* Set sort order for search query.
*
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
index a72762ff796e0..a907df2d718df 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
@@ -41,6 +41,24 @@
+
+
+ Fill the Storefront Search field. Submits the Form. Validates that 'Minimum Search query length' warning appears.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -101,7 +119,7 @@
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchMainSection.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchMainSection.xml
index 667f08fea6579..b005e100b30bb 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchMainSection.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Section/StorefrontCatalogSearchMainSection.xml
@@ -16,5 +16,7 @@
+
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
index 19db201e91f40..47d107148a574 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
@@ -92,6 +92,7 @@
+
@@ -100,6 +101,7 @@
+
@@ -107,13 +109,18 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Search/view/frontend/templates/form.mini.phtml b/app/code/Magento/Search/view/frontend/templates/form.mini.phtml
index 766dd4d992bd4..0dd9c819c855a 100644
--- a/app/code/Magento/Search/view/frontend/templates/form.mini.phtml
+++ b/app/code/Magento/Search/view/frontend/templates/form.mini.phtml
@@ -24,7 +24,8 @@ $helper = $this->helper(\Magento\Search\Helper\Data::class);
data-mage-init='{"quickSearch":{
"formSelector":"#search_mini_form",
"url":"= $block->escapeUrl($helper->getSuggestUrl())?>",
- "destinationSelector":"#search_autocomplete"}
+ "destinationSelector":"#search_autocomplete",
+ "minSearchLength":"= $block->escapeHtml($helper->getMinQueryLength()) ?>"}
}'
type="text"
name="= $block->escapeHtmlAttr($helper->getQueryParamName()) ?>"
diff --git a/app/code/Magento/Search/view/frontend/web/js/form-mini.js b/app/code/Magento/Search/view/frontend/web/js/form-mini.js
index 64e6eceb1eba6..b4493c5f38089 100644
--- a/app/code/Magento/Search/view/frontend/web/js/form-mini.js
+++ b/app/code/Magento/Search/view/frontend/web/js/form-mini.js
@@ -30,7 +30,7 @@ define([
$.widget('mage.quickSearch', {
options: {
autocomplete: 'off',
- minSearchLength: 2,
+ minSearchLength: 3,
responseFieldElements: 'ul li',
selectClass: 'selected',
template:
diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php
index 93df194080b69..e84d64b681c40 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php
@@ -26,6 +26,9 @@ public function testLoadWithFilterSearch($request, $filters, $expectedCount)
foreach ($filters as $field => $value) {
$fulltextCollection->addFieldToFilter($field, $value);
}
+ if ($request == 'quick_search_container' && isset($filters['search_term'])) {
+ $fulltextCollection->addSearchFilter($filters['search_term']);
+ }
$fulltextCollection->loadWithFilter();
$items = $fulltextCollection->getItems();
$this->assertCount($expectedCount, $items);
@@ -48,7 +51,7 @@ public function testSearchResultsAreTheSameForSameRequests()
['searchRequestName' => 'quick_search_container']
);
- $fulltextCollection->addFieldToFilter('search_term', 'shorts');
+ $fulltextCollection->addSearchFilter('shorts');
$fulltextCollection->setOrder('relevance');
$fulltextCollection->load();
$items = $fulltextCollection->getItems();
From 30d35df50c7767f66a76c0c0a1e15155111407b6 Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Sun, 1 Sep 2019 23:24:07 +0300
Subject: [PATCH 0124/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Fix CR comments
---
.../Sales/Model/Order/Shipment/TrackRepository.php | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
index 93396976565ea..3cf173117b4b6 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
@@ -120,13 +120,11 @@ public function delete(ShipmentTrackInterface $entity)
*/
public function save(ShipmentTrackInterface $entity)
{
- $shipments = $this->shipmentCollection->create()->addFieldToFilter('order_id', $entity['order_id']);
- $shipmentId = [];
- foreach ($shipments->getItems() as $shipment) {
- $shipmentId[] = $shipment->getId();
- }
+ $shipments = $this->shipmentCollection->create()
+ ->addFieldToFilter('entity_id', $entity['parent_id'])
+ ->toArray();
- if (array_search($entity['parent_id'], $shipmentId) === false) {
+ if (empty($shipments['items'])) {
$this->logger->error('The shipment doesn\'t belong to the order.');
throw new CouldNotSaveException(__('Could not save the shipment tracking.'));
}
From 9097ecccbc95c1c15e385ece55fcb2bda62557a7 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Mon, 9 Sep 2019 13:14:44 +0300
Subject: [PATCH 0125/1978] MC-19783: Weight attribute label is missing
---
.../Catalog/Ui/DataProvider/Product/Form/Modifier/General.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
index 91c74a2da5048..e783fc61fe0ce 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php
@@ -221,6 +221,7 @@ protected function customizeWeightField(array $meta)
'validate-zero-or-greater' => true
],
'additionalClasses' => 'admin__field-small',
+ 'sortOrder' => 0,
'addafter' => $this->locator->getStore()->getConfig('general/locale/weight_unit'),
'imports' => $disabled ? [] : [
'disabled' => '!${$.provider}:' . self::DATA_SCOPE_PRODUCT
@@ -266,6 +267,7 @@ protected function customizeWeightField(array $meta)
],
],
'value' => (int)$this->locator->getProduct()->getTypeInstance()->hasWeight(),
+ 'sortOrder' => 10,
'disabled' => $disabled,
]
);
From 2134abaadbba832545b3008863e167a7c3e31ca9 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 9 Sep 2019 12:00:36 -0500
Subject: [PATCH 0126/1978] MC-18685: Remove custom layout updates from admin
---
.../Controller/Adminhtml/Category/Save.php | 9 +-
.../Backend/AbstractLayoutUpdate.php | 122 ++++++++++++++++++
.../Attribute/Backend/Customlayoutupdate.php | 73 +++++------
.../Attribute/Backend/LayoutUpdate.php | 73 +----------
.../Attribute/Backend/LayoutUpdate.php | 73 +----------
.../Product/Attribute/LayoutUpdateManager.php | 2 -
.../Controller/Adminhtml/ProductTest.php | 9 +-
7 files changed, 174 insertions(+), 187 deletions(-)
create mode 100644 app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
index 9812dda73fd3e..2dc193d399ec0 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Category/Save.php
@@ -175,6 +175,10 @@ public function execute()
}
try {
+ $this->_eventManager->dispatch(
+ 'catalog_category_prepare_save',
+ ['category' => $category, 'request' => $this->getRequest()]
+ );
/**
* Check "Use Default Value" checkboxes values
*/
@@ -186,11 +190,6 @@ public function execute()
}
}
- $this->_eventManager->dispatch(
- 'catalog_category_prepare_save',
- ['category' => $category, 'request' => $this->getRequest()]
- );
-
/**
* Proceed with $_POST['use_config']
* set into category model for processing through validation
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
new file mode 100644
index 0000000000000..ece3c8e499e4d
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
@@ -0,0 +1,122 @@
+getAttribute()->getAttributeCode();
+ $data = $model->getData();
+ //Custom attributes must not be initialized if they have not already been or it will break the saving process.
+ if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
+ && array_key_exists($code, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
+ return $model->getCustomAttribute($code)->getValue();
+ } elseif (array_key_exists($code, $data)) {
+ return $data[$code];
+ }
+
+ return null;
+ }
+
+ /**
+ * Compose list of available files (layout handles) for given entity.
+ *
+ * @param AbstractModel $forModel
+ * @return string[]
+ */
+ abstract protected function listAvailableValues(AbstractModel $forModel): array;
+
+ /**
+ * Extracts prepare attribute value to be saved.
+ *
+ * @throws LocalizedException
+ * @param AbstractModel $model
+ * @return string|null
+ */
+ private function prepareValue(AbstractModel $model): ?string
+ {
+ $value = $this->extractAttributeValue($model);
+ if ($value
+ && $value !== self::VALUE_USE_UPDATE_XML
+ && !in_array($value, $this->listAvailableValues($model), true)
+ ) {
+ throw new LocalizedException(__('Selected layout update is not available'));
+ }
+ if ($value === self::VALUE_USE_UPDATE_XML) {
+ $value = null;
+ }
+ if (!$value) {
+ $value = null;
+ }
+
+ return $value;
+ }
+
+ /**
+ * Set value for the object.
+ *
+ * @param string|null $value
+ * @param AbstractModel $forObject
+ * @return void
+ */
+ private function setAttributeValue(?string $value, AbstractModel $forObject): void
+ {
+ $attrCode = $this->getAttribute()->getAttributeCode();
+ $data = $forObject->getData();
+ if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
+ && array_key_exists($attrCode, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
+ $forObject->setCustomAttribute($attrCode, $value);
+ }
+ $forObject->setData($attrCode, $value);
+ }
+
+ /**
+ * @inheritDoc
+ *
+ * @param AbstractModel $object
+ */
+ public function validate($object)
+ {
+ $valid = parent::validate($object);
+ if ($valid) {
+ $this->prepareValue($object);
+ }
+
+ return $valid;
+ }
+
+ /**
+ * @inheritDoc
+ * @param AbstractModel $object
+ * @throws LocalizedException
+ */
+ public function beforeSave($object)
+ {
+ $this->setAttributeValue($this->prepareValue($object), $object);
+
+ return $this;
+ }
+}
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index 881fb3a57d3e7..d5190d5df5ed3 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -8,9 +8,7 @@
use Magento\Catalog\Model\AbstractModel;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\View\Model\Layout\Update\ValidatorFactory;
-use Magento\Eav\Model\Entity\Attribute\Exception;
-use Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate as CategoryLayoutUpdate;
-use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as ProductLayoutUpdate;
+use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
/**
* Layout update attribute backend
@@ -20,18 +18,15 @@
* @SuppressWarnings(PHPMD.LongVariable)
* @since 100.0.2
*/
-class Customlayoutupdate extends \Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend
+class Customlayoutupdate extends AbstractBackend
{
/**
- * Layout update validator factory
- *
* @var ValidatorFactory
+ * @deprecated Is not used anymore.
*/
protected $_layoutUpdateValidatorFactory;
/**
- * Construct the custom layout update class
- *
* @param ValidatorFactory $layoutUpdateValidatorFactory
*/
public function __construct(ValidatorFactory $layoutUpdateValidatorFactory)
@@ -40,31 +35,19 @@ public function __construct(ValidatorFactory $layoutUpdateValidatorFactory)
}
/**
- * Validate the custom layout update
- *
- * @param \Magento\Framework\DataObject $object
- * @return bool
- * @throws Exception
+ * @inheritDoc
+ * @param AbstractModel $object
*/
public function validate($object)
{
- $attributeName = $this->getAttribute()->getName();
- $xml = trim($object->getData($attributeName));
-
- if (!$this->getAttribute()->getIsRequired() && empty($xml)) {
- return true;
+ if (parent::validate($object)) {
+ $attrCode = $this->getAttribute()->getAttributeCode();
+ $value = $this->extractValue($object);
+ if ($value && $object->getOrigData($attrCode) !== $value) {
+ throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
+ }
}
- /** @var $validator \Magento\Framework\View\Model\Layout\Update\Validator */
- $validator = $this->_layoutUpdateValidatorFactory->create();
- if (!$validator->isValid($xml)) {
- $messages = $validator->getMessages();
- //Add first message to exception
- $message = array_shift($messages);
- $eavExc = new Exception(__($message));
- $eavExc->setAttributeCode($attributeName);
- throw $eavExc;
- }
return true;
}
@@ -78,23 +61,34 @@ public function validate($object)
private function extractValue(AbstractModel $object, ?string $attributeCode = null)
{
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
- $attribute = $object->getCustomAttribute($attributeCode);
+ $data = $object->getData();
+ //Custom attributes must not be initialized if they have not already been or it will break the saving process.
+ if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
+ && array_key_exists($attributeCode, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
+ return $object->getCustomAttribute($attributeCode)->getValue();
+ } elseif (array_key_exists($attributeCode, $data)) {
+ return $data[$attributeCode];
+ }
- return $object->getData($attributeCode) ?? ($attribute ? $attribute->getValue() : null);
+ return null;
}
/**
* Put an attribute value.
*
* @param AbstractModel $object
- * @param mixed $value
+ * @param string|null $value
* @param string|null $attributeCode
* @return void
*/
- private function putValue(AbstractModel $object, $value, ?string $attributeCode = null): void
+ private function putValue(AbstractModel $object, ?string $value, ?string $attributeCode = null): void
{
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
- $object->setCustomAttribute($attributeCode, $value);
+ $data = $object->getData();
+ if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
+ && array_key_exists($attributeCode, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
+ $object->setCustomAttribute($attributeCode, $value);
+ }
$object->setData($attributeCode, $value);
}
@@ -105,18 +99,11 @@ private function putValue(AbstractModel $object, $value, ?string $attributeCode
*/
public function beforeSave($object)
{
- $attributeName = $this->getAttribute()->getName();
- $value = $this->extractValue($object);
- //New values are not accepted
- if ($value && $object->getOrigData($attributeName) !== $value) {
- throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
- }
+ //Validate first, validation might have been skipped.
+ $this->validate($object);
//If custom file was selected we need to remove this attribute
$file = $this->extractValue($object, 'custom_layout_update_file');
- if ($file
- && $file !== CategoryLayoutUpdate::VALUE_USE_UPDATE_XML
- && $file !== ProductLayoutUpdate::VALUE_USE_UPDATE_XML
- ) {
+ if ($file && $file !== AbstractLayoutUpdate::VALUE_USE_UPDATE_XML) {
$this->putValue($object, null);
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index ee10b170f0d84..cab8dc0961bb1 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -8,17 +8,16 @@
namespace Magento\Catalog\Model\Category\Attribute\Backend;
-use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
+use Magento\Catalog\Model\AbstractModel;
+use Magento\Catalog\Model\Attribute\Backend\AbstractLayoutUpdate;
use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
-use Magento\Framework\Exception\LocalizedException;
/**
* Allows to select a layout file to merge when rendering the category's page.
*/
-class LayoutUpdate extends AbstractBackend
+class LayoutUpdate extends AbstractLayoutUpdate
{
- public const VALUE_USE_UPDATE_XML = '__existing__';
/**
* @var LayoutUpdateManager
@@ -33,72 +32,12 @@ public function __construct(LayoutUpdateManager $manager)
$this->manager = $manager;
}
- /**
- * Extracts the attributes value from given entity.
- *
- * @throws LocalizedException
- * @param Category $category
- * @return string|null
- */
- private function extractValue(Category $category): ?string
- {
- $attrCode = $this->getAttribute()->getAttributeCode();
- $attrValue = $category->getCustomAttribute($attrCode);
- $value = $category->getData($attrCode) ?? ($attrValue ? $attrValue->getValue() : null);
- if ($value
- && $value !== self::VALUE_USE_UPDATE_XML
- && !in_array($value, $this->manager->fetchAvailableFiles($category), true)
- ) {
- throw new LocalizedException(__('Selected layout update is not available'));
- }
- if (!$value) {
- $value = null;
- }
-
- return $value;
- }
-
- /**
- * Set value for the object.
- *
- * @param string|null $value
- * @param Category $object
- */
- private function setValue(?string $value, Category $object): void
- {
- $attrCode = $this->getAttribute()->getAttributeCode();
- $object->setCustomAttribute($attrCode, $value);
- $object->setData($attrCode, $value);
- }
-
/**
* @inheritDoc
- *
- * @param Category $object
+ * @param AbstractModel|Category $forModel
*/
- public function validate($object)
+ protected function listAvailableValues(AbstractModel $forModel): array
{
- $valid = parent::validate($object);
- if ($valid) {
- $this->extractValue($object);
- }
-
- return $valid;
- }
-
- /**
- * @inheritDoc
- * @param Category $object
- * @throws LocalizedException
- */
- public function beforeSave($object)
- {
- $value = $this->extractValue($object);
- if ($value === self::VALUE_USE_UPDATE_XML) {
- $value = null;
- }
- $this->setValue($value, $object);
-
- return $this;
+ return $this->manager->fetchAvailableFiles($forModel);
}
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index e71e27cac6dd0..e3050baee2f5b 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -8,17 +8,16 @@
namespace Magento\Catalog\Model\Product\Attribute\Backend;
-use Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend;
+use Magento\Catalog\Model\AbstractModel;
+use Magento\Catalog\Model\Attribute\Backend\AbstractLayoutUpdate;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
-use Magento\Framework\Exception\LocalizedException;
/**
* Allows to select a layout file to merge when rendering the product's page.
*/
-class LayoutUpdate extends AbstractBackend
+class LayoutUpdate extends AbstractLayoutUpdate
{
- public const VALUE_USE_UPDATE_XML = '__existing__';
/**
* @var LayoutUpdateManager
@@ -33,72 +32,12 @@ public function __construct(LayoutUpdateManager $manager)
$this->manager = $manager;
}
- /**
- * Extracts the attributes value from given entity.
- *
- * @throws LocalizedException
- * @param Product $product
- * @return string|null
- */
- private function extractValue(Product $product): ?string
- {
- $attrCode = $this->getAttribute()->getAttributeCode();
- $attrValue = $product->getCustomAttribute($attrCode);
- $value = $product->getData($attrCode) ?? ($attrValue ? $attrValue->getValue() : null);
- if ($value
- && $value !== self::VALUE_USE_UPDATE_XML
- && !in_array($value, $this->manager->fetchAvailableFiles($product), true)
- ) {
- throw new LocalizedException(__('Selected layout update is not available'));
- }
- if (!$value) {
- $value = null;
- }
-
- return $value;
- }
-
- /**
- * Set value for the object.
- *
- * @param string|null $value
- * @param Product $object
- */
- private function setValue(?string $value, Product $object): void
- {
- $attrCode = $this->getAttribute()->getAttributeCode();
- $object->setCustomAttribute($attrCode, $value);
- $object->setData($attrCode, $value);
- }
-
/**
* @inheritDoc
- *
- * @param Product $object
+ * @param AbstractModel|Product $forModel
*/
- public function validate($object)
+ protected function listAvailableValues(AbstractModel $forModel): array
{
- $valid = parent::validate($object);
- if ($valid) {
- $this->extractValue($object);
- }
-
- return $valid;
- }
-
- /**
- * @inheritDoc
- * @param Product $object
- * @throws LocalizedException
- */
- public function beforeSave($object)
- {
- $value = $this->extractValue($object);
- if ($value === self::VALUE_USE_UPDATE_XML) {
- $value = null;
- }
- $this->setValue($value, $object);
-
- return $this;
+ return $this->manager->fetchAvailableFiles($forModel);
}
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
index 1e0acdc989cdb..12f7118924268 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -8,7 +8,6 @@
namespace Magento\Catalog\Model\Product\Attribute;
-use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\Area;
use Magento\Framework\DataObject;
@@ -16,7 +15,6 @@
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\Model\Layout\Merge as LayoutProcessor;
use Magento\Framework\View\Model\Layout\MergeFactory as LayoutProcessorFactory;
-use Magento\Framework\View\Result\Page as PageLayout;
/**
* Manage available layout updates for products.
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index 67b6ec4e7d70f..c5537c89b78d0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -449,8 +449,8 @@ public function testSaveDesign(): void
/**
* Test custom update files functionality.
*
- * @magentoDbIsolation enabled
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoDbIsolation disabled
* @throws \Throwable
* @return void
*/
@@ -463,8 +463,11 @@ public function testSaveCustomLayout(): void
/** @var ProductLayoutUpdateManager $layoutManager */
$layoutManager = Bootstrap::getObjectManager()->get(ProductLayoutUpdateManager::class);
$layoutManager->setFakeFiles((int)$product->getId(), [$file]);
+ $productData = $product->getData();
+ unset($productData['options']);
+ unset($productData[$product->getIdFieldName()]);
$requestData = [
- 'product' => $product->getData()
+ 'product' => $productData
];
$uri = 'backend/catalog/product/save';
@@ -476,7 +479,7 @@ public function testSaveCustomLayout(): void
$this->getRequest()->setParam('id', $product->getId());
$this->dispatch($uri);
$this->assertSessionMessages(
- self::equalTo(['tst']),
+ self::equalTo(['Selected layout update is not available']),
MessageInterface::TYPE_ERROR
);
From cb08621a0c4330adf90d552f3c30cacaf2f1b717 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 9 Sep 2019 13:47:56 -0500
Subject: [PATCH 0127/1978] MC-18685: Remove custom layout updates from admin
---
.../Catalog/Model/Category/DataProvider.php | 5 ++
.../Model/Category/DataProviderTest.php | 78 ++++++++++++-------
2 files changed, 57 insertions(+), 26 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php
index bd377f4ab302e..16239f71355fa 100644
--- a/app/code/Magento/Catalog/Model/Category/DataProvider.php
+++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php
@@ -67,6 +67,8 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider
'size' => 'multiline_count',
];
+ private $boolMetaProperties = ['visible', 'required'];
+
/**
* Form element mapping
*
@@ -358,6 +360,9 @@ public function getAttributesMeta(Type $entityType)
foreach ($this->metaProperties as $metaName => $origName) {
$value = $attribute->getDataUsingMethod($origName);
$meta[$code][$metaName] = $value;
+ if (in_array($metaName, $this->boolMetaProperties, true)) {
+ $meta[$code][$metaName] = (bool)$meta[$code][$metaName];
+ }
if ('frontend_input' === $origName) {
$meta[$code]['formElement'] = isset($this->formElement[$value])
? $this->formElement[$value]
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
index e91aa01eb9046..5934f32dcd746 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
@@ -90,6 +90,33 @@ public function testGetMetaRequiredAttributes()
}
}
+ /**
+ * Check that deprecated custom layout attribute is hidden.
+ *
+ * @return void
+ */
+ public function testOldCustomLayoutInvisible(): void
+ {
+ //Testing a category without layout xml
+ /** @var Category $category */
+ $category = $this->categoryFactory->create();
+ $category->load($id = 2);
+ $this->registry->register('category', $category);
+
+ $meta = $this->dataProvider->getMeta();
+ $this->assertArrayHasKey('design', $meta);
+ $this->assertArrayHasKey('children', $meta['design']);
+ $this->assertArrayHasKey('custom_layout_update', $meta['design']['children']);
+ $this->assertArrayHasKey('arguments', $meta['design']['children']['custom_layout_update']);
+ $this->assertArrayHasKey('data', $meta['design']['children']['custom_layout_update']['arguments']);
+ $this->assertArrayHasKey(
+ 'config',
+ $meta['design']['children']['custom_layout_update']['arguments']['data']
+ );
+ $config = $meta['design']['children']['custom_layout_update']['arguments']['data']['config'];
+ $this->assertTrue($config['visible'] === false);
+ }
+
/**
* Check that custom layout update file attribute is processed correctly.
*
@@ -117,20 +144,13 @@ public function testCustomLayoutFileAttribute(): void
}
/**
- * Check that proper options are returned for a category.
+ * Extract custom layout update file attribute's options from metadata.
*
- * @return void
+ * @param array $meta
+ * @return array
*/
- public function testCustomLayoutMeta(): void
+ private function extractCustomLayoutOptions(array $meta): array
{
- //Testing a category without layout xml
- /** @var Category $category */
- $category = $this->categoryFactory->create();
- $category->load($id = 2);
- $this->fakeFiles->setCategoryFakeFiles((int)$category->getId(), ['test1', 'test2']);
- $this->registry->register('category', $category);
-
- $meta = $this->dataProvider->getMeta();
$this->assertArrayHasKey('design', $meta);
$this->assertArrayHasKey('children', $meta['design']);
$this->assertArrayHasKey('custom_layout_update_file', $meta['design']['children']);
@@ -144,12 +164,31 @@ public function testCustomLayoutMeta(): void
'options',
$meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']
);
+
+ return $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']['options'];
+ }
+
+ /**
+ * Check that proper options are returned for a category.
+ *
+ * @return void
+ */
+ public function testCustomLayoutMeta(): void
+ {
+ //Testing a category without layout xml
+ /** @var Category $category */
+ $category = $this->categoryFactory->create();
+ $category->load($id = 2);
+ $this->fakeFiles->setCategoryFakeFiles((int)$category->getId(), ['test1', 'test2']);
+ $this->registry->register('category', $category);
+
+ $meta = $this->dataProvider->getMeta();
+ $list = $this->extractCustomLayoutOptions($meta);
$expectedList = [
['label' => 'No update', 'value' => '', '__disableTmpl' => true],
['label' => 'test1', 'value' => 'test1', '__disableTmpl' => true],
['label' => 'test2', 'value' => 'test2', '__disableTmpl' => true]
];
- $list = $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']['options'];
sort($expectedList);
sort($list);
$this->assertEquals($expectedList, $list);
@@ -159,19 +198,6 @@ public function testCustomLayoutMeta(): void
$this->fakeFiles->setCategoryFakeFiles((int)$category->getId(), ['test3']);
$meta = $this->dataProvider->getMeta();
- $this->assertArrayHasKey('design', $meta);
- $this->assertArrayHasKey('children', $meta['design']);
- $this->assertArrayHasKey('custom_layout_update_file', $meta['design']['children']);
- $this->assertArrayHasKey('arguments', $meta['design']['children']['custom_layout_update_file']);
- $this->assertArrayHasKey('data', $meta['design']['children']['custom_layout_update_file']['arguments']);
- $this->assertArrayHasKey(
- 'config',
- $meta['design']['children']['custom_layout_update_file']['arguments']['data']
- );
- $this->assertArrayHasKey(
- 'options',
- $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']
- );
$expectedList = [
['label' => 'No update', 'value' => '', '__disableTmpl' => true],
[
@@ -181,7 +207,7 @@ public function testCustomLayoutMeta(): void
],
['label' => 'test3', 'value' => 'test3', '__disableTmpl' => true],
];
- $list = $meta['design']['children']['custom_layout_update_file']['arguments']['data']['config']['options'];
+ $list = $this->extractCustomLayoutOptions($meta);
sort($expectedList);
sort($list);
$this->assertEquals($expectedList, $list);
From 422bc7f5b4f0b617e7a88650927d150bc45c3ebb Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 9 Sep 2019 14:09:11 -0500
Subject: [PATCH 0128/1978] MC-18685: Remove custom layout updates from admin
---
.../Backend/AbstractLayoutUpdate.php | 15 +-
.../Attribute/Backend/Customlayoutupdate.php | 22 +--
.../Backend/CustomlayoutupdateTest.php | 137 ------------------
.../Backend/CustomlayoutupdateTest.php | 25 +++-
4 files changed, 28 insertions(+), 171 deletions(-)
delete mode 100644 app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
index ece3c8e499e4d..6aedd509af8e0 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
@@ -23,22 +23,13 @@ abstract class AbstractLayoutUpdate extends AbstractBackend
* Extract attribute value.
*
* @param AbstractModel $model
- * @throws LocalizedException
* @return mixed
*/
private function extractAttributeValue(AbstractModel $model)
{
$code = $this->getAttribute()->getAttributeCode();
- $data = $model->getData();
- //Custom attributes must not be initialized if they have not already been or it will break the saving process.
- if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
- && array_key_exists($code, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
- return $model->getCustomAttribute($code)->getValue();
- } elseif (array_key_exists($code, $data)) {
- return $data[$code];
- }
- return null;
+ return $model->getData($code);
}
/**
@@ -85,9 +76,7 @@ private function prepareValue(AbstractModel $model): ?string
private function setAttributeValue(?string $value, AbstractModel $forObject): void
{
$attrCode = $this->getAttribute()->getAttributeCode();
- $data = $forObject->getData();
- if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
- && array_key_exists($attrCode, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
+ if ($forObject->hasData(AbstractModel::CUSTOM_ATTRIBUTES)) {
$forObject->setCustomAttribute($attrCode, $value);
}
$forObject->setData($attrCode, $value);
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index d5190d5df5ed3..ceb6f660aed6f 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -42,9 +42,11 @@ public function validate($object)
{
if (parent::validate($object)) {
$attrCode = $this->getAttribute()->getAttributeCode();
- $value = $this->extractValue($object);
- if ($value && $object->getOrigData($attrCode) !== $value) {
- throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
+ if ($object instanceof AbstractModel) {
+ $value = $this->extractValue($object);
+ if ($value && $object->getOrigData($attrCode) !== $value) {
+ throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
+ }
}
}
@@ -61,16 +63,8 @@ public function validate($object)
private function extractValue(AbstractModel $object, ?string $attributeCode = null)
{
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
- $data = $object->getData();
- //Custom attributes must not be initialized if they have not already been or it will break the saving process.
- if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
- && array_key_exists($attributeCode, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
- return $object->getCustomAttribute($attributeCode)->getValue();
- } elseif (array_key_exists($attributeCode, $data)) {
- return $data[$attributeCode];
- }
- return null;
+ return $object->getData($attributeCode);
}
/**
@@ -84,9 +78,7 @@ private function extractValue(AbstractModel $object, ?string $attributeCode = nu
private function putValue(AbstractModel $object, ?string $value, ?string $attributeCode = null): void
{
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
- $data = $object->getData();
- if (array_key_exists(AbstractModel::CUSTOM_ATTRIBUTES, $data)
- && array_key_exists($attributeCode, $data[AbstractModel::CUSTOM_ATTRIBUTES])) {
+ if ($object->hasData(AbstractModel::CUSTOM_ATTRIBUTES)) {
$object->setCustomAttribute($attributeCode, $value);
}
$object->setData($attributeCode, $value);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php
deleted file mode 100644
index 01fad60609c29..0000000000000
--- a/app/code/Magento/Catalog/Test/Unit/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ /dev/null
@@ -1,137 +0,0 @@
-setData($this->attributeName, 'exception');
- $this->model->validate($object);
- }
-
- /**
- * @param string
- * @dataProvider validateProvider
- */
- public function testValidate($data)
- {
- $object = new DataObject();
- $object->setData($this->attributeName, $data);
-
- $this->assertTrue($this->model->validate($object));
- $this->assertTrue($this->model->validate($object));
- }
-
- /**
- * @return array
- */
- public function validateProvider()
- {
- return [[''], ['xml']];
- }
-
- protected function setUp()
- {
- $helper = new ObjectManager($this);
- $this->model = $helper->getObject(
- \Magento\Catalog\Model\Attribute\Backend\Customlayoutupdate::class,
- [
- 'layoutUpdateValidatorFactory' => $this->getMockedLayoutUpdateValidatorFactory()
- ]
- );
- $this->model->setAttribute($this->getMockedAttribute());
- }
-
- /**
- * @return \Magento\Framework\View\Model\Layout\Update\ValidatorFactory
- */
- private function getMockedLayoutUpdateValidatorFactory()
- {
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\View\Model\Layout\Update\ValidatorFactory::class);
- $mockBuilder->disableOriginalConstructor();
- $mockBuilder->setMethods(['create']);
- $mock = $mockBuilder->getMock();
-
- $mock->expects($this->any())
- ->method('create')
- ->will($this->returnValue($this->getMockedValidator()));
-
- return $mock;
- }
-
- /**
- * @return \Magento\Framework\View\Model\Layout\Update\Validator
- */
- private function getMockedValidator()
- {
- $mockBuilder = $this->getMockBuilder(\Magento\Framework\View\Model\Layout\Update\Validator::class);
- $mockBuilder->disableOriginalConstructor();
- $mock = $mockBuilder->getMock();
-
- $mock->expects($this->any())
- ->method('isValid')
- ->will(
- /**
- * @param string $xml
- * $return bool
- */
- $this->returnCallback(
- function ($xml) {
- if ($xml == 'exception') {
- return false;
- } else {
- return true;
- }
- }
- )
- );
-
- $mock->expects($this->any())
- ->method('getMessages')
- ->will($this->returnValue(['error']));
-
- return $mock;
- }
-
- /**
- * @return \Magento\Eav\Model\Entity\Attribute\AbstractAttribute
- */
- private function getMockedAttribute()
- {
- $mockBuilder = $this->getMockBuilder(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
- $mockBuilder->disableOriginalConstructor();
- $mock = $mockBuilder->getMock();
-
- $mock->expects($this->any())
- ->method('getName')
- ->will($this->returnValue($this->attributeName));
-
- $mock->expects($this->any())
- ->method('getIsRequired')
- ->will($this->returnValue(false));
-
- return $mock;
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index dbc14c7d25dae..2efeae50dc3c4 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -35,14 +35,24 @@ class CustomlayoutupdateTest extends TestCase
*/
private $category;
+ /**
+ * Recreate the category model.
+ *
+ * @return void
+ */
+ private function recreateCategory(): void
+ {
+ $this->category = $this->categoryFactory->create();
+ $this->category->load(2);
+ }
+
/**
* @inheritDoc
*/
protected function setUp()
{
$this->categoryFactory = Bootstrap::getObjectManager()->get(CategoryFactory::class);
- $this->category = $this->categoryFactory->create();
- $this->category->load(2);
+ $this->recreateCategory();
$this->attribute = $this->category->getAttributes()['custom_layout_update']->getBackend();
}
@@ -100,19 +110,22 @@ public function testDependsOnNewUpdate(): void
$this->attribute->beforeSave($this->category);
$this->assertEmpty($this->category->getCustomAttribute('custom_layout_update')->getValue());
$this->assertEquals('new', $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
+ $this->assertEmpty($this->category->getData('custom_layout_update'));
+ $this->assertEquals('new', $this->category->getData('custom_layout_update_file'));
//Existing update chosen
- $this->category->setCustomAttribute('custom_layout_update', 'test');
+ $this->recreateCategory();
+ $this->category->setData('custom_layout_update', 'test');
$this->category->setOrigData('custom_layout_update', 'test');
- $this->category->setCustomAttribute(
+ $this->category->setData(
'custom_layout_update_file',
\Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML
);
$this->attribute->beforeSave($this->category);
- $this->assertEquals('test', $this->category->getCustomAttribute('custom_layout_update')->getValue());
+ $this->assertEquals('test', $this->category->getData('custom_layout_update'));
/** @var AbstractBackend $fileAttribute */
$fileAttribute = $this->category->getAttributes()['custom_layout_update_file']->getBackend();
$fileAttribute->beforeSave($this->category);
- $this->assertEquals(null, $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
+ $this->assertEquals(null, $this->category->getData('custom_layout_update_file'));
}
}
From b12bd5a34a79dbd621a4a1a0288fe9d0ddf20f8b Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 9 Sep 2019 15:13:07 -0500
Subject: [PATCH 0129/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Backend/Customlayoutupdate.php | 42 +++++++++++--------
.../Attribute/Backend/LayoutUpdate.php | 1 +
.../Attribute/Backend/LayoutUpdate.php | 1 +
.../Catalog/Api/CategoryRepositoryTest.php | 4 +-
.../Category/CreateCategoryEntityTest.xml | 4 +-
.../Backend/CustomlayoutupdateTest.php | 3 +-
.../Model/Category/DataProviderTest.php | 3 +-
.../Form/Modifier/LayoutUpdateTest.php | 1 +
8 files changed, 37 insertions(+), 22 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index ceb6f660aed6f..d3cdb7c545cbc 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -34,8 +34,27 @@ public function __construct(ValidatorFactory $layoutUpdateValidatorFactory)
$this->_layoutUpdateValidatorFactory = $layoutUpdateValidatorFactory;
}
+ /**
+ * Extract an attribute value.
+ *
+ * @param AbstractModel $object
+ * @param string|null $attributeCode
+ * @return mixed
+ */
+ private function extractValue(AbstractModel $object, ?string $attributeCode = null)
+ {
+ $attributeCode = $attributeCode ?? $this->getAttribute()->getName();
+ $value = $object->getData($attributeCode);
+ if (!$value) {
+ $value = null;
+ }
+
+ return $value;
+ }
+
/**
* @inheritDoc
+ *
* @param AbstractModel $object
*/
public function validate($object)
@@ -53,31 +72,16 @@ public function validate($object)
return true;
}
- /**
- * Extract an attribute value.
- *
- * @param AbstractModel $object
- * @param string|null $attributeCode
- * @return mixed
- */
- private function extractValue(AbstractModel $object, ?string $attributeCode = null)
- {
- $attributeCode = $attributeCode ?? $this->getAttribute()->getName();
-
- return $object->getData($attributeCode);
- }
-
/**
* Put an attribute value.
*
* @param AbstractModel $object
* @param string|null $value
- * @param string|null $attributeCode
* @return void
*/
- private function putValue(AbstractModel $object, ?string $value, ?string $attributeCode = null): void
+ private function putValue(AbstractModel $object, ?string $value): void
{
- $attributeCode = $attributeCode ?? $this->getAttribute()->getName();
+ $attributeCode = $this->getAttribute()->getName();
if ($object->hasData(AbstractModel::CUSTOM_ATTRIBUTES)) {
$object->setCustomAttribute($attributeCode, $value);
}
@@ -86,6 +90,7 @@ private function putValue(AbstractModel $object, ?string $value, ?string $attrib
/**
* @inheritDoc
+ *
* @param AbstractModel $object
* @throws LocalizedException
*/
@@ -93,10 +98,13 @@ public function beforeSave($object)
{
//Validate first, validation might have been skipped.
$this->validate($object);
+ $value = $this->extractValue($object);
//If custom file was selected we need to remove this attribute
$file = $this->extractValue($object, 'custom_layout_update_file');
if ($file && $file !== AbstractLayoutUpdate::VALUE_USE_UPDATE_XML) {
$this->putValue($object, null);
+ } else {
+ $this->putValue($object, $value);
}
return parent::beforeSave($object);
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index cab8dc0961bb1..215fe1c19bd8d 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -34,6 +34,7 @@ public function __construct(LayoutUpdateManager $manager)
/**
* @inheritDoc
+ *
* @param AbstractModel|Category $forModel
*/
protected function listAvailableValues(AbstractModel $forModel): array
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index e3050baee2f5b..fa5a218824eea 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -34,6 +34,7 @@ public function __construct(LayoutUpdateManager $manager)
/**
* @inheritDoc
+ *
* @param AbstractModel|Product $forModel
*/
protected function listAvailableValues(AbstractModel $forModel): array
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
index 510a4f1594fff..e0c45967b214e 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
@@ -316,7 +316,9 @@ protected function updateCategory($id, $data, ?string $token = null)
'operation' => self::SERVICE_NAME . 'Save',
],
];
- $serviceInfo['rest']['token'] = $serviceInfo['soap']['token'] = $token;
+ if ($token) {
+ $serviceInfo['rest']['token'] = $serviceInfo['soap']['token'] = $token;
+ }
if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) {
$data['id'] = $id;
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml
index 69093b8adb8db..54f0fd8e3e79b 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml
@@ -37,7 +37,7 @@
custom meta keywords %isolation%
Custom meta description %isolation%
2 columns with right bar
- <referenceContainer name="catalog.leftnav" remove="true"/>
+
Magento Luma
Yes
01/10/2014
@@ -80,7 +80,7 @@
Custom meta description %isolation%
catalogProductSimple::default,catalogProductSimple::default
2 columns with right bar
- <referenceContainer name="content.aside" remove="true"/>
+
Magento Luma
Yes
01/10/2014
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index 2efeae50dc3c4..7447950ea2ab6 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -90,9 +90,10 @@ public function testImmutable(): void
$this->assertTrue($caughtException);
//Removing a value
- $this->category->setCustomAttribute('custom_layout_update', null);
+ $this->category->setCustomAttribute('custom_layout_update', '');
$this->category->setOrigData('custom_layout_update', 'test');
$this->attribute->beforeSave($this->category);
+ $this->assertNull($this->category->getCustomAttribute('custom_layout_update')->getValue());
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
index 5934f32dcd746..93cf11477ed56 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
@@ -127,7 +127,8 @@ public function testCustomLayoutFileAttribute(): void
//File has value
/** @var Category $category */
$category = $this->categoryFactory->create();
- $category->load($id = 2);
+ $id = 2;
+ $category->load($id);
$category->setData('custom_layout_update', null);
$category->setData('custom_layout_update_file', $file = 'test-file');
$this->registry->register('category', $category);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
index 61e68561d9ee4..6ccae88d38672 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
@@ -24,6 +24,7 @@
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoAppArea adminhtml
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class LayoutUpdateTest extends TestCase
{
From fe50575bcebec1e4afa0177b69ac8b122c62bd23 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 9 Sep 2019 16:56:13 -0500
Subject: [PATCH 0130/1978] MC-18685: Remove custom layout updates from admin
---
.../Category/CreateCategoryEntityTest.xml | 2 -
.../Model/Category/DataProviderTest.php | 4 +-
.../Form/Modifier/LayoutUpdateTest.php | 56 +++++++++----------
.../Adminhtml/Category/Tab/AttributesTest.php | 4 +-
4 files changed, 31 insertions(+), 35 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml
index 54f0fd8e3e79b..5ea1b692e3eb9 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/TestCase/Category/CreateCategoryEntityTest.xml
@@ -37,7 +37,6 @@
custom meta keywords %isolation%
Custom meta description %isolation%
2 columns with right bar
-
Magento Luma
Yes
01/10/2014
@@ -80,7 +79,6 @@
Custom meta description %isolation%
catalogProductSimple::default,catalogProductSimple::default
2 columns with right bar
-
Magento Luma
Yes
01/10/2014
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
index 93cf11477ed56..49cba292f974a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
@@ -100,7 +100,7 @@ public function testOldCustomLayoutInvisible(): void
//Testing a category without layout xml
/** @var Category $category */
$category = $this->categoryFactory->create();
- $category->load($id = 2);
+ $category->load(2);
$this->registry->register('category', $category);
$meta = $this->dataProvider->getMeta();
@@ -179,7 +179,7 @@ public function testCustomLayoutMeta(): void
//Testing a category without layout xml
/** @var Category $category */
$category = $this->categoryFactory->create();
- $category->load($id = 2);
+ $category->load(2);
$this->fakeFiles->setCategoryFakeFiles((int)$category->getId(), ['test1', 'test2']);
$this->registry->register('category', $category);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
index 6ccae88d38672..4a928fb1386c0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
@@ -107,20 +107,13 @@ public function testModifyData(): void
}
/**
- * Check that entity specific options are returned.
+ * Extract options meta.
*
- * @return void
- * @throws \Throwable
- * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @param array $meta
+ * @return array
*/
- public function testEntitySpecificData(): void
+ private function extractCustomLayoutOptions(array $meta): array
{
- //Testing a category without layout xml
- $product = $this->repo->get('simple');
- $this->locator->method('getProduct')->willReturn($product);
- $this->fakeFiles->setFakeFiles((int)$product->getId(), ['test1', 'test2']);
-
- $meta = $this->eavModifier->modifyMeta([]);
$this->assertArrayHasKey('design', $meta);
$this->assertArrayHasKey('children', $meta['design']);
$this->assertArrayHasKey('container_custom_layout_update_file', $meta['design']['children']);
@@ -135,12 +128,31 @@ public function testEntitySpecificData(): void
$this->assertArrayHasKey('data', $fieldMeta['arguments']);
$this->assertArrayHasKey('config', $fieldMeta['arguments']['data']);
$this->assertArrayHasKey('options', $fieldMeta['arguments']['data']['config']);
+
+ return $fieldMeta['arguments']['data']['config']['options'];
+ }
+
+ /**
+ * Check that entity specific options are returned.
+ *
+ * @return void
+ * @throws \Throwable
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ */
+ public function testEntitySpecificData(): void
+ {
+ //Testing a category without layout xml
+ $product = $this->repo->get('simple');
+ $this->locator->method('getProduct')->willReturn($product);
+ $this->fakeFiles->setFakeFiles((int)$product->getId(), ['testOne', 'test_two']);
+
+ $meta = $this->eavModifier->modifyMeta([]);
+ $list = $this->extractCustomLayoutOptions($meta);
$expectedList = [
['label' => 'No update', 'value' => '', '__disableTmpl' => true],
- ['label' => 'test1', 'value' => 'test1', '__disableTmpl' => true],
- ['label' => 'test2', 'value' => 'test2', '__disableTmpl' => true]
+ ['label' => 'testOne', 'value' => 'testOne', '__disableTmpl' => true],
+ ['label' => 'test_two', 'value' => 'test_two', '__disableTmpl' => true]
];
- $list = $fieldMeta['arguments']['data']['config']['options'];
sort($expectedList);
sort($list);
$this->assertEquals($expectedList, $list);
@@ -150,20 +162,7 @@ public function testEntitySpecificData(): void
$this->fakeFiles->setFakeFiles((int)$product->getId(), ['test3']);
$meta = $this->eavModifier->modifyMeta([]);
- $this->assertArrayHasKey('design', $meta);
- $this->assertArrayHasKey('children', $meta['design']);
- $this->assertArrayHasKey('container_custom_layout_update_file', $meta['design']['children']);
- $this->assertArrayHasKey('children', $meta['design']['children']['container_custom_layout_update_file']);
- $this->assertArrayHasKey(
- 'custom_layout_update_file',
- $meta['design']['children']['container_custom_layout_update_file']['children']
- );
- $fieldMeta = $meta['design']['children']['container_custom_layout_update_file']['children'];
- $fieldMeta = $fieldMeta['custom_layout_update_file'];
- $this->assertArrayHasKey('arguments', $fieldMeta);
- $this->assertArrayHasKey('data', $fieldMeta['arguments']);
- $this->assertArrayHasKey('config', $fieldMeta['arguments']['data']);
- $this->assertArrayHasKey('options', $fieldMeta['arguments']['data']['config']);
+ $list = $this->extractCustomLayoutOptions($meta);
$expectedList = [
['label' => 'No update', 'value' => '', '__disableTmpl' => true],
[
@@ -173,7 +172,6 @@ public function testEntitySpecificData(): void
],
['label' => 'test3', 'value' => 'test3', '__disableTmpl' => true],
];
- $list = $fieldMeta['arguments']['data']['config']['options'];
sort($expectedList);
sort($list);
$this->assertEquals($expectedList, $list);
diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Plugin/Catalog/Block/Adminhtml/Category/Tab/AttributesTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Plugin/Catalog/Block/Adminhtml/Category/Tab/AttributesTest.php
index 0cd3ad644197b..8ca84c4b066fe 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Plugin/Catalog/Block/Adminhtml/Category/Tab/AttributesTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Plugin/Catalog/Block/Adminhtml/Category/Tab/AttributesTest.php
@@ -51,8 +51,8 @@ public function testGetAttributesMeta()
$urlKeyData = $meta['search_engine_optimization']['children']['url_key']['arguments']['data']['config'];
$this->assertEquals('text', $urlKeyData['dataType']);
$this->assertEquals('input', $urlKeyData['formElement']);
- $this->assertEquals('1', $urlKeyData['visible']);
- $this->assertEquals('0', $urlKeyData['required']);
+ $this->assertEquals(true, $urlKeyData['visible']);
+ $this->assertEquals(false, $urlKeyData['required']);
$this->assertEquals('[STORE VIEW]', $urlKeyData['scopeLabel']);
}
}
From 51d73783d066e55790de6eadc960aa66551bfde2 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 9 Sep 2019 16:56:40 -0500
Subject: [PATCH 0131/1978] MC-18685: Remove custom layout updates from admin
---
.../tests/app/Magento/Catalog/Test/Fixture/Category.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml
index fafd9842cc749..c5036555b6635 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Fixture/Category.xml
@@ -49,7 +49,6 @@
-
From e9dfb728f62d86eab3dc8db29f6eefa172b130b3 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 10 Sep 2019 11:28:23 -0500
Subject: [PATCH 0132/1978] MC-18685: Remove custom layout updates from admin
---
.../Magento/Catalog/Test/Handler/Category/Curl.php | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php
index 5c54b366b7ab4..4cfef9a6b4f66 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Handler/Category/Curl.php
@@ -251,9 +251,15 @@ protected function getBlockId($landingName)
$curl->write($url, [], CurlInterface::GET);
$response = $curl->read();
$curl->close();
- preg_match('~\{"value":"(\d+)","label":"' . preg_quote($landingName) . '"\}~', $response, $matches);
- $id = isset($matches[1]) ? (int)$matches[1] : null;
+ preg_match(
+ '/\{[^\{]*?\\"value\\":\\"(\d+)\\"[^\{]*?\\"label\\":\\"' .preg_quote($landingName) .'\\".*?\}/',
+ $response,
+ $matches
+ );
+ if (empty($matches[1])) {
+ throw new \RuntimeException('Failed to extract CMS block ID from a category page');
+ }
- return $id;
+ return (int)$matches[1];
}
}
From 30e3978e00194dca4eba959103ccfd4b79cb823c Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 11 Sep 2019 11:13:39 +0400
Subject: [PATCH 0133/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
...StrorefrontElasticsearchSearchInvalidValueTest.xml | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
index 55e31e91e9016..1e3badb5f1ce6 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
@@ -40,8 +40,9 @@
-
-
+
+
+
@@ -106,5 +107,11 @@
+
+
+
+
+
+
From 320aac0d8715d7de3201488afaf2cfcaa268e1a4 Mon Sep 17 00:00:00 2001
From: VaD1ke
Date: Tue, 10 Sep 2019 10:45:43 +0300
Subject: [PATCH 0134/1978] Fix doubled elastic index in alias after error
---
app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php b/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php
index 97a76de4b995a..b5309dbdadb70 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php
@@ -193,6 +193,9 @@ public function addDocs(array $documents, $storeId, $mappedIndexerId)
*/
public function cleanIndex($storeId, $mappedIndexerId)
{
+ // needed to fix bug with double indices in alias because of second reindex in same process
+ unset($this->preparedIndex[$storeId]);
+
$this->checkIndex($storeId, $mappedIndexerId, true);
$indexName = $this->indexNameResolver->getIndexName($storeId, $mappedIndexerId, $this->preparedIndex);
if ($this->client->isEmptyIndex($indexName)) {
From 2e4b9004da73012153ae03fbd49b2a986fc5a879 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 11 Sep 2019 10:56:17 -0500
Subject: [PATCH 0135/1978] MC-18685: Remove custom layout updates from admin
---
lib/internal/Magento/Framework/Setup/SampleData/Executor.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/Setup/SampleData/Executor.php b/lib/internal/Magento/Framework/Setup/SampleData/Executor.php
index de60f0378484d..0b6e21b0d2a10 100644
--- a/lib/internal/Magento/Framework/Setup/SampleData/Executor.php
+++ b/lib/internal/Magento/Framework/Setup/SampleData/Executor.php
@@ -49,7 +49,7 @@ public function exec(InstallerInterface $installer)
try {
$this->appState->emulateAreaCode(\Magento\Framework\App\Area::AREA_GLOBAL, [$installer, 'install']);
$this->state->setInstalled();
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
$this->state->setError();
$this->logger->error('Sample Data error: ' . $e->getMessage());
}
From bbe0f4500530aee94b38271acc5c88e9c804d8bb Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 11 Sep 2019 13:04:40 -0500
Subject: [PATCH 0136/1978] MC-18685: Remove custom layout updates from admin
---
lib/internal/Magento/Framework/Setup/SampleData/Executor.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/internal/Magento/Framework/Setup/SampleData/Executor.php b/lib/internal/Magento/Framework/Setup/SampleData/Executor.php
index 0b6e21b0d2a10..43ad676e7f534 100644
--- a/lib/internal/Magento/Framework/Setup/SampleData/Executor.php
+++ b/lib/internal/Magento/Framework/Setup/SampleData/Executor.php
@@ -5,6 +5,9 @@
*/
namespace Magento\Framework\Setup\SampleData;
+/**
+ * Performs sample data installations.
+ */
class Executor
{
/**
@@ -39,6 +42,7 @@ public function __construct(
/**
* Execute SampleData module installation.
+ *
* Catch exception if it appeared and continue installation
*
* @param InstallerInterface $installer
From fcc38ef4d445d96cb108e62eb0f8d17cf421347d Mon Sep 17 00:00:00 2001
From: VaD1ke
Date: Thu, 12 Sep 2019 17:22:14 +0300
Subject: [PATCH 0137/1978] Fix code sniffer violations in elasticsearch
adapter
---
.../Model/Adapter/Elasticsearch.php | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php b/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php
index b5309dbdadb70..7a2b382a5ad53 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/Elasticsearch.php
@@ -206,7 +206,7 @@ public function cleanIndex($storeId, $mappedIndexerId)
// prepare new index name and increase version
$indexPattern = $this->indexNameResolver->getIndexPattern($storeId, $mappedIndexerId);
$version = (int)(str_replace($indexPattern, '', $indexName));
- $newIndexName = $indexPattern . ++$version;
+ $newIndexName = $indexPattern . (++$version);
// remove index if already exists
if ($this->client->indexExists($newIndexName)) {
@@ -357,12 +357,14 @@ protected function prepareIndex($storeId, $indexName, $mappedIndexerId)
{
$this->indexBuilder->setStoreId($storeId);
$settings = $this->indexBuilder->build();
- $allAttributeTypes = $this->fieldMapper->getAllAttributesTypes([
- 'entityType' => $mappedIndexerId,
- // Use store id instead of website id from context for save existing fields mapping.
- // In future websiteId will be eliminated due to index stored per store
- 'websiteId' => $storeId
- ]);
+ $allAttributeTypes = $this->fieldMapper->getAllAttributesTypes(
+ [
+ 'entityType' => $mappedIndexerId,
+ // Use store id instead of website id from context for save existing fields mapping.
+ // In future websiteId will be eliminated due to index stored per store
+ 'websiteId' => $storeId
+ ]
+ );
$settings['index']['mapping']['total_fields']['limit'] = $this->getMappingTotalFieldsLimit($allAttributeTypes);
$this->client->createIndex($indexName, ['settings' => $settings]);
$this->client->addFieldsMapping(
From eaca5465e196a63dc7bd585366b6690e3294f1b7 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Mon, 16 Sep 2019 16:26:45 +0400
Subject: [PATCH 0138/1978] MC-18822: Increase test coverage for Content
functional area
- Automation test for MC-6192
---
.../AdminProductAttributeSetActionGroup.xml | 8 +-
.../Test/Mftf/Data/ProductAttributeData.xml | 4 +
.../Catalog/Test/Mftf/Data/ProductData.xml | 13 --
.../Mftf/Section/AdminProductFormSection.xml | 2 +-
.../StorefrontCategorySidebarSection.xml | 1 +
.../AdminAddOptionsToAttributeActionGroup.xml | 38 ----
.../AdminConfigurableProductActionGroup.xml | 41 ++--
...reateProductConfigurationsPanelSection.xml | 2 +-
...CheckResultsOfColorAndOtherFiltersTest.xml | 186 ++++++++++++++++++
...CheckResultsOfColorAndOtherFiltersTest.xml | 172 ----------------
10 files changed, 210 insertions(+), 257 deletions(-)
create mode 100644 app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
delete mode 100644 app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
index c67c2148673a5..e3f13f32ad015 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
@@ -64,11 +64,11 @@
-
+
-
-
-
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
index 6bbca45741c75..bc5f2af7b9950 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
@@ -108,6 +108,10 @@
true
ProductAttributeFrontendLabel
+
+ multiselect
+ Multiple Select
+
attribute
select
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index b8d7aa878230a..517ab253b8238 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -1165,19 +1165,6 @@
EavStock10
CustomAttributeProductAttribute
-
- Simple1
- simple
- 4
- 4
- Simple1
- 1.00
- api-simple-product
- 1
- 111
- EavStockItem
- CustomAttributeCategoryIds
-
simple-product_
simple
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
index b8aa4aa0ce822..fbfeac6327f90 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
index 406bea8d8aeab..0058d32dda303 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
@@ -8,6 +8,7 @@
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml
index b8bdbdfe082c5..e88f71ce23ac2 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminAddOptionsToAttributeActionGroup.xml
@@ -8,44 +8,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Adds 5 provided Options to a new Attribute on the Configurable Product creation/edit page.
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
index a1042141d9373..9b77dfd043f71 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
@@ -26,40 +26,25 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
-
+
+
-
+
+
-
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml
index 488b227c29cbd..34feeb3b5bf3e 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/AdminCreateProductConfigurationsPanelSection.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
new file mode 100644
index 0000000000000..2d68861b5d946
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
deleted file mode 100644
index 5b16f083067ee..0000000000000
--- a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
+++ /dev/null
@@ -1,172 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From 99cb4475b89d51e53413ad9418d9bcc10bfe7d09 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 17 Sep 2019 16:26:36 +0300
Subject: [PATCH 0139/1978] MC-20195: Move test MC-13104 to infrastructure
---
...product_simple_with_custom_file_option.php | 94 +++++++++++++++++++
...imple_with_custom_file_option_rollback.php | 33 +++++++
.../Checkout/_files/ValidatorFileMock.php | 32 ++++---
3 files changed, 145 insertions(+), 14 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
new file mode 100644
index 0000000000000..5c0c024ef4c39
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
@@ -0,0 +1,94 @@
+reinitialize();
+
+/** @var ObjectManager $objectManager */
+$objectManager = Bootstrap::getObjectManager();
+
+/** @var CategoryLinkManagementInterface $categoryLinkManagement */
+$categoryLinkManagement = $objectManager->create(CategoryLinkManagementInterface::class);
+
+/** @var $product Product */
+$product = $objectManager->create(Product::class);
+$product->isObjectNew(true);
+$product->setTypeId(Type::TYPE_SIMPLE)
+ ->setAttributeSetId(4)
+ ->setWebsiteIds([1])
+ ->setName('Simple Product')
+ ->setSku('simple_with_custom_file_option')
+ ->setPrice(10)
+ ->setWeight(1)
+ ->setShortDescription("Short description")
+ ->setTaxClassId(0)
+ ->setDescription('Description with html tag ')
+ ->setMetaTitle('meta title')
+ ->setMetaKeyword('meta keyword')
+ ->setMetaDescription('meta description')
+ ->setVisibility(Visibility::VISIBILITY_BOTH)
+ ->setStatus(Status::STATUS_ENABLED)
+ ->setStockData(
+ [
+ 'use_config_manage_stock' => 1,
+ 'qty' => 100,
+ 'is_qty_decimal' => 0,
+ 'is_in_stock' => 1,
+ ]
+ )
+ ->setCanSaveCustomOptions(true)
+ ->setHasOptions(true);
+
+$options = [
+ [
+ 'title' => 'file option',
+ 'type' => 'file',
+ 'is_require' => true,
+ 'sort_order' => 1,
+ 'price' => 30.0,
+ 'price_type' => 'percent',
+ 'sku' => 'sku3',
+ 'file_extension' => 'jpg, png, gif',
+ 'image_size_x' => 100,
+ 'image_size_y' => 100,
+
+ ],
+];
+
+$customOptions = [];
+
+/** @var ProductCustomOptionInterfaceFactory $customOptionFactory */
+$customOptionFactory = $objectManager->create(ProductCustomOptionInterfaceFactory::class);
+
+foreach ($options as $option) {
+ /** @var ProductCustomOptionInterface $customOption */
+ $customOption = $customOptionFactory->create(['data' => $option]);
+ $customOption->setProductSku($product->getSku());
+
+ $customOptions[] = $customOption;
+}
+
+$product->setOptions($customOptions);
+
+/** @var ProductRepositoryInterface $productRepositoryFactory */
+$productRepository = $objectManager->create(ProductRepositoryInterface::class);
+$productRepository->save($product);
+
+$categoryLinkManagement->assignProductToCategories(
+ $product->getSku(),
+ [2]
+);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php
new file mode 100644
index 0000000000000..7f53552174518
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php
@@ -0,0 +1,33 @@
+getInstance()->reinitialize();
+
+/** @var Registry $registry */
+$registry = Bootstrap::getObjectManager()->get(Registry::class);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = Bootstrap::getObjectManager()
+ ->get(ProductRepositoryInterface::class);
+try {
+ $product = $productRepository->get('simple_with_custom_file_option', false, null, true);
+ $productRepository->delete($product);
+}
+catch (NoSuchEntityException $e)
+{
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php
index 440f437e74e7c..9b5650b1826c3 100644
--- a/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php
+++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/ValidatorFileMock.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Checkout\_files;
use Magento\Catalog\Model\Product\Option\Type\File\ValidatorFile;
@@ -14,27 +16,29 @@ class ValidatorFileMock extends \PHPUnit\Framework\TestCase
{
/**
* Returns mock.
- *
+ * @param array|null $fileData
* @return ValidatorFile|\PHPUnit_Framework_MockObject_MockObject
*/
- public function getInstance()
+ public function getInstance($fileData = null)
{
- $userValue = [
- 'type' => 'image/jpeg',
- 'title' => "test.jpg",
- 'quote_path' => "custom_options/quote/s/t/4624d2.jpg",
- 'order_path' => "custom_options/order/s/t/89d25b4624d2.jpg",
- "fullpath" => "pub/media/custom_options/quote/s/t/e47389d25b4624d2.jpg",
- "size"=> "71901",
- "width" => 5,
- "height" => 5,
- "secret_key" => "10839ec1631b77e5e473",
- ];
+ if (empty($fileData)) {
+ $fileData = [
+ 'type' => 'image/jpeg',
+ 'title' => "test.jpg",
+ 'quote_path' => "custom_options/quote/s/t/4624d2.jpg",
+ 'order_path' => "custom_options/order/s/t/89d25b4624d2.jpg",
+ "fullpath" => "pub/media/custom_options/quote/s/t/e47389d25b4624d2.jpg",
+ "size" => "71901",
+ "width" => 5,
+ "height" => 5,
+ "secret_key" => "10839ec1631b77e5e473",
+ ];
+ }
$instance = $this->getMockBuilder(ValidatorFile::class)
->disableOriginalConstructor()
->getMock();
$instance->method('SetProduct')->willReturnSelf();
- $instance->method('validate')->willReturn($userValue);
+ $instance->method('validate')->willReturn($fileData);
return $instance;
}
From 9363ec3134e5358c7aa77872d4a79715040dfc58 Mon Sep 17 00:00:00 2001
From: Aliaksei Yakimovich2
Date: Tue, 17 Sep 2019 16:44:11 +0300
Subject: [PATCH 0140/1978] MC-15523: Watermark is possible to set up for
swatch image type
- Fixed merge conflict with 2.3-develop;
---
.../Theme/Test/Mftf/Section/AdminDesignConfigSection.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
index cf420598ca44e..762537ba426f2 100644
--- a/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
+++ b/app/code/Magento/Theme/Test/Mftf/Section/AdminDesignConfigSection.xml
@@ -32,5 +32,7 @@
+
+
From c61eb1036181f459a86dfa7ce6b51b4a10b803c6 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Tue, 17 Sep 2019 18:26:27 +0400
Subject: [PATCH 0141/1978] MC-18822: Increase test coverage for Content
functional area
- Automation test for MC-6192
---
.../Section/StorefrontCategorySidebarSection.xml | 1 -
...AdminCheckResultsOfColorAndOtherFiltersTest.xml | 14 +++++++-------
.../Test/Mftf/Section/LayeredNavigationSection.xml | 1 +
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
index 0058d32dda303..406bea8d8aeab 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontCategorySidebarSection.xml
@@ -8,7 +8,6 @@
-
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
index 2d68861b5d946..097251c844c40 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -168,19 +168,19 @@
-
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml
index 1e4137beacd88..b3e0c430b12e7 100644
--- a/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml
+++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Section/LayeredNavigationSection.xml
@@ -9,6 +9,7 @@
+
From 3e42c25472b9269045281631a9a84cc2f5726a3a Mon Sep 17 00:00:00 2001
From: David Lambauer
Date: Tue, 17 Sep 2019 17:39:27 +0200
Subject: [PATCH 0142/1978] Removed static types for compatibility
---
.../Magento/AdminNotification/Block/Grid/Renderer/Actions.php | 2 +-
.../Magento/AdminNotification/Block/Grid/Renderer/Notice.php | 2 +-
.../Magento/AdminNotification/Block/Grid/Renderer/Severity.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
index af8ccf65dd769..86cf528fd4971 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
@@ -45,7 +45,7 @@ public function __construct(Context $context, Data $urlHelper, array $data = [])
* @param \Magento\Framework\DataObject $row
* @return string
*/
- public function render(DataObject $row) : string
+ public function render(DataObject $row)
{
$readDetailsHtml = $row->getData('url') ? '' .
$this->escapeHtml($row->getData('title')) .
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
index bf26bc15813e1..d50781b1f6415 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
@@ -44,7 +44,7 @@ public function __construct(Context $context, Inbox $notice, array $data = [])
* @param \Magento\Framework\DataObject $row
* @return string
*/
- public function render(DataObject $row) : string
+ public function render(DataObject $row)
{
$class = '';
$value = '';
From 4350ca0e10454faac94f3c274972dcacdece9bde Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 17 Sep 2019 22:12:18 +0300
Subject: [PATCH 0143/1978] MC-20195: Move test MC-13104 to infrastructure
---
.../product_simple_with_custom_file_option_rollback.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php
index 7f53552174518..87321b2a080c0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option_rollback.php
@@ -24,9 +24,7 @@
try {
$product = $productRepository->get('simple_with_custom_file_option', false, null, true);
$productRepository->delete($product);
-}
-catch (NoSuchEntityException $e)
-{
+} catch (NoSuchEntityException $e) {
}
$registry->unregister('isSecureArea');
From b5bc8480ca7becfe4d1cb30b98866e9ff683bb5d Mon Sep 17 00:00:00 2001
From: Ihor Sviziev
Date: Wed, 18 Sep 2019 11:33:50 +0300
Subject: [PATCH 0144/1978] magento/magento2#22297 Fix elasticsearch issue over
secure connection
---
.../Model/Client/Elasticsearch.php | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php b/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php
index 34129a5af0012..e4018196c845d 100644
--- a/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php
@@ -103,21 +103,28 @@ public function testConnection()
*/
private function buildConfig($options = [])
{
- $host = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
+ $hostname = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
// @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
// @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
- if (!empty($options['port'])) {
- $host .= ':' . $options['port'];
+
+ $authString = '';
+ if (!empty($options['enableAuth']) && (int)$options['enableAuth'] === 1) {
+ $authString = "{$options['username']}:{$options['password']}@";
}
- if (!empty($options['enableAuth']) && ($options['enableAuth'] == 1)) {
- $host = sprintf('%s://%s:%s@%s', $protocol, $options['username'], $options['password'], $host);
+
+ $portString = '';
+ if (!empty($options['port'])) {
+ $portString = ':' . $options['port'];
}
+ $host = $protocol . '://' . $authString . $hostname . $portString;
+
$options['hosts'] = [$host];
+
return $options;
}
From dcdf3643a30612d879aa4d8ff4927782046e2f1e Mon Sep 17 00:00:00 2001
From: Ihor Sviziev
Date: Wed, 18 Sep 2019 11:34:31 +0300
Subject: [PATCH 0145/1978] magento/magento2#22297 Fix elasticsearch issue over
secure connection
Apply changes for ES5 client
---
.../Model/Client/Elasticsearch.php | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php
index 93f4caa10adf9..b9102bc5e00c4 100644
--- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php
@@ -108,21 +108,28 @@ public function testConnection()
*/
private function buildConfig($options = [])
{
- $host = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
+ $hostname = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
// @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
// @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
- if (!empty($options['port'])) {
- $host .= ':' . $options['port'];
+
+ $authString = '';
+ if (!empty($options['enableAuth']) && (int)$options['enableAuth'] === 1) {
+ $authString = "{$options['username']}:{$options['password']}@";
}
- if (!empty($options['enableAuth']) && ($options['enableAuth'] == 1)) {
- $host = sprintf('%s://%s:%s@%s', $protocol, $options['username'], $options['password'], $host);
+
+ $portString = '';
+ if (!empty($options['port'])) {
+ $portString = ':' . $options['port'];
}
+ $host = $protocol . '://' . $authString . $hostname . $portString;
+
$options['hosts'] = [$host];
+
return $options;
}
From 2c46bd50269d99fbf3f1837b7ff8adc10cc8105d Mon Sep 17 00:00:00 2001
From: Ihor Sviziev
Date: Wed, 18 Sep 2019 11:34:57 +0300
Subject: [PATCH 0146/1978] magento/magento2#22297 Fix elasticsearch issue over
secure connection
Apply changes for default ES client
---
.../Model/Client/Elasticsearch.php | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php b/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php
index f9b827304446d..d933d8bb5d0b5 100644
--- a/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php
@@ -103,21 +103,28 @@ public function testConnection()
*/
private function buildConfig($options = [])
{
- $host = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
+ $hostname = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
// @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
// @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
- if (!empty($options['port'])) {
- $host .= ':' . $options['port'];
+
+ $authString = '';
+ if (!empty($options['enableAuth']) && (int)$options['enableAuth'] === 1) {
+ $authString = "{$options['username']}:{$options['password']}@";
}
- if (!empty($options['enableAuth']) && ($options['enableAuth'] == 1)) {
- $host = sprintf('%s://%s:%s@%s', $protocol, $options['username'], $options['password'], $host);
+
+ $portString = '';
+ if (!empty($options['port'])) {
+ $portString = ':' . $options['port'];
}
+ $host = $protocol . '://' . $authString . $hostname . $portString;
+
$options['hosts'] = [$host];
+
return $options;
}
From 103cef8e9676c1a3e835bc8bb6d0c283df45aa3a Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Wed, 18 Sep 2019 14:50:52 +0300
Subject: [PATCH 0147/1978] MC-17149: UI components configuration incorrect
(overlapping text labels)
---
.../Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
index 3ea6a3cdfe656..7c86d1604943b 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
@@ -203,7 +203,7 @@ protected function preparePriceFields($fieldCode)
*
* @return $this
*/
- private function customizePrice()
+ private function customizePrice(): self
{
$pathFrom = $this->arrayManager->findPath('price', $this->meta, null, 'children');
From 095d7075a9f2c7267233f0f1ecbce2abb559eab1 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Wed, 18 Sep 2019 16:17:45 +0300
Subject: [PATCH 0148/1978] graphQl-903: deprecated use_for_shipping in billing
address schema
---
.../Model/Cart/AssignBillingAddressToCart.php | 6 +++---
.../Model/Cart/SetBillingAddressOnCart.php | 10 +++++-----
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 3 ++-
.../Quote/Customer/SetBillingAddressOnCartTest.php | 12 ++++++------
.../Quote/Guest/SetBillingAddressOnCartTest.php | 12 ++++++------
5 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php
index dd6478b4873c6..64a5a16cb84a2 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php
@@ -39,17 +39,17 @@ public function __construct(
*
* @param CartInterface $cart
* @param AddressInterface $billingAddress
- * @param bool $useForShipping
+ * @param bool $sameAsShipping
* @throws GraphQlInputException
* @throws GraphQlNoSuchEntityException
*/
public function execute(
CartInterface $cart,
AddressInterface $billingAddress,
- bool $useForShipping
+ bool $sameAsShipping
): void {
try {
- $this->billingAddressManagement->assign($cart->getId(), $billingAddress, $useForShipping);
+ $this->billingAddressManagement->assign($cart->getId(), $billingAddress, $sameAsShipping);
} catch (NoSuchEntityException $e) {
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
} catch (LocalizedException $e) {
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 673debefd0874..08aeb56e4cd09 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -56,8 +56,8 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
{
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
$addressInput = $billingAddressInput['address'] ?? null;
- $useForShipping = isset($billingAddressInput['use_for_shipping'])
- ? (bool)$billingAddressInput['use_for_shipping'] : false;
+ $sameAsshipping = isset($billingAddressInput['same_as_shipping'])
+ ? (bool)$billingAddressInput['same_as_shipping'] : false;
if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
@@ -72,15 +72,15 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
}
$addresses = $cart->getAllShippingAddresses();
- if ($useForShipping && count($addresses) > 1) {
+ if ($sameAsshipping && count($addresses) > 1) {
throw new GraphQlInputException(
- __('Using the "use_for_shipping" option with multishipping is not possible.')
+ __('Using the "same_as_shipping" option with multishipping is not possible.')
);
}
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput);
- $this->assignBillingAddressToCart->execute($cart, $billingAddress, $useForShipping);
+ $this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsshipping);
}
/**
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index a86eea46aa864..ae0a1bc34866a 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -96,7 +96,8 @@ input SetBillingAddressOnCartInput {
input BillingAddressInput {
customer_address_id: Int
address: CartAddressInput
- use_for_shipping: Boolean
+ use_for_shipping: Boolean @doc(description: "Deprecated. Use same_as_shipping")
+ same_as_shipping: Boolean
}
input CartAddressInput {
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 011930e723273..ec4ab012d37dc 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -120,7 +120,7 @@ public function testSetNewBillingAddress()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
- public function testSetNewBillingAddressWithUseForShippingParameter()
+ public function testSetNewBillingAddressWithSameAsShippingParameter()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
@@ -142,7 +142,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
telephone: "88776655"
save_in_address_book: false
}
- use_for_shipping: true
+ same_as_shipping: true
}
}
) {
@@ -337,7 +337,7 @@ public function testSetNewBillingAddressWithoutCustomerAddressIdAndAddress()
input: {
cart_id: "$maskedQuoteId"
billing_address: {
- use_for_shipping: true
+ same_as_shipping: true
}
}
) {
@@ -363,7 +363,7 @@ public function testSetNewBillingAddressWithoutCustomerAddressIdAndAddress()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_multishipping_with_two_shipping_addresses.php
*/
- public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
+ public function testSetNewBillingAddressWithSameAsShippingAndMultishipping()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
@@ -385,7 +385,7 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
telephone: "88776655"
save_in_address_book: false
}
- use_for_shipping: true
+ same_as_shipping: true
}
}
) {
@@ -399,7 +399,7 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
QUERY;
self::expectExceptionMessage(
- 'Using the "use_for_shipping" option with multishipping is not possible.'
+ 'Using the "same_as_shipping" option with multishipping is not possible.'
);
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
index 730e65b4ba8aa..8e500510494c2 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
@@ -90,7 +90,7 @@ public function testSetNewBillingAddress()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
- public function testSetNewBillingAddressWithUseForShippingParameter()
+ public function testSetNewBillingAddressWithSameAsShippingParameter()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
@@ -112,7 +112,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
telephone: "88776655"
save_in_address_book: false
}
- use_for_shipping: true
+ same_as_shipping: true
}
}
) {
@@ -346,7 +346,7 @@ public function testSetNewBillingAddressWithoutCustomerAddressIdAndAddress()
input: {
cart_id: "$maskedQuoteId"
billing_address: {
- use_for_shipping: true
+ same_as_shipping: true
}
}
) {
@@ -371,7 +371,7 @@ public function testSetNewBillingAddressWithoutCustomerAddressIdAndAddress()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_multishipping_with_two_shipping_addresses.php
*/
- public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
+ public function testSetNewBillingAddressWithSameAsShippingAndMultishipping()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
@@ -393,7 +393,7 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
telephone: "88776655"
save_in_address_book: false
}
- use_for_shipping: true
+ same_as_shipping: true
}
}
) {
@@ -407,7 +407,7 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
QUERY;
self::expectExceptionMessage(
- 'Using the "use_for_shipping" option with multishipping is not possible.'
+ 'Using the "same_as_shipping" option with multishipping is not possible.'
);
$this->graphQlMutation($query);
}
From 5f33b53d11a44c9b0af75c0932958e235b08ccb3 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 18 Sep 2019 16:37:07 +0300
Subject: [PATCH 0149/1978] Working on the test
---
.../AdminUpdateCmsPageRewriteEntityTest.xml | 92 +++++++++++++++++++
1 file changed, 92 insertions(+)
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
new file mode 100644
index 0000000000000..07ec8e0fd71a2
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 1334d8ad1a7e3bb07468880f7fb4a40dc3087eb7 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Wed, 18 Sep 2019 16:51:58 +0300
Subject: [PATCH 0150/1978] Update the test
---
.../AdminUpdateCmsPageRewriteEntityTest.xml | 33 +++++++++++++++++--
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
index 07ec8e0fd71a2..40a38dc689241 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
@@ -66,8 +66,6 @@
-
-
@@ -83,9 +81,38 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 5ccd367ebc628b588a77cb2032faeabd6005b039 Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Wed, 18 Sep 2019 17:07:38 +0300
Subject: [PATCH 0151/1978] MC-20193: Invoice Sales Email not send
---
.../Magento/Quote/Observer/SubmitObserver.php | 16 +++-
.../Test/Unit/Observer/SubmitObserverTest.php | 73 ++++++++++++++++++-
.../Adminhtml/Order/Invoice/Save.php | 15 +++-
.../Adminhtml/Order/Invoice/SaveTest.php | 2 +-
4 files changed, 98 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Quote/Observer/SubmitObserver.php b/app/code/Magento/Quote/Observer/SubmitObserver.php
index 1213636e5966b..2f57bf4e4ff07 100644
--- a/app/code/Magento/Quote/Observer/SubmitObserver.php
+++ b/app/code/Magento/Quote/Observer/SubmitObserver.php
@@ -5,8 +5,10 @@
*/
namespace Magento\Quote\Observer;
+use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Framework\Event\ObserverInterface;
+use Magento\Sales\Model\Order\Invoice;
class SubmitObserver implements ObserverInterface
{
@@ -20,16 +22,23 @@ class SubmitObserver implements ObserverInterface
*/
private $orderSender;
+ /**
+ * @var InvoiceSender
+ */
+ private $invoiceSender;
+
/**
* @param \Psr\Log\LoggerInterface $logger
* @param OrderSender $orderSender
*/
public function __construct(
\Psr\Log\LoggerInterface $logger,
- OrderSender $orderSender
+ OrderSender $orderSender,
+ InvoiceSender $invoiceSender
) {
$this->logger = $logger;
$this->orderSender = $orderSender;
+ $this->invoiceSender = $invoiceSender;
}
/**
@@ -51,6 +60,11 @@ public function execute(\Magento\Framework\Event\Observer $observer)
if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
try {
$this->orderSender->send($order);
+ foreach ($order->getInvoiceCollection()->getItems() as $invoice) {
+ if ($invoice->getState() === Invoice::STATE_PAID) {
+ $this->invoiceSender->send($invoice);
+ }
+ }
} catch (\Exception $e) {
$this->logger->critical($e);
}
diff --git a/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php
index c19606a7b8f5d..f0ce3132bc66b 100644
--- a/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php
@@ -5,6 +5,11 @@
*/
namespace Magento\Quote\Test\Unit\Observer;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Sales\Model\Order\Email\Sender\InvoiceSender;
+use Magento\Sales\Model\Order\Invoice;
+use Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as InvoiceCollection;
+
class SubmitObserverTest extends \PHPUnit\Framework\TestCase
{
/**
@@ -42,6 +47,21 @@ class SubmitObserverTest extends \PHPUnit\Framework\TestCase
*/
protected $paymentMock;
+ /**
+ * @var InvoiceSender|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $invoiceSenderMock;
+
+ /**
+ * @var Invoice|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $invoiceMock;
+
+ /**
+ * @var InvoiceCollection|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $invoiceCollectionMock;
+
protected function setUp()
{
$this->loggerMock = $this->createMock(\Psr\Log\LoggerInterface::class);
@@ -59,9 +79,18 @@ protected function setUp()
$eventMock->expects($this->once())->method('getQuote')->willReturn($this->quoteMock);
$eventMock->expects($this->once())->method('getOrder')->willReturn($this->orderMock);
$this->quoteMock->expects($this->once())->method('getPayment')->willReturn($this->paymentMock);
- $this->model = new \Magento\Quote\Observer\SubmitObserver(
- $this->loggerMock,
- $this->orderSenderMock
+ $this->invoiceSenderMock = $this->createMock(InvoiceSender::class);
+ $this->invoiceMock = $this->createMock(Invoice::class);
+ $this->invoiceCollectionMock = $this->createMock(InvoiceCollection::class);
+ $objectManager = new ObjectManager($this);
+
+ $this->model = $objectManager->getObject(
+ \Magento\Quote\Observer\SubmitObserver::class,
+ [
+ 'logger' => $this->loggerMock,
+ 'orderSender' => $this->orderSenderMock,
+ 'invoiceSender' => $this->invoiceSenderMock,
+ ]
);
}
@@ -70,6 +99,10 @@ public function testSendEmail()
$this->paymentMock->expects($this->once())->method('getOrderPlaceRedirectUrl')->willReturn('');
$this->orderMock->expects($this->once())->method('getCanSendNewEmailFlag')->willReturn(true);
$this->orderSenderMock->expects($this->once())->method('send')->willReturn(true);
+ $this->orderMock->expects($this->once())
+ ->method('getInvoiceCollection')
+ ->willReturn($this->invoiceCollectionMock);
+ $this->invoiceCollectionMock->expects($this->once())->method('getItems')->willReturn([]);
$this->loggerMock->expects($this->never())->method('critical');
$this->model->execute($this->observerMock);
}
@@ -93,4 +126,38 @@ public function testSendEmailWhenRedirectUrlExists()
$this->loggerMock->expects($this->never())->method('critical');
$this->model->execute($this->observerMock);
}
+
+ public function testSendEmailWithPaidInvoice()
+ {
+ $this->prepareDataForSendInvoice();
+ $this->invoiceMock->expects($this->once())->method('getState')->willReturn(Invoice::STATE_PAID);
+ $this->invoiceSenderMock->expects($this->once())
+ ->method('send')
+ ->with($this->invoiceMock)
+ ->willReturn(true);
+ $this->loggerMock->expects($this->never())->method('critical');
+
+ $this->model->execute($this->observerMock);
+ }
+
+ public function testSendEmailWithNotPaidInvoice()
+ {
+ $this->prepareDataForSendInvoice();
+ $this->invoiceMock->expects($this->once())->method('getState')->willReturn(Invoice::STATE_OPEN);
+ $this->invoiceSenderMock->expects($this->never())->method('send');
+ $this->loggerMock->expects($this->never())->method('critical');
+
+ $this->model->execute($this->observerMock);
+ }
+
+ private function prepareDataForSendInvoice()
+ {
+ $this->paymentMock->expects($this->once())->method('getOrderPlaceRedirectUrl')->willReturn('');
+ $this->orderMock->expects($this->once())->method('getCanSendNewEmailFlag')->willReturn(true);
+ $this->orderSenderMock->expects($this->once())->method('send')->willReturn(true);
+ $this->orderMock->expects($this->once())
+ ->method('getInvoiceCollection')
+ ->willReturn($this->invoiceCollectionMock);
+ $this->invoiceCollectionMock->expects($this->once())->method('getItems')->willReturn([$this->invoiceMock]);
+ }
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
index 67a0dc469163b..12f9712adb56a 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/Save.php
@@ -16,6 +16,7 @@
use Magento\Sales\Model\Order\ShipmentFactory;
use Magento\Sales\Model\Order\Invoice;
use Magento\Sales\Model\Service\InvoiceService;
+use Magento\Sales\Helper\Data as SalesData;
/**
* Save invoice controller.
@@ -56,6 +57,11 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
*/
private $invoiceService;
+ /**
+ * @var SalesData
+ */
+ private $salesData;
+
/**
* @param Action\Context $context
* @param Registry $registry
@@ -63,6 +69,7 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
* @param ShipmentSender $shipmentSender
* @param ShipmentFactory $shipmentFactory
* @param InvoiceService $invoiceService
+ * @param SalesData $salesData
*/
public function __construct(
Action\Context $context,
@@ -70,7 +77,8 @@ public function __construct(
InvoiceSender $invoiceSender,
ShipmentSender $shipmentSender,
ShipmentFactory $shipmentFactory,
- InvoiceService $invoiceService
+ InvoiceService $invoiceService,
+ SalesData $salesData = null
) {
$this->registry = $registry;
$this->invoiceSender = $invoiceSender;
@@ -78,6 +86,7 @@ public function __construct(
$this->shipmentFactory = $shipmentFactory;
$this->invoiceService = $invoiceService;
parent::__construct($context);
+ $this->salesData = $salesData ?? $this->_objectManager->get(SalesData::class);
}
/**
@@ -199,7 +208,7 @@ public function execute()
// send invoice/shipment emails
try {
- if (!empty($data['send_email'])) {
+ if (!empty($data['send_email']) || $this->salesData->canSendNewInvoiceEmail()) {
$this->invoiceSender->send($invoice);
}
} catch (\Exception $e) {
@@ -208,7 +217,7 @@ public function execute()
}
if ($shipment) {
try {
- if (!empty($data['send_email'])) {
+ if (!empty($data['send_email']) || $this->salesData->canSendNewShipmentEmail()) {
$this->shipmentSender->send($shipment);
}
} catch (\Exception $e) {
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php
index 40540f3126899..2dc5f5adc86d2 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/Invoice/SaveTest.php
@@ -28,7 +28,7 @@ class SaveTest extends AbstractInvoiceControllerTest
*/
public function testSendEmailOnInvoiceSave(): void
{
- $order = $this->prepareRequest(['invoice' => ['send_email' => true]]);
+ $order = $this->prepareRequest();
$this->dispatch('backend/sales/order_invoice/save');
$this->assertSessionMessages(
From 9b2b07568a42748e1a27e09d32db05fc867500ba Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Wed, 18 Sep 2019 17:10:06 +0300
Subject: [PATCH 0152/1978] MC-17149: UI components configuration incorrect
(overlapping text labels)
---
.../Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
index 7c86d1604943b..b8164eeb459d6 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AdvancedPricing.php
@@ -203,7 +203,7 @@ protected function preparePriceFields($fieldCode)
*
* @return $this
*/
- private function customizePrice(): self
+ private function customizePrice(): AdvancedPricing
{
$pathFrom = $this->arrayManager->findPath('price', $this->meta, null, 'children');
From 953e034762cb79c5a187426f979cceeec2617b11 Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Wed, 18 Sep 2019 18:53:02 +0300
Subject: [PATCH 0153/1978] MC-20193: Invoice Sales Email not send
---
app/code/Magento/Quote/Observer/SubmitObserver.php | 6 ++++++
.../Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/app/code/Magento/Quote/Observer/SubmitObserver.php b/app/code/Magento/Quote/Observer/SubmitObserver.php
index 2f57bf4e4ff07..9a3217cc7d6b6 100644
--- a/app/code/Magento/Quote/Observer/SubmitObserver.php
+++ b/app/code/Magento/Quote/Observer/SubmitObserver.php
@@ -10,6 +10,9 @@
use Magento\Framework\Event\ObserverInterface;
use Magento\Sales\Model\Order\Invoice;
+/**
+ * Class responsive for sending order and invoice emails when it's created through storefront.
+ */
class SubmitObserver implements ObserverInterface
{
/**
@@ -30,6 +33,7 @@ class SubmitObserver implements ObserverInterface
/**
* @param \Psr\Log\LoggerInterface $logger
* @param OrderSender $orderSender
+ * @param InvoiceSender $invoiceSender
*/
public function __construct(
\Psr\Log\LoggerInterface $logger,
@@ -42,6 +46,8 @@ public function __construct(
}
/**
+ * Send order and invoice email.
+ *
* @param \Magento\Framework\Event\Observer $observer
*
* @return void
diff --git a/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php b/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php
index f0ce3132bc66b..5c106876a2c13 100644
--- a/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Observer/SubmitObserverTest.php
@@ -10,6 +10,10 @@
use Magento\Sales\Model\Order\Invoice;
use Magento\Sales\Model\ResourceModel\Order\Invoice\Collection as InvoiceCollection;
+/**
+ * Test for \Magento\Quote\Observer\SubmitObserver class.
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
class SubmitObserverTest extends \PHPUnit\Framework\TestCase
{
/**
From f92ba2213fefcb3e75299894cd49d75a4efe32aa Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 18 Sep 2019 13:25:01 -0500
Subject: [PATCH 0154/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/ProductPriceIndexFilter.php | 83 +++++++++----------
1 file changed, 37 insertions(+), 46 deletions(-)
diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
index f9a49d4f8d121..170710ce09698 100644
--- a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
+++ b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
@@ -9,11 +9,11 @@
use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item;
+use Magento\CatalogInventory\Model\Stock;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceModifierInterface;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructure;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\DB\Query\Generator;
/**
* Class for filter product price index.
@@ -40,38 +40,22 @@ class ProductPriceIndexFilter implements PriceModifierInterface
*/
private $connectionName;
- /**
- * @var Generator
- */
- private $batchQueryGenerator;
-
- /**
- * @var int
- */
- private $batchSize;
-
/**
* @param StockConfigurationInterface $stockConfiguration
* @param Item $stockItem
* @param ResourceConnection $resourceConnection
* @param string $connectionName
- * @param Generator $batchQueryGenerator
- * @param int $batchSize
*/
public function __construct(
StockConfigurationInterface $stockConfiguration,
Item $stockItem,
ResourceConnection $resourceConnection = null,
- $connectionName = 'indexer',
- Generator $batchQueryGenerator = null,
- $batchSize = 100
+ $connectionName = 'indexer'
) {
$this->stockConfiguration = $stockConfiguration;
$this->stockItem = $stockItem;
$this->resourceConnection = $resourceConnection ?: ObjectManager::getInstance()->get(ResourceConnection::class);
$this->connectionName = $connectionName;
- $this->batchQueryGenerator = $batchQueryGenerator ?: ObjectManager::getInstance()->get(Generator::class);
- $this->batchSize = $batchSize;
}
/**
@@ -80,9 +64,7 @@ public function __construct(
* @param IndexTableStructure $priceTable
* @param array $entityIds
* @return void
- *
* @throws \Magento\Framework\Exception\LocalizedException
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = []) : void
{
@@ -91,38 +73,47 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
}
$connection = $this->resourceConnection->getConnection($this->connectionName);
- $select = $connection->select();
-
- $select->from(
- ['stock_item' => $this->stockItem->getMainTable()],
- ['stock_item.product_id', 'MAX(stock_item.is_in_stock) as max_is_in_stock']
- );
+ $stockSelect = $connection->select();
if ($this->stockConfiguration->getManageStock()) {
- $select->where('stock_item.use_config_manage_stock = 1 OR stock_item.manage_stock = 1');
+ $stockStatus = $connection->getCheckSql(
+ 'use_config_manage_stock = 0 AND manage_stock = 0',
+ Stock::STOCK_IN_STOCK,
+ 'is_in_stock'
+ );
} else {
- $select->where('stock_item.use_config_manage_stock = 0 AND stock_item.manage_stock = 1');
+ $stockStatus = $connection->getCheckSql(
+ 'use_config_manage_stock = 0 AND manage_stock = 1',
+ 'is_in_stock',
+ Stock::STOCK_IN_STOCK
+ );
}
+ $stockStatus = new \Zend_Db_Expr('MAX(' . $stockStatus . ')');
+ $stockSelect->from(
+ $this->stockItem->getMainTable(),
+ [
+ 'product_id' => 'product_id',
+ 'stock_status' => $stockStatus,
+ ]
+ );
+ if (!empty($entityIds)) {
+ $stockSelect->where('product_id IN (?)', $entityIds);
+ }
+ $stockSelect->group('product_id');
- $select->group('stock_item.product_id');
- $select->having('max_is_in_stock = 0');
-
- $batchSelectIterator = $this->batchQueryGenerator->generate(
- 'product_id',
- $select,
- $this->batchSize,
- \Magento\Framework\DB\Query\BatchIteratorInterface::UNIQUE_FIELD_ITERATOR
+ $select = $connection->select();
+ $select->from(
+ ['price_index' => $priceTable->getTableName()],
+ []
);
+ $select->joinInner(
+ ['stock_item' => $stockSelect],
+ 'stock_item.product_id = price_index.' . $priceTable->getEntityField(),
+ []
+ );
+ $select->where('stock_item.stock_status = ?', Stock::STOCK_OUT_OF_STOCK);
- foreach ($batchSelectIterator as $select) {
- $productIds = null;
- foreach ($connection->query($select)->fetchAll() as $row) {
- $productIds[] = $row['product_id'];
- }
- if ($productIds !== null) {
- $where = [$priceTable->getEntityField() .' IN (?)' => $productIds];
- $connection->delete($priceTable->getTableName(), $where);
- }
- }
+ $query = $select->deleteFromSelect('price_index');
+ $connection->query($query);
}
}
From c60896cabe8bb7610401cf05ae5504345c2a076d Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 18 Sep 2019 17:01:36 -0500
Subject: [PATCH 0155/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
app/code/Magento/CatalogRule/etc/indexer.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/CatalogRule/etc/indexer.xml b/app/code/Magento/CatalogRule/etc/indexer.xml
index e648ea567631c..340918ed63531 100644
--- a/app/code/Magento/CatalogRule/etc/indexer.xml
+++ b/app/code/Magento/CatalogRule/etc/indexer.xml
@@ -17,6 +17,7 @@
+
From db62db02e6505f2d43146437ef87dd09d59d142b Mon Sep 17 00:00:00 2001
From: "dzmitry_tabusheu@epam.com"
Date: Thu, 19 Sep 2019 07:31:23 +0300
Subject: [PATCH 0156/1978] MAGETWO-72172: [2.3] Disabled variation of
configurable product can be added to shopping cart via admin
- Disabled skipping if product is saleable check
---
.../Block/Product/View/Type/Configurable.php | 3 +-
.../Product/View/Type/ConfigurableTest.php | 37 +++++++------------
2 files changed, 15 insertions(+), 25 deletions(-)
diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
index 71db9d32aa593..55c0c8f6ca4ce 100644
--- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php
@@ -182,11 +182,10 @@ public function getAllowProducts()
{
if (!$this->hasAllowProducts()) {
$products = [];
- $skipSaleableCheck = $this->catalogProduct->getSkipSaleableCheck();
$allProducts = $this->getProduct()->getTypeInstance()->getUsedProducts($this->getProduct(), null);
/** @var $product \Magento\Catalog\Model\Product */
foreach ($allProducts as $product) {
- if ($skipSaleableCheck || ((int) $product->getStatus()) === Status::STATUS_ENABLED) {
+ if ((int) $product->getStatus() === Status::STATUS_ENABLED) {
$products[] = $product;
}
}
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php
index c5c2368720b98..36fda4ef3245c 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Block/Product/View/Type/ConfigurableTest.php
@@ -233,9 +233,7 @@ public function cacheKeyProvider(): array
public function testGetCacheKeyInfo(array $expected, string $priceCurrency = null, string $customerGroupId = null)
{
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
- ->setMethods([
- 'getCurrentCurrency',
- ])
+ ->setMethods(['getCurrentCurrency'])
->getMockForAbstractClass();
$storeMock->expects($this->any())
->method('getCode')
@@ -270,9 +268,7 @@ public function testGetJsonConfig()
$amountMock = $this->getAmountMock($amount);
$priceMock = $this->getMockBuilder(\Magento\Framework\Pricing\Price\PriceInterface::class)
- ->setMethods([
- 'getAmount',
- ])
+ ->setMethods(['getAmount'])
->getMockForAbstractClass();
$priceMock->expects($this->any())->method('getAmount')->willReturn($amountMock);
$tierPriceMock = $this->getTierPriceMock($amountMock, $priceQty, $percentage);
@@ -287,22 +283,25 @@ public function testGetJsonConfig()
->getMock();
$priceInfoMock->expects($this->any())
->method('getPrice')
- ->willReturnMap([
- ['regular_price', $priceMock],
- ['final_price', $priceMock],
- ['tier_price', $tierPriceMock],
- ]);
+ ->willReturnMap(
+ [
+ ['regular_price', $priceMock],
+ ['final_price', $priceMock],
+ ['tier_price', $tierPriceMock],
+ ]
+ );
$productMock->expects($this->any())->method('getTypeInstance')->willReturn($productTypeMock);
$productMock->expects($this->any())->method('getPriceInfo')->willReturn($priceInfoMock);
$productMock->expects($this->any())->method('isSaleable')->willReturn(true);
$productMock->expects($this->any())->method('getId')->willReturn($productId);
+ $productMock->expects($this->any())->method('getStatus')
+ ->willReturn(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED);
$this->helper->expects($this->any())
->method('getOptions')
->with($productMock, [$productMock])
->willReturn([]);
- $this->product->expects($this->any())->method('getSkipSaleableCheck')->willReturn(true);
$attributesData = [
'attributes' => [],
@@ -421,9 +420,7 @@ private function getProductTypeMock(\PHPUnit_Framework_MockObject_MockObject $pr
->willReturn('%s');
$storeMock = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
- ->setMethods([
- 'getCurrentCurrency',
- ])
+ ->setMethods(['getCurrentCurrency'])
->getMockForAbstractClass();
$storeMock->expects($this->any())
->method('getCurrentCurrency')
@@ -475,10 +472,7 @@ protected function mockContextObject()
protected function getAmountMock($amount): \PHPUnit_Framework_MockObject_MockObject
{
$amountMock = $this->getMockBuilder(\Magento\Framework\Pricing\Amount\AmountInterface::class)
- ->setMethods([
- 'getValue',
- 'getBaseAmount',
- ])
+ ->setMethods(['getValue', 'getBaseAmount'])
->getMockForAbstractClass();
$amountMock->expects($this->any())
->method('getValue')
@@ -506,10 +500,7 @@ protected function getTierPriceMock(\PHPUnit_Framework_MockObject_MockObject $am
];
$tierPriceMock = $this->getMockBuilder(\Magento\Catalog\Pricing\Price\TierPriceInterface::class)
- ->setMethods([
- 'getTierPriceList',
- 'getSavePercent',
- ])
+ ->setMethods(['getTierPriceList', 'getSavePercent'])
->getMockForAbstractClass();
$tierPriceMock->expects($this->any())
->method('getTierPriceList')
From 8245222bf55c03f69828674c2817bf025f3b7325 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Thu, 19 Sep 2019 07:32:28 +0300
Subject: [PATCH 0157/1978] MAGETWO-72172: [2.3] Disabled variation of
configurable product can be added to shopping cart via admin
- Added automated test script
---
...vailableToConfigureDisabledProductTest.xml | 158 ++++++++++++++++++
1 file changed, 158 insertions(+)
create mode 100644 app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml
new file mode 100644
index 0000000000000..ed521cef2a411
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml
@@ -0,0 +1,158 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From eb0706bec1dd3b948787cb41ed13ffb5a2b1eb00 Mon Sep 17 00:00:00 2001
From: "dzmitry_tabusheu@epam.com"
Date: Thu, 19 Sep 2019 07:34:54 +0300
Subject: [PATCH 0158/1978] MAGETWO-72172: [2.3] Disabled variation of
configurable product can be added to shopping cart via admin
- Fixed autotest
---
.../Test/Mftf/Section/AdminOrderFormConfigureProductSection.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormConfigureProductSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormConfigureProductSection.xml
index 8c093891ac46d..4f065ec7eb748 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormConfigureProductSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormConfigureProductSection.xml
@@ -9,6 +9,7 @@
+
From f556ab303836db16edc2c45ab1aa22ea32f5c736 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Thu, 19 Sep 2019 09:07:10 +0300
Subject: [PATCH 0159/1978] Convert UpdateCmsPageRewriteEntityTest to MFTF
---
.../AdminUpdateCmsPageRewriteEntityTest.xml | 46 +++++++++++++++----
1 file changed, 37 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
index 40a38dc689241..f772c62489a98 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
@@ -11,7 +11,7 @@
-
+
@@ -66,12 +66,11 @@
+
-
+
-
-
@@ -81,10 +80,11 @@
-
+
+
@@ -92,15 +92,15 @@
+
-
-
-
+
+
@@ -110,9 +110,37 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From fb9709dfd3dbe98663282f375e6593f179dc7bcd Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Thu, 19 Sep 2019 09:10:37 +0300
Subject: [PATCH 0160/1978] Update UpdateCmsPageRewriteEntityTest.xml file
---
.../Cms/Test/TestCase/UpdateCmsPageRewriteEntityTest.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageRewriteEntityTest.xml b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageRewriteEntityTest.xml
index 6ff68599beeb3..1125ce8d916c1 100644
--- a/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageRewriteEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Cms/Test/TestCase/UpdateCmsPageRewriteEntityTest.xml
@@ -8,7 +8,7 @@
- severity:S2
+ severity:S2,mftf_migrated:yes
cms_default_no_redirect
Main Website/Main Website Store/%default%
request_path%isolation%
@@ -18,7 +18,7 @@
- severity:S2
+ severity:S2,mftf_migrated:yes
cms_default_temporary_redirect
Main Website/Main Website Store/Default Store View
request_path%isolation%.html
@@ -28,7 +28,7 @@
- severity:S2
+ severity:S2,mftf_migrated:yes
cms_default_permanent_redirect
Main Website/Main Website Store/Default Store View
request_path%isolation%.htm
From 950b8a3ce350d8cc43b2849494d475a8c9f08bf4 Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Thu, 19 Sep 2019 10:42:09 +0300
Subject: [PATCH 0161/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
...CustomizableOptionToProductWithSKUTest.xml | 5 +--
...UpdateProductAttributesGlobalScopeTest.xml | 12 +++---
.../AdminConfigurableProductUpdateTest.xml | 41 +++++++++----------
3 files changed, 26 insertions(+), 32 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
index b1f00a2f51a95..e29a23fe4f18f 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
@@ -18,9 +18,6 @@
-
-
-
@@ -79,6 +76,6 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 87e0bf3d2e9a0..83b64990b22e7 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -18,9 +18,6 @@
-
-
-
@@ -38,7 +35,7 @@
-
+
@@ -58,10 +55,11 @@
-
+
-
+
+
@@ -77,6 +75,7 @@
+
@@ -88,6 +87,7 @@
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
index 3a6a20de3ed90..88bd48909e3d1 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
@@ -17,34 +17,33 @@
-
-
-
-
+
-
+
-
+
-
+
+
+
+
-
-
+
@@ -54,30 +53,28 @@
-
+
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
From 452800a7a3c803ba64cb5aef9308eedc74315545 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Thu, 19 Sep 2019 12:19:18 +0300
Subject: [PATCH 0162/1978] MC-20195: Move test MC-13104 to infrastructure
---
...product_simple_with_custom_file_option.php | 37 ++++++++-----------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
index 5c0c024ef4c39..77a9871764cee 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
@@ -53,34 +53,27 @@
->setCanSaveCustomOptions(true)
->setHasOptions(true);
-$options = [
- [
- 'title' => 'file option',
- 'type' => 'file',
- 'is_require' => true,
- 'sort_order' => 1,
- 'price' => 30.0,
- 'price_type' => 'percent',
- 'sku' => 'sku3',
- 'file_extension' => 'jpg, png, gif',
- 'image_size_x' => 100,
- 'image_size_y' => 100,
-
- ],
+$option = [
+ 'title' => 'file option',
+ 'type' => 'file',
+ 'is_require' => true,
+ 'sort_order' => 1,
+ 'price' => 30.0,
+ 'price_type' => 'percent',
+ 'sku' => 'sku3',
+ 'file_extension' => 'jpg, png, gif',
+ 'image_size_x' => 100,
+ 'image_size_y' => 100,
];
$customOptions = [];
/** @var ProductCustomOptionInterfaceFactory $customOptionFactory */
$customOptionFactory = $objectManager->create(ProductCustomOptionInterfaceFactory::class);
-
-foreach ($options as $option) {
- /** @var ProductCustomOptionInterface $customOption */
- $customOption = $customOptionFactory->create(['data' => $option]);
- $customOption->setProductSku($product->getSku());
-
- $customOptions[] = $customOption;
-}
+/** @var ProductCustomOptionInterface $customOption */
+$customOption = $customOptionFactory->create(['data' => $option]);
+$customOption->setProductSku($product->getSku());
+$customOptions[] = $customOption;
$product->setOptions($customOptions);
From 928e966f3d8f79a3bb5b22d60c63e6a31cda3e58 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 19 Sep 2019 21:18:56 +0530
Subject: [PATCH 0163/1978] Issue #24225 fixed: FPT / Tax Totals Sorting Not
Correct
---
.../Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml | 2 +-
.../Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml | 2 +-
.../Weee/view/adminhtml/layout/sales_order_invoice_new.xml | 2 +-
.../Weee/view/adminhtml/layout/sales_order_invoice_view.xml | 2 +-
.../Magento/Weee/view/adminhtml/layout/sales_order_view.xml | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml
index 94a77534d94e8..04522be9cb625 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml
@@ -10,7 +10,7 @@
- tax
+ grand_total
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml
index 94a77534d94e8..04522be9cb625 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml
@@ -10,7 +10,7 @@
- tax
+ grand_total
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml
index d14bba1395385..8a89806c429c9 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml
@@ -10,7 +10,7 @@
- tax
+ grand_total
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml
index d14bba1395385..8a89806c429c9 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml
@@ -10,7 +10,7 @@
- tax
+ grand_total
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml
index f31acedf94447..5be6eba2d8b12 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml
@@ -10,7 +10,7 @@
- tax
+ grand_total
From 025f6c15dd390fca1c0bab68dece4acd8eb99334 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 19 Sep 2019 13:23:42 -0500
Subject: [PATCH 0164/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Cms/etc/db_schema.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Cms/etc/db_schema.xml b/app/code/Magento/Cms/etc/db_schema.xml
index e0cf534e8354c..9ff3153098482 100644
--- a/app/code/Magento/Cms/etc/db_schema.xml
+++ b/app/code/Magento/Cms/etc/db_schema.xml
@@ -69,7 +69,7 @@
+ length="128" comment="Page Custom Layout File"/>
From ce9fdb065ec69ae203d8b5f1539607c27489e742 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Fri, 20 Sep 2019 10:50:12 +0400
Subject: [PATCH 0165/1978] MC-18822: Increase test coverage for Content
functional area
- Automation test for MC-6192
---
.../AdminProductAttributeSetActionGroup.xml | 2 +-
...CheckResultsOfColorAndOtherFiltersTest.xml | 150 ++++++++----------
...CheckResultsOfColorAndOtherFiltersTest.xml | 34 ++++
3 files changed, 99 insertions(+), 87 deletions(-)
create mode 100644 app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
index e3f13f32ad015..a7d5a3864c052 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeSetActionGroup.xml
@@ -64,7 +64,7 @@
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
index 097251c844c40..3af1ad8aa3ae8 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -58,77 +58,12 @@
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -160,27 +95,70 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
+
+
+
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
new file mode 100644
index 0000000000000..32325f948e07b
--- /dev/null
+++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 9371d8e4650dcee19b96ee20dc95e38ff38447cc Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Fri, 20 Sep 2019 15:34:37 +0300
Subject: [PATCH 0166/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
.../Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 83b64990b22e7..5c1a97721201d 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -29,8 +29,11 @@
+
+
+
From 50e60e18484088c05aab85944e8fa80655c3d953 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 20 Sep 2019 11:11:01 -0500
Subject: [PATCH 0167/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 67 +++++++++----------
.../Model/Indexer/ReindexRuleProductPrice.php | 7 +-
.../Indexer/RuleProductsSelectBuilder.php | 13 ++--
3 files changed, 39 insertions(+), 48 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index e12eabba76401..10abf356fbef2 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -275,11 +275,21 @@ protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
- $products = $this->productLoader->getProducts($ids);
- $activeRules = $this->getActiveRules();
- foreach ($products as $product) {
- $this->applyRules($activeRules, $product);
+ /** @var Rule[] $activeRules */
+ $activeRules = $this->getActiveRules()->getItems();
+ foreach ($activeRules as $rule) {
+ $rule->setProductsFilter($ids);
+ $productIds = $rule->getMatchingProductIds();
+ foreach ($productIds as $productId) {
+ $this->assignProductToRule($rule, $productId);
+ }
+ }
+
+ $this->cleanProductPriceIndex($ids);
+ foreach ($ids as $productId) {
+ $this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
+
$this->reindexRuleGroupWebsite->execute();
}
@@ -320,7 +330,7 @@ protected function doReindexFull()
[
$this->getTable('catalogrule_product'),
$this->getTable('catalogrule_product_price'),
- $this->getTable('catalogrule_group_website')
+ $this->getTable('catalogrule_group_website'),
]
);
}
@@ -365,27 +375,25 @@ protected function cleanByIds($productIds)
* Assign product to rule
*
* @param Rule $rule
- * @param Product $product
+ * @param int $productId
* @return void
*/
- private function assignProductToRule(Rule $rule, Product $product): void
+ private function assignProductToRule(Rule $rule, int $productId): void
{
- if (!$rule->validate($product)) {
- return;
- }
-
$ruleId = (int) $rule->getId();
- $productEntityId = (int) $product->getId();
$ruleProductTable = $this->getTable('catalogrule_product');
$this->connection->delete(
$ruleProductTable,
[
'rule_id = ?' => $ruleId,
- 'product_id = ?' => $productEntityId,
+ 'product_id = ?' => $productId,
]
);
- $websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
+ $websiteIds = $rule->getWebsiteIds();
+ if (!is_array($websiteIds)) {
+ $websiteIds = explode(',', $websiteIds);
+ }
$customerGroupIds = $rule->getCustomerGroupIds();
$fromTime = strtotime($rule->getFromDate());
$toTime = strtotime($rule->getToDate());
@@ -404,7 +412,7 @@ private function assignProductToRule(Rule $rule, Product $product): void
'to_time' => $toTime,
'website_id' => $websiteId,
'customer_group_id' => $customerGroupId,
- 'product_id' => $productEntityId,
+ 'product_id' => $productId,
'action_operator' => $actionOperator,
'action_amount' => $actionAmount,
'action_stop' => $actionStop,
@@ -422,6 +430,8 @@ private function assignProductToRule(Rule $rule, Product $product): void
}
}
+
+
/**
* Apply rule
*
@@ -433,30 +443,15 @@ private function assignProductToRule(Rule $rule, Product $product): void
*/
protected function applyRule(Rule $rule, $product)
{
- $this->assignProductToRule($rule, $product);
- $this->reindexRuleProductPrice->execute($this->batchCount, $product);
+ if ($rule->validate($product)) {
+ $this->assignProductToRule($rule, $product->getId());
+ }
+ $this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
$this->reindexRuleGroupWebsite->execute();
return $this;
}
- /**
- * Apply rules
- *
- * @param RuleCollection $ruleCollection
- * @param Product $product
- * @return void
- */
- private function applyRules(RuleCollection $ruleCollection, Product $product): void
- {
- foreach ($ruleCollection as $rule) {
- $this->assignProductToRule($rule, $product);
- }
-
- $this->cleanProductPriceIndex([$product->getId()]);
- $this->reindexRuleProductPrice->execute($this->batchCount, $product);
- }
-
/**
* Retrieve table name
*
@@ -507,7 +502,7 @@ protected function updateRuleProductData(Rule $rule)
*/
protected function applyAllRules(Product $product = null)
{
- $this->reindexRuleProductPrice->execute($this->batchCount, $product);
+ $this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
$this->reindexRuleGroupWebsite->execute();
return $this;
}
@@ -562,7 +557,7 @@ protected function calcRuleProductPrice($ruleData, $productData = null)
*/
protected function getRuleProductsStmt($websiteId, Product $product = null)
{
- return $this->ruleProductsSelectBuilder->build($websiteId, $product);
+ return $this->ruleProductsSelectBuilder->build((int) $websiteId, (int) $product->getId());
}
/**
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProductPrice.php b/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProductPrice.php
index 11ba87730bec1..51869f1accbb3 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProductPrice.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/ReindexRuleProductPrice.php
@@ -6,7 +6,6 @@
namespace Magento\CatalogRule\Model\Indexer;
-use Magento\Catalog\Model\Product;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Store\Model\StoreManagerInterface;
@@ -65,19 +64,19 @@ public function __construct(
* Reindex product prices.
*
* @param int $batchCount
- * @param Product|null $product
+ * @param int|null $productId
* @param bool $useAdditionalTable
* @return bool
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function execute($batchCount, Product $product = null, $useAdditionalTable = false)
+ public function execute(int $batchCount, ?int $productId = null, bool $useAdditionalTable = false)
{
/**
* Update products rules prices per each website separately
* because for each website date in website's timezone should be used
*/
foreach ($this->storeManager->getWebsites() as $website) {
- $productsStmt = $this->ruleProductsSelectBuilder->build($website->getId(), $product, $useAdditionalTable);
+ $productsStmt = $this->ruleProductsSelectBuilder->build($website->getId(), $productId, $useAdditionalTable);
$dayPrices = [];
$stopFlags = [];
$prevKey = null;
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php
index 6989a33535ad8..31fe9112ed279 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php
@@ -74,15 +74,12 @@ public function __construct(
* Build select for indexer according passed parameters.
*
* @param int $websiteId
- * @param \Magento\Catalog\Model\Product|null $product
+ * @param int|null $productId
* @param bool $useAdditionalTable
* @return \Zend_Db_Statement_Interface
*/
- public function build(
- $websiteId,
- \Magento\Catalog\Model\Product $product = null,
- $useAdditionalTable = false
- ) {
+ public function build(int $websiteId, ?int $productId = null, bool $useAdditionalTable = false)
+ {
$connection = $this->resource->getConnection();
$indexTable = $this->resource->getTableName('catalogrule_product');
if ($useAdditionalTable) {
@@ -107,8 +104,8 @@ public function build(
['rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id']
);
- if ($product && $product->getEntityId()) {
- $select->where('rp.product_id=?', $product->getEntityId());
+ if ($productId) {
+ $select->where('rp.product_id=?', $productId);
}
/**
From 13cea66ec53f20188d5dd06fe915920b8bb7803f Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 20 Sep 2019 13:16:51 -0500
Subject: [PATCH 0168/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/ProductPriceIndexFilter.php | 42 +--
.../Model/Indexer/IndexBuilder.php | 17 +-
.../Indexer/RuleProductsSelectBuilder.php | 8 +-
.../Unit/Model/Indexer/IndexBuilderTest.php | 289 ------------------
.../Indexer/ReindexRuleProductPriceTest.php | 6 +-
.../Indexer/RuleProductsSelectBuilderTest.php | 200 ------------
6 files changed, 31 insertions(+), 531 deletions(-)
delete mode 100644 app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php
delete mode 100644 app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php
diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
index 170710ce09698..32fb85f270b9c 100644
--- a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
+++ b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
@@ -73,8 +73,17 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
}
$connection = $this->resourceConnection->getConnection($this->connectionName);
-
$stockSelect = $connection->select();
+ $stockSelect->from(
+ $this->stockItem->getMainTable(),
+ [
+ 'product_id',
+ ]
+ );
+ if (!empty($entityIds)) {
+ $stockSelect->where('product_id IN (?)', $entityIds);
+ }
+ $stockSelect->group('product_id');
if ($this->stockConfiguration->getManageStock()) {
$stockStatus = $connection->getCheckSql(
'use_config_manage_stock = 0 AND manage_stock = 0',
@@ -89,31 +98,12 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
);
}
$stockStatus = new \Zend_Db_Expr('MAX(' . $stockStatus . ')');
- $stockSelect->from(
- $this->stockItem->getMainTable(),
- [
- 'product_id' => 'product_id',
- 'stock_status' => $stockStatus,
- ]
- );
- if (!empty($entityIds)) {
- $stockSelect->where('product_id IN (?)', $entityIds);
- }
- $stockSelect->group('product_id');
+ $stockSelect->having($stockStatus . ' = ' . Stock::STOCK_OUT_OF_STOCK);
+ $productIds = $connection->fetchCol($stockSelect);
- $select = $connection->select();
- $select->from(
- ['price_index' => $priceTable->getTableName()],
- []
- );
- $select->joinInner(
- ['stock_item' => $stockSelect],
- 'stock_item.product_id = price_index.' . $priceTable->getEntityField(),
- []
- );
- $select->where('stock_item.stock_status = ?', Stock::STOCK_OUT_OF_STOCK);
-
- $query = $select->deleteFromSelect('price_index');
- $connection->query($query);
+ if (!empty($productIds)) {
+ $where = [$priceTable->getEntityField() .' IN (?)' => $productIds];
+ $connection->delete($priceTable->getTableName(), $where);
+ }
}
}
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 10abf356fbef2..6391171be0a35 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -280,8 +280,9 @@ protected function doReindexByIds($ids)
foreach ($activeRules as $rule) {
$rule->setProductsFilter($ids);
$productIds = $rule->getMatchingProductIds();
- foreach ($productIds as $productId) {
- $this->assignProductToRule($rule, $productId);
+ foreach ($productIds as $productId => $result) {
+ $websiteIds = array_keys(array_filter($result));
+ $this->assignProductToRule($rule, $productId, $websiteIds);
}
}
@@ -376,9 +377,10 @@ protected function cleanByIds($productIds)
*
* @param Rule $rule
* @param int $productId
+ * @param array $websiteIds
* @return void
*/
- private function assignProductToRule(Rule $rule, int $productId): void
+ private function assignProductToRule(Rule $rule, int $productId, array $websiteIds): void
{
$ruleId = (int) $rule->getId();
$ruleProductTable = $this->getTable('catalogrule_product');
@@ -390,10 +392,6 @@ private function assignProductToRule(Rule $rule, int $productId): void
]
);
- $websiteIds = $rule->getWebsiteIds();
- if (!is_array($websiteIds)) {
- $websiteIds = explode(',', $websiteIds);
- }
$customerGroupIds = $rule->getCustomerGroupIds();
$fromTime = strtotime($rule->getFromDate());
$toTime = strtotime($rule->getToDate());
@@ -430,8 +428,6 @@ private function assignProductToRule(Rule $rule, int $productId): void
}
}
-
-
/**
* Apply rule
*
@@ -444,7 +440,8 @@ private function assignProductToRule(Rule $rule, int $productId): void
protected function applyRule(Rule $rule, $product)
{
if ($rule->validate($product)) {
- $this->assignProductToRule($rule, $product->getId());
+ $websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
+ $this->assignProductToRule($rule, $product->getId(), $websiteIds);
}
$this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
$this->reindexRuleGroupWebsite->execute();
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php
index 31fe9112ed279..e15bf6b3b1faa 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/RuleProductsSelectBuilder.php
@@ -156,9 +156,11 @@ public function build(int $websiteId, ?int $productId = null, bool $useAdditiona
sprintf($joinCondition, $tableAlias, $storeId),
[]
);
- $select->columns([
- 'default_price' => $connection->getIfNullSql($tableAlias . '.value', 'pp_default.value'),
- ]);
+ $select->columns(
+ [
+ 'default_price' => $connection->getIfNullSql($tableAlias . '.value', 'pp_default.value'),
+ ]
+ );
return $connection->query($select);
}
diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php
deleted file mode 100644
index 78668366bccdc..0000000000000
--- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/IndexBuilderTest.php
+++ /dev/null
@@ -1,289 +0,0 @@
-resource = $this->createPartialMock(
- \Magento\Framework\App\ResourceConnection::class,
- ['getConnection', 'getTableName']
- );
- $this->ruleCollectionFactory = $this->createPartialMock(
- \Magento\CatalogRule\Model\ResourceModel\Rule\CollectionFactory::class,
- ['create']
- );
- $this->backend = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Backend\AbstractBackend::class);
- $this->select = $this->createMock(\Magento\Framework\DB\Select::class);
- $this->metadataPool = $this->createMock(\Magento\Framework\EntityManager\MetadataPool::class);
- $metadata = $this->createMock(\Magento\Framework\EntityManager\EntityMetadata::class);
- $this->metadataPool->expects($this->any())->method('getMetadata')->willReturn($metadata);
- $this->connection = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
- $this->db = $this->createMock(\Zend_Db_Statement_Interface::class);
- $this->website = $this->createMock(\Magento\Store\Model\Website::class);
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->combine = $this->createMock(\Magento\Rule\Model\Condition\Combine::class);
- $this->rules = $this->createMock(\Magento\CatalogRule\Model\Rule::class);
- $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class);
- $this->attribute = $this->createMock(\Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class);
- $this->priceCurrency = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
- $this->dateFormat = $this->createMock(\Magento\Framework\Stdlib\DateTime::class);
- $this->dateTime = $this->createMock(\Magento\Framework\Stdlib\DateTime\DateTime::class);
- $this->eavConfig = $this->createPartialMock(\Magento\Eav\Model\Config::class, ['getAttribute']);
- $this->product = $this->createMock(\Magento\Catalog\Model\Product::class);
- $this->productFactory = $this->createPartialMock(\Magento\Catalog\Model\ProductFactory::class, ['create']);
- $this->connection->expects($this->any())->method('select')->will($this->returnValue($this->select));
- $this->connection->expects($this->any())->method('query')->will($this->returnValue($this->db));
- $this->select->expects($this->any())->method('distinct')->will($this->returnSelf());
- $this->select->expects($this->any())->method('where')->will($this->returnSelf());
- $this->select->expects($this->any())->method('from')->will($this->returnSelf());
- $this->select->expects($this->any())->method('order')->will($this->returnSelf());
- $this->resource->expects($this->any())->method('getConnection')->will($this->returnValue($this->connection));
- $this->resource->expects($this->any())->method('getTableName')->will($this->returnArgument(0));
- $this->storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue([$this->website]));
- $this->storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($this->website));
- $this->rules->expects($this->any())->method('getId')->will($this->returnValue(1));
- $this->rules->expects($this->any())->method('getWebsiteIds')->will($this->returnValue([1]));
- $this->rules->expects($this->any())->method('getCustomerGroupIds')->will($this->returnValue([1]));
-
- $ruleCollection = $this->createMock(\Magento\CatalogRule\Model\ResourceModel\Rule\Collection::class);
- $this->ruleCollectionFactory->expects($this->once())
- ->method('create')
- ->willReturn($ruleCollection);
- $ruleCollection->expects($this->once())
- ->method('addFieldToFilter')
- ->willReturnSelf();
- $ruleIterator = new \ArrayIterator([$this->rules]);
- $ruleCollection->method('getIterator')
- ->willReturn($ruleIterator);
-
- $this->product->expects($this->any())->method('load')->will($this->returnSelf());
- $this->product->expects($this->any())->method('getId')->will($this->returnValue(1));
- $this->product->expects($this->any())->method('getWebsiteIds')->will($this->returnValue([1]));
-
- $this->rules->expects($this->any())->method('validate')->with($this->product)->willReturn(true);
- $this->attribute->expects($this->any())->method('getBackend')->will($this->returnValue($this->backend));
- $this->productFactory->expects($this->any())->method('create')->will($this->returnValue($this->product));
- $this->productLoader = $this->getMockBuilder(ProductLoader::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->indexBuilder = (new ObjectManager($this))->getObject(
- \Magento\CatalogRule\Model\Indexer\IndexBuilder::class,
- [
- 'ruleCollectionFactory' => $this->ruleCollectionFactory,
- 'priceCurrency' => $this->priceCurrency,
- 'resource' => $this->resource,
- 'storeManager' => $this->storeManager,
- 'logger' => $this->logger,
- 'eavConfig' => $this->eavConfig,
- 'dateFormat' => $this->dateFormat,
- 'dateTime' => $this->dateTime,
- 'productFactory' => $this->productFactory,
- 'productLoader' => $this->productLoader,
- ]
- );
-
- $this->reindexRuleProductPrice = $this->createMock(
- \Magento\CatalogRule\Model\Indexer\ReindexRuleProductPrice::class
- );
- $this->reindexRuleGroupWebsite = $this->createMock(
- \Magento\CatalogRule\Model\Indexer\ReindexRuleGroupWebsite::class
- );
- $this->setProperties(
- $this->indexBuilder,
- [
- 'metadataPool' => $this->metadataPool,
- 'reindexRuleProductPrice' => $this->reindexRuleProductPrice,
- 'reindexRuleGroupWebsite' => $this->reindexRuleGroupWebsite,
- ]
- );
- }
-
- /**
- * Test UpdateCatalogRuleGroupWebsiteData
- *
- * @covers \Magento\CatalogRule\Model\Indexer\IndexBuilder::updateCatalogRuleGroupWebsiteData
- * @return void
- */
- public function testUpdateCatalogRuleGroupWebsiteData()
- {
- $priceAttrMock = $this->createPartialMock(\Magento\Catalog\Model\Entity\Attribute::class, ['getBackend']);
- $backendModelMock = $this->createPartialMock(
- \Magento\Catalog\Model\Product\Attribute\Backend\Tierprice::class,
- ['getResource']
- );
- $resourceMock = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Product\Attribute\Backend\Tierprice::class,
- ['getMainTable']
- );
- $resourceMock->expects($this->any())
- ->method('getMainTable')
- ->will($this->returnValue('catalog_product_entity_tier_price'));
- $backendModelMock->expects($this->any())
- ->method('getResource')
- ->will($this->returnValue($resourceMock));
- $priceAttrMock->expects($this->any())
- ->method('getBackend')
- ->will($this->returnValue($backendModelMock));
-
- $iterator = [$this->product];
- $this->productLoader->expects($this->once())
- ->method('getProducts')
- ->willReturn($iterator);
-
- $this->reindexRuleProductPrice->expects($this->once())->method('execute')->willReturn(true);
- $this->reindexRuleGroupWebsite->expects($this->once())->method('execute')->willReturn(true);
-
- $this->indexBuilder->reindexByIds([1]);
- }
-
- /**
- * @param $object
- * @param array $properties
- */
- private function setProperties($object, $properties = [])
- {
- $reflectionClass = new \ReflectionClass(get_class($object));
- foreach ($properties as $key => $value) {
- if ($reflectionClass->hasProperty($key)) {
- $reflectionProperty = $reflectionClass->getProperty($key);
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($object, $value);
- }
- }
- }
-}
diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php
index 5f63283df6760..d0f266d574945 100644
--- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php
+++ b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/ReindexRuleProductPriceTest.php
@@ -71,6 +71,7 @@ public function testExecute()
$websiteId = 234;
$defaultGroupId = 11;
$defaultStoreId = 22;
+ $productId = 55;
$websiteMock = $this->createMock(WebsiteInterface::class);
$websiteMock->expects($this->once())
@@ -93,11 +94,10 @@ public function testExecute()
->with($defaultGroupId)
->willReturn($groupMock);
- $productMock = $this->createMock(Product::class);
$statementMock = $this->createMock(\Zend_Db_Statement_Interface::class);
$this->ruleProductsSelectBuilderMock->expects($this->once())
->method('build')
- ->with($websiteId, $productMock, true)
+ ->with($websiteId, $productId, true)
->willReturn($statementMock);
$ruleData = [
@@ -126,6 +126,6 @@ public function testExecute()
$this->pricesPersistorMock->expects($this->once())
->method('execute');
- $this->assertTrue($this->model->execute(1, $productMock, true));
+ $this->assertTrue($this->model->execute(1, $productId, true));
}
}
diff --git a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php b/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php
deleted file mode 100644
index e43fe41dc2127..0000000000000
--- a/app/code/Magento/CatalogRule/Test/Unit/Model/Indexer/RuleProductsSelectBuilderTest.php
+++ /dev/null
@@ -1,200 +0,0 @@
-storeManagerMock = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
- ->getMockForAbstractClass();
- $this->resourceMock = $this->getMockBuilder(\Magento\Framework\App\ResourceConnection::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->activeTableSwitcherMock = $this->getMockBuilder(ActiveTableSwitcher::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->eavConfigMock = $this->getMockBuilder(\Magento\Eav\Model\Config::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->metadataPoolMock = $this->getMockBuilder(\Magento\Framework\EntityManager\MetadataPool::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->tableSwapperMock = $this->getMockForAbstractClass(
- IndexerTableSwapperInterface::class
- );
-
- $this->model = new \Magento\CatalogRule\Model\Indexer\RuleProductsSelectBuilder(
- $this->resourceMock,
- $this->eavConfigMock,
- $this->storeManagerMock,
- $this->metadataPoolMock,
- $this->activeTableSwitcherMock,
- $this->tableSwapperMock
- );
- }
-
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
- public function testBuild()
- {
- $websiteId = 55;
- $ruleTable = 'catalogrule_product';
- $rplTable = 'catalogrule_product_replica';
- $prTable = 'catalog_product_entity';
- $wsTable = 'catalog_product_website';
- $productMock = $this->getMockBuilder(Product::class)->disableOriginalConstructor()->getMock();
- $productMock->expects($this->exactly(2))->method('getEntityId')->willReturn(500);
-
- $connectionMock = $this->getMockBuilder(AdapterInterface::class)->disableOriginalConstructor()->getMock();
- $this->resourceMock->expects($this->at(0))->method('getConnection')->willReturn($connectionMock);
-
- $this->tableSwapperMock->expects($this->once())
- ->method('getWorkingTableName')
- ->with($ruleTable)
- ->willReturn($rplTable);
-
- $this->resourceMock->expects($this->at(1))->method('getTableName')->with($ruleTable)->willReturn($ruleTable);
- $this->resourceMock->expects($this->at(2))->method('getTableName')->with($rplTable)->willReturn($rplTable);
- $this->resourceMock->expects($this->at(3))->method('getTableName')->with($prTable)->willReturn($prTable);
- $this->resourceMock->expects($this->at(4))->method('getTableName')->with($wsTable)->willReturn($wsTable);
-
- $selectMock = $this->getMockBuilder(Select::class)->disableOriginalConstructor()->getMock();
- $connectionMock->expects($this->once())->method('select')->willReturn($selectMock);
- $selectMock->expects($this->at(0))->method('from')->with(['rp' => $rplTable])->willReturnSelf();
- $selectMock->expects($this->at(1))
- ->method('order')
- ->with(['rp.website_id', 'rp.customer_group_id', 'rp.product_id', 'rp.sort_order', 'rp.rule_id'])
- ->willReturnSelf();
- $selectMock->expects($this->at(2))->method('where')->with('rp.product_id=?', 500)->willReturnSelf();
-
- $attributeMock = $this->getMockBuilder(AbstractAttribute::class)->disableOriginalConstructor()->getMock();
- $this->eavConfigMock->expects($this->once())
- ->method('getAttribute')
- ->with(Product::ENTITY, 'price')
- ->willReturn($attributeMock);
- $backendMock = $this->getMockBuilder(AbstractBackend::class)->disableOriginalConstructor()->getMock();
- $backendMock->expects($this->once())->method('getTable')->willReturn('price_table');
- $attributeMock->expects($this->once())->method('getBackend')->willReturn($backendMock);
- $attributeMock->expects($this->once())->method('getId')->willReturn(200);
-
- $metadataMock = $this->getMockBuilder(EntityMetadataInterface::class)->disableOriginalConstructor()->getMock();
- $this->metadataPoolMock->expects($this->once())
- ->method('getMetadata')
- ->with(\Magento\Catalog\Api\Data\ProductInterface::class)
- ->willReturn($metadataMock);
- $metadataMock->expects($this->once())->method('getLinkField')->willReturn('link_field');
-
- $selectMock->expects($this->at(3))
- ->method('join')
- ->with(['e' => $prTable], 'e.entity_id = rp.product_id', [])
- ->willReturnSelf();
- $selectMock->expects($this->at(4))
- ->method('join')
- ->with(
- ['pp_default' => 'price_table'],
- 'pp_default.link_field=e.link_field AND (pp_default.attribute_id=200) and pp_default.store_id=0',
- []
- )->willReturnSelf();
- $websiteMock = $this->getMockBuilder(WebsiteInterface::class)
- ->setMethods(['getDefaultGroup'])
- ->getMockForAbstractClass();
- $this->storeManagerMock->expects($this->once())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($websiteMock);
-
- $groupMock = $this->getMockBuilder(\Magento\Store\Model\Group::class)
- ->setMethods(['getDefaultStoreId'])
- ->disableOriginalConstructor()
- ->getMock();
- $websiteMock->expects($this->once())->method('getDefaultGroup')->willReturn($groupMock);
- $groupMock->expects($this->once())->method('getDefaultStoreId')->willReturn(700);
-
- $selectMock->expects($this->at(5))
- ->method('joinInner')
- ->with(
- ['product_website' => $wsTable],
- 'product_website.product_id=rp.product_id '
- . 'AND product_website.website_id = rp.website_id '
- . 'AND product_website.website_id='
- . $websiteId,
- []
- )->willReturnSelf();
- $selectMock->expects($this->at(6))
- ->method('joinLeft')
- ->with(
- ['pp' . $websiteId => 'price_table'],
- 'pp55.link_field=e.link_field AND (pp55.attribute_id=200) and pp55.store_id=700',
- []
- )->willReturnSelf();
-
- $connectionMock->expects($this->once())
- ->method('getIfNullSql')
- ->with('pp55.value', 'pp_default.value')
- ->willReturn('IF NULL SQL');
- $selectMock->expects($this->at(7))
- ->method('columns')
- ->with(['default_price' => 'IF NULL SQL'])
- ->willReturnSelf();
- $statementMock = $this->getMockBuilder(\Zend_Db_Statement_Interface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $connectionMock->expects($this->once())->method('query')->with($selectMock)->willReturn($statementMock);
-
- $this->assertEquals($statementMock, $this->model->build($websiteId, $productMock, true));
- }
-}
From 94829efa4f48cc16f4261e43a28d3be9911869de Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 20 Sep 2019 14:04:30 -0500
Subject: [PATCH 0169/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Catalog/Model/Category.php | 2 +-
.../Catalog/Model/Category/Authorization.php | 56 ++++++++++-------
.../Catalog/Model/Product/Authorization.php | 20 +++++-
.../Magento/Cms/Model/Page/Authorization.php | 55 +++++++++++++---
.../Controller/Adminhtml/CategoryTest.php | 63 +++++++++++++++++++
.../Controller/Adminhtml/ProductTest.php | 55 +++++++++++++++-
.../Controller/Adminhtml/PageDesignTest.php | 41 +++++++++++-
7 files changed, 254 insertions(+), 38 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 421922b4eb69c..b97f092c2f2b0 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -483,7 +483,7 @@ public function getProductCollection()
* Retrieve all customer attributes
*
* @param bool $noDesignAttributes
- * @return array
+ * @return \Magento\Eav\Api\Data\AttributeInterface[]
* @todo Use with Flat Resource
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
diff --git a/app/code/Magento/Catalog/Model/Category/Authorization.php b/app/code/Magento/Catalog/Model/Category/Authorization.php
index a40db89e35906..d2d37226e7006 100644
--- a/app/code/Magento/Catalog/Model/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Category/Authorization.php
@@ -41,6 +41,37 @@ public function __construct(AuthorizationInterface $authorization, CategoryFacto
$this->categoryFactory = $factory;
}
+ /**
+ * Determine whether a category has design properties changed.
+ *
+ * @param CategoryModel $category
+ * @param CategoryModel|null $oldCategory
+ * @return bool
+ */
+ private function hasChanges(CategoryModel $category, ?CategoryModel $oldCategory): bool
+ {
+ foreach ($category->getDesignAttributes() as $designAttribute) {
+ $oldValues = [null];
+ if ($oldCategory) {
+ //New value must match saved value exactly
+ $oldValues = [$oldCategory->getData($designAttribute->getAttributeCode())];
+ } else {
+ //New value can be either empty or default value.
+ $oldValues[] = $designAttribute->getDefaultValue();
+ }
+ $newValue = $category->getData($designAttribute->getAttributeCode());
+ if (empty($newValue)) {
+ $newValue = null;
+ }
+
+ if (!in_array($newValue, $oldValues, true)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
/**
* Authorize saving of a category.
*
@@ -52,36 +83,17 @@ public function __construct(AuthorizationInterface $authorization, CategoryFacto
public function authorizeSavingOf(CategoryInterface $category): void
{
if (!$this->authorization->isAllowed('Magento_Catalog::edit_category_design')) {
- $notAllowed = false;
- $designAttributeCodes = array_map(
- function (AttributeInterface $attribute) {
- return $attribute->getAttributeCode();
- },
- $category->getDesignAttributes()
- );
- if (!$category->getId()) {
- foreach ($designAttributeCodes as $attribute) {
- if ($category->getData($attribute)) {
- $notAllowed = true;
- break;
- }
- }
- } else {
+ $savedCategory = null;
+ if ($category->getId()) {
/** @var CategoryModel $savedCategory */
$savedCategory = $this->categoryFactory->create();
$savedCategory->load($category->getId());
if (!$savedCategory->getName()) {
throw NoSuchEntityException::singleField('id', $category->getId());
}
- foreach ($designAttributeCodes as $attribute) {
- if ($category->getData($attribute) != $savedCategory->getData($attribute)) {
- $notAllowed = true;
- break;
- }
- }
}
- if ($notAllowed) {
+ if ($this->hasChanges($category, $savedCategory)) {
throw new AuthorizationException(__('Not allowed to edit the category\'s design attributes'));
}
}
diff --git a/app/code/Magento/Catalog/Model/Product/Authorization.php b/app/code/Magento/Catalog/Model/Product/Authorization.php
index 9a5e8fc396dd5..8147ecf38c84a 100644
--- a/app/code/Magento/Catalog/Model/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Product/Authorization.php
@@ -58,9 +58,25 @@ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProd
'custom_design_to',
'custom_layout_update_file'
];
+ $attributes = null;
+ if (!$oldProduct) {
+ //For default values.
+ $attributes = $product->getAttributes();
+ }
foreach ($designAttributes as $designAttribute) {
- $oldValue = $oldProduct ? $oldProduct->getData($designAttribute) : null;
- if ($product->getData($designAttribute) != $oldValue) {
+ $oldValues = [null];
+ if ($oldProduct) {
+ //New value may only be the saved value
+ $oldValues = [$oldProduct->getData($designAttribute)];
+ } elseif (array_key_exists($designAttribute, $attributes)) {
+ //New value can be empty or default
+ $oldValues[] = $attributes[$designAttribute]->getDefaultValue();
+ }
+ $newValue = $product->getData($designAttribute);
+ if (empty($newValue)) {
+ $newValue = null;
+ }
+ if (!in_array($newValue, $oldValues, true)) {
return true;
}
}
diff --git a/app/code/Magento/Cms/Model/Page/Authorization.php b/app/code/Magento/Cms/Model/Page/Authorization.php
index 0ab63bb4901bc..9075141ce15b5 100644
--- a/app/code/Magento/Cms/Model/Page/Authorization.php
+++ b/app/code/Magento/Cms/Model/Page/Authorization.php
@@ -12,7 +12,9 @@
use Magento\Cms\Api\PageRepositoryInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
-use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Store\Model\ScopeInterface;
+use \Magento\Store\Model\StoreManagerInterface;
/**
* Authorization for saving a page.
@@ -29,16 +31,32 @@ class Authorization
*/
private $authorization;
+ /**
+ * @var ScopeConfigInterface
+ */
+ private $scopeConfig;
+
+ /**
+ * @var StoreManagerInterface
+ */
+ private $storeManager;
+
/**
* @param PageRepositoryInterface $pageRepository
* @param AuthorizationInterface $authorization
+ * @param ScopeConfigInterface $scopeConfig
+ * @param StoreManagerInterface $storeManager
*/
public function __construct(
PageRepositoryInterface $pageRepository,
- AuthorizationInterface $authorization
+ AuthorizationInterface $authorization,
+ ScopeConfigInterface $scopeConfig,
+ StoreManagerInterface $storeManager
) {
$this->pageRepository = $pageRepository;
$this->authorization = $authorization;
+ $this->scopeConfig = $scopeConfig;
+ $this->storeManager = $storeManager;
}
/**
@@ -47,24 +65,41 @@ public function __construct(
* @param PageInterface $page
* @param PageInterface|null $oldPage
* @return bool
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
private function hasPageChanged(PageInterface $page, ?PageInterface $oldPage): bool
{
+ if (!$oldPage) {
+ $oldPageLayout = $this->scopeConfig->getValue(
+ 'web/default_layouts/default_cms_layout',
+ ScopeInterface::SCOPE_STORE,
+ $this->storeManager->getStore()
+ );
+ if ($page->getPageLayout() && $page->getPageLayout() !== $oldPageLayout) {
+ //If page layout is set and it's not a default value - design attributes are changed.
+ return true;
+ }
+ //Otherwise page layout is empty and is OK to save.
+ $oldPageLayout = $page->getPageLayout();
+ } else {
+ //Compare page layout to saved value.
+ $oldPageLayout = $oldPage->getPageLayout();
+ }
+ //Compare new values to saved values or require them to be empty
$oldUpdateXml = $oldPage ? $oldPage->getLayoutUpdateXml() : null;
- $oldPageLayout = $oldPage ? $oldPage->getPageLayout() : null;
$oldCustomTheme = $oldPage ? $oldPage->getCustomTheme() : null;
$oldLayoutUpdate = $oldPage ? $oldPage->getCustomLayoutUpdateXml() : null;
$oldThemeFrom = $oldPage ? $oldPage->getCustomThemeFrom() : null;
$oldThemeTo = $oldPage ? $oldPage->getCustomThemeTo() : null;
- if ($page->getLayoutUpdateXml() !== $oldUpdateXml
- || $page->getPageLayout() !== $oldPageLayout
- || $page->getCustomTheme() !== $oldCustomTheme
- || $page->getCustomLayoutUpdateXml() !== $oldLayoutUpdate
- || $page->getCustomThemeFrom() !== $oldThemeFrom
- || $page->getCustomThemeTo() !== $oldThemeTo
+ if ($page->getLayoutUpdateXml() != $oldUpdateXml
+ || $page->getPageLayout() != $oldPageLayout
+ || $page->getCustomTheme() != $oldCustomTheme
+ || $page->getCustomLayoutUpdateXml() != $oldLayoutUpdate
+ || $page->getCustomThemeFrom() != $oldThemeFrom
+ || $page->getCustomThemeTo() != $oldThemeTo
) {
return true;
}
@@ -78,7 +113,7 @@ private function hasPageChanged(PageInterface $page, ?PageInterface $oldPage): b
* @param PageInterface $page
* @return void
* @throws AuthorizationException
- * @throws LocalizedException When it is impossible to perform authorization for given page.
+ * @throws \Magento\Framework\Exception\LocalizedException When it is impossible to perform authorization.
*/
public function authorizeFor(PageInterface $page): void
{
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
index 1faff4bc03ffa..b1cbc1f544109 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
@@ -8,6 +8,7 @@
use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
+use Magento\Framework\Registry;
use Magento\TestFramework\Catalog\Model\CategoryLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Store\Model\Store;
@@ -647,6 +648,68 @@ public function testSaveDesign(): void
);
}
+ /**
+ * Save design attributes with default values without design permissions.
+ *
+ * @magentoDbIsolation enabled
+ * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
+ * @return void
+ * @throws \Throwable
+ */
+ public function testSaveDesignWithDefaults(): void
+ {
+ /** @var $store \Magento\Store\Model\Store */
+ $store = Bootstrap::getObjectManager()->create(Store::class);
+ $store->load('fixturestore', 'code');
+ $storeId = $store->getId();
+ /** @var CategoryModel $category */
+ $category = $this->categoryFactory->create();
+ $category->load(2);
+ $attributes = $category->getAttributes();
+ $attributes['custom_design']->setDefaultValue('1');
+ $attributes['custom_design']->save();
+ $requestData = [
+ 'name' => 'Test name',
+ 'parent_id' => '2',
+ 'is_active' => '0',
+ 'description' => 'Custom Description',
+ 'meta_title' => 'Custom Title',
+ 'meta_keywords' => 'Custom keywords',
+ 'meta_description' => 'Custom meta description',
+ 'include_in_menu' => '0',
+ 'url_key' => 'default-test-category-test',
+ 'display_mode' => 'PRODUCTS',
+ 'landing_page' => '1',
+ 'is_anchor' => true,
+ 'store_id' => $storeId,
+ 'use_config' => [
+ 'available_sort_by' => 1,
+ 'default_sort_by' => 1,
+ 'filter_price_range' => 1,
+ ],
+ 'custom_design' => '1',
+ 'custom_apply_to_products' => '0'
+ ];
+ $uri = 'backend/catalog/category/save';
+
+ //Updating the category's design settings without proper permissions.
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_category_design');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('store', $requestData['store_id']);
+ $this->dispatch($uri);
+
+ //Verifying that category was saved.
+ /** @var Registry $registry */
+ $registry = Bootstrap::getObjectManager()->get(Registry::class);
+ $id = $registry->registry('current_category')->getId();
+ /** @var CategoryModel $category */
+ $category = $this->categoryFactory->create();
+ $category->load($id);
+ $this->assertNotEmpty($category->getId());
+ $this->assertEquals('1', $category->getData('custom_design'));
+ }
+
/**
* Test custom update files functionality.
*
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index c5537c89b78d0..d6f82ccaea648 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Catalog\Controller\Adminhtml;
-use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Message\Manager;
@@ -13,9 +12,9 @@
use Magento\Catalog\Model\ProductRepository;
use Magento\Catalog\Model\ProductRepositoryFactory;
use Magento\Framework\Message\MessageInterface;
-use Magento\Store\Model\Store;
use Magento\TestFramework\Catalog\Model\ProductLayoutUpdateManager;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
/**
* @magentoAppArea adminhtml
@@ -32,6 +31,11 @@ class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendControl
*/
private $repositoryFactory;
+ /**
+ * @var ProductResource
+ */
+ private $resourceModel;
+
/**
* @inheritDoc
*/
@@ -41,6 +45,7 @@ protected function setUp()
$this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
$this->repositoryFactory = Bootstrap::getObjectManager()->get(ProductRepositoryFactory::class);
+ $this->resourceModel = Bootstrap::getObjectManager()->get(ProductResource::class);
}
/**
@@ -446,6 +451,52 @@ public function testSaveDesign(): void
);
}
+ /**
+ * Save design without the permissions but with default values.
+ *
+ * @magentoDbIsolation enabled
+ * @throws \Throwable
+ * @return void
+ */
+ public function testSaveDesignWithDefaults(): void
+ {
+ $optionsContainerDefault = $this->resourceModel->getAttribute('options_container')->getDefaultValue();
+ $requestData = [
+ 'product' => [
+ 'type' => 'simple',
+ 'sku' => 'simple',
+ 'store' => '0',
+ 'set' => '4',
+ 'back' => 'edit',
+ 'product' => [],
+ 'is_downloadable' => '0',
+ 'affect_configurable_product_attributes' => '1',
+ 'new_variation_attribute_set_id' => '4',
+ 'use_default' => [
+ 'gift_message_available' => '0',
+ 'gift_wrapping_available' => '0'
+ ],
+ 'configurable_matrix_serialized' => '[]',
+ 'associated_product_ids_serialized' => '[]',
+ 'options_container' => $optionsContainerDefault
+ ]
+ ];
+ $uri = 'backend/catalog/product/save';
+
+ //Updating product's design settings without proper permissions.
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_product_design');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->dispatch($uri);
+
+ //Validating saved entity.
+ /** @var ProductRepository $repo */
+ $repo = $this->repositoryFactory->create();
+ $product = $repo->get('simple');
+ $this->assertNotNull($product->getData('options_container'));
+ $this->assertEquals($optionsContainerDefault, $product->getData('options_container'));
+ }
+
/**
* Test custom update files functionality.
*
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
index 1d47ebc8aeca6..a13dc4e1f200b 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
@@ -13,6 +13,7 @@
use Magento\Cms\Model\Page;
use Magento\Cms\Model\PageFactory;
use Magento\Framework\Acl\Builder;
+use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Helper\Bootstrap;
@@ -50,6 +51,11 @@ class PageDesignTest extends AbstractBackendController
*/
private $pageRetriever;
+ /**
+ * @var ScopeConfigInterface
+ */
+ private $scopeConfig;
+
/**
* @inheritDoc
*/
@@ -59,6 +65,7 @@ protected function setUp()
$this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
$this->pageRetriever = Bootstrap::getObjectManager()->get(GetPageByIdentifierInterface::class);
+ $this->scopeConfig = Bootstrap::getObjectManager()->get(ScopeConfigInterface::class);
}
/**
@@ -76,7 +83,8 @@ public function testSaveDesign(): void
$requestData = [
PageInterface::IDENTIFIER => $id,
PageInterface::TITLE => 'Page title',
- PageInterface::CUSTOM_THEME => '1'
+ PageInterface::CUSTOM_THEME => '1',
+ PageInterface::PAGE_LAYOUT => 'empty'
];
//Creating a new page with design properties without the required permissions.
@@ -119,6 +127,37 @@ public function testSaveDesign(): void
);
}
+ /**
+ * Check that default design values are accepted without the permissions.
+ *
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testSaveDesignWithDefaults(): void
+ {
+ //Test page data.
+ $id = 'test-page';
+ $defaultLayout = $this->scopeConfig->getValue('web/default_layouts/default_cms_layout');
+ $requestData = [
+ PageInterface::IDENTIFIER => $id,
+ PageInterface::TITLE => 'Page title',
+ PageInterface::PAGE_LAYOUT => $defaultLayout
+ ];
+ //Creating a new page with design properties without the required permissions but with default values.
+ $this->aclBuilder->getAcl()->deny(null, 'Magento_Cms::save_design');
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($requestData);
+ $this->dispatch($this->uri);
+
+ //Validating saved page
+ /** @var Page $page */
+ $page = Bootstrap::getObjectManager()->create(PageInterface::class);
+ $page->load($id, PageInterface::IDENTIFIER);
+ $this->assertNotEmpty($page->getId());
+ $this->assertNotNull($page->getPageLayout());
+ $this->assertEquals($defaultLayout, $page->getPageLayout());
+ }
+
/**
* Test that custom layout update fields are dealt with properly.
*
From e3328a5ece7679ffea92b4fb4a6b7d2fe16edd5c Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 20 Sep 2019 17:00:45 -0500
Subject: [PATCH 0170/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Catalog/Model/Category/Authorization.php | 3 +++
app/code/Magento/Catalog/Model/Product/Authorization.php | 3 +++
2 files changed, 6 insertions(+)
diff --git a/app/code/Magento/Catalog/Model/Category/Authorization.php b/app/code/Magento/Catalog/Model/Category/Authorization.php
index d2d37226e7006..5529b067df3a9 100644
--- a/app/code/Magento/Catalog/Model/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Category/Authorization.php
@@ -55,6 +55,9 @@ private function hasChanges(CategoryModel $category, ?CategoryModel $oldCategory
if ($oldCategory) {
//New value must match saved value exactly
$oldValues = [$oldCategory->getData($designAttribute->getAttributeCode())];
+ if (empty($oldValues[0])) {
+ $oldValues[0] = null;
+ }
} else {
//New value can be either empty or default value.
$oldValues[] = $designAttribute->getDefaultValue();
diff --git a/app/code/Magento/Catalog/Model/Product/Authorization.php b/app/code/Magento/Catalog/Model/Product/Authorization.php
index 8147ecf38c84a..2500330e14968 100644
--- a/app/code/Magento/Catalog/Model/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Product/Authorization.php
@@ -68,6 +68,9 @@ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProd
if ($oldProduct) {
//New value may only be the saved value
$oldValues = [$oldProduct->getData($designAttribute)];
+ if (empty($oldValues[0])) {
+ $oldValues[0] = null;
+ }
} elseif (array_key_exists($designAttribute, $attributes)) {
//New value can be empty or default
$oldValues[] = $attributes[$designAttribute]->getDefaultValue();
From 2fe3c1dd15b905c4b0c594ec47753277a3ba5133 Mon Sep 17 00:00:00 2001
From: Patrick McLain
Date: Wed, 18 Sep 2019 10:58:11 -0400
Subject: [PATCH 0171/1978] Add Merge Cart Mutation
* Merge two guest carts
* Merge customer cart with guest cart
* Merge customer cart with inactive customer cart
Fixes magento/graphql-ce#905
---
.../QuoteGraphQl/Model/Cart/GetCart.php | 95 ++++++
.../Model/Cart/GetCartForUser.php | 46 +--
.../QuoteGraphQl/Model/Cart/MergeCarts.php | 91 ++++++
.../Model/Resolver/MergeCarts.php | 65 +++++
.../Magento/QuoteGraphQl/etc/schema.graphqls | 6 +
.../GraphQl/Quote/Customer/MergeCartsTest.php | 271 ++++++++++++++++++
.../GraphQl/Quote/Guest/MergeCartsTest.php | 138 +++++++++
7 files changed, 672 insertions(+), 40 deletions(-)
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/GetCart.php
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/MergeCarts.php
create mode 100644 app/code/Magento/QuoteGraphQl/Model/Resolver/MergeCarts.php
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/GetCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/GetCart.php
new file mode 100644
index 0000000000000..4f414ac1de3d9
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/GetCart.php
@@ -0,0 +1,95 @@
+maskedQuoteIdToQuoteId = $maskedQuoteIdToQuoteId;
+ $this->cartRepository = $cartRepository;
+ }
+
+ /**
+ * Get cart for merge
+ *
+ * @param string $cartHash
+ * @param int|null $customerId
+ * @param int $storeId
+ * @return Quote
+ * @throws GraphQlNoSuchEntityException
+ * @throws NoSuchEntityException
+ */
+ public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
+ {
+ try {
+ $cartId = $this->maskedQuoteIdToQuoteId->execute($cartHash);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(
+ __('Could not find a cart with ID "%masked_cart_id"', ['masked_cart_id' => $cartHash])
+ );
+ }
+
+ try {
+ /** @var Quote $cart */
+ $cart = $this->cartRepository->get($cartId);
+ } catch (NoSuchEntityException $e) {
+ throw new GraphQlNoSuchEntityException(
+ __('Could not find a cart with ID "%masked_cart_id"', ['masked_cart_id' => $cartHash])
+ );
+ }
+
+ if ((int)$cart->getStoreId() !== $storeId) {
+ throw new GraphQlNoSuchEntityException(
+ __(
+ 'Wrong store code specified for cart "%masked_cart_id"',
+ ['masked_cart_id' => $cartHash]
+ )
+ );
+ }
+
+ $cartCustomerId = (int)$cart->getCustomerId();
+
+ /* Guest cart, allow operations */
+ if (0 === $cartCustomerId) {
+ return $cart;
+ }
+
+ if ($cartCustomerId !== $customerId) {
+ throw new GraphQlNoSuchEntityException(
+ __('The current user cannot perform operations on cart "%masked_cart_id"', ['masked_cart_id' => $cartHash])
+ );
+ }
+ return $cart;
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php b/app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php
index af70809a1053d..67e1a0df608b1 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/GetCartForUser.php
@@ -10,8 +10,6 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
-use Magento\Quote\Api\CartRepositoryInterface;
-use Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface;
use Magento\Quote\Model\Quote;
/**
@@ -20,25 +18,17 @@
class GetCartForUser
{
/**
- * @var MaskedQuoteIdToQuoteIdInterface
+ * @var GetCart
*/
- private $maskedQuoteIdToQuoteId;
+ private $getCart;
/**
- * @var CartRepositoryInterface
- */
- private $cartRepository;
-
- /**
- * @param MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId
- * @param CartRepositoryInterface $cartRepository
+ * @param GetCart $getCart
*/
public function __construct(
- MaskedQuoteIdToQuoteIdInterface $maskedQuoteIdToQuoteId,
- CartRepositoryInterface $cartRepository
+ GetCart $getCart
) {
- $this->maskedQuoteIdToQuoteId = $maskedQuoteIdToQuoteId;
- $this->cartRepository = $cartRepository;
+ $this->getCart = $getCart;
}
/**
@@ -54,22 +44,7 @@ public function __construct(
*/
public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
{
- try {
- $cartId = $this->maskedQuoteIdToQuoteId->execute($cartHash);
- } catch (NoSuchEntityException $exception) {
- throw new GraphQlNoSuchEntityException(
- __('Could not find a cart with ID "%masked_cart_id"', ['masked_cart_id' => $cartHash])
- );
- }
-
- try {
- /** @var Quote $cart */
- $cart = $this->cartRepository->get($cartId);
- } catch (NoSuchEntityException $e) {
- throw new GraphQlNoSuchEntityException(
- __('Could not find a cart with ID "%masked_cart_id"', ['masked_cart_id' => $cartHash])
- );
- }
+ $cart = $this->getCart->execute($cartHash, $customerId, $storeId);
if (false === (bool)$cart->getIsActive()) {
throw new GraphQlNoSuchEntityException(
@@ -77,15 +52,6 @@ public function execute(string $cartHash, ?int $customerId, int $storeId): Quote
);
}
- if ((int)$cart->getStoreId() !== $storeId) {
- throw new GraphQlNoSuchEntityException(
- __(
- 'Wrong store code specified for cart "%masked_cart_id"',
- ['masked_cart_id' => $cartHash]
- )
- );
- }
-
$cartCustomerId = (int)$cart->getCustomerId();
/* Guest cart, allow operations */
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/MergeCarts.php b/app/code/Magento/QuoteGraphQl/Model/Cart/MergeCarts.php
new file mode 100644
index 0000000000000..f844a23613984
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/MergeCarts.php
@@ -0,0 +1,91 @@
+quoteMaskFactory = $quoteMaskFactory;
+ $this->quoteMaskResource = $quoteMaskResource;
+ $this->cartRepository = $cartRepository;
+ }
+
+ /**
+ * Merge two quotes
+ *
+ * @param Quote $firstCart
+ * @param Quote $secondQuote
+ * @return string
+ */
+ public function execute(Quote $firstCart, Quote $secondQuote): string
+ {
+ $firstCart->merge($secondQuote);
+ $firstCart->setIsActive(true);
+
+ $this->updateMaskedId($secondQuote);
+ $maskedQuoteId = $this->updateMaskedId($firstCart);
+
+ $this->cartRepository->save($firstCart);
+
+ $secondQuote->setIsActive(false);
+ $this->cartRepository->save($secondQuote);
+
+ return $maskedQuoteId;
+ }
+
+ /**
+ * Update quote masked id
+ *
+ * @param Quote $quote
+ * @return string
+ */
+ private function updateMaskedId(Quote $quote): string
+ {
+ /** @var QuoteIdMask $quoteIdMask */
+ $quoteIdMask = $this->quoteMaskFactory->create();
+ $this->quoteMaskResource->load($quoteIdMask, $quote->getId(), 'quote_id');
+ $quoteIdMask->unsetData('masked_id');
+ $this->quoteMaskResource->save($quoteIdMask);
+ $maskedId = $quoteIdMask->getMaskedId();
+
+ return $maskedId;
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/MergeCarts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/MergeCarts.php
new file mode 100644
index 0000000000000..6e440d8c2be97
--- /dev/null
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/MergeCarts.php
@@ -0,0 +1,65 @@
+getCart = $getCart;
+ $this->mergeCarts = $mergeCarts;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
+ {
+ if (empty($args['input']['first_cart_id'])) {
+ throw new GraphQlInputException(__('Required parameter "first_cart_id" is missing'));
+ }
+ if (empty($args['input']['second_cart_id'])) {
+ throw new GraphQlInputException(__('Required parameter "second_cart_id" is missing'));
+ }
+
+ $currentUserId = $context->getUserId();
+ $storeId = $storeId = (int) $context->getExtensionAttributes()->getStore()->getId();
+ $firstCart = $this->getCart->execute($args['input']['first_cart_id'], $currentUserId, $storeId);
+ $secondCart = $this->getCart->execute($args['input']['second_cart_id'], $currentUserId, $storeId);
+
+ $maskedQuoteId = $this->mergeCarts->execute($firstCart, $secondCart);
+
+ return $maskedQuoteId;
+ }
+}
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index a86eea46aa864..753cabc587a11 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -20,6 +20,7 @@ type Mutation {
setGuestEmailOnCart(input: SetGuestEmailOnCartInput): SetGuestEmailOnCartOutput @resolver(class: "Magento\\QuoteGraphQl\\Model\\Resolver\\SetGuestEmailOnCart")
setPaymentMethodAndPlaceOrder(input: SetPaymentMethodAndPlaceOrderInput): PlaceOrderOutput @deprecated(reason: "Should use setPaymentMethodOnCart and placeOrder mutations in single request.") @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\SetPaymentAndPlaceOrder")
placeOrder(input: PlaceOrderInput): PlaceOrderOutput @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\PlaceOrder")
+ mergeCarts(input: MergeCartsInput): String @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MergeCarts")
}
input createEmptyCartInput {
@@ -146,6 +147,11 @@ input SetGuestEmailOnCartInput {
email: String!
}
+input MergeCartsInput {
+ first_cart_id: String!
+ second_cart_id: String!
+}
+
type CartPrices {
grand_total: Money
subtotal_including_tax: Money
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
new file mode 100644
index 0000000000000..f6428243905b6
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
@@ -0,0 +1,271 @@
+quoteResource = $objectManager->get(QuoteResource::class);
+ $this->quoteFactory = $objectManager->get(QuoteFactory::class);
+ $this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
+ $this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
+ }
+
+ protected function tearDown()
+ {
+ $quote = $this->quoteFactory->create();
+ $this->quoteResource->load($quote, '1', 'customer_id');
+ $this->quoteResource->delete($quote);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testMergeGuestWithCustomerCart()
+ {
+ $firstQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
+
+ $secondQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($secondQuote, 'test_order_with_virtual_product_without_address', 'reserved_order_id');
+
+ $firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
+ $secondMaskedId = $this->quoteIdToMaskedId->execute((int)$secondQuote->getId());
+
+ $query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
+ $mergeResponse = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
+
+ self::assertArrayHasKey('mergeCarts', $mergeResponse);
+ $maskedQuoteId = $mergeResponse['mergeCarts'];
+ self::assertNotEquals($firstMaskedId, $maskedQuoteId);
+ self::assertNotEquals($secondMaskedId, $maskedQuoteId);
+
+ $cartResponse = $this->graphQlMutation($this->getCartQuery($maskedQuoteId), [], '', $this->getHeaderMap());
+
+ self::assertArrayHasKey('cart', $cartResponse);
+ self::assertArrayHasKey('items', $cartResponse['cart']);
+ self::assertCount(2, $cartResponse['cart']['items']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/make_cart_inactive.php
+ */
+ public function testMergeTwoCustomerCarts()
+ {
+ $firstQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
+ $firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
+
+ $createCartResponse = $this->graphQlMutation($this->getCreateEmptyCartMutation(), [], '', $this->getHeaderMap());
+ self::assertArrayHasKey('createEmptyCart', $createCartResponse);
+ $secondMaskedId = $createCartResponse['createEmptyCart'];
+ $this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap());
+
+ $query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
+ $mergeResponse = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
+
+ self::assertArrayHasKey('mergeCarts', $mergeResponse);
+ $maskedQuoteId = $mergeResponse['mergeCarts'];
+ self::assertNotEquals($firstMaskedId, $maskedQuoteId);
+ self::assertNotEquals($secondMaskedId, $maskedQuoteId);
+
+ $cartResponse = $this->graphQlMutation($this->getCartQuery($maskedQuoteId), [], '', $this->getHeaderMap());
+
+ self::assertArrayHasKey('cart', $cartResponse);
+ self::assertArrayHasKey('items', $cartResponse['cart']);
+ self::assertCount(1, $cartResponse['cart']['items']);
+
+ $item = $cartResponse['cart']['items'][0];
+ self::assertArrayHasKey('quantity', $item);
+ self::assertArrayHasKey('product', $item);
+ self::assertArrayHasKey('sku', $item['product']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/two_customers.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ * @expectedException \Exception
+ * @expectedExceptionMessage The current user cannot perform operations on cart
+ */
+ public function testMergeOtherCustomerCart()
+ {
+ $firstQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
+
+ $firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
+ $createCartResponse = $this->graphQlMutation($this->getCreateEmptyCartMutation(), [], '', $this->getHeaderMap('customer_two@example.com'));
+ self::assertArrayHasKey('createEmptyCart', $createCartResponse);
+ $secondMaskedId = $createCartResponse['createEmptyCart'];
+ $this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap('customer_two@example.com'));
+
+ $query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
+ $this->graphQlMutation($query, [], '', $this->getHeaderMap());
+ }
+
+ /**
+ * Add simple product to cart
+ *
+ * @param string $maskedId
+ * @param array $headerMap
+ */
+ private function addSimpleProductToCart(string $maskedId, array $headerMap): void
+ {
+ $result = $this->graphQlMutation($this->getAddProductToCartMutation($maskedId), [], '', $headerMap);
+ self::assertArrayHasKey('addSimpleProductsToCart', $result);
+ self::assertArrayHasKey('cart', $result['addSimpleProductsToCart']);
+ self::assertArrayHasKey('items', $result['addSimpleProductsToCart']['cart']);
+ self::assertArrayHasKey(0, $result['addSimpleProductsToCart']['cart']['items']);
+ self::assertArrayHasKey('quantity', $result['addSimpleProductsToCart']['cart']['items'][0]);
+ self::assertEquals(1, $result['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
+ self::assertArrayHasKey('product', $result['addSimpleProductsToCart']['cart']['items'][0]);
+ self::assertArrayHasKey('sku', $result['addSimpleProductsToCart']['cart']['items'][0]['product']);
+ self::assertEquals('simple_product', $result['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
+ }
+
+ /**
+ * Create the mergeCart mutation
+ *
+ * @param string $firstMaskedId
+ * @param string $secondMaskedId
+ * @return string
+ */
+ private function getCartMergeMutation(string $firstMaskedId, string $secondMaskedId): string
+ {
+ return <<customerTokenService->createCustomerAccessToken($username, $password);
+ $headerMap = ['Authorization' => 'Bearer ' . $customerToken];
+ return $headerMap;
+ }
+}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php
new file mode 100644
index 0000000000000..349e8058ee2c7
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php
@@ -0,0 +1,138 @@
+quoteResource = $objectManager->get(QuoteResource::class);
+ $this->quoteFactory = $objectManager->get(QuoteFactory::class);
+ $this->quoteIdToMaskedId = $objectManager->get(QuoteIdToMaskedQuoteIdInterface::class);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
+ */
+ public function testMergeGuestCarts()
+ {
+ $firstQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($firstQuote, 'test_order_with_simple_product_without_address', 'reserved_order_id');
+
+ $secondQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($secondQuote, 'test_order_with_virtual_product_without_address', 'reserved_order_id');
+
+ $firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
+ $secondMaskedId = $this->quoteIdToMaskedId->execute((int)$secondQuote->getId());
+
+ $query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
+ $mergeResponse = $this->graphQlMutation($query);
+
+ self::assertArrayHasKey('mergeCarts', $mergeResponse);
+ $maskedQuoteId = $mergeResponse['mergeCarts'];
+ self::assertNotEquals($firstMaskedId, $maskedQuoteId);
+ self::assertNotEquals($secondMaskedId, $maskedQuoteId);
+
+ $cartResponse = $this->graphQlMutation($this->getCartQuery($maskedQuoteId));
+
+ self::assertArrayHasKey('cart', $cartResponse);
+ self::assertArrayHasKey('items', $cartResponse['cart']);
+ self::assertCount(2, $cartResponse['cart']['items']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ * @expectedException \Exception
+ * @expectedExceptionMessage The current user cannot perform operations on cart
+ */
+ public function testMergeGuestWithCustomerCart()
+ {
+ $firstQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($firstQuote, 'test_order_with_virtual_product_without_address', 'reserved_order_id');
+
+ $secondQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($secondQuote, 'test_quote', 'reserved_order_id');
+
+ $firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
+ $secondMaskedId = $this->quoteIdToMaskedId->execute((int)$secondQuote->getId());
+
+ $query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
+ $this->graphQlMutation($query);
+ }
+
+ /**
+ * Create the mergeCart mutation
+ *
+ * @param string $firstMaskedId
+ * @param string $secondMaskedId
+ * @return string
+ */
+ private function getCartMergeMutation(string $firstMaskedId, string $secondMaskedId): string
+ {
+ return <<
Date: Sat, 21 Sep 2019 08:03:02 -0400
Subject: [PATCH 0172/1978] fix static tests
---
.../GraphQl/Quote/Customer/MergeCartsTest.php | 20 ++++++++++++++++---
.../GraphQl/Quote/Guest/MergeCartsTest.php | 6 +++++-
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
index f6428243905b6..525c3731aa7e2 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
@@ -68,7 +68,11 @@ public function testMergeGuestWithCustomerCart()
$this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
$secondQuote = $this->quoteFactory->create();
- $this->quoteResource->load($secondQuote, 'test_order_with_virtual_product_without_address', 'reserved_order_id');
+ $this->quoteResource->load(
+ $secondQuote,
+ 'test_order_with_virtual_product_without_address',
+ 'reserved_order_id'
+ );
$firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
$secondMaskedId = $this->quoteIdToMaskedId->execute((int)$secondQuote->getId());
@@ -101,7 +105,12 @@ public function testMergeTwoCustomerCarts()
$this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
$firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
- $createCartResponse = $this->graphQlMutation($this->getCreateEmptyCartMutation(), [], '', $this->getHeaderMap());
+ $createCartResponse = $this->graphQlMutation(
+ $this->getCreateEmptyCartMutation(),
+ [],
+ '',
+ $this->getHeaderMap()
+ );
self::assertArrayHasKey('createEmptyCart', $createCartResponse);
$secondMaskedId = $createCartResponse['createEmptyCart'];
$this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap());
@@ -140,7 +149,12 @@ public function testMergeOtherCustomerCart()
$this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
$firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
- $createCartResponse = $this->graphQlMutation($this->getCreateEmptyCartMutation(), [], '', $this->getHeaderMap('customer_two@example.com'));
+ $createCartResponse = $this->graphQlMutation(
+ $this->getCreateEmptyCartMutation(),
+ [],
+ '',
+ $this->getHeaderMap('customer_two@example.com')
+ );
self::assertArrayHasKey('createEmptyCart', $createCartResponse);
$secondMaskedId = $createCartResponse['createEmptyCart'];
$this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap('customer_two@example.com'));
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php
index 349e8058ee2c7..3be368c06a917 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/MergeCartsTest.php
@@ -51,7 +51,11 @@ public function testMergeGuestCarts()
$this->quoteResource->load($firstQuote, 'test_order_with_simple_product_without_address', 'reserved_order_id');
$secondQuote = $this->quoteFactory->create();
- $this->quoteResource->load($secondQuote, 'test_order_with_virtual_product_without_address', 'reserved_order_id');
+ $this->quoteResource->load(
+ $secondQuote,
+ 'test_order_with_virtual_product_without_address',
+ 'reserved_order_id'
+ );
$firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
$secondMaskedId = $this->quoteIdToMaskedId->execute((int)$secondQuote->getId());
From 1d841c378b6ae623b3ff5fd97ddf2f1f206636ca Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Mon, 23 Sep 2019 08:12:39 +0300
Subject: [PATCH 0173/1978] [Wishlist] Remove name from WishlistOutput #920
---
app/code/Magento/WishlistGraphQl/etc/module.xml | 7 ++++++-
.../Magento/WishlistGraphQl/etc/schema.graphqls | 15 +++++++++++++--
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/WishlistGraphQl/etc/module.xml b/app/code/Magento/WishlistGraphQl/etc/module.xml
index 337623cc85a92..c2f5b3165b2ab 100644
--- a/app/code/Magento/WishlistGraphQl/etc/module.xml
+++ b/app/code/Magento/WishlistGraphQl/etc/module.xml
@@ -6,5 +6,10 @@
*/
-->
-
+
+
+
+
+
+
diff --git a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
index 2aa5f03a787d0..7daf15596f19d 100644
--- a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
@@ -5,10 +5,21 @@ type Query {
wishlist: WishlistOutput @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistResolver") @doc(description: "The wishlist query returns the contents of a customer's wish list") @cache(cacheable: false)
}
-type WishlistOutput {
+type Customer {
+ wishlists: Wishlist! @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistResolver") @cache(cacheable: false)
+}
+
+type WishlistOutput @doc(description: "Deprecated: 'Wishlist' type should be used instead") {
+ items: [WishlistItem] @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "Deprecated: use field `items` from type `Wishlist`"),
+ items_count: Int @doc(description: "Deprecated: use field `items_count` from type `Wishlist`"),
+ name: String @doc(description: "Deprecated."),
+ sharing_code: String @doc(description: "Deprecated: use field `sharing_code` from type `Wishlist`"),
+ updated_at: String @doc(description: "Deprecated: use field `updated_at` from type `Wishlist`")
+}
+
+type Wishlist {
items: [WishlistItem] @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"),
items_count: Int @doc(description: "The number of items in the wish list"),
- name: String @doc(description: "When multiple wish lists are enabled, the name the customer assigns to the wishlist"),
sharing_code: String @doc(description: "An encrypted code that Magento uses to link to the wish list"),
updated_at: String @doc(description: "The time of the last modification to the wish list")
}
From 83456fcfef437b489b2bba3be0b81c2a5f2c56d6 Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Mon, 23 Sep 2019 10:24:38 +0300
Subject: [PATCH 0174/1978] refactoring
---
.../Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml | 2 +-
.../Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml | 2 +-
.../Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml
index 98fd20b3368c2..0d2e26b3cf7c3 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml
+++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreatePartialShipmentEntityTest.xml
@@ -26,7 +26,7 @@
-
+
diff --git a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml
index 6dfccc3171758..8a816c2334da5 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml
+++ b/app/code/Magento/Shipping/Test/Mftf/Test/AdminCreateShipmentEntityTest.xml
@@ -26,7 +26,7 @@
-
+
diff --git a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml
index 032651c818b91..3fa93602e5256 100644
--- a/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Shipping/Test/TestCase/CreateShipmentEntityTest.xml
@@ -8,7 +8,7 @@
- test_type:extended_acceptance_test, mftf_migrated:yes
+ test_type:extended_acceptance_test,mftf_migrated:yes
default
catalogProductSimple::default
1
From ed9fa6a3f14f72b114dc1ba0aa18f966eab9a451 Mon Sep 17 00:00:00 2001
From: Aliaksei Yakimovich2
Date: Tue, 30 Jul 2019 14:43:28 +0300
Subject: [PATCH 0175/1978] MC-18824: Increase test coverage for Import /
export functional area
- Added integration test for MC-11760;
---
.../Model/Export/ProductTest.php | 27 +++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
index 183ba86ca7572..8db0f32941bd9 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
@@ -404,6 +404,33 @@ public function testExportWithCustomOptions(): void
self::assertSame($expectedData, $customOptionData);
}
+ /**
+ * Check that no duplicate entities when multiple custom options used
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_simple_with_options.php
+ */
+ public function testExportWithMultipleOptions()
+ {
+ $expectedCount = 1;
+ $resultsFilename = 'export_results.csv';
+ $this->model->setWriter(
+ $this->objectManager->create(
+ \Magento\ImportExport\Model\Export\Adapter\Csv::class
+ )
+ );
+ $exportData = $this->model->export();
+
+ $varDirectory = $this->objectManager->get(\Magento\Framework\Filesystem::class)
+ ->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);
+ $varDirectory->writeFile($resultsFilename, $exportData);
+ /** @var \Magento\Framework\File\Csv $csv */
+ $csv = $this->objectManager->get(\Magento\Framework\File\Csv::class);
+ $data = $csv->getData($varDirectory->getAbsolutePath($resultsFilename));
+ $actualCount = count($data) - 1;
+
+ $this->assertSame($expectedCount, $actualCount);
+ }
+
/**
* @param string $exportedCustomOption
* @return array
From 409927b7c5597f44baf84c784d8a35c01a086f6a Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 14 Aug 2019 12:47:16 +0400
Subject: [PATCH 0176/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6406
---
...lityDifferentStoreViewsAfterImportTest.xml | 79 +++++++++++++++++++
.../Store/Test/Mftf/Data/StoreData.xml | 20 ++++-
.../_data/import_productsoftwostoresdata.csv | 7 ++
3 files changed, 105 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
create mode 100644 dev/tests/acceptance/tests/_data/import_productsoftwostoresdata.csv
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
new file mode 100644
index 0000000000000..400ad76caf83d
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
index 1a1847bf38308..b0c3905c66dde 100644
--- a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
+++ b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
@@ -194,4 +194,22 @@
third_store_view
third_store_view
-
\ No newline at end of file
+
+ 1
+ English
+ english
+ 1
+ null
+ store
+ add
+
+
+ 1
+ Chinese
+ chinese
+ 1
+ null
+ store
+ add
+
+
diff --git a/dev/tests/acceptance/tests/_data/import_productsoftwostoresdata.csv b/dev/tests/acceptance/tests/_data/import_productsoftwostoresdata.csv
new file mode 100644
index 0000000000000..5cb120e7e2b2b
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/import_productsoftwostoresdata.csv
@@ -0,0 +1,7 @@
+sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,msrp_price,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id
+name4,,Default,simple,,base,name4,name4,name4,0,1,None,Catalog,39,1,7/8/2015 8:00,,name4,,,,12/16/2015 6:33,7/7/2016 13:01,,,Product Info Column,,,,,,,,Use config,,,1,0,1,0,0,0,1,1,10000,1,1,1,1,1,1,1,0,1,0,0,1
+name4,english,Default,simple,,base,, ,,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+name4,chinese,Default,simple,,base,白瓷奶勺110厘米, ,白瓷奶勺110厘米,,,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+name5,,Default,simple,,base,name5,name5,name5,0,1,,Catalog,229,111.75,7/15/2015 0:00,,name5,,,,12/16/2015 6:33,7/7/2016 13:01,,,Product Info Column,,,,,,,,Use config,,,0,0,1,0,2,2,1,1,10000,1,1,1,1,1,1,1,0,1,0,0,1
+name5,chinese,Default,simple,,base,盐磨瓶18厘米,,盐磨瓶18厘米,,2,None,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
+name5,english,Default,simple,,base,,,,,2,None,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
From 17fa6d9dad005ad38d69b1a1107f9bc220a77835 Mon Sep 17 00:00:00 2001
From: RomanKis
Date: Mon, 23 Sep 2019 13:02:50 +0300
Subject: [PATCH 0177/1978] graphQl-914: [Customer] Improve consistency of
country field in customer address
---
.../Address/CreateCustomerAddress.php | 3 +
.../Address/UpdateCustomerAddress.php | 3 +
.../CustomerGraphQl/etc/schema.graphqls | 6 +-
.../Customer/CreateCustomerAddressTest.php | 99 +++++++++++++++
.../Customer/UpdateCustomerAddressTest.php | 120 ++++++++++++++++++
5 files changed, 229 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php
index 388b6dc2ea943..474bd99a8f136 100644
--- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php
+++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php
@@ -67,6 +67,9 @@ public function __construct(
*/
public function execute(int $customerId, array $data): AddressInterface
{
+ if (isset($data['country_code'])) {
+ $data['country_id'] = $data['country_code'];
+ }
$this->validateData($data);
/** @var AddressInterface $address */
diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php
index 65745a20bc8eb..26e53c7c3a0a8 100644
--- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php
+++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/UpdateCustomerAddress.php
@@ -66,6 +66,9 @@ public function __construct(
*/
public function execute(AddressInterface $address, array $data): void
{
+ if (isset($data['country_code'])) {
+ $data['country_id'] = $data['country_code'];
+ }
$this->validateData($data);
$filteredData = array_diff_key($data, array_flip($this->restrictedKeys));
diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
index d27debdc39c64..fa50ebeed09c4 100644
--- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
@@ -28,7 +28,8 @@ input CustomerAddressInput {
city: String @doc(description: "The city or town")
region: CustomerAddressRegionInput @doc(description: "An object containing the region name, region code, and region ID")
postcode: String @doc(description: "The customer's ZIP or postal code")
- country_id: CountryCodeEnum @doc(description: "The customer's country")
+ country_id: CountryCodeEnum @doc(description: "The customer's country") @deprecated(reason: "Use country_code instead.")
+ country_code: CountryCodeEnum @doc(description: "The customer's country")
default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address")
default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address")
fax: String @doc(description: "The fax number")
@@ -100,7 +101,8 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform
customer_id: Int @doc(description: "The customer ID")
region: CustomerAddressRegion @doc(description: "An object containing the region name, region code, and region ID")
region_id: Int @doc(description: "A number that uniquely identifies the state, province, or other area")
- country_id: String @doc(description: "The customer's country")
+ country_id: String @doc(description: "The customer's country") @deprecated(reason: "Use country_code instead.")
+ country_code: CountryCodeEnum @doc(description: "The customer's country")
street: [String] @doc(description: "An array of strings that define the street number and name")
company: String @doc(description: "The customer's company")
telephone: String @doc(description: "The telephone number")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
index 203e9b5cb42e5..a065ab3f26e7e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
@@ -133,6 +133,105 @@ public function testCreateCustomerAddress()
$this->assertCustomerAddressesFields($address, $newAddress);
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testCreateCustomerAddressWithCountryCode()
+ {
+ $customerId = 1;
+ $newAddress = [
+ 'region' => [
+ 'region' => 'Arizona',
+ 'region_id' => 4,
+ 'region_code' => 'AZ'
+ ],
+ 'country_code' => 'US',
+ 'street' => ['Line 1 Street', 'Line 2'],
+ 'company' => 'Company name',
+ 'telephone' => '123456789',
+ 'fax' => '123123123',
+ 'postcode' => '7777',
+ 'city' => 'City Name',
+ 'firstname' => 'Adam',
+ 'lastname' => 'Phillis',
+ 'middlename' => 'A',
+ 'prefix' => 'Mr.',
+ 'suffix' => 'Jr.',
+ 'vat_id' => '1',
+ 'default_shipping' => true,
+ 'default_billing' => false
+ ];
+
+ $mutation
+ = <<graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
+ $this->assertArrayHasKey('createCustomerAddress', $response);
+ $this->assertArrayHasKey('customer_id', $response['createCustomerAddress']);
+ $this->assertEquals($customerId, $response['createCustomerAddress']['customer_id']);
+ $this->assertArrayHasKey('id', $response['createCustomerAddress']);
+
+ $address = $this->addressRepository->getById($response['createCustomerAddress']['id']);
+ $this->assertEquals($address->getId(), $response['createCustomerAddress']['id']);
+
+ $newAddress['country_id'] = $newAddress['country_code'];
+ unset($newAddress['country_code']);
+ $this->assertCustomerAddressesFields($address, $response['createCustomerAddress']);
+ $this->assertCustomerAddressesFields($address, $newAddress);
+ }
+
/**
* @expectedException Exception
* @expectedExceptionMessage The current customer isn't authorized.
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
index 9840236dc9896..b83649061c333 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
@@ -77,6 +77,34 @@ public function testUpdateCustomerAddress()
$this->assertCustomerAddressesFields($address, $updateAddress);
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer_address.php
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testUpdateCustomerAddressWithCountryCode()
+ {
+ $userName = 'customer@example.com';
+ $password = 'password';
+ $customerId = 1;
+ $addressId = 1;
+
+ $mutation = $this->getMutationWithCountryCode($addressId);
+
+ $response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
+ $this->assertArrayHasKey('updateCustomerAddress', $response);
+ $this->assertArrayHasKey('customer_id', $response['updateCustomerAddress']);
+ $this->assertEquals($customerId, $response['updateCustomerAddress']['customer_id']);
+ $this->assertArrayHasKey('id', $response['updateCustomerAddress']);
+
+ $address = $this->addressRepository->getById($addressId);
+ $this->assertEquals($address->getId(), $response['updateCustomerAddress']['id']);
+ $this->assertCustomerAddressesFields($address, $response['updateCustomerAddress']);
+
+ $updateAddress = $this->getAddressDataCanadaCountry();
+ $this->assertCustomerAddressesFields($address, $updateAddress);
+ }
+
/**
* @expectedException Exception
* @expectedExceptionMessage The current customer isn't authorized.
@@ -405,6 +433,35 @@ private function getAddressData(): array
];
}
+ /**
+ * @return array
+ */
+ private function getAddressDataCanadaCountry(): array
+ {
+ return [
+ 'region' => [
+ 'region' => 'Alberta',
+ 'region_id' => 66,
+ 'region_code' => 'AB'
+ ],
+ 'country_id' => 'CA',
+ 'street' => ['Line 1 Street', 'Line 2'],
+ 'company' => 'Company Name',
+ 'telephone' => '123456789',
+ 'fax' => '123123123',
+ 'postcode' => '7777',
+ 'city' => 'City Name',
+ 'firstname' => 'Adam',
+ 'lastname' => 'Phillis',
+ 'middlename' => 'A',
+ 'prefix' => 'Mr.',
+ 'suffix' => 'Jr.',
+ 'vat_id' => '1',
+ 'default_shipping' => true,
+ 'default_billing' => true
+ ];
+ }
+
/**
* @param int $addressId
* @return string
@@ -464,6 +521,69 @@ private function getMutation(int $addressId): string
default_billing
}
}
+MUTATION;
+ return $mutation;
+ }
+
+ /**
+ * @param int $addressId
+ * @return string
+ */
+ private function getMutationWithCountryCode(int $addressId): string
+ {
+ $updateAddress = $this->getAddressDataCanadaCountry();
+ $defaultShippingText = $updateAddress['default_shipping'] ? "true" : "false";
+ $defaultBillingText = $updateAddress['default_billing'] ? "true" : "false";
+
+ $mutation
+ = <<
Date: Wed, 14 Aug 2019 18:38:30 +0400
Subject: [PATCH 0178/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6416
---
.../AdminImportProductsActionGroup.xml | 12 +++++++
.../Mftf/Section/AdminImportHeaderSection.xml | 1 +
...dminImportCSVWithSpecialCharactersTest.xml | 35 +++++++++++++++++++
.../acceptance/tests/_data/import91569.csv | 2 ++
4 files changed, 50 insertions(+)
create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
create mode 100644 dev/tests/acceptance/tests/_data/import91569.csv
diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
index 9063916e9f502..faa66886178dd 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
@@ -60,4 +60,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml
index 748580be09406..c39ebbe04f2e1 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml
@@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
new file mode 100644
index 0000000000000..ec0937e8426f1
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
@@ -0,0 +1,35 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/_data/import91569.csv b/dev/tests/acceptance/tests/_data/import91569.csv
new file mode 100644
index 0000000000000..5d62286ccf2ee
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/import91569.csv
@@ -0,0 +1,2 @@
+sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,deferred_stock_update,use_config_deferred_stock_update,related_skus,related_position,crosssell_skus,crosssell_position,upsell_skus,upsell_position,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,bundle_shipment_type,configurable_variations,configurable_variation_labels,associated_skus
+Mug,,Default,simple,Default Category/C1,base,Mug,this is a mug
,,,1,Taxable Goods,"Catalog, Search",30,,,,mug,Mug,Mug,Mug ,,,,,,,,,"10/1/18, 9:21 PM","10/1/18, 11:30 PM",,,Block after Info Column,,,,Use config,,,,,,,,,gift_wrapping_available=Use config,99,0,1,0,0,1,1,1,10000,1,1,1,1,1,1,1,1,1,0,0,0,1,1,,,,,,,,,,,,,,,,,,,
From a6b3f9144e0d5aca1372646dc524ef3b0e3880d7 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 15 Aug 2019 16:44:07 +0400
Subject: [PATCH 0179/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6317
---
.../Catalog/Test/Mftf/Data/ProductData.xml | 14 +++++
...UpdatingProductThroughImportingCSVTest.xml | 53 +++++++++++++++++++
.../acceptance/tests/_data/export-91544.csv | 2 +
3 files changed, 69 insertions(+)
create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
create mode 100644 dev/tests/acceptance/tests/_data/export-91544.csv
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index e122615eb8aa4..985057e8c58bc 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -64,6 +64,20 @@
EavStockItem
CustomAttributeCategoryIds
+
+ simpleProduct
+ simple
+ 4
+ simpleProduct
+ 123.00
+ 4
+ 1
+ 1000
+ simpleProduct
+ 1
+ EavStockItem
+ CustomAttributeCategoryIds
+
SimpleProductForTest1
simple
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
new file mode 100644
index 0000000000000..603bce882fbba
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/_data/export-91544.csv b/dev/tests/acceptance/tests/_data/export-91544.csv
new file mode 100644
index 0000000000000..147d6f8ade275
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/export-91544.csv
@@ -0,0 +1,2 @@
+sku,url_key
+simpleProduct,simpleProd
From f54fe7aa3b354b58bd6de35ba328c125135d9903 Mon Sep 17 00:00:00 2001
From: Lilit Sargsyan
Date: Fri, 16 Aug 2019 18:41:00 +0400
Subject: [PATCH 0180/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-11332
---
.../ActionGroup/AdminProductActionGroup.xml | 13 +++
.../Catalog/Test/Mftf/Data/ProductData.xml | 4 +
...utesChangedValueToEmptyAfterImportTest.xml | 80 +++++++++++++++++++
.../tests/_data/import_simple_product.csv | 2 +
4 files changed, 99 insertions(+)
create mode 100644 app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
create mode 100644 dev/tests/acceptance/tests/_data/import_simple_product.csv
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
index 5c5ee0f9cb321..1d3b08b831ce6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
@@ -241,6 +241,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 985057e8c58bc..fb14e0bad26f6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -1040,6 +1040,10 @@
BBB Product
+
+ Simple_Product
+ testsku
+
Product "!@#$%^&*()+:;\|}{][?=~`
|}{][?=~`
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
new file mode 100644
index 0000000000000..1d3ec59788b84
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/acceptance/tests/_data/import_simple_product.csv b/dev/tests/acceptance/tests/_data/import_simple_product.csv
new file mode 100644
index 0000000000000..1e7756008996b
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/import_simple_product.csv
@@ -0,0 +1,2 @@
+sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,deferred_stock_update,use_config_deferred_stock_update,related_skus,related_position,crosssell_skus,crosssell_position,upsell_skus,upsell_position,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,bundle_shipment_type,giftcard_type,giftcard_allow_open_amount,giftcard_open_amount_min,giftcard_open_amount_max,giftcard_amount,use_config_is_redeemable,giftcard_is_redeemable,use_config_lifetime,giftcard_lifetime,use_config_allow_message,giftcard_allow_message,use_config_email_template,giftcard_email_template,associated_skus,configurable_variations,configurable_variation_labels
+testsku,,Default,simple,Default Category/simpleCategory5d53a993b7ccb2,base,Simple_Product,,,,1,Taxable Goods,"Catalog, Search",560,,,,simple-product,Simple_Product,Simple_Product,Simple_Product ,,,,,,,,,"8/14/19, 6:27 AM","8/14/19, 6:27 AM",,,Block after Info Column,,,,Use config,,,,,,,Use config,,,25,0,1,0,0,1,1,1,10000,1,1,1,1,1,1,1,1,1,0,0,0,1,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
From bce2d9d39162f3a788c3f4db4d6537baf950f800 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 4 Sep 2019 17:42:47 +0400
Subject: [PATCH 0181/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6416
---
.../Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml | 4 ++--
.../tests/_data/{import91569.csv => importSpecChars.csv} | 0
2 files changed, 2 insertions(+), 2 deletions(-)
rename dev/tests/acceptance/tests/_data/{import91569.csv => importSpecChars.csv} (100%)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
index ec0937e8426f1..f752cb3e7c908 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
@@ -11,7 +11,7 @@
-
+
@@ -27,7 +27,7 @@
-
+
diff --git a/dev/tests/acceptance/tests/_data/import91569.csv b/dev/tests/acceptance/tests/_data/importSpecChars.csv
similarity index 100%
rename from dev/tests/acceptance/tests/_data/import91569.csv
rename to dev/tests/acceptance/tests/_data/importSpecChars.csv
From 6500f2a0f1bf0c8673a6993eab5ce57dc88816f2 Mon Sep 17 00:00:00 2001
From: Aliaksei Yakimovich2
Date: Wed, 4 Sep 2019 16:07:35 +0300
Subject: [PATCH 0182/1978] MC-18824: Increase test coverage for Import /
export functional area
- Added integration test for MC-13653;
---
.../Model/Export/ProductTest.php | 76 +++++++++++++++++++
1 file changed, 76 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
index 8db0f32941bd9..4753d947e9d3c 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php
@@ -8,6 +8,10 @@
namespace Magento\CatalogImportExport\Model\Export;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Observer\SwitchPriceAttributeScopeOnConfigChange;
+use Magento\Framework\App\Config\ReinitableConfigInterface;
+
/**
* @magentoDataFixtureBeforeTransaction Magento/Catalog/_files/enable_reindex_schedule.php
* @magentoAppIsolation enabled
@@ -32,6 +36,11 @@ class ProductTest extends \PHPUnit\Framework\TestCase
*/
protected $fileSystem;
+ /**
+ * @var ProductRepositoryInterface
+ */
+ private $productRepository;
+
/**
* Stock item attributes which must be exported
*
@@ -69,6 +78,7 @@ protected function setUp()
$this->model = $this->objectManager->create(
\Magento\CatalogImportExport\Model\Export\Product::class
);
+ $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
}
/**
@@ -459,4 +469,70 @@ function ($input) {
return $optionItems;
}
+
+ /**
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoDataFixture Magento/Store/_files/second_website_with_two_stores.php
+ * @magentoConfigFixture current_store catalog/price/scope 1
+ * @magentoDbIsolation disabled
+ * @magentoAppArea adminhtml
+ */
+ public function testExportProductWithTwoWebsites()
+ {
+ $globalStoreCode = 'admin';
+ $secondStoreCode = 'fixture_second_store';
+
+ $expectedData = [
+ $globalStoreCode => 10.0,
+ $secondStoreCode => 9.99
+ ];
+
+ /** @var \Magento\Store\Model\Store $store */
+ $store = $this->objectManager->create(\Magento\Store\Model\Store::class);
+ $reinitiableConfig = $this->objectManager->get(ReinitableConfigInterface::class);
+ $observer = $this->objectManager->get(\Magento\Framework\Event\Observer::class);
+ $switchPriceScope = $this->objectManager->get(SwitchPriceAttributeScopeOnConfigChange::class);
+ /** @var \Magento\Catalog\Model\Product\Action $productAction */
+ $productAction = $this->objectManager->create(\Magento\Catalog\Model\Product\Action::class);
+ /** @var \Magento\Framework\File\Csv $csv */
+ $csv = $this->objectManager->get(\Magento\Framework\File\Csv::class);
+ /** @var $varDirectory \Magento\Framework\Filesystem\Directory\WriteInterface */
+ $varDirectory = $this->objectManager->get(\Magento\Framework\Filesystem::class)
+ ->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);
+ $secondStore = $store->load($secondStoreCode);
+
+ $this->model->setWriter(
+ $this->objectManager->create(
+ \Magento\ImportExport\Model\Export\Adapter\Csv::class
+ )
+ );
+
+ $reinitiableConfig->setValue('catalog/price/scope', \Magento\Store\Model\Store::PRICE_SCOPE_WEBSITE);
+ $switchPriceScope->execute($observer);
+
+ $product = $this->productRepository->get('simple');
+ $productId = $product->getId();
+ $productAction->updateWebsites([$productId], [$secondStore->getWebsiteId()], 'add');
+ $product->setStoreId($secondStore->getId());
+ $product->setPrice('9.99');
+ $product->getResource()->save($product);
+
+ $exportData = $this->model->export();
+
+ $varDirectory->writeFile('test_product_with_two_websites.csv', $exportData);
+ $data = $csv->getData($varDirectory->getAbsolutePath('test_product_with_two_websites.csv'));
+
+ $columnNumber = array_search('price', $data[0]);
+ $this->assertNotFalse($columnNumber);
+
+ $pricesData = [
+ $globalStoreCode => (float)$data[1][$columnNumber],
+ $secondStoreCode => (float)$data[2][$columnNumber],
+ ];
+
+ self::assertSame($expectedData, $pricesData);
+
+ $reinitiableConfig->setValue('catalog/price/scope', \Magento\Store\Model\Store::PRICE_SCOPE_GLOBAL);
+ $switchPriceScope->execute($observer);
+ }
}
From 983ce3e249d3f248ddd9c94f5621a156dd8ff006 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 9 Sep 2019 16:26:27 +0400
Subject: [PATCH 0183/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6317
---
app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml | 2 +-
...nURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml | 4 ++--
.../tests/_data/{export-91544.csv => simpleProductUpdate.csv} | 0
3 files changed, 3 insertions(+), 3 deletions(-)
rename dev/tests/acceptance/tests/_data/{export-91544.csv => simpleProductUpdate.csv} (100%)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index fb14e0bad26f6..909a1223a048b 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -68,7 +68,7 @@
simpleProduct
simple
4
- simpleProduct
+ SimpleProduct
123.00
4
1
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
index 603bce882fbba..42af7f67ca4ee 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
@@ -35,11 +35,11 @@
-
+
-
+
diff --git a/dev/tests/acceptance/tests/_data/export-91544.csv b/dev/tests/acceptance/tests/_data/simpleProductUpdate.csv
similarity index 100%
rename from dev/tests/acceptance/tests/_data/export-91544.csv
rename to dev/tests/acceptance/tests/_data/simpleProductUpdate.csv
From 03d7471d70ad3bd2fbf481192cb2be661d76e5a1 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 9 Sep 2019 17:00:24 +0400
Subject: [PATCH 0184/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6406
---
...ibilityDifferentStoreViewsAfterImportTest.xml | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
index 400ad76caf83d..175a575acb188 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
@@ -11,7 +11,7 @@
-
+
@@ -31,13 +31,6 @@
-
-
-
-
-
-
-
@@ -58,6 +51,13 @@
+
+
+
+
+
+
+
From e7f342a66e321224f360abf89b835c11718712dc Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 9 Sep 2019 17:44:18 +0400
Subject: [PATCH 0185/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-11332
---
.../ActionGroup/AdminProductActionGroup.xml | 13 ----
...utesChangedValueToEmptyAfterImportTest.xml | 59 ++++++++++---------
2 files changed, 32 insertions(+), 40 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
index 1d3b08b831ce6..5c5ee0f9cb321 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
@@ -241,19 +241,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
index 1d3ec59788b84..20e4ed2257cd4 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
@@ -18,9 +18,9 @@
-
-
-
+
+
+
@@ -28,31 +28,9 @@
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -68,6 +46,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From ff811e6acfa1e65da0137ec63d42bf4dabac6b45 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Thu, 29 Aug 2019 16:02:16 +0300
Subject: [PATCH 0186/1978] MC-18824: Increase test coverage for Import /
export functional area
- Integration test for MC-6348
---
.../Model/Import/ProductTest.php | 34 ++++++++++++++++++-
.../_files/import_media_hidden_images.csv | 2 ++
2 files changed, 35 insertions(+), 1 deletion(-)
create mode 100644 dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_media_hidden_images.csv
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 1b33cd695d06e..6587f005aed4f 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -3,12 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
/**
* Test class for \Magento\CatalogImportExport\Model\Import\Product
*
* The "CouplingBetweenObjects" warning is caused by tremendous complexity of the original class
- *
*/
namespace Magento\CatalogImportExport\Model\Import;
@@ -20,6 +20,7 @@
use Magento\Framework\App\Bootstrap;
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\DataObject;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Filesystem;
use Magento\Framework\Registry;
@@ -846,6 +847,37 @@ public function testSaveMediaImage()
$this->assertEquals('Additional Image Label Two', $additionalImageTwoItem->getLabel());
}
+ /**
+ * Test that after product import images from "hide_from_product_page" attribute hidden properly.
+ *
+ * @magentoDataFixture mediaImportImageFixture
+ * @magentoAppIsolation enabled
+ */
+ public function testSaveHiddenImages()
+ {
+ $this->importDataForMediaTest('import_media_hidden_images.csv');
+ $product = $this->getProductBySku('simple_new');
+ $images = $product->getMediaGalleryEntries();
+
+ $hiddenImages = array_filter(
+ $images,
+ static function (DataObject $image) {
+ return $image->getDisabled() == 1;
+ }
+ );
+
+ $this->assertCount(3, $hiddenImages);
+
+ $imageItem = array_shift($hiddenImages);
+ $this->assertEquals('/m/a/magento_image.jpg', $imageItem->getFile());
+
+ $imageItem = array_shift($hiddenImages);
+ $this->assertEquals('/m/a/magento_thumbnail.jpg', $imageItem->getFile());
+
+ $imageItem = array_shift($hiddenImages);
+ $this->assertEquals('/m/a/magento_additional_image_two.jpg', $imageItem->getFile());
+ }
+
/**
* Test that new images should be added after the existing ones.
*
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_media_hidden_images.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_media_hidden_images.csv
new file mode 100644
index 0000000000000..1c1bebee57578
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_media_hidden_images.csv
@@ -0,0 +1,2 @@
+sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label1,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,crosssell_skus,upsell_skus,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values,associated_skus
+simple_new,,Default,simple,,base,New Product,,,,1,Taxable Goods,"Catalog, Search",10,,,,new-product,New Product,New Product,New Product,magento_image.jpg,Image Label,magento_small_image.jpg,Small Image Label,magento_thumbnail.jpg,Thumbnail Label,magento_image.jpg,Image Label,10/20/2015 7:05,10/20/2015 7:05,,,Block after Info Column,,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100,0,1,0,0,1,1,1,10000,1,1,1,1,1,0,1,1,0,0,0,1,,,,"magento_additional_image_one.jpg, magento_additional_image_two.jpg","Additional Image Label One,Additional Image Label Two","magento_image.jpg,magento_thumbnail.jpg,magento_additional_image_two.jpg",,,,,,,
From 230e8ae27057cbe8e4ca1f833218be45dff7a072 Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Fri, 2 Aug 2019 08:39:35 +0300
Subject: [PATCH 0187/1978] MC-18824: Increase test coverage for Import /
export functional area
- Integration test for MC-11391
---
.../Model/Import/ProductTest.php | 21 +++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 6587f005aed4f..8a40fc9a6c2c6 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -2612,4 +2612,25 @@ private function importFile(string $fileName): void
$this->_model->importData();
}
+
+ /**
+ * Checking product images after Add/Update import failure
+ *
+ * @magentoDataFixture mediaImportImageFixture
+ * @magentoDataFixture Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images.php
+ * @magentoDbIsolation enabled
+ * @magentoAppIsolation enabled
+ *
+ * @return void
+ */
+ public function testProductBaseImageAfterImport()
+ {
+ $this->importDataForMediaTest('import_media.csv');
+
+ $this->testImportWithNonExistingImage();
+
+ /** @var $productAfterImport \Magento\Catalog\Model\Product */
+ $productAfterImport = $this->getProductBySku('simple_new');
+ $this->assertNotEquals('/no/exists/image/magento_image.jpg', $productAfterImport->getData('image'));
+ }
}
From 91021d5fd3ea76769c52e8fd39bdfcabc1d5f18b Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 11 Sep 2019 17:58:40 +0400
Subject: [PATCH 0188/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-11332
---
...atSomeAttributesChangedValueToEmptyAfterImportTest.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
index 20e4ed2257cd4..50573faf9860a 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
@@ -10,17 +10,17 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
+
-
-
-
-
+
+
+
From f1ba0ce3a73f6de9c0c646c35679aae46574ecad Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Thu, 19 Sep 2019 18:18:02 +0300
Subject: [PATCH 0189/1978] MC-18824: Increase test coverage for Import /
export functional area
- Integration test for MC-6348 : CR comments fix.
---
.../Magento/CatalogImportExport/Model/Import/ProductTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 8a40fc9a6c2c6..f62c84eea4057 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -848,7 +848,7 @@ public function testSaveMediaImage()
}
/**
- * Test that after product import images from "hide_from_product_page" attribute hidden properly.
+ * Tests that "hide_from_product_page" attribute is hidden after importing product images.
*
* @magentoDataFixture mediaImportImageFixture
* @magentoAppIsolation enabled
From 78a7e6076ca03d532eed0ee8513bae834a7d7d8d Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 23 Sep 2019 14:29:23 +0400
Subject: [PATCH 0190/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
.../Catalog/Test/Mftf/Data/ProductData.xml | 3 ++
...ontElasticsearchSearchInvalidValueTest.xml | 46 ++++++++++---------
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 517ab253b8238..d8af28a23671f 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -64,6 +64,9 @@
EavStockItem
CustomAttributeCategoryIds
+
+ /s\i’m“p:l\$e#@!,.`=%&^
+
SimpleProductForTest1
simple
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
index 1e3badb5f1ce6..84bbe00d2b971 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
@@ -22,26 +22,20 @@
-
-
-
-
-
-
@@ -49,20 +43,18 @@
-
-
-
+
+
+
-
-
@@ -71,14 +63,13 @@
-
-
+
@@ -88,17 +79,28 @@
-
-
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
@@ -107,11 +109,13 @@
-
-
-
-
+
+
+
+
+
+
-
+
From 629099d9d37bee4d2bb57ed8ede524f10fb918e1 Mon Sep 17 00:00:00 2001
From: Dzmitry Tabusheu
Date: Tue, 24 Sep 2019 15:33:47 +0300
Subject: [PATCH 0191/1978] MAGETWO-72172: [2.3] Disabled variation of
configurable product can be added to shopping cart via admin
- Fixed functional test
---
.../Test/NoOptionAvailableToConfigureDisabledProductTest.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml
index ed521cef2a411..fd607d2203c66 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/NoOptionAvailableToConfigureDisabledProductTest.xml
@@ -10,6 +10,8 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
+
+
From 5fd3c14b5bac44a5dce5aaef26203a526be6f32f Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Tue, 24 Sep 2019 17:44:11 +0300
Subject: [PATCH 0192/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
...CustomizableOptionToProductWithSKUTest.xml | 21 +++++++------------
...UpdateProductAttributesGlobalScopeTest.xml | 13 +++++-------
.../AdminConfigurableProductUpdateTest.xml | 15 +++++++++----
3 files changed, 23 insertions(+), 26 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
index e29a23fe4f18f..c191822b2c7e6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
@@ -15,36 +15,32 @@
-
+
-
-
-
-
+
+
+
+
+
-
-
-
-
-
+
-
@@ -55,12 +51,10 @@
-
-
@@ -74,7 +68,6 @@
-
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 5c1a97721201d..925cc4d1590c5 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -29,15 +29,13 @@
-
-
-
+
@@ -61,14 +59,13 @@
+
-
-
-
-
-
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
index 88bd48909e3d1..4cd962e76bc96 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
@@ -34,15 +34,19 @@
-
+
+
+
+
+
@@ -58,9 +62,9 @@
-
-
-
+
+
+
@@ -70,10 +74,13 @@
+
+
+
From 5a60b4f4494e9d813d73724190164d5b099d3734 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Tue, 24 Sep 2019 16:33:04 -0500
Subject: [PATCH 0193/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 6391171be0a35..a434d337f00c2 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -279,11 +279,7 @@ protected function doReindexByIds($ids)
$activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
$rule->setProductsFilter($ids);
- $productIds = $rule->getMatchingProductIds();
- foreach ($productIds as $productId => $result) {
- $websiteIds = array_keys(array_filter($result));
- $this->assignProductToRule($rule, $productId, $websiteIds);
- }
+ $this->reindexRuleProduct->execute($rule, $this->batchCount);
}
$this->cleanProductPriceIndex($ids);
@@ -435,6 +431,8 @@ private function assignProductToRule(Rule $rule, int $productId, array $websiteI
* @param Product $product
* @return $this
* @throws \Exception
+ * @deprecated
+ * @see ReindexRuleProduct::execute
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
protected function applyRule(Rule $rule, $product)
From 3cec03358c610f9fc7f94d9b2ccaf43ca47eb879 Mon Sep 17 00:00:00 2001
From: Alex Kolesnyk
Date: Tue, 24 Sep 2019 22:56:26 -0500
Subject: [PATCH 0194/1978] MQE-1714: Community MTF to MFTF test conversion
code review
- minor fixes and added testCaseId
---
.../Test/AdminUserLockWhenEditingUserTest.xml | 9 +--
.../AdminFillUserRoleFormActionGroup.xml | 4 +-
.../AssertAdminUserIsInGridActionGroup.xml | 22 ++++++
...ertUserRoleRestrictedAccessActionGroup.xml | 14 ++++
.../Magento/User/Test/Mftf/Data/UserData.xml | 6 ++
.../User/Test/Mftf/Data/UserRoleData.xml | 22 +++---
.../Test/Mftf/Metadata/user_role-meta.xml | 7 +-
.../Mftf/Test/AdminUpdateUserRoleTest.xml | 78 ------------------
.../Test/Mftf/Test/AdminUpdateUserTest.xml | 79 +++++++++++++++++++
9 files changed, 141 insertions(+), 100 deletions(-)
create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
create mode 100644 app/code/Magento/User/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
delete mode 100644 app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
create mode 100644 app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml
diff --git a/app/code/Magento/Security/Test/Mftf/Test/AdminUserLockWhenEditingUserTest.xml b/app/code/Magento/Security/Test/Mftf/Test/AdminUserLockWhenEditingUserTest.xml
index 2ce54d6c0fda5..9f421668bdc4f 100644
--- a/app/code/Magento/Security/Test/Mftf/Test/AdminUserLockWhenEditingUserTest.xml
+++ b/app/code/Magento/Security/Test/Mftf/Test/AdminUserLockWhenEditingUserTest.xml
@@ -20,14 +20,7 @@
-
-
-
- {$adminPassword}
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminFillUserRoleFormActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminFillUserRoleFormActionGroup.xml
index 480695aa7a931..7b913382651ae 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminFillUserRoleFormActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminFillUserRoleFormActionGroup.xml
@@ -17,13 +17,13 @@
-
+
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
new file mode 100644
index 0000000000000..3499f4e0d951c
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertAdminUserIsInGridActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
new file mode 100644
index 0000000000000..0747eab31588e
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AssertUserRoleRestrictedAccessActionGroup.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserData.xml b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
index d465851c62373..6366cbe594309 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserData.xml
@@ -33,6 +33,12 @@
- 1
+
+ 123123qA
+ 123123qA
+ {{roleSales.rolename}}
+
+
admin
John
diff --git a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
index a0d89bbf3fb9d..ba53b853efe0f 100644
--- a/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
+++ b/app/code/Magento/User/Test/Mftf/Data/UserRoleData.xml
@@ -14,26 +14,30 @@
1
-
- Administrator
+
+ Administrator
All
- []
+ 1
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
+ []
-
- Role Sales
+
+ Role Sales
Custom
- ['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails','Magento_Backend::system','Magento_Backend::system_other_settings','Magento_AdminNotification::adminnotification','Magento_AdminNotification::show_list']
+ 0
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
+ ['Magento_Sales::sales','Magento_Sales::sales_operation','Magento_Sales::actions','Magento_Sales::sales_order','Magento_Sales::create','Magento_Sales::actions_view','Magento_Sales::email','Magento_Sales::reorder','Magento_Sales::actions_edit','Magento_Sales::cancel','Magento_Sales::review_payment','Magento_Sales::capture','Magento_Sales::invoice','Magento_Sales::creditmemo','Magento_Sales::hold','Magento_Sales::unhold','Magento_Sales::ship','Magento_Sales::comment','Magento_Sales::emails','Magento_Backend::system_other_settings','Magento_AdminNotification::adminnotification','Magento_AdminNotification::show_list']
- Limited
+ Limited
Custom
All
- Restricted
+ Restricted
Custom
All
@@ -41,7 +45,7 @@
restrictedWebsiteRole
- 123123q
+ {{_ENV.MAGENTO_ADMIN_PASSWORD}}
0
- 1
diff --git a/app/code/Magento/User/Test/Mftf/Metadata/user_role-meta.xml b/app/code/Magento/User/Test/Mftf/Metadata/user_role-meta.xml
index 9d0132453c798..5384bd520b2c7 100644
--- a/app/code/Magento/User/Test/Mftf/Metadata/user_role-meta.xml
+++ b/app/code/Magento/User/Test/Mftf/Metadata/user_role-meta.xml
@@ -10,9 +10,10 @@
application/x-www-form-urlencoded
- string
- string
-
+ string
+ string
+ integer
+
string
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
deleted file mode 100644
index 570bc572df7de..0000000000000
--- a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserRoleTest.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml
new file mode 100644
index 0000000000000..dfadee8ee6807
--- /dev/null
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminUpdateUserTest.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 7d03bdc3c8735446cb4f74d4219a9a54c11230b4 Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Wed, 25 Sep 2019 12:37:07 +0300
Subject: [PATCH 0195/1978] [Wishlist] Remove name from WishlistOutput #920
---
.../Resolver/CustomerWishlistsResolver.php | 67 +++++++++++
.../WishlistGraphQl/etc/schema.graphqls | 2 +-
.../Wishlist/CustomerWishlistsTest.php | 110 ++++++++++++++++++
3 files changed, 178 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
diff --git a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
new file mode 100644
index 0000000000000..a2b8280fc3d0d
--- /dev/null
+++ b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
@@ -0,0 +1,67 @@
+_wishlistCollectionFactory = $wishlistCollectionFactory;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function resolve(
+ Field $field,
+ $context,
+ ResolveInfo $info,
+ array $value = null,
+ array $args = null
+ ) {
+ $customerId = $context->getUserId();
+
+ /* Guest checking */
+ if (!$customerId && 0 === $customerId) {
+ throw new GraphQlAuthorizationException(__('The current user cannot perform operations on wishlist'));
+ }
+ $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($customerId);
+ $wishlists = $collection->getItems();
+ $wishlistsData = [];
+ if (0 === count($wishlists)) {
+ return $wishlistsData;
+ }
+
+ foreach ($wishlists as $wishlist) {
+ $wishlistsData [] = [
+ 'sharing_code' => $wishlist->getSharingCode(),
+ 'updated_at' => $wishlist->getUpdatedAt(),
+ 'items_count' => $wishlist->getItemsCount(),
+ 'model' => $wishlist,
+ ];
+ }
+ return $wishlistsData;
+ }
+}
diff --git a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
index 7daf15596f19d..b7cc60fe100c6 100644
--- a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
@@ -6,7 +6,7 @@ type Query {
}
type Customer {
- wishlists: Wishlist! @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistResolver") @cache(cacheable: false)
+ wishlists: [Wishlist]! @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlistsResolver") @doc(description: "The wishlist query returns the contents of a customer's wish lists") @cache(cacheable: false)
}
type WishlistOutput @doc(description: "Deprecated: 'Wishlist' type should be used instead") {
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
new file mode 100644
index 0000000000000..cdc774f08c2cb
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
@@ -0,0 +1,110 @@
+customerTokenService = Bootstrap::getObjectManager()->get(CustomerTokenServiceInterface::class);
+ $this->_wishlistCollectionFactory = Bootstrap::getObjectManager()->get(CollectionFactory::class);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Wishlist/_files/wishlist.php
+ */
+ public function testGetCustomerWishlists(): void
+ {
+ /** @var \Magento\Wishlist\Model\Wishlist $wishlist */
+ $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId(1);
+
+ /** @var Item $wishlistItem */
+ $wishlistItem = $collection->getFirstItem();
+ $query =
+ <<graphQlQuery(
+ $query,
+ [],
+ '',
+ $this->getCustomerAuthHeaders('customer@example.com', 'password')
+ );
+
+ $this->assertEquals($wishlistItem->getItemsCount(), $response['wishlists'][0]['items_count']);
+ $this->assertEquals($wishlistItem->getSharingCode(), $response['wishlists'][0]['sharing_code']);
+ $this->assertEquals($wishlistItem->getUpdatedAt(), $response['wishlists'][0]['updated_at']);
+ $this->assertEquals('simple', $response['wishlists'][0]['items'][0]['product']['sku']);
+
+ }
+
+ /**
+ * @expectedException \Exception
+ * @expectedExceptionMessage The current customer isn't authorized.
+ */
+ public function testGetGuestWishlist()
+ {
+ $query =
+ <<graphQlQuery($query);
+ }
+
+ /**
+ * @param string $email
+ * @param string $password
+ * @return array
+ * @throws \Magento\Framework\Exception\AuthenticationException
+ */
+ private function getCustomerAuthHeaders(string $email, string $password): array
+ {
+ $customerToken = $this->customerTokenService->createCustomerAccessToken($email, $password);
+ return ['Authorization' => 'Bearer ' . $customerToken];
+ }
+}
From f38582816355f797da3f870fe8ca796dbd8c6a44 Mon Sep 17 00:00:00 2001
From: Nikita Chubukov
Date: Wed, 25 Sep 2019 12:00:28 +0300
Subject: [PATCH 0196/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Fix CR comments
---
.../Model/Order/Shipment/TrackRepository.php | 1 +
.../Sales/Service/V1/ShipmentAddTrackTest.php | 16 +++++++++-------
2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
index 3cf173117b4b6..24ccf45d60145 100644
--- a/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
+++ b/app/code/Magento/Sales/Model/Order/Shipment/TrackRepository.php
@@ -121,6 +121,7 @@ public function delete(ShipmentTrackInterface $entity)
public function save(ShipmentTrackInterface $entity)
{
$shipments = $this->shipmentCollection->create()
+ ->addFieldToFilter('order_id', $entity['order_id'])
->addFieldToFilter('entity_id', $entity['parent_id'])
->toArray();
diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
index 5b7b1bf606932..93d835d77a1e5 100644
--- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
@@ -104,20 +104,22 @@ public function testShipmentTrackWithFailedOrderId()
ShipmentTrackInterface::TITLE => 'Shipment title',
ShipmentTrackInterface::CARRIER_CODE => Track::CUSTOM_CARRIER_CODE,
];
- $expectedMessage = 'Could not save the shipment tracking.';
+ $exceptionMessage = '';
try {
$this->_webApiCall($this->getServiceInfo(), ['entity' => $trackData]);
} catch (\SoapFault $e) {
- $this->assertContains(
- $expectedMessage,
- $e->getMessage(),
- 'SoapFault does not contain expected message.'
- );
+ $exceptionMessage = $e->getMessage();
} catch (\Exception $e) {
$errorObj = $this->processRestExceptionResult($e);
- $this->assertEquals($expectedMessage, $errorObj['message']);
+ $exceptionMessage = $errorObj['message'];
}
+
+ $this->assertContains(
+ $exceptionMessage,
+ 'Could not save the shipment tracking.',
+ 'SoapFault or CouldNotSaveException does not contain exception message.'
+ );
}
/**
From 8b328e9c68306d5c2d6632e3548d2eaea7c9c0d6 Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Thu, 26 Sep 2019 13:50:22 +0300
Subject: [PATCH 0197/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
.../Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
index 4cd962e76bc96..5f2d889d369fd 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
@@ -67,10 +67,9 @@
-
-
-
-
+
+
+
From 6025197fc0b4e5b298982e0cf5f76bdca5fcd04b Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Thu, 26 Sep 2019 15:37:18 +0300
Subject: [PATCH 0198/1978] refactoring
---
.../Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml | 3 ++-
.../Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml | 2 ++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
index 899ca8b7d7f4e..533bbb6760573 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
@@ -13,9 +13,10 @@
+
-
+
diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
index 00dc9b320d7ad..bc226a70375f0 100644
--- a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
+++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
@@ -30,6 +30,7 @@
+
@@ -55,5 +56,6 @@
+
From 7d4a306702274f3d5f41154f0e57903c5136470b Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Thu, 26 Sep 2019 15:53:09 +0300
Subject: [PATCH 0199/1978] [Wishlist] Remove name from WishlistOutput #920
---
.../Magento/GraphQl/Wishlist/CustomerWishlistsTest.php | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
index cdc774f08c2cb..2a6c70161a623 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
@@ -67,11 +67,10 @@ public function testGetCustomerWishlists(): void
$this->getCustomerAuthHeaders('customer@example.com', 'password')
);
- $this->assertEquals($wishlistItem->getItemsCount(), $response['wishlists'][0]['items_count']);
- $this->assertEquals($wishlistItem->getSharingCode(), $response['wishlists'][0]['sharing_code']);
- $this->assertEquals($wishlistItem->getUpdatedAt(), $response['wishlists'][0]['updated_at']);
- $this->assertEquals('simple', $response['wishlists'][0]['items'][0]['product']['sku']);
-
+ $this->assertEquals($wishlistItem->getItemsCount(), $response['customer']['wishlists'][0]['items_count']);
+ $this->assertEquals($wishlistItem->getSharingCode(), $response['customer']['wishlists'][0]['sharing_code']);
+ $this->assertEquals($wishlistItem->getUpdatedAt(), $response['customer']['wishlists'][0]['updated_at']);
+ $this->assertEquals('simple', $response['customer']['wishlists'][0]['items'][0]['product']['sku']);
}
/**
From 39c9c80c589e86f8d1586400b7166d5149f495fb Mon Sep 17 00:00:00 2001
From: RomanKis
Date: Fri, 27 Sep 2019 09:45:53 +0300
Subject: [PATCH 0200/1978] graphQl-961: ShippingAddressInput.postcode: String,
is not required by Schema
---
.../Model/Cart/QuoteAddressFactory.php | 4 +++
.../Model/Cart/SetBillingAddressOnCart.php | 27 ++++++++++++++++
.../Model/Cart/SetShippingAddressesOnCart.php | 26 +++++++++++++++
.../Customer/SetBillingAddressOnCartTest.php | 32 ++++++++++++++-----
.../Customer/SetShippingAddressOnCartTest.php | 30 +++++++++++++----
5 files changed, 104 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
index afc88f026ed62..52f5387f15785 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
@@ -66,6 +66,10 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress
$addressInput['country_id'] = $addressInput['country_code'];
}
+ if (isset($addressInput['region'])) {
+ $addressInput['region_code'] = $addressInput['region'];
+ }
+
$maxAllowedLineCount = $this->addressHelper->getStreetLines();
if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) {
throw new GraphQlInputException(
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 673debefd0874..cf8e38ebbfcc6 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -111,6 +111,33 @@ private function createBillingAddress(
(int)$context->getUserId()
);
}
+
+ $errors = $billingAddress->validate();
+
+ if (true !== $errors) {
+ throw new GraphQlInputException(
+ __('Shipping address error: %message', ['message' => $this->getAddressErrors($errors)])
+ );
+ }
+
return $billingAddress;
}
+
+ /**
+ * Collecting errors.
+ *
+ * @param array $errors
+ * @return string
+ */
+ private function getAddressErrors(array $errors): string
+ {
+ $errorMessages = [];
+
+ /** @var \Magento\Framework\Phrase $error */
+ foreach ($errors as $error) {
+ $errorMessages[] = $error->render();
+ }
+
+ return implode(PHP_EOL, $errorMessages);
+ }
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
index 260f1343556f0..9e39992eed830 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
@@ -82,6 +82,32 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
);
}
+ $errors = $shippingAddress->validate();
+
+ if (true !== $errors) {
+ throw new GraphQlInputException(
+ __('Shipping address error: %message', ['message' => $this->getAddressErrors($errors)])
+ );
+ }
+
$this->assignShippingAddressToCart->execute($cart, $shippingAddress);
}
+
+ /**
+ * Collecting errors.
+ *
+ * @param array $errors
+ * @return string
+ */
+ private function getAddressErrors(array $errors): string
+ {
+ $errorMessages = [];
+
+ /** @var \Magento\Framework\Phrase $error */
+ foreach ($errors as $error) {
+ $errorMessages[] = $error->render();
+ }
+
+ return implode(PHP_EOL, $errorMessages);
+ }
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 011930e723273..29109f89352ff 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -77,7 +77,7 @@ public function testSetNewBillingAddress()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -136,7 +136,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -297,7 +297,7 @@ public function testSetNewBillingAddressAndFromAddressBookAtSameTime()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -379,7 +379,7 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -573,7 +573,7 @@ public function testSetBillingAddressWithoutRequiredParameters(string $input, st
QUERY;
$this->expectExceptionMessage($message);
- $this->graphQlMutation($query);
+ $this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
/**
@@ -590,7 +590,23 @@ public function dataProviderSetWithoutRequiredParameters(): array
'missed_cart_id' => [
'billing_address: {}',
'Required parameter "cart_id" is missing'
- ]
+ ],
+ 'missed_region' => [
+ 'cart_id: "cart_id_value"
+ billing_address: {
+ address: {
+ firstname: "test firstname"
+ lastname: "test lastname"
+ company: "test company"
+ street: ["test street 1", "test street 2"]
+ city: "test city"
+ postcode: "887766"
+ country_code: "US"
+ telephone: "88776655"
+ }
+ }',
+ '"regionId" is required. Enter and try again.'
+ ],
];
}
@@ -616,7 +632,7 @@ public function testSetNewBillingAddressWithRedundantStreetLine()
company: "test company"
street: ["test street 1", "test street 2", "test street 3"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -659,7 +675,7 @@ public function testSetBillingAddressWithLowerCaseCountry()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "us"
telephone: "88776655"
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
index e74b7c41b3983..fd21475f12504 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
@@ -78,7 +78,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -144,7 +144,7 @@ public function testSetNewShippingAddressOnCartWithVirtualProduct()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -272,7 +272,7 @@ public function testSetNewShippingAddressAndFromAddressBookAtSameTime()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -424,7 +424,23 @@ public function dataProviderUpdateWithMissedRequiredParameters(): array
'missed_cart_id' => [
'shipping_addresses: {}',
'Required parameter "cart_id" is missing'
- ]
+ ],
+ 'missed_region' => [
+ 'cart_id: "cart_id_value"
+ shipping_addresses: [{
+ address: {
+ firstname: "test firstname"
+ lastname: "test lastname"
+ company: "test company"
+ street: ["test street 1", "test street 2"]
+ city: "test city"
+ postcode: "887766"
+ country_code: "US"
+ telephone: "88776655"
+ }
+ }]',
+ '"regionId" is required. Enter and try again.'
+ ],
];
}
@@ -454,7 +470,7 @@ public function testSetMultipleNewShippingAddresses()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -468,7 +484,7 @@ public function testSetMultipleNewShippingAddresses()
company: "test company 2"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -512,7 +528,7 @@ public function testSetNewShippingAddressOnCartWithRedundantStreetLine()
company: "test company"
street: ["test street 1", "test street 2", "test street 3"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
From 5dd4a1085b02c25d061b3d0ab85783823de068cf Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Fri, 27 Sep 2019 09:48:13 +0300
Subject: [PATCH 0201/1978] graphQl-903: added description to the
same_as_shipping field
---
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index ae0a1bc34866a..e97582b9ae52d 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -97,7 +97,7 @@ input BillingAddressInput {
customer_address_id: Int
address: CartAddressInput
use_for_shipping: Boolean @doc(description: "Deprecated. Use same_as_shipping")
- same_as_shipping: Boolean
+ same_as_shipping: Boolean @doc(description: "Set billing address same as shipping")
}
input CartAddressInput {
From 863d178be4baf88fffc7b252c0a92f6edb0410e5 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Fri, 27 Sep 2019 10:57:22 +0300
Subject: [PATCH 0202/1978] graphQl-890: fixed deprecation messages
---
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index 2edb3f1e196ab..cd72e90344c6f 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -220,7 +220,7 @@ type ShippingCartAddress implements CartAddressInterface {
available_shipping_methods: [AvailableShippingMethod] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\AvailableShippingMethods")
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
customer_notes: String
- items_weight: Float @deprecated
+ items_weight: Float @deprecated(reason: "This information shoud not be exposed on frontend")
cart_items: [CartItemInterface]
}
@@ -228,7 +228,7 @@ type BillingCartAddress implements CartAddressInterface {
customer_notes: String @deprecated (reason: "The field is used only in shipping address")
}
-type CartItemQuantity @deprecated(reason: "Use CartItemInterface instead") {
+type CartItemQuantity @deprecated(reason: "All fields in CartItemQuantity should be deprecated (so this type can be completely removed in the future releases)") {
cart_item_id: Int!
quantity: Float!
}
From aeb0175397d78221372cc21d8db74168afb77c5f Mon Sep 17 00:00:00 2001
From: Vitaliy
Date: Fri, 27 Sep 2019 13:19:01 +0300
Subject: [PATCH 0203/1978] graphQl-903: Update
app/code/Magento/QuoteGraphQl/etc/schema.graphqls
Co-Authored-By: Lena Orobei
---
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index e97582b9ae52d..1c60f18c5bc26 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -96,7 +96,7 @@ input SetBillingAddressOnCartInput {
input BillingAddressInput {
customer_address_id: Int
address: CartAddressInput
- use_for_shipping: Boolean @doc(description: "Deprecated. Use same_as_shipping")
+ use_for_shipping: Boolean @doc(description: "Deprecated: use `same_as_shipping` field instead")
same_as_shipping: Boolean @doc(description: "Set billing address same as shipping")
}
From 4c85d8439053b9df7644f3e86105b4d5b2570522 Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 27 Sep 2019 13:43:20 +0300
Subject: [PATCH 0204/1978] [Wishlist] Remove name from WishlistOutput #920
---
.../WishlistGraphQl/etc/schema.graphqls | 10 +++---
.../Wishlist/CustomerWishlistsTest.php | 31 +++++++++++++++++++
2 files changed, 36 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
index b7cc60fe100c6..28d80c4a21884 100644
--- a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
@@ -10,11 +10,11 @@ type Customer {
}
type WishlistOutput @doc(description: "Deprecated: 'Wishlist' type should be used instead") {
- items: [WishlistItem] @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "Deprecated: use field `items` from type `Wishlist`"),
- items_count: Int @doc(description: "Deprecated: use field `items_count` from type `Wishlist`"),
- name: String @doc(description: "Deprecated."),
- sharing_code: String @doc(description: "Deprecated: use field `sharing_code` from type `Wishlist`"),
- updated_at: String @doc(description: "Deprecated: use field `updated_at` from type `Wishlist`")
+ items: [WishlistItem] @deprecated(reason: "Use field `items` from type `Wishlist` instead") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"),
+ items_count: Int @deprecated(reason: "Use field `items_count` from type `Wishlist` instead") @doc(description: "The number of items in the wish list"),
+ name: String @deprecated(reason: "This field is related to Commerce functionality and is always null in Open source edition") @doc(description: "When multiple wish lists are enabled, the name the customer assigns to the wishlist"),
+ sharing_code: String @deprecated(reason: "Use field `sharing_code` from type `Wishlist` instead") @doc(description: "An encrypted code that Magento uses to link to the wish list"),
+ updated_at: String @deprecated(reason: "Use field `updated_at` from type `Wishlist` instead") @doc(description: "The time of the last modification to the wish list")
}
type Wishlist {
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
index 2a6c70161a623..2d6c3ff34b0ab 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
@@ -73,6 +73,37 @@ public function testGetCustomerWishlists(): void
$this->assertEquals('simple', $response['customer']['wishlists'][0]['items'][0]['product']['sku']);
}
+ public function testCustomerWithoutWishlists(): void
+ {
+ $query =
+ <<graphQlQuery(
+ $query,
+ [],
+ '',
+ $this->getCustomerAuthHeaders('customer@example.com', 'password')
+ );
+
+ $this->assertEquals([], $response['customer']['wishlists']);
+ }
+
/**
* @expectedException \Exception
* @expectedExceptionMessage The current customer isn't authorized.
From b52fe3e5f67a4e2d670a8599568da8266614b51f Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 27 Sep 2019 14:39:40 +0300
Subject: [PATCH 0205/1978] [Wishlist] Remove name from WishlistOutput #920
---
.../Magento/GraphQl/Wishlist/CustomerWishlistsTest.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
index 2d6c3ff34b0ab..74b91cfb85209 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistsTest.php
@@ -73,6 +73,9 @@ public function testGetCustomerWishlists(): void
$this->assertEquals('simple', $response['customer']['wishlists'][0]['items'][0]['product']['sku']);
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ */
public function testCustomerWithoutWishlists(): void
{
$query =
From b94085ecc4a6a48c318a7c2465f69cfa44277606 Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 27 Sep 2019 15:01:01 +0300
Subject: [PATCH 0206/1978] Magento 2.3.2 - PWA - graphQl fetching Issue for
phtml file called in static block #960
---
.../Model/Resolver/DataProvider/Block.php | 27 +++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
index fa4944381b858..9cbb34a939109 100644
--- a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
+++ b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
@@ -11,6 +11,7 @@
use Magento\Cms\Api\Data\BlockInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Widget\Model\Template\FilterEmulate;
+use Magento\Framework\App\State;
/**
* Cms block data provider
@@ -27,16 +28,24 @@ class Block
*/
private $widgetFilter;
+ /**
+ * @var State
+ */
+ private $state;
+
/**
* @param BlockRepositoryInterface $blockRepository
* @param FilterEmulate $widgetFilter
+ * @param State $state
*/
public function __construct(
BlockRepositoryInterface $blockRepository,
- FilterEmulate $widgetFilter
+ FilterEmulate $widgetFilter,
+ State $state
) {
$this->blockRepository = $blockRepository;
$this->widgetFilter = $widgetFilter;
+ $this->state = $state;
}
/**
@@ -56,7 +65,11 @@ public function getData(string $blockIdentifier): array
);
}
- $renderedContent = $this->widgetFilter->filter($block->getContent());
+ $renderedContent = $this->state->emulateAreaCode(
+ 'frontend',
+ [$this, 'getRenderedBlockContent'],
+ [$block->getContent()]
+ );
$blockData = [
BlockInterface::BLOCK_ID => $block->getId(),
@@ -66,4 +79,14 @@ public function getData(string $blockIdentifier): array
];
return $blockData;
}
+
+ /**
+ * @param string $blockContent
+ *
+ * @return string
+ */
+ public function getRenderedBlockContent(string $blockContent) : string
+ {
+ return $this->widgetFilter->filter($blockContent);
+ }
}
From 5b0b948319eaf4a64dfd5217c9076ca8d88c311d Mon Sep 17 00:00:00 2001
From: Aliaksei_Manenak
Date: Fri, 27 Sep 2019 14:45:12 +0300
Subject: [PATCH 0207/1978] MC-18822: Increase test coverage for Content
functional area
- MC-11441 should be covered by Integration test
---
.../Newsletter/Controller/SubscriberTest.php | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
index 35f9cb4a5a11c..b7b87d3b9e20d 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
@@ -8,10 +8,13 @@
namespace Magento\Newsletter\Controller;
use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Customer\Model\AccountConfirmation;
+use Magento\Framework\App\Config\MutableScopeConfigInterface;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Data\Form\FormKey;
use Magento\Newsletter\Model\ResourceModel\Subscriber as SubscriberLoader;
use Magento\Newsletter\Model\Subscriber;
+use Magento\Store\Model\ScopeInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\AbstractController;
@@ -76,10 +79,17 @@ public function testNewActionOwnerEmail()
/**
* Check that Customer still subscribed for newsletters emails after registration.
*
- * @magentoConfigFixture ccustomer/create/account_confirm 1
+ * @magentoDbIsolation enabled
*/
public function testCreatePosWithSubscribeEmailAction()
{
+ $config = Bootstrap::getObjectManager()->get(MutableScopeConfigInterface::class);
+ $accountConfirmationRequired = $config->getValue(
+ AccountConfirmation::XML_PATH_IS_CONFIRM,
+ ScopeInterface::SCOPE_WEBSITES
+ );
+ $config->setValue(AccountConfirmation::XML_PATH_IS_CONFIRM, 1, ScopeInterface::SCOPE_WEBSITES);
+
$subscriber = Bootstrap::getObjectManager()->create(Subscriber::class);
$customerEmail = 'subscribeemail@example.com';
// Subscribe by email
@@ -100,6 +110,12 @@ public function testCreatePosWithSubscribeEmailAction()
// check customer subscribed to newsletter
$this->assertTrue($subscriberResource->loadByCustomerData($customer)['subscriber_status'] === "1");
+
+ $config->setValue(
+ AccountConfirmation::XML_PATH_IS_CONFIRM,
+ $accountConfirmationRequired,
+ ScopeInterface::SCOPE_WEBSITES
+ );
}
/**
From 0ee4cdd10392fa42dc3ea148d27bc557a3ce167b Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 27 Sep 2019 15:24:44 +0300
Subject: [PATCH 0208/1978] Magento 2.3.2 - PWA - graphQl fetching Issue for
phtml file called in static block #960
---
.../Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
index 9cbb34a939109..8eda6d27a1c72 100644
--- a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
+++ b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
@@ -66,7 +66,7 @@ public function getData(string $blockIdentifier): array
}
$renderedContent = $this->state->emulateAreaCode(
- 'frontend',
+ \Magento\Framework\App\Area::AREA_FRONTEND,
[$this, 'getRenderedBlockContent'],
[$block->getContent()]
);
@@ -81,6 +81,8 @@ public function getData(string $blockIdentifier): array
}
/**
+ * Get block data as it rendered on frontend
+ *
* @param string $blockContent
*
* @return string
From 2826f74772af2091e8b5262d06beac7b79eaa700 Mon Sep 17 00:00:00 2001
From: skylineop
Date: Fri, 27 Sep 2019 18:00:22 +0300
Subject: [PATCH 0209/1978] 15959 Extension attributes of quote on checkout
page
---
app/code/Magento/Checkout/Model/DefaultConfigProvider.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Checkout/Model/DefaultConfigProvider.php b/app/code/Magento/Checkout/Model/DefaultConfigProvider.php
index 70352b50d8de4..15c22b1f72573 100644
--- a/app/code/Magento/Checkout/Model/DefaultConfigProvider.php
+++ b/app/code/Magento/Checkout/Model/DefaultConfigProvider.php
@@ -397,6 +397,9 @@ private function getQuoteData()
if ($this->checkoutSession->getQuote()->getId()) {
$quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
$quoteData = $quote->toArray();
+ if (is_object($quote->getExtensionAttributes())) {
+ $quoteData['extension_attributes'] = $quote->getExtensionAttributes()->__toArray();
+ }
$quoteData['is_virtual'] = $quote->getIsVirtual();
if (!$quote->getCustomer()->getId()) {
From d7aba3d377ab4f72a265c24f16577b3049dffc60 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Fri, 27 Sep 2019 11:37:25 -0500
Subject: [PATCH 0210/1978] MC-20119: Spike to figure out how to persist
promotions data on quote - added POC
---
.../Quote/Model/Quote/Address/Total.php | 15 +++++++++
.../Model/Quote/Item/Plugin/Discount.php | 23 ++++++++++++++
app/code/Magento/Quote/etc/db_schema.xml | 5 ++-
app/code/Magento/Quote/etc/di.xml | 3 ++
.../SalesRule/Model/Quote/Discount.php | 31 +++++++++++++++++++
.../Magento/SalesRule/Model/RulesApplier.php | 12 +++----
6 files changed, 82 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php
diff --git a/app/code/Magento/Quote/Model/Quote/Address/Total.php b/app/code/Magento/Quote/Model/Quote/Address/Total.php
index d8dd0953407d4..3ed9f7f984334 100644
--- a/app/code/Magento/Quote/Model/Quote/Address/Total.php
+++ b/app/code/Magento/Quote/Model/Quote/Address/Total.php
@@ -200,4 +200,19 @@ public function getFullInfo()
}
return $fullInfo;
}
+
+ public function getDiscountBreakdown() {
+ $fullInfo = $this->getData('discount_breakdown');
+ if (is_string($fullInfo)) {
+ $fullInfo = $this->serializer->unserialize($fullInfo);
+ }
+ return $fullInfo;
+ }
+
+ public function setDiscountBreakdown($discount) {
+ if (isset($discount)) {
+ $this->setData('discount_breakdown', $this->serializer->serialize($discount));
+ }
+ return $this;
+ }
}
diff --git a/app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php
new file mode 100644
index 0000000000000..134258c2e09ab
--- /dev/null
+++ b/app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php
@@ -0,0 +1,23 @@
+getExtensionAttributes();
+ $cartItem->setDiscounts(\GuzzleHttp\json_encode($extension->getDiscounts()));
+ return [$quote, $cartItem];
+ }
+}
\ No newline at end of file
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
index b4c75fc1d21d0..cf3ce416e24c5 100644
--- a/app/code/Magento/Quote/etc/db_schema.xml
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -173,8 +173,10 @@
default="0" comment="Base Grand Total"/>
-
+
+
diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml
index cd5e62307fdca..6060e3e2845a1 100644
--- a/app/code/Magento/Quote/etc/di.xml
+++ b/app/code/Magento/Quote/etc/di.xml
@@ -101,6 +101,9 @@
+
+
+
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 315ce874513a3..47aaee2bd8fa7 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -131,6 +131,7 @@ public function collect(
$this->calculator->prepareDescription($address);
$total->setDiscountDescription($address->getDiscountDescription());
+ $total->setDiscountBreakdown($this->aggregateDiscountPerRule($quote));
$total->setSubtotalWithDiscount($total->getSubtotal() + $total->getDiscountAmount());
$total->setBaseSubtotalWithDiscount($total->getBaseSubtotal() + $total->getBaseDiscountAmount());
@@ -218,4 +219,34 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
}
return $result;
}
+
+ /**
+ * @param \Magento\Quote\Model\Quote $quote
+ * @return array
+ */
+ private function aggregateDiscountPerRule(
+ \Magento\Quote\Model\Quote $quote
+ ) {
+ $items = $quote->getItems();
+ $discountPerRule = [];
+ if ($items) {
+ foreach ($items as $item) {
+ $discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
+ if ($discountBreakdown) {
+ foreach ($discountBreakdown as $key => $value) {
+ /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
+ $discount = $value['discount'];
+ $ruleLabel = $value['rule'];
+ if (isset($discountPerRule[$key])) {
+ $discountPerRule[$key]['discount'] += $discount;
+ } else {
+ $discountPerRule[$key]['discount'] = $discount;
+ }
+ $discountPerRule[$key]['rule'] = $ruleLabel;
+ }
+ }
+ }
+ }
+ return $discountPerRule;
+ }
}
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index 34b8ba89fafa8..f09d02b31dfb4 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -156,7 +156,7 @@ public function addDiscountDescription($address, $rule)
*/
protected function applyRule($item, $rule, $address, $couponCode)
{
- $discountData = $this->getDiscountData($item, $rule);
+ $discountData = $this->getDiscountData($item, $rule, $address);
$this->setDiscountData($discountData, $item);
$this->maintainAddressCouponCode($address, $rule, $couponCode);
@@ -172,7 +172,7 @@ protected function applyRule($item, $rule, $address, $couponCode)
* @param \Magento\SalesRule\Model\Rule $rule
* @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
*/
- protected function getDiscountData($item, $rule)
+ protected function getDiscountData($item, $rule, $address)
{
$qty = $this->validatorUtility->getItemQty($item, $rule);
@@ -181,7 +181,7 @@ protected function getDiscountData($item, $rule)
$discountData = $discountCalculator->calculate($rule, $item, $qty);
$this->eventFix($discountData, $item, $rule, $qty);
$this->validatorUtility->deltaRoundingFix($discountData, $item);
- $this->setDiscountBreakdown($discountData, $item, $rule);
+ $this->setDiscountBreakdown($discountData, $item, $rule, $address);
/**
* We can't use row total here because row total not include tax
@@ -201,7 +201,7 @@ protected function getDiscountData($item, $rule)
* @param \Magento\SalesRule\Model\Rule $rule
* @return $this
*/
- private function setDiscountBreakdown($discountData, $item, $rule)
+ private function setDiscountBreakdown($discountData, $item, $rule, $address)
{
if ($discountData->getAmount() > 0) {
/** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
@@ -211,8 +211,8 @@ private function setDiscountBreakdown($discountData, $item, $rule)
$discount->setBaseAmount($discountData->getBaseAmount());
$discount->setOriginalAmount($discountData->getOriginalAmount());
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts() ?? [];
- $discountBreakdown[$rule->getId()]['discount'] = $discount;
- $discountBreakdown[$rule->getId()]['rule'] = $rule;
+ $discountBreakdown[$rule->getId()]['discount'] = $discountData->getAmount();
+ $discountBreakdown[$rule->getId()]['rule'] = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
$item->getExtensionAttributes()->setDiscounts($discountBreakdown);
}
return $this;
From 18a32604d8069af1823c7a4306f3dcf16deb1f84 Mon Sep 17 00:00:00 2001
From: RomanKis
Date: Sun, 29 Sep 2019 13:29:42 +0300
Subject: [PATCH 0211/1978] graphQl-961: ShippingAddressInput.postcode: String,
is not required by Schema
---
.../Model/Cart/QuoteAddressFactory.php | 25 ++++++++++++++++---
.../Guest/SetBillingAddressOnCartTest.php | 14 +++++------
.../Guest/SetShippingAddressOnCartTest.php | 12 ++++-----
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
index 52f5387f15785..9fe8d34435d5d 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
@@ -9,12 +9,14 @@
use Magento\Customer\Helper\Address as AddressHelper;
use Magento\CustomerGraphQl\Model\Customer\Address\GetCustomerAddress;
+use Magento\Directory\Api\CountryInformationAcquirerInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
use Magento\Quote\Model\Quote\AddressFactory as BaseQuoteAddressFactory;
+use Magento\Framework\App\ObjectManager;
/**
* Create QuoteAddress
@@ -36,38 +38,53 @@ class QuoteAddressFactory
*/
private $addressHelper;
+ /**
+ * @var CountryInformationAcquirerInterface
+ */
+ private $countryInformationAcquirer;
+
/**
* @param BaseQuoteAddressFactory $quoteAddressFactory
* @param GetCustomerAddress $getCustomerAddress
* @param AddressHelper $addressHelper
+ * @param CountryInformationAcquirerInterface|null $countryInformationAcquirer
*/
public function __construct(
BaseQuoteAddressFactory $quoteAddressFactory,
GetCustomerAddress $getCustomerAddress,
- AddressHelper $addressHelper
+ AddressHelper $addressHelper,
+ CountryInformationAcquirerInterface $countryInformationAcquirer = null
) {
$this->quoteAddressFactory = $quoteAddressFactory;
$this->getCustomerAddress = $getCustomerAddress;
$this->addressHelper = $addressHelper;
+ $this->countryInformationAcquirer = $countryInformationAcquirer;
+ $this->countryInformationAcquirer = $countryInformationAcquirer
+ ?: ObjectManager::getInstance()->get(CountryInformationAcquirerInterface::class);
}
/**
* Create QuoteAddress based on input data
*
* @param array $addressInput
+ *
* @return QuoteAddress
* @throws GraphQlInputException
*/
public function createBasedOnInputData(array $addressInput): QuoteAddress
{
$addressInput['country_id'] = '';
- if ($addressInput['country_code']) {
+ if (isset($addressInput['country_code']) && $addressInput['country_code']) {
$addressInput['country_code'] = strtoupper($addressInput['country_code']);
$addressInput['country_id'] = $addressInput['country_code'];
}
- if (isset($addressInput['region'])) {
- $addressInput['region_code'] = $addressInput['region'];
+ if ($addressInput['country_id'] && isset($addressInput['region'])) {
+ $countryInformation = $this->countryInformationAcquirer->getCountryInfo($addressInput['country_id']);
+ $availableRegions = $countryInformation->getAvailableRegions();
+ if (null !== $availableRegions) {
+ $addressInput['region_code'] = $addressInput['region'];
+ }
}
$maxAllowedLineCount = $this->addressHelper->getStreetLines();
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
index 730e65b4ba8aa..dd113c2a0205e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
@@ -48,7 +48,7 @@ public function testSetNewBillingAddress()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -106,7 +106,7 @@ public function testSetNewBillingAddressWithUseForShippingParameter()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -182,7 +182,7 @@ public function testSetBillingAddressToCustomerCart()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -259,7 +259,7 @@ public function testSetBillingAddressOnNonExistentCart()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -387,7 +387,7 @@ public function testSetNewBillingAddressWithUseForShippingAndMultishipping()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -433,7 +433,7 @@ public function testSetNewBillingAddressRedundantStreetLine()
company: "test company"
street: ["test street 1", "test street 2", "test street 3"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -476,7 +476,7 @@ public function testSetBillingAddressWithLowerCaseCountry()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "us"
telephone: "88776655"
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php
index 0351a4f58a8e0..217759edf10fd 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetShippingAddressOnCartTest.php
@@ -49,7 +49,7 @@ public function testSetNewShippingAddressOnCartWithSimpleProduct()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -114,7 +114,7 @@ public function testSetNewShippingAddressOnCartWithVirtualProduct()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -266,7 +266,7 @@ public function testSetNewShippingAddressOnCartWithRedundantStreetLine()
company: "test company"
street: ["test street 1", "test street 2", "test street 3"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -335,7 +335,7 @@ public function testSetMultipleNewShippingAddresses()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -349,7 +349,7 @@ public function testSetMultipleNewShippingAddresses()
company: "test company 2"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -389,7 +389,7 @@ public function testSetShippingAddressOnNonExistentCart()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AL"
postcode: "887766"
country_code: "US"
telephone: "88776655"
From 18784c217649e6f6eb2137dc939845bb12a79755 Mon Sep 17 00:00:00 2001
From: RomanKis
Date: Sun, 29 Sep 2019 13:58:46 +0300
Subject: [PATCH 0212/1978] graphQl-961: ShippingAddressInput.postcode: String,
is not required by Schema
---
.../Model/Cart/SetBillingAddressOnCart.php | 18 +++++++++++++++---
.../Model/Cart/SetShippingAddressesOnCart.php | 17 +++++++++++++++--
2 files changed, 30 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index cf8e38ebbfcc6..dd2daa6cb24ff 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -112,15 +112,27 @@ private function createBillingAddress(
);
}
- $errors = $billingAddress->validate();
+ $this->validateAddress($billingAddress);
+
+ return $billingAddress;
+ }
+
+ /**
+ * Validate quote address.
+ *
+ * @param Address $shippingAddress
+ *
+ * @throws GraphQlInputException
+ */
+ private function validateAddress(Address $shippingAddress)
+ {
+ $errors = $shippingAddress->validate();
if (true !== $errors) {
throw new GraphQlInputException(
__('Shipping address error: %message', ['message' => $this->getAddressErrors($errors)])
);
}
-
- return $billingAddress;
}
/**
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
index 9e39992eed830..a15398806efa6 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
@@ -11,6 +11,7 @@
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\GraphQl\Model\Query\ContextInterface;
use Magento\Quote\Api\Data\CartInterface;
+use Magento\Quote\Model\Quote\Address;
/**
* Set single shipping address for a specified shopping cart
@@ -82,6 +83,20 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
);
}
+ $this->validateAddress($shippingAddress);
+
+ $this->assignShippingAddressToCart->execute($cart, $shippingAddress);
+ }
+
+ /**
+ * Validate quote address.
+ *
+ * @param Address $shippingAddress
+ *
+ * @throws GraphQlInputException
+ */
+ private function validateAddress(Address $shippingAddress)
+ {
$errors = $shippingAddress->validate();
if (true !== $errors) {
@@ -89,8 +104,6 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
__('Shipping address error: %message', ['message' => $this->getAddressErrors($errors)])
);
}
-
- $this->assignShippingAddressToCart->execute($cart, $shippingAddress);
}
/**
From cee3afc81c64d497e10e1ae2f1f02da6e7c1032f Mon Sep 17 00:00:00 2001
From: Bohdan Shevchenko <1408sheva@gmail.com>
Date: Mon, 30 Sep 2019 09:18:28 +0300
Subject: [PATCH 0213/1978] MC-20481: [API Test] Revoke all access Tokens for
Customer
---
.../Customer/Api/CustomerRepositoryTest.php | 63 +++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php
index 709abbbb8fbf9..7a02e2f843719 100644
--- a/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Customer/Api/CustomerRepositoryTest.php
@@ -10,6 +10,9 @@
use Magento\Customer\Api\Data\AddressInterface as Address;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\Exception\InputException;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Webapi\Rest\Request;
+use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Helper\Customer as CustomerHelper;
use Magento\TestFramework\TestCase\WebapiAbstract;
@@ -780,6 +783,66 @@ public function testSearchCustomersMultipleFilterGroups()
$this->assertEquals(0, $searchResults['total_count']);
}
+ /**
+ * Test revoking all access Tokens for customer
+ */
+ public function testRevokeAllAccessTokensForCustomer()
+ {
+ $customerData = $this->_createCustomer();
+
+ /** @var CustomerTokenServiceInterface $customerTokenService */
+ $customerTokenService = Bootstrap::getObjectManager()->create(CustomerTokenServiceInterface::class);
+ $token = $customerTokenService->createCustomerAccessToken(
+ $customerData[Customer::EMAIL],
+ CustomerHelper::PASSWORD
+ );
+ $serviceInfo = [
+ 'rest' => [
+ 'resourcePath' => self::RESOURCE_PATH . '/me',
+ 'httpMethod' => Request::HTTP_METHOD_GET,
+ 'token' => $token,
+ ],
+ 'soap' => [
+ 'service' => self::SERVICE_NAME,
+ 'serviceVersion' => self::SERVICE_VERSION,
+ 'operation' => self::SERVICE_NAME . 'GetSelf',
+ 'token' => $token,
+ ],
+ ];
+
+ $customerLoadedData = $this->_webApiCall($serviceInfo, ['customerId' => $customerData[Customer::ID]]);
+ self::assertGreaterThanOrEqual($customerData[Customer::UPDATED_AT], $customerLoadedData[Customer::UPDATED_AT]);
+ unset($customerData[Customer::UPDATED_AT]);
+ self::assertArraySubset($customerData, $customerLoadedData);
+
+ $revokeToken = $customerTokenService->revokeCustomerAccessToken($customerData[Customer::ID]);
+ self::assertTrue($revokeToken);
+
+ try {
+ $customerTokenService->revokeCustomerAccessToken($customerData[Customer::ID]);
+ } catch (\Throwable $exception) {
+ $this->assertInstanceOf(LocalizedException::class, $exception);
+ $this->assertEquals('This customer has no tokens.', $exception->getMessage());
+ }
+
+ $expectedMessage = 'The consumer isn\'t authorized to access %resources.';
+
+ try {
+ $this->_webApiCall($serviceInfo, ['customerId' => $customerData[Customer::ID]]);
+ } catch (\SoapFault $e) {
+ $this->assertContains(
+ $expectedMessage,
+ $e->getMessage(),
+ 'SoapFault does not contain expected message.'
+ );
+ } catch (\Throwable $e) {
+ $errorObj = $this->processRestExceptionResult($e);
+ $this->assertEquals($expectedMessage, $errorObj['message']);
+ $this->assertEquals(['resources' => 'self'], $errorObj['parameters']);
+ $this->assertEquals(HTTPExceptionCodes::HTTP_UNAUTHORIZED, $e->getCode());
+ }
+ }
+
/**
* Retrieve customer data by Id
*
From 3cd8e6ec5ba041d72d939747ec5bc5804f3d23b1 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 30 Sep 2019 16:47:49 +0400
Subject: [PATCH 0214/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml | 2 +-
... => StorefrontElasticsearchSearchInvalidValueTest.xml} | 8 +++++---
2 files changed, 6 insertions(+), 4 deletions(-)
rename app/code/Magento/Elasticsearch6/Test/Mftf/Test/{StrorefrontElasticsearchSearchInvalidValueTest.xml => StorefrontElasticsearchSearchInvalidValueTest.xml} (94%)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index d8af28a23671f..38abc678dddd5 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -65,7 +65,7 @@
CustomAttributeCategoryIds
- /s\i’m“p:l\$e#@!,.`=%&^
+ SimpleProduct -+~/\\<>\’“:*\$#@()!,.?`=%&^
SimpleProductForTest1
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearchSearchInvalidValueTest.xml
similarity index 94%
rename from app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
rename to app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearchSearchInvalidValueTest.xml
index 84bbe00d2b971..932bef3a1452b 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StrorefrontElasticsearchSearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearchSearchInvalidValueTest.xml
@@ -8,7 +8,7 @@
-
+
@@ -47,6 +47,8 @@
+
+
@@ -94,11 +96,11 @@
-
+
-
+
From 72d20aee6d7d37f46b205207053467a5ca57cf80 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Mon, 30 Sep 2019 16:18:12 +0300
Subject: [PATCH 0215/1978] MC-18165: Quick search with two chars shows all
products
---
.../StorefrontCatalogSearchActionGroup.xml | 5 +++-
.../Test/Mftf/Data/ConfigData.xml | 19 +++++++++++++
.../Mftf/Test/SearchEntityResultsTest.xml | 27 ++++++++++++++-----
3 files changed, 43 insertions(+), 8 deletions(-)
create mode 100644 app/code/Magento/CatalogSearch/Test/Mftf/Data/ConfigData.xml
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
index a907df2d718df..1c1bd95dd7105 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
@@ -45,8 +45,11 @@
Fill the Storefront Search field. Submits the Form. Validates that 'Minimum Search query length' warning appears.
+
+
+
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Data/ConfigData.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Data/ConfigData.xml
new file mode 100644
index 0000000000000..dd8c426592619
--- /dev/null
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Data/ConfigData.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+ catalog/search/min_query_length
+ 3
+
+
+ catalog/search/min_query_length
+ 4
+
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
index 47d107148a574..ba751fe34bf08 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
@@ -74,6 +74,7 @@
+
@@ -89,8 +90,8 @@
-
-
+
+
@@ -99,6 +100,7 @@
+
@@ -110,19 +112,30 @@
+
+
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
+
-
+
+
From a056502ee6110506f81b5f7732cf9d3587f091c4 Mon Sep 17 00:00:00 2001
From: Nikita Shcherbatykh
Date: Mon, 30 Sep 2019 17:25:29 +0300
Subject: [PATCH 0216/1978] MC-19031: Sorting the product grid by custom
product attribute sorts by value ID instead of Alphabetically
---
.../Mftf/Data/ProductAttributeOptionData.xml | 8 ++
.../Catalog/Test/Mftf/Data/StoreLabelData.xml | 8 ++
...ductGridFilteringByCustomAttributeTest.xml | 104 ++++++++++++++++++
.../Model/Entity/Attribute/Source/Table.php | 2 +-
.../ResourceModel/Entity/Attribute/Option.php | 16 ++-
.../Entity/Attribute/Source/TableTest.php | 2 +-
6 files changed, 133 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml
index bb0e85bcbb40b..a8646a58ae39c 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeOptionData.xml
@@ -86,6 +86,14 @@
White
white
+
+
+ Blue
+ false
+ 3
+ Option11Store0
+ Option11Store1
+
option1
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/StoreLabelData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/StoreLabelData.xml
index 0e51995ac72e8..dcd7fde92283c 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/StoreLabelData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/StoreLabelData.xml
@@ -72,4 +72,12 @@
1
Red
+
+ 0
+ Blue
+
+
+ 1
+ Blue
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml
new file mode 100644
index 0000000000000..b0832b8f5944c
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml
@@ -0,0 +1,104 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
index f9aa1a9ed3ba1..46e4b665cabdf 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Source/Table.php
@@ -213,7 +213,7 @@ public function addValueSortToCollection($collection, $dir = \Magento\Framework\
$valueExpr
);
- $collection->getSelect()->order("{$attribute->getAttributeCode()} {$dir}");
+ $collection->getSelect()->order("{$attribute->getAttributeCode()}_value {$dir}");
return $this;
}
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php
index 79c277dcb6a82..5a110a45d5805 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute/Option.php
@@ -42,10 +42,13 @@ public function addOptionValueToCollection($collection, $attribute, $valueExpr)
"{$optionTable2}.option_id={$valueExpr} AND {$optionTable2}.store_id=?",
$collection->getStoreId()
);
- $valueExpr = $connection->getCheckSql(
- "{$optionTable2}.value_id IS NULL",
- "{$optionTable1}.option_id",
- "{$optionTable2}.option_id"
+ $valueIdExpr = $connection->getIfNullSql(
+ "{$optionTable2}.option_id",
+ "{$optionTable1}.option_id"
+ );
+ $valueExpr = $connection->getIfNullSql(
+ "{$optionTable2}.value",
+ "{$optionTable1}.value"
);
$collection->getSelect()->joinLeft(
@@ -55,7 +58,10 @@ public function addOptionValueToCollection($collection, $attribute, $valueExpr)
)->joinLeft(
[$optionTable2 => $this->getTable('eav_attribute_option_value')],
$tableJoinCond2,
- [$attributeCode => $valueExpr]
+ [
+ $attributeCode => $valueIdExpr,
+ $attributeCode . '_value' => $valueExpr,
+ ]
);
return $this;
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
index b68446d22f910..e61a7ebb862a9 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Source/TableTest.php
@@ -314,7 +314,7 @@ public function testAddValueSortToCollection()
$attrOption->expects($this->once())->method('addOptionValueToCollection')
->with($collection, $this->abstractAttributeMock, $expr)
->willReturnSelf();
- $select->expects($this->once())->method('order')->with("{$attributeCode} {$dir}");
+ $select->expects($this->once())->method('order')->with("{$attributeCode}_value {$dir}");
$this->assertEquals($this->model, $this->model->addValueSortToCollection($collection, $dir));
}
From 343df48cdf1f17801ca613b549e071780d8fc97b Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 26 Sep 2019 10:39:42 +0400
Subject: [PATCH 0217/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-11332
---
...atSomeAttributesChangedValueToEmptyAfterImportTest.xml | 8 --------
1 file changed, 8 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
index 50573faf9860a..af893b1e29e34 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
@@ -29,12 +29,10 @@
-
-
@@ -42,12 +40,10 @@
-
-
@@ -56,25 +52,21 @@
-
-
-
-
From 85bf559df58809ba8fda4e6947b0a633edf9c9b6 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 26 Sep 2019 11:23:29 +0400
Subject: [PATCH 0218/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6406
---
...tVisibilityDifferentStoreViewsAfterImportTest.xml | 12 +++---------
app/code/Magento/Store/Test/Mftf/Data/StoreData.xml | 9 ---------
2 files changed, 3 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
index 175a575acb188..fe7960324c0c3 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
@@ -22,10 +22,9 @@
-
-
+
@@ -34,7 +33,6 @@
-
@@ -42,9 +40,8 @@
-
-
+
@@ -52,14 +49,12 @@
-
-
@@ -70,9 +65,8 @@
-
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
index b0c3905c66dde..8198e87062e98 100644
--- a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
+++ b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
@@ -194,15 +194,6 @@
third_store_view
third_store_view
-
- 1
- English
- english
- 1
- null
- store
- add
-
1
Chinese
From 95373f6833a0bb8e507a4c3bccbd29b8c698805f Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 26 Sep 2019 11:36:35 +0400
Subject: [PATCH 0219/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6317
---
...nURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml | 4 ----
1 file changed, 4 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
index 42af7f67ca4ee..c395f607fb30a 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
@@ -21,7 +21,6 @@
-
@@ -30,20 +29,17 @@
-
-
-
From 5d730a109b61de6e0fb535aeddd752e01f1aa45c Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Thu, 26 Sep 2019 12:25:43 +0400
Subject: [PATCH 0220/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6416
---
.../ActionGroup/AdminImportProductsActionGroup.xml | 12 ------------
.../Test/AdminImportCSVWithSpecialCharactersTest.xml | 6 +++---
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
index faa66886178dd..9063916e9f502 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
@@ -60,16 +60,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
index f752cb3e7c908..38c1a09dc534c 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportCSVWithSpecialCharactersTest.xml
@@ -25,11 +25,11 @@
-
+
-
-
+
+
From b32f90fe98553ae259ca51bf2a3433f817cde8df Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Wed, 25 Sep 2019 13:38:47 +0300
Subject: [PATCH 0221/1978] MC-18824: Increase test coverage for Import /
export functional area
- Integration test for MC-6348 : CR comments fix.
---
.../Magento/CatalogImportExport/Model/Import/ProductTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index f62c84eea4057..ba5fa3816d0be 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -862,7 +862,7 @@ public function testSaveHiddenImages()
$hiddenImages = array_filter(
$images,
static function (DataObject $image) {
- return $image->getDisabled() == 1;
+ return $image->getDisabled() === 1;
}
);
From c4cf138b54ee21a936898bcbdb1fc34d8807c83b Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 30 Sep 2019 15:58:39 -0500
Subject: [PATCH 0222/1978] MC-18685: Remove custom layout updates from admin
---
.../Backend/AbstractLayoutUpdate.php | 23 ++--
.../Attribute/Backend/Customlayoutupdate.php | 12 +-
.../Attribute/Source/LayoutUpdate.php | 5 +-
.../Catalog/Model/Category/Authorization.php | 8 +-
.../Product/Attribute/Source/LayoutUpdate.php | 5 +-
.../Catalog/Model/Product/Authorization.php | 22 ++--
.../Controller/Adminhtml/CategoryTest.php | 26 ++++-
.../Controller/Adminhtml/ProductTest.php | 3 +
.../Backend/AbstractLayoutUpdateTest.php | 109 ++++++++++++++++++
.../Backend/CustomlayoutupdateTest.php | 34 ------
10 files changed, 177 insertions(+), 70 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
index 6aedd509af8e0..d5f1aeef5d913 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
@@ -19,6 +19,8 @@ abstract class AbstractLayoutUpdate extends AbstractBackend
{
public const VALUE_USE_UPDATE_XML = '__existing__';
+ public const VALUE_NO_UPDATE = '__no_update__';
+
/**
* Extract attribute value.
*
@@ -52,16 +54,11 @@ private function prepareValue(AbstractModel $model): ?string
$value = $this->extractAttributeValue($model);
if ($value
&& $value !== self::VALUE_USE_UPDATE_XML
+ && $value !== self::VALUE_NO_UPDATE
&& !in_array($value, $this->listAvailableValues($model), true)
) {
throw new LocalizedException(__('Selected layout update is not available'));
}
- if ($value === self::VALUE_USE_UPDATE_XML) {
- $value = null;
- }
- if (!$value) {
- $value = null;
- }
return $value;
}
@@ -71,11 +68,12 @@ private function prepareValue(AbstractModel $model): ?string
*
* @param string|null $value
* @param AbstractModel $forObject
+ * @param string|null $attrCode
* @return void
*/
- private function setAttributeValue(?string $value, AbstractModel $forObject): void
+ private function setAttributeValue(?string $value, AbstractModel $forObject, ?string $attrCode = null): void
{
- $attrCode = $this->getAttribute()->getAttributeCode();
+ $attrCode = $attrCode ?? $this->getAttribute()->getAttributeCode();
if ($forObject->hasData(AbstractModel::CUSTOM_ATTRIBUTES)) {
$forObject->setCustomAttribute($attrCode, $value);
}
@@ -104,7 +102,14 @@ public function validate($object)
*/
public function beforeSave($object)
{
- $this->setAttributeValue($this->prepareValue($object), $object);
+ $value = $this->prepareValue($object);
+ if ($value && ($value === self::VALUE_NO_UPDATE || $value !== self::VALUE_USE_UPDATE_XML)) {
+ $this->setAttributeValue(null, $object, 'custom_layout_update');
+ }
+ if (!$value || $value === self::VALUE_USE_UPDATE_XML || $value === self::VALUE_NO_UPDATE) {
+ $value = null;
+ }
+ $this->setAttributeValue($value, $object);
return $this;
}
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index d3cdb7c545cbc..f9a4473c2c93f 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -38,10 +38,9 @@ public function __construct(ValidatorFactory $layoutUpdateValidatorFactory)
* Extract an attribute value.
*
* @param AbstractModel $object
- * @param string|null $attributeCode
* @return mixed
*/
- private function extractValue(AbstractModel $object, ?string $attributeCode = null)
+ private function extractValue(AbstractModel $object)
{
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
$value = $object->getData($attributeCode);
@@ -98,14 +97,7 @@ public function beforeSave($object)
{
//Validate first, validation might have been skipped.
$this->validate($object);
- $value = $this->extractValue($object);
- //If custom file was selected we need to remove this attribute
- $file = $this->extractValue($object, 'custom_layout_update_file');
- if ($file && $file !== AbstractLayoutUpdate::VALUE_USE_UPDATE_XML) {
- $this->putValue($object, null);
- } else {
- $this->putValue($object, $value);
- }
+ $this->putValue($object, $this->extractValue($object));
return parent::beforeSave($object);
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index 648fe2c57290d..d3012b1b49587 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -13,6 +13,7 @@
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Framework\Api\CustomAttributesDataInterface;
+use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as Backend;
/**
* List of layout updates available for a category.
@@ -42,7 +43,7 @@ public function __construct(LayoutUpdateManager $manager)
*/
public function getAllOptions()
{
- $default = '';
+ $default = Backend::VALUE_NO_UPDATE;
$defaultText = 'No update';
$this->optionsText[$default] = $defaultText;
@@ -70,7 +71,7 @@ public function getOptionsFor(CustomAttributesDataInterface $entity): array
{
$options = $this->getAllOptions();
if ($entity->getCustomAttribute('custom_layout_update')) {
- $existingValue = \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
+ $existingValue = Backend::VALUE_USE_UPDATE_XML;
$existingLabel = 'Use existing';
$options[] = ['label' => $existingLabel, 'value' => $existingValue];
$this->optionsText[$existingValue] = $existingLabel;
diff --git a/app/code/Magento/Catalog/Model/Category/Authorization.php b/app/code/Magento/Catalog/Model/Category/Authorization.php
index 5529b067df3a9..984adaae387f4 100644
--- a/app/code/Magento/Catalog/Model/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Category/Authorization.php
@@ -11,10 +11,10 @@
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Catalog\Model\CategoryFactory;
-use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate;
/**
* Additional authorization for category operations.
@@ -63,7 +63,11 @@ private function hasChanges(CategoryModel $category, ?CategoryModel $oldCategory
$oldValues[] = $designAttribute->getDefaultValue();
}
$newValue = $category->getData($designAttribute->getAttributeCode());
- if (empty($newValue)) {
+ if (empty($newValue)
+ || ($designAttribute->getBackend() instanceof LayoutUpdate
+ && ($newValue === LayoutUpdate::VALUE_USE_UPDATE_XML || $newValue === LayoutUpdate::VALUE_NO_UPDATE)
+ )
+ ) {
$newValue = null;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index 78e29002beb25..467bbfc629020 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -12,6 +12,7 @@
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Framework\Api\CustomAttributesDataInterface;
+use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as Backend;
/**
* List of layout updates available for a product.
@@ -41,7 +42,7 @@ public function __construct(LayoutUpdateManager $manager)
*/
public function getAllOptions()
{
- $default = '';
+ $default = Backend::VALUE_NO_UPDATE;
$defaultText = 'No update';
$this->optionsText[$default] = $defaultText;
@@ -67,7 +68,7 @@ public function getOptionsFor(CustomAttributesDataInterface $entity): array
{
$options = $this->getAllOptions();
if ($entity->getCustomAttribute('custom_layout_update')) {
- $existingValue = \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
+ $existingValue = Backend::VALUE_USE_UPDATE_XML;
$existingLabel = 'Use existing';
$options[] = ['label' => $existingLabel, 'value' => $existingValue];
$this->optionsText[$existingValue] = $existingLabel;
diff --git a/app/code/Magento/Catalog/Model/Product/Authorization.php b/app/code/Magento/Catalog/Model/Product/Authorization.php
index 2500330e14968..41af459da9887 100644
--- a/app/code/Magento/Catalog/Model/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Product/Authorization.php
@@ -14,6 +14,7 @@
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate;
/**
* Additional authorization for product operations.
@@ -58,12 +59,13 @@ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProd
'custom_design_to',
'custom_layout_update_file'
];
- $attributes = null;
- if (!$oldProduct) {
- //For default values.
- $attributes = $product->getAttributes();
- }
+ $attributes = $product->getAttributes();
+
foreach ($designAttributes as $designAttribute) {
+ $attribute = $attributes[$designAttribute];
+ if (!array_key_exists($designAttribute, $attributes)) {
+ continue;
+ }
$oldValues = [null];
if ($oldProduct) {
//New value may only be the saved value
@@ -71,12 +73,16 @@ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProd
if (empty($oldValues[0])) {
$oldValues[0] = null;
}
- } elseif (array_key_exists($designAttribute, $attributes)) {
+ } else {
//New value can be empty or default
- $oldValues[] = $attributes[$designAttribute]->getDefaultValue();
+ $oldValues[] = $attribute->getDefaultValue();
}
$newValue = $product->getData($designAttribute);
- if (empty($newValue)) {
+ if (empty($newValue)
+ || ($attribute->getBackend() instanceof LayoutUpdate
+ && ($newValue === LayoutUpdate::VALUE_USE_UPDATE_XML || $newValue === LayoutUpdate::VALUE_NO_UPDATE)
+ )
+ ) {
$newValue = null;
}
if (!in_array($newValue, $oldValues, true)) {
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
index b1cbc1f544109..c6e1faadd1013 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/CategoryTest.php
@@ -628,7 +628,7 @@ public function testSaveDesign(): void
//Trying again with the permissions.
$requestData['custom_layout_update_file'] = null;
- $requestData['custom_design'] = 'test-theme';
+ $requestData['page_layout'] = '2columns-left';
$this->aclBuilder->getAcl()
->allow(null, ['Magento_Catalog::categories', 'Magento_Catalog::edit_category_design']);
$this->getRequest()->setDispatched(false);
@@ -639,8 +639,28 @@ public function testSaveDesign(): void
/** @var CategoryModel $category */
$category = $this->categoryFactory->create();
$category->load(2);
- $this->assertNotEmpty($category->getCustomDesign());
- $this->assertEquals('test-theme', $category->getCustomDesign());
+ $this->assertEquals('2columns-left', $category->getData('page_layout'));
+ //No new error messages
+ $this->assertSessionMessages(
+ self::equalTo($sessionMessages),
+ MessageInterface::TYPE_ERROR
+ );
+
+ //Trying to save special value without the permissions.
+ $requestData['custom_layout_update_file'] = CategoryModel\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
+ $requestData['description'] = 'test';
+ $this->aclBuilder->getAcl()->deny(null, ['Magento_Catalog::edit_category_design']);
+ $this->getRequest()->setDispatched(false);
+ $this->getRequest()->setPostValue($requestData);
+ $this->getRequest()->setParam('store', $requestData['store_id']);
+ $this->getRequest()->setParam('id', $requestData['id']);
+ $this->dispatch($uri);
+ /** @var CategoryModel $category */
+ $category = $this->categoryFactory->create();
+ $category->load(2);
+ $this->assertEquals('2columns-left', $category->getData('page_layout'));
+ $this->assertEmpty($category->getData('custom_layout_update_file'));
+ $this->assertEquals('test', $category->getData('description'));
//No new error messages
$this->assertSessionMessages(
self::equalTo($sessionMessages),
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index d6f82ccaea648..1f2569a6ffdb6 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Catalog\Controller\Adminhtml;
+use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate;
use Magento\Framework\Acl\Builder;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Message\Manager;
@@ -485,6 +486,8 @@ public function testSaveDesignWithDefaults(): void
//Updating product's design settings without proper permissions.
$this->aclBuilder->getAcl()->deny(null, 'Magento_Catalog::edit_product_design');
+ //Testing that special "No Update" value is treated as no change.
+ $requestData['product']['custom_layout_update_file'] = LayoutUpdate::VALUE_NO_UPDATE;
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($requestData);
$this->dispatch($uri);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php
new file mode 100644
index 0000000000000..b4022dc147b36
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php
@@ -0,0 +1,109 @@
+category = $this->categoryFactory->create();
+ $this->category->load(2);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ protected function setUp()
+ {
+ $this->categoryFactory = Bootstrap::getObjectManager()->get(CategoryFactory::class);
+ $this->recreateCategory();
+ $this->attribute = $this->category->getAttributes()['custom_layout_update_file']->getBackend();
+ $this->layoutManager = Bootstrap::getObjectManager()->get(CategoryLayoutUpdateManager::class);
+ }
+
+ /**
+ * Check that custom layout update file's values erase the old attribute's value.
+ *
+ * @return void
+ * @throws \Throwable
+ */
+ public function testDependsOnNewUpdate(): void
+ {
+ //New selected file value is set
+ $this->layoutManager->setCategoryFakeFiles(2, ['new']);
+ $this->category->setCustomAttribute('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setCustomAttribute('custom_layout_update_file', 'new');
+ $this->attribute->beforeSave($this->category);
+ $this->assertEmpty($this->category->getCustomAttribute('custom_layout_update')->getValue());
+ $this->assertEquals('new', $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
+ $this->assertEmpty($this->category->getData('custom_layout_update'));
+ $this->assertEquals('new', $this->category->getData('custom_layout_update_file'));
+
+ //Existing update chosen
+ $this->recreateCategory();
+ $this->category->setData('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setData(
+ 'custom_layout_update_file',
+ \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML
+ );
+ $this->attribute->beforeSave($this->category);
+ $this->assertEquals('test', $this->category->getData('custom_layout_update'));
+ /** @var AbstractBackend $fileAttribute */
+ $fileAttribute = $this->category->getAttributes()['custom_layout_update_file']->getBackend();
+ $fileAttribute->beforeSave($this->category);
+ $this->assertEquals(null, $this->category->getData('custom_layout_update_file'));
+
+ //Removing custom layout update by explicitly selecting the new file (or an empty file).
+ $this->recreateCategory();
+ $this->category->setData('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setData(
+ 'custom_layout_update_file',
+ \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_NO_UPDATE
+ );
+ $this->attribute->beforeSave($this->category);
+ $this->assertEmpty($this->category->getData('custom_layout_update'));
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index 7447950ea2ab6..a340094b01040 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -95,38 +95,4 @@ public function testImmutable(): void
$this->attribute->beforeSave($this->category);
$this->assertNull($this->category->getCustomAttribute('custom_layout_update')->getValue());
}
-
- /**
- * Check that custom layout update file's values erase the old attribute's value.
- *
- * @return void
- * @throws \Throwable
- */
- public function testDependsOnNewUpdate(): void
- {
- //New selected file value is set
- $this->category->setCustomAttribute('custom_layout_update', 'test');
- $this->category->setOrigData('custom_layout_update', 'test');
- $this->category->setCustomAttribute('custom_layout_update_file', 'new');
- $this->attribute->beforeSave($this->category);
- $this->assertEmpty($this->category->getCustomAttribute('custom_layout_update')->getValue());
- $this->assertEquals('new', $this->category->getCustomAttribute('custom_layout_update_file')->getValue());
- $this->assertEmpty($this->category->getData('custom_layout_update'));
- $this->assertEquals('new', $this->category->getData('custom_layout_update_file'));
-
- //Existing update chosen
- $this->recreateCategory();
- $this->category->setData('custom_layout_update', 'test');
- $this->category->setOrigData('custom_layout_update', 'test');
- $this->category->setData(
- 'custom_layout_update_file',
- \Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML
- );
- $this->attribute->beforeSave($this->category);
- $this->assertEquals('test', $this->category->getData('custom_layout_update'));
- /** @var AbstractBackend $fileAttribute */
- $fileAttribute = $this->category->getAttributes()['custom_layout_update_file']->getBackend();
- $fileAttribute->beforeSave($this->category);
- $this->assertEquals(null, $this->category->getData('custom_layout_update_file'));
- }
}
From 502d526817e431706eeca656e3b92edcda75b174 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 30 Sep 2019 19:42:41 -0500
Subject: [PATCH 0223/1978] MC-18685: Remove custom layout updates from admin
---
.../Backend/AbstractLayoutUpdate.php | 3 +
.../Attribute/Backend/Customlayoutupdate.php | 2 +-
.../Catalog/Model/Category/Authorization.php | 90 +++++++++++++-----
.../Catalog/Model/Product/Authorization.php | 91 ++++++++++++++-----
.../Catalog/Api/CategoryRepositoryTest.php | 15 ++-
.../Api/ProductRepositoryInterfaceTest.php | 16 +++-
.../Backend/AbstractLayoutUpdateTest.php | 12 +++
.../Backend/CustomlayoutupdateTest.php | 2 +-
.../Model/Category/DataProviderTest.php | 12 ++-
.../Form/Modifier/LayoutUpdateTest.php | 12 ++-
10 files changed, 196 insertions(+), 59 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
index d5f1aeef5d913..1aa7ab7e5880f 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdate.php
@@ -52,6 +52,9 @@ abstract protected function listAvailableValues(AbstractModel $forModel): array;
private function prepareValue(AbstractModel $model): ?string
{
$value = $this->extractAttributeValue($model);
+ if (!is_string($value)) {
+ $value = null;
+ }
if ($value
&& $value !== self::VALUE_USE_UPDATE_XML
&& $value !== self::VALUE_NO_UPDATE
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index f9a4473c2c93f..759bdb54439b6 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -44,7 +44,7 @@ private function extractValue(AbstractModel $object)
{
$attributeCode = $attributeCode ?? $this->getAttribute()->getName();
$value = $object->getData($attributeCode);
- if (!$value) {
+ if (!$value || !is_string($value)) {
$value = null;
}
diff --git a/app/code/Magento/Catalog/Model/Category/Authorization.php b/app/code/Magento/Catalog/Model/Category/Authorization.php
index 984adaae387f4..407ce2c045b25 100644
--- a/app/code/Magento/Catalog/Model/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Category/Authorization.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Catalog\Model\CategoryFactory;
+use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -41,6 +42,61 @@ public function __construct(AuthorizationInterface $authorization, CategoryFacto
$this->categoryFactory = $factory;
}
+ /**
+ * Extract attribute value from the model.
+ *
+ * @param CategoryModel $category
+ * @param AttributeInterface $attr
+ * @throws \RuntimeException When no new value is present.
+ * @return mixed
+ */
+ private function extractAttributeValue(CategoryModel $category, AttributeInterface $attr)
+ {
+ if ($category->hasData($attr->getAttributeCode())) {
+ $newValue = $category->getData($attr->getAttributeCode());
+ } elseif ($category->hasData(CategoryModel::CUSTOM_ATTRIBUTES)
+ && $attrValue = $category->getCustomAttribute($attr->getAttributeCode())
+ ) {
+ $newValue = $attrValue->getValue();
+ } else {
+ throw new \RuntimeException('New value is not set');
+ }
+
+ if (empty($newValue)
+ || ($attr->getBackend() instanceof LayoutUpdate
+ && ($newValue === LayoutUpdate::VALUE_USE_UPDATE_XML || $newValue === LayoutUpdate::VALUE_NO_UPDATE)
+ )
+ ) {
+ $newValue = null;
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Find values to compare the new one.
+ *
+ * @param AttributeInterface $attribute
+ * @param CategoryModel|null $oldCategory
+ * @return mixed[]
+ */
+ private function fetchOldValue(AttributeInterface $attribute, ?CategoryModel $oldCategory): array
+ {
+ $oldValues = [null];
+ if ($oldCategory) {
+ //New value must match saved value exactly
+ $oldValues = [$oldCategory->getData($attribute->getAttributeCode())];
+ if (empty($oldValues[0])) {
+ $oldValues[0] = null;
+ }
+ } else {
+ //New value can be either empty or default value.
+ $oldValues[] = $attribute->getDefaultValue();
+ }
+
+ return $oldValues;
+ }
+
/**
* Determine whether a category has design properties changed.
*
@@ -51,24 +107,12 @@ public function __construct(AuthorizationInterface $authorization, CategoryFacto
private function hasChanges(CategoryModel $category, ?CategoryModel $oldCategory): bool
{
foreach ($category->getDesignAttributes() as $designAttribute) {
- $oldValues = [null];
- if ($oldCategory) {
- //New value must match saved value exactly
- $oldValues = [$oldCategory->getData($designAttribute->getAttributeCode())];
- if (empty($oldValues[0])) {
- $oldValues[0] = null;
- }
- } else {
- //New value can be either empty or default value.
- $oldValues[] = $designAttribute->getDefaultValue();
- }
- $newValue = $category->getData($designAttribute->getAttributeCode());
- if (empty($newValue)
- || ($designAttribute->getBackend() instanceof LayoutUpdate
- && ($newValue === LayoutUpdate::VALUE_USE_UPDATE_XML || $newValue === LayoutUpdate::VALUE_NO_UPDATE)
- )
- ) {
- $newValue = null;
+ $oldValues = $this->fetchOldValue($designAttribute, $oldCategory);
+ try {
+ $newValue = $this->extractAttributeValue($category, $designAttribute);
+ } catch (\RuntimeException $exception) {
+ //No new value
+ continue;
}
if (!in_array($newValue, $oldValues, true)) {
@@ -94,9 +138,13 @@ public function authorizeSavingOf(CategoryInterface $category): void
if ($category->getId()) {
/** @var CategoryModel $savedCategory */
$savedCategory = $this->categoryFactory->create();
- $savedCategory->load($category->getId());
- if (!$savedCategory->getName()) {
- throw NoSuchEntityException::singleField('id', $category->getId());
+ if ($category->getOrigData()) {
+ $savedCategory->setData($category->getOrigData());
+ } else {
+ $savedCategory->load($category->getId());
+ if (!$savedCategory->getName()) {
+ throw NoSuchEntityException::singleField('id', $category->getId());
+ }
}
}
diff --git a/app/code/Magento/Catalog/Model/Product/Authorization.php b/app/code/Magento/Catalog/Model/Product/Authorization.php
index 41af459da9887..13147d5787bd1 100644
--- a/app/code/Magento/Catalog/Model/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Product/Authorization.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product as ProductModel;
use Magento\Catalog\Model\ProductFactory;
+use Magento\Eav\Api\Data\AttributeInterface;
use Magento\Framework\AuthorizationInterface;
use Magento\Framework\Exception\AuthorizationException;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -41,6 +42,60 @@ public function __construct(AuthorizationInterface $authorization, ProductFactor
$this->productFactory = $factory;
}
+ /**
+ * Extract attribute value from the model.
+ *
+ * @param ProductModel $product
+ * @param AttributeInterface $attr
+ * @return mixed
+ * @throws \RuntimeException When no new value is present.
+ */
+ private function extractAttributeValue(ProductModel $product, AttributeInterface $attr)
+ {
+ if ($product->hasData($attr->getAttributeCode())) {
+ $newValue = $product->getData($attr->getAttributeCode());
+ } elseif ($product->hasData(ProductModel::CUSTOM_ATTRIBUTES)
+ && $attrValue = $product->getCustomAttribute($attr->getAttributeCode())
+ ) {
+ $newValue = $attrValue->getValue();
+ } else {
+ throw new \RuntimeException('No new value is present');
+ }
+
+ if (empty($newValue)
+ || ($attr->getBackend() instanceof LayoutUpdate
+ && ($newValue === LayoutUpdate::VALUE_USE_UPDATE_XML || $newValue === LayoutUpdate::VALUE_NO_UPDATE)
+ )
+ ) {
+ $newValue = null;
+ }
+
+ return $newValue;
+ }
+
+ /**
+ * Prepare old values to compare to.
+ *
+ * @param AttributeInterface $attribute
+ * @param ProductModel|null $oldProduct
+ * @return array
+ */
+ private function fetchOldValues(AttributeInterface $attribute, ?ProductModel $oldProduct): array
+ {
+ if ($oldProduct) {
+ //New value may only be the saved value
+ $oldValues = [$oldProduct->getData($attribute->getAttributeCode())];
+ if (empty($oldValues[0])) {
+ $oldValues[0] = null;
+ }
+ } else {
+ //New value can be empty or default
+ $oldValues[] = $attribute->getDefaultValue();
+ }
+
+ return $oldValues;
+ }
+
/**
* Check whether the product has changed.
*
@@ -62,28 +117,16 @@ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProd
$attributes = $product->getAttributes();
foreach ($designAttributes as $designAttribute) {
- $attribute = $attributes[$designAttribute];
if (!array_key_exists($designAttribute, $attributes)) {
continue;
}
- $oldValues = [null];
- if ($oldProduct) {
- //New value may only be the saved value
- $oldValues = [$oldProduct->getData($designAttribute)];
- if (empty($oldValues[0])) {
- $oldValues[0] = null;
- }
- } else {
- //New value can be empty or default
- $oldValues[] = $attribute->getDefaultValue();
- }
- $newValue = $product->getData($designAttribute);
- if (empty($newValue)
- || ($attribute->getBackend() instanceof LayoutUpdate
- && ($newValue === LayoutUpdate::VALUE_USE_UPDATE_XML || $newValue === LayoutUpdate::VALUE_NO_UPDATE)
- )
- ) {
- $newValue = null;
+ $attribute = $attributes[$designAttribute];
+ $oldValues = $this->fetchOldValues($attribute, $oldProduct);
+ try {
+ $newValue = $this->extractAttributeValue($product, $attribute);
+ } catch (\RuntimeException $exception) {
+ //No new value
+ continue;
}
if (!in_array($newValue, $oldValues, true)) {
return true;
@@ -108,9 +151,13 @@ public function authorizeSavingOf(ProductInterface $product): void
if ($product->getId()) {
/** @var ProductModel $savedProduct */
$savedProduct = $this->productFactory->create();
- $savedProduct->load($product->getId());
- if (!$savedProduct->getSku()) {
- throw NoSuchEntityException::singleField('id', $product->getId());
+ if ($product->getOrigData()) {
+ $savedProduct->setData($product->getOrigData());
+ } else {
+ $savedProduct->load($product->getId());
+ if (!$savedProduct->getSku()) {
+ throw NoSuchEntityException::singleField('id', $product->getId());
+ }
}
}
if ($this->hasProductChanged($product, $savedProduct)) {
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
index e0c45967b214e..d614f6e913dc5 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/CategoryRepositoryTest.php
@@ -423,16 +423,21 @@ public function testSaveDesign(): void
//Updating our role to remove design properties access.
$this->updateRoleResources($roleName, ['Magento_Catalog::categories']);
//Updating the category but with the same design properties values.
+ //Omitting existing design attribute and keeping it's existing value
+ $attributes = $categoryData['custom_attributes'];
+ foreach ($attributes as $index => $attrData) {
+ if ($attrData['attribute_code'] === 'custom_design') {
+ unset($categoryData['custom_attributes'][$index]);
+ break;
+ }
+ }
+ unset($attributes, $index, $attrData);
$result = $this->updateCategory($categoryData['id'], $categoryData, $token);
//We haven't changed the design so operation is successful.
$this->assertArrayHasKey('id', $result);
//Changing a design property.
- foreach ($categoryData['custom_attributes'] as &$customAttribute) {
- if ($customAttribute['attribute_code'] === 'custom_design') {
- $customAttribute['value'] = 'test2';
- }
- }
+ $categoryData['custom_attributes'][] = ['attribute_code' => 'custom_design', 'value' => 'test2'];
$exceptionMessage = null;
try {
$this->updateCategory($categoryData['id'], $categoryData, $token);
diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
index c5014ed391fb3..cde593c9fad2b 100644
--- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php
@@ -1678,6 +1678,7 @@ public function testSaveDesign(): void
foreach ($productSaved['custom_attributes'] as $customAttribute) {
if ($customAttribute['attribute_code'] === 'custom_design') {
$savedCustomDesign = $customAttribute['value'];
+ break;
}
}
$this->assertEquals('1', $savedCustomDesign);
@@ -1690,16 +1691,21 @@ public function testSaveDesign(): void
$rules->setResources(['Magento_Catalog::products']);
$rules->saveRel();
//Updating the product but with the same design properties values.
+ //Removing the design attribute and keeping existing value.
+ $attributes = $productData['custom_attributes'];
+ foreach ($attributes as $i => $attribute) {
+ if ($attribute['attribute_code'] === 'custom_design') {
+ unset($productData['custom_attributes'][$i]);
+ break;
+ }
+ }
+ unset($attributes, $attribute, $i);
$result = $this->updateProduct($productData, $token);
//We haven't changed the design so operation is successful.
$this->assertArrayHasKey('id', $result);
//Changing a design property.
- foreach ($productData['custom_attributes'] as &$customAttribute) {
- if ($customAttribute['attribute_code'] === 'custom_design') {
- $customAttribute['value'] = '2';
- }
- }
+ $productData['custom_attributes'][] = ['attribute_code' => 'custom_design', 'value' => '2'];
$exceptionMessage = null;
try {
$this->updateProduct($productData, $token);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php
index b4022dc147b36..40725d3ee58be 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/AbstractLayoutUpdateTest.php
@@ -105,5 +105,17 @@ public function testDependsOnNewUpdate(): void
);
$this->attribute->beforeSave($this->category);
$this->assertEmpty($this->category->getData('custom_layout_update'));
+
+ //Empty value doesn't change the old attribute. Any non-string value can be used to represent an empty value.
+ $this->recreateCategory();
+ $this->category->setData('custom_layout_update', 'test');
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setData(
+ 'custom_layout_update_file',
+ false
+ );
+ $this->attribute->beforeSave($this->category);
+ $this->assertEquals('test', $this->category->getData('custom_layout_update'));
+ $this->assertNull($this->category->getData('custom_layout_update_file'));
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index a340094b01040..308a577a6aa6f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -65,7 +65,7 @@ protected function setUp()
public function testImmutable(): void
{
//Value is empty
- $this->category->setCustomAttribute('custom_layout_update', null);
+ $this->category->setCustomAttribute('custom_layout_update', false);
$this->category->setOrigData('custom_layout_update', null);
$this->attribute->beforeSave($this->category);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
index 49cba292f974a..6d66055cd1548 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Category/DataProviderTest.php
@@ -186,7 +186,11 @@ public function testCustomLayoutMeta(): void
$meta = $this->dataProvider->getMeta();
$list = $this->extractCustomLayoutOptions($meta);
$expectedList = [
- ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ [
+ 'label' => 'No update',
+ 'value' => \Magento\Catalog\Model\Attribute\Backend\AbstractLayoutUpdate::VALUE_NO_UPDATE,
+ '__disableTmpl' => true
+ ],
['label' => 'test1', 'value' => 'test1', '__disableTmpl' => true],
['label' => 'test2', 'value' => 'test2', '__disableTmpl' => true]
];
@@ -200,7 +204,11 @@ public function testCustomLayoutMeta(): void
$meta = $this->dataProvider->getMeta();
$expectedList = [
- ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ [
+ 'label' => 'No update',
+ 'value' => \Magento\Catalog\Model\Attribute\Backend\AbstractLayoutUpdate::VALUE_NO_UPDATE,
+ '__disableTmpl' => true
+ ],
[
'label' => 'Use existing',
'value' => LayoutUpdate::VALUE_USE_UPDATE_XML,
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
index 4a928fb1386c0..ebfbd06d7edad 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdateTest.php
@@ -149,7 +149,11 @@ public function testEntitySpecificData(): void
$meta = $this->eavModifier->modifyMeta([]);
$list = $this->extractCustomLayoutOptions($meta);
$expectedList = [
- ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ [
+ 'label' => 'No update',
+ 'value' => \Magento\Catalog\Model\Attribute\Backend\AbstractLayoutUpdate::VALUE_NO_UPDATE,
+ '__disableTmpl' => true
+ ],
['label' => 'testOne', 'value' => 'testOne', '__disableTmpl' => true],
['label' => 'test_two', 'value' => 'test_two', '__disableTmpl' => true]
];
@@ -164,7 +168,11 @@ public function testEntitySpecificData(): void
$meta = $this->eavModifier->modifyMeta([]);
$list = $this->extractCustomLayoutOptions($meta);
$expectedList = [
- ['label' => 'No update', 'value' => '', '__disableTmpl' => true],
+ [
+ 'label' => 'No update',
+ 'value' => \Magento\Catalog\Model\Attribute\Backend\AbstractLayoutUpdate::VALUE_NO_UPDATE,
+ '__disableTmpl' => true
+ ],
[
'label' => 'Use existing',
'value' => LayoutUpdateAttribute::VALUE_USE_UPDATE_XML,
From 6a418305949865eeb50d64ade70f87890c2a4a88 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 30 Sep 2019 20:00:43 -0500
Subject: [PATCH 0224/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Cms/Api/Data/PageInterface.php | 2 ++
.../Magento/Cms/Controller/Adminhtml/Page/Save.php | 1 +
app/code/Magento/Cms/Model/Page/DataProvider.php | 6 +++---
app/code/Magento/Cms/Model/PageRepository.php | 5 +++++
.../Cms/Controller/Adminhtml/PageDesignTest.php | 4 ++++
.../Magento/Cms/Model/PageRepositoryTest.php | 12 ++++++++++++
.../Magento/Cms/_files/pages_with_layout_xml.php | 1 +
7 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Cms/Api/Data/PageInterface.php b/app/code/Magento/Cms/Api/Data/PageInterface.php
index 38d8feb953319..7a31ab1b9a94f 100644
--- a/app/code/Magento/Cms/Api/Data/PageInterface.php
+++ b/app/code/Magento/Cms/Api/Data/PageInterface.php
@@ -125,6 +125,7 @@ public function getSortOrder();
* Get layout update xml
*
* @return string|null
+ * @deprecated Existing updates are applied, new are not accepted.
*/
public function getLayoutUpdateXml();
@@ -274,6 +275,7 @@ public function setSortOrder($sortOrder);
*
* @param string $layoutUpdateXml
* @return \Magento\Cms\Api\Data\PageInterface
+ * @deprecated Existing updates are applied, new are not accepted.
*/
public function setLayoutUpdateXml($layoutUpdateXml);
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 1e4896c449d59..38901c6c00dbe 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -102,6 +102,7 @@ public function execute()
$customLayoutFile = (string)$this->getRequest()->getParam('layout_update_selected');
if ($customLayoutFile !== '_existing_') {
$data['custom_layout_update_xml'] = null;
+ $data['layout_update_xml'] = null;
} else {
$customLayoutFile = null;
}
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
index d1f148fe0198a..b9fb05e0f39e4 100644
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ b/app/code/Magento/Cms/Model/Page/DataProvider.php
@@ -109,7 +109,7 @@ public function getData()
/** @var $page \Magento\Cms\Model\Page */
foreach ($items as $page) {
$this->loadedData[$page->getId()] = $page->getData();
- if ($page->getCustomLayoutUpdateXml()) {
+ if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
//Deprecated layout update exists.
$this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_';
}
@@ -120,7 +120,7 @@ public function getData()
$page = $this->collection->getNewEmptyItem();
$page->setData($data);
$this->loadedData[$page->getId()] = $page->getData();
- if ($page->getCustomLayoutUpdateXml()) {
+ if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
$this->loadedData[$page->getId()]['layout_update_selected'] = '_existing_';
}
$this->dataPersistor->clear('cms_page');
@@ -175,7 +175,7 @@ public function getMeta()
}
//If custom layout XML is set then displaying this special option.
if ($found) {
- if ($found->getCustomLayoutUpdateXml()) {
+ if ($found->getCustomLayoutUpdateXml() || $found->getLayoutUpdateXml()) {
$options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
}
foreach ($this->customLayoutManager->fetchAvailableFiles($found) as $layoutFile) {
diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php
index 4492ea55da3a2..b555123af8967 100644
--- a/app/code/Magento/Cms/Model/PageRepository.php
+++ b/app/code/Magento/Cms/Model/PageRepository.php
@@ -136,6 +136,11 @@ public function save(\Magento\Cms\Api\Data\PageInterface $page)
) {
throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
}
+ if ($page->getLayoutUpdateXml()
+ && (!$savedPage || $page->getLayoutUpdateXml() !== $savedPage->getLayoutUpdateXml())
+ ) {
+ throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
+ }
$this->resource->save($page);
$this->identityMap->add($page);
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
index a13dc4e1f200b..ab0a5aa72f35e 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
@@ -173,6 +173,7 @@ public function testSaveLayoutXml(): void
PageInterface::IDENTIFIER => 'test_custom_layout_page_1',
PageInterface::TITLE => 'Page title',
PageInterface::CUSTOM_LAYOUT_UPDATE_XML => $page->getCustomLayoutUpdateXml(),
+ PageInterface::LAYOUT_UPDATE_XML => $page->getLayoutUpdateXml(),
'layout_update_selected' => '_existing_'
];
@@ -183,12 +184,14 @@ public function testSaveLayoutXml(): void
$updated = $this->pageRetriever->execute('test_custom_layout_page_1', 0);
$this->assertEquals($updated->getCustomLayoutUpdateXml(), $page->getCustomLayoutUpdateXml());
+ $this->assertEquals($updated->getLayoutUpdateXml(), $page->getLayoutUpdateXml());
$requestData = [
Page::PAGE_ID => $page->getId(),
PageInterface::IDENTIFIER => 'test_custom_layout_page_1',
PageInterface::TITLE => 'Page title',
PageInterface::CUSTOM_LAYOUT_UPDATE_XML => $page->getCustomLayoutUpdateXml(),
+ PageInterface::LAYOUT_UPDATE_XML => $page->getLayoutUpdateXml(),
'layout_update_selected' => ''
];
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
@@ -198,5 +201,6 @@ public function testSaveLayoutXml(): void
$updated = $this->pageRetriever->execute('test_custom_layout_page_1', 0);
$this->assertEmpty($updated->getCustomLayoutUpdateXml());
+ $this->assertEmpty($updated->getLayoutUpdateXml());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
index 5bbb8b870aad5..145830ab08259 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
@@ -63,9 +63,21 @@ public function testSaveUpdateXml(): void
}
$this->assertTrue($forbidden);
+ //New value is not accepted.
+ $page->setLayoutUpdateXml($page->getLayoutUpdateXml() .'TEST');
+ $forbidden = false;
+ try {
+ $page = $this->repo->save($page);
+ } catch (CouldNotSaveException $exception) {
+ $forbidden = true;
+ }
+ $this->assertTrue($forbidden);
+
//Can be removed
$page->setCustomLayoutUpdateXml(null);
+ $page->setLayoutUpdateXml(null);
$page = $this->repo->save($page);
$this->assertEmpty($page->getCustomLayoutUpdateXml());
+ $this->assertEmpty($page->getLayoutUpdateXml());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
index 80f0c8757a579..550b40a1bfec6 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
@@ -17,6 +17,7 @@
$page->setIdentifier('test_custom_layout_page_1');
$page->setTitle('Test Page');
$page->setCustomLayoutUpdateXml('tst');
+$page->setLayoutUpdateXml('tst_current');
$page->setIsActive(true);
$page->setStoreId(0);
$page->save();
From 8caaf36696dd84c2b75771368f306e1ec4fc7671 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 1 Oct 2019 09:01:59 +0300
Subject: [PATCH 0225/1978] MC-18165: Quick search with two chars shows all
products
---
.../Model/ResourceModel/Fulltext/CollectionTest.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php
index 3f70b329c5693..8863834078214 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogSearch/Model/ResourceModel/Fulltext/CollectionTest.php
@@ -50,6 +50,9 @@ public function testLoadWithFilterQuickSearch($filters, $expectedCount)
foreach ($filters as $field => $value) {
$fulltextCollection->addFieldToFilter($field, $value);
}
+ if (isset($filters['search_term'])) {
+ $fulltextCollection->addSearchFilter($filters['search_term']);
+ }
$fulltextCollection->loadWithFilter();
$items = $fulltextCollection->getItems();
$this->assertCount($expectedCount, $items);
From 867a00c5e14e052177204182225a93aa0d34c501 Mon Sep 17 00:00:00 2001
From: Nikita Shcherbatykh
Date: Tue, 1 Oct 2019 10:13:28 +0300
Subject: [PATCH 0226/1978] MC-19031: Sorting the product grid by custom
product attribute sorts by value ID instead of Alphabetically
---
.../Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml
index b0832b8f5944c..72c270aad585c 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductGridFilteringByCustomAttributeTest.xml
@@ -92,6 +92,7 @@
+
From f255faefc34b9b7a70c74da407401af93d5ff554 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Tue, 1 Oct 2019 10:01:26 +0300
Subject: [PATCH 0227/1978] MC-20624: Automate MC-11459
---
.../_files/import_export/customers.php | 34 ++---
.../import_export/customers_rollback.php | 36 +++++
.../Model/Export/CustomerTest.php | 142 ++++++++++--------
3 files changed, 129 insertions(+), 83 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers.php b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers.php
index 2f9c3dc31ef3d..9b989779e4cbd 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers.php
@@ -3,16 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-$customers = [];
-$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Customer\Model\Customer::class
-);
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Customer\Model\Customer;
+use Magento\Framework\Registry;
+
+/** @var $objectManager ObjectManagerInterface */
+$objectManager = Bootstrap::getObjectManager();
+
+$customers = [];
+$customer = $objectManager->create(Customer::class);
$customer->setWebsiteId(
1
-)->setEntityId(
- 1
)->setEntityTypeId(
1
)->setAttributeSetId(
@@ -40,13 +44,9 @@
$customer->save();
$customers[] = $customer;
-$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Customer\Model\Customer::class
-);
+$customer = $objectManager->create(Customer::class);
$customer->setWebsiteId(
1
-)->setEntityId(
- 2
)->setEntityTypeId(
1
)->setAttributeSetId(
@@ -74,13 +74,9 @@
$customer->save();
$customers[] = $customer;
-$customer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Customer\Model\Customer::class
-);
+$customer = $objectManager->create(Customer::class);
$customer->setWebsiteId(
1
-)->setEntityId(
- 3
)->setEntityTypeId(
1
)->setAttributeSetId(
@@ -108,9 +104,7 @@
$customer->save();
$customers[] = $customer;
-/** @var $objectManager \Magento\TestFramework\ObjectManager */
-$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-$objectManager->get(\Magento\Framework\Registry::class)
+$objectManager->get(Registry::class)
->unregister('_fixture/Magento_ImportExport_Customer_Collection');
-$objectManager->get(\Magento\Framework\Registry::class)
+$objectManager->get(Registry::class)
->register('_fixture/Magento_ImportExport_Customer_Collection', $customers);
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php
new file mode 100644
index 0000000000000..4630236c17b06
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php
@@ -0,0 +1,36 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var $customer Customer */
+$customer = $objectManager->create(Customer::class);
+
+$emailsToDelete = [
+ 'customer@example.com',
+ 'julie.worrell@example.com',
+ 'david.lamar@example.com',
+];
+foreach ($emailsToDelete as $email) {
+ try {
+ $customer->loadByEmail($email)->delete();
+ } catch (\Exception $e) {
+ }
+}
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
index 88b748f8bbbae..7cde07675ae27 100644
--- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
+++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
@@ -4,48 +4,61 @@
* See COPYING.txt for license details.
*/
-/**
- * Test for customer export model
- */
namespace Magento\CustomerImportExport\Model\Export;
+use Magento\Framework\Registry;
+use Magento\Customer\Model\Attribute;
+use Magento\ImportExport\Model\Export;
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\ImportExport\Model\Export\Adapter\Csv;
+use Magento\Customer\Model\Customer as CustomerModel;
+use Magento\CustomerImportExport\Model\Export\Customer;
+use Magento\Customer\Model\ResourceModel\Attribute\Collection;
+use Magento\Customer\Model\ResourceModel\Customer\Collection as CustomerCollection;
+
+/**
+ * Tests for customer export model.
+ */
class CustomerTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var \Magento\CustomerImportExport\Model\Export\Customer
+ * @var Customer
*/
protected $_model;
+ /**
+ * @var ObjectManagerInterface
+ */
+ private $objectManager;
+
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
- $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\CustomerImportExport\Model\Export\Customer::class
- );
+ $this->objectManager = Bootstrap::getObjectManager();
+ $this->_model = $this->objectManager->create(Customer::class);
}
/**
- * Test export method
+ * Export "Customer Main File".
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
*/
public function testExport()
{
$expectedAttributes = [];
- /** @var $collection \Magento\Customer\Model\ResourceModel\Attribute\Collection */
- $collection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Customer\Model\ResourceModel\Attribute\Collection::class
- );
- /** @var $attribute \Magento\Customer\Model\Attribute */
+ /** @var $collection Collection */
+ $collection = $this->objectManager->create(Collection::class);
+ /** @var $attribute Attribute */
foreach ($collection as $attribute) {
$expectedAttributes[] = $attribute->getAttributeCode();
}
$expectedAttributes = array_diff($expectedAttributes, $this->_model->getDisabledAttributes());
- $this->_model->setWriter(
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\ImportExport\Model\Export\Adapter\Csv::class
- )
- );
+ $this->_model->setWriter($this->objectManager->get(Csv::class));
$data = $this->_model->export();
$this->assertNotEmpty($data);
@@ -54,32 +67,45 @@ public function testExport()
$this->assertEquals(
count($expectedAttributes),
count(array_intersect($expectedAttributes, $lines['header'])),
- 'Expected attribute codes were not exported'
+ 'Expected attribute codes were not exported.'
);
- $this->assertNotEmpty($lines['data'], 'No data was exported');
-
- /** @var $objectManager \Magento\TestFramework\ObjectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- /** @var $customers \Magento\Customer\Model\Customer[] */
- $customers = $objectManager->get(
- \Magento\Framework\Registry::class
- )->registry(
- '_fixture/Magento_ImportExport_Customer_Collection'
- );
- foreach ($customers as $key => $customer) {
- foreach ($expectedAttributes as $code) {
- if (!in_array($code, $this->_model->getDisabledAttributes()) && isset($lines[$key][$code])) {
- $this->assertEquals(
- $customer->getData($code),
- $lines[$key][$code],
- 'Attribute "' . $code . '" is not equal'
- );
+ $this->assertNotEmpty($lines['data'], 'No data was exported.');
+
+ /** @var $customers CustomerModel[] */
+ $customers = $this->objectManager->create(CustomerCollection::class)->getItems();
+ foreach ($customers as $customer) {
+ $data = $customer->getData();
+ $exportData = $lines['data'][$data['email']];
+ $exportData = $this->unsetDuplicateData($exportData);
+ array_walk(
+ $exportData,
+ function (&$value) {
+ if (is_string($value) && $value === '') {
+ $value = null;
+ }
}
- }
+ );
+
+ $this->assertArraySubset($exportData, $data);
}
}
+ /**
+ * Unset non-useful or duplicate data from exported file data.
+ *
+ * @param array $data
+ * @return array
+ */
+ private function unsetDuplicateData(array $data): array
+ {
+ unset($data['_website']);
+ unset($data['_store']);
+ unset($data['password']);
+
+ return $data;
+ }
+
/**
* Test entity type code value
*/
@@ -93,10 +119,7 @@ public function testGetEntityTypeCode()
*/
public function testGetAttributeCollection()
{
- $this->assertInstanceOf(
- \Magento\Customer\Model\ResourceModel\Attribute\Collection::class,
- $this->_model->getAttributeCollection()
- );
+ $this->assertInstanceOf(Collection::class, $this->_model->getAttributeCollection());
}
/**
@@ -104,14 +127,14 @@ public function testGetAttributeCollection()
*/
public function testFilterAttributeCollection()
{
- /** @var $collection \Magento\Customer\Model\ResourceModel\Attribute\Collection */
+ /** @var $collection Collection */
$collection = $this->_model->getAttributeCollection();
$collection = $this->_model->filterAttributeCollection($collection);
/**
* Check that disabled attributes is not existed in attribute collection
*/
$existedAttributes = [];
- /** @var $attribute \Magento\Customer\Model\Attribute */
+ /** @var $attribute Attribute */
foreach ($collection as $attribute) {
$existedAttributes[] = $attribute->getAttributeCode();
}
@@ -127,7 +150,7 @@ public function testFilterAttributeCollection()
* Check that all overridden attributes were affected during filtering process
*/
$overriddenAttributes = $this->_model->getOverriddenAttributes();
- /** @var $attribute \Magento\Customer\Model\Attribute */
+ /** @var $attribute Attribute */
foreach ($collection as $attribute) {
if (isset($overriddenAttributes[$attribute->getAttributeCode()])) {
foreach ($overriddenAttributes[$attribute->getAttributeCode()] as $propertyKey => $property) {
@@ -150,27 +173,22 @@ public function testFilterEntityCollection()
{
$createdAtDate = '2038-01-01';
- /** @var $objectManager \Magento\TestFramework\ObjectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+ /** @var $objectManager ObjectManagerInterface */
+ $objectManager = $this->objectManager;
/**
* Change created_at date of first customer for future filter test.
*/
- $customers = $objectManager->get(
- \Magento\Framework\Registry::class
- )->registry(
- '_fixture/Magento_ImportExport_Customer_Collection'
- );
+ $customers = $objectManager->get(Registry::class)
+ ->registry('_fixture/Magento_ImportExport_Customer_Collection');
$customers[0]->setCreatedAt($createdAtDate);
$customers[0]->save();
/**
* Change type of created_at attribute. In this case we have possibility to test date rage filter
*/
- $attributeCollection = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Customer\Model\ResourceModel\Attribute\Collection::class
- );
+ $attributeCollection = $this->objectManager->create(Collection::class);
$attributeCollection->addFieldToFilter('attribute_code', 'created_at');
- /** @var $createdAtAttribute \Magento\Customer\Model\Attribute */
+ /** @var $createdAtAttribute Attribute */
$createdAtAttribute = $attributeCollection->getFirstItem();
$createdAtAttribute->setBackendType('datetime');
$createdAtAttribute->save();
@@ -178,19 +196,17 @@ public function testFilterEntityCollection()
* Prepare filter.asd
*/
$parameters = [
- \Magento\ImportExport\Model\Export::FILTER_ELEMENT_GROUP => [
+ Export::FILTER_ELEMENT_GROUP => [
'email' => 'example.com',
'created_at' => [$createdAtDate, ''],
- 'store_id' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
- \Magento\Store\Model\StoreManagerInterface::class
- )->getStore()->getId()
+ 'store_id' => $this->objectManager->get(StoreManagerInterface::class)->getStore()->getId()
]
];
$this->_model->setParameters($parameters);
- /** @var $customers \Magento\Customer\Model\ResourceModel\Customer\Collection */
+ /** @var $customers Collection */
$collection = $this->_model->filterEntityCollection(
- \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Customer\Model\ResourceModel\Customer\Collection::class
+ $this->objectManager->create(
+ CustomerCollection::class
)
);
$collection->load();
From ab36bbd9afd1e7866e9e5707959a4d338e7a9241 Mon Sep 17 00:00:00 2001
From: Daniel Renaud
Date: Tue, 1 Oct 2019 09:27:38 -0500
Subject: [PATCH 0228/1978] MC-19639: Admin Analytics modal allows user to
navigate the admin
- MC-19638: User can dismiss the Admin Analytics modal with ESC key
---
.../ui_component/admin_usage_notification.xml | 2 +-
.../view/adminhtml/web/js/modal/component.js | 80 ++++++++++++++++---
2 files changed, 68 insertions(+), 14 deletions(-)
diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml b/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml
index 3c35f1937783b..fcd1c4ebbbcdf 100644
--- a/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml
+++ b/app/code/Magento/AdminAnalytics/view/adminhtml/ui_component/admin_usage_notification.xml
@@ -85,7 +85,7 @@
- Help us improve Magento Admin by allowing us to collect usage data.
All usage data that we collect for this purpose cannot be used to individually identify you and is used only to improve the Magento Admin and related products and services.
- You can learn more and opt out at any time by following the instructions in merchant documentation .
+ You can learn more and opt out at any time by following the instructions in merchant documentation .
]]>
diff --git a/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js b/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js
index bc09890d0d0b4..dedab9f379525 100644
--- a/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js
+++ b/app/code/Magento/AdminAnalytics/view/adminhtml/web/js/modal/component.js
@@ -20,16 +20,7 @@ define([
enableLogAction: '${ $.provider }:data.enableLogAction',
disableLogAction: '${ $.provider }:data.disableLogAction'
},
- options: {
- keyEventHandlers: {
- /**
- * Prevents escape key from exiting out of modal
- */
- escapeKey: function () {
- return;
- }
- }
- },
+ options: {},
notificationWindow: null
},
@@ -41,11 +32,32 @@ define([
this._super();
},
+ /**
+ * Configure ESC and TAB so user can't leave modal
+ * without selecting an option
+ *
+ * @returns {Object} Chainable.
+ */
+ initModalEvents: function () {
+ this._super();
+ //Don't allow ESC key to close modal
+ this.options.keyEventHandlers.escapeKey = function(e){e.preventDefault()};
+ //Restrict tab action to the modal
+ this.options.keyEventHandlers.tabKey = this.handleTabKey.bind(this);
+
+ return this;
+ },
+
/**
* Once the modal is opened it hides the X
*/
onOpened: function () {
- $('.modal-header button.action-close').hide();
+ $('.modal-header button.action-close').attr("disabled", true).hide();
+
+ this.focusableElements = $(this.rootSelector).find("a[href], button:enabled");
+ this.firstFocusableElement = this.focusableElements[0];
+ this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1];
+ this.firstFocusableElement.focus();
},
/**
@@ -104,10 +116,52 @@ define([
* Allows admin usage popup to be shown first and then new release notification
*/
openReleasePopup: function () {
- var notifiModal = registry.get('release_notification.release_notification.notification_modal_1');
+ var notificationModal = registry.get('release_notification.release_notification.notification_modal_1');
if (analyticsPopupConfig.releaseVisible) {
- notifiModal.initializeContentAfterAnalytics();
+ notificationModal.initializeContentAfterAnalytics();
+ }
+ },
+
+ /**
+ * Handle Tab and Shift+Tab key event
+ *
+ * Keep the tab actions restricted to the popup modal
+ * so the user must select an option to dismiss the modal
+ */
+ handleTabKey: function(event) {
+ var modal = this;
+ var KEY_TAB = 9;
+
+ function handleBackwardTab() {
+ if ( document.activeElement === modal.firstFocusableElement
+ || document.activeElement === $(modal.rootSelector)[0]
+ ) {
+ event.preventDefault();
+ modal.lastFocusableElement.focus();
+ }
+ }
+ function handleForwardTab() {
+ if ( document.activeElement === modal.lastFocusableElement) {
+ event.preventDefault();
+ modal.firstFocusableElement.focus();
+ }
+ }
+
+ switch(event.keyCode) {
+ case KEY_TAB:
+ if ( modal.focusableElements.length === 1 ) {
+ event.preventDefault();
+ break;
+ }
+ if ( event.shiftKey ) {
+ handleBackwardTab();
+ break;
+ }
+ handleForwardTab();
+ break;
+ default:
+ break;
}
}
}
From a0c79b6aa4c856e2ca4da24ac854e748bee7fa84 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 1 Oct 2019 14:00:22 -0500
Subject: [PATCH 0229/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Backend/Customlayoutupdate.php | 29 +++++++++++++-
.../Magento/Cms/Model/Page/DataProvider.php | 38 ++++++++++--------
app/code/Magento/Cms/Model/PageRepository.php | 40 ++++++++++++-------
.../Controller/Adminhtml/Page/SaveTest.php | 5 ++-
.../Controller/Adminhtml/ProductTest.php | 1 +
.../Backend/CustomlayoutupdateTest.php | 26 ++++++++++++
6 files changed, 104 insertions(+), 35 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
index 759bdb54439b6..b5aa5e2035100 100644
--- a/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
+++ b/app/code/Magento/Catalog/Model/Attribute/Backend/Customlayoutupdate.php
@@ -51,6 +51,31 @@ private function extractValue(AbstractModel $object)
return $value;
}
+ /**
+ * Extract old attribute value.
+ *
+ * @param AbstractModel $object
+ * @return mixed Old value or null.
+ */
+ private function extractOldValue(AbstractModel $object)
+ {
+ if (!empty($object->getId())) {
+ $attr = $this->getAttribute()->getAttributeCode();
+
+ if ($object->getOrigData()) {
+ return $object->getOrigData($attr);
+ }
+
+ $oldObject = clone $object;
+ $oldObject->unsetData();
+ $oldObject->load($object->getId());
+
+ return $oldObject->getData($attr);
+ }
+
+ return null;
+ }
+
/**
* @inheritDoc
*
@@ -59,10 +84,10 @@ private function extractValue(AbstractModel $object)
public function validate($object)
{
if (parent::validate($object)) {
- $attrCode = $this->getAttribute()->getAttributeCode();
if ($object instanceof AbstractModel) {
$value = $this->extractValue($object);
- if ($value && $object->getOrigData($attrCode) !== $value) {
+ $oldValue = $this->extractOldValue($object);
+ if ($value && $oldValue !== $value) {
throw new LocalizedException(__('Custom layout update text cannot be changed, only removed'));
}
}
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
index b9fb05e0f39e4..e75097ca163e4 100644
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ b/app/code/Magento/Cms/Model/Page/DataProvider.php
@@ -5,6 +5,7 @@
*/
namespace Magento\Cms\Model\Page;
+use Magento\Cms\Model\Page;
use Magento\Cms\Model\ResourceModel\Page\CollectionFactory;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Request\DataPersistorInterface;
@@ -84,6 +85,20 @@ public function __construct(
?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
}
+ /**
+ * Find requested page.
+ *
+ * @return Page|null
+ */
+ private function findCurrentPage(): ?Page
+ {
+ if ($this->getRequestFieldName() && ($pageId = (int)$this->request->getParam($this->getRequestFieldName()))) {
+ return $this->collection->getItemById($pageId);
+ }
+
+ return null;
+ }
+
/**
* Prepares Meta
*
@@ -162,25 +177,14 @@ public function getMeta()
//List of custom layout files available for current page.
$options = [['label' => 'No update', 'value' => '']];
- if ($this->getRequestFieldName() && ($pageId = (int)$this->request->getParam($this->getRequestFieldName()))) {
+ if ($page = $this->findCurrentPage()) {
//We must have a specific page selected.
- //Finding our page.
- $found = null;
- /** @var \Magento\Cms\Model\Page $page */
- foreach ($this->collection->getItems() as $page) {
- if ($page->getId() == $pageId) {
- $found = $page;
- break;
- }
- }
//If custom layout XML is set then displaying this special option.
- if ($found) {
- if ($found->getCustomLayoutUpdateXml() || $found->getLayoutUpdateXml()) {
- $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
- }
- foreach ($this->customLayoutManager->fetchAvailableFiles($found) as $layoutFile) {
- $options[] = ['label' => $layoutFile, 'value' => $layoutFile];
- }
+ if ($page->getCustomLayoutUpdateXml() || $page->getLayoutUpdateXml()) {
+ $options[] = ['label' => 'Use existing layout update XML', 'value' => '_existing_'];
+ }
+ foreach ($this->customLayoutManager->fetchAvailableFiles($page) as $layoutFile) {
+ $options[] = ['label' => $layoutFile, 'value' => $layoutFile];
}
}
$customLayoutMeta = [
diff --git a/app/code/Magento/Cms/Model/PageRepository.php b/app/code/Magento/Cms/Model/PageRepository.php
index b555123af8967..72f07771f59d4 100644
--- a/app/code/Magento/Cms/Model/PageRepository.php
+++ b/app/code/Magento/Cms/Model/PageRepository.php
@@ -113,6 +113,30 @@ public function __construct(
$this->identityMap = $identityMap ?? ObjectManager::getInstance()->get(IdentityMap::class);
}
+ /**
+ * Validate new layout update values.
+ *
+ * @param Data\PageInterface $page
+ * @return void
+ * @throws \InvalidArgumentException
+ */
+ private function validateLayoutUpdate(Data\PageInterface $page): void
+ {
+ //Persisted data
+ $savedPage = $page->getId() ? $this->getById($page->getId()) : null;
+ //Custom layout update can be removed or kept as is.
+ if ($page->getCustomLayoutUpdateXml()
+ && (!$savedPage || $page->getCustomLayoutUpdateXml() !== $savedPage->getCustomLayoutUpdateXml())
+ ) {
+ throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
+ }
+ if ($page->getLayoutUpdateXml()
+ && (!$savedPage || $page->getLayoutUpdateXml() !== $savedPage->getLayoutUpdateXml())
+ ) {
+ throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
+ }
+ }
+
/**
* Save Page data
*
@@ -127,21 +151,7 @@ public function save(\Magento\Cms\Api\Data\PageInterface $page)
$page->setStoreId($storeId);
}
try {
- //Persisted data
- $savedPage = $page->getId() ? $this->getById($page->getId()) : null;
-
- //Custom layout update must be selected from available files
- if ($page->getCustomLayoutUpdateXml()
- && (!$savedPage || $page->getCustomLayoutUpdateXml() !== $savedPage->getCustomLayoutUpdateXml())
- ) {
- throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
- }
- if ($page->getLayoutUpdateXml()
- && (!$savedPage || $page->getLayoutUpdateXml() !== $savedPage->getLayoutUpdateXml())
- ) {
- throw new \InvalidArgumentException('Custom layout updates must be selected from a file');
- }
-
+ $this->validateLayoutUpdate($page);
$this->resource->save($page);
$this->identityMap->add($page);
} catch (\Exception $exception) {
diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
index bc6703eaf4426..15ba72154643c 100644
--- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
@@ -295,7 +295,10 @@ public function testSaveActionThrowsException()
$this->dataPersistorMock->expects($this->any())
->method('set')
- ->with('cms_page', ['page_id' => $this->pageId, 'custom_layout_update_xml' => null]);
+ ->with(
+ 'cms_page',
+ ['page_id' => $this->pageId, 'custom_layout_update_xml' => null, 'layout_update_xml' => null]
+ );
$this->resultRedirect->expects($this->atLeastOnce())
->method('setPath')
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
index 1f2569a6ffdb6..3c9c00617f7de 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/ProductTest.php
@@ -19,6 +19,7 @@
/**
* @magentoAppArea adminhtml
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ProductTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
index 308a577a6aa6f..7f594d265418f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Attribute/Backend/CustomlayoutupdateTest.php
@@ -61,6 +61,7 @@ protected function setUp()
*
* @return void
* @throws \Throwable
+ * @magentoDbIsolation enabled
*/
public function testImmutable(): void
{
@@ -94,5 +95,30 @@ public function testImmutable(): void
$this->category->setOrigData('custom_layout_update', 'test');
$this->attribute->beforeSave($this->category);
$this->assertNull($this->category->getCustomAttribute('custom_layout_update')->getValue());
+
+ //Using old stored value
+ //Saving old value 1st
+ $this->recreateCategory();
+ $this->category->setOrigData('custom_layout_update', 'test');
+ $this->category->setData('custom_layout_update', 'test');
+ $this->category->save();
+ $this->recreateCategory();
+ $this->category = $this->categoryFactory->create(['data' => $this->category->getData()]);
+
+ //Trying the same value.
+ $this->category->setData('custom_layout_update', 'test');
+ $this->attribute->beforeSave($this->category);
+ //Trying new value
+ $this->category->setData('custom_layout_update', 'test2');
+ $caughtException = false;
+ try {
+ $this->attribute->beforeSave($this->category);
+ } catch (LocalizedException $exception) {
+ $caughtException = true;
+ }
+ $this->assertTrue($caughtException);
+ //Empty value
+ $this->category->setData('custom_layout_update', null);
+ $this->attribute->beforeSave($this->category);
}
}
From a500c3a4686fe7707889ea1f9638beb208bd4bef Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 1 Oct 2019 18:43:39 -0500
Subject: [PATCH 0230/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/LayoutUpdateManager.php | 26 +++++++++++++++----
.../Product/Attribute/LayoutUpdateManager.php | 23 ++++++++++++++--
app/code/Magento/Cms/Helper/Page.php | 12 ++++++++-
.../Page/CustomLayout/CustomLayoutManager.php | 16 ++++++++++--
4 files changed, 67 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
index 69c5f961cb96f..6cf8e93f2c3f1 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
@@ -9,13 +9,13 @@
namespace Magento\Catalog\Model\Category\Attribute;
use Magento\Catalog\Api\Data\CategoryInterface;
+use Magento\Catalog\Model\Category;
use Magento\Framework\App\Area;
use Magento\Framework\DataObject;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
use Magento\Framework\View\DesignInterface;
use Magento\Framework\View\Model\Layout\Merge as LayoutProcessor;
use Magento\Framework\View\Model\Layout\MergeFactory as LayoutProcessorFactory;
-use Magento\Framework\View\Result\Page as PageLayout;
/**
* Manage available layout updates for categories.
@@ -113,6 +113,24 @@ function (string $handle) use ($category) : ?string {
);
}
+ /**
+ * Extract custom layout attribute value.
+ *
+ * @param CategoryInterface $category
+ * @return mixed
+ */
+ private function extractAttributeValue(CategoryInterface $category)
+ {
+ if ($category instanceof Category && $category->hasData('custom_layout_update_file')) {
+ return $category->getData('custom_layout_update_file');
+ }
+ if ($attr = $category->getCustomAttribute('custom_layout_update_file')) {
+ return $attr->getValue();
+ }
+
+ return null;
+ }
+
/**
* Extract selected custom layout settings.
*
@@ -124,13 +142,11 @@ function (string $handle) use ($category) : ?string {
*/
public function extractCustomSettings(CategoryInterface $category, DataObject $intoSettings): void
{
- if ($category->getId()
- && $attribute = $category->getCustomAttribute('custom_layout_update_file')
- ) {
+ if ($category->getId() && $value = $this->extractAttributeValue($category)) {
$handles = $intoSettings->getPageLayoutHandles() ?? [];
$handles = array_merge_recursive(
$handles,
- ['selectable' => $category->getId() . '_' . $attribute->getValue()]
+ ['selectable' => $category->getId() . '_' . $value]
);
$intoSettings->setPageLayoutHandles($handles);
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
index 12f7118924268..91f84f88fa6d9 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -9,6 +9,7 @@
namespace Magento\Catalog\Model\Product\Attribute;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Product;
use Magento\Framework\App\Area;
use Magento\Framework\DataObject;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
@@ -124,6 +125,24 @@ function (string $handle) use ($identifier) : ?string {
);
}
+ /**
+ * Extract custom layout attribute value.
+ *
+ * @param ProductInterface $product
+ * @return mixed
+ */
+ private function extractAttributeValue(ProductInterface $product)
+ {
+ if ($product instanceof Product && $product->hasData('custom_layout_update_file')) {
+ return $product->getData('custom_layout_update_file');
+ }
+ if ($attr = $product->getCustomAttribute('custom_layout_update_file')) {
+ return $attr->getValue();
+ }
+
+ return null;
+ }
+
/**
* Extract selected custom layout settings.
*
@@ -135,11 +154,11 @@ function (string $handle) use ($identifier) : ?string {
*/
public function extractCustomSettings(ProductInterface $product, DataObject $intoSettings): void
{
- if ($product->getSku() && $attribute = $product->getCustomAttribute('custom_layout_update_file')) {
+ if ($product->getSku() && $value = $this->extractAttributeValue($product)) {
$handles = $intoSettings->getPageLayoutHandles() ?? [];
$handles = array_merge_recursive(
$handles,
- ['selectable' => $this->sanitizeSku($product) . '_' . $attribute->getValue()]
+ ['selectable' => $this->sanitizeSku($product) . '_' . $value]
);
$intoSettings->setPageLayoutHandles($handles);
}
diff --git a/app/code/Magento/Cms/Helper/Page.php b/app/code/Magento/Cms/Helper/Page.php
index bbef6fc059c36..39b292bf07239 100644
--- a/app/code/Magento/Cms/Helper/Page.php
+++ b/app/code/Magento/Cms/Helper/Page.php
@@ -7,6 +7,7 @@
use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
use Magento\Cms\Model\Page\CustomLayoutRepositoryInterface;
+use Magento\Cms\Model\Page\IdentityMap;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -90,6 +91,11 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper
*/
private $customLayoutRepo;
+ /**
+ * @var IdentityMap
+ */
+ private $identityMap;
+
/**
* Constructor
*
@@ -104,6 +110,7 @@ class Page extends \Magento\Framework\App\Helper\AbstractHelper
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
* @param CustomLayoutManagerInterface|null $customLayoutManager
* @param CustomLayoutRepositoryInterface|null $customLayoutRepo
+ * @param IdentityMap|null $identityMap
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -117,7 +124,8 @@ public function __construct(
\Magento\Framework\Escaper $escaper,
\Magento\Framework\View\Result\PageFactory $resultPageFactory,
?CustomLayoutManagerInterface $customLayoutManager = null,
- ?CustomLayoutRepositoryInterface $customLayoutRepo = null
+ ?CustomLayoutRepositoryInterface $customLayoutRepo = null,
+ ?IdentityMap $identityMap = null
) {
$this->messageManager = $messageManager;
$this->_page = $page;
@@ -131,6 +139,7 @@ public function __construct(
?? ObjectManager::getInstance()->get(CustomLayoutManagerInterface::class);
$this->customLayoutRepo = $customLayoutRepo
?? ObjectManager::getInstance()->get(CustomLayoutRepositoryInterface::class);
+ $this->identityMap = $identityMap ?? ObjectManager::getInstance()->get(IdentityMap::class);
parent::__construct($context);
}
@@ -158,6 +167,7 @@ public function prepareResultPage(Action $action, $pageId = null)
if (!$this->_page->getId()) {
return false;
}
+ $this->identityMap->add($this->_page);
$inRange = $this->_localeDate->isScopeDateInInterval(
null,
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
index d11d86433152d..988bd5b4ac136 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutManager.php
@@ -12,6 +12,7 @@
use Magento\Cms\Api\PageRepositoryInterface;
use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelectedInterface;
use Magento\Cms\Model\Page\CustomLayoutManagerInterface;
+use Magento\Cms\Model\Page\IdentityMap;
use Magento\Framework\App\Area;
use Magento\Framework\View\Design\Theme\FlyweightFactory;
use Magento\Framework\View\DesignInterface;
@@ -49,22 +50,30 @@ class CustomLayoutManager implements CustomLayoutManagerInterface
*/
private $layoutProcessor;
+ /**
+ * @var IdentityMap
+ */
+ private $identityMap;
+
/**
* @param FlyweightFactory $themeFactory
* @param DesignInterface $design
* @param PageRepositoryInterface $pageRepository
* @param LayoutProcessorFactory $layoutProcessorFactory
+ * @param IdentityMap $identityMap
*/
public function __construct(
FlyweightFactory $themeFactory,
DesignInterface $design,
PageRepositoryInterface $pageRepository,
- LayoutProcessorFactory $layoutProcessorFactory
+ LayoutProcessorFactory $layoutProcessorFactory,
+ IdentityMap $identityMap
) {
$this->themeFactory = $themeFactory;
$this->design = $design;
$this->pageRepository = $pageRepository;
$this->layoutProcessorFactory = $layoutProcessorFactory;
+ $this->identityMap = $identityMap;
}
/**
@@ -132,7 +141,10 @@ function (string $handle) use ($identifier) : ?string {
*/
public function applyUpdate(PageLayout $layout, CustomLayoutSelectedInterface $layoutSelected): void
{
- $page = $this->pageRepository->getById($layoutSelected->getPageId());
+ $page = $this->identityMap->get($layoutSelected->getPageId());
+ if (!$page) {
+ $page = $this->pageRepository->getById($layoutSelected->getPageId());
+ }
$layout->addPageLayoutHandles(
['selectable' => $this->sanitizeIdentifier($page) .'_' .$layoutSelected->getLayoutFileId()]
From 298e4048b512542c44d05901e25dadbd1e1afb5b Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Wed, 2 Oct 2019 10:02:27 +0300
Subject: [PATCH 0231/1978] GraphQl-903: use_for_shipping backward
compatibility
---
.../Model/Cart/SetBillingAddressOnCart.php | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 08aeb56e4cd09..0f211a63726b4 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -56,9 +56,14 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
{
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
$addressInput = $billingAddressInput['address'] ?? null;
- $sameAsshipping = isset($billingAddressInput['same_as_shipping'])
+ $sameAsShipping = isset($billingAddressInput['same_as_shipping'])
? (bool)$billingAddressInput['same_as_shipping'] : false;
+ if (!isset($billingAddressInput['same_as_shipping'])) {
+ $sameAsShipping = isset($billingAddressInput['use_for_shipping'])
+ ? (bool)$billingAddressInput['use_for_shipping'] : false;
+ }
+
if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
__('The billing address must contain either "customer_address_id" or "address".')
@@ -72,7 +77,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
}
$addresses = $cart->getAllShippingAddresses();
- if ($sameAsshipping && count($addresses) > 1) {
+ if ($sameAsShipping && count($addresses) > 1) {
throw new GraphQlInputException(
__('Using the "same_as_shipping" option with multishipping is not possible.')
);
@@ -80,7 +85,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
$billingAddress = $this->createBillingAddress($context, $customerAddressId, $addressInput);
- $this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsshipping);
+ $this->assignBillingAddressToCart->execute($cart, $billingAddress, $sameAsShipping);
}
/**
From 35f77dbf8452da84312d174397c0e3fa80ceca24 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 2 Oct 2019 12:22:53 +0400
Subject: [PATCH 0232/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
...efrontElasticsearch6SearchInvalidValueTest.xml} | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)
rename app/code/Magento/Elasticsearch6/Test/Mftf/Test/{StorefrontElasticsearchSearchInvalidValueTest.xml => StorefrontElasticsearch6SearchInvalidValueTest.xml} (87%)
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearchSearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
similarity index 87%
rename from app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearchSearchInvalidValueTest.xml
rename to app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
index 932bef3a1452b..5f6949dcafef5 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearchSearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
@@ -8,7 +8,7 @@
-
+
@@ -96,11 +96,11 @@
-
+
-
+
@@ -111,13 +111,5 @@
-
-
-
-
-
-
-
-
From f7cc155c64c4416bf0b59410415e5bc297879dc1 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Wed, 2 Oct 2019 12:00:09 +0300
Subject: [PATCH 0233/1978] MC-20624: Automate MC-11459
---
.../Model/Export/CustomerTest.php | 123 ++++++++++++++++--
1 file changed, 113 insertions(+), 10 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
index 7cde07675ae27..bf1888d6b420c 100644
--- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
+++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
@@ -9,6 +9,7 @@
use Magento\Framework\Registry;
use Magento\Customer\Model\Attribute;
use Magento\ImportExport\Model\Export;
+use Magento\ImportExport\Model\Import;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Model\StoreManagerInterface;
@@ -20,6 +21,8 @@
/**
* Tests for customer export model.
+ *
+ * @magentoAppArea adminhtml
*/
class CustomerTest extends \PHPUnit\Framework\TestCase
{
@@ -33,6 +36,16 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
*/
private $objectManager;
+ /**
+ * @var array
+ */
+ private $attributeValues;
+
+ /**
+ * @var array
+ */
+ private $attributeTypes;
+
/**
* @inheritdoc
*/
@@ -49,10 +62,13 @@ protected function setUp()
*/
public function testExport()
{
- $expectedAttributes = [];
- /** @var $collection Collection */
+ /** @var Collection $collection */
$collection = $this->objectManager->create(Collection::class);
- /** @var $attribute Attribute */
+ $this->initAttributeValues($collection);
+ $this->initAttributeTypes($collection);
+
+ $expectedAttributes = [];
+ /** @var Attribute $attribute */
foreach ($collection as $attribute) {
$expectedAttributes[] = $attribute->getAttributeCode();
}
@@ -72,10 +88,10 @@ public function testExport()
$this->assertNotEmpty($lines['data'], 'No data was exported.');
- /** @var $customers CustomerModel[] */
+ /** @var CustomerModel[] $customers */
$customers = $this->objectManager->create(CustomerCollection::class)->getItems();
foreach ($customers as $customer) {
- $data = $customer->getData();
+ $data = $this->processCustomerData($customer, $expectedAttributes);
$exportData = $lines['data'][$data['email']];
$exportData = $this->unsetDuplicateData($exportData);
array_walk(
@@ -91,6 +107,96 @@ function (&$value) {
}
}
+ /**
+ * Initialize attribute option values.
+ *
+ * @param Collection $attributeCollection
+ * @return $this
+ */
+ private function initAttributeValues(Collection $attributeCollection): CustomerTest
+ {
+ /** @var Attribute $attribute */
+ foreach ($attributeCollection as $attribute) {
+ $this->attributeValues[$attribute->getAttributeCode()] = $this->_model->getAttributeOptions($attribute);
+ }
+
+ return $this;
+ }
+
+ /**
+ * Initialize attribute types.
+ *
+ * @param \Magento\Customer\Model\ResourceModel\Attribute\Collection $attributeCollection
+ * @return $this
+ */
+ private function initAttributeTypes(Collection $attributeCollection): CustomerTest
+ {
+ /** @var Attribute $attribute */
+ foreach ($attributeCollection as $attribute) {
+ $this->attributeTypes[$attribute->getAttributeCode()] = $attribute->getFrontendInput();
+ }
+
+ return $this;
+ }
+
+ /**
+ * Format Customer data as same as export data.
+ *
+ * @param CustomerModel $item
+ * @param array $expectedAttributes
+ * @return array
+ */
+ private function processCustomerData(CustomerModel $item, array $expectedAttributes): array
+ {
+ $data = [];
+ foreach ($expectedAttributes as $attributeCode) {
+ $attributeValue = $item->getData($attributeCode);
+
+ if ($this->isMultiselect($attributeCode)) {
+ $values = [];
+ $attributeValue = explode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $attributeValue);
+ foreach ($attributeValue as $value) {
+ $values[] = $this->getAttributeValueById($attributeCode, $value);
+ }
+ $data[$attributeCode] = implode(Import::DEFAULT_GLOBAL_MULTI_VALUE_SEPARATOR, $values);
+ } else {
+ $data[$attributeCode] = $this->getAttributeValueById($attributeCode, $attributeValue);
+ }
+ }
+
+ return $data;
+ }
+
+ /**
+ * Check that attribute is multiselect type by attribute code.
+ *
+ * @param string $attributeCode
+ * @return bool
+ */
+ private function isMultiselect(string $attributeCode): bool
+ {
+ return isset($this->attributeTypes[$attributeCode])
+ && $this->attributeTypes[$attributeCode] === 'multiselect';
+ }
+
+ /**
+ * Return attribute value by id.
+ *
+ * @param string $attributeCode
+ * @param int|string $valueId
+ * @return mixed
+ */
+ private function getAttributeValueById(string $attributeCode, $valueId)
+ {
+ if (isset($this->attributeValues[$attributeCode])
+ && isset($this->attributeValues[$attributeCode][$valueId])
+ ) {
+ return $this->attributeValues[$attributeCode][$valueId];
+ }
+
+ return $valueId;
+ }
+
/**
* Unset non-useful or duplicate data from exported file data.
*
@@ -172,14 +278,10 @@ public function testFilterAttributeCollection()
public function testFilterEntityCollection()
{
$createdAtDate = '2038-01-01';
-
- /** @var $objectManager ObjectManagerInterface */
- $objectManager = $this->objectManager;
-
/**
* Change created_at date of first customer for future filter test.
*/
- $customers = $objectManager->get(Registry::class)
+ $customers = $this->objectManager->get(Registry::class)
->registry('_fixture/Magento_ImportExport_Customer_Collection');
$customers[0]->setCreatedAt($createdAtDate);
$customers[0]->save();
@@ -239,6 +341,7 @@ protected function _csvToArray($content, $entityId = null)
}
}
}
+
return $data;
}
}
From 9d96481c5d690fc4fd399b5a63007e5d91d440d6 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Wed, 2 Oct 2019 12:04:18 +0300
Subject: [PATCH 0234/1978] GraphQl-903: fixed static issue
---
.../QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 0f211a63726b4..b90752ae7358b 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -56,13 +56,10 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
{
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
$addressInput = $billingAddressInput['address'] ?? null;
+ $useForShipping = isset($billingAddressInput['use_for_shipping'])
+ ? (bool)$billingAddressInput['use_for_shipping'] : false;
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
- ? (bool)$billingAddressInput['same_as_shipping'] : false;
-
- if (!isset($billingAddressInput['same_as_shipping'])) {
- $sameAsShipping = isset($billingAddressInput['use_for_shipping'])
- ? (bool)$billingAddressInput['use_for_shipping'] : false;
- }
+ ? (bool)$billingAddressInput['same_as_shipping'] : $useForShipping;
if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
From adcbfdd9b8c88e27465046e5111115e74c54e766 Mon Sep 17 00:00:00 2001
From: Mahesh Singh
Date: Wed, 2 Oct 2019 16:15:03 +0530
Subject: [PATCH 0235/1978] Fixed issue with full tax summary
---
app/code/Magento/Tax/Block/Sales/Order/Tax.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Tax/Block/Sales/Order/Tax.php b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
index 0adaec9311ee6..c05bbb0244c1b 100644
--- a/app/code/Magento/Tax/Block/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
@@ -107,7 +107,7 @@ protected function _addTax($after = 'discount')
$taxTotal = new \Magento\Framework\DataObject(['code' => 'tax', 'block_name' => $this->getNameInLayout()]);
$totals = $this->getParentBlock()->getTotals();
if ($totals['grand_total']) {
- $this->getParentBlock()->addTotalBefore($taxTotal, 'grand_total');
+ $this->getParentBlock()->addTotal($taxTotal, 'grand_total');
}
$this->getParentBlock()->addTotal($taxTotal, $after);
return $this;
@@ -320,7 +320,7 @@ protected function _initGrandTotal()
]
);
$parent->addTotal($totalExcl, 'grand_total');
- $parent->addTotal($totalIncl, 'tax');
+ $parent->addTotal($totalIncl, 'grand_total');
$this->_addTax('grand_total');
}
return $this;
From 0c0dc6df18ed32673a359421091765f9c61e7cc4 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Wed, 2 Oct 2019 17:02:59 +0300
Subject: [PATCH 0236/1978] MC-20624: Automate MC-11459
---
.../import_export/customers_rollback.php | 1 +
.../Model/Export/CustomerTest.php | 72 +++++++++++++++----
2 files changed, 61 insertions(+), 12 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php
index 4630236c17b06..f8eeb8edd15da 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/import_export/customers_rollback.php
@@ -34,3 +34,4 @@
}
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
+$registry->unregister('_fixture/Magento_ImportExport_Customer_Collection');
diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
index bf1888d6b420c..74a21af111fbe 100644
--- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
+++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
@@ -46,6 +46,11 @@ class CustomerTest extends \PHPUnit\Framework\TestCase
*/
private $attributeTypes;
+ /**
+ * @var Collection
+ */
+ private $attributeCollection;
+
/**
* @inheritdoc
*/
@@ -53,33 +58,64 @@ protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
$this->_model = $this->objectManager->create(Customer::class);
+ $this->attributeCollection = $this->objectManager->create(Collection::class);
}
/**
* Export "Customer Main File".
*
* @magentoDataFixture Magento/Customer/_files/import_export/customers.php
+ * @return void
*/
public function testExport()
{
- /** @var Collection $collection */
- $collection = $this->objectManager->create(Collection::class);
- $this->initAttributeValues($collection);
- $this->initAttributeTypes($collection);
+ $this->processCustomerAttribute();
+ $expectedAttributes = $this->getExpectedAttributes();
+ $lines = $this->export($expectedAttributes);
+ $this->checkExportData($lines, $expectedAttributes);
+ }
+ /**
+ * Return attributes which should be exported.
+ *
+ * @return array
+ */
+ private function getExpectedAttributes(): array
+ {
$expectedAttributes = [];
/** @var Attribute $attribute */
- foreach ($collection as $attribute) {
+ foreach ($this->attributeCollection as $attribute) {
$expectedAttributes[] = $attribute->getAttributeCode();
}
- $expectedAttributes = array_diff($expectedAttributes, $this->_model->getDisabledAttributes());
- $this->_model->setWriter($this->objectManager->get(Csv::class));
+ return array_diff($expectedAttributes, $this->_model->getDisabledAttributes());
+ }
+
+ /**
+ * Prepare Customer attribute.
+ *
+ * @return void
+ */
+ private function processCustomerAttribute(): void
+ {
+ $this->initAttributeValues($this->attributeCollection);
+ $this->initAttributeTypes($this->attributeCollection);
+ }
+
+ /**
+ * Export customer.
+ *
+ * @param array $expectedAttributes
+ * @return array
+ */
+ private function export(array $expectedAttributes): array
+ {
+ $this->_model->setWriter($this->objectManager->create(Csv::class));
$data = $this->_model->export();
+
$this->assertNotEmpty($data);
$lines = $this->_csvToArray($data, 'email');
-
$this->assertEquals(
count($expectedAttributes),
count(array_intersect($expectedAttributes, $lines['header'])),
@@ -88,8 +124,20 @@ public function testExport()
$this->assertNotEmpty($lines['data'], 'No data was exported.');
+ return $lines;
+ }
+
+ /**
+ * Check that exported data is correct.
+ *
+ * @param array $lines
+ * @param array $expectedAttributes
+ * @return void
+ */
+ private function checkExportData(array $lines, array $expectedAttributes): void
+ {
/** @var CustomerModel[] $customers */
- $customers = $this->objectManager->create(CustomerCollection::class)->getItems();
+ $customers = $this->objectManager->create(CustomerCollection::class);
foreach ($customers as $customer) {
$data = $this->processCustomerData($customer, $expectedAttributes);
$exportData = $lines['data'][$data['email']];
@@ -111,7 +159,7 @@ function (&$value) {
* Initialize attribute option values.
*
* @param Collection $attributeCollection
- * @return $this
+ * @return CustomerTest
*/
private function initAttributeValues(Collection $attributeCollection): CustomerTest
{
@@ -127,7 +175,7 @@ private function initAttributeValues(Collection $attributeCollection): CustomerT
* Initialize attribute types.
*
* @param \Magento\Customer\Model\ResourceModel\Attribute\Collection $attributeCollection
- * @return $this
+ * @return CustomerTest
*/
private function initAttributeTypes(Collection $attributeCollection): CustomerTest
{
@@ -184,7 +232,7 @@ private function isMultiselect(string $attributeCode): bool
*
* @param string $attributeCode
* @param int|string $valueId
- * @return mixed
+ * @return int|string|array
*/
private function getAttributeValueById(string $attributeCode, $valueId)
{
From a7f87cedecb81ea4901266aadd669fd8f3bea347 Mon Sep 17 00:00:00 2001
From: "rostyslav.hymon"
Date: Wed, 2 Oct 2019 17:11:19 +0300
Subject: [PATCH 0237/1978] MC-18457: Free Shipping Minimum Order Amount
Excluding/Including Tax options
---
.../Model/Carrier/Freeshipping.php | 23 +-
...eeShippingDisplayWithInclTaxOptionTest.xml | 68 ++++++
.../Unit/Model/Carrier/FreeshippingTest.php | 200 ++++++++++++++++++
.../OfflineShipping/etc/adminhtml/system.xml | 4 +
.../Magento/Quote/Model/Quote/Address.php | 21 +-
.../Test/Mftf/Data/FreeShippingMethodData.xml | 15 ++
.../Mftf/Metadata/shipping_methods-meta.xml | 3 +
.../Sales/Total/Quote/CommonTaxCollector.php | 4 +
8 files changed, 324 insertions(+), 14 deletions(-)
create mode 100644 app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml
create mode 100644 app/code/Magento/OfflineShipping/Test/Unit/Model/Carrier/FreeshippingTest.php
diff --git a/app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php b/app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php
index 674e6b8089787..a1fca2b155f11 100644
--- a/app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php
+++ b/app/code/Magento/OfflineShipping/Model/Carrier/Freeshipping.php
@@ -63,6 +63,24 @@ public function __construct(
parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data);
}
+ /**
+ * Check subtotal for allowed free shipping
+ *
+ * @param RateRequest $request
+ *
+ * @return bool
+ */
+ private function isFreeShippingRequired(RateRequest $request): bool
+ {
+ $minSubtotal = $request->getPackageValueWithDiscount();
+ if ($request->getBaseSubtotalWithDiscountInclTax()
+ && $this->getConfigFlag('tax_including')) {
+ $minSubtotal = $request->getBaseSubtotalWithDiscountInclTax();
+ }
+
+ return $minSubtotal >= $this->getConfigData('free_shipping_subtotal');
+ }
+
/**
* FreeShipping Rates Collector
*
@@ -80,10 +98,7 @@ public function collectRates(RateRequest $request)
$this->_updateFreeMethodQuote($request);
- if ($request->getFreeShipping() || $request->getPackageValueWithDiscount() >= $this->getConfigData(
- 'free_shipping_subtotal'
- )
- ) {
+ if ($request->getFreeShipping() || $this->isFreeShippingRequired($request)) {
/** @var \Magento\Quote\Model\Quote\Address\RateResult\Method $method */
$method = $this->_rateMethodFactory->create();
diff --git a/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml b/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml
new file mode 100644
index 0000000000000..db44a06b54a88
--- /dev/null
+++ b/app/code/Magento/OfflineShipping/Test/Mftf/Test/StorefrontFreeShippingDisplayWithInclTaxOptionTest.xml
@@ -0,0 +1,68 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/OfflineShipping/Test/Unit/Model/Carrier/FreeshippingTest.php b/app/code/Magento/OfflineShipping/Test/Unit/Model/Carrier/FreeshippingTest.php
new file mode 100644
index 0000000000000..7f8959e610d42
--- /dev/null
+++ b/app/code/Magento/OfflineShipping/Test/Unit/Model/Carrier/FreeshippingTest.php
@@ -0,0 +1,200 @@
+scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->resultFactoryMock = $this->getMockBuilder(ResultFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->methodFactoryMock = $this
+ ->getMockBuilder(MethodFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+
+ $this->helper = new ObjectManager($this);
+ $this->model = $this->helper->getObject(
+ Freeshipping::class,
+ [
+ 'scopeConfig' => $this->scopeConfigMock,
+ '_rateResultFactory' => $this->resultFactoryMock,
+ '_rateMethodFactory' => $this->methodFactoryMock,
+ ]
+ );
+ }
+
+ /**
+ * Test for collect rate free shipping with tax options
+ *
+ * @param int $subtotalInclTax
+ * @param int $minOrderAmount
+ * @param int $packageValueWithDiscount
+ * @param int $baseSubtotalWithDiscountInclTax
+ * @param InvokedCount $expectedCallAppend
+ *
+ * @return void
+ * @dataProvider freeShippingWithSubtotalTaxDataProvider
+ */
+ public function testCollectRatesFreeShippingWithTaxOptions(
+ int $subtotalInclTax,
+ int $minOrderAmount,
+ int $packageValueWithDiscount,
+ int $baseSubtotalWithDiscountInclTax,
+ InvokedCount $expectedCallAppend
+ ): void {
+ /** @var RateRequest|MockObject $request */
+ $request = $this->getMockBuilder(RateRequest::class)
+ ->disableOriginalConstructor()
+ ->setMethods(
+ [
+ 'getAllItems',
+ 'getPackageQty',
+ 'getFreeShipping',
+ 'getBaseSubtotalWithDiscountInclTax',
+ 'getPackageValueWithDiscount',
+ ]
+ )
+ ->getMock();
+ $item = $this->getMockBuilder(QuoteItem::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->scopeConfigMock->expects($this->at(0))
+ ->method('isSetFlag')
+ ->willReturn(true);
+ $this->scopeConfigMock->expects($this->at(1))
+ ->method('isSetFlag')
+ ->with(
+ 'carriers/freeshipping/tax_including',
+ ScopeInterface::SCOPE_STORE,
+ null
+ )
+ ->willReturn($subtotalInclTax);
+ $this->scopeConfigMock->expects($this->at(2))
+ ->method('getValue')
+ ->with(
+ 'carriers/freeshipping/free_shipping_subtotal',
+ ScopeInterface::SCOPE_STORE,
+ null
+ )
+ ->willReturn($minOrderAmount);
+ $method = $this->getMockBuilder(Method::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setCarrier', 'setCarrierTitle', 'setMethod', 'setMethodTitle', 'setPrice', 'setCost'])
+ ->getMock();
+ $resultModel = $this->getMockBuilder(Result::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['append'])
+ ->getMock();
+ $this->resultFactoryMock->method('create')
+ ->willReturn($resultModel);
+ $request->method('getPackageValueWithDiscount')
+ ->willReturn($packageValueWithDiscount);
+ $request->method('getAllItems')
+ ->willReturn([$item]);
+ $request->method('getFreeShipping')
+ ->willReturn(false);
+ $request->method('getBaseSubtotalWithDiscountInclTax')
+ ->willReturn($baseSubtotalWithDiscountInclTax);
+ $this->methodFactoryMock->method('create')->willReturn($method);
+
+ $resultModel->expects($expectedCallAppend)
+ ->method('append')
+ ->with($method);
+
+ $this->model->collectRates($request);
+ }
+
+ /**
+ * @return array
+ */
+ public function freeShippingWithSubtotalTaxDataProvider(): array
+ {
+ return [
+ [
+ 'subtotalInclTax' => 1,
+ 'minOrderAmount' => 10,
+ 'packageValueWithDiscount' => 8,
+ 'baseSubtotalWithDiscountInclTax' => 15,
+ 'expectedCallAppend' => $this->once(),
+
+ ],
+ [
+ 'subtotalInclTax' => 1,
+ 'minOrderAmount' => 20,
+ 'packageValueWithDiscount' => 8,
+ 'baseSubtotalWithDiscountInclTax' => 15,
+ 'expectedCallAppend' => $this->never(),
+
+ ],
+ [
+ 'subtotalInclTax' => 0,
+ 'minOrderAmount' => 10,
+ 'packageValueWithDiscount' => 8,
+ 'baseSubtotalWithDiscountInclTax' => 15,
+ 'expectedCallAppend' => $this->never(),
+
+ ],
+ ];
+ }
+}
diff --git a/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml b/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml
index 2b29d2211b9d1..cb75bddf4d7bd 100644
--- a/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml
+++ b/app/code/Magento/OfflineShipping/etc/adminhtml/system.xml
@@ -127,6 +127,10 @@
Minimum Order Amount
validate-number validate-zero-or-greater
+
+ Include Tax to Amount
+ Magento\Config\Model\Config\Source\Yesno
+
Method Name
diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php
index 3ecbc69b80785..ecc51a00e8fb5 100644
--- a/app/code/Magento/Quote/Model/Quote/Address.php
+++ b/app/code/Magento/Quote/Model/Quote/Address.php
@@ -471,7 +471,7 @@ protected function _isDefaultShippingNullOrSameAsBillingAddress()
/**
* Declare address quote model object
*
- * @param \Magento\Quote\Model\Quote $quote
+ * @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
public function setQuote(\Magento\Quote\Model\Quote $quote)
@@ -691,7 +691,7 @@ public function getItemQty($itemId = 0)
*/
public function hasItems()
{
- return sizeof($this->getAllItems()) > 0;
+ return count($this->getAllItems()) > 0;
}
/**
@@ -1020,6 +1020,7 @@ public function requestShippingRates(\Magento\Quote\Model\Quote\Item\AbstractIte
$request->setLimitCarrier($this->getLimitCarrier());
$baseSubtotalInclTax = $this->getBaseSubtotalTotalInclTax();
$request->setBaseSubtotalInclTax($baseSubtotalInclTax);
+ $request->setBaseSubtotalWithDiscountInclTax($this->getBaseSubtotalWithDiscount() + $this->getBaseTaxAmount());
$result = $this->_rateCollector->create()->collectRates($request)->getResult();
@@ -1225,8 +1226,8 @@ public function setBaseShippingAmount($value, $alreadyExclTax = false)
/**
* Set total amount value
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function setTotalAmount($code, $amount)
@@ -1243,8 +1244,8 @@ public function setTotalAmount($code, $amount)
/**
* Set total amount value in base store currency
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function setBaseTotalAmount($code, $amount)
@@ -1261,8 +1262,8 @@ public function setBaseTotalAmount($code, $amount)
/**
* Add amount total amount value
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function addTotalAmount($code, $amount)
@@ -1276,8 +1277,8 @@ public function addTotalAmount($code, $amount)
/**
* Add amount total amount value in base store currency
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function addBaseTotalAmount($code, $amount)
diff --git a/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml b/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml
index d700aa622c177..3d3667e59903f 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml
+++ b/app/code/Magento/Shipping/Test/Mftf/Data/FreeShippingMethodData.xml
@@ -26,6 +26,7 @@
freeTitleDefault
freeNameDefault
freeShippingSubtotalDefault
+ TaxIncludingDefault
freeSpecificerrmsgDefault
freeSallowspecificDefault
freeSpecificcountryDefault
@@ -44,6 +45,9 @@
+
+ 0
+
This shipping method is not available. To use this shipping method, please contact us.
@@ -66,6 +70,17 @@
101
+
+
+ TaxIncluding
+
+
+ 1
+
+
+
+ TaxIncludingDefault
+
freeShippingSubtotalDefault
diff --git a/app/code/Magento/Shipping/Test/Mftf/Metadata/shipping_methods-meta.xml b/app/code/Magento/Shipping/Test/Mftf/Metadata/shipping_methods-meta.xml
index 5781b886386f6..14c0d6d5af725 100644
--- a/app/code/Magento/Shipping/Test/Mftf/Metadata/shipping_methods-meta.xml
+++ b/app/code/Magento/Shipping/Test/Mftf/Metadata/shipping_methods-meta.xml
@@ -66,6 +66,9 @@
string
+
+ boolean
+
string
diff --git a/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php b/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
index 77b3cfa3a08bb..c70c715d32c1b 100644
--- a/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
+++ b/app/code/Magento/Tax/Model/Sales/Total/Quote/CommonTaxCollector.php
@@ -383,6 +383,7 @@ public function mapItems(
$priceIncludesTax,
$useBaseCurrency
);
+ //phpcs:ignore Magento2.Performance.ForeachArrayMerge
$itemDataObjects = array_merge($itemDataObjects, $extraTaxableItems);
}
} else {
@@ -394,6 +395,7 @@ public function mapItems(
$priceIncludesTax,
$useBaseCurrency
);
+ //phpcs:ignore Magento2.Performance.ForeachArrayMerge
$itemDataObjects = array_merge($itemDataObjects, $extraTaxableItems);
}
}
@@ -592,6 +594,7 @@ protected function processProductItems(
$total->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
$total->setBaseSubtotalInclTax($baseSubtotalInclTax);
$shippingAssignment->getShipping()->getAddress()->setBaseSubtotalTotalInclTax($baseSubtotalInclTax);
+ $shippingAssignment->getShipping()->getAddress()->setBaseTaxAmount($baseTax);
return $this;
}
@@ -799,6 +802,7 @@ public function convertAppliedTaxes($appliedTaxes, $baseAppliedTaxes, $extraInfo
'rates' => $rates,
];
if (!empty($extraInfo)) {
+ //phpcs:ignore Magento2.Performance.ForeachArrayMerge
$appliedTaxArray = array_merge($appliedTaxArray, $extraInfo);
}
From 0b6bd0c5a77e26e9d22cbd8a45d91af76a2514d4 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 2 Oct 2019 11:18:45 -0500
Subject: [PATCH 0238/1978] MC-18685: Remove custom layout updates from admin
---
.../Adminhtml/Page/PostDataProcessor.php | 3 +-
.../Cms/Controller/Adminhtml/Page/Save.php | 27 +-----
app/code/Magento/Cms/Model/Page.php | 61 ++++++++++---
.../CustomLayout/CustomLayoutRepository.php | 29 ++++++-
.../Magento/Cms/Model/Page/DataProvider.php | 11 ++-
.../Model/Page/CustomLayoutRepositoryTest.php | 86 +++++++++++++++----
6 files changed, 158 insertions(+), 59 deletions(-)
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
index c46bcb8f247aa..5172752fb29bd 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/PostDataProcessor.php
@@ -63,7 +63,6 @@ public function __construct(
*/
public function filter($data)
{
- unset($data['layout_update_selected']);
$filterRules = [];
foreach (['custom_theme_from', 'custom_theme_to'] as $dateField) {
@@ -140,7 +139,7 @@ private function validateData($data, $layoutXmlValidator)
if (!empty($data['layout_update_xml']) && !$layoutXmlValidator->isValid($data['layout_update_xml'])) {
return false;
}
-
+
if (!empty($data['custom_layout_update_xml']) &&
!$layoutXmlValidator->isValid($data['custom_layout_update_xml'])
) {
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 38901c6c00dbe..8ad33f90b7c88 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -48,26 +48,19 @@ class Save extends \Magento\Backend\App\Action implements HttpPostActionInterfac
*/
private $pageRepository;
- /**
- * @var CustomLayoutRepositoryInterface
- */
- private $customLayoutRepository;
-
/**
* @param Action\Context $context
* @param PostDataProcessor $dataProcessor
* @param DataPersistorInterface $dataPersistor
* @param \Magento\Cms\Model\PageFactory|null $pageFactory
* @param \Magento\Cms\Api\PageRepositoryInterface|null $pageRepository
- * @param CustomLayoutRepositoryInterface|null $customLayoutRepository
*/
public function __construct(
Action\Context $context,
PostDataProcessor $dataProcessor,
DataPersistorInterface $dataPersistor,
\Magento\Cms\Model\PageFactory $pageFactory = null,
- \Magento\Cms\Api\PageRepositoryInterface $pageRepository = null,
- ?CustomLayoutRepositoryInterface $customLayoutRepository = null
+ \Magento\Cms\Api\PageRepositoryInterface $pageRepository = null
) {
$this->dataProcessor = $dataProcessor;
$this->dataPersistor = $dataPersistor;
@@ -98,14 +91,6 @@ public function execute()
if (empty($data['page_id'])) {
$data['page_id'] = null;
}
- //Either use existing custom layout XML or use a file.
- $customLayoutFile = (string)$this->getRequest()->getParam('layout_update_selected');
- if ($customLayoutFile !== '_existing_') {
- $data['custom_layout_update_xml'] = null;
- $data['layout_update_xml'] = null;
- } else {
- $customLayoutFile = null;
- }
/** @var \Magento\Cms\Model\Page $model */
$model = $this->pageFactory->create();
@@ -128,7 +113,7 @@ public function execute()
['page' => $model, 'request' => $this->getRequest()]
);
- $this->savePage($model, $customLayoutFile);
+ $this->savePage($model);
$this->messageManager->addSuccessMessage(__('You saved the page.'));
return $this->processResultRedirect($model, $resultRedirect, $data);
} catch (LocalizedException $e) {
@@ -147,21 +132,15 @@ public function execute()
* Save the page.
*
* @param Page $page
- * @param string|null $customLayoutFile
* @return void
* @throws \Throwable
*/
- private function savePage(Page $page, ?string $customLayoutFile): void
+ private function savePage(Page $page): void
{
if (!$this->dataProcessor->validate($page->getData())) {
throw new \InvalidArgumentException('Page is invalid');
}
$this->pageRepository->save($page);
- if ($customLayoutFile) {
- $this->customLayoutRepository->save(new CustomLayoutSelected($page->getId(), $customLayoutFile));
- } else {
- $this->customLayoutRepository->deleteFor($page->getId());
- }
}
/**
diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php
index 8eefe26236ba5..66aef2a6371b7 100644
--- a/app/code/Magento/Cms/Model/Page.php
+++ b/app/code/Magento/Cms/Model/Page.php
@@ -7,7 +7,9 @@
use Magento\Cms\Api\Data\PageInterface;
use Magento\Cms\Helper\Page as PageHelper;
+use Magento\Cms\Model\Page\CustomLayout\CustomLayoutRepository;
use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject\IdentityInterface;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractModel;
@@ -57,6 +59,29 @@ class Page extends AbstractModel implements PageInterface, IdentityInterface
*/
private $scopeConfig;
+ /**
+ * @var CustomLayoutRepository
+ */
+ private $customLayoutRepository;
+
+ /**
+ * @inheritDoc
+ *
+ * @param CustomLayoutRepository|null $customLayoutRepository
+ */
+ public function __construct(
+ \Magento\Framework\Model\Context $context,
+ \Magento\Framework\Registry $registry,
+ \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
+ \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
+ array $data = [],
+ ?CustomLayoutRepository $customLayoutRepository = null
+ ) {
+ parent::__construct($context, $registry, $resource, $resourceCollection, $data);
+ $this->customLayoutRepository = $customLayoutRepository
+ ?? ObjectManager::getInstance()->get(CustomLayoutRepository::class);
+ }
+
/**
* Initialize resource model
*
@@ -548,22 +573,32 @@ public function beforeSave()
$this->setUpdateTime(null);
}
- if (!$this->getId() || $originalIdentifier === $currentIdentifier) {
- return parent::beforeSave();
+ if ($this->getId() && $originalIdentifier !== $currentIdentifier) {
+ switch ($originalIdentifier) {
+ case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_ROUTE_PAGE):
+ throw new LocalizedException(
+ __('This identifier is reserved for "CMS No Route Page" in configuration.')
+ );
+ case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_HOME_PAGE):
+ throw new LocalizedException(__('This identifier is reserved for "CMS Home Page" in configuration.'));
+ case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_COOKIES_PAGE):
+ throw new LocalizedException(
+ __('This identifier is reserved for "CMS No Cookies Page" in configuration.')
+ );
+ }
}
- switch ($originalIdentifier) {
- case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_ROUTE_PAGE):
- throw new LocalizedException(
- __('This identifier is reserved for "CMS No Route Page" in configuration.')
- );
- case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_HOME_PAGE):
- throw new LocalizedException(__('This identifier is reserved for "CMS Home Page" in configuration.'));
- case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_COOKIES_PAGE):
- throw new LocalizedException(
- __('This identifier is reserved for "CMS No Cookies Page" in configuration.')
- );
+ //Removing deprecated custom layout update if a new value is provided
+ $layoutUpdate = $this->getData('layout_update_selected');
+ if ($layoutUpdate === '_no_update_' || ($layoutUpdate && $layoutUpdate !== '_existing_')) {
+ $this->setCustomLayoutUpdateXml(null);
+ $this->setLayoutUpdateXml(null);
+ }
+ if ($layoutUpdate === '_no_update_' || $layoutUpdate === '_existing_') {
+ $layoutUpdate = null;
}
+ $this->setData('layout_update_selected', $layoutUpdate);
+ $this->customLayoutRepository->validateLayoutSelectedFor($this);
return parent::beforeSave();
}
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
index 9365bb31e970a..ce50bbe7c7476 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
@@ -82,6 +82,18 @@ private function findPage(int $id): PageModel
return $page;
}
+ /**
+ * Check whether the page can use this layout.
+ *
+ * @param PageModel $page
+ * @param string $layoutFile
+ * @return bool
+ */
+ private function isLayoutValidFor(PageModel $page, string $layoutFile): bool
+ {
+ return in_array($layoutFile, $this->manager->fetchAvailableFiles($page), true);
+ }
+
/**
* Save new custom layout file value for a page.
*
@@ -94,7 +106,7 @@ private function findPage(int $id): PageModel
private function saveLayout(int $pageId, ?string $layoutFile): void
{
$page = $this->findPage($pageId);
- if ($layoutFile !== null && !in_array($layoutFile, $this->manager->fetchAvailableFiles($page), true)) {
+ if ($layoutFile !== null && !$this->isLayoutValidFor($page, $layoutFile)) {
throw new \InvalidArgumentException(
$layoutFile .' is not available for page #' .$pageId
);
@@ -114,6 +126,21 @@ public function save(CustomLayoutSelectedInterface $layout): void
$this->saveLayout($layout->getPageId(), $layout->getLayoutFileId());
}
+ /**
+ * Validate layout update of given page model.
+ *
+ * @param PageModel $page
+ * @return void
+ * @throws LocalizedException
+ */
+ public function validateLayoutSelectedFor(PageModel $page): void
+ {
+ $layoutFile = $page->getData('layout_update_selected');
+ if ($layoutFile && !$this->isLayoutValidFor($page, $layoutFile)) {
+ throw new LocalizedException(__('Invalid Custom Layout Update selected'));
+ }
+ }
+
/**
* @inheritDoc
*/
diff --git a/app/code/Magento/Cms/Model/Page/DataProvider.php b/app/code/Magento/Cms/Model/Page/DataProvider.php
index e75097ca163e4..41010575a1f27 100644
--- a/app/code/Magento/Cms/Model/Page/DataProvider.php
+++ b/app/code/Magento/Cms/Model/Page/DataProvider.php
@@ -48,6 +48,11 @@ class DataProvider extends \Magento\Ui\DataProvider\ModifierPoolDataProvider
*/
private $customLayoutManager;
+ /**
+ * @var CollectionFactory
+ */
+ private $collectionFactory;
+
/**
* @param string $name
* @param string $primaryFieldName
@@ -76,6 +81,7 @@ public function __construct(
?CustomLayoutManagerInterface $customLayoutManager = null
) {
$this->collection = $pageCollectionFactory->create();
+ $this->collectionFactory = $pageCollectionFactory;
$this->dataPersistor = $dataPersistor;
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data, $pool);
$this->auth = $auth ?? ObjectManager::getInstance()->get(AuthorizationInterface::class);
@@ -93,6 +99,8 @@ public function __construct(
private function findCurrentPage(): ?Page
{
if ($this->getRequestFieldName() && ($pageId = (int)$this->request->getParam($this->getRequestFieldName()))) {
+ //Loading data for the collection.
+ $this->getData();
return $this->collection->getItemById($pageId);
}
@@ -120,6 +128,7 @@ public function getData()
if (isset($this->loadedData)) {
return $this->loadedData;
}
+ $this->collection = $this->collectionFactory->create();
$items = $this->collection->getItems();
/** @var $page \Magento\Cms\Model\Page */
foreach ($items as $page) {
@@ -176,7 +185,7 @@ public function getMeta()
}
//List of custom layout files available for current page.
- $options = [['label' => 'No update', 'value' => '']];
+ $options = [['label' => 'No update', 'value' => '_no_update_']];
if ($page = $this->findCurrentPage()) {
//We must have a specific page selected.
//If custom layout XML is set then displaying this special option.
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
index 12b436fd32411..e3422cd81638b 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutRepositoryTest.php
@@ -11,9 +11,11 @@
use Magento\Cms\Model\Page;
use Magento\Cms\Model\PageFactory;
use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelected;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\View\Model\Layout\Merge;
use Magento\Framework\View\Model\Layout\MergeFactory;
+use Magento\TestFramework\Cms\Model\CustomLayoutManager;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
@@ -32,29 +34,41 @@ class CustomLayoutRepositoryTest extends TestCase
*/
private $pageFactory;
+ /**
+ * @var CustomLayoutManager
+ */
+ private $fakeManager;
+
+ /**
+ * @var IdentityMap
+ */
+ private $identityMap;
+
/**
* @inheritDoc
*/
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
+ $this->fakeManager = $objectManager->get(CustomLayoutManager::class);
+ $this->repo = $objectManager->create(CustomLayoutRepositoryInterface::class, ['manager' => $this->fakeManager]);
+ $this->pageFactory = $objectManager->get(PageFactory::class);
+ $this->identityMap = $objectManager->get(IdentityMap::class);
+ }
- //Mocking available list of files for the page.
- $handles = [
- 'cms_page_view_selectable_page100_select1',
- 'cms_page_view_selectable_page100_select2'
- ];
- $processor = $this->getMockBuilder(Merge::class)->disableOriginalConstructor()->getMock();
- $processor->method('getAvailableHandles')->willReturn($handles);
- $processorFactory = $this->getMockBuilder(MergeFactory::class)->disableOriginalConstructor()->getMock();
- $processorFactory->method('create')->willReturn($processor);
- $manager = $objectManager->create(
- CustomLayoutManagerInterface::class,
- ['layoutProcessorFactory' => $processorFactory]
- );
- $this->repo = $objectManager->create(CustomLayoutRepositoryInterface::class, ['manager' => $manager]);
+ /**
+ * Create page instance.
+ *
+ * @param string $id
+ * @return Page
+ */
+ private function createPage(string $id): Page
+ {
+ $page = $this->pageFactory->create(['customLayoutRepository' => $this->repo]);
+ $page->load($id, 'identifier');
+ $this->identityMap->add($page);
- $this->pageFactory = $objectManager->get(PageFactory::class);
+ return $page;
}
/**
@@ -65,10 +79,9 @@ protected function setUp()
*/
public function testCustomLayout(): void
{
- /** @var Page $page */
- $page = $this->pageFactory->create();
- $page->load('page100', 'identifier');
+ $page = $this->createPage('page100');
$pageId = (int)$page->getId();
+ $this->fakeManager->fakeAvailableFiles($pageId, ['select1', 'select2']);
//Invalid file ID
$exceptionRaised = null;
@@ -99,4 +112,41 @@ public function testCustomLayout(): void
}
$this->assertTrue($notFound);
}
+
+ /**
+ * Test that layout updates are saved with save method.
+ *
+ * @magentoDataFixture Magento/Cms/_files/pages.php
+ * @return void
+ */
+ public function testSaved(): void
+ {
+ $page = $this->createPage('page100');
+ $this->fakeManager->fakeAvailableFiles((int)$page->getId(), ['select1', 'select2']);
+
+ //Special no-update instruction
+ $page->setData('layout_update_selected', '_no_update_');
+ $page->save();
+ $this->assertNull($page->getData('layout_update_selected'));
+
+ //Existing file update
+ $page->setData('layout_update_selected', 'select1');
+ $page->save();
+ /** @var Page $page */
+ $page = $this->pageFactory->create();
+ $page->load('page100', 'identifier');
+ $this->assertEquals('select1', $page->getData('layout_update_selected'));
+ $this->assertEquals('select1', $this->repo->getFor((int)$page->getId())->getLayoutFileId());
+
+ //Invalid file
+ $caught = null;
+ $page->setData('layout_update_selected', 'nonExisting');
+ try {
+ $page->save();
+ } catch (\Throwable $exception) {
+ $caught = $exception;
+ }
+ $this->assertInstanceOf(LocalizedException::class, $caught);
+ $this->assertEquals($caught->getMessage(), 'Invalid Custom Layout Update selected');
+ }
}
From fd7522ff7c584a123be556c3b8fbb89d05a95c15 Mon Sep 17 00:00:00 2001
From: RomanKis
Date: Thu, 3 Oct 2019 14:40:50 +0300
Subject: [PATCH 0239/1978] graphQl-914: [Customer] Improve consistency of
country field in customer address
---
.../Address/CreateCustomerAddress.php | 1 +
.../Address/ExtractCustomerAddressData.php | 4 +++
.../CustomerGraphQl/etc/schema.graphqls | 5 ++--
.../Customer/CreateCustomerAddressTest.php | 21 ++++++++-------
.../Customer/UpdateCustomerAddressTest.php | 27 ++++++++++---------
5 files changed, 34 insertions(+), 24 deletions(-)
diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php
index 474bd99a8f136..9637b3e555b8b 100644
--- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php
+++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php
@@ -67,6 +67,7 @@ public function __construct(
*/
public function execute(int $customerId, array $data): AddressInterface
{
+ // It is needed because AddressInterface has country_id field.
if (isset($data['country_code'])) {
$data['country_id'] = $data['country_code'];
}
diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php
index 8741bff7aa88d..7992ca8342921 100644
--- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php
+++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php
@@ -127,6 +127,10 @@ public function execute(AddressInterface $address): array
$addressData['customer_id'] = null;
+ if (isset($addressData['country_id'])) {
+ $addressData['country_code'] = $addressData['country_id'];
+ }
+
return $addressData;
}
}
diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
index fea55ec385675..9ce2d61aa458d 100644
--- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
@@ -28,7 +28,7 @@ input CustomerAddressInput {
city: String @doc(description: "The city or town")
region: CustomerAddressRegionInput @doc(description: "An object containing the region name, region code, and region ID")
postcode: String @doc(description: "The customer's ZIP or postal code")
- country_id: CountryCodeEnum @doc(description: "The customer's country") @deprecated(reason: "Use country_code instead.")
+ country_id: CountryCodeEnum @doc(description: "Deprecated, use country_code instead.")
country_code: CountryCodeEnum @doc(description: "The customer's country")
default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address")
default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address")
@@ -103,7 +103,8 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform
customer_id: Int @doc(description: "The customer ID") @deprecated(reason: "customer_id is not needed as part of CustomerAddress, address ID (id) is unique identifier for the addresses.")
region: CustomerAddressRegion @doc(description: "An object containing the region name, region code, and region ID")
region_id: Int @deprecated(reason: "Region ID is excessive on storefront and region code should suffice for all scenarios")
- country_id: String @doc(description: "The customer's country")
+ country_id: String @doc(description: "The customer's country") @deprecated(reason: "Use country_code instead.")
+ country_code: CountryCodeEnum @doc(description: "The customer's country")
street: [String] @doc(description: "An array of strings that define the street number and name")
company: String @doc(description: "The customer's company")
telephone: String @doc(description: "The telephone number")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
index 8860965d07f05..9ccd3b0d46c7a 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
@@ -139,7 +139,6 @@ public function testCreateCustomerAddress()
*/
public function testCreateCustomerAddressWithCountryCode()
{
- $customerId = 1;
$newAddress = [
'region' => [
'region' => 'Arizona',
@@ -195,7 +194,7 @@ public function testCreateCustomerAddressWithCountryCode()
region_id
region_code
}
- country_id
+ country_code
street
company
telephone
@@ -220,16 +219,14 @@ public function testCreateCustomerAddressWithCountryCode()
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
$this->assertArrayHasKey('createCustomerAddress', $response);
$this->assertArrayHasKey('customer_id', $response['createCustomerAddress']);
- $this->assertEquals($customerId, $response['createCustomerAddress']['customer_id']);
+ $this->assertEquals(null, $response['createCustomerAddress']['customer_id']);
$this->assertArrayHasKey('id', $response['createCustomerAddress']);
$address = $this->addressRepository->getById($response['createCustomerAddress']['id']);
$this->assertEquals($address->getId(), $response['createCustomerAddress']['id']);
- $newAddress['country_id'] = $newAddress['country_code'];
- unset($newAddress['country_code']);
- $this->assertCustomerAddressesFields($address, $response['createCustomerAddress']);
- $this->assertCustomerAddressesFields($address, $newAddress);
+ $this->assertCustomerAddressesFields($address, $response['createCustomerAddress'], 'country_code');
+ $this->assertCustomerAddressesFields($address, $newAddress, 'country_code');
}
/**
@@ -412,12 +409,16 @@ public function invalidInputDataProvider()
*
* @param AddressInterface $address
* @param array $actualResponse
+ * @param string $countryFieldName
*/
- private function assertCustomerAddressesFields(AddressInterface $address, array $actualResponse): void
- {
+ private function assertCustomerAddressesFields(
+ AddressInterface $address,
+ array $actualResponse,
+ string $countryFieldName = 'country_id'
+ ): void {
/** @var $addresses */
$assertionMap = [
- ['response_field' => 'country_id', 'expected_value' => $address->getCountryId()],
+ ['response_field' => $countryFieldName, 'expected_value' => $address->getCountryId()],
['response_field' => 'street', 'expected_value' => $address->getStreet()],
['response_field' => 'company', 'expected_value' => $address->getCompany()],
['response_field' => 'telephone', 'expected_value' => $address->getTelephone()],
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
index 84525a55f8a9f..d92c003c080ef 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
@@ -85,7 +85,6 @@ public function testUpdateCustomerAddressWithCountryCode()
{
$userName = 'customer@example.com';
$password = 'password';
- $customerId = 1;
$addressId = 1;
$mutation = $this->getMutationWithCountryCode($addressId);
@@ -93,15 +92,15 @@ public function testUpdateCustomerAddressWithCountryCode()
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
$this->assertArrayHasKey('updateCustomerAddress', $response);
$this->assertArrayHasKey('customer_id', $response['updateCustomerAddress']);
- $this->assertEquals($customerId, $response['updateCustomerAddress']['customer_id']);
+ $this->assertEquals(null, $response['updateCustomerAddress']['customer_id']);
$this->assertArrayHasKey('id', $response['updateCustomerAddress']);
$address = $this->addressRepository->getById($addressId);
$this->assertEquals($address->getId(), $response['updateCustomerAddress']['id']);
- $this->assertCustomerAddressesFields($address, $response['updateCustomerAddress']);
+ $this->assertCustomerAddressesFields($address, $response['updateCustomerAddress'], 'country_code');
$updateAddress = $this->getAddressDataCanadaCountry();
- $this->assertCustomerAddressesFields($address, $updateAddress);
+ $this->assertCustomerAddressesFields($address, $updateAddress, 'country_code');
}
/**
@@ -159,12 +158,16 @@ public function testUpdateCustomerAddressWithMissingAttribute()
*
* @param AddressInterface $address
* @param array $actualResponse
+ * @param string $countryFieldName
*/
- private function assertCustomerAddressesFields(AddressInterface $address, $actualResponse): void
- {
+ private function assertCustomerAddressesFields(
+ AddressInterface $address,
+ $actualResponse,
+ string $countryFieldName = 'country_id'
+ ): void {
/** @var $addresses */
$assertionMap = [
- ['response_field' => 'country_id', 'expected_value' => $address->getCountryId()],
+ ['response_field' => $countryFieldName, 'expected_value' => $address->getCountryId()],
['response_field' => 'street', 'expected_value' => $address->getStreet()],
['response_field' => 'company', 'expected_value' => $address->getCompany()],
['response_field' => 'telephone', 'expected_value' => $address->getTelephone()],
@@ -443,7 +446,7 @@ private function getAddressDataCanadaCountry(): array
'region_id' => 66,
'region_code' => 'AB'
],
- 'country_id' => 'CA',
+ 'country_code' => 'CA',
'street' => ['Line 1 Street', 'Line 2'],
'company' => 'Company Name',
'telephone' => '123456789',
@@ -531,8 +534,8 @@ private function getMutation(int $addressId): string
private function getMutationWithCountryCode(int $addressId): string
{
$updateAddress = $this->getAddressDataCanadaCountry();
- $defaultShippingText = $updateAddress['default_shipping'] ? "true" : "false";
- $defaultBillingText = $updateAddress['default_billing'] ? "true" : "false";
+ $defaultShippingText = $updateAddress['default_shipping'] ? 'true' : 'false';
+ $defaultBillingText = $updateAddress['default_billing'] ? 'true' : 'false';
$mutation
= <<
Date: Thu, 3 Oct 2019 16:02:55 +0300
Subject: [PATCH 0240/1978] MC-5233: DateTime product attributes support
---
.../Product/Attribute/Edit/Tab/Advanced.php | 50 +++++-
.../Product/Attribute/Edit/Tab/Main.php | 112 +++++++++-----
.../Attribute/Edit/Tab/AdvancedTest.php | 104 ++++++++++---
.../Unit/Ui/Component/ColumnFactoryTest.php | 143 ++++++++++++++++--
.../Product/Form/Modifier/EavTest.php | 100 +++++++-----
.../Catalog/Ui/Component/ColumnFactory.php | 72 +++++++--
.../Catalog/Ui/Component/Listing/Columns.php | 5 +-
.../Product/Form/Modifier/Eav.php | 16 ++
app/code/Magento/Catalog/etc/adminhtml/di.xml | 17 +++
app/code/Magento/Catalog/etc/config.xml | 7 +
.../catalog/product/attribute/js.phtml | 1 +
.../product_attribute_add_form.xml | 26 ++++
.../Magento/Eav/Model/Entity/Attribute.php | 37 ++++-
.../Entity/Attribute/Frontend/Datetime.php | 6 +-
.../Attribute/Frontend/DatetimeTest.php | 62 ++++++--
.../Test/Unit/Model/Entity/AttributeTest.php | 2 +
.../adminhtml/web/js/product-attributes.js | 8 +
app/code/Magento/Ui/Component/Filters.php | 3 +
.../Ui/Component/Filters/Type/Date.php | 47 ++++--
.../Component/Form/Element/DataType/Date.php | 24 ++-
.../Unit/Component/Filters/Type/DateTest.php | 113 +++++++++-----
.../Ui/Test/Unit/Component/FiltersTest.php | 47 ++++--
.../Form/Element/DataType/DateTest.php | 69 ++++++++-
.../Ui/view/base/web/js/form/element/date.js | 7 +
.../Ui/view/base/web/js/grid/columns/date.js | 17 ++-
.../view/base/web/js/grid/filters/filters.js | 4 +
.../Ui/view/base/web/js/grid/filters/range.js | 8 +
27 files changed, 872 insertions(+), 235 deletions(-)
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
index 1b6756968662f..89239a2e3e608 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Advanced.php
@@ -7,16 +7,20 @@
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
use Magento\Backend\Block\Widget\Form\Generic;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Config\Model\Config\Source\Yesno;
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
use Magento\Eav\Helper\Data;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Stdlib\DateTime;
/**
- * Product attribute add/edit form main tab
+ * Product attribute add/edit advanced form tab
*
* @api
* @since 100.0.2
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Advanced extends Generic
{
@@ -70,7 +74,7 @@ public function __construct(
* Adding product form elements for editing attribute
*
* @return $this
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
* @SuppressWarnings(PHPMD)
*/
protected function _prepareForm()
@@ -139,7 +143,21 @@ protected function _prepareForm()
'label' => __('Default Value'),
'title' => __('Default Value'),
'value' => $attributeObject->getDefaultValue(),
- 'date_format' => $dateFormat
+ 'date_format' => $dateFormat,
+ ]
+ );
+
+ $timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
+ $fieldset->addField(
+ 'default_value_datetime',
+ 'date',
+ [
+ 'name' => 'default_value_datetime',
+ 'label' => __('Default Value'),
+ 'title' => __('Default Value'),
+ 'value' => $this->getLocalizedDateDefaultValue(),
+ 'date_format' => $dateFormat,
+ 'time_format' => $timeFormat,
]
);
@@ -266,7 +284,7 @@ protected function _initFormValues()
/**
* Retrieve attribute object from registry
*
- * @return mixed
+ * @return Attribute
*/
private function getAttributeObject()
{
@@ -285,4 +303,28 @@ private function getPropertyLocker()
}
return $this->propertyLocker;
}
+
+ /**
+ * Get localized date default value
+ *
+ * @return string
+ * @throws LocalizedException
+ */
+ private function getLocalizedDateDefaultValue(): string
+ {
+ $attributeObject = $this->getAttributeObject();
+ if (empty($attributeObject->getDefaultValue()) || $attributeObject->getFrontendInput() !== 'datetime') {
+ return (string)$attributeObject->getDefaultValue();
+ }
+
+ try {
+ $localizedDate = $this->_localeDate->date($attributeObject->getDefaultValue(), null, false);
+ $localizedDate->setTimezone(new \DateTimeZone($this->_localeDate->getConfigTimezone()));
+ $localizedDate = $localizedDate->format(DateTime::DATETIME_PHP_FORMAT);
+ } catch (\Exception $e) {
+ throw new LocalizedException(__('The default date is invalid.'));
+ }
+
+ return $localizedDate;
+ }
}
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
index 85cf37a1214b5..ddc7273432cb3 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
@@ -7,60 +7,60 @@
/**
* Product attribute add/edit form main tab
*
- * @author Magento Core Team
+ * @author Magento Core Team
*/
namespace Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab;
+use Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply as HelperApply;
use Magento\Eav\Block\Adminhtml\Attribute\Edit\Main\AbstractMain;
+use Magento\Framework\Data\Form\Element\AbstractElement;
+use Magento\Framework\Data\Form\Element\Fieldset;
+use Magento\Framework\DataObject;
/**
+ * Product attribute add/edit form main tab
+ *
* @api
- * @SuppressWarnings(PHPMD.DepthOfInheritance)
* @since 100.0.2
*/
class Main extends AbstractMain
{
/**
- * Adding product form elements for editing attribute
- *
- * @return $this
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
+ * @inheritdoc
*/
protected function _prepareForm()
{
parent::_prepareForm();
- /** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attributeObject */
- $attributeObject = $this->getAttributeObject();
- /* @var $form \Magento\Framework\Data\Form */
- $form = $this->getForm();
- /* @var $fieldset \Magento\Framework\Data\Form\Element\Fieldset */
- $fieldset = $form->getElement('base_fieldset');
- $fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
- foreach ($fieldset->getElements() as $element) {
- /** @var \Magento\Framework\Data\Form\AbstractForm $element */
- if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
- $fieldsToRemove[] = $element->getId();
- }
- }
- foreach ($fieldsToRemove as $id) {
- $fieldset->removeField($id);
- }
+ $this->removeUnusedFields();
+ $this->processFrontendInputTypes();
+
+ $this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $this->getForm()]);
+
+ return $this;
+ }
+ /**
+ * @inheritdoc
+ */
+ protected function _getAdditionalElementTypes()
+ {
+ return ['apply' => HelperApply::class];
+ }
+
+ /**
+ * Process frontend input types for product attributes
+ *
+ * @return void
+ */
+ private function processFrontendInputTypes(): void
+ {
+ $form = $this->getForm();
+ /** @var AbstractElement $frontendInputElm */
$frontendInputElm = $form->getElement('frontend_input');
- $additionalTypes = [
- ['value' => 'price', 'label' => __('Price')],
- ['value' => 'media_image', 'label' => __('Media Image')],
- ];
- $additionalReadOnlyTypes = ['gallery' => __('Gallery')];
- if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
- $additionalTypes[] = [
- 'value' => $attributeObject->getFrontendInput(),
- 'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()],
- ];
- }
+ $additionalTypes = $this->getAdditionalFrontendInputTypes();
- $response = new \Magento\Framework\DataObject();
+ $response = new DataObject();
$response->setTypes([]);
$this->_eventManager->dispatch('adminhtml_product_attribute_types', ['response' => $response]);
$_hiddenFields = [];
@@ -74,19 +74,51 @@ protected function _prepareForm()
$frontendInputValues = array_merge($frontendInputElm->getValues(), $additionalTypes);
$frontendInputElm->setValues($frontendInputValues);
+ }
- $this->_eventManager->dispatch('product_attribute_form_build_main_tab', ['form' => $form]);
+ /**
+ * Get additional Frontend Input Types for product attributes
+ *
+ * @return array
+ */
+ private function getAdditionalFrontendInputTypes(): array
+ {
+ $additionalTypes = [
+ ['value' => 'price', 'label' => __('Price')],
+ ['value' => 'media_image', 'label' => __('Media Image')],
+ ];
- return $this;
+ $additionalReadOnlyTypes = ['gallery' => __('Gallery')];
+ $attributeObject = $this->getAttributeObject();
+ if (isset($additionalReadOnlyTypes[$attributeObject->getFrontendInput()])) {
+ $additionalTypes[] = [
+ 'value' => $attributeObject->getFrontendInput(),
+ 'label' => $additionalReadOnlyTypes[$attributeObject->getFrontendInput()],
+ ];
+ }
+
+ return $additionalTypes;
}
/**
- * Retrieve additional element types for product attributes
+ * Remove unused form fields
*
- * @return array
+ * @return void
*/
- protected function _getAdditionalElementTypes()
+ private function removeUnusedFields(): void
{
- return ['apply' => \Magento\Catalog\Block\Adminhtml\Product\Helper\Form\Apply::class];
+ $form = $this->getForm();
+ /* @var $fieldset Fieldset */
+ $fieldset = $form->getElement('base_fieldset');
+ $fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
+ foreach ($fieldset->getElements() as $element) {
+ /** @var AbstractElement $element */
+ if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
+ $fieldsToRemove[] = $element->getId();
+ }
+ }
+ foreach ($fieldsToRemove as $id) {
+ $fieldset->removeField($id);
+ }
}
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
index 0352bc83cafb7..4d9345d0b3f22 100644
--- a/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Block/Adminhtml/Product/Attribute/Edit/Tab/AdvancedTest.php
@@ -5,66 +5,87 @@
*/
namespace Magento\Catalog\Test\Unit\Block\Adminhtml\Product\Attribute\Edit\Tab;
+use Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Config\Model\Config\Source\Yesno;
use Magento\Eav\Block\Adminhtml\Attribute\PropertyLocker;
+use Magento\Eav\Helper\Data as EavHelper;
+use Magento\Eav\Model\Entity\Type as EntityType;
+use Magento\Framework\Data\Form;
+use Magento\Framework\Data\Form\Element\Fieldset;
+use Magento\Framework\Data\Form\Element\Text;
+use Magento\Framework\Data\FormFactory;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\ReadInterface;
+use Magento\Framework\Registry;
+use Magento\Framework\Stdlib\DateTime;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
/**
+ * Test product attribute add/edit advanced form tab
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AdvancedTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var \Magento\Catalog\Block\Adminhtml\Product\Attribute\Grid
+ * @var Advanced
*/
protected $block;
/**
- * @var \Magento\Framework\Data\FormFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var FormFactory|MockObject
*/
protected $formFactory;
/**
- * @var \Magento\Framework\Registry|\PHPUnit_Framework_MockObject_MockObject
+ * @var Registry|MockObject
*/
protected $registry;
/**
- * @var \Magento\Framework\Stdlib\DateTime\TimezoneInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
protected $localeDate;
/**
- * @var \Magento\Config\Model\Config\Source\Yesno|\PHPUnit_Framework_MockObject_MockObject
+ * @var Yesno|MockObject
*/
protected $yesNo;
/**
- * @var \Magento\Eav\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var EavHelper|MockObject
*/
protected $eavData;
/**
- * @var \Magento\Framework\Filesystem|\PHPUnit_Framework_MockObject_MockObject
+ * @var Filesystem|MockObject
*/
protected $filesystem;
/**
- * @var PropertyLocker|\PHPUnit_Framework_MockObject_MockObject
+ * @var PropertyLocker|MockObject
*/
protected $propertyLocker;
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
- $this->formFactory = $this->createMock(\Magento\Framework\Data\FormFactory::class);
- $this->yesNo = $this->createMock(\Magento\Config\Model\Config\Source\Yesno::class);
- $this->localeDate = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
- $this->eavData = $this->createMock(\Magento\Eav\Helper\Data::class);
- $this->filesystem = $this->createMock(\Magento\Framework\Filesystem::class);
+ $objectManager = new ObjectManager($this);
+ $this->registry = $this->createMock(Registry::class);
+ $this->formFactory = $this->createMock(FormFactory::class);
+ $this->yesNo = $this->createMock(Yesno::class);
+ $this->localeDate = $this->createMock(TimezoneInterface::class);
+ $this->eavData = $this->createMock(EavHelper::class);
+ $this->filesystem = $this->createMock(Filesystem::class);
$this->propertyLocker = $this->createMock(PropertyLocker::class);
$this->block = $objectManager->getObject(
- \Magento\Catalog\Block\Adminhtml\Product\Attribute\Edit\Tab\Advanced::class,
+ Advanced::class,
[
'registry' => $this->registry,
'formFactory' => $this->formFactory,
@@ -77,17 +98,35 @@ protected function setUp()
);
}
+ /**
+ * Test the block's html output
+ */
public function testToHtml()
{
- $fieldSet = $this->createMock(\Magento\Framework\Data\Form\Element\Fieldset::class);
- $form = $this->createMock(\Magento\Framework\Data\Form::class);
+ $defaultValue = 'default_value';
+ $localizedDefaultValue = 'localized_default_value';
+ $frontendInput = 'datetime';
+ $dateFormat = 'mm/dd/yy';
+ $timeFormat = 'H:i:s:';
+ $timeZone = 'America/Chicago';
+
+ $fieldSet = $this->createMock(Fieldset::class);
+ $form = $this->createMock(Form::class);
$attributeModel = $this->createPartialMock(
- \Magento\Catalog\Model\ResourceModel\Eav\Attribute::class,
- ['getDefaultValue', 'setDisabled', 'getId', 'getEntityType', 'getIsUserDefined', 'getAttributeCode']
+ Attribute::class,
+ [
+ 'getDefaultValue',
+ 'setDisabled',
+ 'getId',
+ 'getEntityType',
+ 'getIsUserDefined',
+ 'getAttributeCode',
+ 'getFrontendInput'
+ ]
);
- $entityType = $this->createMock(\Magento\Eav\Model\Entity\Type::class);
- $formElement = $this->createPartialMock(\Magento\Framework\Data\Form\Element\Text::class, ['setDisabled']);
- $directoryReadInterface = $this->createMock(\Magento\Framework\Filesystem\Directory\ReadInterface::class);
+ $entityType = $this->createMock(EntityType::class);
+ $formElement = $this->createPartialMock(Text::class, ['setDisabled']);
+ $directoryReadInterface = $this->createMock(ReadInterface::class);
$this->registry->expects($this->any())->method('registry')->with('entity_attribute')
->willReturn($attributeModel);
@@ -95,13 +134,28 @@ public function testToHtml()
$form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
$form->expects($this->any())->method('getElement')->willReturn($formElement);
$fieldSet->expects($this->any())->method('addField')->willReturnSelf();
- $attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
+ $attributeModel->expects($this->any())->method('getDefaultValue')->willReturn($defaultValue);
$attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
$attributeModel->expects($this->any())->method('getId')->willReturn(1);
$attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
$attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
$attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
- $this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
+ $attributeModel->expects($this->any())->method('getFrontendInput')->willReturn($frontendInput);
+
+ $dateTimeMock = $this->createMock(\DateTime::class);
+ $dateTimeMock->expects($this->once())->method('setTimezone')->with(new \DateTimeZone($timeZone));
+ $dateTimeMock->expects($this->once())
+ ->method('format')
+ ->with(DateTime::DATETIME_PHP_FORMAT)
+ ->willReturn($localizedDefaultValue);
+ $this->localeDate->expects($this->any())->method('getDateFormat')->willReturn($dateFormat);
+ $this->localeDate->expects($this->any())->method('getTimeFormat')->willReturn($timeFormat);
+ $this->localeDate->expects($this->once())->method('getConfigTimezone')->willReturn($timeZone);
+ $this->localeDate->expects($this->once())
+ ->method('date')
+ ->with($defaultValue, null, false)
+ ->willReturn($dateTimeMock);
+
$entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
$this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
$formElement->expects($this->exactly(2))->method('setDisabled')->willReturnSelf();
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
index 774edcfeb6b64..f002173de7996 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
@@ -7,14 +7,16 @@
namespace Magento\Catalog\Test\Unit\Ui\Component;
-use PHPUnit\Framework\TestCase;
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Ui\Component\ColumnFactory;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\ColumnInterface;
use Magento\Ui\Component\Filters\FilterModifier;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
* ColumnFactory test.
@@ -32,25 +34,30 @@ class ColumnFactoryTest extends TestCase
private $objectManager;
/**
- * @var ProductAttributeInterface|\PHPUnit\Framework\MockObject\MockObject
+ * @var Attribute|MockObject
*/
private $attribute;
/**
- * @var ContextInterface|\PHPUnit\Framework\MockObject\MockObject
+ * @var ContextInterface|MockObject
*/
private $context;
/**
- * @var UiComponentFactory|\PHPUnit\Framework\MockObject\MockObject
+ * @var UiComponentFactory|MockObject
*/
private $uiComponentFactory;
/**
- * @var ColumnInterface|\PHPUnit\Framework\MockObject\MockObject
+ * @var ColumnInterface|MockObject
*/
private $column;
+ /**
+ * @var TimezoneInterface|MockObject
+ */
+ private $timeZone;
+
/**
* @inheritdoc
*/
@@ -58,18 +65,30 @@ protected function setUp(): void
{
$this->objectManager = new ObjectManager($this);
- $this->attribute = $this->getMockBuilder(ProductAttributeInterface::class)
- ->setMethods(['usesSource'])
- ->getMockForAbstractClass();
+ $this->attribute = $this->createPartialMock(
+ Attribute::class,
+ [
+ 'getAttributeCode',
+ 'getIsFilterableInGrid',
+ 'getFrontendInput',
+ 'getDefaultFrontendLabel',
+ 'getIsVisibleInGrid',
+ ]
+ );
$this->context = $this->createMock(ContextInterface::class);
$this->uiComponentFactory = $this->createMock(UiComponentFactory::class);
$this->column = $this->getMockForAbstractClass(ColumnInterface::class);
$this->uiComponentFactory->method('create')
->willReturn($this->column);
+ $this->timeZone = $this->createMock(TimezoneInterface::class);
- $this->columnFactory = $this->objectManager->getObject(ColumnFactory::class, [
- 'componentFactory' => $this->uiComponentFactory
- ]);
+ $this->columnFactory = $this->objectManager->getObject(
+ ColumnFactory::class,
+ [
+ 'componentFactory' => $this->uiComponentFactory,
+ 'timezone' => $this->timeZone,
+ ]
+ );
}
/**
@@ -96,7 +115,6 @@ public function testCreatedObject(): void
*
* @param array $filterModifiers
* @param null|string $filter
- *
* @return void
* @dataProvider filterModifiersProvider
*/
@@ -132,7 +150,7 @@ public function testCreateWithNotFilterableInGridAttribute(array $filterModifier
}
/**
- * Filter modifiers data provider.
+ * Filter modifiers data provider
*
* @return array
*/
@@ -153,4 +171,101 @@ public function filterModifiersProvider(): array
],
];
}
+
+ /**
+ * Test to create date column
+ *
+ * @param string $frontendInput
+ * @param bool $showsTime
+ * @param string $expectedDateFormat
+ * @param string $expectedTimezone
+ * @dataProvider createDateColumnDataProvider
+ */
+ public function testCreateDateColumn(
+ string $frontendInput,
+ bool $showsTime,
+ string $expectedDateFormat,
+ string $expectedTimezone
+ ) {
+ $attributeCode = 'attribute_code';
+ $dateFormat = 'date_format';
+ $dateTimeFormat = 'datetime_format';
+ $defaultTimezone = 'default_timezone';
+ $configTimezone = 'config_timezone';
+ $label = 'Date label';
+
+ $expectedConfig = [
+ 'data' => [
+ 'config' => [
+ 'label' => __($label),
+ 'dataType' => 'date',
+ 'add_field' => true,
+ 'visible' => true,
+ 'filter' => 'dateRange',
+ 'component' => 'Magento_Ui/js/grid/columns/date',
+ 'timeZone' => $expectedTimezone,
+ 'dateFormat' => $expectedDateFormat,
+ 'options' => [
+ 'showsTime' => $showsTime
+ ]
+ ],
+ ],
+ 'context' => $this->context,
+ ];
+
+ $this->attribute->method('getAttributeCode')
+ ->willReturn($attributeCode);
+ $this->attribute->method('getDefaultFrontendLabel')
+ ->willReturn($label);
+ $this->attribute->method('getIsFilterableInGrid')
+ ->willReturn(true);
+ $this->attribute->method('getIsVisibleInGrid')
+ ->willReturn(true);
+ $this->attribute->method('getFrontendInput')
+ ->willReturn($frontendInput);
+
+ $this->timeZone->method('getDateFormat')
+ ->with(\IntlDateFormatter::MEDIUM)
+ ->willReturn($dateFormat);
+ $this->timeZone->method('getDateTimeFormat')
+ ->with(\IntlDateFormatter::MEDIUM)
+ ->willReturn($dateTimeFormat);
+ $this->timeZone->method('getDefaultTimezone')
+ ->willReturn($defaultTimezone);
+ $this->timeZone->method('getConfigTimezone')
+ ->willReturn($configTimezone);
+
+ $this->uiComponentFactory->expects($this->once())
+ ->method('create')
+ ->with($attributeCode, 'column', $expectedConfig)
+ ->willReturn($this->column);
+
+ $this->assertEquals(
+ $this->column,
+ $this->columnFactory->create($this->attribute, $this->context)
+ );
+ }
+
+ /**
+ * Data provider to create date column test
+ *
+ * @return array
+ */
+ public function createDateColumnDataProvider(): array
+ {
+ return [
+ [
+ 'frontendInput' => 'date',
+ 'showsTime' => false,
+ 'dateFormat' => 'date_format',
+ 'expectedTimezone' => 'default_timezone',
+ ],
+ [
+ 'frontendInput' => 'datetime',
+ 'showsTime' => true,
+ 'expectedDateFormat' => 'datetime_format',
+ 'expectedTimezone' => 'config_timezone',
+ ],
+ ];
+ }
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php
index 88075b13f1430..834cb505e0903 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php
@@ -38,6 +38,7 @@
use Magento\Framework\Stdlib\ArrayManager;
use Magento\Catalog\Model\ResourceModel\Eav\AttributeFactory as EavAttributeFactory;
use Magento\Framework\Event\ManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Class EavTest
@@ -49,142 +50,142 @@
class EavTest extends AbstractModifierTest
{
/**
- * @var Config|\PHPUnit_Framework_MockObject_MockObject
+ * @var Config|MockObject
*/
private $eavConfigMock;
/**
- * @var EavValidationRules|\PHPUnit_Framework_MockObject_MockObject
+ * @var EavValidationRules|MockObject
*/
private $eavValidationRulesMock;
/**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var RequestInterface|MockObject
*/
private $requestMock;
/**
- * @var GroupCollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupCollectionFactory|MockObject
*/
private $groupCollectionFactoryMock;
/**
- * @var GroupCollection|\PHPUnit_Framework_MockObject_MockObject
+ * @var GroupCollection|MockObject
*/
private $groupCollectionMock;
/**
- * @var Group|\PHPUnit_Framework_MockObject_MockObject
+ * @var Group|MockObject
*/
private $groupMock;
/**
- * @var EavAttribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var EavAttribute|MockObject
*/
private $attributeMock;
/**
- * @var EntityType|\PHPUnit_Framework_MockObject_MockObject
+ * @var EntityType|MockObject
*/
private $entityTypeMock;
/**
- * @var AttributeCollectionFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeCollectionFactory|MockObject
*/
private $attributeCollectionFactoryMock;
/**
- * @var AttributeCollection|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeCollection|MockObject
*/
private $attributeCollectionMock;
/**
- * @var StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var FormElementMapper|\PHPUnit_Framework_MockObject_MockObject
+ * @var FormElementMapper|MockObject
*/
private $formElementMapperMock;
/**
- * @var MetaPropertiesMapper|\PHPUnit_Framework_MockObject_MockObject
+ * @var MetaPropertiesMapper|MockObject
*/
private $metaPropertiesMapperMock;
/**
- * @var SearchCriteriaBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteriaBuilder|MockObject
*/
private $searchCriteriaBuilderMock;
/**
- * @var ProductAttributeGroupRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeGroupRepositoryInterface|MockObject
*/
private $attributeGroupRepositoryMock;
/**
- * @var SearchCriteria|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchCriteria|MockObject
*/
private $searchCriteriaMock;
/**
- * @var SortOrderBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var SortOrderBuilder|MockObject
*/
private $sortOrderBuilderMock;
/**
- * @var ProductAttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeRepositoryInterface|MockObject
*/
private $attributeRepositoryMock;
/**
- * @var AttributeGroupInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AttributeGroupInterface|MockObject
*/
private $attributeGroupMock;
/**
- * @var SearchResultsInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SearchResultsInterface|MockObject
*/
private $searchResultsMock;
/**
- * @var Attribute|\PHPUnit_Framework_MockObject_MockObject
+ * @var Attribute|MockObject
*/
private $eavAttributeMock;
/**
- * @var StoreInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreInterface|MockObject
*/
protected $storeMock;
/**
- * @var Currency|\PHPUnit_Framework_MockObject_MockObject
+ * @var Currency|MockObject
*/
protected $currencyMock;
/**
- * @var CurrencyLocale|\PHPUnit_Framework_MockObject_MockObject
+ * @var CurrencyLocale|MockObject
*/
protected $currencyLocaleMock;
/**
- * @var ProductAttributeInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ProductAttributeInterface|MockObject
*/
protected $productAttributeMock;
/**
- * @var ArrayManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var ArrayManager|MockObject
*/
protected $arrayManagerMock;
/**
- * @var EavAttributeFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var EavAttributeFactory|MockObject
*/
protected $eavAttributeFactoryMock;
/**
- * @var ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ManagerInterface|MockObject
*/
protected $eventManagerMock;
@@ -457,8 +458,10 @@ public function testModifyData()
* @param string|null $attrValue
* @param array $expected
* @param bool $locked
- * @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists
- * @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
+ * @param string|null $frontendInput
+ * @param array $expectedCustomize
+ * @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::isProductExists
+ * @covers \Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\Eav::setupAttributeMeta
* @dataProvider setupAttributeMetaDataProvider
*/
public function testSetupAttributeMetaDefaultAttribute(
@@ -466,7 +469,9 @@ public function testSetupAttributeMetaDefaultAttribute(
bool $productRequired,
$attrValue,
array $expected,
- $locked = false
+ bool $locked = false,
+ string $frontendInput = null,
+ array $expectedCustomize = []
) : void {
$configPath = 'arguments/data/config';
$groupCode = 'product-details';
@@ -492,6 +497,7 @@ public function testSetupAttributeMetaDefaultAttribute(
$this->productAttributeMock->method('getDefaultValue')->willReturn('required_value');
$this->productAttributeMock->method('getAttributeCode')->willReturn('code');
$this->productAttributeMock->method('getValue')->willReturn('value');
+ $this->productAttributeMock->method('getFrontendInput')->willReturn($frontendInput);
$attributeMock = $this->getMockBuilder(AttributeInterface::class)
->setMethods(['getValue'])
@@ -527,14 +533,16 @@ function ($value) use ($attributeOptionsExpected) {
}
)
)
- ->willReturn($expected);
+ ->willReturn($expected + $expectedCustomize);
$this->arrayManagerMock->method('get')->willReturn([]);
$this->arrayManagerMock->method('exists')->willReturn(true);
+ $actual = $this->eav->setupAttributeMeta($this->productAttributeMock, $groupCode, $sortOrder);
+
$this->assertEquals(
- $expected,
- $this->eav->setupAttributeMeta($this->productAttributeMock, $groupCode, $sortOrder)
+ $expected + $expectedCustomize,
+ $actual
);
}
@@ -660,7 +668,29 @@ public function setupAttributeMetaDataProvider()
'globalScope' => false,
'sortOrder' => 0,
],
- ]
+ ],
+ 'datetime_null_prod_not_new_and_required' => [
+ 'productId' => 1,
+ 'productRequired' => true,
+ 'attrValue' => 'val',
+ 'expected' => [
+ 'dataType' => 'datetime',
+ 'formElement' => 'datetime',
+ 'visible' => null,
+ 'required' => true,
+ 'notice' => null,
+ 'default' => null,
+ 'label' => new Phrase(null),
+ 'code' => 'code',
+ 'source' => 'product-details',
+ 'scopeLabel' => '',
+ 'globalScope' => false,
+ 'sortOrder' => 0,
+ ],
+ 'locked' => false,
+ 'frontendInput' => 'datetime',
+ 'expectedCustomize' => ['arguments' => ['data' => ['config' => ['options' => ['showsTime' => 1]]]]],
+ ],
];
}
}
diff --git a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
index 9a6a22fcb0985..c538273476b1f 100644
--- a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
+++ b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
@@ -5,7 +5,14 @@
*/
namespace Magento\Catalog\Ui\Component;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use Magento\Framework\View\Element\UiComponent\ContextInterface;
+use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Filters\FilterModifier;
+use Magento\Ui\Component\Listing\Columns\ColumnInterface;
/**
* Column Factory
@@ -16,7 +23,7 @@
class ColumnFactory
{
/**
- * @var \Magento\Framework\View\Element\UiComponentFactory
+ * @var UiComponentFactory
*/
protected $componentFactory;
@@ -40,25 +47,36 @@ class ColumnFactory
'select' => 'select',
'multiselect' => 'multiselect',
'date' => 'date',
+ 'datetime' => 'date',
];
/**
- * @param \Magento\Framework\View\Element\UiComponentFactory $componentFactory
+ * @var TimezoneInterface
*/
- public function __construct(\Magento\Framework\View\Element\UiComponentFactory $componentFactory)
- {
+ private $timezone;
+
+ /**
+ * @param UiComponentFactory $componentFactory
+ * @param TimezoneInterface|null $timezone
+ */
+ public function __construct(
+ UiComponentFactory $componentFactory,
+ TimezoneInterface $timezone = null
+ ) {
$this->componentFactory = $componentFactory;
+ $this->timezone = $timezone
+ ?? ObjectManager::getInstance()->get(TimezoneInterface::class);
}
/**
* Create Factory
*
- * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
- * @param \Magento\Framework\View\Element\UiComponent\ContextInterface $context
+ * @param ProductAttributeInterface $attribute
+ * @param ContextInterface $context
* @param array $config
*
- * @return \Magento\Ui\Component\Listing\Columns\ColumnInterface
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @return ColumnInterface
+ * @throws LocalizedException
*/
public function create($attribute, $context, array $config = [])
{
@@ -84,19 +102,46 @@ public function create($attribute, $context, array $config = [])
$optionData['__disableTmpl'] = true;
}
}
-
+
$config['component'] = $this->getJsComponent($config['dataType']);
-
+
+ if ($config['dataType'] === 'date') {
+ $config += $this->getDateConfig($attribute);
+ }
+
$arguments = [
'data' => [
'config' => $config,
],
'context' => $context,
];
-
+
return $this->componentFactory->create($columnName, 'column', $arguments);
}
+ /**
+ * Get config for Date columns
+ *
+ * @param ProductAttributeInterface $attribute
+ * @return array
+ */
+ private function getDateConfig(ProductAttributeInterface $attribute): array
+ {
+ $isDatetime = $attribute->getFrontendInput() === 'datetime';
+ $dateFormat = $isDatetime
+ ? $this->timezone->getDateTimeFormat(\IntlDateFormatter::MEDIUM)
+ : $this->timezone->getDateFormat(\IntlDateFormatter::MEDIUM);
+ $timeZone = $isDatetime
+ ? $this->timezone->getConfigTimezone()
+ : $this->timezone->getDefaultTimezone();
+
+ return [
+ 'timeZone' => $timeZone,
+ 'dateFormat' => $dateFormat,
+ 'options' => [ 'showsTime' => $isDatetime],
+ ];
+ }
+
/**
* Get Js Component
*
@@ -112,7 +157,7 @@ protected function getJsComponent($dataType)
/**
* Get Data Type
*
- * @param \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute
+ * @param ProductAttributeInterface $attribute
*
* @return string
*/
@@ -129,8 +174,9 @@ protected function getDataType($attribute)
*/
protected function getFilterType($frontendInput)
{
- $filtersMap = ['date' => 'dateRange'];
+ $filtersMap = ['date' => 'dateRange', 'datetime' => 'dateRange'];
$result = array_replace_recursive($this->dataTypeMap, $filtersMap);
+
return $result[$frontendInput] ?? $result['default'];
}
}
diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php
index 8ea6d8b9e5a06..d7b9bc3846f49 100644
--- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php
+++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php
@@ -6,6 +6,8 @@
namespace Magento\Catalog\Ui\Component\Listing;
/**
+ * Column IU component
+ *
* @api
* @since 100.0.2
*/
@@ -30,6 +32,7 @@ class Columns extends \Magento\Ui\Component\Listing\Columns
'boolean' => 'select',
'multiselect' => 'select',
'date' => 'dateRange',
+ 'datetime' => 'datetimeRange',
];
/**
@@ -52,7 +55,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function prepare()
{
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
index 4039ff862f6fe..e41b2390930f0 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
@@ -746,6 +746,9 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC
// Gallery attribute is being handled by "Images And Videos" section
$meta = [];
break;
+ case 'datetime':
+ $meta = $this->customizeDatetimeAttribute($meta);
+ break;
}
//Checking access to design config.
@@ -948,6 +951,19 @@ private function customizeWysiwyg(ProductAttributeInterface $attribute, array $m
return $meta;
}
+ /**
+ * Customize datetime attribute
+ *
+ * @param array $meta
+ * @return array
+ */
+ private function customizeDatetimeAttribute(array $meta)
+ {
+ $meta['arguments']['data']['config']['options']['showsTime'] = 1;
+
+ return $meta;
+ }
+
/**
* Retrieve form element
*
diff --git a/app/code/Magento/Catalog/etc/adminhtml/di.xml b/app/code/Magento/Catalog/etc/adminhtml/di.xml
index c04cfb2dce00a..9e02d3da9f5d8 100644
--- a/app/code/Magento/Catalog/etc/adminhtml/di.xml
+++ b/app/code/Magento/Catalog/etc/adminhtml/di.xml
@@ -232,4 +232,21 @@
+
+
+
+ -
+
- datetime
+ - Date and Time
+
+
+
+
+
+
+
+ - date
+
+
+
diff --git a/app/code/Magento/Catalog/etc/config.xml b/app/code/Magento/Catalog/etc/config.xml
index 20511f4ff2295..8506d2ae03032 100644
--- a/app/code/Magento/Catalog/etc/config.xml
+++ b/app/code/Magento/Catalog/etc/config.xml
@@ -78,5 +78,12 @@
stretch
+
+
+
+ datetime
+
+
+
diff --git a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml
index f020eddc35dbd..212a345f4bcbc 100644
--- a/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml
+++ b/app/code/Magento/Catalog/view/adminhtml/templates/catalog/product/attribute/js.phtml
@@ -172,6 +172,7 @@ function switchDefaultValueField()
break;
case 'date':
+ case 'datetime':
defaultValueDateVisibility = true;
break;
diff --git a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml
index 6c5d37a92ea4a..3a6621137ed5a 100644
--- a/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml
+++ b/app/code/Magento/Catalog/view/adminhtml/ui_component/product_attribute_add_form.xml
@@ -101,6 +101,7 @@
- textarea
- texteditor
- date
+ - datetime
- boolean
- multiselect
- select
@@ -287,6 +288,7 @@
- textarea
- texteditor
- date
+ - datetime
- boolean
- multiselect
- select
@@ -376,6 +378,29 @@
default_value_date
+
+
+ -
+
-
+
- datetime
+
+
+
+
+ text
+ Default Value
+ default_value_datetime
+
+
+
+
+
+ true
+
+
+
+
+
-
@@ -412,6 +437,7 @@
- textarea
- texteditor
- date
+ - date
- boolean
- multiselect
- select
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php
index 8bd9ca2cc03c8..82eafa6174bb2 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute.php
@@ -285,13 +285,8 @@ public function beforeSave()
// save default date value as timestamp
if ($hasDefaultValue) {
- try {
- $locale = $this->_localeResolver->getLocale();
- $defaultValue = $this->_localeDate->date($defaultValue, $locale, false, false);
- $this->setDefaultValue($defaultValue->format(DateTime::DATETIME_PHP_FORMAT));
- } catch (\Exception $e) {
- throw new LocalizedException(__('The default date is invalid. Verify the date and try again.'));
- }
+ $defaultValue = $this->getUtcDateDefaultValue($defaultValue);
+ $this->setDefaultValue($defaultValue);
}
}
@@ -310,6 +305,29 @@ public function beforeSave()
return parent::beforeSave();
}
+ /**
+ * Convert localized date default value to UTC
+ *
+ * @param string $defaultValue
+ * @return string
+ * @throws LocalizedException
+ */
+ private function getUtcDateDefaultValue(string $defaultValue): string
+ {
+ $hasTime = $this->getFrontendInput() === 'datetime';
+ try {
+ $defaultValue = $this->_localeDate->date($defaultValue, null, $hasTime, $hasTime);
+ if ($hasTime) {
+ $defaultValue->setTimezone(new \DateTimeZone($this->_localeDate->getDefaultTimezone()));
+ }
+ $utcValue = $defaultValue->format(DateTime::DATETIME_PHP_FORMAT);
+ } catch (\Exception $e) {
+ throw new LocalizedException(__('The default date is invalid. Verify the date and try again.'));
+ }
+
+ return $utcValue;
+ }
+
/**
* @inheritdoc
*
@@ -346,6 +364,7 @@ public function getBackendTypeByInput($type)
break;
case 'date':
+ case 'datetime':
$field = 'datetime';
break;
@@ -401,6 +420,10 @@ public function getDefaultValueByInput($type)
$field = 'default_value_date';
break;
+ case 'datetime':
+ $field = 'default_value_datetime';
+ break;
+
case 'boolean':
$field = 'default_value_yesno';
break;
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
index a9cd3be246bb1..8effd73d34af2 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
@@ -7,6 +7,8 @@
namespace Magento\Eav\Model\Entity\Attribute\Frontend;
/**
+ * Entity datetime frontend attribute
+ *
* @api
* @since 100.0.2
*/
@@ -42,10 +44,12 @@ public function getValue(\Magento\Framework\DataObject $object)
$value = parent::getValue($object);
if ($value) {
+ $timeType = $this->getAttribute()->getFrontendInput() === 'datetime'
+ ? \IntlDateFormatter::MEDIUM : \IntlDateFormatter::NONE;
$data = $this->_localeDate->formatDateTime(
new \DateTime($value),
\IntlDateFormatter::MEDIUM,
- \IntlDateFormatter::NONE
+ $timeType
);
}
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php
index 66549f2e00415..c775548fc8c75 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php
@@ -5,22 +5,31 @@
*/
namespace Magento\Eav\Test\Unit\Model\Entity\Attribute\Frontend;
+use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Eav\Model\Entity\Attribute\Frontend\Datetime;
+use Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory;
+use Magento\Framework\DataObject;
+use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class DatetimeTest extends \PHPUnit\Framework\TestCase
+/**
+ * Class to test Entity datetime frontend attribute
+ */
+class DatetimeTest extends TestCase
{
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var TimezoneInterface|MockObject
*/
private $localeDateMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var BooleanFactory|MockObject
*/
private $booleanFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var AbstractAttribute|MockObject
*/
private $attributeMock;
@@ -29,40 +38,63 @@ class DatetimeTest extends \PHPUnit\Framework\TestCase
*/
private $model;
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
- $this->booleanFactoryMock = $this->createMock(\Magento\Eav\Model\Entity\Attribute\Source\BooleanFactory::class);
- $this->localeDateMock = $this->createMock(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
+ $this->booleanFactoryMock = $this->createMock(BooleanFactory::class);
+ $this->localeDateMock = $this->createMock(TimezoneInterface::class);
$this->attributeMock = $this->createPartialMock(
- \Magento\Eav\Model\Entity\Attribute\AbstractAttribute::class,
- ['getAttributeCode', 'getFrontendLabel', 'getData']
+ AbstractAttribute::class,
+ ['getAttributeCode', 'getFrontendLabel', 'getFrontendInput']
);
$this->model = new Datetime($this->booleanFactoryMock, $this->localeDateMock);
$this->model->setAttribute($this->attributeMock);
}
- public function testGetValue()
+ /**
+ * Test to retrieve attribute value
+ *
+ * @param string $frontendInput
+ * @param int $timeType
+ * @dataProvider getValueDataProvider
+ */
+ public function testGetValue(string $frontendInput, int $timeType)
{
$attributeValue = '11-11-2011';
+ $attributeCode = 'datetime';
$date = new \DateTime($attributeValue);
- $object = new \Magento\Framework\DataObject(['datetime' => $attributeValue]);
+ $object = new DataObject([$attributeCode => $attributeValue]);
$this->attributeMock->expects($this->any())
->method('getAttributeCode')
- ->willReturn('datetime');
+ ->willReturn($attributeCode);
$this->attributeMock->expects($this->any())
- ->method('getData')
- ->with('frontend_input')
- ->willReturn('text');
+ ->method('getFrontendInput')
+ ->willReturn($frontendInput);
$this->localeDateMock->expects($this->once())
->method('formatDateTime')
- ->with($date, \IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE, null, null, null)
+ ->with($date, \IntlDateFormatter::MEDIUM, $timeType)
->willReturn($attributeValue);
$this->assertEquals($attributeValue, $this->model->getValue($object));
}
+ /**
+ * Retrieve attribute value data provider
+ *
+ * @return array
+ */
+ public function getValueDataProvider(): array
+ {
+ return [
+ ['frontendInput' => 'date', 'timeType' => \IntlDateFormatter::NONE],
+ ['frontendInput' => 'datetime', 'timeType' => \IntlDateFormatter::MEDIUM],
+ ];
+ }
+
/**
* @param mixed $labelText
* @param string $attributeCode
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php
index 402497a1379c0..7aa5bca00f0b6 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/AttributeTest.php
@@ -57,6 +57,7 @@ public static function dataGetBackendTypeByInput()
['image', 'text'],
['textarea', 'text'],
['date', 'datetime'],
+ ['datetime', 'datetime'],
['select', 'int'],
['boolean', 'int'],
['price', 'decimal'],
@@ -91,6 +92,7 @@ public static function dataGetDefaultValueByInput()
['weight', 'default_value_text'],
['textarea', 'default_value_textarea'],
['date', 'default_value_date'],
+ ['datetime', 'default_value_datetime'],
['boolean', 'default_value_yesno']
];
}
diff --git a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js
index f795f99e8112d..9e48af20ee945 100644
--- a/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js
+++ b/app/code/Magento/Swatches/view/adminhtml/web/js/product-attributes.js
@@ -31,6 +31,7 @@ define([
defaultValueText: $('#default_value_text'),
defaultValueTextarea: $('#default_value_textarea'),
defaultValueDate: $('#default_value_date'),
+ defaultValueDatetime: $('#default_value_datetime'),
defaultValueYesno: $('#default_value_yesno'),
isGlobal: $('#is_global'),
useProductImageForSwatch: $('#use_product_image_for_swatch'),
@@ -178,6 +179,7 @@ define([
defaultValueTextVisibility = false,
defaultValueTextareaVisibility = false,
defaultValueDateVisibility = false,
+ defaultValueDatetimeVisibility = false,
defaultValueYesnoVisibility = false,
scopeVisibility = true,
useProductImageForSwatch = false,
@@ -203,6 +205,10 @@ define([
defaultValueDateVisibility = true;
break;
+ case 'datetime':
+ defaultValueDatetimeVisibility = true;
+ break;
+
case 'boolean':
defaultValueYesnoVisibility = true;
break;
@@ -256,6 +262,7 @@ define([
defaultValueTextVisibility = false;
defaultValueTextareaVisibility = false;
defaultValueDateVisibility = false;
+ defaultValueDatetimeVisibility = false;
defaultValueYesnoVisibility = false;
break;
@@ -279,6 +286,7 @@ define([
this.setRowVisibility(this.defaultValueText, defaultValueTextVisibility);
this.setRowVisibility(this.defaultValueTextarea, defaultValueTextareaVisibility);
this.setRowVisibility(this.defaultValueDate, defaultValueDateVisibility);
+ this.setRowVisibility(this.defaultValueDatetime, defaultValueDatetimeVisibility);
this.setRowVisibility(this.defaultValueYesno, defaultValueYesnoVisibility);
this.setRowVisibility(this.isGlobal, scopeVisibility);
diff --git a/app/code/Magento/Ui/Component/Filters.php b/app/code/Magento/Ui/Component/Filters.php
index fe02c23af9c8a..5bf89ae7936e9 100644
--- a/app/code/Magento/Ui/Component/Filters.php
+++ b/app/code/Magento/Ui/Component/Filters.php
@@ -12,6 +12,8 @@
use Magento\Ui\Component\Listing\Columns\ColumnInterface;
/**
+ * Grid filters UI component
+ *
* @api
* @since 100.0.2
*/
@@ -36,6 +38,7 @@ class Filters extends AbstractComponent implements ObserverInterface
'textRange' => 'filterRange',
'select' => 'filterSelect',
'dateRange' => 'filterDate',
+ 'datetimeRange' => 'filterDate',
];
/**
diff --git a/app/code/Magento/Ui/Component/Filters/Type/Date.php b/app/code/Magento/Ui/Component/Filters/Type/Date.php
index e854b888c45e6..28ad8568ebe31 100644
--- a/app/code/Magento/Ui/Component/Filters/Type/Date.php
+++ b/app/code/Magento/Ui/Component/Filters/Type/Date.php
@@ -9,6 +9,8 @@
use Magento\Ui\Component\Form\Element\DataType\Date as DataTypeDate;
/**
+ * Date grid filter UI Component
+ *
* @api
* @since 100.0.2
*/
@@ -84,30 +86,18 @@ protected function applyFilter()
if (isset($value['from'])) {
$this->applyFilterByType(
'gteq',
- $this->wrappedComponent->convertDate(
- $value['from'],
- 0,
- 0,
- 0,
- !$this->getData('config/skipTimeZoneConversion')
- )
+ $this->convertDatetime((string)$value['from'])
);
}
if (isset($value['to'])) {
$this->applyFilterByType(
'lteq',
- $this->wrappedComponent->convertDate(
- $value['to'],
- 23,
- 59,
- 59,
- !$this->getData('config/skipTimeZoneConversion')
- )
+ $this->convertDatetime((string)$value['to'], 23, 59, 59)
);
}
} else {
- $this->applyFilterByType('eq', $this->wrappedComponent->convertDate($value));
+ $this->applyFilterByType('eq', $this->convertDatetime((string)$value));
}
}
}
@@ -130,4 +120,31 @@ protected function applyFilterByType($type, $value)
$this->getContext()->getDataProvider()->addFilter($filter);
}
}
+
+ /**
+ * Convert given date to default (UTC) timezone
+ *
+ * @param string $value
+ * @param int $hour
+ * @param int $minute
+ * @param int $second
+ * @return \DateTime
+ */
+ private function convertDatetime(string $value, int $hour = 0, int $minute = 0, int $second = 0): ?\DateTime
+ {
+ $value = $this->getData('config/options/showsTime')
+ ? $this->wrappedComponent->convertDatetime(
+ $value,
+ !$this->getData('config/skipTimeZoneConversion')
+ )
+ : $this->wrappedComponent->convertDate(
+ $value,
+ $hour,
+ $minute,
+ $second,
+ !$this->getData('config/skipTimeZoneConversion')
+ );
+
+ return $value;
+ }
}
diff --git a/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php b/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
index 31d2fe786cfd8..8ea6236e8e2e2 100644
--- a/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
+++ b/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
@@ -111,7 +111,7 @@ public function getComponentName()
public function convertDate($date, $hour = 0, $minute = 0, $second = 0, $setUtcTimeZone = true)
{
try {
- $dateObj = $this->localeDate->date($date, $this->getLocale(), true);
+ $dateObj = $this->localeDate->date($date, $this->getLocale(), false);
$dateObj->setTime($hour, $minute, $second);
//convert store date to default date in UTC timezone without DST
if ($setUtcTimeZone) {
@@ -122,4 +122,26 @@ public function convertDate($date, $hour = 0, $minute = 0, $second = 0, $setUtcT
return null;
}
}
+
+ /**
+ * Convert given date to default (UTC) timezone
+ *
+ * @param string $date
+ * @param bool $setUtcTimeZone
+ * @return \DateTime|null
+ */
+ public function convertDatetime(string $date, bool $setUtcTimeZone = true): ?\DateTime
+ {
+ try {
+ $date = rtrim($date, 'Z');
+ $dateObj = new \DateTime($date, new \DateTimeZone($this->localeDate->getConfigTimezone()));
+ //convert store date to default date in UTC timezone without DST
+ if ($setUtcTimeZone) {
+ $dateObj->setTimezone(new \DateTimeZone('UTC'));
+ }
+ return $dateObj;
+ } catch (\Exception $e) {
+ return null;
+ }
+ }
}
diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php
index 78456968cbef1..7038a587be0b0 100644
--- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php
+++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php
@@ -13,6 +13,7 @@
use Magento\Ui\Component\Filters\Type\Date;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\Form\Element\DataType\Date as FormDate;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Class DateTest
@@ -20,27 +21,27 @@
class DateTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var ContextInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ContextInterface|MockObject
*/
private $contextMock;
/**
- * @var UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var UiComponentFactory|MockObject
*/
private $uiComponentFactory;
/**
- * @var FilterBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterBuilder|MockObject
*/
private $filterBuilderMock;
/**
- * @var FilterModifier|\PHPUnit_Framework_MockObject_MockObject
+ * @var FilterModifier|MockObject
*/
private $filterModifierMock;
/**
- * @var DataProviderInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataProviderInterface|MockObject
*/
private $dataProviderMock;
@@ -89,18 +90,19 @@ public function testGetComponentName()
* Run test prepare method
*
* @param string $name
+ * @param bool $showsTime
* @param array $filterData
* @param array|null $expectedCondition
* @dataProvider getPrepareDataProvider
* @return void
*/
- public function testPrepare($name, $filterData, $expectedCondition)
+ public function testPrepare(string $name, bool $showsTime, array $filterData, ?array $expectedCondition)
{
$processor = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\Processor::class)
->disableOriginalConstructor()
->getMock();
$this->contextMock->expects(static::atLeastOnce())->method('getProcessor')->willReturn($processor);
- /** @var FormDate $uiComponent */
+ /** @var FormDate|MockObject $uiComponent */
$uiComponent = $this->getMockBuilder(FormDate::class)
->disableOriginalConstructor()
->getMock();
@@ -125,7 +127,7 @@ public function testPrepare($name, $filterData, $expectedCondition)
->willReturn($this->dataProviderMock);
if ($expectedCondition !== null) {
- $this->processFilters($name, $filterData, $expectedCondition, $uiComponent);
+ $this->processFilters($name, $showsTime, $filterData, $expectedCondition, $uiComponent);
}
$this->uiComponentFactory->expects($this->any())
@@ -139,7 +141,10 @@ public function testPrepare($name, $filterData, $expectedCondition)
$this->filterBuilderMock,
$this->filterModifierMock,
[],
- ['name' => $name]
+ [
+ 'name' => $name,
+ 'config' => ['options' => ['showsTime' => $showsTime]],
+ ]
);
$date->prepare();
}
@@ -152,7 +157,7 @@ public function testPrepare($name, $filterData, $expectedCondition)
* @param string $expectedDate
* @param int $i
*
- * @return Filter|\PHPUnit_Framework_MockObject_MockObject
+ * @return Filter|MockObject
*/
private function getFilterMock($name, $expectedType, $expectedDate, &$i)
{
@@ -184,57 +189,87 @@ public function getPrepareDataProvider()
{
return [
[
- 'test_date',
- ['test_date' => ['from' => '11-05-2015', 'to' => null]],
- ['date' => '2015-05-11 00:00:00', 'type' => 'gteq'],
+ 'name' => 'test_date',
+ 'showsTime' => false,
+ 'filterData' => ['test_date' => ['from' => '11-05-2015', 'to' => null]],
+ 'expectedCondition' => ['date' => '2015-05-11 00:00:00', 'type' => 'gteq'],
],
[
- 'test_date',
- ['test_date' => ['from' => null, 'to' => '11-05-2015']],
- ['date' => '2015-05-11 23:59:59', 'type' => 'lteq'],
+ 'name' => 'test_date',
+ 'showsTime' => false,
+ 'filterData' => ['test_date' => ['from' => null, 'to' => '11-05-2015']],
+ 'expectedCondition' => ['date' => '2015-05-11 23:59:59', 'type' => 'lteq'],
],
[
- 'test_date',
- ['test_date' => ['from' => '11-05-2015', 'to' => '11-05-2015']],
- [
+ 'name' => 'test_date',
+ 'showsTime' => false,
+ 'filterData' => ['test_date' => ['from' => '11-05-2015', 'to' => '11-05-2015']],
+ 'expectedCondition' => [
'date_from' => '2015-05-11 00:00:00', 'type_from' => 'gteq',
'date_to' => '2015-05-11 23:59:59', 'type_to' => 'lteq'
],
],
[
- 'test_date',
- ['test_date' => '11-05-2015'],
- ['date' => '2015-05-11 00:00:00', 'type' => 'eq'],
+ 'name' => 'test_date',
+ 'showsTime' => false,
+ 'filterData' => ['test_date' => '11-05-2015'],
+ 'expectedCondition' => ['date' => '2015-05-11 00:00:00', 'type' => 'eq'],
+ ],
+ [
+ 'name' => 'test_date',
+ 'showsTime' => false,
+ 'filterData' => ['test_date' => ['from' => '', 'to' => '']],
+ 'expectedCondition' => null,
],
[
- 'test_date',
- ['test_date' => ['from' => '', 'to' => '']],
- null,
+ 'name' => 'test_date',
+ 'showsTime' => true,
+ 'filterData' => ['test_date' => ['from' => '11-05-2015 10:20:00', 'to' => '11-05-2015 18:25:00']],
+ 'expectedCondition' => [
+ 'date_from' => '2015-05-11 10:20:00', 'type_from' => 'gteq',
+ 'date_to' => '2015-05-11 18:25:00', 'type_to' => 'lteq'
+ ],
],
];
}
/**
- * @param $name
- * @param $filterData
- * @param $expectedCondition
- * @param $uiComponent
+ * @param string $name
+ * @param bool $showsTime
+ * @param array $filterData
+ * @param array $expectedCondition
+ * @param MockObject $uiComponent
*/
- private function processFilters($name, $filterData, $expectedCondition, $uiComponent)
- {
+ private function processFilters(
+ string $name,
+ bool $showsTime,
+ array $filterData,
+ array $expectedCondition,
+ FormDate $uiComponent
+ ) {
if (is_string($filterData[$name])) {
$uiComponent->expects(static::once())
- ->method('convertDate')
+ ->method($showsTime ? 'convertDatetime' : 'convertDate')
->with($filterData[$name])
->willReturn(new \DateTime($filterData[$name]));
} else {
- $from = new \DateTime($filterData[$name]['from']);
- $to = new \DateTime($filterData[$name]['to'] . ' 23:59:59');
- $uiComponent->method('convertDate')
- ->willReturnMap([
- [$filterData[$name]['from'], 0, 0, 0, true, $from],
- [$filterData[$name]['to'], 23, 59, 59, true, $to],
- ]);
+ if ($showsTime) {
+ $from = new \DateTime($filterData[$name]['from']);
+ $to = new \DateTime($filterData[$name]['to']);
+ $uiComponent->method('convertDatetime')
+ ->willReturnMap([
+ [$filterData[$name]['from'], true, $from],
+ [$filterData[$name]['to'], true, $to],
+ ]);
+ } else {
+ $from = new \DateTime($filterData[$name]['from']);
+ $to = new \DateTime($filterData[$name]['to'] . ' 23:59:59');
+ $uiComponent->method('convertDate')
+ ->willReturnMap([
+ [$filterData[$name]['from'], 0, 0, 0, true, $from],
+ [$filterData[$name]['to'], 23, 59, 59, true, $to],
+ ]);
+ }
}
$i = 0;
diff --git a/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php b/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php
index 402fd30bf4d5b..19a1be69ca1d7 100644
--- a/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php
+++ b/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php
@@ -8,23 +8,27 @@
namespace Magento\Ui\Test\Unit\Component;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
-use \Magento\Ui\Component\Filters;
+use Magento\Framework\View\Element\UiComponent\ContextInterface;
+use Magento\Framework\View\Element\UiComponentFactory;
+use Magento\Framework\View\Element\UiComponentInterface;
+use Magento\Ui\Component\Filters;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Unit tests for \Magento\Ui\Component\Filters class
*/
class FiltersTest extends \PHPUnit\Framework\TestCase
{
- /** @var Filters|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var Filters|MockObject */
private $filters;
- /** @var \Magento\Framework\View\Element\UiComponentInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var UiComponentInterface|MockObject */
private $uiComponentInterface;
- /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var UiComponentFactory|MockObject */
private $uiComponentFactory;
- /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var ContextInterface|MockObject */
private $context;
/**
@@ -33,13 +37,13 @@ class FiltersTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$objectManager = new ObjectManager($this);
- $this->uiComponentInterface = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentInterface::class)
+ $this->uiComponentInterface = $this->getMockBuilder(UiComponentInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->uiComponentFactory = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentFactory::class)
+ $this->uiComponentFactory = $this->getMockBuilder(UiComponentFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->context = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponent\ContextInterface::class)
+ $this->context = $this->getMockBuilder(ContextInterface::class)
->disableOriginalConstructor()
->getMock();
$this->filters = $objectManager->getObject(
@@ -52,7 +56,14 @@ protected function setUp()
);
}
- public function testUpdate()
+ /**
+ * Test to Update filter component according to $component
+ *
+ * @param string $filterType
+ * @param string $filterName
+ * @dataProvider updateDataProvider
+ */
+ public function testUpdate(string $filterType, string $filterName)
{
$componentName = 'component_name';
$componentConfig = [0, 1, 2];
@@ -60,7 +71,10 @@ public function testUpdate()
->disableOriginalConstructor()
->setMethods(['getData', 'getName', 'getConfiguration'])
->getMockForAbstractClass();
- $columnInterface->expects($this->atLeastOnce())->method('getData')->with('config/filter')->willReturn('text');
+ $columnInterface->expects($this->atLeastOnce())
+ ->method('getData')
+ ->with('config/filter')
+ ->willReturn($filterType);
$columnInterface->expects($this->atLeastOnce())->method('getName')->willReturn($componentName);
$columnInterface->expects($this->once())->method('getConfiguration')->willReturn($componentConfig);
$filterComponent = $this->getMockBuilder(\Magento\Framework\View\Element\UiComponentInterface::class)
@@ -71,11 +85,22 @@ public function testUpdate()
->willReturnSelf();
$filterComponent->expects($this->once())->method('prepare')->willReturnSelf();
$this->uiComponentFactory->expects($this->once())->method('create')
- ->with($componentName, 'filterInput', ['context' => $this->context])
+ ->with($componentName, $filterName, ['context' => $this->context])
->willReturn($filterComponent);
$this->filters->update($columnInterface);
/** Verify that filter is already set and it wouldn't be set again */
$this->filters->update($columnInterface);
}
+
+ /**
+ * @return array
+ */
+ public function updateDataProvider(): array
+ {
+ return [
+ ['text', 'filterInput'],
+ ['datetimeRange', 'filterDate'],
+ ];
+ }
}
diff --git a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/DataType/DateTest.php b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/DataType/DateTest.php
index cdb11f05daa8c..015c025e7c102 100644
--- a/app/code/Magento/Ui/Test/Unit/Component/Form/Element/DataType/DateTest.php
+++ b/app/code/Magento/Ui/Test/Unit/Component/Form/Element/DataType/DateTest.php
@@ -11,27 +11,35 @@
use Magento\Framework\View\Element\UiComponent\Context;
use Magento\Framework\View\Element\UiComponent\Processor;
use Magento\Ui\Component\Form\Element\DataType\Date;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class DateTest extends \PHPUnit\Framework\TestCase
+/**
+ * Class to test Date form element
+ */
+class DateTest extends TestCase
{
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var Context|MockObject */
private $contextMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var TimezoneInterface|MockObject */
private $localeDateMock;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var ResolverInterface|MockObject */
private $localeResolverMock;
- /** @var \Magento\Ui\Component\Form\Element\DataType\Date */
+ /** @var Date */
private $date;
- /** @var \PHPUnit_Framework_MockObject_MockObject */
+ /** @var Processor|MockObject */
private $processorMock;
- /** @var \Magento\Framework\TestFramework\Unit\Helper\ObjectManager */
+ /** @var ObjectManager */
private $objectManagerHelper;
+ /**
+ * @inheritdoc
+ */
public function setUp()
{
$this->contextMock = $this->createMock(Context::class);
@@ -39,9 +47,12 @@ public function setUp()
$this->localeResolverMock = $this->createMock(ResolverInterface::class);
$this->objectManagerHelper = new ObjectManager($this);
$this->processorMock = $this->createMock(Processor::class);
- $this->contextMock->expects($this->atLeastOnce())->method('getProcessor')->willReturn($this->processorMock);
+ $this->contextMock->method('getProcessor')->willReturn($this->processorMock);
}
+ /**
+ * Test to Prepare component configuration with Time offset
+ */
public function testPrepareWithTimeOffset()
{
$this->date = new Date(
@@ -72,6 +83,9 @@ public function testPrepareWithTimeOffset()
$this->assertEquals($localeDateFormat, $config['options']['dateFormat']);
}
+ /**
+ * Test to Prepare component configuration without Time offset
+ */
public function testPrepareWithoutTimeOffset()
{
$defaultDateFormat = 'MM/dd/y';
@@ -130,4 +144,43 @@ public function testPrepare()
$this->assertEquals('America/Chicago', $configArray['storeTimeZone']);
$this->assertEquals('de-DE', $configArray['options']['storeLocale']);
}
+
+ /**
+ * Test to Convert given date to default (UTC) timezone
+ *
+ * @param string $dateStr
+ * @param bool $setUtcTimeZone
+ * @param string $convertedDate
+ * @dataProvider convertDatetimeDataProvider
+ */
+ public function testConvertDatetime(string $dateStr, bool $setUtcTimeZone, string $convertedDate)
+ {
+ $this->localeDateMock->method('getConfigTimezone')
+ ->willReturn('America/Los_Angeles');
+
+ $this->date = $this->objectManagerHelper->getObject(
+ Date::class,
+ [
+ 'localeDate' => $this->localeDateMock,
+ ]
+ );
+
+ $this->assertEquals(
+ $convertedDate,
+ $this->date->convertDatetime($dateStr, $setUtcTimeZone)->format('Y-m-d H:i:s'),
+ "The date value wasn't converted"
+ );
+ }
+
+ /**
+ * @return array
+ */
+ public function convertDatetimeDataProvider(): array
+ {
+ return [
+ ['2019-09-30T12:32:00.000Z', false, '2019-09-30 12:32:00'],
+ ['2019-09-30T12:32:00.000', false, '2019-09-30 12:32:00'],
+ ['2019-09-30T12:32:00.000Z', true, '2019-09-30 19:32:00'],
+ ];
+ }
}
diff --git a/app/code/Magento/Ui/view/base/web/js/form/element/date.js b/app/code/Magento/Ui/view/base/web/js/form/element/date.js
index ac28271e90a3b..1432372dd75a9 100644
--- a/app/code/Magento/Ui/view/base/web/js/form/element/date.js
+++ b/app/code/Magento/Ui/view/base/web/js/form/element/date.js
@@ -107,6 +107,13 @@ define([
return this._super().observe(['shiftedValue']);
},
+ /**
+ * @inheritdoc
+ */
+ getPreview: function () {
+ return this.shiftedValue();
+ },
+
/**
* Prepares and sets date/time value that will be displayed
* in the input field.
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
index 3f9c5b20d6215..cc69d990372c1 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
@@ -9,8 +9,10 @@
define([
'mageUtils',
'moment',
- './column'
-], function (utils, moment, Column) {
+ './column',
+ 'underscore',
+ 'moment-timezone-with-data'
+], function (utils, moment, Column, _) {
'use strict';
return Column.extend({
@@ -20,9 +22,9 @@ define([
},
/**
- * Overrides base method to normalize date format.
+ * Overrides base method to normalize date format
*
- * @returns {DateColumn} Chainable.
+ * @returns {DateColumn} Chainable
*/
initConfig: function () {
this._super();
@@ -38,12 +40,15 @@ define([
* @returns {String} Formatted date.
*/
getLabel: function (value, format) {
- var date;
+ var date = moment.utc(this._super());
if (this.storeLocale !== undefined) {
moment.locale(this.storeLocale, utils.extend({}, this.calendarConfig));
}
- date = moment(this._super());
+
+ if (!_.isUndefined(this.timeZone)) {
+ date = date.tz(this.timeZone);
+ }
date = date.isValid() && value[this.index] ?
date.format(format || this.dateFormat) :
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js
index 98c3eb1c6f882..a6fae9df50c4d 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/filters.js
@@ -83,6 +83,10 @@ define([
component: 'Magento_Ui/js/grid/filters/range',
rangeType: 'date'
},
+ datetimeRange: {
+ component: 'Magento_Ui/js/grid/filters/range',
+ rangeType: 'datetime'
+ },
textRange: {
component: 'Magento_Ui/js/grid/filters/range',
rangeType: 'text'
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js b/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js
index ccfba8e98b6f4..1949234c89324 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/filters/range.js
@@ -30,6 +30,14 @@ define([
dateFormat: 'MM/dd/YYYY',
shiftedValue: 'filter'
},
+ datetime: {
+ component: 'Magento_Ui/js/form/element/date',
+ dateFormat: 'MM/dd/YYYY',
+ shiftedValue: 'filter',
+ options: {
+ showsTime: true
+ }
+ },
text: {
component: 'Magento_Ui/js/form/element/abstract'
},
From 9b6a45e8d0e448a726d06cb56952035acbc9a537 Mon Sep 17 00:00:00 2001
From: Aliaksei_Manenak
Date: Thu, 3 Oct 2019 14:49:12 +0300
Subject: [PATCH 0241/1978] MC-18822: Increase test coverage for Content
functional area
- Skip until failed. https://jira.corp.magento.com/browse/MAGETWO-96420
---
.../testsuite/Magento/Newsletter/Controller/SubscriberTest.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
index b7b87d3b9e20d..bf19d6ddefc36 100644
--- a/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
+++ b/dev/tests/integration/testsuite/Magento/Newsletter/Controller/SubscriberTest.php
@@ -83,6 +83,8 @@ public function testNewActionOwnerEmail()
*/
public function testCreatePosWithSubscribeEmailAction()
{
+ $this->markTestSkipped('Skip until failed. MAGETWO-96420');
+
$config = Bootstrap::getObjectManager()->get(MutableScopeConfigInterface::class);
$accountConfirmationRequired = $config->getValue(
AccountConfirmation::XML_PATH_IS_CONFIRM,
From f8b47b3606bc4e852f31271313c57e34a3bda69f Mon Sep 17 00:00:00 2001
From: RomanKis
Date: Thu, 3 Oct 2019 17:12:26 +0300
Subject: [PATCH 0242/1978] graphQl-961: ShippingAddressInput.postcode: String,
is not required by Schema
---
.../Model/Cart/QuoteAddressFactory.php | 8 +++-----
.../Model/Cart/SetBillingAddressOnCart.php | 2 ++
.../Model/Cart/SetShippingAddressesOnCart.php | 2 ++
.../Customer/SetShippingAddressOnCartTest.php | 16 ++++++++++++++++
4 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
index 9fe8d34435d5d..0fca8a19aa03f 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
@@ -16,7 +16,6 @@
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
use Magento\Quote\Model\Quote\AddressFactory as BaseQuoteAddressFactory;
-use Magento\Framework\App\ObjectManager;
/**
* Create QuoteAddress
@@ -47,20 +46,19 @@ class QuoteAddressFactory
* @param BaseQuoteAddressFactory $quoteAddressFactory
* @param GetCustomerAddress $getCustomerAddress
* @param AddressHelper $addressHelper
- * @param CountryInformationAcquirerInterface|null $countryInformationAcquirer
+ * @param CountryInformationAcquirerInterface $countryInformationAcquirer
*/
public function __construct(
BaseQuoteAddressFactory $quoteAddressFactory,
GetCustomerAddress $getCustomerAddress,
AddressHelper $addressHelper,
- CountryInformationAcquirerInterface $countryInformationAcquirer = null
+ CountryInformationAcquirerInterface $countryInformationAcquirer
) {
$this->quoteAddressFactory = $quoteAddressFactory;
$this->getCustomerAddress = $getCustomerAddress;
$this->addressHelper = $addressHelper;
$this->countryInformationAcquirer = $countryInformationAcquirer;
- $this->countryInformationAcquirer = $countryInformationAcquirer
- ?: ObjectManager::getInstance()->get(CountryInformationAcquirerInterface::class);
+ $this->countryInformationAcquirer = $countryInformationAcquirer;
}
/**
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index dd2daa6cb24ff..d3e4b13d2023b 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -140,6 +140,8 @@ private function validateAddress(Address $shippingAddress)
*
* @param array $errors
* @return string
+ *
+ * @todo change implementation in https://github.com/magento/graphql-ce/issues/970.
*/
private function getAddressErrors(array $errors): string
{
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
index 499f6a6e9e402..b2db19d4ffe45 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
@@ -81,6 +81,8 @@ private function validateAddress(Address $shippingAddress)
*
* @param array $errors
* @return string
+ *
+ * @todo change implementation in https://github.com/magento/graphql-ce/issues/970.
*/
private function getAddressErrors(array $errors): string
{
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
index fd21475f12504..2fcbddfad1a6f 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
@@ -441,6 +441,22 @@ public function dataProviderUpdateWithMissedRequiredParameters(): array
}]',
'"regionId" is required. Enter and try again.'
],
+ 'missed_multiple_fields' => [
+ 'cart_id: "cart_id_value"
+ shipping_addresses: [{
+ address: {
+ firstname: "test firstname"
+ lastname: "test lastname"
+ company: "test company"
+ street: ["test street 1", "test street 2"]
+ city: "test city"
+ country_code: "US"
+ telephone: "88776655"
+ }
+ }]',
+ '"postcode" is required. Enter and try again.
+"regionId" is required. Enter and try again.'
+ ],
];
}
From 59ff70960eab3d2ad6e3599d4c427fce2bd0be93 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Thu, 3 Oct 2019 09:48:58 -0500
Subject: [PATCH 0243/1978] MC-20648: Implement the changes - added changes for
storing discounts in db
---
.../Quote/Model/Quote/Address/Total.php | 15 ------
.../Model/Quote/Item/Plugin/Discount.php | 23 ---------
app/code/Magento/Quote/etc/db_schema.xml | 7 ++-
app/code/Magento/Quote/etc/di.xml | 3 --
.../Model/Cart/DiscountAggregator.php | 48 -------------------
.../Model/Resolver/CartItemPrices.php | 6 +--
.../QuoteGraphQl/Model/Resolver/Discounts.php | 20 ++------
.../Model/Plugin/ResourceModel/Discount.php | 47 ++++++++++++++++++
.../SalesRule/Model/Quote/Discount.php | 44 ++++++++---------
.../Model/Quote/Item/Plugin/Discount.php | 43 +++++++++++++++++
app/code/Magento/SalesRule/etc/di.xml | 7 ++-
.../SalesRule/etc/extension_attributes.xml | 3 ++
12 files changed, 129 insertions(+), 137 deletions(-)
delete mode 100644 app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php
delete mode 100644 app/code/Magento/QuoteGraphQl/Model/Cart/DiscountAggregator.php
create mode 100644 app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
create mode 100644 app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
diff --git a/app/code/Magento/Quote/Model/Quote/Address/Total.php b/app/code/Magento/Quote/Model/Quote/Address/Total.php
index 3ed9f7f984334..d8dd0953407d4 100644
--- a/app/code/Magento/Quote/Model/Quote/Address/Total.php
+++ b/app/code/Magento/Quote/Model/Quote/Address/Total.php
@@ -200,19 +200,4 @@ public function getFullInfo()
}
return $fullInfo;
}
-
- public function getDiscountBreakdown() {
- $fullInfo = $this->getData('discount_breakdown');
- if (is_string($fullInfo)) {
- $fullInfo = $this->serializer->unserialize($fullInfo);
- }
- return $fullInfo;
- }
-
- public function setDiscountBreakdown($discount) {
- if (isset($discount)) {
- $this->setData('discount_breakdown', $this->serializer->serialize($discount));
- }
- return $this;
- }
}
diff --git a/app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php
deleted file mode 100644
index 134258c2e09ab..0000000000000
--- a/app/code/Magento/Quote/Model/Quote/Item/Plugin/Discount.php
+++ /dev/null
@@ -1,23 +0,0 @@
-getExtensionAttributes();
- $cartItem->setDiscounts(\GuzzleHttp\json_encode($extension->getDiscounts()));
- return [$quote, $cartItem];
- }
-}
\ No newline at end of file
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
index cf3ce416e24c5..9a72658b0af6e 100644
--- a/app/code/Magento/Quote/etc/db_schema.xml
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -173,10 +173,9 @@
default="0" comment="Base Grand Total"/>
-
-
+
-
+
diff --git a/app/code/Magento/Quote/etc/di.xml b/app/code/Magento/Quote/etc/di.xml
index 6060e3e2845a1..cd5e62307fdca 100644
--- a/app/code/Magento/Quote/etc/di.xml
+++ b/app/code/Magento/Quote/etc/di.xml
@@ -101,9 +101,6 @@
-
-
-
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/DiscountAggregator.php b/app/code/Magento/QuoteGraphQl/Model/Cart/DiscountAggregator.php
deleted file mode 100644
index a620b4b2610cf..0000000000000
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/DiscountAggregator.php
+++ /dev/null
@@ -1,48 +0,0 @@
-getItems();
- $discountPerRule = [];
- foreach ($items as $item) {
- $discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
- if ($discountBreakdown) {
- foreach ($discountBreakdown as $key => $value) {
- /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
- $discount = $value['discount'];
- $rule = $value['rule'];
- if (isset($discountPerRule[$key])) {
- $discountPerRule[$key]['discount'] += $discount->getAmount();
- } else {
- $discountPerRule[$key]['discount'] = $discount->getAmount();
- }
- $discountPerRule[$key]['rule'] = $rule;
- }
- }
- }
- return $discountPerRule;
- }
-}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
index b66327ac1dbba..56488bf0eaadf 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
@@ -94,11 +94,11 @@ private function getDiscountValues($cartItem, $currencyCode)
$discount = [];
$amount = [];
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
- $discountData = $value['discount'];
+ $discountAmount = $value['discount'];
/* @var \Magento\SalesRule\Model\Rule $rule */
$rule = $value['rule'];
- $discount['label'] = $rule->getStoreLabel($cartItem->getQuote()->getStore()) ?: __('Discount');
- $amount['value'] = $discountData->getAmount();
+ $discount['label'] = $rule ?: __('Discount');
+ $amount['value'] = $discountAmount;
$amount['currency'] = $currencyCode;
$discount['amount'] = $amount;
$discountValues[] = $discount;
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
index 2c3f6d0e69f4a..b00d75a305868 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
@@ -12,27 +12,12 @@
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Quote\Model\Quote;
-use Magento\QuoteGraphQl\Model\Cart\DiscountAggregator;
/**
* @inheritdoc
*/
class Discounts implements ResolverInterface
{
- /**
- * @var DiscountAggregator
- */
- private $discountAggregator;
-
- /**
- * @param DiscountAggregator|null $discountAggregator
- */
- public function __construct(
- DiscountAggregator $discountAggregator
- ) {
- $this->discountAggregator = $discountAggregator;
- }
-
/**
* @inheritdoc
*/
@@ -55,14 +40,15 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
private function getDiscountValues(Quote $quote)
{
$discountValues=[];
- $totalDiscounts = $this->discountAggregator->aggregateDiscountPerRule($quote);
+ $address = $quote->getShippingAddress();
+ $totalDiscounts = $address->getExtensionAttributes()->getDiscounts();
if ($totalDiscounts) {
foreach ($totalDiscounts as $value) {
$discount = [];
$amount = [];
/* @var \Magento\SalesRule\Model\Rule $rule*/
$rule = $value['rule'];
- $discount['label'] = $rule->getStoreLabel($quote->getStore()) ?: __('Discount');
+ $discount['label'] = $rule ?: __('Discount');
$amount['value'] = $value['discount'];
$amount['currency'] = $quote->getQuoteCurrencyCode();
$discount['amount'] = $amount;
diff --git a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
new file mode 100644
index 0000000000000..e0e88d9534f18
--- /dev/null
+++ b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
@@ -0,0 +1,47 @@
+json = $json;
+ }
+
+ /**
+ * Plugin method for persisting data from extension attribute
+ *
+ * @param \Magento\Quote\Model\ResourceModel\Quote $subject
+ * @param \Magento\Framework\Model\AbstractModel $object
+ * @return array
+ */
+ public function beforeSave(
+ \Magento\Quote\Model\ResourceModel\Quote $subject,
+ \Magento\Framework\Model\AbstractModel $object
+ ) {
+ foreach ($object->getAllAddresses() as $address) {
+ $discounts = $address->getExtensionAttributes()->getDiscounts();
+ if ($discounts) {
+ $address->setDiscounts($this->json->serialize($discounts));
+ }
+ }
+ return [$object];
+ }
+}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 47aaee2bd8fa7..efd2d5b5a6802 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -127,14 +127,13 @@ public function collect(
$this->calculator->process($item);
$this->aggregateItemDiscount($item, $total);
}
+ $this->aggregateDiscountPerRule($item, $address);
}
$this->calculator->prepareDescription($address);
$total->setDiscountDescription($address->getDiscountDescription());
- $total->setDiscountBreakdown($this->aggregateDiscountPerRule($quote));
$total->setSubtotalWithDiscount($total->getSubtotal() + $total->getDiscountAmount());
$total->setBaseSubtotalWithDiscount($total->getBaseSubtotal() + $total->getBaseDiscountAmount());
-
$address->setDiscountAmount($total->getDiscountAmount());
$address->setBaseDiscountAmount($total->getBaseDiscountAmount());
@@ -221,32 +220,31 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
}
/**
- * @param \Magento\Quote\Model\Quote $quote
- * @return array
+ * Aggregates discount per rule
+ *
+ * @param \Magento\Quote\Api\Data\CartItemInterface $item
+ * @param \Magento\Quote\Api\Data\AddressInterface $address
+ * @return void
*/
private function aggregateDiscountPerRule(
- \Magento\Quote\Model\Quote $quote
+ \Magento\Quote\Api\Data\CartItemInterface $item,
+ \Magento\Quote\Api\Data\AddressInterface $address
) {
- $items = $quote->getItems();
- $discountPerRule = [];
- if ($items) {
- foreach ($items as $item) {
- $discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
- if ($discountBreakdown) {
- foreach ($discountBreakdown as $key => $value) {
- /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
- $discount = $value['discount'];
- $ruleLabel = $value['rule'];
- if (isset($discountPerRule[$key])) {
- $discountPerRule[$key]['discount'] += $discount;
- } else {
- $discountPerRule[$key]['discount'] = $discount;
- }
- $discountPerRule[$key]['rule'] = $ruleLabel;
- }
+ $discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
+ $discountPerRule = $address->getExtensionAttributes()->getDiscounts();
+ if ($discountBreakdown) {
+ foreach ($discountBreakdown as $key => $value) {
+ /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
+ $discount = $value['discount'];
+ $ruleLabel = $value['rule'];
+ if (isset($discountPerRule[$key])) {
+ $discountPerRule[$key]['discount'] += $discount;
+ } else {
+ $discountPerRule[$key]['discount'] = $discount;
}
+ $discountPerRule[$key]['rule'] = $ruleLabel;
}
}
- return $discountPerRule;
+ $address->getExtensionAttributes()->setDiscounts($discountPerRule);
}
}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
new file mode 100644
index 0000000000000..143fa073b37ec
--- /dev/null
+++ b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
@@ -0,0 +1,43 @@
+json = $json;
+ }
+
+ /**
+ * Plugin method for persisting data from extension attributes
+ *
+ * @param CartItemPersister $subject
+ * @param CartInterface $quote
+ * @param CartItemInterface $cartItem
+ * @return array
+ */
+ public function beforeSave(CartItemPersister $subject, CartInterface $quote, CartItemInterface $cartItem)
+ {
+ $cartExtension = $cartItem->getExtensionAttributes();
+ $cartItem->setDiscounts($this->json->serialize($cartExtension->getDiscounts()));
+ return [$quote, $cartItem];
+ }
+}
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index c1d22a04771ab..a3bc8b7e57e8f 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -178,7 +178,12 @@
-
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/etc/extension_attributes.xml b/app/code/Magento/SalesRule/etc/extension_attributes.xml
index 202ced4204f73..b73afcd09f060 100644
--- a/app/code/Magento/SalesRule/etc/extension_attributes.xml
+++ b/app/code/Magento/SalesRule/etc/extension_attributes.xml
@@ -9,4 +9,7 @@
+
+
+
\ No newline at end of file
From 81f48ac946d0ef0853aed5abbd016f9f0574cacf Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 3 Oct 2019 14:02:02 -0500
Subject: [PATCH 0244/1978] MC-18685: Remove custom layout updates from admin
---
.../Cms/Controller/Adminhtml/Page/Save.php | 4 --
app/code/Magento/Cms/Model/Page.php | 37 +++++++++++++------
.../Controller/Adminhtml/Page/SaveTest.php | 2 +-
3 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 8ad33f90b7c88..9d195e5999956 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -11,8 +11,6 @@
use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\Request\DataPersistorInterface;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Cms\Model\Page\CustomLayoutRepositoryInterface;
-use Magento\Cms\Model\Page\CustomLayout\Data\CustomLayoutSelected;
/**
* Save CMS page action.
@@ -67,8 +65,6 @@ public function __construct(
$this->pageFactory = $pageFactory ?: ObjectManager::getInstance()->get(\Magento\Cms\Model\PageFactory::class);
$this->pageRepository = $pageRepository
?: ObjectManager::getInstance()->get(\Magento\Cms\Api\PageRepositoryInterface::class);
- $this->customLayoutRepository = $customLayoutRepository
- ?? ObjectManager::getInstance()->get(CustomLayoutRepositoryInterface::class);
parent::__construct($context);
}
diff --git a/app/code/Magento/Cms/Model/Page.php b/app/code/Magento/Cms/Model/Page.php
index 66aef2a6371b7..28d013f45f1fa 100644
--- a/app/code/Magento/Cms/Model/Page.php
+++ b/app/code/Magento/Cms/Model/Page.php
@@ -65,8 +65,11 @@ class Page extends AbstractModel implements PageInterface, IdentityInterface
private $customLayoutRepository;
/**
- * @inheritDoc
- *
+ * @param \Magento\Framework\Model\Context $context
+ * @param \Magento\Framework\Registry $registry
+ * @param \Magento\Framework\Model\ResourceModel\AbstractResource|null $resource
+ * @param \Magento\Framework\Data\Collection\AbstractDb|null $resourceCollection
+ * @param array $data
* @param CustomLayoutRepository|null $customLayoutRepository
*/
public function __construct(
@@ -561,18 +564,15 @@ public function setIsActive($isActive)
}
/**
- * @inheritdoc
- * @since 101.0.0
+ * Validate identifier before saving the entity.
+ *
+ * @return void
+ * @throws LocalizedException
*/
- public function beforeSave()
+ private function validateNewIdentifier(): void
{
$originalIdentifier = $this->getOrigData('identifier');
$currentIdentifier = $this->getIdentifier();
-
- if ($this->hasDataChanges()) {
- $this->setUpdateTime(null);
- }
-
if ($this->getId() && $originalIdentifier !== $currentIdentifier) {
switch ($originalIdentifier) {
case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_ROUTE_PAGE):
@@ -580,13 +580,28 @@ public function beforeSave()
__('This identifier is reserved for "CMS No Route Page" in configuration.')
);
case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_HOME_PAGE):
- throw new LocalizedException(__('This identifier is reserved for "CMS Home Page" in configuration.'));
+ throw new LocalizedException(
+ __('This identifier is reserved for "CMS Home Page" in configuration.')
+ );
case $this->getScopeConfig()->getValue(PageHelper::XML_PATH_NO_COOKIES_PAGE):
throw new LocalizedException(
__('This identifier is reserved for "CMS No Cookies Page" in configuration.')
);
}
}
+ }
+
+ /**
+ * @inheritdoc
+ * @since 101.0.0
+ */
+ public function beforeSave()
+ {
+ if ($this->hasDataChanges()) {
+ $this->setUpdateTime(null);
+ }
+
+ $this->validateNewIdentifier();
//Removing deprecated custom layout update if a new value is provided
$layoutUpdate = $this->getData('layout_update_selected');
diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
index 15ba72154643c..b5ae9fb55c2bb 100644
--- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
@@ -297,7 +297,7 @@ public function testSaveActionThrowsException()
->method('set')
->with(
'cms_page',
- ['page_id' => $this->pageId, 'custom_layout_update_xml' => null, 'layout_update_xml' => null]
+ ['page_id' => $this->pageId]
);
$this->resultRedirect->expects($this->atLeastOnce())
From 9948404e92f926ea4948d66104a05f8884acb417 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 3 Oct 2019 15:36:28 -0500
Subject: [PATCH 0245/1978] MC-18685: Remove custom layout updates from admin
---
.../CustomLayout/CustomLayoutRepository.php | 2 +-
.../Controller/Adminhtml/PageDesignTest.php | 29 +++++++++++++++----
.../Model/Page/CustomLayoutManagerTest.php | 10 ++++++-
.../Cms/Model/Page/DataProviderTest.php | 4 +--
.../Cms/_files/pages_with_layout_xml.php | 19 ++++++++----
5 files changed, 49 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
index ce50bbe7c7476..cf0db6eb27cb8 100644
--- a/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
+++ b/app/code/Magento/Cms/Model/Page/CustomLayout/CustomLayoutRepository.php
@@ -136,7 +136,7 @@ public function save(CustomLayoutSelectedInterface $layout): void
public function validateLayoutSelectedFor(PageModel $page): void
{
$layoutFile = $page->getData('layout_update_selected');
- if ($layoutFile && !$this->isLayoutValidFor($page, $layoutFile)) {
+ if ($layoutFile && (!$page->getId() || !$this->isLayoutValidFor($page, $layoutFile))) {
throw new LocalizedException(__('Invalid Custom Layout Update selected'));
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
index ab0a5aa72f35e..8bc7a89280559 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Controller/Adminhtml/PageDesignTest.php
@@ -56,6 +56,11 @@ class PageDesignTest extends AbstractBackendController
*/
private $scopeConfig;
+ /**
+ * @var string[]
+ */
+ private $pagesToDelete = [];
+
/**
* @inheritDoc
*/
@@ -68,10 +73,24 @@ protected function setUp()
$this->scopeConfig = Bootstrap::getObjectManager()->get(ScopeConfigInterface::class);
}
+ /**
+ * @inheritDoc
+ */
+ protected function tearDown()
+ {
+ parent::tearDown();
+
+ foreach ($this->pagesToDelete as $identifier) {
+ $page = $this->pageRetriever->execute($identifier);
+ $page->delete();
+ }
+ $this->pagesToDelete = [];
+ }
+
/**
* Check whether additional authorization is required for the design fields.
*
- * @magentoDbIsolation enabled
+ * @magentoDbIsolation disabled
* @return void
*/
public function testSaveDesign(): void
@@ -79,7 +98,7 @@ public function testSaveDesign(): void
//Expected list of sessions messages collected throughout the controller calls.
$sessionMessages = ['You are not allowed to change CMS pages design settings'];
//Test page data.
- $id = 'test-page';
+ $id = 'test-page' .rand(1111, 9999);
$requestData = [
PageInterface::IDENTIFIER => $id,
PageInterface::TITLE => 'Page title',
@@ -130,13 +149,13 @@ public function testSaveDesign(): void
/**
* Check that default design values are accepted without the permissions.
*
- * @magentoDbIsolation enabled
+ * @magentoDbIsolation disabled
* @return void
*/
public function testSaveDesignWithDefaults(): void
{
//Test page data.
- $id = 'test-page';
+ $id = 'test-page' .rand(1111, 9999);
$defaultLayout = $this->scopeConfig->getValue('web/default_layouts/default_cms_layout');
$requestData = [
PageInterface::IDENTIFIER => $id,
@@ -192,7 +211,7 @@ public function testSaveLayoutXml(): void
PageInterface::TITLE => 'Page title',
PageInterface::CUSTOM_LAYOUT_UPDATE_XML => $page->getCustomLayoutUpdateXml(),
PageInterface::LAYOUT_UPDATE_XML => $page->getLayoutUpdateXml(),
- 'layout_update_selected' => ''
+ 'layout_update_selected' => '_no_update_'
];
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($requestData);
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
index 966afa0febc1c..e741b95ff4371 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/CustomLayoutManagerTest.php
@@ -42,6 +42,11 @@ class CustomLayoutManagerTest extends TestCase
*/
private $resultFactory;
+ /**
+ * @var IdentityMap
+ */
+ private $identityMap;
+
/**
* @inheritDoc
*/
@@ -68,6 +73,7 @@ protected function setUp()
['manager' => $this->manager]
);
$this->pageFactory = $objectManager->get(PageFactory::class);
+ $this->identityMap = $objectManager->get(IdentityMap::class);
}
/**
@@ -80,15 +86,17 @@ protected function setUp()
public function testCustomLayoutUpdate(): void
{
/** @var Page $page */
- $page = $this->pageFactory->create();
+ $page = $this->pageFactory->create(['customLayoutRepository' => $this->repo]);
$page->load('page100', 'identifier');
$pageId = (int)$page->getId();
+ $this->identityMap->add($page);
//Set file ID
$this->repo->save(new CustomLayoutSelected($pageId, 'select2'));
//Test handles
$result = $this->resultFactory->create();
$this->manager->applyUpdate($result, $this->repo->getFor($pageId));
+ $this->identityMap->remove((int)$page->getId());
$this->assertContains('___selectable_page100_select2', $result->getLayout()->getUpdate()->getHandles());
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
index d2ca833f3923f..2028f5d8a04b6 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/Page/DataProviderTest.php
@@ -116,7 +116,7 @@ public function testCustomLayoutMeta(): void
$meta['design']['children']['custom_layout_update_select']['arguments']['data']
);
$expectedList = [
- ['label' => 'No update', 'value' => ''],
+ ['label' => 'No update', 'value' => '_no_update_'],
['label' => 'test1', 'value' => 'test1'],
['label' => 'test2', 'value' => 'test2']
];
@@ -141,7 +141,7 @@ public function testCustomLayoutMeta(): void
$meta['design']['children']['custom_layout_update_select']['arguments']['data']
);
$expectedList = [
- ['label' => 'No update', 'value' => ''],
+ ['label' => 'No update', 'value' => '_no_update_'],
['label' => 'Use existing layout update XML', 'value' => '_existing_'],
['label' => 'test3', 'value' => 'test3'],
];
diff --git a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
index 550b40a1bfec6..9734ed3abaeed 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/_files/pages_with_layout_xml.php
@@ -8,33 +8,40 @@
use Magento\Cms\Model\Page as PageModel;
use Magento\Cms\Model\PageFactory as PageModelFactory;
+use Magento\TestFramework\Cms\Model\CustomLayoutManager;
use Magento\TestFramework\Helper\Bootstrap;
$objectManager = Bootstrap::getObjectManager();
$pageFactory = $objectManager->get(PageModelFactory::class);
+/** @var CustomLayoutManager $fakeManager */
+$fakeManager = $objectManager->get(CustomLayoutManager::class);
+$layoutRepo = $objectManager->create(PageModel\CustomLayoutRepositoryInterface::class, ['manager' => $fakeManager]);
+
/** @var PageModel $page */
-$page = $pageFactory->create();
+$page = $pageFactory->create(['customLayoutRepository' => $layoutRepo]);
$page->setIdentifier('test_custom_layout_page_1');
$page->setTitle('Test Page');
-$page->setCustomLayoutUpdateXml('tst');
-$page->setLayoutUpdateXml('tst_current');
+$page->setCustomLayoutUpdateXml(' ');
+$page->setLayoutUpdateXml(' ');
$page->setIsActive(true);
$page->setStoreId(0);
$page->save();
/** @var PageModel $page2 */
-$page2 = $pageFactory->create();
+$page2 = $pageFactory->create(['customLayoutRepository' => $layoutRepo]);
$page2->setIdentifier('test_custom_layout_page_2');
$page2->setTitle('Test Page 2');
$page->setIsActive(true);
$page->setStoreId(0);
$page2->save();
/** @var PageModel $page3 */
-$page3 = $pageFactory->create();
+$page3 = $pageFactory->create(['customLayoutRepository' => $layoutRepo]);
$page3->setIdentifier('test_custom_layout_page_3');
$page3->setTitle('Test Page 3');
-$page3->setData('layout_update_selected', 'test_selected');
$page3->setStores([0]);
$page3->setIsActive(1);
$page3->setContent('Test Page ');
$page3->setPageLayout('1column');
$page3->save();
+$fakeManager->fakeAvailableFiles((int)$page3->getId(), ['test_selected']);
+$page3->setData('layout_update_selected', 'test_selected');
+$page3->save();
From e9c704b9277e2567278992dabd14946e65c42f42 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Fri, 4 Oct 2019 10:12:06 +0300
Subject: [PATCH 0246/1978] MC-5233: DateTime product attributes support
---
.../Attribute/Frontend/DatetimeTest.php | 2 +-
.../Unit/Component/Filters/Type/DateTest.php | 21 ++++---
.../Ui/Test/Unit/Component/FiltersTest.php | 2 +-
.../Eav/Model/Entity/AttributeTest.php | 55 ++++++++++++-------
4 files changed, 49 insertions(+), 31 deletions(-)
diff --git a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php
index c775548fc8c75..163f3d208e724 100644
--- a/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php
+++ b/app/code/Magento/Eav/Test/Unit/Model/Entity/Attribute/Frontend/DatetimeTest.php
@@ -56,7 +56,7 @@ protected function setUp()
/**
* Test to retrieve attribute value
- *
+ *
* @param string $frontendInput
* @param int $timeType
* @dataProvider getValueDataProvider
diff --git a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php
index 7038a587be0b0..31d7ca92c5985 100644
--- a/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php
+++ b/app/code/Magento/Ui/Test/Unit/Component/Filters/Type/DateTest.php
@@ -239,6 +239,7 @@ public function getPrepareDataProvider()
* @param array $filterData
* @param array $expectedCondition
* @param MockObject $uiComponent
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
private function processFilters(
string $name,
@@ -257,18 +258,22 @@ private function processFilters(
$from = new \DateTime($filterData[$name]['from']);
$to = new \DateTime($filterData[$name]['to']);
$uiComponent->method('convertDatetime')
- ->willReturnMap([
- [$filterData[$name]['from'], true, $from],
- [$filterData[$name]['to'], true, $to],
- ]);
+ ->willReturnMap(
+ [
+ [$filterData[$name]['from'], true, $from],
+ [$filterData[$name]['to'], true, $to],
+ ]
+ );
} else {
$from = new \DateTime($filterData[$name]['from']);
$to = new \DateTime($filterData[$name]['to'] . ' 23:59:59');
$uiComponent->method('convertDate')
- ->willReturnMap([
- [$filterData[$name]['from'], 0, 0, 0, true, $from],
- [$filterData[$name]['to'], 23, 59, 59, true, $to],
- ]);
+ ->willReturnMap(
+ [
+ [$filterData[$name]['from'], 0, 0, 0, true, $from],
+ [$filterData[$name]['to'], 23, 59, 59, true, $to],
+ ]
+ );
}
}
diff --git a/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php b/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php
index 19a1be69ca1d7..d4cf7f1af8d62 100644
--- a/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php
+++ b/app/code/Magento/Ui/Test/Unit/Component/FiltersTest.php
@@ -58,7 +58,7 @@ protected function setUp()
/**
* Test to Update filter component according to $component
- *
+ *
* @param string $filterType
* @param string $filterName
* @dataProvider updateDataProvider
diff --git a/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php
index 2750e2a768aab..5df08762e29a7 100644
--- a/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php
@@ -3,15 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
declare(strict_types=1);
namespace Magento\Eav\Model\Entity;
-use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Locale\ResolverInterface;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+use PHPUnit\Framework\TestCase;
-class AttributeTest extends \PHPUnit\Framework\TestCase
+/**
+ * Class to test EAV Entity attribute model
+ */
+class AttributeTest extends TestCase
{
/**
* @var Attribute
@@ -19,33 +24,33 @@ class AttributeTest extends \PHPUnit\Framework\TestCase
private $attribute;
/**
- * @var \Magento\Framework\ObjectManagerInterface
+ * @var ObjectManagerInterface
*/
private $objectManager;
/**
* @var ResolverInterface
*/
- private $_localeResolver;
+ private $localeResolver;
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
$this->attribute = $this->objectManager->get(Attribute::class);
- $this->_localeResolver = $this->objectManager->get(ResolverInterface::class);
+ $this->localeResolver = $this->objectManager->get(ResolverInterface::class);
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function tearDown()
{
$this->attribute = null;
$this->objectManager = null;
- $this->_localeResolver = null;
+ $this->localeResolver = null;
}
/**
@@ -56,11 +61,17 @@ protected function tearDown()
* @dataProvider beforeSaveDataProvider
* @throws
*/
- public function testBeforeSave($defaultValue, $backendType, $locale, $expected)
- {
+ public function testBeforeSave(
+ string $defaultValue,
+ string $backendType,
+ string $frontendInput,
+ string $locale,
+ string $expected
+ ) {
$this->attribute->setDefaultValue($defaultValue);
$this->attribute->setBackendType($backendType);
- $this->_localeResolver->setLocale($locale);
+ $this->attribute->setFrontendInput($frontendInput);
+ $this->localeResolver->setLocale($locale);
$this->attribute->beforeSave();
$this->assertEquals($expected, $this->attribute->getDefaultValue());
@@ -74,13 +85,15 @@ public function testBeforeSave($defaultValue, $backendType, $locale, $expected)
public function beforeSaveDataProvider()
{
return [
- ['21/07/18', 'datetime', 'en_AU', '2018-07-21 00:00:00'],
- ['07/21/18', 'datetime', 'en_US', '2018-07-21 00:00:00'],
- ['21/07/18', 'datetime', 'fr_FR', '2018-07-21 00:00:00'],
- ['21/07/18', 'datetime', 'de_DE', '2018-07-21 00:00:00'],
- ['21/07/18', 'datetime', 'uk_UA', '2018-07-21 00:00:00'],
- ['100.50', 'decimal', 'en_US', '100.50'],
- ['100,50', 'decimal', 'uk_UA', '100.5'],
+ ['21/07/18', 'datetime', 'date', 'en_AU', '2018-07-21 00:00:00'],
+ ['07/21/18', 'datetime', 'date', 'en_US', '2018-07-21 00:00:00'],
+ ['21/07/18', 'datetime', 'date', 'fr_FR', '2018-07-21 00:00:00'],
+ ['21/07/18', 'datetime', 'date', 'de_DE', '2018-07-21 00:00:00'],
+ ['21/07/18', 'datetime', 'date', 'uk_UA', '2018-07-21 00:00:00'],
+ ['100.50', 'decimal', 'decimal', 'en_US', '100.50'],
+ ['100,50', 'decimal', 'decimal', 'uk_UA', '100.5'],
+ ['07/21/2019 2:30 PM', 'datetime', 'datetime', 'en_US', '2019-07-21 21:30:00'],
+ ['21.07.2019 14:30', 'datetime', 'datetime', 'uk_UA', '2019-07-21 21:30:00'],
];
}
@@ -90,13 +103,13 @@ public function beforeSaveDataProvider()
* @param string $locale
* @param string $expected
* @dataProvider beforeSaveErrorDataDataProvider
- * @expectedException \Magento\Framework\Exception\LocalizedException
+ * @expectedException LocalizedException
*/
public function testBeforeSaveErrorData($defaultValue, $backendType, $locale, $expected)
{
$this->attribute->setDefaultValue($defaultValue);
$this->attribute->setBackendType($backendType);
- $this->_localeResolver->setLocale($locale);
+ $this->localeResolver->setLocale($locale);
$this->attribute->beforeSave();
$this->expectExceptionMessage($expected);
From 0a2eaae1b2f401f1341f4a767386e55c8fd6f39e Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Fri, 4 Oct 2019 11:28:48 +0400
Subject: [PATCH 0247/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- Updated automated test script
---
.../Mftf/Data/Elasticsearch6ConfigData.xml | 15 ++++++++++++
...ntElasticsearch6SearchInvalidValueTest.xml | 10 ++++----
.../Test/Mftf/Data/SearchEngineConfigData.xml | 23 +++++++++++++++++++
3 files changed, 43 insertions(+), 5 deletions(-)
create mode 100644 app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml
create mode 100644 app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml
new file mode 100644
index 0000000000000..7a61f13e62049
--- /dev/null
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ catalog/search/engine
+ elasticsearch6
+
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
index 5f6949dcafef5..1c105bff9aa0b 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
@@ -10,7 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
-
+
@@ -24,17 +24,17 @@
-
+
-
+
-
-
+
+
diff --git a/app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml b/app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml
new file mode 100644
index 0000000000000..7e1019904b4e9
--- /dev/null
+++ b/app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ catalog/search/engine
+ mysql
+
+
+ catalog/search/min_query_length
+ 3
+
+
+ catalog/search/min_query_length
+ 2
+
+
From a8f3b9e8931d69a4bfa3af51483ed89b16292eea Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Fri, 27 Sep 2019 17:19:04 +0300
Subject: [PATCH 0248/1978] magento/magento2#22856: Catalog price rules are not
working with custom options as expected.
---
.../Product/View/Options/AbstractOptions.php | 30 ++++-
.../Magento/Catalog/Model/Product/Option.php | 123 ++++++------------
.../Model/Product/Option/Type/DefaultType.php | 67 ++++++----
.../Model/Product/Option/Type/Select.php | 31 +++--
.../Catalog/Model/Product/Option/Value.php | 60 +++++++--
.../CalculateCustomOptionCatalogRule.php | 99 ++++++++++++++
.../Unit/Model/Product/Option/ValueTest.php | 32 +++--
app/code/Magento/CatalogRule/Model/Rule.php | 15 ++-
.../Model/Product/BundlePriceAbstract.php | 21 ++-
...ndleWithCatalogPriceRuleCalculatorTest.php | 1 +
.../Block/Product/View/OptionsTest.php | 70 ++++++++--
11 files changed, 400 insertions(+), 149 deletions(-)
create mode 100644 app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php
diff --git a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php
index 030b6e1d2204c..0bfdcc678e9f7 100644
--- a/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php
+++ b/app/code/Magento/Catalog/Block/Product/View/Options/AbstractOptions.php
@@ -3,16 +3,14 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
-/**
- * Product options abstract type block
- *
- * @author Magento Core Team
- */
+declare(strict_types=1);
namespace Magento\Catalog\Block\Product\View\Options;
+use Magento\Catalog\Pricing\Price\BasePrice;
+use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
+use Magento\Framework\App\ObjectManager;
/**
* Product options section abstract block.
@@ -47,20 +45,29 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
*/
protected $_catalogHelper;
+ /**
+ * @var CalculateCustomOptionCatalogRule
+ */
+ private $calculateCustomOptionCatalogRule;
+
/**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
* @param \Magento\Catalog\Helper\Data $catalogData
* @param array $data
+ * @param CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\Pricing\Helper\Data $pricingHelper,
\Magento\Catalog\Helper\Data $catalogData,
- array $data = []
+ array $data = [],
+ CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
) {
$this->pricingHelper = $pricingHelper;
$this->_catalogHelper = $catalogData;
+ $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
+ ?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
parent::__construct($context, $data);
}
@@ -161,6 +168,15 @@ protected function _formatPrice($value, $flag = true)
$priceStr = $sign;
$customOptionPrice = $this->getProduct()->getPriceInfo()->getPrice('custom_option_price');
+
+ if (!$value['is_percent']) {
+ $value['pricing_value'] = $this->calculateCustomOptionCatalogRule->execute(
+ $this->getProduct(),
+ (float)$value['pricing_value'],
+ (bool)$value['is_percent']
+ );
+ }
+
$context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
$optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context);
$priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 4f730834412e4..0170de5dc1ed4 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Model\Product;
@@ -11,8 +12,10 @@
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option\Value;
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
-use Magento\Catalog\Pricing\Price\BasePrice;
+use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractExtensibleModel;
@@ -108,6 +111,11 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
*/
private $customOptionValuesFactory;
+ /**
+ * @var CalculateCustomOptionCatalogRule
+ */
+ private $calculateCustomOptionCatalogRule;
+
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
@@ -121,6 +129,7 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
+ * @param CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -135,14 +144,17 @@ public function __construct(
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
- ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null
+ ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null,
+ CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
) {
$this->productOptionValue = $productOptionValue;
$this->optionTypeFactory = $optionFactory;
$this->validatorPool = $validatorPool;
$this->string = $string;
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
- \Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
+ ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
+ $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule ??
+ ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
parent::__construct(
$context,
@@ -156,10 +168,7 @@ public function __construct(
}
/**
- * Get resource instance
- *
- * @return \Magento\Framework\Model\ResourceModel\Db\AbstractDb
- * @deprecated 101.1.0 because resource models should be used directly
+ * @inheritdoc
*/
protected function _getResource()
{
@@ -439,10 +448,12 @@ public function afterSave()
*/
public function getPrice($flag = false)
{
- if ($flag && $this->getPriceType() == self::$typePercent) {
- $basePrice = $this->getProduct()->getPriceInfo()->getPrice(BasePrice::PRICE_CODE)->getValue();
- $price = $basePrice * ($this->_getData(self::KEY_PRICE) / 100);
- return $price;
+ if ($flag) {
+ return $this->calculateCustomOptionCatalogRule->execute(
+ $this->getProduct(),
+ (float)$this->getData(self::KEY_PRICE),
+ $this->getPriceType() === Value::TYPE_PERCENT
+ );
}
return $this->_getData(self::KEY_PRICE);
}
@@ -536,9 +547,7 @@ public function getSearchableData($productId, $storeId)
}
/**
- * Clearing object's data
- *
- * @return $this
+ * @inheritdoc
*/
protected function _clearData()
{
@@ -548,9 +557,7 @@ protected function _clearData()
}
/**
- * Clearing cyclic references
- *
- * @return $this
+ * @inheritdoc
*/
protected function _clearReferences()
{
@@ -571,9 +578,7 @@ protected function _getValidationRulesBeforeSave()
}
/**
- * Get product SKU
- *
- * @return string
+ * @inheritdoc
*/
public function getProductSku()
{
@@ -585,9 +590,7 @@ public function getProductSku()
}
/**
- * Get option id
- *
- * @return int|null
+ * @inheritdoc
* @codeCoverageIgnoreStart
*/
public function getOptionId()
@@ -596,9 +599,7 @@ public function getOptionId()
}
/**
- * Get option title
- *
- * @return string
+ * @inheritdoc
*/
public function getTitle()
{
@@ -606,9 +607,7 @@ public function getTitle()
}
/**
- * Get option type
- *
- * @return string
+ * @inheritdoc
*/
public function getType()
{
@@ -616,9 +615,7 @@ public function getType()
}
/**
- * Get sort order
- *
- * @return int
+ * @inheritdoc
*/
public function getSortOrder()
{
@@ -626,10 +623,7 @@ public function getSortOrder()
}
/**
- * Get is require
- *
- * @return bool
- * @SuppressWarnings(PHPMD.BooleanGetMethodName)
+ * @inheritdoc
*/
public function getIsRequire()
{
@@ -637,9 +631,7 @@ public function getIsRequire()
}
/**
- * Get price type
- *
- * @return string|null
+ * @inheritdoc
*/
public function getPriceType()
{
@@ -647,9 +639,7 @@ public function getPriceType()
}
/**
- * Get Sku
- *
- * @return string|null
+ * @inheritdoc
*/
public function getSku()
{
@@ -697,10 +687,7 @@ public function getImageSizeY()
}
/**
- * Set product SKU
- *
- * @param string $productSku
- * @return $this
+ * @inheritdoc
*/
public function setProductSku($productSku)
{
@@ -708,10 +695,7 @@ public function setProductSku($productSku)
}
/**
- * Set option id
- *
- * @param int $optionId
- * @return $this
+ * @inheritdoc
*/
public function setOptionId($optionId)
{
@@ -719,10 +703,7 @@ public function setOptionId($optionId)
}
/**
- * Set option title
- *
- * @param string $title
- * @return $this
+ * @inheritdoc
*/
public function setTitle($title)
{
@@ -730,10 +711,7 @@ public function setTitle($title)
}
/**
- * Set option type
- *
- * @param string $type
- * @return $this
+ * @inheritdoc
*/
public function setType($type)
{
@@ -741,10 +719,7 @@ public function setType($type)
}
/**
- * Set sort order
- *
- * @param int $sortOrder
- * @return $this
+ * @inheritdoc
*/
public function setSortOrder($sortOrder)
{
@@ -752,10 +727,7 @@ public function setSortOrder($sortOrder)
}
/**
- * Set is require
- *
- * @param bool $isRequired
- * @return $this
+ * @inheritdoc
*/
public function setIsRequire($isRequired)
{
@@ -763,10 +735,7 @@ public function setIsRequire($isRequired)
}
/**
- * Set price
- *
- * @param float $price
- * @return $this
+ * @inheritdoc
*/
public function setPrice($price)
{
@@ -774,10 +743,7 @@ public function setPrice($price)
}
/**
- * Set price type
- *
- * @param string $priceType
- * @return $this
+ * @inheritdoc
*/
public function setPriceType($priceType)
{
@@ -785,10 +751,7 @@ public function setPriceType($priceType)
}
/**
- * Set Sku
- *
- * @param string $sku
- * @return $this
+ * @inheritdoc
*/
public function setSku($sku)
{
@@ -929,7 +892,7 @@ public function setExtensionAttributes(
private function getOptionRepository()
{
if (null === $this->optionRepository) {
- $this->optionRepository = \Magento\Framework\App\ObjectManager::getInstance()
+ $this->optionRepository = ObjectManager::getInstance()
->get(\Magento\Catalog\Model\Product\Option\Repository::class);
}
return $this->optionRepository;
@@ -943,7 +906,7 @@ private function getOptionRepository()
private function getMetadataPool()
{
if (null === $this->metadataPool) {
- $this->metadataPool = \Magento\Framework\App\ObjectManager::getInstance()
+ $this->metadataPool = ObjectManager::getInstance()
->get(\Magento\Framework\EntityManager\MetadataPool::class);
}
return $this->metadataPool;
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
index c388be8b6f394..be7f1921afccf 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/DefaultType.php
@@ -3,17 +3,26 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Model\Product\Option\Type;
-use Magento\Framework\Exception\LocalizedException;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Configuration\Item\ItemInterface;
+use Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface;
+use Magento\Catalog\Model\Product\Option;
+use Magento\Catalog\Model\Product\Option\Value;
+use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\LocalizedException;
/**
* Catalog product option default type
*
* @api
* @author Magento Core Team
+ * @SuppressWarnings(PHPMD.CookieAndSessionMisuse)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
*/
@@ -22,14 +31,14 @@ class DefaultType extends \Magento\Framework\DataObject
/**
* Option Instance
*
- * @var \Magento\Catalog\Model\Product\Option
+ * @var Option
*/
protected $_option;
/**
* Product Instance
*
- * @var \Magento\Catalog\Model\Product
+ * @var Product
*/
protected $_product;
@@ -54,27 +63,36 @@ class DefaultType extends \Magento\Framework\DataObject
*/
protected $_checkoutSession;
+ /**
+ * @var CalculateCustomOptionCatalogRule
+ */
+ private $calculateCustomOptionCatalogRule;
+
/**
* Construct
*
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param array $data
+ * @param CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule
*/
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
- array $data = []
+ array $data = [],
+ CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
) {
$this->_checkoutSession = $checkoutSession;
parent::__construct($data);
$this->_scopeConfig = $scopeConfig;
+ $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule ?? ObjectManager::getInstance()
+ ->get(CalculateCustomOptionCatalogRule::class);
}
/**
* Option Instance setter
*
- * @param \Magento\Catalog\Model\Product\Option $option
+ * @param Option $option
* @return $this
*/
public function setOption($option)
@@ -86,12 +104,12 @@ public function setOption($option)
/**
* Option Instance getter
*
+ * @return Option
* @throws \Magento\Framework\Exception\LocalizedException
- * @return \Magento\Catalog\Model\Product\Option
*/
public function getOption()
{
- if ($this->_option instanceof \Magento\Catalog\Model\Product\Option) {
+ if ($this->_option instanceof Option) {
return $this->_option;
}
throw new LocalizedException(__('The option instance type in options group is incorrect.'));
@@ -100,7 +118,7 @@ public function getOption()
/**
* Product Instance setter
*
- * @param \Magento\Catalog\Model\Product $product
+ * @param Product $product
* @return $this
*/
public function setProduct($product)
@@ -112,12 +130,12 @@ public function setProduct($product)
/**
* Product Instance getter
*
+ * @return Product
* @throws \Magento\Framework\Exception\LocalizedException
- * @return \Magento\Catalog\Model\Product
*/
public function getProduct()
{
- if ($this->_product instanceof \Magento\Catalog\Model\Product) {
+ if ($this->_product instanceof Product) {
return $this->_product;
}
throw new LocalizedException(__('The product instance type in options group is incorrect.'));
@@ -126,15 +144,12 @@ public function getProduct()
/**
* Getter for Configuration Item Option
*
- * @return \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface
+ * @return OptionInterface
* @throws LocalizedException
*/
public function getConfigurationItemOption()
{
- if ($this->_getData(
- 'configuration_item_option'
- ) instanceof \Magento\Catalog\Model\Product\Configuration\Item\Option\OptionInterface
- ) {
+ if ($this->_getData('configuration_item_option') instanceof OptionInterface) {
return $this->_getData('configuration_item_option');
}
@@ -149,14 +164,12 @@ public function getConfigurationItemOption()
/**
* Getter for Configuration Item
*
- * @return \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
+ * @return ItemInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getConfigurationItem()
{
- if ($this->_getData(
- 'configuration_item'
- ) instanceof \Magento\Catalog\Model\Product\Configuration\Item\ItemInterface
+ if ($this->_getData('configuration_item') instanceof ItemInterface
) {
return $this->_getData('configuration_item');
}
@@ -341,7 +354,11 @@ public function getOptionPrice($optionValue, $basePrice)
{
$option = $this->getOption();
- return $this->_getChargeableOptionPrice($option->getPrice(), $option->getPriceType() == 'percent', $basePrice);
+ return $this->calculateCustomOptionCatalogRule->execute(
+ $option->getProduct(),
+ (float)$option->getPrice(),
+ $option->getPriceType() === Value::TYPE_PERCENT
+ );
}
/**
@@ -368,14 +385,14 @@ public function getProductOptions()
$options = $this->getProduct()->getOptions();
if ($options != null) {
foreach ($options as $_option) {
- /* @var $option \Magento\Catalog\Model\Product\Option */
+ /* @var $option Option */
$this->_productOptions[$this->getProduct()->getId()][$_option->getTitle()] = [
'option_id' => $_option->getId(),
];
if ($_option->getGroupByType() == ProductCustomOptionInterface::OPTION_GROUP_SELECT) {
$optionValues = [];
foreach ($_option->getValues() as $_value) {
- /* @var $value \Magento\Catalog\Model\Product\Option\Value */
+ /* @var $value Value */
$optionValues[$_value->getTitle()] = $_value->getId();
}
$this->_productOptions[$this
@@ -395,12 +412,14 @@ public function getProductOptions()
}
/**
+ * Return final chargeable price for option
+ *
* @param float $price Price of option
* @param boolean $isPercent Price type - percent or fixed
* @param float $basePrice For percent price type
* @return float
* @deprecated 102.0.4 typo in method name
- * @see _getChargeableOptionPrice
+ * @see CalculateCustomOptionCatalogRule::execute
*/
protected function _getChargableOptionPrice($price, $isPercent, $basePrice)
{
@@ -414,6 +433,8 @@ protected function _getChargableOptionPrice($price, $isPercent, $basePrice)
* @param boolean $isPercent Price type - percent or fixed
* @param float $basePrice For percent price type
* @return float
+ * @deprecated
+ * @see CalculateCustomOptionCatalogRule::execute
*/
protected function _getChargeableOptionPrice($price, $isPercent, $basePrice)
{
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php b/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
index d2766b1bbb054..8eebd3e91c2ee 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Type/Select.php
@@ -3,9 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Model\Product\Option\Type;
+use Magento\Catalog\Model\Product\Option\Value;
+use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\LocalizedException;
/**
@@ -37,6 +41,11 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
*/
private $singleSelectionTypes;
+ /**
+ * @var CalculateCustomOptionCatalogRule
+ */
+ private $calculateCustomOptionCatalogRule;
+
/**
* @param \Magento\Checkout\Model\Session $checkoutSession
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
@@ -44,6 +53,7 @@ class Select extends \Magento\Catalog\Model\Product\Option\Type\DefaultType
* @param \Magento\Framework\Escaper $escaper
* @param array $data
* @param array $singleSelectionTypes
+ * @param CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule
*/
public function __construct(
\Magento\Checkout\Model\Session $checkoutSession,
@@ -51,7 +61,8 @@ public function __construct(
\Magento\Framework\Stdlib\StringUtils $string,
\Magento\Framework\Escaper $escaper,
array $data = [],
- array $singleSelectionTypes = []
+ array $singleSelectionTypes = [],
+ CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null
) {
$this->string = $string;
$this->_escaper = $escaper;
@@ -61,6 +72,8 @@ public function __construct(
'drop_down' => \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN,
'radio' => \Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_TYPE_RADIO,
];
+ $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule ?? ObjectManager::getInstance()
+ ->get(CalculateCustomOptionCatalogRule::class);
}
/**
@@ -248,10 +261,10 @@ public function getOptionPrice($optionValue, $basePrice)
foreach (explode(',', $optionValue) as $value) {
$_result = $option->getValueById($value);
if ($_result) {
- $result += $this->_getChargeableOptionPrice(
- $_result->getPrice(),
- $_result->getPriceType() == 'percent',
- $basePrice
+ $result += $this->calculateCustomOptionCatalogRule->execute(
+ $option->getProduct(),
+ (float)$_result->getPrice(),
+ $_result->getPriceType() === Value::TYPE_PERCENT
);
} else {
if ($this->getListener()) {
@@ -263,10 +276,10 @@ public function getOptionPrice($optionValue, $basePrice)
} elseif ($this->_isSingleSelection()) {
$_result = $option->getValueById($optionValue);
if ($_result) {
- $result = $this->_getChargeableOptionPrice(
- $_result->getPrice(),
- $_result->getPriceType() == 'percent',
- $basePrice
+ $result = $this->calculateCustomOptionCatalogRule->execute(
+ $option->getProduct(),
+ (float)$_result->getPrice(),
+ $_result->getPriceType() === Value::TYPE_PERCENT
);
} else {
if ($this->getListener()) {
diff --git a/app/code/Magento/Catalog/Model/Product/Option/Value.php b/app/code/Magento/Catalog/Model/Product/Option/Value.php
index ebbc060c99edf..fce39614248ca 100644
--- a/app/code/Magento/Catalog/Model/Product/Option/Value.php
+++ b/app/code/Magento/Catalog/Model/Product/Option/Value.php
@@ -3,13 +3,16 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Catalog\Model\Product\Option;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Option;
-use Magento\Framework\Model\AbstractModel;
use Magento\Catalog\Pricing\Price\BasePrice;
+use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Model\AbstractModel;
use Magento\Catalog\Pricing\Price\CustomOptionPriceCalculator;
use Magento\Catalog\Pricing\Price\RegularPrice;
@@ -69,6 +72,11 @@ class Value extends AbstractModel implements \Magento\Catalog\Api\Data\ProductCu
*/
private $customOptionPriceCalculator;
+ /**
+ * @var CalculateCustomOptionCatalogRule
+ */
+ private $calculateCustomOptionCatalogRule;
+
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
@@ -77,6 +85,7 @@ class Value extends AbstractModel implements \Magento\Catalog\Api\Data\ProductCu
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @param CustomOptionPriceCalculator|null $customOptionPriceCalculator
+ * @param CalculateCustomOptionCatalogRule|null $CalculateCustomOptionCatalogRule
*/
public function __construct(
\Magento\Framework\Model\Context $context,
@@ -85,11 +94,14 @@ public function __construct(
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
- CustomOptionPriceCalculator $customOptionPriceCalculator = null
+ CustomOptionPriceCalculator $customOptionPriceCalculator = null,
+ CalculateCustomOptionCatalogRule $CalculateCustomOptionCatalogRule = null
) {
$this->_valueCollectionFactory = $valueCollectionFactory;
$this->customOptionPriceCalculator = $customOptionPriceCalculator
- ?? \Magento\Framework\App\ObjectManager::getInstance()->get(CustomOptionPriceCalculator::class);
+ ?? ObjectManager::getInstance()->get(CustomOptionPriceCalculator::class);
+ $this->calculateCustomOptionCatalogRule = $CalculateCustomOptionCatalogRule
+ ?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
parent::__construct(
$context,
@@ -101,7 +113,7 @@ public function __construct(
}
/**
- * @return void
+ * @inheritDoc
*/
protected function _construct()
{
@@ -109,6 +121,8 @@ protected function _construct()
}
/**
+ * Add value.
+ *
* @codeCoverageIgnoreStart
* @param mixed $value
* @return $this
@@ -120,6 +134,8 @@ public function addValue($value)
}
/**
+ * Get values.
+ *
* @return array
*/
public function getValues()
@@ -128,6 +144,8 @@ public function getValues()
}
/**
+ * Set values.
+ *
* @param array $values
* @return $this
*/
@@ -138,6 +156,8 @@ public function setValues($values)
}
/**
+ * Unset values.
+ *
* @return $this
*/
public function unsetValues()
@@ -147,6 +167,8 @@ public function unsetValues()
}
/**
+ * Set option.
+ *
* @param Option $option
* @return $this
*/
@@ -157,6 +179,8 @@ public function setOption(Option $option)
}
/**
+ * Unset option.
+ *
* @return $this
*/
public function unsetOption()
@@ -166,7 +190,7 @@ public function unsetOption()
}
/**
- * Enter description here...
+ * Get option.
*
* @return Option
*/
@@ -176,6 +200,8 @@ public function getOption()
}
/**
+ * Set product.
+ *
* @param Product $product
* @return $this
*/
@@ -188,6 +214,8 @@ public function setProduct($product)
//@codeCoverageIgnoreEnd
/**
+ * Get product.
+ *
* @return Product
*/
public function getProduct()
@@ -199,7 +227,10 @@ public function getProduct()
}
/**
+ * Save values.
+ *
* @return $this
+ * @throws \Exception
*/
public function saveValues()
{
@@ -225,8 +256,9 @@ public function saveValues()
}
/**
- * Return price. If $flag is true and price is percent
- * return converted percent to price
+ * Return price.
+ *
+ * If $flag is true and price is percent return converted percent to price
*
* @param bool $flag
* @return float|int
@@ -234,7 +266,11 @@ public function saveValues()
public function getPrice($flag = false)
{
if ($flag) {
- return $this->customOptionPriceCalculator->getOptionPriceByPriceCode($this, BasePrice::PRICE_CODE);
+ return $this->calculateCustomOptionCatalogRule->execute(
+ $this->getProduct(),
+ (float)$this->getData(self::KEY_PRICE),
+ $this->getPriceType() === self::TYPE_PERCENT
+ );
}
return $this->_getData(self::KEY_PRICE);
}
@@ -250,7 +286,7 @@ public function getRegularPrice()
}
/**
- * Enter description here...
+ * Get values collection.
*
* @param Option $option
* @return \Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection
@@ -268,6 +304,8 @@ public function getValuesCollection(Option $option)
}
/**
+ * Get values by option.
+ *
* @param array $optionIds
* @param int $option_id
* @param int $store_id
@@ -287,6 +325,8 @@ public function getValuesByOption($optionIds, $option_id, $store_id)
}
/**
+ * Delete value.
+ *
* @param int $option_id
* @return $this
*/
@@ -297,6 +337,8 @@ public function deleteValue($option_id)
}
/**
+ * Delete values.
+ *
* @param int $option_type_id
* @return $this
*/
diff --git a/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php b/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php
new file mode 100644
index 0000000000000..91ff8f921566c
--- /dev/null
+++ b/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php
@@ -0,0 +1,99 @@
+priceModifier = $priceModifier;
+ $this->priceCurrency = $priceCurrency;
+ }
+
+ /**
+ * Calculate prices of custom options of the product with catalog rules applied.
+ *
+ * @param Product $product
+ * @param float $optionPriceValue
+ * @param bool $isPercent
+ * @return float
+ */
+ public function execute(
+ Product $product,
+ float $optionPriceValue,
+ bool $isPercent
+ ): float {
+ $basePrice = $this->getGetBasePriceWithOutCatalogRules($product);
+ if ($isPercent) {
+ $optionPrice = $basePrice * $optionPriceValue / 100;
+ } else {
+ $optionPrice = $optionPriceValue;
+ }
+
+ $totalPriceModified = $this->priceModifier->modifyPrice(
+ $basePrice + $optionPrice,
+ $product
+ );
+ $basePriceModified = $this->priceModifier->modifyPrice(
+ $basePrice,
+ $product
+ );
+ $price = $totalPriceModified - $basePriceModified;
+
+ return $this->priceCurrency->convertAndRound($price);
+ }
+
+ /**
+ * Get product base price without catalog rules applied.
+ *
+ * @param Product $product
+ * @return float
+ */
+ private function getGetBasePriceWithOutCatalogRules(Product $product): float
+ {
+ $basePrice = null;
+ foreach ($product->getPriceInfo()->getPrices() as $price) {
+ if ($price instanceof BasePriceProviderInterface
+ && $price->getPriceCode() !== CatalogRulePrice::PRICE_CODE
+ && $price->getValue() !== false
+ ) {
+ $basePrice = min(
+ $price->getValue(),
+ $basePrice ?? $price->getValue()
+ );
+ }
+ }
+
+ return $basePrice ?? $product->getPrice();
+ }
+}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php
index 1ff5bef78cd79..212c8020750d2 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/Option/ValueTest.php
@@ -3,15 +3,21 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-namespace Magento\Catalog\Test\Unit\Model\Product\Option;
+declare(strict_types=1);
-use \Magento\Catalog\Model\Product\Option\Value;
+namespace Magento\Catalog\Test\Unit\Model\Product\Option;
use Magento\Catalog\Model\Product;
+
use Magento\Catalog\Model\Product\Option;
-use Magento\Framework\Model\ActionValidator\RemoveAction;
+use Magento\Catalog\Model\Product\Option\Value;
+use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use PHPUnit\Framework\MockObject\MockObject;
+/**
+ * Test for \Magento\Catalog\Model\Product\Option\Value class.
+ */
class ValueTest extends \PHPUnit\Framework\TestCase
{
/**
@@ -24,6 +30,11 @@ class ValueTest extends \PHPUnit\Framework\TestCase
*/
private $customOptionPriceCalculatorMock;
+ /**
+ * @var CalculateCustomOptionCatalogRule|MockObject
+ */
+ private $CalculateCustomOptionCatalogRule;
+
protected function setUp()
{
$mockedResource = $this->getMockedResource();
@@ -33,6 +44,10 @@ protected function setUp()
\Magento\Catalog\Pricing\Price\CustomOptionPriceCalculator::class
);
+ $this->CalculateCustomOptionCatalogRule = $this->createMock(
+ CalculateCustomOptionCatalogRule::class
+ );
+
$helper = new ObjectManager($this);
$this->model = $helper->getObject(
\Magento\Catalog\Model\Product\Option\Value::class,
@@ -40,6 +55,7 @@ protected function setUp()
'resource' => $mockedResource,
'valueCollectionFactory' => $mockedCollectionFactory,
'customOptionPriceCalculator' => $this->customOptionPriceCalculatorMock,
+ 'CalculateCustomOptionCatalogRule' => $this->CalculateCustomOptionCatalogRule
]
);
$this->model->setOption($this->getMockedOption());
@@ -66,11 +82,11 @@ public function testGetPrice()
$this->model->setPriceType(Value::TYPE_PERCENT);
$this->assertEquals($price, $this->model->getPrice(false));
- $percentPice = 100;
- $this->customOptionPriceCalculatorMock->expects($this->atLeastOnce())
- ->method('getOptionPriceByPriceCode')
- ->willReturn($percentPice);
- $this->assertEquals($percentPice, $this->model->getPrice(true));
+ $percentPrice = 100;
+ $this->CalculateCustomOptionCatalogRule->expects($this->atLeastOnce())
+ ->method('execute')
+ ->willReturn($percentPrice);
+ $this->assertEquals($percentPrice, $this->model->getPrice(true));
}
public function testGetValuesCollection()
diff --git a/app/code/Magento/CatalogRule/Model/Rule.php b/app/code/Magento/CatalogRule/Model/Rule.php
index f2e8e54d34665..cd24201963f25 100644
--- a/app/code/Magento/CatalogRule/Model/Rule.php
+++ b/app/code/Magento/CatalogRule/Model/Rule.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\CatalogRule\Model;
use Magento\Catalog\Model\Product;
@@ -13,6 +15,7 @@
use Magento\CatalogRule\Helper\Data;
use Magento\CatalogRule\Model\Data\Condition\Converter;
use Magento\CatalogRule\Model\Indexer\Rule\RuleProductProcessor;
+use Magento\CatalogRule\Model\ResourceModel\Product\ConditionsToCollectionApplier;
use Magento\CatalogRule\Model\ResourceModel\Rule as RuleResourceModel;
use Magento\CatalogRule\Model\Rule\Action\CollectionFactory as RuleCollectionFactory;
use Magento\CatalogRule\Model\Rule\Condition\CombineFactory;
@@ -33,7 +36,6 @@
use Magento\Framework\Stdlib\DateTime;
use Magento\Framework\Stdlib\DateTime\TimezoneInterface;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\CatalogRule\Model\ResourceModel\Product\ConditionsToCollectionApplier;
/**
* Catalog Rule data model
@@ -499,7 +501,8 @@ public function calcProductPriceRule(Product $product, $price)
} else {
$customerGroupId = $this->_customerSession->getCustomerGroupId();
}
- $dateTs = $this->_localeDate->scopeTimeStamp($storeId);
+ $currentDateTime = new \DateTime();
+ $dateTs = $currentDateTime->getTimestamp();
$cacheKey = date('Y-m-d', $dateTs) . "|{$websiteId}|{$customerGroupId}|{$productId}|{$price}";
if (!array_key_exists($cacheKey, self::$_priceRulesData)) {
@@ -895,4 +898,12 @@ public function getIdentities()
{
return ['price'];
}
+
+ /**
+ * Clear price rules cache.
+ */
+ public function clearPriceRulesData(): void
+ {
+ self::$_priceRulesData = [];
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/BundlePriceAbstract.php b/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/BundlePriceAbstract.php
index e30916810b1e0..2a7b80e62797d 100644
--- a/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/BundlePriceAbstract.php
+++ b/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/BundlePriceAbstract.php
@@ -3,11 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Bundle\Model\Product;
/**
* Abstract class for testing bundle prices
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
abstract class BundlePriceAbstract extends \PHPUnit\Framework\TestCase
@@ -29,6 +31,14 @@ abstract class BundlePriceAbstract extends \PHPUnit\Framework\TestCase
*/
protected $productCollectionFactory;
+ /**
+ * @var \Magento\CatalogRule\Model\RuleFactory
+ */
+ private $ruleFactory;
+
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
@@ -42,15 +52,19 @@ protected function setUp()
true,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
+ $this->ruleFactory = $this->objectManager->get(\Magento\CatalogRule\Model\RuleFactory::class);
}
/**
- * Get test cases
+ * Get test cases.
+ *
* @return array
*/
abstract public function getTestCases();
/**
+ * Prepare fixture.
+ *
* @param array $strategyModifiers
* @param string $productSku
* @return void
@@ -61,11 +75,14 @@ abstract public function getTestCases();
*/
protected function prepareFixture($strategyModifiers, $productSku)
{
+ $this->ruleFactory->create()->clearPriceRulesData();
+
$bundleProduct = $this->productRepository->get($productSku);
foreach ($strategyModifiers as $modifier) {
if (method_exists($this, $modifier['modifierName'])) {
array_unshift($modifier['data'], $bundleProduct);
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
$bundleProduct = call_user_func_array([$this, $modifier['modifierName']], $modifier['data']);
} else {
throw new \Magento\Framework\Exception\InputException(
@@ -113,6 +130,8 @@ protected function addSimpleProduct(\Magento\Catalog\Model\Product $bundleProduc
}
/**
+ * Add custom option.
+ *
* @param \Magento\Catalog\Model\Product $bundleProduct
* @param array $optionsData
* @return \Magento\Catalog\Model\Product
diff --git a/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/FixedBundleWithCatalogPriceRuleCalculatorTest.php b/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/FixedBundleWithCatalogPriceRuleCalculatorTest.php
index b3c46c75bcfb7..2b0e8c75a15e0 100644
--- a/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/FixedBundleWithCatalogPriceRuleCalculatorTest.php
+++ b/dev/tests/integration/testsuite/Magento/Bundle/Model/Product/FixedBundleWithCatalogPriceRuleCalculatorTest.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Bundle\Model\Product;
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/OptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/OptionsTest.php
index 152ad6a6286f4..8997920ac1e3a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/OptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/OptionsTest.php
@@ -3,8 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Block\Product\View;
+use Magento\CatalogRule\Model\Indexer\IndexBuilder;
+
/**
* Test class for \Magento\Catalog\Block\Product\View\Options.
*/
@@ -30,12 +34,19 @@ class OptionsTest extends \PHPUnit\Framework\TestCase
*/
protected $productRepository;
+ /**
+ * @var IndexBuilder
+ */
+ private $indexBuilder;
+
protected function setUp()
{
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$this->productRepository = $this->objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+ $this->indexBuilder = $this->objectManager->create(IndexBuilder::class);
+
try {
$this->product = $this->productRepository->get('simple');
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
@@ -113,24 +124,63 @@ private function getExpectedJsonConfig()
{
return [
0 => [
- 'prices' =>
- ['oldPrice' =>
- ['amount' => 10, 'adjustments' => []],
+ 'prices' => ['oldPrice' => ['amount' => 10, 'adjustments' => []],
'basePrice' => ['amount' => 10],
'finalPrice' => ['amount' => 10]
],
- 'type' => 'fixed',
- 'name' => 'drop_down option 1',
+ 'type' => 'fixed',
+ 'name' => 'drop_down option 1',
],
1 => [
- 'prices' =>
- ['oldPrice' =>
- ['amount' => 40, 'adjustments' => []],
+ 'prices' => ['oldPrice' => ['amount' => 40, 'adjustments' => []],
'basePrice' => ['amount' => 40],
'finalPrice' => ['amount' => 40],
],
- 'type' => 'percent',
- 'name' => 'drop_down option 2',
+ 'type' => 'percent',
+ 'name' => 'drop_down option 2',
+ ],
+ ];
+ }
+
+ /**
+ * Test option prices with catalog price rules applied.
+ *
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/CatalogRule/_files/two_rules.php
+ * @magentoDataFixture Magento/Catalog/_files/product_with_dropdown_option.php
+ */
+ public function testGetJsonConfigWithCatalogRules()
+ {
+ $this->indexBuilder->reindexFull();
+
+ $config = json_decode($this->block->getJsonConfig(), true);
+ $configValues = array_values($config);
+ $this->assertEquals($this->getExpectedJsonConfigWithCatalogRules(), array_values($configValues[0]));
+ }
+
+ /**
+ * Expected data for testGetJsonConfigWithCatalogRules
+ *
+ * @return array
+ */
+ private function getExpectedJsonConfigWithCatalogRules()
+ {
+ return [
+ 0 => [
+ 'prices' => ['oldPrice' => ['amount' => 10, 'adjustments' => []],
+ 'basePrice' => ['amount' => 9.5],
+ 'finalPrice' => ['amount' => 9.5],
+ ],
+ 'type' => 'fixed',
+ 'name' => 'drop_down option 1',
+ ],
+ 1 => [
+ 'prices' => ['oldPrice' => ['amount' => 40, 'adjustments' => []],
+ 'basePrice' => ['amount' => 38],
+ 'finalPrice' => ['amount' => 38],
+ ],
+ 'type' => 'percent',
+ 'name' => 'drop_down option 2',
],
];
}
From 3bb11bb745298a44ade08ea94cdbf44e35adb35b Mon Sep 17 00:00:00 2001
From: Daniel Ruf
Date: Fri, 4 Oct 2019 10:12:18 +0200
Subject: [PATCH 0249/1978] Simplify some conditional checks
---
.../Model/OperationProcessor.php | 4 +---
.../Magento/Indexer/Test/Unit/Model/IndexerTest.php | 10 +---------
.../Ui/view/base/web/js/lib/validation/rules.js | 2 +-
lib/web/mage/validation.js | 2 +-
4 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
index 6826c34fd35f0..a617a943db9f9 100644
--- a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
+++ b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
@@ -206,9 +206,7 @@ private function executeHandler($callback, $entityParams)
}
} catch (NoSuchEntityException $e) {
$this->logger->error($e->getMessage());
- $result['status'] = ($e instanceof TemporaryStateExceptionInterface) ?
- OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED :
- OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED;
+ $result['status'] = OperationInterface::STATUS_TYPE_NOT_RETRIABLY_FAILED;
$result['error_code'] = $e->getCode();
$result['messages'][] = $e->getMessage();
} catch (LocalizedException $e) {
diff --git a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php
index 6b7cc12218990..3edba23897a35 100644
--- a/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php
+++ b/app/code/Magento/Indexer/Test/Unit/Model/IndexerTest.php
@@ -154,15 +154,7 @@ public function testGetLatestUpdated($getViewIsEnabled, $getViewGetUpdated, $get
$this->stateFactoryMock->expects($this->once())->method('create')->will($this->returnValue($stateMock));
if ($getViewIsEnabled && $getViewGetUpdated) {
- if (!$getStateGetUpdated) {
- $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
- } else {
- if ($getViewGetUpdated == $getStateGetUpdated) {
- $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
- } else {
- $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
- }
- }
+ $this->assertEquals($getViewGetUpdated, $this->model->getLatestUpdated());
} else {
$this->assertEquals($getStateGetUpdated, $this->model->getLatestUpdated());
}
diff --git a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
index d765f842a0895..b558ca2c28079 100644
--- a/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
+++ b/app/code/Magento/Ui/view/base/web/js/lib/validation/rules.js
@@ -822,7 +822,7 @@ define([
],
'validate-state': [
function (value) {
- return value !== 0 || value === '';
+ return value !== 0;
},
$.mage.__('Please select State/Province.')
],
diff --git a/lib/web/mage/validation.js b/lib/web/mage/validation.js
index dfa35473176b9..e4ace239cf1b5 100644
--- a/lib/web/mage/validation.js
+++ b/lib/web/mage/validation.js
@@ -1122,7 +1122,7 @@
],
'validate-state': [
function (v) {
- return v !== 0 || v === '';
+ return v !== 0;
},
$.mage.__('Please select State/Province.')
],
From 2a6dc66bbeab6179a717f31c988ed0a4eee8ec4d Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Fri, 4 Oct 2019 17:04:19 +0300
Subject: [PATCH 0250/1978] Fix for merging guest cart items and customer cart
items
---
.../Magento/Quote/Model/QuoteManagement.php | 31 +++++++++++--------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php
index 84ef699b6209e..1df2cd4d08def 100644
--- a/app/code/Magento/Quote/Model/QuoteManagement.php
+++ b/app/code/Magento/Quote/Model/QuoteManagement.php
@@ -298,23 +298,28 @@ public function assignCustomer($cartId, $customerId, $storeId)
);
}
try {
- $this->quoteRepository->getForCustomer($customerId);
- throw new StateException(
- __("The customer can't be assigned to the cart because the customer already has an active cart.")
- );
- // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
+ $customerActiveQuote = $this->quoteRepository->getForCustomer($customerId);
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ /** This exception appear when customer have no active cart*/
+ $customerActiveQuote = $this->quoteFactory->create();
+ $customerActiveQuote->setCustomer($customer);
+ $customerActiveQuote->setCustomerIsGuest(0);
+ $customerActiveQuote->setStoreId($storeId);
+ $customerActiveQuote->setIsActive(true);
}
- $quote->setCustomer($customer);
- $quote->setCustomerIsGuest(0);
- /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
- $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'quote_id');
- if ($quoteIdMask->getId()) {
- $quoteIdMask->delete();
+ if ($customerActiveQuote->getIsActive()) {
+ /** Merge carts */
+ $customerActiveQuote->merge($quote);
+ $this->quoteRepository->delete($quote);
+ $this->quoteRepository->save($customerActiveQuote);
+
+ return true;
+ } else {
+ throw new \Magento\Framework\Exception\NoSuchEntityException(
+ __("The customer can't be assigned to the cart. No active cart for customer.")
+ );
}
- $this->quoteRepository->save($quote);
- return true;
}
/**
From dc460c817b810553c3a037f9ae65985a07efb975 Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Fri, 4 Oct 2019 17:05:21 +0300
Subject: [PATCH 0251/1978] Update for PHPUnit test scenario according to new
update for merging guest cart and customer cart.
---
.../Test/Unit/Model/QuoteManagementTest.php | 99 ++++++++-----------
1 file changed, 42 insertions(+), 57 deletions(-)
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index cd2afc39733f2..85b030d9d1291 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -7,11 +7,14 @@
namespace Magento\Quote\Test\Unit\Model;
+use Magento\Customer\Api\Data\CustomerInterface;
+use Magento\Customer\Model\Customer;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Quote\Model\CustomerManagement;
+use Magento\Quote\Model\Quote;
use Magento\Quote\Model\QuoteIdMaskFactory;
use Magento\Sales\Api\Data\OrderAddressInterface;
@@ -199,7 +202,7 @@ protected function setUp()
);
$this->quoteMock = $this->createPartialMock(
- \Magento\Quote\Model\Quote::class,
+ Quote::class,
[
'assignCustomer',
'collectTotals',
@@ -275,7 +278,7 @@ public function testCreateEmptyCartAnonymous()
$storeId = 345;
$quoteId = 2311;
- $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
+ $quoteMock = $this->createMock(Quote::class);
$quoteAddress = $this->createPartialMock(
\Magento\Quote\Model\Quote\Address::class,
['setCollectShippingRates']
@@ -306,14 +309,14 @@ public function testCreateEmptyCartForCustomer()
$quoteId = 2311;
$userId = 567;
- $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
+ $quoteMock = $this->createMock(Quote::class);
$this->quoteRepositoryMock
->expects($this->once())
->method('getActiveForCustomer')
->with($userId)
->willThrowException(new NoSuchEntityException());
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
+ $customer = $this->getMockBuilder(CustomerInterface::class)
->setMethods(['getDefaultBilling'])->disableOriginalConstructor()->getMockForAbstractClass();
$quoteAddress = $this->createPartialMock(
\Magento\Quote\Model\Quote\Address::class,
@@ -342,14 +345,14 @@ public function testCreateEmptyCartForCustomerReturnExistsQuote()
$storeId = 345;
$userId = 567;
- $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
+ $quoteMock = $this->createMock(Quote::class);
$this->quoteRepositoryMock
->expects($this->once())
->method('getActiveForCustomer')
->with($userId)->willReturn($quoteMock);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
+ $customer = $this->getMockBuilder(CustomerInterface::class)
->setMethods(['getDefaultBilling'])->disableOriginalConstructor()->getMockForAbstractClass();
$quoteAddress = $this->createPartialMock(
\Magento\Quote\Model\Quote\Address::class,
@@ -379,8 +382,8 @@ public function testAssignCustomerFromAnotherStore()
$customerId = 455;
$storeId = 5;
- $quoteMock = $this->createMock(\Magento\Quote\Model\Quote::class);
- $customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
+ $quoteMock = $this->createMock(Quote::class);
+ $customerMock = $this->createMock(CustomerInterface::class);
$this->quoteRepositoryMock
->expects($this->once())
@@ -395,7 +398,7 @@ public function testAssignCustomerFromAnotherStore()
->willReturn($customerMock);
$customerModelMock = $this->createPartialMock(
- \Magento\Customer\Model\Customer::class,
+ Customer::class,
['load', 'getSharedStoreIds']
);
$this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock);
@@ -424,10 +427,10 @@ public function testAssignCustomerToNonanonymousCart()
$storeId = 5;
$quoteMock = $this->createPartialMock(
- \Magento\Quote\Model\Quote::class,
+ Quote::class,
['getCustomerId', 'setCustomer', 'setCustomerIsGuest']
);
- $customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
+ $customerMock = $this->createMock(CustomerInterface::class);
$this->quoteRepositoryMock
->expects($this->once())
@@ -442,7 +445,7 @@ public function testAssignCustomerToNonanonymousCart()
->willReturn($customerMock);
$customerModelMock = $this->createPartialMock(
- \Magento\Customer\Model\Customer::class,
+ Customer::class,
['load', 'getSharedStoreIds']
);
$this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock);
@@ -463,7 +466,7 @@ public function testAssignCustomerToNonanonymousCart()
}
/**
- * @expectedException \Magento\Framework\Exception\StateException
+ * @expectedException NoSuchEntityException
*/
public function testAssignCustomerNoSuchCustomer()
{
@@ -472,10 +475,9 @@ public function testAssignCustomerNoSuchCustomer()
$storeId = 5;
$quoteMock = $this->createPartialMock(
- \Magento\Quote\Model\Quote::class,
+ Quote::class,
['getCustomerId', 'setCustomer', 'setCustomerIsGuest']
);
- $customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
$this->quoteRepositoryMock
->expects($this->once())
@@ -487,36 +489,14 @@ public function testAssignCustomerNoSuchCustomer()
->expects($this->once())
->method('getById')
->with($customerId)
- ->willReturn($customerMock);
+ ->willThrowException(new NoSuchEntityException());
- $customerModelMock = $this->createPartialMock(
- \Magento\Customer\Model\Customer::class,
- ['load', 'getSharedStoreIds']
+ $this->expectExceptionMessage(
+ "No such entity."
);
- $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock);
- $customerModelMock
- ->expects($this->once())
- ->method('load')
- ->with($customerId)
- ->willReturnSelf();
-
- $customerModelMock
- ->expects($this->once())
- ->method('getSharedStoreIds')
- ->willReturn([$storeId, 'some store value']);
-
- $quoteMock->expects($this->once())->method('getCustomerId')->willReturn(null);
-
- $this->quoteRepositoryMock
- ->expects($this->once())
- ->method('getForCustomer')
- ->with($customerId);
$this->model->assignCustomer($cartId, $customerId, $storeId);
- $this->expectExceptionMessage(
- "The customer can't be assigned to the cart because the customer already has an active cart."
- );
}
public function testAssignCustomer()
@@ -525,18 +505,11 @@ public function testAssignCustomer()
$customerId = 455;
$storeId = 5;
- $this->getPropertyValue($this->model, 'quoteIdMaskFactory')
- ->expects($this->once())
- ->method('create')
- ->willReturn($this->quoteIdMock);
- $this->quoteIdMock->expects($this->once())->method('load')->with($cartId, 'quote_id')->willReturnSelf();
- $this->quoteIdMock->expects($this->once())->method('getId')->willReturn(10);
- $this->quoteIdMock->expects($this->once())->method('delete');
$quoteMock = $this->createPartialMock(
- \Magento\Quote\Model\Quote::class,
- ['getCustomerId', 'setCustomer', 'setCustomerIsGuest']
+ Quote::class,
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'merge']
);
- $customerMock = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
+ $customerMock = $this->createMock(CustomerInterface::class);
$this->quoteRepositoryMock
->expects($this->once())
@@ -551,7 +524,7 @@ public function testAssignCustomer()
->willReturn($customerMock);
$customerModelMock = $this->createPartialMock(
- \Magento\Customer\Model\Customer::class,
+ Customer::class,
['load', 'getSharedStoreIds']
);
$this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock);
@@ -574,10 +547,22 @@ public function testAssignCustomer()
->with($customerId)
->willThrowException(new NoSuchEntityException());
- $quoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
- $quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
+ $activeQuoteMock = $this->createPartialMock(
+ Quote::class,
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
+ );
- $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock);
+ $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($activeQuoteMock);
+ $activeQuoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
+ $activeQuoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
+ $activeQuoteMock->expects($this->once())->method('setStoreId')->with($storeId);
+ $activeQuoteMock->expects($this->once())->method('setIsActive')->with(1);
+
+ $activeQuoteMock->expects($this->once())->method('getIsActive')->willReturn(1);
+ $activeQuoteMock->expects($this->once())->method('merge')->with($quoteMock)->willReturnSelf();
+ $this->quoteRepositoryMock->expects($this->once())->method('delete')->with($quoteMock);
+
+ $this->quoteRepositoryMock->expects($this->once())->method('save')->with($activeQuoteMock);
$this->model->assignCustomer($cartId, $customerId, $storeId);
}
@@ -881,7 +866,7 @@ protected function getQuote(
\Magento\Quote\Model\Quote\Address $shippingAddress = null
) {
$quote = $this->createPartialMock(
- \Magento\Quote\Model\Quote::class,
+ Quote::class,
[
'setIsActive',
'getCustomerEmail',
@@ -928,7 +913,7 @@ protected function getQuote(
->willReturn($payment);
$customer = $this->createPartialMock(
- \Magento\Customer\Model\Customer::class,
+ Customer::class,
['getDefaultBilling', 'getId']
);
$quote->expects($this->any())->method('getCustomerId')->willReturn($customerId);
@@ -1021,7 +1006,7 @@ protected function prepareOrderFactory(
public function testGetCartForCustomer()
{
$customerId = 100;
- $cartMock = $this->createMock(\Magento\Quote\Model\Quote::class);
+ $cartMock = $this->createMock(Quote::class);
$this->quoteRepositoryMock->expects($this->once())
->method('getActiveForCustomer')
->with($customerId)
From 9f77a81dc7921077a0edd600d18d51a95115d002 Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Fri, 4 Oct 2019 18:07:41 +0300
Subject: [PATCH 0252/1978] Add use of NoSuchEntityException exception class
with namespace in test code.
---
.../Quote/Test/Unit/Model/QuoteManagementTest.php | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index 85b030d9d1291..c72dc1979e0e8 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -10,7 +10,6 @@
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\Customer;
use Magento\Framework\App\RequestInterface;
-use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\HTTP\PhpEnvironment\RemoteAddress;
use Magento\Quote\Model\CustomerManagement;
@@ -315,7 +314,7 @@ public function testCreateEmptyCartForCustomer()
->expects($this->once())
->method('getActiveForCustomer')
->with($userId)
- ->willThrowException(new NoSuchEntityException());
+ ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
$customer = $this->getMockBuilder(CustomerInterface::class)
->setMethods(['getDefaultBilling'])->disableOriginalConstructor()->getMockForAbstractClass();
$quoteAddress = $this->createPartialMock(
@@ -466,7 +465,7 @@ public function testAssignCustomerToNonanonymousCart()
}
/**
- * @expectedException NoSuchEntityException
+ * @expectedException \Magento\Framework\Exception\NoSuchEntityException
*/
public function testAssignCustomerNoSuchCustomer()
{
@@ -489,7 +488,7 @@ public function testAssignCustomerNoSuchCustomer()
->expects($this->once())
->method('getById')
->with($customerId)
- ->willThrowException(new NoSuchEntityException());
+ ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
$this->expectExceptionMessage(
"No such entity."
@@ -545,7 +544,7 @@ public function testAssignCustomer()
->expects($this->once())
->method('getForCustomer')
->with($customerId)
- ->willThrowException(new NoSuchEntityException());
+ ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
$activeQuoteMock = $this->createPartialMock(
Quote::class,
@@ -1001,7 +1000,7 @@ protected function prepareOrderFactory(
}
/**
- * @throws NoSuchEntityException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function testGetCartForCustomer()
{
From 616a5f482cacb56e01343442bb831b7bbb70f9e9 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 4 Oct 2019 11:47:11 -0500
Subject: [PATCH 0253/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
app/code/Magento/CatalogRule/etc/indexer.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/etc/indexer.xml b/app/code/Magento/CatalogRule/etc/indexer.xml
index 340918ed63531..e648ea567631c 100644
--- a/app/code/Magento/CatalogRule/etc/indexer.xml
+++ b/app/code/Magento/CatalogRule/etc/indexer.xml
@@ -17,7 +17,6 @@
-
From 1f8379f8848e0af6bc9778cec1d9d59a479634cb Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 4 Oct 2019 14:04:20 -0500
Subject: [PATCH 0254/1978] MC-18685: Remove custom layout updates from admin
---
.../Magento/Install/Test/TestCase/InstallTest.php | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
index b219305a7be65..42c3a5a0ed117 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
@@ -184,7 +184,18 @@ public function test(
// Step 3: Web Configuration.
$assertAdminUri->processAssert($this->installPage);
$this->installPage->getWebConfigBlock()->clickAdvancedOptions();
- $this->installPage->getWebConfigBlock()->fill($installConfig);
+ //Waiting for modules list to show and fill it out
+ $browser->waitUntil(
+ function () use ($installConfig) {
+ try {
+ $this->installPage->getWebConfigBlock()->fill($installConfig);
+ return true;
+ } catch (\Throwable $exception) {
+ //Modules list is not yet loaded, waiting some more
+ return false;
+ }
+ }
+ );
$this->installPage->getWebConfigBlock()->clickNext();
// Step 4: Customize Your Store
$this->installPage->getCustomizeStoreBlock()->fill($installConfig);
From 6ff21a67ba555b2dc24b677a0368085e976a457f Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Fri, 4 Oct 2019 22:46:25 +0300
Subject: [PATCH 0255/1978] Fix for Static Tests build
---
app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index c72dc1979e0e8..59b42b7376597 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -495,7 +495,6 @@ public function testAssignCustomerNoSuchCustomer()
);
$this->model->assignCustomer($cartId, $customerId, $storeId);
-
}
public function testAssignCustomer()
From 55682ec22817c37ebb29caff5702e47d536b3fde Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Fri, 4 Oct 2019 17:31:09 -0500
Subject: [PATCH 0256/1978] MC-18685: Remove custom layout updates from admin
---
.../CheckProductsOrderActionGroup.xml | 3 ++
.../Install/Test/TestCase/InstallTest.php | 28 ++++++++++---------
2 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index 7fbe71cbee301..536ac347f5768 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -19,6 +19,9 @@
+
+
+
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
index 42c3a5a0ed117..add66b1da3d62 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
@@ -184,21 +184,23 @@ public function test(
// Step 3: Web Configuration.
$assertAdminUri->processAssert($this->installPage);
$this->installPage->getWebConfigBlock()->clickAdvancedOptions();
- //Waiting for modules list to show and fill it out
- $browser->waitUntil(
- function () use ($installConfig) {
- try {
- $this->installPage->getWebConfigBlock()->fill($installConfig);
- return true;
- } catch (\Throwable $exception) {
- //Modules list is not yet loaded, waiting some more
- return false;
- }
- }
- );
+ $this->installPage->getWebConfigBlock()->fill($installConfig);
$this->installPage->getWebConfigBlock()->clickNext();
// Step 4: Customize Your Store
- $this->installPage->getCustomizeStoreBlock()->fill($installConfig);
+ //Waiting for block to properly load
+ \PHPUnit\Framework\Assert::assertTrue(
+ $browser->waitUntil(
+ function () use ($installConfig) {
+ try {
+ $this->installPage->getCustomizeStoreBlock()->fill($installConfig);
+ return true;
+ } catch (\Throwable $exception) {
+ //Not loaded yet
+ return false;
+ }
+ }
+ )
+ );
$this->installPage->getCustomizeStoreBlock()->clickNext();
// Step 5: Create Admin Account.
$this->installPage->getCreateAdminBlock()->fill($user);
From d0e2ced7c02a04a32de03d6bad0cb06ff8fc431f Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Sat, 5 Oct 2019 04:27:49 +0300
Subject: [PATCH 0257/1978] Fix assignCustomer for API test. Additional unit
test for assignCustomer when customer has active cart.
---
.../Magento/Quote/Model/QuoteManagement.php | 31 ++---
.../Test/Unit/Model/QuoteManagementTest.php | 107 +++++++++++++++---
2 files changed, 110 insertions(+), 28 deletions(-)
diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php
index 1df2cd4d08def..1aea905706cd5 100644
--- a/app/code/Magento/Quote/Model/QuoteManagement.php
+++ b/app/code/Magento/Quote/Model/QuoteManagement.php
@@ -301,25 +301,28 @@ public function assignCustomer($cartId, $customerId, $storeId)
$customerActiveQuote = $this->quoteRepository->getForCustomer($customerId);
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
/** This exception appear when customer have no active cart*/
- $customerActiveQuote = $this->quoteFactory->create();
- $customerActiveQuote->setCustomer($customer);
- $customerActiveQuote->setCustomerIsGuest(0);
- $customerActiveQuote->setStoreId($storeId);
- $customerActiveQuote->setIsActive(true);
+ $customerActiveQuote = false;
}
- if ($customerActiveQuote->getIsActive()) {
+ if ($customerActiveQuote) {
/** Merge carts */
- $customerActiveQuote->merge($quote);
- $this->quoteRepository->delete($quote);
- $this->quoteRepository->save($customerActiveQuote);
+ $quote->merge($customerActiveQuote);
+ $this->quoteRepository->delete($customerActiveQuote);
+ }
+ $quote->setCustomer($customer);
+ $quote->setCustomerIsGuest(0);
+ $quote->setStoreId($storeId);
+ $quote->setIsActive(1);
- return true;
- } else {
- throw new \Magento\Framework\Exception\NoSuchEntityException(
- __("The customer can't be assigned to the cart. No active cart for customer.")
- );
+ /** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
+ $quoteIdMask = $this->quoteIdMaskFactory->create()->load($cartId, 'quote_id');
+ if ($quoteIdMask->getId()) {
+ $quoteIdMask->delete();
}
+
+ $this->quoteRepository->save($quote);
+
+ return true;
}
/**
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index 59b42b7376597..e5753c8c27fa2 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -497,16 +497,27 @@ public function testAssignCustomerNoSuchCustomer()
$this->model->assignCustomer($cartId, $customerId, $storeId);
}
- public function testAssignCustomer()
+ public function testAssignCustomerWithActiveCart()
{
$cartId = 220;
$customerId = 455;
$storeId = 5;
+ $this->getPropertyValue($this->model, 'quoteIdMaskFactory')
+ ->expects($this->once())
+ ->method('create')
+ ->willReturn($this->quoteIdMock);
+
$quoteMock = $this->createPartialMock(
Quote::class,
- ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'merge']
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
+ );
+
+ $activeQuoteMock = $this->createPartialMock(
+ Quote::class,
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
);
+
$customerMock = $this->createMock(CustomerInterface::class);
$this->quoteRepositoryMock
@@ -538,29 +549,97 @@ public function testAssignCustomer()
->willReturn([$storeId, 'some store value']);
$quoteMock->expects($this->once())->method('getCustomerId')->willReturn(null);
-
$this->quoteRepositoryMock
->expects($this->once())
->method('getForCustomer')
->with($customerId)
- ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
+ ->willReturn($activeQuoteMock);
- $activeQuoteMock = $this->createPartialMock(
+ $quoteMock->expects($this->once())->method('merge')->with($activeQuoteMock)->willReturnSelf();
+ $this->quoteRepositoryMock->expects($this->once())->method('delete')->with($activeQuoteMock);
+
+ $quoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
+ $quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
+ $quoteMock->expects($this->once())->method('setStoreId')->with($storeId);
+ $quoteMock->expects($this->once())->method('setIsActive')->with(1);
+
+ $this->quoteIdMock->expects($this->once())->method('load')->with($cartId, 'quote_id')->willReturnSelf();
+ $this->quoteIdMock->expects($this->once())->method('getId')->willReturn(10);
+ $this->quoteIdMock->expects($this->once())->method('delete');
+ $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock);
+
+ $this->model->assignCustomer($cartId, $customerId, $storeId);
+ }
+
+ public function testAssignCustomer()
+ {
+ $cartId = 220;
+ $customerId = 455;
+ $storeId = 5;
+ $activeQuoteMock = null;
+
+ $this->getPropertyValue($this->model, 'quoteIdMaskFactory')
+ ->expects($this->once())
+ ->method('create')
+ ->willReturn($this->quoteIdMock);
+
+ $quoteMock = $this->createPartialMock(
Quote::class,
['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
);
- $this->quoteFactoryMock->expects($this->once())->method('create')->willReturn($activeQuoteMock);
- $activeQuoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
- $activeQuoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
- $activeQuoteMock->expects($this->once())->method('setStoreId')->with($storeId);
- $activeQuoteMock->expects($this->once())->method('setIsActive')->with(1);
+ $customerMock = $this->createMock(CustomerInterface::class);
+ $this->quoteRepositoryMock
+ ->expects($this->once())
+ ->method('getActive')
+ ->with($cartId)
+ ->willReturn($quoteMock);
+
+ $this->customerRepositoryMock
+ ->expects($this->once())
+ ->method('getById')
+ ->with($customerId)
+ ->willReturn($customerMock);
+
+ $customerModelMock = $this->createPartialMock(
+ Customer::class,
+ ['load', 'getSharedStoreIds']
+ );
- $activeQuoteMock->expects($this->once())->method('getIsActive')->willReturn(1);
- $activeQuoteMock->expects($this->once())->method('merge')->with($quoteMock)->willReturnSelf();
- $this->quoteRepositoryMock->expects($this->once())->method('delete')->with($quoteMock);
+ $this->customerFactoryMock->expects($this->once())->method('create')->willReturn($customerModelMock);
- $this->quoteRepositoryMock->expects($this->once())->method('save')->with($activeQuoteMock);
+ $customerModelMock
+ ->expects($this->once())
+ ->method('load')
+ ->with($customerId)
+ ->willReturnSelf();
+
+ $customerModelMock
+ ->expects($this->once())
+ ->method('getSharedStoreIds')
+ ->willReturn([$storeId, 'some store value']);
+
+ $quoteMock->expects($this->once())->method('getCustomerId')->willReturn(null);
+
+ $this->quoteRepositoryMock
+ ->expects($this->once())
+ ->method('getForCustomer')
+ ->with($customerId)
+ ->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
+
+ $this->assertEquals(false, $activeQuoteMock);
+ $quoteMock->expects($this->never())->method('merge');
+ $this->quoteRepositoryMock->expects($this->never())->method('delete');
+
+ $quoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
+ $quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
+ $quoteMock->expects($this->once())->method('setStoreId')->with($storeId);
+ $quoteMock->expects($this->once())->method('setIsActive')->with(1);
+
+ $this->quoteIdMock->expects($this->once())->method('load')->with($cartId, 'quote_id')->willReturnSelf();
+ $this->quoteIdMock->expects($this->once())->method('getId')->willReturn(10);
+ $this->quoteIdMock->expects($this->once())->method('delete');
+ $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock);
$this->model->assignCustomer($cartId, $customerId, $storeId);
}
From f4cbd32d8013fc653ed5c5fafc3baf167ec01f04 Mon Sep 17 00:00:00 2001
From: lfolco
Date: Sat, 5 Oct 2019 17:47:17 -0400
Subject: [PATCH 0258/1978] handle parameter $requiredAttributeIds when getting
products (magento/magento2#24483)
---
.../Model/Product/Type/Configurable.php | 51 ++++--
.../Model/Product/Type/ConfigurableTest.php | 27 ++++
...duct_configurable_with_metadescription.php | 145 ++++++++++++++++++
...igurable_with_metadescription_rollback.php | 39 +++++
4 files changed, 252 insertions(+), 10 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription.php
create mode 100644 dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription_rollback.php
diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php
index c60953e33e9eb..5b50cc0ebd5e0 100644
--- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php
+++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable.php
@@ -9,12 +9,14 @@
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Config;
use Magento\Catalog\Model\Product\Gallery\ReadHandler as GalleryReadHandler;
use Magento\ConfigurableProduct\Model\Product\Type\Collection\SalableProcessor;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Framework\Api\SearchCriteriaBuilder;
/**
* Configurable product type implementation
@@ -194,9 +196,18 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
*/
private $salableProcessor;
+ /**
+ * @var ProductAttributeRepositoryInterface|null
+ */
+ private $productAttributeRepository;
+
+ /**
+ * @var SearchCriteriaBuilder|null
+ */
+ private $searchCriteriaBuilder;
+
/**
* @codingStandardsIgnoreStart/End
- *
* @param \Magento\Catalog\Model\Product\Option $catalogProductOption
* @param \Magento\Eav\Model\Config $eavConfig
* @param \Magento\Catalog\Model\Product\Type $catalogProductType
@@ -214,9 +225,13 @@ class Configurable extends \Magento\Catalog\Model\Product\Type\AbstractType
* @param \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable $catalogProductTypeConfigurable
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface $extensionAttributesJoinProcessor
+ * @param \Magento\Framework\Cache\FrontendInterface|null $cache
+ * @param \Magento\Customer\Model\Session|null $customerSession
* @param \Magento\Framework\Serialize\Serializer\Json $serializer
* @param ProductInterfaceFactory $productFactory
* @param SalableProcessor $salableProcessor
+ * @param ProductAttributeRepositoryInterface|null $productAttributeRepository
+ * @param SearchCriteriaBuilder|null $searchCriteriaBuilder
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -241,7 +256,9 @@ public function __construct(
\Magento\Customer\Model\Session $customerSession = null,
\Magento\Framework\Serialize\Serializer\Json $serializer = null,
ProductInterfaceFactory $productFactory = null,
- SalableProcessor $salableProcessor = null
+ SalableProcessor $salableProcessor = null,
+ ProductAttributeRepositoryInterface $productAttributeRepository = null,
+ SearchCriteriaBuilder $searchCriteriaBuilder = null
) {
$this->typeConfigurableFactory = $typeConfigurableFactory;
$this->_eavAttributeFactory = $eavAttributeFactory;
@@ -256,6 +273,10 @@ public function __construct(
$this->productFactory = $productFactory ?: ObjectManager::getInstance()
->get(ProductInterfaceFactory::class);
$this->salableProcessor = $salableProcessor ?: ObjectManager::getInstance()->get(SalableProcessor::class);
+ $this->productAttributeRepository = $productAttributeRepository ?:
+ ObjectManager::getInstance()->get(ProductAttributeRepositoryInterface::class);
+ $this->searchCriteriaBuilder = $searchCriteriaBuilder ?:
+ ObjectManager::getInstance()->get(SearchCriteriaBuilder::class);
parent::__construct(
$catalogProductOption,
$eavConfig,
@@ -1231,19 +1252,16 @@ public function isPossibleBuyFromList($product)
/**
* Returns array of sub-products for specified configurable product
- *
- * $requiredAttributeIds - one dimensional array, if provided
* Result array contains all children for specified configurable product
*
* @param \Magento\Catalog\Model\Product $product
- * @param array $requiredAttributeIds
+ * @param array $requiredAttributeIds Attributes to include in the select; one-dimensional array
* @return ProductInterface[]
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function getUsedProducts($product, $requiredAttributeIds = null)
{
if (!$product->hasData($this->_usedProducts)) {
- $collection = $this->getConfiguredUsedProductCollection($product, false);
+ $collection = $this->getConfiguredUsedProductCollection($product, false, $requiredAttributeIds);
$usedProducts = array_values($collection->getItems());
$product->setData($this->_usedProducts, $usedProducts);
}
@@ -1390,16 +1408,18 @@ private function getUsedProductsCacheKey($keyParts)
/**
* Prepare collection for retrieving sub-products of specified configurable product
- *
* Retrieve related products collection with additional configuration
*
* @param \Magento\Catalog\Model\Product $product
* @param bool $skipStockFilter
+ * @param array $requiredAttributeIds Attributes to include in the select
* @return \Magento\ConfigurableProduct\Model\ResourceModel\Product\Type\Configurable\Product\Collection
+ * @throws \Magento\Framework\Exception\LocalizedException
*/
private function getConfiguredUsedProductCollection(
\Magento\Catalog\Model\Product $product,
- $skipStockFilter = true
+ $skipStockFilter = true,
+ $requiredAttributeIds = null
) {
$collection = $this->getUsedProductCollection($product);
@@ -1407,8 +1427,19 @@ private function getConfiguredUsedProductCollection(
$collection->setFlag('has_stock_status_filter', true);
}
+ $attributesForSelect = $this->getAttributesForCollection($product);
+ if ($requiredAttributeIds) {
+ $this->searchCriteriaBuilder->addFilter('attribute_id', $requiredAttributeIds, 'in');
+ $requiredAttributes = $this->productAttributeRepository
+ ->getList($this->searchCriteriaBuilder->create())->getItems();
+ $requiredAttributeCodes = [];
+ foreach ($requiredAttributes as $requiredAttribute) {
+ $requiredAttributeCodes[] = $requiredAttribute->getAttributeCode();
+ }
+ $attributesForSelect = array_unique(array_merge($attributesForSelect, $requiredAttributeCodes));
+ }
$collection
- ->addAttributeToSelect($this->getAttributesForCollection($product))
+ ->addAttributeToSelect($attributesForSelect)
->addFilterByRequiredOptions()
->setStoreId($product->getStoreId());
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 78fa4733a2562..0d2043434d359 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
@@ -254,6 +254,33 @@ public function testGetUsedProducts()
}
}
+ /**
+ * Tests the $requiredAttributes parameter; uses meta_description as an example of an attribute that is not
+ * included in default attribute select.
+ * @magentoAppIsolation enabled
+ * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable_with_metadescription.php
+ */
+ public function testGetUsedProductsWithRequiredAttributes()
+ {
+ $requiredAttributeIds = [86];
+ $products = $this->model->getUsedProducts($this->product, $requiredAttributeIds);
+ foreach ($products as $product) {
+ self::assertNotNull($product->getData('meta_description'));
+ }
+ }
+
+ /**
+ * @magentoAppIsolation enabled
+ * @magentoDataFixture Magento/ConfigurableProduct/_files/product_configurable_with_metadescription.php
+ */
+ public function testGetUsedProductsWithoutRequiredAttributes()
+ {
+ $products = $this->model->getUsedProducts($this->product);
+ foreach ($products as $product) {
+ self::assertNull($product->getData('meta_description'));
+ }
+ }
+
/**
* Test getUsedProducts returns array with same indexes regardless collections was cache or not.
*
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription.php
new file mode 100644
index 0000000000000..d0afeeaf19fe8
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription.php
@@ -0,0 +1,145 @@
+reinitialize();
+
+require __DIR__ . '/configurable_attribute.php';
+
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = Bootstrap::getObjectManager()
+ ->create(ProductRepositoryInterface::class);
+
+/** @var $installer CategorySetup */
+$installer = Bootstrap::getObjectManager()->create(CategorySetup::class);
+
+/* Create simple products per each option value*/
+/** @var AttributeOptionInterface[] $options */
+$options = $attribute->getOptions();
+
+$attributeValues = [];
+$attributeSetId = $installer->getAttributeSetId('catalog_product', 'Default');
+$associatedProductIds = [];
+$productIds = [10, 20];
+array_shift($options); //remove the first option which is empty
+
+foreach ($options as $option) {
+ /** @var $product Product */
+ $product = Bootstrap::getObjectManager()->create(Product::class);
+ $productId = array_shift($productIds);
+ $product->setTypeId(Type::TYPE_SIMPLE)
+ ->setId($productId)
+ ->setAttributeSetId($attributeSetId)
+ ->setWebsiteIds([1])
+ ->setName('Configurable Option' . $option->getLabel())
+ ->setSku('simple_' . $productId)
+ ->setPrice($productId)
+ ->setTestConfigurable($option->getValue())
+ ->setVisibility(Visibility::VISIBILITY_NOT_VISIBLE)
+ ->setStatus(Status::STATUS_ENABLED)
+ ->setMetaDescription('meta_description' . $productId)
+ ->setStockData(['use_config_manage_stock' => 1, 'qty' => 100, 'is_qty_decimal' => 0, 'is_in_stock' => 1]);
+
+ $product = $productRepository->save($product);
+
+ /** @var \Magento\CatalogInventory\Model\Stock\Item $stockItem */
+ $stockItem = Bootstrap::getObjectManager()->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();
+}
+
+/** @var $product Product */
+$product = Bootstrap::getObjectManager()->create(Product::class);
+
+/** @var Factory $optionsFactory */
+$optionsFactory = Bootstrap::getObjectManager()->create(Factory::class);
+
+$configurableAttributesData = [
+ [
+ 'attribute_id' => $attribute->getId(),
+ 'code' => $attribute->getAttributeCode(),
+ 'label' => $attribute->getStoreLabel(),
+ 'position' => '0',
+ 'values' => $attributeValues,
+ ],
+];
+
+$configurableOptions = $optionsFactory->create($configurableAttributesData);
+
+$extensionConfigurableAttributes = $product->getExtensionAttributes();
+$extensionConfigurableAttributes->setConfigurableProductOptions($configurableOptions);
+$extensionConfigurableAttributes->setConfigurableProductLinks($associatedProductIds);
+
+$product->setExtensionAttributes($extensionConfigurableAttributes);
+
+// Remove any previously created product with the same id.
+/** @var \Magento\Framework\Registry $registry */
+$registry = Bootstrap::getObjectManager()->get(\Magento\Framework\Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+try {
+ $productToDelete = $productRepository->getById(1);
+ $productRepository->delete($productToDelete);
+
+ /** @var \Magento\Quote\Model\ResourceModel\Quote\Item $itemResource */
+ $itemResource = Bootstrap::getObjectManager()->get(\Magento\Quote\Model\ResourceModel\Quote\Item::class);
+ $itemResource->getConnection()->delete(
+ $itemResource->getMainTable(),
+ 'product_id = ' . $productToDelete->getId()
+ );
+} catch (\Exception $e) {
+ // Nothing to remove
+}
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+$product->setTypeId(Configurable::TYPE_CODE)
+ ->setId(1)
+ ->setAttributeSetId($attributeSetId)
+ ->setWebsiteIds([1])
+ ->setName('Configurable Product')
+ ->setSku('configurable')
+ ->setVisibility(Visibility::VISIBILITY_BOTH)
+ ->setStatus(Status::STATUS_ENABLED)
+ ->setStockData(['use_config_manage_stock' => 1, 'is_in_stock' => 1]);
+
+$productRepository->save($product);
+
+/** @var \Magento\Catalog\Api\CategoryLinkManagementInterface $categoryLinkManagement */
+$categoryLinkManagement = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->create(\Magento\Catalog\Api\CategoryLinkManagementInterface::class);
+
+$categoryLinkManagement->assignProductToCategories(
+ $product->getSku(),
+ [2]
+);
diff --git a/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription_rollback.php b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription_rollback.php
new file mode 100644
index 0000000000000..21953dea6f587
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/ConfigurableProduct/_files/product_configurable_with_metadescription_rollback.php
@@ -0,0 +1,39 @@
+get(\Magento\Framework\Registry::class);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */
+$productRepository = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()
+ ->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
+
+foreach (['simple_10', 'simple_20', '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
+ }
+}
+
+require __DIR__ . '/configurable_attribute_rollback.php';
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From a3368b58edef5764012d976face8c755a1a97485 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Mon, 7 Oct 2019 09:56:33 +0300
Subject: [PATCH 0259/1978] MC-20624: Automate MC-11459
---
.../Model/Export/CustomerTest.php | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
index 74a21af111fbe..884a4a38ebe0f 100644
--- a/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
+++ b/dev/tests/integration/testsuite/Magento/CustomerImportExport/Model/Export/CustomerTest.php
@@ -142,16 +142,10 @@ private function checkExportData(array $lines, array $expectedAttributes): void
$data = $this->processCustomerData($customer, $expectedAttributes);
$exportData = $lines['data'][$data['email']];
$exportData = $this->unsetDuplicateData($exportData);
- array_walk(
- $exportData,
- function (&$value) {
- if (is_string($value) && $value === '') {
- $value = null;
- }
- }
- );
- $this->assertArraySubset($exportData, $data);
+ foreach ($data as $key => $value) {
+ $this->assertEquals($value, $exportData[$key], "Attribute '{$key}' is not equal.");
+ }
}
}
From f02cb965d7f0a21404c1e25535f98e74e4b928cd Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Mon, 7 Oct 2019 15:37:53 +0300
Subject: [PATCH 0260/1978] MC-19686: Logging in on frontend of Magento 2.3.2
doesn't seem to work properly after you ran 'bin/magento
customer:hash:upgrade'
---
lib/internal/Magento/Framework/Encryption/Encryptor.php | 5 +++--
.../Magento/Framework/Encryption/Test/Unit/EncryptorTest.php | 1 +
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/internal/Magento/Framework/Encryption/Encryptor.php b/lib/internal/Magento/Framework/Encryption/Encryptor.php
index 3e501bdd601b7..c5caf39152607 100644
--- a/lib/internal/Magento/Framework/Encryption/Encryptor.php
+++ b/lib/internal/Magento/Framework/Encryption/Encryptor.php
@@ -273,11 +273,12 @@ public function isValidHash($password, $hash)
{
try {
$this->explodePasswordHash($hash);
+ $recreated = $password;
foreach ($this->getPasswordVersion() as $hashVersion) {
if ($hashVersion === self::HASH_VERSION_ARGON2ID13) {
- $recreated = $this->getArgonHash($password, $this->getPasswordSalt());
+ $recreated = $this->getArgonHash($recreated, $this->getPasswordSalt());
} else {
- $recreated = $this->generateSimpleHash($this->getPasswordSalt() . $password, $hashVersion);
+ $recreated = $this->generateSimpleHash($this->getPasswordSalt() . $recreated, $hashVersion);
}
$hash = $this->getPasswordHash();
}
diff --git a/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php b/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php
index 602d7d5c59b95..6478b74ac05cd 100644
--- a/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php
+++ b/lib/internal/Magento/Framework/Encryption/Test/Unit/EncryptorTest.php
@@ -152,6 +152,7 @@ public function validateHashDataProvider(): array
['password', 'hash:salt:1', false],
['password', '67a1e09bb1f83f5007dc119c14d663aa:salt:0', true],
['password', '13601bda4ea78e55a07b98866d2be6be0744e3866f13c00c811cab608a28f322:salt:1', true],
+ ['password', 'c6aad9e058f6c4b06187c06d2b69bf506a786af030f81fb6d83778422a68205e:salt:1:2', true],
];
}
From b6d071f9b57a784206730e1f3612fd13ffdabf4b Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Mon, 7 Oct 2019 16:26:34 +0300
Subject: [PATCH 0261/1978] MC-5233: DateTime product attributes support
---
.../Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php | 2 +-
app/code/Magento/Catalog/Ui/Component/ColumnFactory.php | 6 +++---
.../Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php | 2 +-
.../Eav/Model/Entity/Attribute/Frontend/Datetime.php | 4 ++--
.../Magento/Ui/Component/Form/Element/DataType/Date.php | 8 ++++----
app/code/Magento/Ui/view/base/web/js/grid/columns/date.js | 4 ++--
.../testsuite/Magento/Eav/Model/Entity/AttributeTest.php | 3 +--
7 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
index ddc7273432cb3..955ea259ec9a8 100644
--- a/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
+++ b/app/code/Magento/Catalog/Block/Adminhtml/Product/Attribute/Edit/Tab/Main.php
@@ -113,7 +113,7 @@ private function removeUnusedFields(): void
$fieldsToRemove = ['attribute_code', 'is_unique', 'frontend_class'];
foreach ($fieldset->getElements() as $element) {
/** @var AbstractElement $element */
- if (substr($element->getId(), 0, strlen('default_value')) == 'default_value') {
+ if (substr($element->getId(), 0, strlen('default_value')) === 'default_value') {
$fieldsToRemove[] = $element->getId();
}
}
diff --git a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
index c538273476b1f..bbcd9bbc9f03a 100644
--- a/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
+++ b/app/code/Magento/Catalog/Ui/Component/ColumnFactory.php
@@ -131,14 +131,14 @@ private function getDateConfig(ProductAttributeInterface $attribute): array
$dateFormat = $isDatetime
? $this->timezone->getDateTimeFormat(\IntlDateFormatter::MEDIUM)
: $this->timezone->getDateFormat(\IntlDateFormatter::MEDIUM);
- $timeZone = $isDatetime
+ $timezone = $isDatetime
? $this->timezone->getConfigTimezone()
: $this->timezone->getDefaultTimezone();
return [
- 'timeZone' => $timeZone,
+ 'timezone' => $timezone,
'dateFormat' => $dateFormat,
- 'options' => [ 'showsTime' => $isDatetime],
+ 'options' => ['showsTime' => $isDatetime],
];
}
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
index e41b2390930f0..0c76feb2c94ec 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
@@ -957,7 +957,7 @@ private function customizeWysiwyg(ProductAttributeInterface $attribute, array $m
* @param array $meta
* @return array
*/
- private function customizeDatetimeAttribute(array $meta)
+ private function customizeDatetimeAttribute(array $meta): array
{
$meta['arguments']['data']['config']['options']['showsTime'] = 1;
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
index 8effd73d34af2..ea454fc0bcc74 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/Frontend/Datetime.php
@@ -44,12 +44,12 @@ public function getValue(\Magento\Framework\DataObject $object)
$value = parent::getValue($object);
if ($value) {
- $timeType = $this->getAttribute()->getFrontendInput() === 'datetime'
+ $showTime = $this->getAttribute()->getFrontendInput() === 'datetime'
? \IntlDateFormatter::MEDIUM : \IntlDateFormatter::NONE;
$data = $this->_localeDate->formatDateTime(
new \DateTime($value),
\IntlDateFormatter::MEDIUM,
- $timeType
+ $showTime
);
}
diff --git a/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php b/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
index 8ea6236e8e2e2..6bf1eacd161cc 100644
--- a/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
+++ b/app/code/Magento/Ui/Component/Form/Element/DataType/Date.php
@@ -127,20 +127,20 @@ public function convertDate($date, $hour = 0, $minute = 0, $second = 0, $setUtcT
* Convert given date to default (UTC) timezone
*
* @param string $date
- * @param bool $setUtcTimeZone
+ * @param bool $setUtcTimezone
* @return \DateTime|null
*/
- public function convertDatetime(string $date, bool $setUtcTimeZone = true): ?\DateTime
+ public function convertDatetime(string $date, bool $setUtcTimezone = true): ?\DateTime
{
try {
$date = rtrim($date, 'Z');
$dateObj = new \DateTime($date, new \DateTimeZone($this->localeDate->getConfigTimezone()));
//convert store date to default date in UTC timezone without DST
- if ($setUtcTimeZone) {
+ if ($setUtcTimezone) {
$dateObj->setTimezone(new \DateTimeZone('UTC'));
}
return $dateObj;
- } catch (\Exception $e) {
+ } catch (\Throwable $e) {
return null;
}
}
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
index cc69d990372c1..3179529e282c6 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
@@ -46,8 +46,8 @@ define([
moment.locale(this.storeLocale, utils.extend({}, this.calendarConfig));
}
- if (!_.isUndefined(this.timeZone)) {
- date = date.tz(this.timeZone);
+ if (!_.isUndefined(this.timezone)) {
+ date = date.tz(this.timezone);
}
date = date.isValid() && value[this.index] ?
diff --git a/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php b/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php
index 5df08762e29a7..5b05308c786b5 100644
--- a/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php
+++ b/dev/tests/integration/testsuite/Magento/Eav/Model/Entity/AttributeTest.php
@@ -7,7 +7,6 @@
namespace Magento\Eav\Model\Entity;
-use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Locale\ResolverInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
@@ -103,7 +102,7 @@ public function beforeSaveDataProvider()
* @param string $locale
* @param string $expected
* @dataProvider beforeSaveErrorDataDataProvider
- * @expectedException LocalizedException
+ * @expectedException \Magento\Framework\Exception\LocalizedException
*/
public function testBeforeSaveErrorData($defaultValue, $backendType, $locale, $expected)
{
From d9cd2ababf92dd16e8e53649fd0534f80915149c Mon Sep 17 00:00:00 2001
From: Veronika Kurochkina
Date: Mon, 7 Oct 2019 14:49:48 +0300
Subject: [PATCH 0262/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Resolve merge conflict
---
app/code/Magento/Sales/i18n/en_US.csv | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/i18n/en_US.csv b/app/code/Magento/Sales/i18n/en_US.csv
index a881a59b535fd..f30315437533f 100644
--- a/app/code/Magento/Sales/i18n/en_US.csv
+++ b/app/code/Magento/Sales/i18n/en_US.csv
@@ -797,4 +797,5 @@ Created,Created
Refunds,Refunds
"Allow Zero GrandTotal for Creditmemo","Allow Zero GrandTotal for Creditmemo"
"Allow Zero GrandTotal","Allow Zero GrandTotal"
-"Could not save the shipment tracking","Could not save the shipment tracking"
\ No newline at end of file
+"Could not save the shipment tracking","Could not save the shipment tracking"
+"Please enter a coupon code!","Please enter a coupon code!"
From 87cde0367e101d10e75a819fde122a7fafc301fd Mon Sep 17 00:00:00 2001
From: Veronika Kurochkina
Date: Mon, 7 Oct 2019 16:42:09 +0300
Subject: [PATCH 0263/1978] MAGETWO-62508: Shipment Tracking REST API should
throw an error if order doesn't exist
- Fix static
---
.../Magento/Sales/Service/V1/ShipmentAddTrackTest.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
index 93d835d77a1e5..639adb8da4624 100644
--- a/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipmentAddTrackTest.php
@@ -20,17 +20,17 @@
class ShipmentAddTrackTest extends WebapiAbstract
{
/**
- * Service read name
+ * Read name of service
*/
const SERVICE_READ_NAME = 'salesShipmentTrackRepositoryV1';
/**
- * Service version
+ * Version of service
*/
const SERVICE_VERSION = 'V1';
/**
- * Shipment increment id
+ * Increment id for shipment
*/
const SHIPMENT_INCREMENT_ID = '100000001';
From eeb766f84b6fdb5fcf5a03029658a56f4eff99c0 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 2 Oct 2019 15:46:25 +0400
Subject: [PATCH 0264/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6406
---
...AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
index fe7960324c0c3..c23175ba95d03 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
@@ -14,7 +14,7 @@
-
+
From 1bf39f917d703b52d655306c8489eaf8b2bda6bb Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 2 Oct 2019 15:48:42 +0400
Subject: [PATCH 0265/1978] MC-18824: Increase test coverage for Import /
export functional area
- Automation test for MC-6317
---
...minURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
index c395f607fb30a..dd4220554b753 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
@@ -14,7 +14,7 @@
-
+
From dbb6837082946eec2d98416abfadc578bf1e67cb Mon Sep 17 00:00:00 2001
From: Yuliya Labudova
Date: Mon, 7 Oct 2019 16:22:40 +0300
Subject: [PATCH 0266/1978] MC-18824: Increase test coverage for Import /
export functional area
- Unskip test for MAGETWO-61593.
---
.../Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml | 2 +-
...kThatSomeAttributesChangedValueToEmptyAfterImportTest.xml | 5 +----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
index 9063916e9f502..12da5974bdbe8 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/ActionGroup/AdminImportProductsActionGroup.xml
@@ -17,7 +17,7 @@
-
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
index af893b1e29e34..e644411d34cc4 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
@@ -18,9 +18,6 @@
-
-
-
@@ -64,7 +61,7 @@
-
+
From d7fac488c4d426e37fd7fccf5b1e1af86ba8afc5 Mon Sep 17 00:00:00 2001
From: Yuliya Labudova
Date: Mon, 7 Oct 2019 16:51:15 +0300
Subject: [PATCH 0267/1978] MC-18824: Increase test coverage for Import /
export functional area
- Fix test MC-6317.
---
...minURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
index dd4220554b753..8d56d9d8dad9d 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminURLKeyWorksWhenUpdatingProductThroughImportingCSVTest.xml
@@ -37,7 +37,7 @@
-
+
From ecc47f5639321a2b5afea9111d9ef9c07faf06f5 Mon Sep 17 00:00:00 2001
From: Yuliya Labudova
Date: Mon, 7 Oct 2019 16:54:00 +0300
Subject: [PATCH 0268/1978] MC-18824: Increase test coverage for Import /
export functional area
- Fix test MC-6406.
---
...AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
index c23175ba95d03..0a1423ece71e0 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductVisibilityDifferentStoreViewsAfterImportTest.xml
@@ -52,7 +52,7 @@
-
+
From b0f2eb875be603b6eb5dfb3e8d17a498a3ed91c7 Mon Sep 17 00:00:00 2001
From: Yuliya Labudova
Date: Mon, 7 Oct 2019 17:03:15 +0300
Subject: [PATCH 0269/1978] MC-18824: Increase test coverage for Import /
export functional area
- Fix conflicts relted to the test MC-6406.
---
app/code/Magento/Store/Test/Mftf/Data/StoreData.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
index 8198e87062e98..bdb1842cf2959 100644
--- a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
+++ b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
@@ -11,6 +11,9 @@
default
1
+
+ All Store Views
+
store
From afb432a40ff687d0aa489ad4ca63bb18f12008f1 Mon Sep 17 00:00:00 2001
From: Andrii-Deineha
Date: Mon, 7 Oct 2019 17:57:34 +0300
Subject: [PATCH 0270/1978] MC-20441: Category rules should apply to grouped
product with invisible individual products
---
.../StorefrontProductCartActionGroup.xml | 14 ++-
...edProductWithTwoLinksToCartActionGroup.xml | 24 ++++
.../AdminCreateCartPriceRuleActionGroup.xml | 24 ++++
...ductWithInvisibleIndividualProductTest.xml | 115 ++++++++++++++++++
4 files changed, 176 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/StorefrontAddGroupedProductWithTwoLinksToCartActionGroup.xml
create mode 100644 app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
index c0a160fcb2a71..5316558b54578 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
@@ -103,7 +103,7 @@
-
+
@@ -112,6 +112,7 @@
+
@@ -146,4 +147,15 @@
+
+
+
+ EXTENDS: StorefrontCheckCartActionGroup. Validates that the provided Discount is present in the Storefront Shopping Cart.
+
+
+
+
+
+
+
diff --git a/app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/StorefrontAddGroupedProductWithTwoLinksToCartActionGroup.xml b/app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/StorefrontAddGroupedProductWithTwoLinksToCartActionGroup.xml
new file mode 100644
index 0000000000000..9763c0a851fff
--- /dev/null
+++ b/app/code/Magento/GroupedProduct/Test/Mftf/ActionGroup/StorefrontAddGroupedProductWithTwoLinksToCartActionGroup.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+ Adding to the Shopping Cart single Grouped product, with 2 associated from the Product page
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml
index c840162f0d162..79cf6bb8c77ae 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml
@@ -139,4 +139,28 @@
+
+
+
+ EXTENDS: AdminCreateCartPriceRuleActionGroup. Sets the provide Condition (Actions Aggregator/Value, Child Attribute and Action Value) for Actions on the Admin Cart Price Rule creation/edit page.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml
new file mode 100644
index 0000000000000..29d2100424c5a
--- /dev/null
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml
@@ -0,0 +1,115 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100
+ 1
+
+
+
+ 200
+ 1
+
+
+
+
+ 300
+ 1
+
+
+
+ 400
+ 1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From bd4b5733ca90fdc1a257f2c496da4490484e9e49 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 7 Oct 2019 12:12:46 -0500
Subject: [PATCH 0271/1978] MC-18685: Remove custom layout updates from admin
---
.../Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml | 2 +-
.../Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index 536ac347f5768..96888c408d2da 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -19,7 +19,7 @@
-
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml b/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml
index cda7f5f3267b0..4c1c088c102cd 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/ActionGroup/StorefrontCustomerWishlistActionGroup.xml
@@ -33,7 +33,7 @@
-
+
From b6f0bb33a648fd1e9014e6fcd93fe019e1e19003 Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Mon, 7 Oct 2019 21:52:41 +0300
Subject: [PATCH 0272/1978] Update functional api test of assignCustomer method
to check if cart merged instead of exception in case if customer has active
cart.
---
.../Magento/Quote/Api/CartManagementTest.php | 17 ++++++++---------
.../Quote/Api/GuestCartManagementTest.php | 16 +++++++---------
2 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php
index 6d585561ae3a9..25d5f9b5a10c6 100644
--- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php
@@ -310,21 +310,20 @@ public function testAssignCustomerThrowsExceptionIfCartIsAssignedToDifferentStor
}
/**
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
* @magentoApiDataFixture Magento/Sales/_files/quote.php
- * @expectedException \Exception
*/
- public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart()
+ public function testAssignCustomerCartMerged()
{
/** @var $customer \Magento\Customer\Model\Customer */
$customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class)->load(1);
// Customer has a quote with reserved order ID test_order_1 (see fixture)
/** @var $customerQuote \Magento\Quote\Model\Quote */
$customerQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)
- ->load('test_order_1', 'reserved_order_id');
- $customerQuote->setIsActive(1)->save();
+ ->load('test_order_item_with_items', 'reserved_order_id');
/** @var $quote \Magento\Quote\Model\Quote */
$quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id');
+ $expectedQuoteItemsQty = $customerQuote->getItemsQty() + $quote->getItemsQty();
$cartId = $quote->getId();
$customerId = $customer->getId();
@@ -346,11 +345,11 @@ public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart(
'customerId' => $customerId,
'storeId' => 1,
];
- $this->_webApiCall($serviceInfo, $requestData);
+ $this->assertTrue($this->_webApiCall( $serviceInfo, $requestData));
- $this->expectExceptionMessage(
- "The customer can't be assigned to the cart because the customer already has an active cart."
- );
+ $mergedQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id');
+
+ $this->assertEquals($expectedQuoteItemsQty, $mergedQuote->getItemsQty());
}
/**
diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php
index bbd1e59f83f90..1c69bc2d57748 100644
--- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php
@@ -231,21 +231,20 @@ public function testAssignCustomerThrowsExceptionIfTargetCartIsNotAnonymous()
}
/**
- * @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_items_saved.php
* @magentoApiDataFixture Magento/Sales/_files/quote.php
- * @expectedException \Exception
*/
- public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart()
+ public function testAssignCustomerCartMerged()
{
/** @var $customer \Magento\Customer\Model\Customer */
$customer = $this->objectManager->create(\Magento\Customer\Model\Customer::class)->load(1);
// Customer has a quote with reserved order ID test_order_1 (see fixture)
/** @var $customerQuote \Magento\Quote\Model\Quote */
$customerQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)
- ->load('test_order_1', 'reserved_order_id');
- $customerQuote->setIsActive(1)->save();
+ ->load('test_order_item_with_items', 'reserved_order_id');
/** @var $quote \Magento\Quote\Model\Quote */
$quote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id');
+ $expectedQuoteItemsQty = $customerQuote->getItemsQty() + $quote->getItemsQty();
$cartId = $quote->getId();
@@ -284,11 +283,10 @@ public function testAssignCustomerThrowsExceptionIfCustomerAlreadyHasActiveCart(
'customerId' => $customerId,
'storeId' => 1,
];
- $this->_webApiCall($serviceInfo, $requestData);
+ $this->assertTrue($this->_webApiCall($serviceInfo, $requestData));
+ $mergedQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id');
- $this->expectExceptionMessage(
- "The customer can't be assigned to the cart because the customer already has an active cart."
- );
+ $this->assertEquals($expectedQuoteItemsQty, $mergedQuote->getItemsQty());
}
/**
From 5bd3d60a3c7580f84ee28cc19e61279ebd8861a5 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 7 Oct 2019 14:40:41 -0500
Subject: [PATCH 0273/1978] MC-18685: Remove custom layout updates from admin
---
.../ActionGroup/CheckProductsOrderActionGroup.xml | 1 +
.../Magento/Install/Test/TestCase/InstallTest.php | 15 +--------------
.../Magento/Install/Test/TestCase/InstallTest.xml | 2 +-
3 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index 96888c408d2da..dcc1ec7fbdd05 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -22,6 +22,7 @@
+
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
index add66b1da3d62..b219305a7be65 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.php
@@ -187,20 +187,7 @@ public function test(
$this->installPage->getWebConfigBlock()->fill($installConfig);
$this->installPage->getWebConfigBlock()->clickNext();
// Step 4: Customize Your Store
- //Waiting for block to properly load
- \PHPUnit\Framework\Assert::assertTrue(
- $browser->waitUntil(
- function () use ($installConfig) {
- try {
- $this->installPage->getCustomizeStoreBlock()->fill($installConfig);
- return true;
- } catch (\Throwable $exception) {
- //Not loaded yet
- return false;
- }
- }
- )
- );
+ $this->installPage->getCustomizeStoreBlock()->fill($installConfig);
$this->installPage->getCustomizeStoreBlock()->clickNext();
// Step 5: Create Admin Account.
$this->installPage->getCreateAdminBlock()->fill($user);
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml
index 86906d4c09406..c0a4ef090258f 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml
@@ -30,7 +30,7 @@
default
pref_
- Chinese (China)
+ Chinese (Simplified Han, China)
From 6900c38941850706d9bff3aae76a428afae1343c Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 7 Oct 2019 15:27:53 -0500
Subject: [PATCH 0274/1978] MC-20648: Implement the changes - added plugins for
loading quote object with discounts - added additional metadata to be stored
in db
---
.../Model/Resolver/CartItemPrices.php | 3 +-
.../QuoteGraphQl/Model/Resolver/Discounts.php | 4 +-
.../SalesRule/Model/Plugin/Discount.php | 101 ++++++++++++++++++
.../Model/Plugin/ResourceModel/Discount.php | 10 ++
.../SalesRule/Model/Quote/Discount.php | 32 +++++-
.../Model/Quote/Item/Plugin/Discount.php | 15 ++-
.../Magento/SalesRule/Model/RulesApplier.php | 2 +-
app/code/Magento/SalesRule/etc/di.xml | 6 ++
8 files changed, 166 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/SalesRule/Model/Plugin/Discount.php
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
index 56488bf0eaadf..bd148ffc9edf1 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
@@ -94,7 +94,8 @@ private function getDiscountValues($cartItem, $currencyCode)
$discount = [];
$amount = [];
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
- $discountAmount = $value['discount'];
+ $discountData = $value['discount'];
+ $discountAmount = $discountData->getAmount();
/* @var \Magento\SalesRule\Model\Rule $rule */
$rule = $value['rule'];
$discount['label'] = $rule ?: __('Discount');
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
index b00d75a305868..7fa66b41c2b4f 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
@@ -49,7 +49,9 @@ private function getDiscountValues(Quote $quote)
/* @var \Magento\SalesRule\Model\Rule $rule*/
$rule = $value['rule'];
$discount['label'] = $rule ?: __('Discount');
- $amount['value'] = $value['discount'];
+ /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
+ $discountData = $value['discount'];
+ $amount['value'] = $discountData->getAmount();
$amount['currency'] = $quote->getQuoteCurrencyCode();
$discount['amount'] = $amount;
$discountValues[] = $discount;
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
new file mode 100644
index 0000000000000..376ed8b8d48bf
--- /dev/null
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -0,0 +1,101 @@
+json = $json;
+ $this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
+ }
+
+ /**
+ * Plugin for adding item discounts to extension attributes
+ *
+ * @param \Magento\Quote\Model\Quote $subject
+ * @param \Magento\Quote\Model\ResourceModel\Quote\Item\Collection $result
+ * @return \Magento\Quote\Model\ResourceModel\Quote\Item\Collection
+ */
+ public function afterGetItemsCollection(
+ \Magento\Quote\Model\Quote $subject,
+ \Magento\Quote\Model\ResourceModel\Quote\Item\Collection $result
+ ) {
+ foreach ($result as $item) {
+ if ($item->getDiscounts() && !$item->getExtensionAttributes()->getDiscounts()) {
+ $discounts = $this->json->unserialize($item->getDiscounts());
+ foreach ($discounts as $key => $value) {
+ $discounts[$key]['discount'] = $this->unserializeDiscountData($value['discount']);
+ }
+ $itemExtension = $item->getExtensionAttributes();
+ $itemExtension->setDiscounts($discounts);
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Plugin for adding address level discounts to extension attributes
+ *
+ * @param \Magento\Quote\Model\Quote $subject
+ * @param array $result
+ * @return array
+ */
+ public function afterGetAllAddresses(
+ \Magento\Quote\Model\Quote $subject,
+ array $result
+ ) {
+ foreach ($result as $address) {
+ if ($address->getDiscounts() && !$address->getExtensionAttributes()->getDiscounts()) {
+ $discounts = $this->json->unserialize($address->getDiscounts());
+ foreach ($discounts as $key => $value) {
+ $discounts[$key]['discount'] = $this->unserializeDiscountData($value['discount']);
+ }
+ $itemExtension = $address->getExtensionAttributes();
+ $itemExtension->setDiscounts($discounts);
+ }
+ }
+ return $result;
+ }
+
+ /**
+ * Unserialize discount object
+ *
+ * @param string $serializedDiscount
+ * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
+ */
+ private function unserializeDiscountData(string $serializedDiscount)
+ {
+ $discountArray = $this->json->unserialize($serializedDiscount);
+ $discountData = $this->discountFactory->create();
+ $discountData->setBaseOriginalAmount($discountArray['baseOriginalAmount']);
+ $discountData->setOriginalAmount($discountArray['originalAmount']);
+ $discountData->setAmount($discountArray['amount']);
+ $discountData->setBaseAmount($discountArray['baseAmount']);
+ return $discountData;
+ }
+}
diff --git a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
index e0e88d9534f18..c240cb973cec6 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
@@ -39,6 +39,16 @@ public function beforeSave(
foreach ($object->getAllAddresses() as $address) {
$discounts = $address->getExtensionAttributes()->getDiscounts();
if ($discounts) {
+ foreach ($discounts as $key => $value) {
+ $discount = $value['discount'];
+ $discountData = [
+ "amount" => $discount->getAmount(),
+ "baseAmount" => $discount->getBaseAmount(),
+ "originalAmount" => $discount->getOriginalAmount(),
+ "baseOriginalAmount" => $discount->getBaseOriginalAmount()
+ ];
+ $discounts[$key]['discount'] = $this->json->serialize($discountData);
+ }
$address->setDiscounts($this->json->serialize($discounts));
}
}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index efd2d5b5a6802..310fea0833532 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -5,6 +5,9 @@
*/
namespace Magento\SalesRule\Model\Quote;
+use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
+use Magento\Framework\App\ObjectManager;
+
/**
* Discount totals calculation model.
*/
@@ -37,22 +40,31 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
protected $priceCurrency;
/**
+ * @var \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory
+ */
+ private $discountFactory;
+
+ /**
+ * Discount constructor.
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\SalesRule\Model\Validator $validator
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
+ * @param DataFactory|null $discountDataFactory
*/
public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\SalesRule\Model\Validator $validator,
- \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
+ \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
+ DataFactory $discountDataFactory = null
) {
$this->setCode(self::COLLECTOR_TYPE_CODE);
$this->eventManager = $eventManager;
$this->calculator = $validator;
$this->storeManager = $storeManager;
$this->priceCurrency = $priceCurrency;
+ $this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
}
/**
@@ -91,12 +103,14 @@ public function collect(
$address->setDiscountDescription([]);
$items = $this->calculator->sortItemsByPriority($items, $address);
+ $address->getExtensionAttributes()->setDiscounts([]);
/** @var \Magento\Quote\Model\Quote\Item $item */
foreach ($items as $item) {
if ($item->getNoDiscount() || !$this->calculator->canApplyDiscount($item)) {
$item->setDiscountAmount(0);
$item->setBaseDiscountAmount(0);
+ $item->getExtensionAttributes()->setDiscounts([]);
// ensure my children are zeroed out
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
@@ -233,14 +247,26 @@ private function aggregateDiscountPerRule(
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
$discountPerRule = $address->getExtensionAttributes()->getDiscounts();
if ($discountBreakdown) {
+ /** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
foreach ($discountBreakdown as $key => $value) {
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
$discount = $value['discount'];
$ruleLabel = $value['rule'];
if (isset($discountPerRule[$key])) {
- $discountPerRule[$key]['discount'] += $discount;
+ $discountData = $discountPerRule[$key]['discount'];
+ $discountData->setBaseAmount($discountData->getBaseAmount()+$discount->getBaseAmount());
+ $discountData->setAmount($discountData->getAmount()+$discount->getAmount());
+ $discountData->setOriginalAmount($discountData->getOriginalAmount()+$discount->getOriginalAmount());
+ $discountData->setBaseOriginalAmount(
+ $discountData->getBaseOriginalAmount()+$discount->getBaseOriginalAmount()
+ );
} else {
- $discountPerRule[$key]['discount'] = $discount;
+ $discountData = $this->discountFactory->create();
+ $discountData->setBaseAmount($discount->getBaseAmount());
+ $discountData->setAmount($discount->getAmount());
+ $discountData->setOriginalAmount($discount->getOriginalAmount());
+ $discountData->setBaseOriginalAmount($discount->getBaseOriginalAmount());
+ $discountPerRule[$key]['discount'] = $discountData;
}
$discountPerRule[$key]['rule'] = $ruleLabel;
}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
index 143fa073b37ec..e746e1ff52234 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
@@ -37,7 +37,20 @@ public function __construct(Json $json)
public function beforeSave(CartItemPersister $subject, CartInterface $quote, CartItemInterface $cartItem)
{
$cartExtension = $cartItem->getExtensionAttributes();
- $cartItem->setDiscounts($this->json->serialize($cartExtension->getDiscounts()));
+ $discounts = $cartExtension->getDiscounts();
+ if ($discounts) {
+ foreach ($discounts as $key => $value) {
+ $discount = $value['discount'];
+ $discountData = [
+ "amount" => $discount->getAmount(),
+ "baseAmount" => $discount->getBaseAmount(),
+ "originalAmount" => $discount->getOriginalAmount(),
+ "baseOriginalAmount" => $discount->getBaseOriginalAmount(),
+ ];
+ $discounts[$key]['discount'] = $this->json->serialize($discountData);
+ }
+ $cartItem->setDiscounts($this->json->serialize($discounts));
+ }
return [$quote, $cartItem];
}
}
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index f09d02b31dfb4..8a15e167f06cf 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -211,7 +211,7 @@ private function setDiscountBreakdown($discountData, $item, $rule, $address)
$discount->setBaseAmount($discountData->getBaseAmount());
$discount->setOriginalAmount($discountData->getOriginalAmount());
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts() ?? [];
- $discountBreakdown[$rule->getId()]['discount'] = $discountData->getAmount();
+ $discountBreakdown[$rule->getId()]['discount'] = $discount;
$discountBreakdown[$rule->getId()]['rule'] = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
$item->getExtensionAttributes()->setDiscounts($discountBreakdown);
}
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index a3bc8b7e57e8f..77794ad2cac09 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -46,6 +46,12 @@
+
+
+
+
+
+
From 5f286a0d56e3b15ba003efd5eb692b4e64523a99 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 7 Oct 2019 15:37:40 -0500
Subject: [PATCH 0275/1978] MC-20648: Implement the changes - review fixes
---
.../Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php | 4 +---
app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php | 4 +---
app/code/Magento/SalesRule/Model/Quote/Discount.php | 1 -
3 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
index bd148ffc9edf1..92a5f926a7d6a 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
@@ -96,9 +96,7 @@ private function getDiscountValues($cartItem, $currencyCode)
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
$discountData = $value['discount'];
$discountAmount = $discountData->getAmount();
- /* @var \Magento\SalesRule\Model\Rule $rule */
- $rule = $value['rule'];
- $discount['label'] = $rule ?: __('Discount');
+ $discount['label'] = $value['rule'] ?: __('Discount');
$amount['value'] = $discountAmount;
$amount['currency'] = $currencyCode;
$discount['amount'] = $amount;
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
index 7fa66b41c2b4f..cfec52a9600e1 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
@@ -46,9 +46,7 @@ private function getDiscountValues(Quote $quote)
foreach ($totalDiscounts as $value) {
$discount = [];
$amount = [];
- /* @var \Magento\SalesRule\Model\Rule $rule*/
- $rule = $value['rule'];
- $discount['label'] = $rule ?: __('Discount');
+ $discount['label'] = $value['rule'] ?: __('Discount');
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
$discountData = $value['discount'];
$amount['value'] = $discountData->getAmount();
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 310fea0833532..1c1a6cd69ded5 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -45,7 +45,6 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
private $discountFactory;
/**
- * Discount constructor.
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\SalesRule\Model\Validator $validator
From fe12c41fb92d9ee24f7af529230919cbdb162ba2 Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Tue, 8 Oct 2019 01:23:07 +0300
Subject: [PATCH 0276/1978] Fix for Static Tests build
---
.../testsuite/Magento/Quote/Api/CartManagementTest.php | 6 ++++--
.../testsuite/Magento/Quote/Api/GuestCartManagementTest.php | 4 +++-
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php
index 25d5f9b5a10c6..08821b08ede5e 100644
--- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/CartManagementTest.php
@@ -345,9 +345,11 @@ public function testAssignCustomerCartMerged()
'customerId' => $customerId,
'storeId' => 1,
];
- $this->assertTrue($this->_webApiCall( $serviceInfo, $requestData));
+ $this->assertTrue($this->_webApiCall($serviceInfo, $requestData));
- $mergedQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id');
+ $mergedQuote = $this->objectManager
+ ->create(\Magento\Quote\Model\Quote::class)
+ ->load('test01', 'reserved_order_id');
$this->assertEquals($expectedQuoteItemsQty, $mergedQuote->getItemsQty());
}
diff --git a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php
index 1c69bc2d57748..120781e674d47 100644
--- a/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/Quote/Api/GuestCartManagementTest.php
@@ -284,7 +284,9 @@ public function testAssignCustomerCartMerged()
'storeId' => 1,
];
$this->assertTrue($this->_webApiCall($serviceInfo, $requestData));
- $mergedQuote = $this->objectManager->create(\Magento\Quote\Model\Quote::class)->load('test01', 'reserved_order_id');
+ $mergedQuote = $this->objectManager
+ ->create(\Magento\Quote\Model\Quote::class)
+ ->load('test01', 'reserved_order_id');
$this->assertEquals($expectedQuoteItemsQty, $mergedQuote->getItemsQty());
}
From fc1dfb047c3085713f18243c832f3cbdfbf43872 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 7 Oct 2019 20:41:29 -0500
Subject: [PATCH 0277/1978] MC-18685: Remove custom layout updates from admin
---
.../Mftf/ActionGroup/CheckProductsOrderActionGroup.xml | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index dcc1ec7fbdd05..c23634eb4fc06 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -18,11 +18,11 @@
-
+
-
-
-
+
+
+
From 656be5bde91726cbdc7a47a8297d3254ade8e09f Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 7 Oct 2019 20:58:18 -0500
Subject: [PATCH 0278/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Catalog/etc/di.xml | 10 ++++++++++
app/code/Magento/Cms/etc/di.xml | 5 +++++
2 files changed, 15 insertions(+)
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 570fa6e7f9ef7..b6304d5945bfe 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1176,4 +1176,14 @@
+
+
+ Magento\Framework\View\Design\Theme\FlyweightFactory\Proxy
+
+
+
+
+ Magento\Framework\View\Design\Theme\FlyweightFactory\Proxy
+
+
diff --git a/app/code/Magento/Cms/etc/di.xml b/app/code/Magento/Cms/etc/di.xml
index 3d97bf4ac0de0..7a0a218b520ac 100644
--- a/app/code/Magento/Cms/etc/di.xml
+++ b/app/code/Magento/Cms/etc/di.xml
@@ -236,5 +236,10 @@
+
+
+ Magento\Framework\View\Design\Theme\FlyweightFactory\Proxy
+
+
From ce90b4cbce8baf4bcacb3c2da739407dd486d71a Mon Sep 17 00:00:00 2001
From: Bohdan Shevchenko <1408sheva@gmail.com>
Date: Tue, 8 Oct 2019 09:37:26 +0300
Subject: [PATCH 0279/1978] MC-21563: [Task] Deprecate Authorize.Net core
payment integration in 2.3.4
---
...erifySecureURLRedirectAuthorizenetTest.xml | 42 -----
...nfigureAuthorizenetAcceptjsActionGroup.xml | 57 ------
.../FillPaymentInformationActionGroup.xml | 46 -----
.../ViewAndValidateOrderActionGroup.xml | 80 --------
...uthorizenetAcceptjsOrderValidationData.xml | 18 --
.../Test/Mftf/Section/AdminMenuSection.xml | 25 ---
...thorizenetAcceptjsConfigurationSection.xml | 24 ---
.../Section/AuthorizenetCheckoutSection.xml | 19 --
.../ConfigurationMainActionsSection.xml | 14 --
.../GuestAuthorizenetCheckoutSection.xml | 22 ---
.../Test/Mftf/Section/OrdersGridSection.xml | 14 --
.../StoresConfigurationListSection.xml | 15 --
.../Mftf/Section/StoresSubmenuSection.xml | 14 --
.../Test/Mftf/Section/ViewOrderSection.xml | 25 ---
...enetAcceptjsWithoutRequiredOptionsTest.xml | 31 ----
.../FullCaptureAuthorizenetAcceptjsTest.xml | 77 --------
...VirtualProductAuthorizenetAcceptjsTest.xml | 86 ---------
.../AuthorizenetFraudCheckoutTest.php | 47 -----
.../AuthorizenetFraudCheckoutTest.xml | 38 ----
.../TestCase/OnePageCheckoutDeclinedTest.xml | 25 ---
...tMethodDataPersistenceWithDiscountTest.xml | 33 ----
.../Test/TestCase/OnePageCheckoutTest.xml | 32 ----
.../Test/TestCase/ReorderOrderEntityTest.xml | 33 ----
.../AcceptTransactionOnAuthorizenetStep.php | 173 ------------------
24 files changed, 990 deletions(-)
delete mode 100644 app/code/Magento/Authorizenet/Test/Mftf/Test/StorefrontVerifySecureURLRedirectAuthorizenetTest.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ConfigureAuthorizenetAcceptjsActionGroup.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/FillPaymentInformationActionGroup.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ViewAndValidateOrderActionGroup.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Data/AuthorizenetAcceptjsOrderValidationData.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AdminMenuSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetAcceptjsConfigurationSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetCheckoutSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ConfigurationMainActionsSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/GuestAuthorizenetCheckoutSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/OrdersGridSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresConfigurationListSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresSubmenuSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ViewOrderSection.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/ConfigureAuthorizenetAcceptjsWithoutRequiredOptionsTest.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml
delete mode 100644 app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.php
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.xml
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutDeclinedTest.xml
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutPaymentMethodDataPersistenceWithDiscountTest.xml
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/ReorderOrderEntityTest.xml
delete mode 100644 dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestStep/AcceptTransactionOnAuthorizenetStep.php
diff --git a/app/code/Magento/Authorizenet/Test/Mftf/Test/StorefrontVerifySecureURLRedirectAuthorizenetTest.xml b/app/code/Magento/Authorizenet/Test/Mftf/Test/StorefrontVerifySecureURLRedirectAuthorizenetTest.xml
deleted file mode 100644
index 5db903f0ed54a..0000000000000
--- a/app/code/Magento/Authorizenet/Test/Mftf/Test/StorefrontVerifySecureURLRedirectAuthorizenetTest.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ConfigureAuthorizenetAcceptjsActionGroup.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ConfigureAuthorizenetAcceptjsActionGroup.xml
deleted file mode 100644
index 924f2b720dd2f..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ConfigureAuthorizenetAcceptjsActionGroup.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-
-
-
-
-
-
- Sets up the Authorize.net Accept JS configuration setting with a specified Payment action.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Disables the Authorize.net Accept JS configuration setting via the CLI.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/FillPaymentInformationActionGroup.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/FillPaymentInformationActionGroup.xml
deleted file mode 100644
index 96c0b122e36d9..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/FillPaymentInformationActionGroup.xml
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
-
- Fill Payment Method with Authorize.net
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Fill Billing Address as Guest with Authorize.net
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ViewAndValidateOrderActionGroup.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ViewAndValidateOrderActionGroup.xml
deleted file mode 100644
index ecbed57ff15b0..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/ActionGroup/ViewAndValidateOrderActionGroup.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
-
-
-
-
-
- Validate the Order is Correct. Then Submit the Invoice.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Validate the Order is Correct. Do Not Submit the Invoice.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Data/AuthorizenetAcceptjsOrderValidationData.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Data/AuthorizenetAcceptjsOrderValidationData.xml
deleted file mode 100644
index 59d4be98d450c..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Data/AuthorizenetAcceptjsOrderValidationData.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
- $24.68
- $128.00
- Processing
- Capture
- No
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AdminMenuSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AdminMenuSection.xml
deleted file mode 100644
index defb91339ea8f..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AdminMenuSection.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetAcceptjsConfigurationSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetAcceptjsConfigurationSection.xml
deleted file mode 100644
index 31be865ea2678..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetAcceptjsConfigurationSection.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetCheckoutSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetCheckoutSection.xml
deleted file mode 100644
index 5d97842de374c..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/AuthorizenetCheckoutSection.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ConfigurationMainActionsSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ConfigurationMainActionsSection.xml
deleted file mode 100644
index 344330c4bc052..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ConfigurationMainActionsSection.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/GuestAuthorizenetCheckoutSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/GuestAuthorizenetCheckoutSection.xml
deleted file mode 100644
index b5f2ecf641162..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/GuestAuthorizenetCheckoutSection.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/OrdersGridSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/OrdersGridSection.xml
deleted file mode 100644
index 7ae3dd0ffee89..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/OrdersGridSection.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresConfigurationListSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresConfigurationListSection.xml
deleted file mode 100644
index f9f1bef38d17d..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresConfigurationListSection.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresSubmenuSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresSubmenuSection.xml
deleted file mode 100644
index e54f9808fd49e..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/StoresSubmenuSection.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ViewOrderSection.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ViewOrderSection.xml
deleted file mode 100644
index 608067d7d31a1..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Section/ViewOrderSection.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/ConfigureAuthorizenetAcceptjsWithoutRequiredOptionsTest.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/ConfigureAuthorizenetAcceptjsWithoutRequiredOptionsTest.xml
deleted file mode 100644
index cbb702c26f17d..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/ConfigureAuthorizenetAcceptjsWithoutRequiredOptionsTest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml
deleted file mode 100644
index 7f25482d627e1..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/FullCaptureAuthorizenetAcceptjsTest.xml
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml b/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml
deleted file mode 100644
index 919c32d8f70d6..0000000000000
--- a/app/code/Magento/AuthorizenetAcceptjs/Test/Mftf/Test/GuestCheckoutVirtualProductAuthorizenetAcceptjsTest.xml
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.php b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.php
deleted file mode 100644
index ca0c473eb685f..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.php
+++ /dev/null
@@ -1,47 +0,0 @@
-executeScenario();
- }
-}
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.xml
deleted file mode 100644
index 9ba32a4cc7a6b..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/AuthorizenetFraudCheckoutTest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- catalogProductSimple::product_10_dollar
- default
- US_address_1_without_email
- login
- Flat Rate
- Fixed
-
- - 15.00
-
-
- - Pending
- - Suspected Fraud
- - Back, Send Email, Get Payment Update
-
- authorizenet_directpost
- visa_default
- sandbox_fraud_hold_review
- unsettled
- authorizenet_fraud_review, authorizenet_authorize_capture
- Processing
- Paid
- Back, Send Email, Credit Memo, Hold, Ship, Reorder
- test_type:3rd_party_test, severity:S1
-
-
-
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutDeclinedTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutDeclinedTest.xml
deleted file mode 100644
index 00c1a1557e05b..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutDeclinedTest.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
- catalogProductSimple::product_10_dollar
- default
- US_address_1_without_email
- login
- Flat Rate
- Fixed
- authorizenet_directpost
- visa_default
- authorizenet, authorizenet_wrong_credentials
- A server error stopped your order from being placed. Please try to place your order again.
- test_type:3rd_party_test, severity:S2
-
-
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutPaymentMethodDataPersistenceWithDiscountTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutPaymentMethodDataPersistenceWithDiscountTest.xml
deleted file mode 100644
index b979745a99b96..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutPaymentMethodDataPersistenceWithDiscountTest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
- Use saved for Authorize.net credit card on checkout
- catalogProductSimple::product_10_dollar
- default
- active_sales_rule_for_all_groups
- US_address_1_without_email
- login
- Flat Rate
- Fixed
- authorizenet_directpost
- default
- visa_default
- authorizenet
-
- - 10.00
-
- Yes
- authorizenet
- Processing
- severity:S1
-
-
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml
deleted file mode 100644
index a7eaaada1be83..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/OnePageCheckoutTest.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
- catalogProductSimple::product_10_dollar
- default
- login
- US_address_1_without_email
- Flat Rate
- Fixed
-
- - 15.00
-
- authorizenet_directpost
- visa_default
- authorizenet
- Processing
- test_type:3rd_party_test, severity:S0
-
-
-
-
-
-
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/ReorderOrderEntityTest.xml b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/ReorderOrderEntityTest.xml
deleted file mode 100644
index b0f4856e28d0d..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestCase/ReorderOrderEntityTest.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
- test_type:3rd_party_test, severity:S2
- Reorder placed order using Authorize.Net payment method (update products, billing address).
- default
- default
- US_address_1_without_email
- Flat Rate
- Fixed
-
- - 565.00
-
- authorizenet_directpost
- authorizenet
- visa_default_admin
- Processing
- Processing
- Back, Reorder, Cancel, Send Email, Hold, Invoice, Ship, Edit
-
-
-
-
-
-
-
diff --git a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestStep/AcceptTransactionOnAuthorizenetStep.php b/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestStep/AcceptTransactionOnAuthorizenetStep.php
deleted file mode 100644
index 0ff6bb486cf81..0000000000000
--- a/dev/tests/functional/tests/app/Magento/Authorizenet/Test/TestStep/AcceptTransactionOnAuthorizenetStep.php
+++ /dev/null
@@ -1,173 +0,0 @@
- frame';
-
- /**
- * Transaction search fixture.
- *
- * @var TransactionSearch
- */
- private $transactionSearch;
-
- /**
- * @param AuthorizenetSandboxCustomer $sandboxCustomer
- * @param TransactionSearch $transactionSearch
- * @param Main $main
- * @param SalesOrderView $salesOrderView
- * @param OrderIndex $salesOrder
- * @param AssertInvoiceStatusInOrdersGrid $assertInvoiceStatusInOrdersGrid
- * @param AssertOrderButtonsAvailable $assertOrderButtonsAvailable
- * @param BrowserInterface $browser
- * @param array $orderBeforeAccept
- * @param string $orderId
- *
- * @SuppressWarnings(PHPMD.ExcessiveParameterList)
- */
- public function __construct(
- AuthorizenetSandboxCustomer $sandboxCustomer,
- TransactionSearch $transactionSearch,
- Main $main,
- SalesOrderView $salesOrderView,
- OrderIndex $salesOrder,
- AssertInvoiceStatusInOrdersGrid $assertInvoiceStatusInOrdersGrid,
- AssertOrderButtonsAvailable $assertOrderButtonsAvailable,
- BrowserInterface $browser,
- array $orderBeforeAccept,
- $orderId
- ) {
- $this->sandboxCustomer = $sandboxCustomer;
- $this->transactionSearch = $transactionSearch;
- $this->main = $main;
- $this->salesOrderView = $salesOrderView;
- $this->salesOrder = $salesOrder;
- $this->assertInvoiceStatusInOrdersGrid = $assertInvoiceStatusInOrdersGrid;
- $this->assertOrderButtonsAvailable = $assertOrderButtonsAvailable;
- $this->browser = $browser;
- $this->orderBeforeAccept = $orderBeforeAccept;
- $this->orderId = $orderId;
- }
-
- /**
- * Accept transaction on sandbox.authorize.net account.
- *
- * @return void
- * @throws \Exception
- */
- public function run()
- {
- $this->assertInvoiceStatusInOrdersGrid->processAssert(
- $this->salesOrderView,
- $this->orderBeforeAccept['invoiceStatus'],
- $this->orderId
- );
- $this->assertOrderButtonsAvailable->processAssert(
- $this->salesOrderView,
- $this->orderBeforeAccept['buttonsAvailable']
- );
- $this->salesOrder->open();
- $this->salesOrder->getSalesOrderGrid()->searchAndOpen(['id' => $this->orderId]);
-
- /** @var \Magento\Sales\Test\Block\Adminhtml\Order\View\Tab\Info $infoTab */
- $infoTab = $this->salesOrderView->getOrderForm()->openTab('info')->getTab('info');
- $latestComment = $infoTab->getCommentsHistoryBlock()->getLatestComment();
- if (!preg_match('/"(\d+)"/', $latestComment['comment'], $matches)) {
- throw new \Exception('Comment with transaction id cannot be found.');
- }
- $transactionId = $matches[1];
- $this->main->open();
- $this->browser->switchToFrame($this->browser->find($this->frame)->getLocator());
- $this->main->getLoginForm()->fill($this->sandboxCustomer)->login();
- $this->main->getModalBlock()->acceptNotification();
- $this->main->getMenuBlock()->openSearchMenu();
- $this->main->getSearchForm()->fill($this->transactionSearch)->search();
- $this->main->getTransactionsGridBlock()->openTransaction($transactionId)->approveTransaction();
- }
-}
From 8e985b1fadd22a5af3f0be38de5954c0a92f2038 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Tue, 8 Oct 2019 11:33:36 +0400
Subject: [PATCH 0280/1978] MC-18820: Increase test coverage for Admin
functional area
- Automation test for MC-6310
---
.../Mftf/Data/GeneralLocalConfigsData.xml | 23 ++++++++++++++++
.../AdminElasticConnectionTestActionGroup.xml | 7 ++---
.../Data/AdminElasticSearch6MessagesData.xml | 14 ++++++++++
.../Mftf/Data/Elasticsearch6ConfigData.xml | 15 +++++++++++
...frontElasticSearchForChineseLocaleTest.xml | 27 +++++--------------
.../Test/Mftf/Data/SearchEngineConfigData.xml | 15 +++++++++++
6 files changed, 78 insertions(+), 23 deletions(-)
create mode 100644 app/code/Magento/Backend/Test/Mftf/Data/GeneralLocalConfigsData.xml
create mode 100644 app/code/Magento/Elasticsearch6/Test/Mftf/Data/AdminElasticSearch6MessagesData.xml
create mode 100644 app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml
create mode 100644 app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml
diff --git a/app/code/Magento/Backend/Test/Mftf/Data/GeneralLocalConfigsData.xml b/app/code/Magento/Backend/Test/Mftf/Data/GeneralLocalConfigsData.xml
new file mode 100644
index 0000000000000..22d595c39407f
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/Data/GeneralLocalConfigsData.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+ general/locale/code
+ websites
+ base
+ zh_Hans_CN
+
+
+ general/locale/code
+ websites
+ base
+ en_US
+
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
index 27b53b7c3e6dd..d00c1c59a0f8d 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/ActionGroup/AdminElasticConnectionTestActionGroup.xml
@@ -9,6 +9,9 @@
+
+ Check ElasticSearch connection after enabling.
+
@@ -16,8 +19,6 @@
-
-
-
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Data/AdminElasticSearch6MessagesData.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/AdminElasticSearch6MessagesData.xml
new file mode 100644
index 0000000000000..3fa0ef9fd1c28
--- /dev/null
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/AdminElasticSearch6MessagesData.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Successful! Test again?
+
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml
new file mode 100644
index 0000000000000..7a61f13e62049
--- /dev/null
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Data/Elasticsearch6ConfigData.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ catalog/search/engine
+ elasticsearch6
+
+
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml
index 1acdaa8ce2b33..fd18a0f4e1e5e 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticSearchForChineseLocaleTest.xml
@@ -8,10 +8,10 @@
-
+
-
-
+
+
@@ -21,10 +21,9 @@
-
-
-
+
+
@@ -35,29 +34,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
-
-
diff --git a/app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml b/app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml
new file mode 100644
index 0000000000000..fe3827d32594a
--- /dev/null
+++ b/app/code/Magento/Search/Test/Mftf/Data/SearchEngineConfigData.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+ catalog/search/engine
+ mysql
+
+
\ No newline at end of file
From 9c9f9fcc5bed3b5df1ef81df4c8ff3333a826bb1 Mon Sep 17 00:00:00 2001
From: Daniel Ruf
Date: Tue, 8 Oct 2019 09:55:29 +0200
Subject: [PATCH 0281/1978] Fix parameter order
---
.../Magento/AsynchronousOperations/Model/OperationProcessor.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
index a617a943db9f9..5f644fa03ae27 100644
--- a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
+++ b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
@@ -80,9 +80,9 @@ class OperationProcessor
* @param ConsumerConfigurationInterface $configuration
* @param Json $jsonHelper
* @param OperationManagementInterface $operationManagement
- * @param LoggerInterface $logger
* @param \Magento\Framework\Webapi\ServiceOutputProcessor $serviceOutputProcessor
* @param \Magento\Framework\Communication\ConfigInterface $communicationConfig
+ * @param LoggerInterface $logger
*/
public function __construct(
MessageValidator $messageValidator,
From 7c55ae5bb6322225b97cdc5c61884e75cb6575b8 Mon Sep 17 00:00:00 2001
From: Daniel Ruf
Date: Tue, 8 Oct 2019 10:11:54 +0200
Subject: [PATCH 0282/1978] Add missing types
---
.../AsynchronousOperations/Model/OperationProcessor.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
index 5f644fa03ae27..ded507958d8a3 100644
--- a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
+++ b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
@@ -174,8 +174,8 @@ public function process(string $encodedMessage)
/**
* Execute topic handler
*
- * @param $callback
- * @param $entityParams
+ * @param callable $callback
+ * @param array $entityParams
* @return array
*/
private function executeHandler($callback, $entityParams)
From a5dd9f010e4ce9780d03e712633763e374964977 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Tue, 8 Oct 2019 11:51:02 +0300
Subject: [PATCH 0283/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../AdminCreateWidgetActionGroup.xml | 20 +++++++++++++++
.../Catalog/Test/Mftf/Data/WidgetsData.xml | 11 ++++++++
.../Test/Mftf/Page/StorefrontCategoryPage.xml | 2 +-
.../AdminCategorySidebarTreeSection.xml | 1 +
.../Mftf/Section/AdminNewWidgetSection.xml | 1 +
.../Mftf/Section/StorefrontWidgetsSection.xml | 3 ++-
.../CatalogPriceRuleActionGroup.xml | 25 +++++++++++++++++++
.../Data/CatalogRuleProductConditionData.xml | 14 +++++++++++
.../Page/AdminNewCatalogPriceRulePage.xml | 1 +
.../AdminNewCatalogPriceRuleSection.xml | 8 ++++--
.../AdminUrlRewriteActionGroup.xml | 25 ++++++++-----------
...CategoryUrlRewriteAndAddNoRedirectTest.xml | 4 +--
...yUrlRewriteAndAddPermanentRedirectTest.xml | 4 +--
...yUrlRewriteAndAddTemporaryRedirectTest.xml | 4 +--
.../AdminCreateWidgetActionGroup.xml | 3 ++-
15 files changed, 101 insertions(+), 25 deletions(-)
create mode 100644 app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleProductConditionData.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
index 45e2ed6205b20..36a9856f2ce74 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
@@ -19,4 +19,24 @@
+
+
+
+ EXTENDS: AdminCreateWidgetActionGroup. Creates Catalog Category Link Widget.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/WidgetsData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/WidgetsData.xml
index 18564ff101fd9..291ff115302f2 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/WidgetsData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/WidgetsData.xml
@@ -32,4 +32,15 @@
All Pages
Sidebar Additional
+
+ Catalog Category Link
+ Magento Luma
+ Test Widget
+
+ - All Store Views
+
+ 0
+ All Pages
+ Main Content Area
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontCategoryPage.xml b/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontCategoryPage.xml
index 469c153d38b88..416e0d27a1824 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontCategoryPage.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Page/StorefrontCategoryPage.xml
@@ -8,7 +8,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml
index bc552721e6ab8..cd5da444699ca 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCategorySidebarTreeSection.xml
@@ -19,5 +19,6 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminNewWidgetSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminNewWidgetSection.xml
index 5329ad48c8f43..8bc9c03642c15 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminNewWidgetSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminNewWidgetSection.xml
@@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontWidgetsSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontWidgetsSection.xml
index 87aab45bd8cb7..ca0c32f142852 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontWidgetsSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontWidgetsSection.xml
@@ -12,5 +12,6 @@
+
-
\ No newline at end of file
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml
index 39f509c68c6e4..f515899f6f120 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml
@@ -188,4 +188,29 @@
+
+
+
+ Clicks on the Conditions tab. Fills in the provided condition for Catalog Price Rule.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleProductConditionData.xml b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleProductConditionData.xml
new file mode 100644
index 0000000000000..510ea25c3f566
--- /dev/null
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleProductConditionData.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+ Magento\CatalogRule\Model\Rule\Condition\Product|category_ids
+
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Page/AdminNewCatalogPriceRulePage.xml b/app/code/Magento/CatalogRule/Test/Mftf/Page/AdminNewCatalogPriceRulePage.xml
index fded4f5e5f322..71372481490e8 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Page/AdminNewCatalogPriceRulePage.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Page/AdminNewCatalogPriceRulePage.xml
@@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
index ba0493d8e995b..d8cb8b202d6d5 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
@@ -42,8 +42,8 @@
-
-
+
+
@@ -51,6 +51,10 @@
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml
index d3e9509f1ef00..9e9660029c6b6 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml
@@ -22,20 +22,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddNoRedirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddNoRedirectTest.xml
index a7a7c0c73d826..85e9d7847d5ea 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddNoRedirectTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddNoRedirectTest.xml
@@ -29,7 +29,7 @@
-
+
@@ -49,4 +49,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddPermanentRedirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddPermanentRedirectTest.xml
index 974550bb92214..477742e7e3618 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddPermanentRedirectTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddPermanentRedirectTest.xml
@@ -29,7 +29,7 @@
-
+
@@ -49,4 +49,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddTemporaryRedirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddTemporaryRedirectTest.xml
index c64019ea38acc..2367c3d982d15 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddTemporaryRedirectTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCreateCategoryUrlRewriteAndAddTemporaryRedirectTest.xml
@@ -29,7 +29,7 @@
-
+
@@ -49,4 +49,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
index 797abdb6f56ae..3765019401365 100644
--- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
+++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
@@ -54,7 +54,7 @@
EXTENDS: AdminCreateWidgetActionGroup. Creates a Dynamic Block Rotate Widget.
-
+
@@ -71,6 +71,7 @@
+
From a916618a6cff3c7697073bbe3bb43455c8a60960 Mon Sep 17 00:00:00 2001
From: Bohdan Shevchenko <1408sheva@gmail.com>
Date: Tue, 8 Oct 2019 12:02:53 +0300
Subject: [PATCH 0284/1978] MC-21563: [Task] Deprecate Authorize.Net core
payment integration in 2.3.4
---
...minAssertRefundOrderStatusInCommentsHistoryActionGroup.xml | 4 ++--
.../Sales/Test/Mftf/Section/AdminOrderCommentsTabSection.xml | 3 ++-
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminAssertRefundOrderStatusInCommentsHistoryActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminAssertRefundOrderStatusInCommentsHistoryActionGroup.xml
index aefc8abc3f05c..e5b581e14d8b0 100644
--- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminAssertRefundOrderStatusInCommentsHistoryActionGroup.xml
+++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminAssertRefundOrderStatusInCommentsHistoryActionGroup.xml
@@ -20,7 +20,7 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderCommentsTabSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderCommentsTabSection.xml
index 19f447117959a..dce0875e29336 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderCommentsTabSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderCommentsTabSection.xml
@@ -11,5 +11,6 @@
-
\ No newline at end of file
+
From 6e5e27fbd66f06423dd53ac9c7b2d8bc645227ba Mon Sep 17 00:00:00 2001
From: Daniel Ruf
Date: Tue, 8 Oct 2019 11:20:58 +0200
Subject: [PATCH 0285/1978] Refactor array_merge in loop and
call_user_func_array
---
.../AsynchronousOperations/Model/OperationProcessor.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
index ded507958d8a3..5e7cb6b7a0916 100644
--- a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
+++ b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
@@ -133,13 +133,15 @@ public function process(string $encodedMessage)
$outputData = null;
if ($errorCode === null) {
+ $handlerMessages = [];
foreach ($handlers as $callback) {
$result = $this->executeHandler($callback, $entityParams);
$status = $result['status'];
$errorCode = $result['error_code'];
- $messages = array_merge($messages, $result['messages']);
+ $handlerMessages[] = $result['messages'];
$outputData = $result['output_data'];
}
+ $messages = array_merge($messages, ...$handlerMessages);
}
if (isset($outputData)) {
@@ -187,7 +189,7 @@ private function executeHandler($callback, $entityParams)
'output_data' => null
];
try {
- $result['output_data'] = call_user_func_array($callback, $entityParams);
+ $result['output_data'] = $callback(...$entityParams);
$result['messages'][] = sprintf('Service execution success %s::%s', get_class($callback[0]), $callback[1]);
} catch (\Zend_Db_Adapter_Exception $e) {
$this->logger->critical($e->getMessage());
From 7b05c055b110b3bb8441afbdb1e9d8bfbeed6516 Mon Sep 17 00:00:00 2001
From: Daniel Ruf
Date: Tue, 8 Oct 2019 13:14:15 +0200
Subject: [PATCH 0286/1978] Revert small change
---
.../AsynchronousOperations/Model/OperationProcessor.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
index 5e7cb6b7a0916..f7a411c745b1f 100644
--- a/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
+++ b/app/code/Magento/AsynchronousOperations/Model/OperationProcessor.php
@@ -133,15 +133,13 @@ public function process(string $encodedMessage)
$outputData = null;
if ($errorCode === null) {
- $handlerMessages = [];
foreach ($handlers as $callback) {
$result = $this->executeHandler($callback, $entityParams);
$status = $result['status'];
$errorCode = $result['error_code'];
- $handlerMessages[] = $result['messages'];
+ $messages = array_merge($messages, $result['messages']);
$outputData = $result['output_data'];
}
- $messages = array_merge($messages, ...$handlerMessages);
}
if (isset($outputData)) {
From c6736580ebad59aaf38752d52e6a56b61c68365b Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Tue, 8 Oct 2019 14:44:53 +0300
Subject: [PATCH 0287/1978] Code refactoring
---
.../User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml b/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
index bcf6d2cc0b7ea..8a37bdfb61db4 100644
--- a/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
+++ b/app/code/Magento/User/Test/Mftf/Test/AdminLockAdminUserEntityTest.xml
@@ -36,7 +36,7 @@
-
+
From a606697606eddb6ebad8095a0dc3ef5fe105c1a7 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 8 Oct 2019 14:47:14 +0300
Subject: [PATCH 0288/1978] MC-20195: Move test MC-13104 to infrastructure
---
.../Catalog/_files/product_simple_with_custom_file_option.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
index 77a9871764cee..0a375a5f25820 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
@@ -34,7 +34,7 @@
->setSku('simple_with_custom_file_option')
->setPrice(10)
->setWeight(1)
- ->setShortDescription("Short description")
+ ->setShortDescription('Short description')
->setTaxClassId(0)
->setDescription('Description with html tag ')
->setMetaTitle('meta title')
From 6cfa6f4b66a1507d1388321322c10003f3d85ea5 Mon Sep 17 00:00:00 2001
From: Andrii-Deineha
Date: Tue, 8 Oct 2019 15:35:08 +0300
Subject: [PATCH 0289/1978] MC-20441: Category rules should apply to grouped
product with invisible individual products
---
.../Mftf/ActionGroup/StorefrontProductCartActionGroup.xml | 4 ++--
...pplyToGroupedProductWithInvisibleIndividualProductTest.xml | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
index 5316558b54578..215a1cba76ed9 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
@@ -155,7 +155,7 @@
-
-
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml
index 29d2100424c5a..8900d838fb825 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCategoryRulesShouldApplyToGroupedProductWithInvisibleIndividualProductTest.xml
@@ -97,6 +97,8 @@
+
+
From 5a014040afd71105af6ba32737ceba8436d6e640 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Tue, 8 Oct 2019 15:42:11 +0300
Subject: [PATCH 0290/1978] MC-5233: DateTime product attributes support
---
.../AdminProductAttributeActionGroup.xml | 11 ++++
.../Test/Mftf/Data/ProductAttributeData.xml | 4 ++
.../AdminCreateProductAttributeSection.xml | 1 +
...dminCreateDatetimeProductAttributeTest.xml | 61 +++++++++++++++++++
4 files changed, 77 insertions(+)
create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index 3e54574c553e3..4081a362153bb 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -370,4 +370,15 @@
+
+
+
+
+ Navigate and open Advanced Attribute Properties section on product attribute page
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
index 6614fa4b5dbeb..38a273fe9fb41 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
@@ -309,6 +309,10 @@
date
No
+
+ datetime
+ No
+
date
No
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
index 462f721913b9c..1236e07a2f278 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
@@ -93,6 +93,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
new file mode 100644
index 0000000000000..5d1f0716f33f7
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
@@ -0,0 +1,61 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From a9f42f9ed40aef0aaaefd5754d575fcb80f4fc7d Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Tue, 8 Oct 2019 15:43:47 +0300
Subject: [PATCH 0291/1978] MC-5233: DateTime product attributes support
---
app/code/Magento/Ui/view/base/web/js/grid/columns/date.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
index 3179529e282c6..88959cda7499d 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/date.js
@@ -40,12 +40,14 @@ define([
* @returns {String} Formatted date.
*/
getLabel: function (value, format) {
- var date = moment.utc(this._super());
+ var date;
if (this.storeLocale !== undefined) {
moment.locale(this.storeLocale, utils.extend({}, this.calendarConfig));
}
+ date = moment.utc(this._super());
+
if (!_.isUndefined(this.timezone)) {
date = date.tz(this.timezone);
}
From db1887747b87bc699c3ceb9796aff30eed30a0a5 Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Tue, 8 Oct 2019 16:22:53 +0300
Subject: [PATCH 0292/1978] magento/magento2#24103: Refactoring.
---
.../AdminNotification/Block/Grid/Renderer/Actions.php | 10 +++++-----
.../AdminNotification/Block/Grid/Renderer/Notice.php | 4 ++--
.../AdminNotification/Block/Grid/Renderer/Severity.php | 2 +-
.../Test/Unit/Block/Grid/Renderer/SeverityTest.php | 7 +++++--
4 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
index 86cf528fd4971..0a19531a34a0c 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Actions.php
@@ -47,14 +47,14 @@ public function __construct(Context $context, Data $urlHelper, array $data = [])
*/
public function render(DataObject $row)
{
- $readDetailsHtml = $row->getData('url') ? '' .
__('Read Details') . ' ' : '';
- $markAsReadHtml = !$row->getData('is_read') ? '' . __(
'Mark as Read'
) . ' ' : '';
@@ -68,7 +68,7 @@ public function render(DataObject $row)
'*/*/remove/',
[
'_current' => true,
- 'id' => $row->getData('notification_id'),
+ 'id' => $row->getNotificationId(),
ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl
]
),
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
index 1cf56d60db9de..bd553e97aff79 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Notice.php
@@ -28,8 +28,8 @@ class Notice extends AbstractRenderer
public function render(DataObject $row)
{
return '' .
- $this->escapeHtml($row->getData('title')) .
+ $this->escapeHtml($row->getTitle()) .
' ' .
- ($row->getData('description') ? ' ' . $this->escapeHtml($row->getData('description')) : '');
+ ($row->getDescription() ? ' ' . $this->escapeHtml($row->getDescription()) : '');
}
}
diff --git a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
index d50781b1f6415..f7f8633e42e79 100644
--- a/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
+++ b/app/code/Magento/AdminNotification/Block/Grid/Renderer/Severity.php
@@ -50,7 +50,7 @@ public function render(DataObject $row)
$value = '';
$column = $this->getColumn();
- $index = $column->getData('index');
+ $index = $column->getIndex();
switch ($row->getData($index)) {
case MessageInterface::SEVERITY_CRITICAL:
$class = 'critical';
diff --git a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
index f42c740ca8fee..2a30be02f173b 100644
--- a/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
+++ b/app/code/Magento/AdminNotification/Test/Unit/Block/Grid/Renderer/SeverityTest.php
@@ -44,8 +44,11 @@ protected function setUp() : void
public function testShouldRenderSeverity() : void
{
/** @var Column | \PHPUnit_Framework_MockObject_MockObject $columnMock */
- $columnMock = $this->getMockBuilder(Column::class)->disableOriginalConstructor()->getMock();
- $columnMock->expects($this->exactly(5))->method('getData')->with($this->equalTo('index'))->willReturn('index');
+ $columnMock = $this->getMockBuilder(Column::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getIndex'])
+ ->getMock();
+ $columnMock->expects($this->exactly(5))->method('getIndex')->willReturn('index');
$this->sut->setColumn($columnMock);
$dataObject = new DataObject();
From 6d3bb60f0d8c80992eb295182f5204fa67250c8b Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Tue, 8 Oct 2019 09:53:16 -0500
Subject: [PATCH 0293/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
app/code/Magento/CatalogRule/etc/indexer.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/CatalogRule/etc/indexer.xml b/app/code/Magento/CatalogRule/etc/indexer.xml
index e648ea567631c..340918ed63531 100644
--- a/app/code/Magento/CatalogRule/etc/indexer.xml
+++ b/app/code/Magento/CatalogRule/etc/indexer.xml
@@ -17,6 +17,7 @@
+
From 8cea8ecfefb1ceebff0a69912db9a781a88feeb3 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Tue, 8 Oct 2019 18:01:04 +0300
Subject: [PATCH 0294/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../CatalogRule/Test/Mftf/Metadata/catalog-rule-meta.xml | 8 ++++++--
.../Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml | 1 +
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Metadata/catalog-rule-meta.xml b/app/code/Magento/CatalogRule/Test/Mftf/Metadata/catalog-rule-meta.xml
index 0d89c7970b852..5b6b610508fef 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Metadata/catalog-rule-meta.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Metadata/catalog-rule-meta.xml
@@ -9,8 +9,9 @@
-
+
application/x-www-form-urlencoded
string
string
@@ -24,4 +25,7 @@
string
string
+
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml
index 9e9660029c6b6..4f89c9389c32b 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/ActionGroup/AdminUrlRewriteActionGroup.xml
@@ -26,6 +26,7 @@
+
From 300d1ebe17275b966dfc716b3348e1fa93ac464f Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 8 Oct 2019 10:44:24 -0500
Subject: [PATCH 0295/1978] MC-18685: Remove custom layout updates from admin
---
app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
index 9d195e5999956..8c5042300abf4 100644
--- a/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
+++ b/app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
@@ -101,6 +101,8 @@ public function execute()
}
}
+ $data['layout_update_xml'] = $model->getLayoutUpdateXml();
+ $data['custom_layout_update_xml'] = $model->getCustomLayoutUpdateXml();
$model->setData($data);
try {
From d9bbc7f8378e2c2ba30940bd563ab439d81a39b0 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 8 Oct 2019 11:55:39 -0500
Subject: [PATCH 0296/1978] MC-20648: Implement the changes - review fixes
---
app/code/Magento/Quote/etc/db_schema.xml | 4 ++--
.../SalesRule/Model/Plugin/Discount.php | 23 ++++++++++---------
.../Magento/SalesRule/Model/RulesApplier.php | 2 ++
3 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
index 9a72658b0af6e..45c1f6ea2ac00 100644
--- a/app/code/Magento/Quote/etc/db_schema.xml
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -175,7 +175,7 @@
-
+
-
+
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
index 376ed8b8d48bf..2f07c3d779293 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -7,7 +7,8 @@
use Magento\Framework\Serialize\Serializer\Json;
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
-use Magento\Framework\App\ObjectManager;
+use Magento\Quote\Model\Quote;
+use Magento\Quote\Model\ResourceModel\Quote\Item\Collection;
/**
* Plugin for persisting discounts along with Quote Address
@@ -22,28 +23,28 @@ class Discount
/**
* @var \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory
*/
- protected $discountFactory;
+ private $discountFactory;
/**
* @param Json $json
* @param DataFactory|null $discountDataFactory
*/
- public function __construct(Json $json, DataFactory $discountDataFactory = null)
+ public function __construct(Json $json, DataFactory $discountDataFactory)
{
$this->json = $json;
- $this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
+ $this->discountFactory = $discountDataFactory;
}
/**
* Plugin for adding item discounts to extension attributes
*
- * @param \Magento\Quote\Model\Quote $subject
- * @param \Magento\Quote\Model\ResourceModel\Quote\Item\Collection $result
- * @return \Magento\Quote\Model\ResourceModel\Quote\Item\Collection
+ * @param Quote $subject
+ * @param Collection $result
+ * @return Collection
*/
public function afterGetItemsCollection(
- \Magento\Quote\Model\Quote $subject,
- \Magento\Quote\Model\ResourceModel\Quote\Item\Collection $result
+ Quote $subject,
+ Collection $result
) {
foreach ($result as $item) {
if ($item->getDiscounts() && !$item->getExtensionAttributes()->getDiscounts()) {
@@ -61,12 +62,12 @@ public function afterGetItemsCollection(
/**
* Plugin for adding address level discounts to extension attributes
*
- * @param \Magento\Quote\Model\Quote $subject
+ * @param Quote $subject
* @param array $result
* @return array
*/
public function afterGetAllAddresses(
- \Magento\Quote\Model\Quote $subject,
+ Quote $subject,
array $result
) {
foreach ($result as $address) {
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index 8a15e167f06cf..f456374b96ae6 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -170,6 +170,7 @@ protected function applyRule($item, $rule, $address, $couponCode)
*
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param \Magento\SalesRule\Model\Rule $rule
+ * @param \Magento\Quote\Model\Quote\Address $address
* @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
*/
protected function getDiscountData($item, $rule, $address)
@@ -199,6 +200,7 @@ protected function getDiscountData($item, $rule, $address)
* @param \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param \Magento\SalesRule\Model\Rule $rule
+ * @param \Magento\Quote\Model\Quote\Address $address
* @return $this
*/
private function setDiscountBreakdown($discountData, $item, $rule, $address)
From a417e11b47d3ab87c2efac3a69982987c80d6be1 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 8 Oct 2019 13:31:48 -0500
Subject: [PATCH 0297/1978] MC-18685: Remove custom layout updates from admin
---
.../Unit/Controller/Adminhtml/Page/SaveTest.php | 6 +++++-
.../AssertWidgetRecentlyComparedProducts.php | 17 ++++++++++++++++-
.../Adminhtml/Product/Set/SaveTest.php | 1 +
3 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
index b5ae9fb55c2bb..91adcdd6db4c8 100644
--- a/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Controller/Adminhtml/Page/SaveTest.php
@@ -297,7 +297,11 @@ public function testSaveActionThrowsException()
->method('set')
->with(
'cms_page',
- ['page_id' => $this->pageId]
+ [
+ 'page_id' => $this->pageId,
+ 'layout_update_xml' => null,
+ 'custom_layout_update_xml' => null
+ ]
);
$this->resultRedirect->expects($this->atLeastOnce())
diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php
index 5a67fe43a691b..b561d022192f4 100644
--- a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php
+++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php
@@ -89,8 +89,23 @@ public function processAssert(
$this->addProducts($products);
$this->removeCompareProducts();
+ $cmsIndex->open();
\PHPUnit\Framework\Assert::assertTrue(
- $this->catalogProductCompare->getWidgetView()->isWidgetVisible($widget, 'Recently Compared'),
+ $browser->waitUntil(
+ function () use ($widget, $browser) {
+ try {
+ $browser->refresh();
+ return $browser->waitUntil(
+ function () use ($widget) {
+ return $this->catalogProductCompare->getWidgetView()
+ ->isWidgetVisible($widget, 'Recently Compared');
+ }
+ );
+ } catch (\Throwable $exception) {
+ return false;
+ }
+ }
+ ),
'Widget is absent on Product Compare page.'
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
index 187fddae1ce4f..2f53b6ccd809b 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
@@ -25,6 +25,7 @@
* Test save attribute set
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @magentoAppArea adminhtml
*/
class SaveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
{
From 8760ce673982719130a20fb25fe15b2513189f48 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 8 Oct 2019 13:59:49 -0500
Subject: [PATCH 0298/1978] MC-20648: Implement the changes - Integration test
fix
---
app/code/Magento/SalesRule/Model/Quote/Discount.php | 4 ++--
app/code/Magento/SalesRule/etc/di.xml | 3 ---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 1c1a6cd69ded5..a6227bafae25d 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -235,12 +235,12 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
/**
* Aggregates discount per rule
*
- * @param \Magento\Quote\Api\Data\CartItemInterface $item
+ * @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param \Magento\Quote\Api\Data\AddressInterface $address
* @return void
*/
private function aggregateDiscountPerRule(
- \Magento\Quote\Api\Data\CartItemInterface $item,
+ \Magento\Quote\Model\Quote\Item\AbstractItem $item,
\Magento\Quote\Api\Data\AddressInterface $address
) {
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index 77794ad2cac09..1980551602493 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -49,9 +49,6 @@
-
-
-
From 66653ee685a76602d967875b4b5839412ffac805 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 8 Oct 2019 16:34:28 -0500
Subject: [PATCH 0299/1978] MC-18685: Remove custom layout updates from admin
---
.../AssertWidgetRecentlyComparedProducts.php | 34 +++++++++++--------
1 file changed, 19 insertions(+), 15 deletions(-)
diff --git a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php
index b561d022192f4..bf70f0f901352 100644
--- a/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php
+++ b/dev/tests/functional/tests/app/Magento/Widget/Test/Constraint/AssertWidgetRecentlyComparedProducts.php
@@ -90,22 +90,26 @@ public function processAssert(
$this->removeCompareProducts();
$cmsIndex->open();
- \PHPUnit\Framework\Assert::assertTrue(
- $browser->waitUntil(
- function () use ($widget, $browser) {
- try {
- $browser->refresh();
- return $browser->waitUntil(
- function () use ($widget) {
- return $this->catalogProductCompare->getWidgetView()
- ->isWidgetVisible($widget, 'Recently Compared');
- }
- );
- } catch (\Throwable $exception) {
- return false;
+ //Widgets data is cache via LocalStorage so it might take couple of refreshes before cache is invalidated.
+ $refreshCount = 3;
+ $refreshNo = 1;
+ $isVisible = false;
+ while (!$isVisible && $refreshNo <= $refreshCount) {
+ $browser->refresh();
+ try {
+ $isVisible = $browser->waitUntil(
+ function () use ($widget) {
+ return $this->catalogProductCompare->getWidgetView()
+ ->isWidgetVisible($widget, 'Recently Compared') ? true : null;
}
- }
- ),
+ );
+ } catch (\Throwable $exception) {
+ $isVisible = false;
+ }
+ $refreshNo++;
+ }
+ \PHPUnit\Framework\Assert::assertTrue(
+ $isVisible,
'Widget is absent on Product Compare page.'
);
}
From 0821bcce2265526b72d8c6eb357b65fd69ec56df Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 8 Oct 2019 22:14:23 -0500
Subject: [PATCH 0300/1978] MC-20648: Implement the changes - Unit test fix
---
.../Test/Unit/Model/Quote/DiscountTest.php | 88 +++++++++++++++++--
1 file changed, 81 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php b/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php
index 090dbd7fe5d6d..72355625318c5 100644
--- a/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php
+++ b/app/code/Magento/SalesRule/Test/Unit/Model/Quote/DiscountTest.php
@@ -47,6 +47,11 @@ class DiscountTest extends \PHPUnit\Framework\TestCase
*/
protected $addressMock;
+ /**
+ * @var \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $discountFactory;
+
protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -72,16 +77,35 @@ protected function setUp()
$priceCurrencyMock = $this->createMock(\Magento\Framework\Pricing\PriceCurrencyInterface::class);
$priceCurrencyMock->expects($this->any())
->method('round')
- ->will($this->returnCallback(
- function ($argument) {
- return round($argument, 2);
- }
- ));
+ ->will(
+ $this->returnCallback(
+ function ($argument) {
+ return round($argument, 2);
+ }
+ )
+ );
$this->addressMock = $this->createPartialMock(
\Magento\Quote\Model\Quote\Address::class,
- ['getQuote', 'getAllItems', 'getShippingAmount', '__wakeup', 'getCustomAttributesCodes']
+ [
+ 'getQuote',
+ 'getAllItems',
+ 'getShippingAmount',
+ '__wakeup',
+ 'getCustomAttributesCodes',
+ 'getExtensionAttributes'
+ ]
);
+ $addressExtension = $this->getMockBuilder(
+ \Magento\Framework\Api\ExtensionAttributesInterface::class
+ )->setMethods(['setDiscounts', 'getDiscounts'])->getMock();
+ $addressExtension->method('getDiscounts')->willReturn([]);
+ $addressExtension->expects($this->any())
+ ->method('setDiscounts')
+ ->willReturn([]);
+ $this->addressMock->expects(
+ $this->any()
+ )->method('getExtensionAttributes')->will($this->returnValue($addressExtension));
$this->addressMock->expects($this->any())
->method('getCustomAttributesCodes')
->willReturn([]);
@@ -90,6 +114,10 @@ function ($argument) {
$shipping->expects($this->any())->method('getAddress')->willReturn($this->addressMock);
$this->shippingAssignmentMock = $this->createMock(\Magento\Quote\Api\Data\ShippingAssignmentInterface::class);
$this->shippingAssignmentMock->expects($this->any())->method('getShipping')->willReturn($shipping);
+ $this->discountFactory = $this->createPartialMock(
+ \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory::class,
+ ['create']
+ );
/** @var \Magento\SalesRule\Model\Quote\Discount $discount */
$this->discount = $this->objectManager->getObject(
@@ -101,14 +129,38 @@ function ($argument) {
'priceCurrency' => $priceCurrencyMock,
]
);
+ $discountData = $this->getMockBuilder(\Magento\SalesRule\Model\Rule\Action\Discount\Data::class)
+ ->setConstructorArgs(
+ [
+ 'amount' => 0,
+ 'baseAmount' => 0,
+ 'originalAmount' => 0,
+ 'baseOriginalAmount' => 0
+ ]
+ )
+ ->getMock();
+ $this->discountFactory->expects($this->any())
+ ->method('create')
+ ->with($this->anything())
+ ->will($this->returnValue($discountData));
}
public function testCollectItemNoDiscount()
{
$itemNoDiscount = $this->createPartialMock(
\Magento\Quote\Model\Quote\Item::class,
- ['getNoDiscount', '__wakeup']
+ ['getNoDiscount', '__wakeup', 'getExtensionAttributes']
);
+ $itemExtension = $this->getMockBuilder(
+ \Magento\Framework\Api\ExtensionAttributesInterface::class
+ )->setMethods(['setDiscounts', 'getDiscounts'])->getMock();
+ $itemExtension->method('getDiscounts')->willReturn([]);
+ $itemExtension->expects($this->any())
+ ->method('setDiscounts')
+ ->willReturn([]);
+ $itemNoDiscount->expects(
+ $this->any()
+ )->method('getExtensionAttributes')->will($this->returnValue($itemExtension));
$itemNoDiscount->expects($this->once())->method('getNoDiscount')->willReturn(true);
$this->validatorMock->expects($this->once())->method('sortItemsByPriority')
->with([$itemNoDiscount], $this->addressMock)
@@ -178,10 +230,21 @@ public function testCollectItemHasChildren($childItemData, $parentData, $expecte
'getHasChildren',
'isChildrenCalculated',
'getChildren',
+ 'getExtensionAttributes',
'__wakeup',
]
)
->getMock();
+ $itemExtension = $this->getMockBuilder(
+ \Magento\Framework\Api\ExtensionAttributesInterface::class
+ )->setMethods(['setDiscounts', 'getDiscounts'])->getMock();
+ $itemExtension->method('getDiscounts')->willReturn([]);
+ $itemExtension->expects($this->any())
+ ->method('setDiscounts')
+ ->willReturn([]);
+ $itemWithChildren->expects(
+ $this->any()
+ )->method('getExtensionAttributes')->will($this->returnValue($itemExtension));
$itemWithChildren->expects($this->once())->method('getNoDiscount')->willReturn(false);
$itemWithChildren->expects($this->once())->method('getParentItem')->willReturn(false);
$itemWithChildren->expects($this->once())->method('getHasChildren')->willReturn(true);
@@ -310,10 +373,21 @@ public function testCollectItemHasNoChildren()
'getHasChildren',
'isChildrenCalculated',
'getChildren',
+ 'getExtensionAttributes',
'__wakeup',
]
)
->getMock();
+ $itemExtension = $this->getMockBuilder(
+ \Magento\Framework\Api\ExtensionAttributesInterface::class
+ )->setMethods(['setDiscounts', 'getDiscounts'])->getMock();
+ $itemExtension->method('getDiscounts')->willReturn([]);
+ $itemExtension->expects($this->any())
+ ->method('setDiscounts')
+ ->willReturn([]);
+ $itemWithChildren->expects(
+ $this->any()
+ )->method('getExtensionAttributes')->will($this->returnValue($itemExtension));
$itemWithChildren->expects($this->once())->method('getNoDiscount')->willReturn(false);
$itemWithChildren->expects($this->once())->method('getParentItem')->willReturn(false);
$itemWithChildren->expects($this->once())->method('getHasChildren')->willReturn(false);
From afd96b8e3cf7c32b948a0d1758f45c1e602977da Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Sun, 15 Sep 2019 22:25:44 +0400
Subject: [PATCH 0301/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Updated automated test script
---
...frontCartTotalValueWithFullDiscountUsingCartRuleTest.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
rename app/code/Magento/{Quote => SalesRule}/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml (96%)
diff --git a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
similarity index 96%
rename from app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
rename to app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
index c8a8f6db850f9..9aaeedcf1936f 100644
--- a/app/code/Magento/Quote/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -9,14 +9,14 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
-
+
-
+
@@ -129,6 +129,8 @@
+
+
From b2cf32463517cf08680159f0e2bd155e026b5f92 Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Mon, 16 Sep 2019 15:51:23 +0400
Subject: [PATCH 0302/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Updated automated test script
---
...ValueWithFullDiscountUsingCartRuleTest.xml | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
index 9aaeedcf1936f..3ca474fd20fbd 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -20,10 +20,8 @@
-
-
@@ -36,24 +34,20 @@
-
-
-
-
5.10
@@ -68,7 +62,6 @@
-
@@ -76,7 +69,6 @@
-
@@ -87,12 +79,10 @@
-
-
@@ -102,30 +92,27 @@
-
-
-
+
-
+
-
+
-
From 066b735a414b8b19e66b5977164b59fa11895585 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Mon, 23 Sep 2019 11:27:52 +0400
Subject: [PATCH 0303/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Updated automated test script
---
.../SalesRule/Test/Mftf/Data/SalesRuleData.xml | 2 +-
...rtTotalValueWithFullDiscountUsingCartRuleTest.xml | 12 ++++++------
app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml | 2 +-
3 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
index a5287ad6468d1..39ea70ddc3df7 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
@@ -89,7 +89,7 @@
Percent of product price discount
50
-
+
TestSalesRule
Main Website
'NOT LOGGED IN', 'General', 'Wholesale', 'Retailer'
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
index 3ca474fd20fbd..da37fa9438996 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -40,12 +40,12 @@
-
+
-
+
@@ -72,11 +72,11 @@
-
+
-
+
@@ -103,12 +103,12 @@
-
+
-
+
diff --git a/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml b/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
index f9afe84366d9e..4b8d79117eb24 100644
--- a/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
+++ b/app/code/Magento/Tax/Test/Mftf/Data/TaxCodeData.xml
@@ -26,7 +26,7 @@
*
8.375
-
+
New York
United States
*
From 2f38a6e485fa5f64eea43682d962fd1e1caf3ab5 Mon Sep 17 00:00:00 2001
From: Mikalai Shostka
Date: Tue, 8 Oct 2019 20:50:24 +0300
Subject: [PATCH 0304/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Updated automated test script
---
...refrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
index da37fa9438996..4ee0372688c09 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -118,8 +118,8 @@
-
-
+
+
From 1a780d2a113b0deba056fc983e2660aa4d21ff58 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Wed, 9 Oct 2019 14:42:37 +0300
Subject: [PATCH 0305/1978] MC-5233: DateTime product attributes support
---
.../AdminProductAttributeActionGroup.xml | 19 +++++-
.../Test/Mftf/Data/ProductAttributeData.xml | 2 +-
.../Section/AdminProductGridFilterSection.xml | 2 +
...dminCreateDatetimeProductAttributeTest.xml | 37 ++++-------
...SimpleProductWithDatetimeAttributeTest.xml | 65 +++++++++++++++++++
5 files changed, 98 insertions(+), 27 deletions(-)
create mode 100644 app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index 4081a362153bb..bc99e8d3f57e9 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -345,6 +345,23 @@
+
+
+
+ EXTENDS: createProductAttribute. Fills in the Attribute Code and Default Value (Attribute Type: Date and Time Field).
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -377,7 +394,7 @@
Navigate and open Advanced Attribute Properties section on product attribute page
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
index 38a273fe9fb41..b24a765706f2d 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductAttributeData.xml
@@ -309,7 +309,7 @@
date
No
-
+
datetime
No
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml
index 3b6f24c0f259d..4e86f14611c24 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductGridFilterSection.xml
@@ -36,5 +36,7 @@
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
index 5d1f0716f33f7..d084eb962c5da 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
@@ -14,44 +14,31 @@
-
+
-
+
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$generateDefaultValue}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 0c7844eefcf76acdcefeea778fb7b9f273df396a Mon Sep 17 00:00:00 2001
From: skylineop
Date: Wed, 9 Oct 2019 15:01:26 +0300
Subject: [PATCH 0306/1978] 15959 Extension attributes of quote on checkout
page fixes
---
app/code/Magento/Checkout/Model/DefaultConfigProvider.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Checkout/Model/DefaultConfigProvider.php b/app/code/Magento/Checkout/Model/DefaultConfigProvider.php
index 15c22b1f72573..fdf49d6765a29 100644
--- a/app/code/Magento/Checkout/Model/DefaultConfigProvider.php
+++ b/app/code/Magento/Checkout/Model/DefaultConfigProvider.php
@@ -397,7 +397,7 @@ private function getQuoteData()
if ($this->checkoutSession->getQuote()->getId()) {
$quote = $this->quoteRepository->get($this->checkoutSession->getQuote()->getId());
$quoteData = $quote->toArray();
- if (is_object($quote->getExtensionAttributes())) {
+ if (null !== $quote->getExtensionAttributes()) {
$quoteData['extension_attributes'] = $quote->getExtensionAttributes()->__toArray();
}
$quoteData['is_virtual'] = $quote->getIsVirtual();
From 602d6a102b0968a168d98c89060409461736e5a0 Mon Sep 17 00:00:00 2001
From: korostii <24894168+korostii@users.noreply.github.com>
Date: Wed, 9 Oct 2019 17:11:22 +0300
Subject: [PATCH 0307/1978] Fix #24019
Update $this->patchesRegistry in realtime in order to prevent patches from neing applied multiple times.
---
lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php b/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php
index 34b7c226185e3..b941bff94253e 100644
--- a/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php
+++ b/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php
@@ -87,6 +87,8 @@ public function fixPatch($patchName)
$adapter = $this->resourceConnection->getConnection();
$adapter->insert($this->resourceConnection->getTableName(self::TABLE_NAME), [self::CLASS_NAME => $patchName]);
+
+ $this->patchesRegistry[] = $patchName;
}
/**
From bb05da78021174bc1a120c5587fc88459685a15a Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 9 Oct 2019 09:48:38 -0500
Subject: [PATCH 0308/1978] MC-20649: Integration tests for store promotions on
quote
- added integration test coverage for discounts on quote
---
.../PlaceOrderWithStorePromotionsTest.php | 168 ++++++++++++++++++
.../Rule/Action/Discount/CartFixedTest.php | 70 +++++++-
.../_files/cart_rule_product_in_category.php | 89 ++++++++++
...cart_rule_product_in_category_rollback.php | 26 +++
.../_files/coupon_cart_fixed_discount.php | 6 +
5 files changed, 358 insertions(+), 1 deletion(-)
create mode 100644 dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php
create mode 100644 dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category_rollback.php
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
new file mode 100644
index 0000000000000..fe35e610a6656
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -0,0 +1,168 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
+ $this->getMaskedQuoteIdByReservedOrderId = $this->objectManager
+ ->get(GetMaskedQuoteIdByReservedOrderId::class);
+ $this->resource = $this->objectManager->get(ResourceConnection::class);
+ $this->connection = $this->resource->getConnection();
+ }
+
+ /**
+ * Test successful place Order with Cart promotions and verify discounts are inserted into
+ * quote_item and quote_address tables
+ *
+ * @magentoDataFixture Magento/Sales/_files/default_rollback.php
+ * @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoDataFixture Magento/SalesRule/_files/cart_rule_product_in_category.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/guest/set_guest_email.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
+ * @magentoDataFixture Magento/GraphQl/Quote/_files/set_checkmo_payment_method.php
+ *
+ * @return void
+ */
+ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules(): void
+ {
+ $serializer = $this->objectManager->get(SerializerInterface::class);
+ /** @var $productRepository */
+ $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ /** @var Product $prod1 */
+ $prod1 = $productRepository->get('simple_product');
+ $categoryId = 56;
+ $reservedOrderId = 'test_quote';
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
+ /** @var Rule $rule */
+ $rule = $this->getSalesRule('50% Off on Large Orders');
+ $salesRuleId = $rule->getRuleId();
+ /** @var categoryLinkManagementInterface $categoryLinkManagement */
+ $categoryLinkManagement = $this->objectManager->create(CategoryLinkManagementInterface::class);
+ $categoryLinkManagement->assignProductToCategories('simple_product', [$categoryId]);
+
+ $query
+ = <<graphQlRequest->send($query);
+ $responseContent = $serializer->unserialize($response->getContent());
+ $this->assertArrayNotHasKey('errors', $responseContent);
+ $this->assertArrayHasKey('data', $responseContent);
+ $orderIdFromResponse = $responseContent['data']['placeOrder']['order']['order_id'];
+ $this->assertEquals($reservedOrderId, $orderIdFromResponse);
+
+ $selectFromQuoteItem = $this->connection->select()->from($this->resource->getTableName('quote_item'));
+ $resultFromQuoteItem = $this->connection->fetchRow($selectFromQuoteItem);
+ $serializedCartDiscount = $resultFromQuoteItem['discounts'];
+
+ $this->assertTrue(array_key_exists($salesRuleId, $serializer->unserialize($serializedCartDiscount)));
+ $this->assertEquals(
+ 10,
+ json_decode($serializer->unserialize($serializedCartDiscount)[$salesRuleId]['discount'], true)['amount']
+ );
+ $this->assertEquals(
+ 'TestRule_Label',
+ $serializer->unserialize($serializedCartDiscount)[$salesRuleId]['rule']
+ );
+ $selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
+ ->where('address_type = "shipping"');
+ $resultFromQuoteAddress = $this->connection->fetchRow($selectFromQuoteAddress);
+
+ $this->assertEquals(
+ 10,
+ json_decode($serializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['discount'], true)['amount']
+ );
+ $this->assertEquals(
+ 10,
+ json_decode($serializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['discount'], true)['baseAmount']
+ );
+ $this->assertEquals(
+ 'TestRule_Label',
+ $serializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['rule']
+ );
+ }
+
+ /**
+ * Gets rule by name.
+ *
+ * @param string $name
+ * @return \Magento\SalesRule\Model\Rule
+ * @throws \Magento\Framework\Exception\InputException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
+ */
+ private function getSalesRule(string $name): \Magento\SalesRule\Model\Rule
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
+ ->create();
+
+ /** @var CartRepositoryInterface $quoteRepository */
+ $ruleRepository = $this->objectManager->get(RuleRepositoryInterface::class);
+ $items = $ruleRepository->getList($searchCriteria)->getItems();
+
+ $rule = array_pop($items);
+ /** @var \Magento\SalesRule\Model\Converter\ToModel $converter */
+ $converter = $this->objectManager->get(\Magento\SalesRule\Model\Converter\ToModel::class);
+
+ return $converter->toModel($rule);
+ }
+}
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 df26c1cc48f7b..5c693dedb7ad4 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
@@ -7,11 +7,14 @@
namespace Magento\SalesRule\Model\Rule\Action\Discount;
+use Magento\Catalog\Api\CategoryLinkManagementInterface;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductRepository;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Quote\Api\Data\CartItemExtensionInterface;
use Magento\Quote\Api\Data\CartItemInterface;
use Magento\Quote\Api\GuestCartItemRepositoryInterface;
use Magento\Quote\Api\GuestCartManagementInterface;
@@ -21,7 +24,9 @@
use Magento\Quote\Model\QuoteIdMask;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
+use Magento\SalesRule\Model\Rule;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\SalesRule\Api\RuleRepositoryInterface;
/**
* Tests for Magento\SalesRule\Model\Rule\Action\Discount\CartFixed.
@@ -131,7 +136,6 @@ public function testOrderWithFixedDiscount(): void
$quote->setCouponCode('CART_FIXED_DISCOUNT_15');
$quote->collectTotals();
$this->quoteRepository->save($quote);
-
$this->assertEquals($expectedGrandTotal, $quote->getGrandTotal());
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
@@ -144,6 +148,45 @@ public function testOrderWithFixedDiscount(): void
$this->assertEquals($expectedGrandTotal, $order->getGrandTotal());
}
+ /**
+ * Applies fixed discount amount on whole cart and created order with it
+ *
+ * @magentoDbIsolation disabled
+ * @magentoAppIsolation enabled
+ * @magentoConfigFixture default_store carriers/freeshipping/active 1
+ * @magentoDataFixture Magento/Sales/_files/quote.php
+ * @magentoDataFixture Magento/SalesRule/_files/coupon_cart_fixed_subtotal_with_discount.php
+ */
+ public function testDiscountsOnQuoteWithFixedDiscount(): void
+ {
+ $quote = $this->getQuote();
+ $quote->getShippingAddress()
+ ->setShippingMethod('freeshipping_freeshipping')
+ ->setCollectShippingRates(true);
+ $quote->setCouponCode('CART_FIXED_DISCOUNT_15');
+ $quote->collectTotals();
+ $this->quoteRepository->save($quote);
+ /** @var Rule $rule */
+ $rule = $this->getSalesRule('15$ fixed discount on whole cart');
+ $salesRuleId = $rule->getRuleId();
+ //$rule->setStoreLabel('Test Coupon_label');
+ /** @var CartItemInterface $item */
+ $item = $quote->getItems()[0];
+ $quoteItemDiscounts = $item->getExtensionAttributes()->getDiscounts();
+ $this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getAmount());
+ $this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getBaseAmount());
+ $this->assertEquals(5,$quoteItemDiscounts[$salesRuleId]['discount']->getOriginalAmount());
+ $this->assertEquals(10, $quoteItemDiscounts[$salesRuleId]['discount']->getBaseOriginalAmount());
+ $this->assertEquals('TestRule_Coupon', $quoteItemDiscounts[$salesRuleId]['rule']);
+
+ $quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
+ $this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getAmount());
+ $this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseAmount());
+ $this->assertEquals(5,$quoteAddressItemDiscount[$salesRuleId]['discount']->getOriginalAmount());
+ $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseOriginalAmount());
+ $this->assertEquals('TestRule_Coupon', $quoteAddressItemDiscount[$salesRuleId]['rule']);
+ }
+
/**
* Load cart from fixture.
*
@@ -250,4 +293,29 @@ private function getOrder(string $incrementId): OrderInterface
return array_pop($items);
}
+ /**
+ * Gets rule by name.
+ *
+ * @param string $name
+ * @return \Magento\SalesRule\Model\Rule
+ * @throws \Magento\Framework\Exception\InputException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
+ */
+ private function getSalesRule(string $name): \Magento\SalesRule\Model\Rule
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
+ ->create();
+
+ /** @var CartRepositoryInterface $quoteRepository */
+ $ruleRepository = $this->objectManager->get(RuleRepositoryInterface::class);
+ $items = $ruleRepository->getList($searchCriteria)->getItems();
+
+ $rule = array_pop($items);
+ /** @var \Magento\SalesRule\Model\Converter\ToModel $converter */
+ $converter = $this->objectManager->get(\Magento\SalesRule\Model\Converter\ToModel::class);
+
+ return $converter->toModel($rule);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php
new file mode 100644
index 0000000000000..ae3f9e16ec717
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php
@@ -0,0 +1,89 @@
+create(\Magento\SalesRule\Model\Rule::class);
+$salesRule->setData(
+ [
+ 'name' => '50% Off on Large Orders',
+ 'is_active' => 1,
+ 'customer_group_ids' => [\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID],
+ 'coupon_type' => \Magento\SalesRule\Model\Rule::COUPON_TYPE_NO_COUPON,
+ 'simple_action' => 'by_percent',
+ 'discount_amount' => 50,
+ 'discount_step' => 0,
+ 'stop_rules_processing' => 0,
+ 'website_ids' => [
+ \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+ \Magento\Store\Model\StoreManagerInterface::class
+ )->getWebsite()->getId()
+ ],
+ 'store_labels' => [
+
+ 'store_id' => 0,
+ 'store_label' => 'TestRule_Label',
+
+ ]
+ ]
+);
+
+$salesRule->getConditions()->loadArray(
+ [
+ 'type' => \Magento\SalesRule\Model\Rule\Condition\Combine::class,
+ 'attribute' => null,
+ 'operator' => null,
+ 'value' => '1',
+ 'is_value_processed' => null,
+ 'aggregator' => 'all',
+ 'conditions' =>
+ [
+ [
+ 'type' => \Magento\SalesRule\Model\Rule\Condition\Product\Found::class,
+ 'attribute' => null,
+ 'operator' => null,
+ 'value' => '1',
+ 'is_value_processed' => null,
+ 'aggregator' => 'all',
+ 'conditions' =>
+ [
+ [
+ 'type' => \Magento\SalesRule\Model\Rule\Condition\Product::class,
+ 'attribute' => 'category_ids',
+ 'operator' => '==',
+ 'value' => '56',
+ 'is_value_processed' => false,
+ ],
+ ],
+ ],
+ ],
+ ]
+);
+
+$salesRule->save();
+
+$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Category::class);
+$category->isObjectNew(true);
+$category->setId(
+ 56
+)->setCreatedAt(
+ '2019-09-23 09:50:07'
+)->setName(
+ 'Category 56'
+)->setParentId(
+ 2
+)->setPath(
+ '1/2/56'
+)->setLevel(
+ 2
+)->setAvailableSortBy(
+ ['position', 'name']
+)->setDefaultSortBy(
+ 'name'
+)->setIsActive(
+ true
+)->setPosition(
+ 1
+)->save();
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category_rollback.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category_rollback.php
new file mode 100644
index 0000000000000..1fd594503a65f
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category_rollback.php
@@ -0,0 +1,26 @@
+get(\Magento\Framework\Registry::class);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var $category \Magento\Catalog\Model\Category */
+$category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(\Magento\Catalog\Model\Category::class);
+$category->load(56);
+if ($category->getId()) {
+ $category->delete();
+}
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php
index 08e3ffe6e046c..545efd082adb2 100644
--- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php
@@ -37,6 +37,12 @@
'website_ids' => [
$objectManager->get(StoreManagerInterface::class)->getWebsite()->getId(),
],
+ 'store_labels' => [
+
+ 'store_id' => 0,
+ 'store_label' => 'TestRule_Coupon',
+
+ ]
]
);
$objectManager->get(\Magento\SalesRule\Model\ResourceModel\Rule::class)->save($salesRule);
From 5f6df930f537b856c5ec4b77e8d1aebb5752814f Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Wed, 9 Oct 2019 11:04:16 -0500
Subject: [PATCH 0309/1978] MC-20648: Implement the changes - Unit/ Integration
test fixes
---
app/code/Magento/SalesRule/Model/Plugin/Discount.php | 2 +-
app/code/Magento/SalesRule/Model/Quote/Discount.php | 5 ++++-
app/code/Magento/SalesRule/Model/RulesApplier.php | 2 +-
3 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
index 2f07c3d779293..4e2458c34e559 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -8,7 +8,7 @@
use Magento\Framework\Serialize\Serializer\Json;
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Quote\Model\Quote;
-use Magento\Quote\Model\ResourceModel\Quote\Item\Collection;
+use Magento\Framework\Data\Collection;
/**
* Plugin for persisting discounts along with Quote Address
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index a6227bafae25d..e3d1cd1454eed 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -116,6 +116,7 @@ public function collect(
foreach ($item->getChildren() as $child) {
$child->setDiscountAmount(0);
$child->setBaseDiscountAmount(0);
+ $item->getExtensionAttributes()->setDiscounts([]);
}
}
continue;
@@ -140,7 +141,9 @@ public function collect(
$this->calculator->process($item);
$this->aggregateItemDiscount($item, $total);
}
- $this->aggregateDiscountPerRule($item, $address);
+ if ($item->getExtensionAttributes()) {
+ $this->aggregateDiscountPerRule($item, $address);
+ }
}
$this->calculator->prepareDescription($address);
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index b8a219b443f02..fdd47cb821ad6 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -211,7 +211,7 @@ protected function getDiscountData($item, $rule, $address)
*/
private function setDiscountBreakdown($discountData, $item, $rule, $address)
{
- if ($discountData->getAmount() > 0) {
+ if ($discountData->getAmount() > 0 && $item->getExtensionAttributes()) {
/** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
$discount = $this->discountFactory->create();
$discount->setBaseOriginalAmount($discountData->getBaseOriginalAmount());
From 7afea4dca06b568d0455fac48b7cdc6da1978998 Mon Sep 17 00:00:00 2001
From: Ani Tumanyan
Date: Wed, 9 Oct 2019 20:06:06 +0400
Subject: [PATCH 0310/1978] MC-18822: Increase test coverage for Content
functional area
- Updated automated test script for MC-6192
---
.../AdminConfigurableProductActionGroup.xml | 27 ++++----
.../Mftf/Data/ConfigurableProductData.xml | 34 +---------
...CheckResultsOfColorAndOtherFiltersTest.xml | 66 +++++++++++++------
...CheckResultsOfColorAndOtherFiltersTest.xml | 11 ++--
4 files changed, 69 insertions(+), 69 deletions(-)
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
index 9b77dfd043f71..6fa4314611008 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminConfigurableProductActionGroup.xml
@@ -9,36 +9,39 @@
+
+ Admin edit created product as configurable. Choose created options
+
-
-
+
+
-
-
-
-
-
-
+
+
+ EXTENDS: generateConfigurationsByAttributeCode. Click to apply single price to all Skus. Enter Attribute price
+
-
+
-
+
+ EXTENDS: generateConfigurationsByAttributeCode. Click to uncheck created option. Enter Attribute price
+
-
-
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
index 1ec9909576432..4d93f334075e8 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
@@ -64,43 +64,13 @@
-
+
configurable
configurable
4
mySet
4
- Jacket
- 1.00
- 2
- configurableurlkey
- 1
- 100
- EavStockItem
- CustomAttributeCategoryIds
-
-
- configurable
- configurable
- 4
- mySet
- 4
- Cardigan
- 1.00
- 2
- configurableurlkey
- 1
- 100
- EavStockItem
- CustomAttributeCategoryIds
-
-
- configurable
- configurable
- 4
- mySet
- 4
- Pants
+ Configurable product
1.00
2
configurableurlkey
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
index 3af1ad8aa3ae8..061c1a1179b7b 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -26,6 +26,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -68,6 +81,10 @@
+
+
+
+
@@ -98,11 +115,12 @@
-
-
-
+
+
+
+
-
+
@@ -112,12 +130,16 @@
-
-
-
-
+
+
+
+
+
+
+
+
-
+
@@ -128,12 +150,16 @@
-
-
+
+
+
-
+
+
+
+
-
+
@@ -143,21 +169,21 @@
-
+
+
-
-
-
-
+
+
+
-
+
-
+
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
index 32325f948e07b..3857f83a71453 100644
--- a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
+++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -18,9 +18,9 @@
-
-
-
+
+
+
@@ -28,7 +28,8 @@
-
-
+
+
+
From a75247c8b568b319131d5fd8b9c46f0092fe0cb8 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 9 Oct 2019 11:29:12 -0500
Subject: [PATCH 0311/1978] MC-20649: Integration tests for store promotions on
quote
- static fixes
---
.../Model/Resolver/PlaceOrderWithStorePromotionsTest.php | 4 +---
.../SalesRule/Model/Rule/Action/Discount/CartFixedTest.php | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index fe35e610a6656..ced7b1d8b7484 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -23,12 +23,10 @@
use PHPUnit\Framework\TestCase;
/**
- * End to end place order test with store promotions via GraphQl
+ * Place order test with store promotions via GraphQl
*
* @magentoAppArea graphql
- *
* @magentoDbIsolation disabled
- *
*/
class PlaceOrderWithStorePromotionsTest extends TestCase
{
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 5c693dedb7ad4..7fd8f0fc872e0 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
@@ -149,7 +149,7 @@ public function testOrderWithFixedDiscount(): void
}
/**
- * Applies fixed discount amount on whole cart and created order with it
+ * Applies fixed discount amount on whole cart and quote and checks the quote model for item discounts
*
* @magentoDbIsolation disabled
* @magentoAppIsolation enabled
@@ -169,7 +169,6 @@ public function testDiscountsOnQuoteWithFixedDiscount(): void
/** @var Rule $rule */
$rule = $this->getSalesRule('15$ fixed discount on whole cart');
$salesRuleId = $rule->getRuleId();
- //$rule->setStoreLabel('Test Coupon_label');
/** @var CartItemInterface $item */
$item = $quote->getItems()[0];
$quoteItemDiscounts = $item->getExtensionAttributes()->getDiscounts();
From 54c9e0b4df6663901c2d093cac96420ba5f6d90b Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Wed, 9 Oct 2019 11:39:44 -0500
Subject: [PATCH 0312/1978] MC-20648: Implement the changes - Static test fixes
---
app/code/Magento/SalesRule/Model/Plugin/Discount.php | 2 ++
.../Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php | 1 +
app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php | 1 +
3 files changed, 4 insertions(+)
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
index 4e2458c34e559..af4d515374bea 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -41,6 +41,7 @@ public function __construct(Json $json, DataFactory $discountDataFactory)
* @param Quote $subject
* @param Collection $result
* @return Collection
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetItemsCollection(
Quote $subject,
@@ -65,6 +66,7 @@ public function afterGetItemsCollection(
* @param Quote $subject
* @param array $result
* @return array
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterGetAllAddresses(
Quote $subject,
diff --git a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
index c240cb973cec6..8059c2574010c 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
@@ -31,6 +31,7 @@ public function __construct(Json $json)
* @param \Magento\Quote\Model\ResourceModel\Quote $subject
* @param \Magento\Framework\Model\AbstractModel $object
* @return array
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(
\Magento\Quote\Model\ResourceModel\Quote $subject,
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
index e746e1ff52234..286061d2f333a 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
@@ -33,6 +33,7 @@ public function __construct(Json $json)
* @param CartInterface $quote
* @param CartItemInterface $cartItem
* @return array
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function beforeSave(CartItemPersister $subject, CartInterface $quote, CartItemInterface $cartItem)
{
From 6a9bd33ef99501fc8fabbd852dfae13f8ffcec31 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 9 Oct 2019 12:35:07 -0500
Subject: [PATCH 0313/1978] MC-20649: Integration tests for store promotions on
quote
- fix static failures
---
.../PlaceOrderWithStorePromotionsTest.php | 29 ++++++++++++-------
.../Rule/Action/Discount/CartFixedTest.php | 6 ++--
.../_files/cart_rule_product_in_category.php | 2 +-
3 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index ced7b1d8b7484..eae8aaee824b9 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -8,8 +8,6 @@
namespace Magento\QuoteGraphQl\Model\Resolver;
use Magento\Catalog\Api\CategoryLinkManagementInterface;
-use Magento\Catalog\Api\ProductRepositoryInterface;
-use Magento\Catalog\Model\Product;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\DB\Adapter\AdapterInterface;
@@ -18,6 +16,7 @@
use Magento\GraphQl\Service\GraphQlRequest;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\SalesRule\Api\RuleRepositoryInterface;
+use Magento\SalesRule\Model\Converter\ToModel;
use Magento\SalesRule\Model\Rule;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
@@ -75,10 +74,6 @@ protected function setUp()
public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules(): void
{
$serializer = $this->objectManager->get(SerializerInterface::class);
- /** @var $productRepository */
- $productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
- /** @var Product $prod1 */
- $prod1 = $productRepository->get('simple_product');
$categoryId = 56;
$reservedOrderId = 'test_quote';
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
@@ -126,11 +121,25 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$this->assertEquals(
10,
- json_decode($serializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['discount'], true)['amount']
+ json_decode(
+ $serializer->unserialize(
+ $resultFromQuoteAddress['discounts']
+ )
+ [$salesRuleId]['discount'],
+ true
+ )
+ ['amount']
);
$this->assertEquals(
10,
- json_decode($serializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['discount'], true)['baseAmount']
+ json_decode(
+ $serializer->unserialize(
+ $resultFromQuoteAddress['discounts']
+ )
+ [$salesRuleId]['discount'],
+ true
+ )
+ ['baseAmount']
);
$this->assertEquals(
'TestRule_Label',
@@ -146,7 +155,7 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
* @throws \Magento\Framework\Exception\InputException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
- private function getSalesRule(string $name): \Magento\SalesRule\Model\Rule
+ private function getSalesRule(string $name): Rule
{
/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
$searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
@@ -159,7 +168,7 @@ private function getSalesRule(string $name): \Magento\SalesRule\Model\Rule
$rule = array_pop($items);
/** @var \Magento\SalesRule\Model\Converter\ToModel $converter */
- $converter = $this->objectManager->get(\Magento\SalesRule\Model\Converter\ToModel::class);
+ $converter = $this->objectManager->get(ToModel::class);
return $converter->toModel($rule);
}
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 7fd8f0fc872e0..9204bb840265c 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
@@ -7,14 +7,12 @@
namespace Magento\SalesRule\Model\Rule\Action\Discount;
-use Magento\Catalog\Api\CategoryLinkManagementInterface;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductRepository;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Quote\Api\CartRepositoryInterface;
-use Magento\Quote\Api\Data\CartItemExtensionInterface;
use Magento\Quote\Api\Data\CartItemInterface;
use Magento\Quote\Api\GuestCartItemRepositoryInterface;
use Magento\Quote\Api\GuestCartManagementInterface;
@@ -174,14 +172,14 @@ public function testDiscountsOnQuoteWithFixedDiscount(): void
$quoteItemDiscounts = $item->getExtensionAttributes()->getDiscounts();
$this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getAmount());
$this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getBaseAmount());
- $this->assertEquals(5,$quoteItemDiscounts[$salesRuleId]['discount']->getOriginalAmount());
+ $this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getOriginalAmount());
$this->assertEquals(10, $quoteItemDiscounts[$salesRuleId]['discount']->getBaseOriginalAmount());
$this->assertEquals('TestRule_Coupon', $quoteItemDiscounts[$salesRuleId]['rule']);
$quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
$this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getAmount());
$this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseAmount());
- $this->assertEquals(5,$quoteAddressItemDiscount[$salesRuleId]['discount']->getOriginalAmount());
+ $this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getOriginalAmount());
$this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseOriginalAmount());
$this->assertEquals('TestRule_Coupon', $quoteAddressItemDiscount[$salesRuleId]['rule']);
}
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php
index ae3f9e16ec717..1c6b6a954cc2e 100644
--- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/cart_rule_product_in_category.php
@@ -86,4 +86,4 @@
true
)->setPosition(
1
-)->save();
\ No newline at end of file
+)->save();
From 5632f4591659a8ae684fe818002977ab7b417c62 Mon Sep 17 00:00:00 2001
From: korostii <24894168+korostii@users.noreply.github.com>
Date: Wed, 9 Oct 2019 20:41:36 +0300
Subject: [PATCH 0314/1978] Fix PHP CS errors
---
lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php b/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php
index b941bff94253e..5579af1694d4a 100644
--- a/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php
+++ b/lib/internal/Magento/Framework/Setup/Patch/PatchHistory.php
@@ -56,9 +56,9 @@ public function __construct(ResourceConnection $resourceConnection)
* Read and cache data patches from db
*
* All patches are store in patch_list table
- * @see self::TABLE_NAME
*
- * @return array
+ * @see self::TABLE_NAME
+ * @return string[]
*/
private function getAppliedPatches()
{
@@ -94,7 +94,7 @@ public function fixPatch($patchName)
/**
* Revert patch from history
*
- * @param $patchName
+ * @param string $patchName
* @return void
*/
public function revertPatchFromHistory($patchName)
From 7e715e48a73c6a6bbd7063b6c3023e959802bb9f Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 9 Oct 2019 13:23:32 -0500
Subject: [PATCH 0315/1978] MC-20649: Integration tests for store promotions on
quote
- jenkin failure fix
---
.../PlaceOrderWithStorePromotionsTest.php | 21 ++++++++++++-------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index eae8aaee824b9..7ce0e5600a157 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -44,6 +44,9 @@ class PlaceOrderWithStorePromotionsTest extends TestCase
/** @var AdapterInterface */
private $connection;
+ /** @var SerializerInterface */
+ private $jsonSerializer;
+
protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
@@ -52,6 +55,7 @@ protected function setUp()
->get(GetMaskedQuoteIdByReservedOrderId::class);
$this->resource = $this->objectManager->get(ResourceConnection::class);
$this->connection = $this->resource->getConnection();
+ $this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
}
/**
@@ -73,7 +77,6 @@ protected function setUp()
*/
public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules(): void
{
- $serializer = $this->objectManager->get(SerializerInterface::class);
$categoryId = 56;
$reservedOrderId = 'test_quote';
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
@@ -96,7 +99,7 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
QUERY;
$response = $this->graphQlRequest->send($query);
- $responseContent = $serializer->unserialize($response->getContent());
+ $responseContent = $this->jsonSerializer->unserialize($response->getContent());
$this->assertArrayNotHasKey('errors', $responseContent);
$this->assertArrayHasKey('data', $responseContent);
$orderIdFromResponse = $responseContent['data']['placeOrder']['order']['order_id'];
@@ -106,14 +109,16 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$resultFromQuoteItem = $this->connection->fetchRow($selectFromQuoteItem);
$serializedCartDiscount = $resultFromQuoteItem['discounts'];
- $this->assertTrue(array_key_exists($salesRuleId, $serializer->unserialize($serializedCartDiscount)));
+ $this->assertTrue(array_key_exists($salesRuleId, $this->jsonSerializer->unserialize($serializedCartDiscount)));
$this->assertEquals(
10,
- json_decode($serializer->unserialize($serializedCartDiscount)[$salesRuleId]['discount'], true)['amount']
+ json_decode($this->jsonSerializer->unserialize(
+ $serializedCartDiscount
+ )[$salesRuleId]['discount'], true)['amount']
);
$this->assertEquals(
'TestRule_Label',
- $serializer->unserialize($serializedCartDiscount)[$salesRuleId]['rule']
+ $this->jsonSerializer->unserialize($serializedCartDiscount)[$salesRuleId]['rule']
);
$selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
->where('address_type = "shipping"');
@@ -122,7 +127,7 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$this->assertEquals(
10,
json_decode(
- $serializer->unserialize(
+ $this->jsonSerializer->unserialize(
$resultFromQuoteAddress['discounts']
)
[$salesRuleId]['discount'],
@@ -133,7 +138,7 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$this->assertEquals(
10,
json_decode(
- $serializer->unserialize(
+ $this->jsonSerializer->unserialize(
$resultFromQuoteAddress['discounts']
)
[$salesRuleId]['discount'],
@@ -143,7 +148,7 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
);
$this->assertEquals(
'TestRule_Label',
- $serializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['rule']
+ $this->jsonSerializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['rule']
);
}
From 678279044bd59794606da614b5d85d2eb92b86c5 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 9 Oct 2019 14:32:44 -0500
Subject: [PATCH 0316/1978] MC-18685: Remove custom layout updates from admin
---
.../tests/app/Magento/Install/Test/TestCase/InstallTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml
index c0a4ef090258f..ed0c4119dd825 100644
--- a/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Install/Test/TestCase/InstallTest.xml
@@ -30,7 +30,7 @@
default
pref_
- Chinese (Simplified Han, China)
+ Chinese
From f3d09288c1305c7d2b3f8128f2b68cfdb39b626c Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 9 Oct 2019 17:12:57 -0500
Subject: [PATCH 0317/1978] MC-20649: Integration tests for store promotions on
quote
- fixed fixture to avoid hard coded values
---
.../integration/testsuite/Magento/Sales/_files/quotes.php | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
index b916fc0240417..98a9f781a8973 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
@@ -18,13 +18,16 @@
$quoteFactory = $objectManager->get(QuoteFactory::class);
/** @var QuoteRepository $quoteRepository */
$quoteRepository = $objectManager->get(QuoteRepository::class);
-
+/** @var \Magento\Store\Model\Store $secondStore */
+$secondStore = $objectManager->get(\Magento\Store\Api\StoreRepositoryInterface::class)->get('fixture_second_store');
+$secondStoreId = $secondStore->getId();
$quotes = [
'quote for first store' => [
'store' => 1,
],
'quote for second store' => [
- 'store' => 2,
+ // 'store' => 2,
+ 'store' => $secondStoreId,
],
];
From 1131b3a6b585103f61a641dae1ef063cebb5cc84 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 9 Oct 2019 16:26:01 -0500
Subject: [PATCH 0318/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/ProductPriceIndexFilter.php | 79 ++++++++----
.../Indexer/ProductPriceIndexFilterTest.php | 121 ++++++++++++++++++
app/code/Magento/CatalogRule/etc/indexer.xml | 1 -
3 files changed, 172 insertions(+), 29 deletions(-)
create mode 100644 app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php
diff --git a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
index 32fb85f270b9c..35231b8460b19 100644
--- a/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
+++ b/app/code/Magento/CatalogInventory/Model/Indexer/ProductPriceIndexFilter.php
@@ -9,11 +9,11 @@
use Magento\CatalogInventory\Api\StockConfigurationInterface;
use Magento\CatalogInventory\Model\ResourceModel\Stock\Item;
-use Magento\CatalogInventory\Model\Stock;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\PriceModifierInterface;
use Magento\Catalog\Model\ResourceModel\Product\Indexer\Price\IndexTableStructure;
use Magento\Framework\App\ResourceConnection;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\DB\Query\Generator;
/**
* Class for filter product price index.
@@ -40,22 +40,38 @@ class ProductPriceIndexFilter implements PriceModifierInterface
*/
private $connectionName;
+ /**
+ * @var Generator
+ */
+ private $batchQueryGenerator;
+
+ /**
+ * @var int
+ */
+ private $batchSize;
+
/**
* @param StockConfigurationInterface $stockConfiguration
* @param Item $stockItem
* @param ResourceConnection $resourceConnection
* @param string $connectionName
+ * @param Generator $batchQueryGenerator
+ * @param int $batchSize
*/
public function __construct(
StockConfigurationInterface $stockConfiguration,
Item $stockItem,
ResourceConnection $resourceConnection = null,
- $connectionName = 'indexer'
+ $connectionName = 'indexer',
+ Generator $batchQueryGenerator = null,
+ $batchSize = 100
) {
$this->stockConfiguration = $stockConfiguration;
$this->stockItem = $stockItem;
$this->resourceConnection = $resourceConnection ?: ObjectManager::getInstance()->get(ResourceConnection::class);
$this->connectionName = $connectionName;
+ $this->batchQueryGenerator = $batchQueryGenerator ?: ObjectManager::getInstance()->get(Generator::class);
+ $this->batchSize = $batchSize;
}
/**
@@ -64,7 +80,9 @@ public function __construct(
* @param IndexTableStructure $priceTable
* @param array $entityIds
* @return void
+ *
* @throws \Magento\Framework\Exception\LocalizedException
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function modifyPrice(IndexTableStructure $priceTable, array $entityIds = []) : void
{
@@ -73,37 +91,42 @@ public function modifyPrice(IndexTableStructure $priceTable, array $entityIds =
}
$connection = $this->resourceConnection->getConnection($this->connectionName);
- $stockSelect = $connection->select();
- $stockSelect->from(
- $this->stockItem->getMainTable(),
- [
- 'product_id',
- ]
+ $select = $connection->select();
+
+ $select->from(
+ ['stock_item' => $this->stockItem->getMainTable()],
+ ['stock_item.product_id', 'MAX(stock_item.is_in_stock) as max_is_in_stock']
);
- if (!empty($entityIds)) {
- $stockSelect->where('product_id IN (?)', $entityIds);
- }
- $stockSelect->group('product_id');
+
if ($this->stockConfiguration->getManageStock()) {
- $stockStatus = $connection->getCheckSql(
- 'use_config_manage_stock = 0 AND manage_stock = 0',
- Stock::STOCK_IN_STOCK,
- 'is_in_stock'
- );
+ $select->where('stock_item.use_config_manage_stock = 1 OR stock_item.manage_stock = 1');
} else {
- $stockStatus = $connection->getCheckSql(
- 'use_config_manage_stock = 0 AND manage_stock = 1',
- 'is_in_stock',
- Stock::STOCK_IN_STOCK
- );
+ $select->where('stock_item.use_config_manage_stock = 0 AND stock_item.manage_stock = 1');
+ }
+
+ if (!empty($entityIds)) {
+ $select->where('stock_item.product_id in (?)', $entityIds);
}
- $stockStatus = new \Zend_Db_Expr('MAX(' . $stockStatus . ')');
- $stockSelect->having($stockStatus . ' = ' . Stock::STOCK_OUT_OF_STOCK);
- $productIds = $connection->fetchCol($stockSelect);
- if (!empty($productIds)) {
- $where = [$priceTable->getEntityField() .' IN (?)' => $productIds];
- $connection->delete($priceTable->getTableName(), $where);
+ $select->group('stock_item.product_id');
+ $select->having('max_is_in_stock = 0');
+
+ $batchSelectIterator = $this->batchQueryGenerator->generate(
+ 'product_id',
+ $select,
+ $this->batchSize,
+ \Magento\Framework\DB\Query\BatchIteratorInterface::UNIQUE_FIELD_ITERATOR
+ );
+
+ foreach ($batchSelectIterator as $select) {
+ $productIds = null;
+ foreach ($connection->query($select)->fetchAll() as $row) {
+ $productIds[] = $row['product_id'];
+ }
+ if ($productIds !== null) {
+ $where = [$priceTable->getEntityField() .' IN (?)' => $productIds];
+ $connection->delete($priceTable->getTableName(), $where);
+ }
}
}
}
diff --git a/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php
new file mode 100644
index 0000000000000..46f4e0f26f378
--- /dev/null
+++ b/app/code/Magento/CatalogInventory/Test/Unit/Model/Indexer/ProductPriceIndexFilterTest.php
@@ -0,0 +1,121 @@
+stockConfiguration = $this->createMock(StockConfigurationInterface::class);
+ $this->item = $this->createMock(Item::class);
+ $this->resourceCnnection = $this->createMock(ResourceConnection::class);
+ $this->generator = $this->createMock(Generator::class);
+
+ $this->productPriceIndexFilter = new ProductPriceIndexFilter(
+ $this->stockConfiguration,
+ $this->item,
+ $this->resourceCnnection,
+ 'indexer',
+ $this->generator,
+ 100
+ );
+ }
+
+ /**
+ * Test to ensure that Modify Price method uses entityIds,
+ */
+ public function testModifyPrice()
+ {
+ $entityIds = [1, 2, 3];
+ $indexTableStructure = $this->createMock(IndexTableStructure::class);
+ $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
+ $this->resourceCnnection->expects($this->once())->method('getConnection')->willReturn($connectionMock);
+ $selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
+ $connectionMock->expects($this->once())->method('select')->willReturn($selectMock);
+ $selectMock->expects($this->at(2))
+ ->method('where')
+ ->with('stock_item.product_id in (?)', $entityIds)
+ ->willReturn($selectMock);
+ $this->generator->expects($this->once())
+ ->method('generate')
+ ->will(
+ $this->returnCallback(
+ $this->getBatchIteratorCallback($selectMock, 5)
+ )
+ );
+
+ $fetchStmtMock = $this->createPartialMock(\Zend_Db_Statement_Pdo::class, ['fetchAll']);
+ $fetchStmtMock->expects($this->any())
+ ->method('fetchAll')
+ ->will($this->returnValue([['product_id' => 1]]));
+ $connectionMock->expects($this->any())->method('query')->will($this->returnValue($fetchStmtMock));
+ $this->productPriceIndexFilter->modifyPrice($indexTableStructure, $entityIds);
+ }
+
+ /**
+ * Returns batches.
+ *
+ * @param MockObject $selectMock
+ * @param int $batchCount
+ * @return \Closure
+ */
+ private function getBatchIteratorCallback(MockObject $selectMock, int $batchCount): \Closure
+ {
+ $iteratorCallback = function () use ($batchCount, $selectMock): array {
+ $result = [];
+ $count = $batchCount;
+ while ($count) {
+ $count--;
+ $result[$count] = $selectMock;
+ }
+
+ return $result;
+ };
+
+ return $iteratorCallback;
+ }
+}
diff --git a/app/code/Magento/CatalogRule/etc/indexer.xml b/app/code/Magento/CatalogRule/etc/indexer.xml
index 340918ed63531..e648ea567631c 100644
--- a/app/code/Magento/CatalogRule/etc/indexer.xml
+++ b/app/code/Magento/CatalogRule/etc/indexer.xml
@@ -17,7 +17,6 @@
-
From 8a86d858307928554384b322c4e9b743ae3cd25f Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Wed, 9 Oct 2019 17:36:04 -0500
Subject: [PATCH 0319/1978] MC-20648: Implement the changes - Changing
extension attribute type to mixed[]
---
app/code/Magento/SalesRule/etc/extension_attributes.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/SalesRule/etc/extension_attributes.xml b/app/code/Magento/SalesRule/etc/extension_attributes.xml
index b73afcd09f060..c6df13e50fd15 100644
--- a/app/code/Magento/SalesRule/etc/extension_attributes.xml
+++ b/app/code/Magento/SalesRule/etc/extension_attributes.xml
@@ -7,9 +7,9 @@
-->
-
+
-
+
\ No newline at end of file
From 57f76eb9c2bc34ea6e871de61f06c85a69ec9f17 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 9 Oct 2019 23:12:36 -0500
Subject: [PATCH 0320/1978] MC-20649: Integration tests for store promotions on
quote
- jenkin failure fix
---
.../PlaceOrderWithStorePromotionsTest.php | 21 +++++++++++--------
1 file changed, 12 insertions(+), 9 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index 7ce0e5600a157..e9c92861c05b1 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -123,17 +123,20 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
->where('address_type = "shipping"');
$resultFromQuoteAddress = $this->connection->fetchRow($selectFromQuoteAddress);
-
- $this->assertEquals(
- 10,
- json_decode(
+ $serializedDiscountQuoteAddress = $resultFromQuoteAddress['discounts'];
+ $this->assertTrue(
+ array_key_exists(
+ $salesRuleId,
$this->jsonSerializer->unserialize(
- $resultFromQuoteAddress['discounts']
+ $serializedDiscountQuoteAddress
)
- [$salesRuleId]['discount'],
- true
)
- ['amount']
+ );
+ $this->assertEquals(
+ 10,
+ json_decode($this->jsonSerializer->unserialize(
+ $serializedDiscountQuoteAddress
+ )[$salesRuleId]['discount'], true)['amount']
);
$this->assertEquals(
10,
@@ -148,7 +151,7 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
);
$this->assertEquals(
'TestRule_Label',
- $this->jsonSerializer->unserialize($resultFromQuoteAddress['discounts'])[$salesRuleId]['rule']
+ $this->jsonSerializer->unserialize($serializedDiscountQuoteAddress)[$salesRuleId]['rule']
);
}
From 7379bc9a62df7af85003a26bf94f72bee16989cc Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Thu, 10 Oct 2019 11:16:11 +0300
Subject: [PATCH 0321/1978] MC-5233: DateTime product attributes support
---
.../AdminProductAttributeActionGroup.xml | 10 +++++-----
.../Section/AdminCreateProductAttributeSection.xml | 2 +-
.../AdminCreateDatetimeProductAttributeTest.xml | 5 +++--
...reateSimpleProductWithDatetimeAttributeTest.xml | 14 +++++++-------
4 files changed, 16 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index bc99e8d3f57e9..6deec50a831b4 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -355,11 +355,11 @@
-
+
-
-
-
+
+
+
@@ -395,7 +395,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
index 1236e07a2f278..e6b86c7a9172b 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
@@ -93,7 +93,7 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
index d084eb962c5da..e46114ff752f6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateDatetimeProductAttributeTest.xml
@@ -23,6 +23,7 @@
+
@@ -40,9 +41,9 @@
-
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
index a21c5a84447dc..019baa4ac153d 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
@@ -22,10 +22,11 @@
-
+
+
@@ -53,13 +54,12 @@
-
-
+
+
-
-
-
-
+
+
+
From 9110f821c258e91431596d835c0b811083d327f3 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Thu, 10 Oct 2019 12:44:11 +0300
Subject: [PATCH 0322/1978] MC-5233: DateTime product attributes support
---
.../Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml | 1 +
.../Test/Mftf/Section/AdminCreateProductAttributeSection.xml | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
index 6deec50a831b4..389330fd7deb5 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeActionGroup.xml
@@ -17,6 +17,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
index e6b86c7a9172b..31c4f5198a8b0 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
@@ -93,7 +93,7 @@
-
+
From c5a1666a93e10806f1861a7df958a6f4de5c4a99 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Thu, 10 Oct 2019 12:49:48 +0300
Subject: [PATCH 0323/1978] MC-5233: DateTime product attributes support
---
.../Test/Unit/Ui/Component/ColumnFactoryTest.php | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
index f002173de7996..4e6730b553307 100644
--- a/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Ui/Component/ColumnFactoryTest.php
@@ -56,7 +56,7 @@ class ColumnFactoryTest extends TestCase
/**
* @var TimezoneInterface|MockObject
*/
- private $timeZone;
+ private $timezone;
/**
* @inheritdoc
@@ -80,13 +80,13 @@ protected function setUp(): void
$this->column = $this->getMockForAbstractClass(ColumnInterface::class);
$this->uiComponentFactory->method('create')
->willReturn($this->column);
- $this->timeZone = $this->createMock(TimezoneInterface::class);
+ $this->timezone = $this->createMock(TimezoneInterface::class);
$this->columnFactory = $this->objectManager->getObject(
ColumnFactory::class,
[
'componentFactory' => $this->uiComponentFactory,
- 'timezone' => $this->timeZone,
+ 'timezone' => $this->timezone,
]
);
}
@@ -203,7 +203,7 @@ public function testCreateDateColumn(
'visible' => true,
'filter' => 'dateRange',
'component' => 'Magento_Ui/js/grid/columns/date',
- 'timeZone' => $expectedTimezone,
+ 'timezone' => $expectedTimezone,
'dateFormat' => $expectedDateFormat,
'options' => [
'showsTime' => $showsTime
@@ -224,15 +224,15 @@ public function testCreateDateColumn(
$this->attribute->method('getFrontendInput')
->willReturn($frontendInput);
- $this->timeZone->method('getDateFormat')
+ $this->timezone->method('getDateFormat')
->with(\IntlDateFormatter::MEDIUM)
->willReturn($dateFormat);
- $this->timeZone->method('getDateTimeFormat')
+ $this->timezone->method('getDateTimeFormat')
->with(\IntlDateFormatter::MEDIUM)
->willReturn($dateTimeFormat);
- $this->timeZone->method('getDefaultTimezone')
+ $this->timezone->method('getDefaultTimezone')
->willReturn($defaultTimezone);
- $this->timeZone->method('getConfigTimezone')
+ $this->timezone->method('getConfigTimezone')
->willReturn($configTimezone);
$this->uiComponentFactory->expects($this->once())
From 956075d171ab721ed50c674e46a9cada205ec16a Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Thu, 10 Oct 2019 13:18:12 +0300
Subject: [PATCH 0324/1978] MC-20425: [Integration Test] Check behavior when
attribute set was changed to a new set with deleted attribute from the
previous set
---
.../Catalog/Controller/Product/ViewTest.php | 231 +++++++++++++++++-
...default_without_country_of_manufacture.php | 54 ++++
...ithout_country_of_manufacture_rollback.php | 58 +++++
...uct_simple_with_country_of_manufacture.php | 53 ++++
...e_with_country_of_manufacture_rollback.php | 32 +++
5 files changed, 425 insertions(+), 3 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture_rollback.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture_rollback.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
index 92a782deee65a..84fbe15047ba2 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
@@ -3,18 +3,71 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Controller\Product;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Eav\Model\AttributeSetSearchResults;
+use Magento\Eav\Model\Entity\Attribute\Set;
+use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SortOrderBuilder;
+use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\Data\Collection;
+use Magento\Catalog\Api\AttributeSetRepositoryInterface;
+use Magento\Eav\Model\Entity\Type;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+
/**
- * @magentoDataFixture Magento/Catalog/controllers/_files/products.php
- * @magentoDbIsolation disabled
+ * Integration test for product view front action.
+ *
+ * @magentoAppArea frontend
*/
class ViewTest extends \Magento\TestFramework\TestCase\AbstractController
{
/**
+ * @var string
+ */
+ private $systemLogFileName = 'system.log';
+
+ /**
+ * @var ProductRepositoryInterface $productRepository
+ */
+ private $productRepository;
+
+ /**
+ * @var AttributeSetRepositoryInterface $attributeSetRepository
+ */
+ private $attributeSetRepository;
+
+ /**
+ * @var Type $productEntityType
+ */
+ private $productEntityType;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
+ $this->attributeSetRepository = $this->_objectManager->create(AttributeSetRepositoryInterface::class);
+ $this->productEntityType = $this->_objectManager->create(Type::class)
+ ->loadByCode(Product::ENTITY);
+ }
+
+ /**
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/Catalog/controllers/_files/products.php
* @magentoConfigFixture current_store catalog/seo/product_canonical_tag 1
+ * @return void
*/
- public function testViewActionWithCanonicalTag()
+ public function testViewActionWithCanonicalTag(): void
{
$this->markTestSkipped(
'MAGETWO-40724: Canonical url from tests sometimes does not equal canonical url from action'
@@ -26,4 +79,176 @@ public function testViewActionWithCanonicalTag()
$this->getResponse()->getBody()
);
}
+
+ /**
+ * View product with custom attribute when attribute removed from it.
+ *
+ * It tests that after changing product attribute set from Default to Custom
+ * there are no waring messages in log in case Custom not contains attribute from Default.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
+ * @magentoDbIsolation disabled
+ * @return void
+ */
+ public function testViewActionCustomAttributeSetWithoutCountryOfManufacture(): void
+ {
+ $product = $this->getProductBySku('simple_with_com');
+ $attributeSetCustom = $this->getProductAttributeSetByName('custom_attribute_set_wout_com');
+
+ $product->setAttributeSetId($attributeSetCustom->getAttributeSetId());
+ $this->productRepository->save($product);
+
+ $this->dispatch(sprintf('catalog/product/view/id/%s/', $product->getId()));
+ $message = 'Attempt to load value of nonexistent EAV attribute';
+ $this->assertFalse(
+ $this->checkSystemLogForMessage($message),
+ sprintf("Warning message found in %s: %s", $this->systemLogFileName, $message)
+ );
+ }
+
+ /**
+ * Check system log file for error message.
+ *
+ * @param string $message
+ * @return bool
+ */
+ private function checkSystemLogForMessage(string $message): bool
+ {
+ $content = $this->getSystemLogContent();
+ $pos = strpos($content, $message);
+
+ return $pos !== false;
+ }
+
+ /**
+ * Get product instance by sku.
+ *
+ * @param string $sku
+ * @return Product
+ */
+ private function getProductBySku(string $sku): Product
+ {
+ $product = $this->productRepository->get($sku);
+
+ return $product;
+ }
+
+ /**
+ * Get product attribute set by name.
+ *
+ * @param string $attributeSetName
+ * @return Set|null
+ */
+ private function getProductAttributeSetByName(string $attributeSetName): ?Set
+ {
+ /** @var SortOrderBuilder $sortOrderBuilder */
+ $sortOrderBuilder = $this->_objectManager->create(SortOrderBuilder::class);
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
+ $searchCriteriaBuilder->addFilter('entity_type_id', $this->productEntityType->getId());
+ $attributeSetIdSortOrder = $sortOrderBuilder
+ ->setField('attribute_set_id')
+ ->setDirection(Collection::SORT_ORDER_DESC)
+ ->create();
+ $searchCriteriaBuilder->addSortOrder($attributeSetIdSortOrder);
+ $searchCriteriaBuilder->setPageSize(1);
+ $searchCriteriaBuilder->setCurrentPage(1);
+
+ /** @var AttributeSetSearchResults $searchResult */
+ $searchResult = $this->attributeSetRepository->getList($searchCriteriaBuilder->create());
+ $items = $searchResult->getItems();
+
+ if (count($items) > 0) {
+ return reset($items);
+ }
+
+ return null;
+ }
+
+ /**
+ * Get system log content.
+ *
+ * @return string
+ */
+ private function getSystemLogContent(): string
+ {
+ $logDir = $this->getLogDirectoryWrite();
+ $logFullFileName = $logDir->getAbsolutePath($this->systemLogFileName);
+ $content = $this->tail($logFullFileName, 10);
+
+ return $content;
+ }
+
+ /**
+ * Get file tail.
+ *
+ * @param string $filename
+ * @param int $lines
+ * @param int $buffer
+ * @return false|string
+ */
+ private function tail(string $filename, int $lines = 10, int $buffer = 4096)
+ {
+ // Open the file
+ $f = fopen($filename, "rb");
+
+ // Jump to last character
+ fseek($f, -1, SEEK_END);
+
+ // Read it and adjust line number if necessary
+ // (Otherwise the result would be wrong if file doesn't end with a blank line)
+ if (fread($f, 1) != "\n") {
+ $lines--;
+ }
+
+ // Start reading
+ $output = '';
+ $chunk = '';
+
+ // While we would like more
+ while (ftell($f) > 0 && $lines >= 0) {
+ // Figure out how far back we should jump
+ $seek = min(ftell($f), $buffer);
+
+ // Do the jump (backwards, relative to where we are)
+ fseek($f, -$seek, SEEK_CUR);
+
+ // Read a chunk and prepend it to our output
+ $output = ($chunk = fread($f, $seek)) . $output;
+
+ // Jump back to where we started reading
+ fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
+
+ // Decrease our line counter
+ $lines -= substr_count($chunk, "\n");
+ }
+
+ // While we have too many lines
+ // (Because of buffer size we might have read too many)
+ while ($lines++ < 0) {
+ // Find first newline and remove all text before that
+ $output = substr($output, strpos($output, "\n") + 1);
+ }
+
+ // Close file and return
+ fclose($f);
+
+ return $output;
+ }
+
+ /**
+ * Get current LOG directory write.
+ *
+ * @return WriteInterface
+ */
+ private function getLogDirectoryWrite()
+ {
+ /** @var Filesystem $filesystem */
+ $filesystem = $this->_objectManager->create(Filesystem::class);
+ $logDirectory = $filesystem->getDirectoryWrite(DirectoryList::LOG);
+
+ return $logDirectory;
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
new file mode 100644
index 0000000000000..0d700215af037
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
@@ -0,0 +1,54 @@
+get(ProductAttributeRepositoryInterface::class);
+/** @var ProductAttributeInterface $attributeCountryOfManufacture */
+$attributeCountryOfManufacture = $attributeRepository->get('country_of_manufacture');
+
+/** @var Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
+$attributeSet = $objectManager->create(Set::class);
+$entityType = $objectManager->create(Type::class)
+ ->loadByCode(Magento\Catalog\Model\Product::ENTITY);
+$defaultSetId = $objectManager->create(Product::class)
+ ->getDefaultAttributeSetid();
+$data = [
+ 'attribute_set_name' => 'custom_attribute_set_wout_com',
+ 'entity_type_id' => $entityType->getId(),
+ 'sort_order' => 300,
+];
+
+$attributeSet->setData($data);
+$attributeSet->validate();
+$attributeSet->save();
+$attributeSet->initFromSkeleton($defaultSetId);
+/** @var Group $group */
+foreach ($attributeSet->getGroups() as $group) {
+ $groupAttributes = $group->getAttributes();
+ $newAttributes = array_filter(
+ $groupAttributes,
+ function ($attribute) use ($attributeCountryOfManufacture) {
+ /** @var ProductAttributeInterface $attribute */
+ return $attribute->getAttributeId() != $attributeCountryOfManufacture->getAttributeId();
+ }
+ );
+ if (count($newAttributes) < count($groupAttributes)) {
+ $group->setAttributes($newAttributes);
+ break;
+ }
+}
+$attributeSet->save();
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture_rollback.php
new file mode 100644
index 0000000000000..7b4719e151303
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture_rollback.php
@@ -0,0 +1,58 @@
+create(AttributeSetRepositoryInterface::class);
+/** @var Type $entityType */
+$entityType = $objectManager->create(Type::class)
+ ->loadByCode(Magento\Catalog\Model\Product::ENTITY);
+$sortOrderBuilder = $objectManager->create(SortOrderBuilder::class);
+/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+$searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
+$searchCriteriaBuilder->addFilter('attribute_set_name', 'custom_attribute_set_wout_com');
+$searchCriteriaBuilder->addFilter('entity_type_id', $entityType->getId());
+$attributeSetIdSortOrder = $sortOrderBuilder
+ ->setField('attribute_set_id')
+ ->setDirection(Collection::SORT_ORDER_DESC)
+ ->create();
+$searchCriteriaBuilder->addSortOrder($attributeSetIdSortOrder);
+$searchCriteriaBuilder->setPageSize(1);
+$searchCriteriaBuilder->setCurrentPage(1);
+
+/** @var AttributeSetSearchResults $searchResult */
+$searchResult = $attributeSetRepository->getList($searchCriteriaBuilder->create());
+$items = $searchResult->getItems();
+
+$registry = $objectManager->get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+try {
+ if (count($items) > 0) {
+ /** @var Set $attributeSet */
+ $attributeSet = reset($items);
+ $attributeSetRepository->deleteById($attributeSet->getId());
+ }
+} catch (\Exception $e) {
+ // In case of test run with DB isolation there is already no object in database
+ // since rollback fixtures called after transaction rollback.
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
new file mode 100644
index 0000000000000..70fb8a598fa3a
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
@@ -0,0 +1,53 @@
+reinitialize();
+
+/** @var \Magento\TestFramework\ObjectManager $objectManager */
+$objectManager = Bootstrap::getObjectManager();
+
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = $objectManager->create(ProductRepositoryInterface::class);
+/** @var ProductRepositoryInterface $productRepository */
+$productFactory = $objectManager->create(ProductInterfaceFactory::class);
+/** @var $product \Magento\Catalog\Model\Product */
+
+$defaultSetId = $objectManager->create(Product::class)
+ ->getDefaultAttributeSetid();
+
+$product = $productFactory->create();
+$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
+ ->setAttributeSetId($defaultSetId)
+ ->setWebsiteIds([1])
+ ->setName('Simple Product With Country Of Manufacture')
+ ->setSku('simple_with_com')
+ ->setPrice(10)
+ ->setWeight(1)
+ ->setCountryOfManufacture('AO')
+ ->setShortDescription("Short description")
+ ->setTaxClassId(0)
+ ->setDescription('Description')
+ ->setMetaTitle('meta title')
+ ->setMetaKeyword('meta keyword')
+ ->setMetaDescription('meta description')
+ ->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH)
+ ->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,
+ ]
+ );
+
+$productRepository->save($product);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture_rollback.php
new file mode 100644
index 0000000000000..ffeb7eb143410
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture_rollback.php
@@ -0,0 +1,32 @@
+create(ProductRepositoryInterface::class);
+
+$registry = $objectManager->get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+try {
+ /** @var Product $product */
+ $product = $productRepository->get('simple_with_com');
+ $productRepository->delete($product);
+} catch (\Exception $e) {
+ // In case of test run with DB isolation there is already no object in database
+ // since rollback fixtures called after transaction rollback.
+}
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From 3d6690ab40d4d6eff6aab6664226c10acb7aaebf Mon Sep 17 00:00:00 2001
From: korostii <24894168+korostii@users.noreply.github.com>
Date: Thu, 10 Oct 2019 13:49:35 +0300
Subject: [PATCH 0325/1978] Add test for #24019
---
.../Test/Unit/Patch/PatchHistoryTest.php | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchHistoryTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchHistoryTest.php
index 5d9631fe27f12..c4cd84f3f81bd 100644
--- a/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchHistoryTest.php
+++ b/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchHistoryTest.php
@@ -83,4 +83,28 @@ public function testFixAppliedPatch()
$adapterMock->expects($this->never())->method('insert');
$this->patchHistory->fixPatch(get_class($patch1));
}
+
+ /**
+ * @expectedException \LogicException
+ * @expectedExceptionMessageRegExp "Patch [a-zA-Z0-9\_]+ cannot be applied twice"
+ */
+ public function testFixPatchTwice()
+ {
+ /** @var PatchInterface|\PHPUnit_Framework_MockObject_MockObject $patch1 */
+ $patch = $this->createMock(PatchInterface::class);
+ /** @var AdapterInterface|\PHPUnit_Framework_MockObject_MockObject $adapterMock */
+ $adapterMock = $this->createMock(AdapterInterface::class);
+ $this->resourceConnectionMock->expects($this->any())->method('getConnection')->willReturn($adapterMock);
+ $this->resourceConnectionMock->expects($this->any())
+ ->method('getTableName')
+ ->willReturn(PatchHistory::TABLE_NAME);
+ $selectMock = $this->createMock(\Magento\Framework\DB\Select::class);
+ $selectMock->expects($this->once())->method('from');
+ $adapterMock->expects($this->any())->method('select')->willReturn($selectMock);
+ $adapterMock->expects($this->once())->method('fetchCol')->willReturn([]);
+ $adapterMock->expects($this->once())->method('insert');
+
+ $this->patchHistory->fixPatch(get_class($patch));
+ $this->patchHistory->fixPatch(get_class($patch));
+ }
}
From e9f0b8a117f09134ed15652e551266a237de3c6e Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Thu, 10 Oct 2019 14:12:39 +0300
Subject: [PATCH 0326/1978] MC-5233: DateTime product attributes support
---
.../Test/Mftf/Section/AdminCreateProductAttributeSection.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
index 31c4f5198a8b0..0934e39dcb062 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminCreateProductAttributeSection.xml
@@ -93,7 +93,7 @@
-
+
From e7ff49d72813c58e160571d65a3be2f0ec9099c4 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Thu, 10 Oct 2019 14:19:27 +0300
Subject: [PATCH 0327/1978] MC-20668: Edit custom options of simple product
---
.../Product/Save/UpdateCustomOptionsTest.php | 125 +++++
.../Create/DataProvider/AbstractBase.php | 172 +++++++
.../Create/DataProvider/Type/Date/Date.php | 24 +
.../DataProvider/Type/Date/DateTime.php | 24 +
.../Create/DataProvider/Type/Date/Time.php | 24 +
.../Create/DataProvider/Type/File/File.php | 90 ++++
.../Type/Select/AbstractSelect.php | 199 ++++++++
.../DataProvider/Type/Select/Checkbox.php | 24 +
.../DataProvider/Type/Select/DropDown.php | 24 +
.../Type/Select/MultipleSelect.php | 24 +
.../DataProvider/Type/Select/RadioButtons.php | 24 +
.../DataProvider/Type/Text/AbstractText.php | 75 +++
.../Create/DataProvider/Type/Text/Area.php | 24 +
.../Create/DataProvider/Type/Text/Field.php | 24 +
.../Model/Product/UpdateCustomOptionsTest.php | 457 ++++++++++++++++++
15 files changed, 1334 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/AbstractText.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
new file mode 100644
index 0000000000000..d2fbaca0eb807
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
@@ -0,0 +1,125 @@
+productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
+ $this->optionRepository = $this->_objectManager->create(ProductCustomOptionRepositoryInterface::class);
+ $this->optionRepositoryFactory = $this->_objectManager->create(ProductCustomOptionInterfaceFactory::class);
+ }
+
+ /**
+ * Test add to product custom option with type "field".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\Field::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ public function testUpdateCustomOptionWithTypeField(array $optionData, array $updateData): void
+ {
+ $product = $this->productRepository->get('simple');
+ $option = $this->optionRepositoryFactory->create(['data' => $optionData]);
+ $option->setProductSku($product->getSku());
+ $product->setOptions([$option]);
+ $this->productRepository->save($product);
+ $currentProductOptions = $this->optionRepository->getProductOptions($product);
+ $this->assertCount(1, $currentProductOptions);
+ /** @var ProductCustomOptionInterface $currentOption */
+ $currentOption = reset($currentProductOptions);
+ $postData = [
+ 'product' => [
+ 'options' => [
+ [
+ 'option_id' => $currentOption->getOptionId(),
+ 'product_id' => $product->getId(),
+ 'type' => $currentOption->getType(),
+ 'is_require' => $currentOption->getIsRequire(),
+ 'sku' => $currentOption->getSku(),
+ 'max_characters' => $currentOption->getMaxCharacters(),
+ 'title' => $currentOption->getTitle(),
+ 'sort_order' => $currentOption->getSortOrder(),
+ 'price' => $currentOption->getPrice(),
+ 'price_type' => $currentOption->getPriceType(),
+ 'is_use_default' => false,
+ ]
+ ]
+ ]
+ ];
+
+ foreach ($updateData as $methodKey => $newValue) {
+ $postData = array_replace_recursive(
+ $postData,
+ [
+ 'product' => [
+ 'options' => [
+ 0 => [
+ $methodKey => $newValue,
+ ]
+ ],
+ ],
+ ]
+ );
+ $this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->dispatch('backend/catalog/product/save/id/' . $product->getEntityId());
+ $this->assertSessionMessages(
+ $this->contains('You saved the product.'),
+ MessageInterface::TYPE_SUCCESS
+ );
+ $updatedOptions = $this->optionRepository->getProductOptions($product);
+ $this->assertCount(1, $updatedOptions);
+ /** @var ProductCustomOptionInterface $updatedOption */
+ $updatedOption = reset($updatedOptions);
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
+ $this->assertEquals($option->getOptionId(), $updatedOption->getOptionId());
+ $this->assertNotEquals($option->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
+ }
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php
new file mode 100644
index 0000000000000..fd8db9d130dd0
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php
@@ -0,0 +1,172 @@
+getType()}_title" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_required_options" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_not_required_options" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 0,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_options_with_fixed_price" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_options_with_percent_price" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'percent',
+ ],
+ ],
+ "type_{$this->getType()}_price" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 22,
+ 'price_type' => 'percent',
+ ],
+ ],
+ "type_{$this->getType()}_sku" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 50,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 22,
+ 'price_type' => 'percent',
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Return data for create options for all cases.
+ *
+ * @return array
+ */
+ public function getDataForUpdateOptions(): array
+ {
+ return array_merge_recursive(
+ $this->getDataForCreateOptions(),
+ [
+ "type_{$this->getType()}_title" => [
+ [
+ 'title' => 'Test updated option title',
+ ]
+ ],
+ "type_{$this->getType()}_required_options" => [
+ [
+ 'is_require' => 0,
+ ],
+ ],
+ "type_{$this->getType()}_not_required_options" => [
+ [
+ 'is_require' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_options_with_fixed_price" => [
+ [
+ 'price_type' => 'percent',
+ ],
+ ],
+ "type_{$this->getType()}_options_with_percent_price" => [
+ [
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_price" => [
+ [
+ 'price' => 60,
+ ],
+ ],
+ "type_{$this->getType()}_sku" => [
+ [
+ 'sku' => 'Updated option sku',
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * Return option type.
+ *
+ * @return string
+ */
+ abstract protected function getType(): string;
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
new file mode 100644
index 0000000000000..6feb20f56e536
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
@@ -0,0 +1,24 @@
+getType()}_option_file_extension" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 30,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'file_extension' => 'gif',
+ 'image_size_x' => 10,
+ 'image_size_y' => 20,
+ ],
+ ],
+ "type_{$this->getType()}_option_maximum_file_size" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'file_extension' => 'gif',
+ 'image_size_x' => 10,
+ 'image_size_y' => 20,
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDataForUpdateOptions(): array
+ {
+ return array_merge_recursive(
+ parent::getDataForUpdateOptions(),
+ [
+ "type_{$this->getType()}_option_file_extension" => [
+ [
+ 'file_extension' => 'jpg',
+ ],
+ ],
+ "type_{$this->getType()}_option_maximum_file_size" => [
+ [
+ 'image_size_x' => 300,
+ 'image_size_y' => 815,
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function getType(): string
+ {
+ return 'file';
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php
new file mode 100644
index 0000000000000..62c9012b0997b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php
@@ -0,0 +1,199 @@
+getType()}_title" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_required_options" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_not_required_options" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 0,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_options_with_fixed_price" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_options_with_percent_price" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 10,
+ 'price_type' => 'percent',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_price" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 22,
+ 'price_type' => 'fixed',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ "type_{$this->getType()}_sku" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ ],
+ [
+ 'record_id' => 0,
+ 'title' => 'Test option 1 value 1',
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ 'sku' => 'test-option-1-value-1',
+ 'sort_order' => 1,
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDataForUpdateOptions(): array
+ {
+ return array_merge_recursive(
+ $this->getDataForCreateOptions(),
+ [
+ "type_{$this->getType()}_title" => [
+ [
+ 'title' => 'Updated test option title 1',
+ ],
+ [],
+ ],
+ "type_{$this->getType()}_required_options" => [
+ [
+ 'is_require' => 0,
+ ],
+ [],
+ ],
+ "type_{$this->getType()}_not_required_options" => [
+ [
+ 'is_require' => 1,
+ ],
+ [],
+ ],
+ "type_{$this->getType()}_options_with_fixed_price" => [
+ [],
+ [
+ 'price_type' => 'percent',
+ ],
+ ],
+ "type_{$this->getType()}_options_with_percent_price" => [
+ [],
+ [
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_price" => [
+ [],
+ [
+ 'price' => 666,
+ ],
+ ],
+ "type_{$this->getType()}_sku" => [
+ [],
+ [
+ 'sku' => 'updated-test-option-1-value-1',
+ ],
+ ],
+ ]
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
new file mode 100644
index 0000000000000..32d55f45a9757
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
@@ -0,0 +1,24 @@
+getType()}_options_with_max_charters_configuration" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'max_characters' => 30,
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ ],
+ ],
+ "type_{$this->getType()}_options_without_max_charters_configuration" => [
+ [
+ 'record_id' => 0,
+ 'sort_order' => 1,
+ 'is_require' => 1,
+ 'sku' => 'test-option-title-1',
+ 'title' => 'Test option title 1',
+ 'type' => $this->getType(),
+ 'price' => 10,
+ 'price_type' => 'fixed',
+ ],
+ ],
+ ]
+ );
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function getDataForUpdateOptions(): array
+ {
+ return array_merge_recursive(
+ parent::getDataForUpdateOptions(),
+ [
+ "type_{$this->getType()}_options_with_max_charters_configuration" => [
+ [
+ 'max_characters' => 0,
+ ],
+ ],
+ "type_{$this->getType()}_options_without_max_charters_configuration" => [
+ [
+ 'max_characters' => 55,
+ ],
+ ],
+ ]
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
new file mode 100644
index 0000000000000..f0dc1f5d7dbcd
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
@@ -0,0 +1,24 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ $this->optionRepository = $this->objectManager->create(ProductCustomOptionRepositoryInterface::class);
+ $this->customOptionFactory = $this->objectManager->create(ProductCustomOptionInterfaceFactory::class);
+ $this->customOptionValueFactory = $this->objectManager
+ ->create(ProductCustomOptionValuesInterfaceFactory::class);
+ $this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
+ $this->currentStoreId = $this->storeManager->getStore()->getId();
+ $adminStoreId = $this->storeManager->getStore('admin')->getId();
+ $this->storeManager->setCurrentStore($adminStoreId);
+
+ parent::setUp();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ $this->storeManager->setCurrentStore($this->currentStoreId);
+
+ parent::tearDown();
+ }
+
+ /**
+ * Test update product custom options with type "area".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\Area::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ public function testUpdateAreaCustomOption(array $optionData, array $updateData): void
+ {
+ $this->updateAndAssertNotSelectCustomOptions($optionData, $updateData);
+ }
+
+ /**
+ * Test update product custom options with type "file".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\File\File::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ public function testUpdateFileCustomOption(array $optionData, array $updateData): void
+ {
+ $this->updateAndAssertNotSelectCustomOptions($optionData, $updateData);
+ }
+
+ /**
+ * Test update product custom options with type "Date".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date\Date::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ public function testUpdateDateCustomOption(array $optionData, array $updateData): void
+ {
+ $this->updateAndAssertNotSelectCustomOptions($optionData, $updateData);
+ }
+
+ /**
+ * Test update product custom options with type "Date & Time".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date\DateTime::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ public function testUpdateDateTimeCustomOption(array $optionData, array $updateData): void
+ {
+ $this->updateAndAssertNotSelectCustomOptions($optionData, $updateData);
+ }
+
+ /**
+ * Test update product custom options with type "Time".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date\Time::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ public function testUpdateTimeCustomOption(array $optionData, array $updateData): void
+ {
+ $this->updateAndAssertNotSelectCustomOptions($optionData, $updateData);
+ }
+
+ /**
+ * Test update product custom options with type "Drop-down".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\DropDown::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $optionValueData
+ * @param array $updateOptionData
+ * @param array $updateOptionValueData
+ */
+ public function testUpdateDropDownCustomOption(
+ array $optionData,
+ array $optionValueData,
+ array $updateOptionData,
+ array $updateOptionValueData
+ ): void {
+ $this->updateAndAssertSelectCustomOptions(
+ $optionData,
+ $optionValueData,
+ $updateOptionData,
+ $updateOptionValueData
+ );
+ }
+
+ /**
+ * Test update product custom options with type "Radio Buttons".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\RadioButtons::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $optionValueData
+ * @param array $updateOptionData
+ * @param array $updateOptionValueData
+ */
+ public function testUpdateRadioButtonsCustomOption(
+ array $optionData,
+ array $optionValueData,
+ array $updateOptionData,
+ array $updateOptionValueData
+ ): void {
+ $this->updateAndAssertSelectCustomOptions(
+ $optionData,
+ $optionValueData,
+ $updateOptionData,
+ $updateOptionValueData
+ );
+ }
+
+ /**
+ * Test update product custom options with type "Checkbox".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\Checkbox::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $optionValueData
+ * @param array $updateOptionData
+ * @param array $updateOptionValueData
+ */
+ public function testUpdateCheckboxCustomOption(
+ array $optionData,
+ array $optionValueData,
+ array $updateOptionData,
+ array $updateOptionValueData
+ ): void {
+ $this->updateAndAssertSelectCustomOptions(
+ $optionData,
+ $optionValueData,
+ $updateOptionData,
+ $updateOptionValueData
+ );
+ }
+
+ /**
+ * Test update product custom options with type "Multiple Select".
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_without_options.php
+ *
+ * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\MultipleSelect::getDataForUpdateOptions
+ *
+ * @param array $optionData
+ * @param array $optionValueData
+ * @param array $updateOptionData
+ * @param array $updateOptionValueData
+ */
+ public function testUpdateMultipleSelectCustomOption(
+ array $optionData,
+ array $optionValueData,
+ array $updateOptionData,
+ array $updateOptionValueData
+ ): void {
+ $this->updateAndAssertSelectCustomOptions(
+ $optionData,
+ $optionValueData,
+ $updateOptionData,
+ $updateOptionValueData
+ );
+ }
+
+ /**
+ * Update product custom options which are not from "select" group and assert updated data.
+ *
+ * @param array $optionData
+ * @param array $updateData
+ */
+ private function updateAndAssertNotSelectCustomOptions(array $optionData, array $updateData): void
+ {
+ $productSku = 'simple';
+ $createdOption = $this->createCustomOption($optionData, $productSku);
+ $updatedOption = $this->updateOptionWithValues($updateData, $productSku);
+
+ foreach ($updateData as $methodKey => $newValue) {
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
+ $this->assertNotEquals($createdOption->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
+ }
+
+ $this->assertEquals($createdOption->getOptionId(), $updatedOption->getOptionId());
+ }
+
+ /**
+ * Update product custom options which from "select" group and assert updated data.
+ *
+ * @param array $optionData
+ * @param array $optionValueData
+ * @param array $updateOptionData
+ * @param array $updateOptionValueData
+ */
+ private function updateAndAssertSelectCustomOptions(
+ array $optionData,
+ array $optionValueData,
+ array $updateOptionData,
+ array $updateOptionValueData
+ ): void {
+ $productSku = 'simple';
+ $createdOption = $this->createCustomOptionWithValue($optionData, $optionValueData, $productSku);
+ $createdOptionValue = $this->getOptionValue($createdOption);
+ $updatedOption = $this->updateOptionAndValueWithValues($updateOptionData, $updateOptionValueData, $productSku);
+ $updatedOptionValue = $this->getOptionValue($updatedOption);
+
+ foreach ($updateOptionData as $methodKey => $newValue) {
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
+ $this->assertNotEquals($createdOption->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
+ }
+
+ foreach ($updateOptionValueData as $methodKey => $newValue) {
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $this->assertEquals($newValue, $updatedOptionValue->{'get' . $methodName}());
+ $this->assertNotEquals(
+ $createdOptionValue->{'get' . $methodName}(),
+ $updatedOptionValue->{'get' . $methodName}()
+ );
+ }
+
+ $this->assertEquals($createdOption->getOptionId(), $updatedOption->getOptionId());
+ }
+
+ /**
+ * Create custom option and save product with created option.
+ *
+ * @param array $optionData
+ * @param string $productSku
+ * @return ProductCustomOptionInterface
+ */
+ private function createCustomOption(array $optionData, string $productSku): ProductCustomOptionInterface
+ {
+ $product = $this->productRepository->get($productSku);
+ $createdOption = $this->customOptionFactory->create(['data' => $optionData]);
+ $createdOption->setProductSku($product->getSku());
+ $product->setOptions([$createdOption]);
+ $this->productRepository->save($product);
+ $productCustomOptions = $this->optionRepository->getProductOptions($product);
+ $this->assertCount(1, $productCustomOptions);
+ $option = reset($productCustomOptions);
+
+ return $option;
+ }
+
+ /**
+ * Create custom option from select group and save product with created option.
+ *
+ * @param array $optionData
+ * @param array $optionValueData
+ * @param string $productSku
+ * @return ProductCustomOptionInterface
+ */
+ private function createCustomOptionWithValue(
+ array $optionData,
+ array $optionValueData,
+ string $productSku
+ ): ProductCustomOptionInterface {
+ $optionValue = $this->customOptionValueFactory->create(['data' => $optionValueData]);
+ $optionData['values'] = [$optionValue];
+
+ return $this->createCustomOption($optionData, $productSku);
+ }
+
+ /**
+ * Update product option with values.
+ *
+ * @param array $updateData
+ * @param string $productSku
+ * @return ProductCustomOptionInterface
+ */
+ private function updateOptionWithValues(array $updateData, string $productSku): ProductCustomOptionInterface
+ {
+ $product = $this->productRepository->get($productSku);
+ $currentOption = $this->getProductOptionByProductSku($product->getSku());
+ $currentOption->setProductSku($product->getSku());
+ foreach ($updateData as $methodKey => $newValue) {
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $currentOption->{'set' . $methodName}($newValue);
+ }
+ $product->setOptions([$currentOption]);
+ $this->productRepository->save($product);
+
+ return $this->getProductOptionByProductSku($product->getSku());
+ }
+
+ /**
+ * Update product option with values.
+ *
+ * @param array $optionUpdateData
+ * @param array $optionValueUpdateData
+ * @param string $productSku
+ * @return ProductCustomOptionInterface
+ */
+ private function updateOptionAndValueWithValues(
+ array $optionUpdateData,
+ array $optionValueUpdateData,
+ string $productSku
+ ): ProductCustomOptionInterface {
+ $product = $this->productRepository->get($productSku);
+ $currentOption = $this->getProductOptionByProductSku($product->getSku());
+ $currentOption->setProductSku($product->getSku());
+ $optionValue = $this->getOptionValue($currentOption);
+ foreach ($optionUpdateData as $methodKey => $newValue) {
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $currentOption->{'set' . $methodName}($newValue);
+ }
+ foreach ($optionValueUpdateData as $methodKey => $newValue) {
+ $methodName = str_replace('_', '', ucwords($methodKey, '_'));
+ $optionValue->{'set' . $methodName}($newValue);
+ }
+ $currentOption->setValues([$optionValue]);
+ $product->setOptions([$currentOption]);
+ $this->productRepository->save($product);
+
+ return $this->getProductOptionByProductSku($product->getSku());
+ }
+
+ /**
+ * Get product option by product sku.
+ *
+ * @param string $productSku
+ * @return ProductCustomOptionInterface
+ */
+ private function getProductOptionByProductSku(string $productSku): ProductCustomOptionInterface
+ {
+ $product = $this->productRepository->get($productSku);
+ $currentOptions = $this->optionRepository->getProductOptions($product);
+ $this->assertCount(1, $currentOptions);
+
+ return reset($currentOptions);
+ }
+
+ /**
+ * Return custom option value.
+ *
+ * @param ProductCustomOptionInterface $customOption
+ * @return ProductCustomOptionValuesInterface
+ */
+ private function getOptionValue(ProductCustomOptionInterface $customOption): ProductCustomOptionValuesInterface
+ {
+ $optionValues = $customOption->getValues();
+ $this->assertCount(1, $optionValues);
+
+ return reset($optionValues);
+ }
+}
From dbbb316ffe6e63144a2fd2ee1a06d9fba0d9fb81 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Thu, 10 Oct 2019 14:44:56 +0300
Subject: [PATCH 0328/1978] MC-20195: Move test MC-13104 to infrastructure
---
.../integration/testsuite/Magento/Sales/_files/quotes.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
index b916fc0240417..ae47ddc842d00 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
@@ -7,6 +7,7 @@
use Magento\Quote\Model\QuoteFactory;
use Magento\Quote\Model\QuoteRepository;
+use Magento\Store\Model\Store;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
@@ -19,12 +20,16 @@
/** @var QuoteRepository $quoteRepository */
$quoteRepository = $objectManager->get(QuoteRepository::class);
+/** @var Store $store */
+$store = $objectManager->create(Store::class);
+$store->load('fixture_second_store', 'code');
+
$quotes = [
'quote for first store' => [
'store' => 1,
],
'quote for second store' => [
- 'store' => 2,
+ 'store' => $store->getId(),
],
];
From f92fe06dcfc248eb6b0906afef3edcf3c4b97690 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Thu, 10 Oct 2019 07:48:26 -0500
Subject: [PATCH 0329/1978] MC-20649: Integration tests for store promotions on
quote
- debugging failure in jenkins
---
.../PlaceOrderWithStorePromotionsTest.php | 52 ++++++++++---------
1 file changed, 27 insertions(+), 25 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index e9c92861c05b1..62ebab07193d8 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -123,32 +123,34 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
->where('address_type = "shipping"');
$resultFromQuoteAddress = $this->connection->fetchRow($selectFromQuoteAddress);
+ $this->assertNotEmpty($resultFromQuoteAddress, 'No record found in quote_address table');
$serializedDiscountQuoteAddress = $resultFromQuoteAddress['discounts'];
- $this->assertTrue(
- array_key_exists(
- $salesRuleId,
- $this->jsonSerializer->unserialize(
- $serializedDiscountQuoteAddress
- )
- )
- );
- $this->assertEquals(
- 10,
- json_decode($this->jsonSerializer->unserialize(
- $serializedDiscountQuoteAddress
- )[$salesRuleId]['discount'], true)['amount']
- );
- $this->assertEquals(
- 10,
- json_decode(
- $this->jsonSerializer->unserialize(
- $resultFromQuoteAddress['discounts']
- )
- [$salesRuleId]['discount'],
- true
- )
- ['baseAmount']
- );
+
+// $this->assertTrue(
+// array_key_exists(
+// $salesRuleId,
+// $this->jsonSerializer->unserialize(
+// $serializedDiscountQuoteAddress
+// )
+// )
+// );
+// $this->assertEquals(
+// 10,
+// json_decode($this->jsonSerializer->unserialize(
+// $serializedDiscountQuoteAddress
+// )[$salesRuleId]['discount'], true)['amount']
+// );
+// $this->assertEquals(
+// 10,
+// json_decode(
+// $this->jsonSerializer->unserialize(
+// $resultFromQuoteAddress['discounts']
+// )
+// [$salesRuleId]['discount'],
+// true
+// )
+// ['baseAmount']
+// );
$this->assertEquals(
'TestRule_Label',
$this->jsonSerializer->unserialize($serializedDiscountQuoteAddress)[$salesRuleId]['rule']
From 27e2049537f34d8ce0748e2f47afc9f95ffed1b1 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Thu, 10 Oct 2019 17:09:16 +0300
Subject: [PATCH 0330/1978] MC-5233: DateTime product attributes support
---
app/code/Magento/Catalog/Ui/Component/Listing/Columns.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php b/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php
index d7b9bc3846f49..1e056d9f8d517 100644
--- a/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php
+++ b/app/code/Magento/Catalog/Ui/Component/Listing/Columns.php
@@ -14,7 +14,7 @@
class Columns extends \Magento\Ui\Component\Listing\Columns
{
/**
- * Default columns max order
+ * Default columns max order value
*/
const DEFAULT_COLUMNS_MAX_ORDER = 100;
From 015bc92d4e97f442264c617216d3a7bddf697dbf Mon Sep 17 00:00:00 2001
From: natalia
Date: Thu, 10 Oct 2019 18:41:00 +0300
Subject: [PATCH 0331/1978] MC-21646: Integration Test failed with
elasticsearch6:
Magento\ProductAlert\Model\ObserverTest::testProcessPortuguese
---
.../Magento/Customer/_files/customer_for_second_store.php | 5 ++++-
.../testsuite/Magento/ProductAlert/Model/ObserverTest.php | 7 ++++---
.../ProductAlert/_files/product_alert_with_store.php | 8 ++++++--
3 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php
index d8c56b7bf6f4f..79fd831dee27a 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/_files/customer_for_second_store.php
@@ -7,11 +7,14 @@
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Store\Api\StoreRepositoryInterface;
require __DIR__ . '/customer.php';
$objectManager = Bootstrap::getObjectManager();
+$storeRepository = $objectManager->get(StoreRepositoryInterface::class);
+$storeId = $storeRepository->get('fixture_second_store')->getId();
$repository = $objectManager->create(CustomerRepositoryInterface::class);
$customer = $repository->get('customer@example.com');
-$customer->setStoreId(2);
+$customer->setStoreId($storeId);
$repository->save($customer);
diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php
index 0f19edc349e84..de7c2dff03b21 100644
--- a/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/ProductAlert/Model/ObserverTest.php
@@ -116,9 +116,10 @@ public function testProcessPortuguese()
// dispatch process() method and check sent message
$this->observer->process();
- $message = $this->transportBuilder->getSentMessage()->getRawMessage();
+ $message = $this->transportBuilder->getSentMessage();
+ $messageContent = $message->getBody()->getParts()[0]->getRawContent();
$expectedText = array_shift($translation);
- $this->assertContains('/frontend/Magento/luma/pt_BR/', $message);
- $this->assertContains(substr($expectedText, 0, 50), $message);
+ $this->assertContains('/frontend/Magento/luma/pt_BR/', $messageContent);
+ $this->assertContains(substr($expectedText, 0, 50), $messageContent);
}
}
diff --git a/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php b/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php
index 38f00d49f1d47..fef16baed1704 100644
--- a/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php
+++ b/dev/tests/integration/testsuite/Magento/ProductAlert/_files/product_alert_with_store.php
@@ -8,22 +8,26 @@
use Magento\TestFramework\Helper\Bootstrap;
use Magento\ProductAlert\Model\Price;
use Magento\ProductAlert\Model\Stock;
+use Magento\Store\Api\StoreRepositoryInterface;
require __DIR__ . '/../../../Magento/Customer/_files/customer_for_second_store.php';
require __DIR__ . '/../../../Magento/Catalog/_files/product_simple_out_of_stock_without_categories.php';
$objectManager = Bootstrap::getObjectManager();
+$storeRepository = $objectManager->get(StoreRepositoryInterface::class);
+$storeId = $storeRepository->get('fixture_second_store')->getId();
+
$price = $objectManager->create(Price::class);
$price->setCustomerId($customer->getId())
->setProductId($product->getId())
->setPrice($product->getPrice()+1)
->setWebsiteId(1)
- ->setStoreId(2);
+ ->setStoreId($storeId);
$price->save();
$stock = $objectManager->create(Stock::class);
$stock->setCustomerId($customer->getId())
->setProductId($product->getId())
->setWebsiteId(1)
- ->setStoreId(2);
+ ->setStoreId($storeId);
$stock->save();
From a6d6d2d1ba3228ef693e1e8daece4b6bb7a5f4b3 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Thu, 10 Oct 2019 11:56:48 -0500
Subject: [PATCH 0332/1978] MC-20649: Integration tests for store promotions on
quote
- debugging failure in jenkins
---
.../PlaceOrderWithStorePromotionsTest.php | 27 +++++++++++--------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index 62ebab07193d8..7239b7134ccaa 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -112,20 +112,24 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
$this->assertTrue(array_key_exists($salesRuleId, $this->jsonSerializer->unserialize($serializedCartDiscount)));
$this->assertEquals(
10,
- json_decode($this->jsonSerializer->unserialize(
- $serializedCartDiscount
- )[$salesRuleId]['discount'], true)['amount']
+ json_decode(
+ $this->jsonSerializer->unserialize(
+ $serializedCartDiscount
+ )
+ [$salesRuleId]['discount'],
+ true
+ )['amount']
);
$this->assertEquals(
'TestRule_Label',
$this->jsonSerializer->unserialize($serializedCartDiscount)[$salesRuleId]['rule']
);
+ $addressType = 'shipping';
$selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
- ->where('address_type = "shipping"');
+ ->where('address_type = ?', $addressType);
$resultFromQuoteAddress = $this->connection->fetchRow($selectFromQuoteAddress);
$this->assertNotEmpty($resultFromQuoteAddress, 'No record found in quote_address table');
$serializedDiscountQuoteAddress = $resultFromQuoteAddress['discounts'];
-
// $this->assertTrue(
// array_key_exists(
// $salesRuleId,
@@ -134,12 +138,13 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
// )
// )
// );
-// $this->assertEquals(
-// 10,
-// json_decode($this->jsonSerializer->unserialize(
-// $serializedDiscountQuoteAddress
-// )[$salesRuleId]['discount'], true)['amount']
-// );
+ /*$this->assertEquals(
+ 10,
+ json_decode($this->jsonSerializer->unserialize(
+ $serializedDiscountQuoteAddress
+ )[$salesRuleId]['discount'], true)['amount']
+ );*/
+
// $this->assertEquals(
// 10,
// json_decode(
From eabb5dacd6d96beedae1ed873226bbee7ef5cb62 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Fri, 26 Jul 2019 19:26:05 +0300
Subject: [PATCH 0333/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix CurrencyConverterApi currency rates provider.
---
.../Currency/Import/CurrencyConverterApi.php | 148 ++++++++++++++----
.../Directory/etc/adminhtml/system.xml | 7 +-
app/code/Magento/Directory/etc/config.xml | 1 +
3 files changed, 121 insertions(+), 35 deletions(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index f52886a14264d..ff3f54fbd506b 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -7,38 +7,47 @@
namespace Magento\Directory\Model\Currency\Import;
+use Magento\Directory\Model\CurrencyFactory;
+use Magento\Store\Model\ScopeInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface as ScopeConfig;
+use Magento\Framework\HTTP\ZendClient;
+use Magento\Framework\HTTP\ZendClientFactory;
+use Exception;
+
+/**
+ * Currency rate converter (free.currconv.com).
+ */
class CurrencyConverterApi extends AbstractImport
{
/**
* @var string
*/
- const CURRENCY_CONVERTER_URL = 'http://free.currencyconverterapi.com/api/v3/convert?q={{CURRENCY_FROM}}_{{CURRENCY_TO}}&compact=ultra'; //@codingStandardsIgnoreLine
+ public const CURRENCY_CONVERTER_URL = 'https://free.currconv.com/api/v7/convert?apiKey={{ACCESS_KEY}}'
+ . '&q={{CURRENCY_RATES}}&compact=ultra';
/**
* Http Client Factory
*
- * @var \Magento\Framework\HTTP\ZendClientFactory
+ * @var ZendClientFactory
*/
private $httpClientFactory;
/**
* Core scope config
*
- * @var \Magento\Framework\App\Config\ScopeConfigInterface
+ * @var ScopeConfig
*/
private $scopeConfig;
/**
- * Initialize dependencies
- *
- * @param \Magento\Directory\Model\CurrencyFactory $currencyFactory
- * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
- * @param \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
+ * @param CurrencyFactory $currencyFactory
+ * @param ScopeConfig $scopeConfig
+ * @param ZendClientFactory $httpClientFactory
*/
public function __construct(
- \Magento\Directory\Model\CurrencyFactory $currencyFactory,
- \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
- \Magento\Framework\HTTP\ZendClientFactory $httpClientFactory
+ CurrencyFactory $currencyFactory,
+ ScopeConfig $scopeConfig,
+ ZendClientFactory $httpClientFactory
) {
parent::__construct($currencyFactory);
$this->scopeConfig = $scopeConfig;
@@ -48,7 +57,7 @@ public function __construct(
/**
* {@inheritdoc}
*/
- public function fetchRates()
+ public function fetchRates(): array
{
$data = [];
$currencies = $this->_getCurrencyCodes();
@@ -72,34 +81,74 @@ public function fetchRates()
* @param array $currenciesTo
* @return array
*/
- private function convertBatch($data, $currencyFrom, $currenciesTo)
+ private function convertBatch(array $data, string $currencyFrom, array $currenciesTo): array
{
+ $url = $this->getServiceURL($currencyFrom, $currenciesTo);
+ if (empty($url)) {
+ $data[$currencyFrom] = $this->makeEmptyResponse($currenciesTo);
+ return $data;
+ }
+
+ set_time_limit(0);
+ try {
+ $response = $this->getServiceResponse($url);
+ } finally {
+ ini_restore('max_execution_time');
+ }
+
+ if (!$this->validateResponse($response)) {
+ $data[$currencyFrom] = $this->makeEmptyResponse($currenciesTo);
+ return $data;
+ }
+
foreach ($currenciesTo as $to) {
- set_time_limit(0);
- try {
- $url = str_replace('{{CURRENCY_FROM}}', $currencyFrom, self::CURRENCY_CONVERTER_URL);
- $url = str_replace('{{CURRENCY_TO}}', $to, $url);
- $response = $this->getServiceResponse($url);
- if ($currencyFrom == $to) {
- $data[$currencyFrom][$to] = $this->_numberFormat(1);
+ if ($currencyFrom === $to) {
+ $data[$currencyFrom][$to] = $this->_numberFormat(1);
+ } else {
+ if (empty($response)) {
+ $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $to);
+ $data[$currencyFrom][$to] = null;
} else {
- if (empty($response)) {
- $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $to);
- $data[$currencyFrom][$to] = null;
- } else {
- $data[$currencyFrom][$to] = $this->_numberFormat(
- (double)$response[$currencyFrom . '_' . $to]
- );
- }
+ $data[$currencyFrom][$to] = $this->_numberFormat(
+ (double)$response[$currencyFrom . '_' . $to]
+ );
}
- } finally {
- ini_restore('max_execution_time');
}
}
return $data;
}
+ /**
+ * Return service URL.
+ *
+ * @param string $currencyFrom
+ * @param array $currenciesTo
+ * @return string
+ */
+ private function getServiceURL(string $currencyFrom, array $currenciesTo): string
+ {
+ // Get access key
+ $accessKey = $this->scopeConfig->getValue('currency/currencyconverterapi/api_key', ScopeInterface::SCOPE_STORE);
+ if (empty($accessKey)) {
+ $this->_messages[] = __('No API Key was specified or an invalid API Key was specified.');
+ return '';
+ }
+
+ // Get currency rates request
+ $currencyQueryParts = [];
+ foreach ($currenciesTo as $currencyTo) {
+ $currencyQueryParts[] = sprintf('%s_%s', $currencyFrom, $currencyTo);
+ }
+ $currencyRates = implode(',', $currencyQueryParts);
+
+ return str_replace(
+ ['{{ACCESS_KEY}}', '{{CURRENCY_RATES}}'],
+ [$accessKey, $currencyRates],
+ self::CURRENCY_CONVERTER_URL
+ );
+ }
+
/**
* Get Fixer.io service response
*
@@ -107,9 +156,9 @@ private function convertBatch($data, $currencyFrom, $currenciesTo)
* @param int $retry
* @return array
*/
- private function getServiceResponse($url, $retry = 0)
+ private function getServiceResponse($url, $retry = 0): array
{
- /** @var \Magento\Framework\HTTP\ZendClient $httpClient */
+ /** @var ZendClient $httpClient */
$httpClient = $this->httpClientFactory->create();
$response = [];
@@ -120,7 +169,7 @@ private function getServiceResponse($url, $retry = 0)
[
'timeout' => $this->scopeConfig->getValue(
'currency/currencyconverterapi/timeout',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
+ ScopeInterface::SCOPE_STORE
),
]
)->request(
@@ -128,7 +177,7 @@ private function getServiceResponse($url, $retry = 0)
)->getBody();
$response = json_decode($jsonResponse, true);
- } catch (\Exception $e) {
+ } catch (Exception $e) {
if ($retry == 0) {
$response = $this->getServiceResponse($url, 1);
}
@@ -136,6 +185,37 @@ private function getServiceResponse($url, $retry = 0)
return $response;
}
+ /**
+ * Validate rates response.
+ *
+ * @param array $response
+ * @return bool
+ */
+ private function validateResponse(array $response): bool
+ {
+ if (!isset($response['error'])) {
+ return true;
+ }
+
+ $errorCodes = [
+ 400 => __('No API Key was specified or an invalid API Key was specified.')
+ ];
+ $this->_messages[] = $errorCodes[$response['status']] ?? __('Currency rates can\'t be retrieved.');
+
+ return false;
+ }
+
+ /**
+ * Make empty rates for provided currencies.
+ *
+ * @param array $currenciesTo
+ * @return array
+ */
+ private function makeEmptyResponse(array $currenciesTo): array
+ {
+ return array_fill_keys($currenciesTo, null);
+ }
+
/**
* {@inheritdoc}
*/
diff --git a/app/code/Magento/Directory/etc/adminhtml/system.xml b/app/code/Magento/Directory/etc/adminhtml/system.xml
index ec5fa35b6a152..eb3f2a0e9ef2b 100644
--- a/app/code/Magento/Directory/etc/adminhtml/system.xml
+++ b/app/code/Magento/Directory/etc/adminhtml/system.xml
@@ -47,7 +47,12 @@
Currency Converter API
-
+
+ API Key
+ currency/currencyconverterapi/api_key
+ Magento\Config\Model\Config\Backend\Encrypted
+
+
Connection Timeout in Seconds
diff --git a/app/code/Magento/Directory/etc/config.xml b/app/code/Magento/Directory/etc/config.xml
index 276d7088cc2ea..c18c4f29d5822 100644
--- a/app/code/Magento/Directory/etc/config.xml
+++ b/app/code/Magento/Directory/etc/config.xml
@@ -24,6 +24,7 @@
100
+
0
From 5f2cea2acd7ca4f26f52eb489f33a4c6f4ec72be Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Fri, 26 Jul 2019 19:34:01 +0300
Subject: [PATCH 0334/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix statics.
---
.../Directory/Model/Currency/Import/CurrencyConverterApi.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index ff3f54fbd506b..c9064d4335530 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -55,7 +55,7 @@ public function __construct(
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function fetchRates(): array
{
@@ -217,7 +217,7 @@ private function makeEmptyResponse(array $currenciesTo): array
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function _convert($currencyFrom, $currencyTo)
{
From 3844080ef80b4d4151cd98e158cfc36afb3cbebb Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Mon, 29 Jul 2019 14:55:53 +0300
Subject: [PATCH 0335/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix statics.
---
.../Directory/Model/Currency/Import/CurrencyConverterApi.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index c9064d4335530..557dca9dd5621 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -88,7 +88,7 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
$data[$currencyFrom] = $this->makeEmptyResponse($currenciesTo);
return $data;
}
-
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
set_time_limit(0);
try {
$response = $this->getServiceResponse($url);
From 5d66cb6fcfcc0ac9efe6f3680a2752464d0f2bad Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Wed, 31 Jul 2019 15:50:16 +0300
Subject: [PATCH 0336/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix error message output for Currency Converter Api service
- Prevent XSS-attack for currency conversion services warning messages
---
.../Adminhtml/System/Currency/FetchRates.php | 73 +++++++++++++++----
.../Currency/Import/CurrencyConverterApi.php | 7 +-
2 files changed, 61 insertions(+), 19 deletions(-)
diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
index 34d24a8b0a7a8..c8d405f535b24 100644
--- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
+++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
@@ -4,26 +4,73 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\CurrencySymbol\Controller\Adminhtml\System\Currency;
+use Magento\Backend\App\Action\Context;
+use Magento\Backend\Model\View\Result\Redirect;
+use Magento\Backend\Model\Session as BackendSession;
+use Magento\CurrencySymbol\Controller\Adminhtml\System\Currency as CurrencyAction;
+use Magento\Directory\Model\Currency\Import\Factory as CurrencyImportFactory;
+use Magento\Directory\Model\Currency\Import\ImportInterface as CurrencyImport;
use Magento\Framework\App\Action\HttpGetActionInterface;
use Magento\Framework\App\Action\HttpPostActionInterface as HttpPostActionInterface;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Escaper;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Controller\ResultFactory;
-use Magento\CurrencySymbol\Controller\Adminhtml\System\Currency as CurrencyAction;
+use Magento\Framework\Registry;
+use Exception;
+/**
+ * Fetch rates controller.
+ */
class FetchRates extends CurrencyAction implements HttpGetActionInterface, HttpPostActionInterface
{
+ /**
+ * @var BackendSession
+ */
+ private $backendSession;
+
+ /**
+ * @var CurrencyImportFactory
+ */
+ private $currencyImportFactory;
+
+ /**
+ * @var Escaper
+ */
+ private $escaper;
+
+ /**
+ * @param Context $context
+ * @param Registry $coreRegistry
+ * @param BackendSession|null $backendSession
+ * @param CurrencyImportFactory|null $currencyImportFactory
+ * @param Escaper|null $escaper
+ */
+ public function __construct(
+ Context $context,
+ Registry $coreRegistry,
+ ?BackendSession $backendSession = null,
+ ?CurrencyImportFactory $currencyImportFactory = null,
+ ?Escaper $escaper = null
+ ) {
+ parent::__construct($context, $coreRegistry);
+ $this->backendSession = $backendSession ?: ObjectManager::getInstance()->get(BackendSession::class);
+ $this->currencyImportFactory = $currencyImportFactory ?: ObjectManager::getInstance()
+ ->get(CurrencyImportFactory::class);
+ $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
+ }
+
/**
* Fetch rates action
*
- * @return \Magento\Backend\Model\View\Result\Redirect
+ * @return Redirect
*/
- public function execute()
+ public function execute(): Redirect
{
- /** @var \Magento\Backend\Model\Session $backendSession */
- $backendSession = $this->_objectManager->get(\Magento\Backend\Model\Session::class);
try {
$service = $this->getRequest()->getParam('rate_services');
$this->_getSession()->setCurrencyRateService($service);
@@ -31,10 +78,9 @@ public function execute()
throw new LocalizedException(__('The Import Service is incorrect. Verify the service and try again.'));
}
try {
- /** @var \Magento\Directory\Model\Currency\Import\ImportInterface $importModel */
- $importModel = $this->_objectManager->get(\Magento\Directory\Model\Currency\Import\Factory::class)
- ->create($service);
- } catch (\Exception $e) {
+ /** @var CurrencyImport $importModel */
+ $importModel = $this->currencyImportFactory->create($service);
+ } catch (Exception $e) {
throw new LocalizedException(
__("The import model can't be initialized. Verify the model and try again.")
);
@@ -43,7 +89,8 @@ public function execute()
$errors = $importModel->getMessages();
if (sizeof($errors) > 0) {
foreach ($errors as $error) {
- $this->messageManager->addWarning($error);
+ $escapedError = $this->escaper->escapeHtml($error);
+ $this->messageManager->addWarning($escapedError);
}
$this->messageManager->addWarning(
__('Click "Save" to apply the rates we found.')
@@ -52,12 +99,12 @@ public function execute()
$this->messageManager->addSuccess(__('Click "Save" to apply the rates we found.'));
}
- $backendSession->setRates($rates);
- } catch (\Exception $e) {
+ $this->backendSession->setRates($rates);
+ } catch (Exception $e) {
$this->messageManager->addError($e->getMessage());
}
- /** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
+ /** @var Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
return $resultRedirect->setPath('adminhtml/*/');
}
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index 557dca9dd5621..6a1dea77671d5 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -196,12 +196,7 @@ private function validateResponse(array $response): bool
if (!isset($response['error'])) {
return true;
}
-
- $errorCodes = [
- 400 => __('No API Key was specified or an invalid API Key was specified.')
- ];
- $this->_messages[] = $errorCodes[$response['status']] ?? __('Currency rates can\'t be retrieved.');
-
+ $this->_messages[] = $response['error'] ?: __('Currency rates can\'t be retrieved.');
return false;
}
From 69710be9023f3af1927bb7b57f3460cb0388ddde Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Thu, 1 Aug 2019 13:43:22 +0300
Subject: [PATCH 0337/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix fatal error after importing with Currency Converter Api service
---
.../Directory/Model/Currency/Import/CurrencyConverterApi.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index 6a1dea77671d5..5f1603fab71c0 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -176,7 +176,7 @@ private function getServiceResponse($url, $retry = 0): array
'GET'
)->getBody();
- $response = json_decode($jsonResponse, true);
+ $response = json_decode($jsonResponse, true) ?: [];
} catch (Exception $e) {
if ($retry == 0) {
$response = $this->getServiceResponse($url, 1);
From 297c410ee2c0093cd459ba395a212696a447c817 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Tue, 13 Aug 2019 18:12:28 +0300
Subject: [PATCH 0338/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Add unit test
---
.../Import/CurrencyConverterApiTest.php | 193 ++++++++++++++++++
1 file changed, 193 insertions(+)
create mode 100644 app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php
diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php
new file mode 100644
index 0000000000000..ad3b646c589a3
--- /dev/null
+++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php
@@ -0,0 +1,193 @@
+currencyFactory = $this->getMockBuilder(CurrencyFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->httpClientFactory = $this->getMockBuilder(ZendClientFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
+ ->disableOriginalConstructor()
+ ->setMethods([])
+ ->getMock();
+
+ $objectManagerHelper = new ObjectManagerHelper($this);
+ $this->model = $objectManagerHelper->getObject(
+ CurrencyConverterApi::class,
+ [
+ 'currencyFactory' => $this->currencyFactory,
+ 'scopeConfig' => $this->scopeConfig,
+ 'httpClientFactory' => $this->httpClientFactory,
+ ]
+ );
+ }
+
+ /**
+ * Prepare CurrencyFactory mock.
+ */
+ private function prepareCurrencyFactoryMock(): void
+ {
+ $currencyFromList = ['USD'];
+ $currencyToList = ['EUR', 'UAH'];
+
+ /** @var Currency|MockObject $currency */
+ $currency = $this->getMockBuilder(Currency::class)->disableOriginalConstructor()->getMock();
+ $currency->expects($this->once())->method('getConfigBaseCurrencies')->willReturn($currencyFromList);
+ $currency->expects($this->once())->method('getConfigAllowCurrencies')->willReturn($currencyToList);
+
+ $this->currencyFactory->expects($this->atLeastOnce())->method('create')->willReturn($currency);
+ }
+
+ /**
+ * Prepare FetchRates test.
+ *
+ * @param string $responseBody
+ */
+ private function prepareFetchRatesTest(string $responseBody): void
+ {
+ $this->prepareCurrencyFactoryMock();
+
+ $this->scopeConfig->method('getValue')
+ ->withConsecutive(
+ ['currency/currencyconverterapi/api_key', 'store'],
+ ['currency/currencyconverterapi/timeout', 'store']
+ )
+ ->willReturnOnConsecutiveCalls('api_key', 100);
+
+ /** @var ZendClient|MockObject $httpClient */
+ $httpClient = $this->getMockBuilder(ZendClient::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ /** @var DataObject|MockObject $currencyMock */
+ $httpResponse = $this->getMockBuilder(DataObject::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['getBody'])
+ ->getMock();
+
+ $this->httpClientFactory->expects($this->once())->method('create')->willReturn($httpClient);
+ $httpClient->expects($this->once())->method('setUri')->willReturnSelf();
+ $httpClient->expects($this->once())->method('setConfig')->willReturnSelf();
+ $httpClient->expects($this->once())->method('request')->willReturn($httpResponse);
+ $httpResponse->expects($this->once())->method('getBody')->willReturn($responseBody);
+ }
+
+ /**
+ * Test Fetch Rates
+ *
+ * @return void
+ */
+ public function testFetchRates(): void
+ {
+ $expectedCurrencyRateList = ['USD' => ['EUR' => 0.891285, 'UAH' => 26.16]];
+ $responseBody = '{"USD_EUR":0.891285,"USD_UAH":26.16,"USD_USD":1}';
+ $this->prepareFetchRatesTest($responseBody);
+
+ self::assertEquals($expectedCurrencyRateList, $this->model->fetchRates());
+ }
+
+ /**
+ * Test FetchRates when Service Response is empty.
+ */
+ public function testFetchRatesWhenServiceResponseIsEmpty(): void
+ {
+ $responseBody = '';
+ $expectedCurrencyRateList = ['USD' => ['EUR' => null, 'UAH' => null]];
+ $cantRetrieveCurrencyMessage = "We can't retrieve a rate from "
+ . "https://free.currconv.com/api/v7/convert?apiKey=api_key&q=USD_EUR,USD_UAH&compact=ultra for %s.";
+ $this->prepareFetchRatesTest($responseBody);
+
+ self::assertEquals($expectedCurrencyRateList, $this->model->fetchRates());
+
+ $messages = $this->model->getMessages();
+ self::assertEquals(sprintf($cantRetrieveCurrencyMessage, 'EUR'), (string) $messages[0]);
+ self::assertEquals(sprintf($cantRetrieveCurrencyMessage, 'UAH'), (string) $messages[1]);
+ }
+
+ /**
+ * Test FetchRates when Service Response has error.
+ */
+ public function testFetchRatesWhenServiceResponseHasError(): void
+ {
+ $serviceErrorMessage = 'Service error';
+ $responseBody = sprintf('{"error":"%s"}', $serviceErrorMessage);
+ $expectedCurrencyRateList = ['USD' => ['EUR' => null, 'UAH' => null]];
+ $this->prepareFetchRatesTest($responseBody);
+
+ self::assertEquals($expectedCurrencyRateList, $this->model->fetchRates());
+
+ $messages = $this->model->getMessages();
+ self::assertEquals($serviceErrorMessage, (string) $messages[0]);
+ }
+
+ /**
+ * Test FetchRates when Service URL is empty.
+ */
+ public function testFetchRatesWhenServiceUrlIsEmpty(): void
+ {
+ $this->prepareCurrencyFactoryMock();
+
+ $this->scopeConfig->method('getValue')
+ ->withConsecutive(
+ ['currency/currencyconverterapi/api_key', 'store'],
+ ['currency/currencyconverterapi/timeout', 'store']
+ )
+ ->willReturnOnConsecutiveCalls('', 100);
+
+ $expectedCurrencyRateList = ['USD' => ['EUR' => null, 'UAH' => null]];
+ self::assertEquals($expectedCurrencyRateList, $this->model->fetchRates());
+
+ $noApiKeyErrorMessage = 'No API Key was specified or an invalid API Key was specified.';
+ $messages = $this->model->getMessages();
+ self::assertEquals($noApiKeyErrorMessage, (string) $messages[0]);
+ }
+}
From 4c71e553e3fac58129121f4590ef6736d994777c Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Tue, 20 Aug 2019 15:16:23 +0300
Subject: [PATCH 0339/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix missed currency rate error message.
---
.../Directory/Model/Currency/Import/CurrencyConverterApi.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index 5f1603fab71c0..f27f3fb6fdf5a 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -105,7 +105,7 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
if ($currencyFrom === $to) {
$data[$currencyFrom][$to] = $this->_numberFormat(1);
} else {
- if (empty($response)) {
+ if (!isset($response[$currencyFrom . '_' . $to])) {
$this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $to);
$data[$currencyFrom][$to] = null;
} else {
From 83222362711390121159a49d4657c5a144b4deba Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Tue, 27 Aug 2019 14:17:22 +0300
Subject: [PATCH 0340/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Exclude service key from absent rate error message.
---
.../Currency/Import/CurrencyConverterApi.php | 23 +++++++++++++++-
.../Model/Currency/Import/FixerIo.php | 26 ++++++++++++++++++-
.../Import/CurrencyConverterApiTest.php | 2 +-
.../Model/Currency/Import/FixerIoTest.php | 2 +-
4 files changed, 49 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index f27f3fb6fdf5a..e213b09404a1d 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -39,6 +39,11 @@ class CurrencyConverterApi extends AbstractImport
*/
private $scopeConfig;
+ /**
+ * @var string
+ */
+ private $currencyConverterServiceHost = '';
+
/**
* @param CurrencyFactory $currencyFactory
* @param ScopeConfig $scopeConfig
@@ -106,7 +111,8 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
$data[$currencyFrom][$to] = $this->_numberFormat(1);
} else {
if (!isset($response[$currencyFrom . '_' . $to])) {
- $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $to);
+ $serviceHost = $this->getServiceHost($url);
+ $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $serviceHost, $to);
$data[$currencyFrom][$to] = null;
} else {
$data[$currencyFrom][$to] = $this->_numberFormat(
@@ -119,6 +125,21 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
return $data;
}
+ /**
+ * Get currency converter service host.
+ *
+ * @param string $url
+ * @return string
+ */
+ private function getServiceHost(string $url): string
+ {
+ if (!$this->currencyConverterServiceHost) {
+ $this->currencyConverterServiceHost = parse_url($url, PHP_URL_SCHEME) . '://'
+ . parse_url($url, PHP_URL_HOST);
+ }
+ return $this->currencyConverterServiceHost;
+ }
+
/**
* Return service URL.
*
diff --git a/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php b/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php
index af49d6daaf379..6fd98cbc63c6b 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Directory\Model\Currency\Import;
use Magento\Store\Model\ScopeInterface;
@@ -32,6 +34,11 @@ class FixerIo extends AbstractImport
*/
private $scopeConfig;
+ /**
+ * @var string
+ */
+ private $currencyConverterServiceHost = '';
+
/**
* Initialize dependencies
*
@@ -73,6 +80,7 @@ public function fetchRates()
*/
protected function _convert($currencyFrom, $currencyTo)
{
+ return 1;
}
/**
@@ -116,7 +124,8 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
$data[$currencyFrom][$currencyTo] = $this->_numberFormat(1);
} else {
if (empty($response['rates'][$currencyTo])) {
- $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $url, $currencyTo);
+ $serviceHost = $this->getServiceHost($url);
+ $this->_messages[] = __('We can\'t retrieve a rate from %1 for %2.', $serviceHost, $currencyTo);
$data[$currencyFrom][$currencyTo] = null;
} else {
$data[$currencyFrom][$currencyTo] = $this->_numberFormat(
@@ -198,4 +207,19 @@ private function makeEmptyResponse(array $currenciesTo): array
{
return array_fill_keys($currenciesTo, null);
}
+
+ /**
+ * Get currency converter service host.
+ *
+ * @param string $url
+ * @return string
+ */
+ private function getServiceHost(string $url): string
+ {
+ if (!$this->currencyConverterServiceHost) {
+ $this->currencyConverterServiceHost = parse_url($url, PHP_URL_SCHEME) . '://'
+ . parse_url($url, PHP_URL_HOST);
+ }
+ return $this->currencyConverterServiceHost;
+ }
}
diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php
index ad3b646c589a3..797f7b73f33be 100644
--- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php
+++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/CurrencyConverterApiTest.php
@@ -143,7 +143,7 @@ public function testFetchRatesWhenServiceResponseIsEmpty(): void
$responseBody = '';
$expectedCurrencyRateList = ['USD' => ['EUR' => null, 'UAH' => null]];
$cantRetrieveCurrencyMessage = "We can't retrieve a rate from "
- . "https://free.currconv.com/api/v7/convert?apiKey=api_key&q=USD_EUR,USD_UAH&compact=ultra for %s.";
+ . "https://free.currconv.com for %s.";
$this->prepareFetchRatesTest($responseBody);
self::assertEquals($expectedCurrencyRateList, $this->model->fetchRates());
diff --git a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php
index 7efcf0d62712a..3147ac6ca2b91 100644
--- a/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php
+++ b/app/code/Magento/Directory/Test/Unit/Model/Currency/Import/FixerIoTest.php
@@ -74,7 +74,7 @@ public function testFetchRates(): void
$responseBody = '{"success":"true","base":"USD","date":"2015-10-07","rates":{"EUR":0.9022}}';
$expectedCurrencyRateList = ['USD' => ['EUR' => 0.9022, 'UAH' => null]];
$message = "We can't retrieve a rate from "
- . "http://data.fixer.io/api/latest?access_key=api_key&base=USD&symbols=EUR,UAH for UAH.";
+ . "http://data.fixer.io for UAH.";
$this->scopeConfig->method('getValue')
->withConsecutive(
From 865aa01e832eeb05e927f21d142848d00f6d9adc Mon Sep 17 00:00:00 2001
From: Lusine Papyan
Date: Wed, 11 Sep 2019 16:59:31 +0400
Subject: [PATCH 0341/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working - Exclude service key from absent rate error message.
- Added automated test script
---
.../AdminCurrencyRatesActionGroup.xml | 24 +++++
.../StorefrontCurrencyRatesActionGroup.xml | 20 +++++
.../Test/Mftf/Page/AdminCurrencyRatesPage.xml | 14 +++
.../Section/AdminCurrencyRatesSection.xml | 17 ++++
.../StorefrontSwitchCurrencyRatesSection.xml | 16 ++++
...nCurrencyConverterAPIConfigurationTest.xml | 87 +++++++++++++++++++
6 files changed, 178 insertions(+)
create mode 100644 app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml
create mode 100644 app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml
create mode 100644 app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml
create mode 100644 app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml
create mode 100644 app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml
create mode 100644 app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml
new file mode 100644
index 0000000000000..4898f731bc703
--- /dev/null
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml
new file mode 100644
index 0000000000000..2f6d1df102d06
--- /dev/null
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml
new file mode 100644
index 0000000000000..d31dd71d474bb
--- /dev/null
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Page/AdminCurrencyRatesPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml
new file mode 100644
index 0000000000000..39d059ad4bd2f
--- /dev/null
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml
new file mode 100644
index 0000000000000..43512796a134d
--- /dev/null
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml
new file mode 100644
index 0000000000000..45eb398a851a2
--- /dev/null
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml
@@ -0,0 +1,87 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 37a01043ad361d8f75913dc95742232267779150 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Fri, 13 Sep 2019 16:18:27 +0300
Subject: [PATCH 0342/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix static tests errors.
---
.../Controller/Adminhtml/System/Currency/FetchRates.php | 2 +-
.../Directory/Model/Currency/Import/CurrencyConverterApi.php | 2 ++
app/code/Magento/Directory/Model/Currency/Import/FixerIo.php | 4 +++-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
index c8d405f535b24..2b5e68eba1a25 100644
--- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
+++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
@@ -87,7 +87,7 @@ public function execute(): Redirect
}
$rates = $importModel->fetchRates();
$errors = $importModel->getMessages();
- if (sizeof($errors) > 0) {
+ if (count($errors) > 0) {
foreach ($errors as $error) {
$escapedError = $this->escaper->escapeHtml($error);
$this->messageManager->addWarning($escapedError);
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index e213b09404a1d..ff1c43cb2be62 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -134,7 +134,9 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
private function getServiceHost(string $url): string
{
if (!$this->currencyConverterServiceHost) {
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
$this->currencyConverterServiceHost = parse_url($url, PHP_URL_SCHEME) . '://'
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
. parse_url($url, PHP_URL_HOST);
}
return $this->currencyConverterServiceHost;
diff --git a/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php b/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php
index 6fd98cbc63c6b..29cdbabb9b993 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/FixerIo.php
@@ -106,7 +106,7 @@ private function convertBatch(array $data, string $currencyFrom, array $currenci
[$accessKey, $currencyFrom, $currenciesStr],
self::CURRENCY_CONVERTER_URL
);
-
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
set_time_limit(0);
try {
$response = $this->getServiceResponse($url);
@@ -217,7 +217,9 @@ private function makeEmptyResponse(array $currenciesTo): array
private function getServiceHost(string $url): string
{
if (!$this->currencyConverterServiceHost) {
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
$this->currencyConverterServiceHost = parse_url($url, PHP_URL_SCHEME) . '://'
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
. parse_url($url, PHP_URL_HOST);
}
return $this->currencyConverterServiceHost;
From 17a86ef452b75cddb50e65e2e1c91c9061c49e58 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Thu, 19 Sep 2019 20:25:29 +0300
Subject: [PATCH 0343/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Added lazy loading of service url.
---
.../Currency/Import/CurrencyConverterApi.php | 43 +++++++++++--------
1 file changed, 25 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index ff1c43cb2be62..3f154113cb3fe 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -44,6 +44,11 @@ class CurrencyConverterApi extends AbstractImport
*/
private $currencyConverterServiceHost = '';
+ /**
+ * @var string
+ */
+ private $serviceUrl = '';
+
/**
* @param CurrencyFactory $currencyFactory
* @param ScopeConfig $scopeConfig
@@ -151,25 +156,27 @@ private function getServiceHost(string $url): string
*/
private function getServiceURL(string $currencyFrom, array $currenciesTo): string
{
- // Get access key
- $accessKey = $this->scopeConfig->getValue('currency/currencyconverterapi/api_key', ScopeInterface::SCOPE_STORE);
- if (empty($accessKey)) {
- $this->_messages[] = __('No API Key was specified or an invalid API Key was specified.');
- return '';
- }
-
- // Get currency rates request
- $currencyQueryParts = [];
- foreach ($currenciesTo as $currencyTo) {
- $currencyQueryParts[] = sprintf('%s_%s', $currencyFrom, $currencyTo);
+ if (!$this->serviceUrl) {
+ // Get access key
+ $accessKey = $this->scopeConfig
+ ->getValue('currency/currencyconverterapi/api_key', ScopeInterface::SCOPE_STORE);
+ if (empty($accessKey)) {
+ $this->_messages[] = __('No API Key was specified or an invalid API Key was specified.');
+ return '';
+ }
+ // Get currency rates request
+ $currencyQueryParts = [];
+ foreach ($currenciesTo as $currencyTo) {
+ $currencyQueryParts[] = sprintf('%s_%s', $currencyFrom, $currencyTo);
+ }
+ $currencyRates = implode(',', $currencyQueryParts);
+ $this->serviceUrl = str_replace(
+ ['{{ACCESS_KEY}}', '{{CURRENCY_RATES}}'],
+ [$accessKey, $currencyRates],
+ self::CURRENCY_CONVERTER_URL
+ );
}
- $currencyRates = implode(',', $currencyQueryParts);
-
- return str_replace(
- ['{{ACCESS_KEY}}', '{{CURRENCY_RATES}}'],
- [$accessKey, $currencyRates],
- self::CURRENCY_CONVERTER_URL
- );
+ return $this->serviceUrl;
}
/**
From 911a7fb9c7879c84cdcb9e78e71ba8daffbd8fff Mon Sep 17 00:00:00 2001
From: natalia
Date: Thu, 26 Sep 2019 12:51:36 +0300
Subject: [PATCH 0344/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working - Exclude service key from absent rate error message.
- Fixed MFTF
---
.../Test/AdminCurrencyConverterAPIConfigurationTest.xml | 8 --------
1 file changed, 8 deletions(-)
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml
index 45eb398a851a2..6232f59bb839a 100644
--- a/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Test/AdminCurrencyConverterAPIConfigurationTest.xml
@@ -24,12 +24,10 @@
-
-
@@ -38,16 +36,13 @@
-
-
-
@@ -61,7 +56,6 @@
-
@@ -73,11 +67,9 @@
-
-
From f3a3a81709765ccd6d0a121d970f56a929fc861c Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 10 Oct 2019 12:59:39 -0500
Subject: [PATCH 0345/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 38 ++++++++++++++++++-
1 file changed, 37 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index a434d337f00c2..a91efbba87f17 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -242,7 +242,21 @@ public function __construct(
*/
public function reindexById($id)
{
- $this->reindexByIds([$id]);
+ try {
+ $this->cleanProductIndex([$id]);
+
+ $products = $this->productLoader->getProducts([$id]);
+ $product = array_values($products)[0];
+ $activeRules = $this->getActiveRules();
+ $this->applyRules($activeRules, $product);
+
+ $this->reindexRuleGroupWebsite->execute();
+ } catch (\Exception $e) {
+ $this->critical($e);
+ throw new \Magento\Framework\Exception\LocalizedException(
+ __('Catalog rule indexing failed. See details in exception log.')
+ );
+ }
}
/**
@@ -447,6 +461,28 @@ protected function applyRule(Rule $rule, $product)
return $this;
}
+ /**
+ * Apply rules
+ *
+ * @param RuleCollection $ruleCollection
+ * @param Product $product
+ * @return void
+ */
+ private function applyRules(RuleCollection $ruleCollection, Product $product): void
+ {
+ foreach ($ruleCollection as $rule) {
+ if (!$rule->validate($product)) {
+ continue;
+ }
+
+ $websiteIds = array_intersect($product->getWebsiteIds(), $rule->getWebsiteIds());
+ $this->assignProductToRule($rule, $product->getId(), $websiteIds);
+ }
+
+ $this->cleanProductPriceIndex([$product->getId()]);
+ $this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
+ }
+
/**
* Retrieve table name
*
From 34e097500aad9eae67b09d988eaa033ea4614d67 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Thu, 10 Oct 2019 13:16:51 -0500
Subject: [PATCH 0346/1978] MC-20649: Integration tests for store promotions on
quote
- code clean up
---
.../PlaceOrderWithStorePromotionsTest.php | 66 ++++++++++---------
1 file changed, 34 insertions(+), 32 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index 7239b7134ccaa..8ef212a73dd14 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -15,6 +15,7 @@
use Magento\GraphQl\Quote\GetMaskedQuoteIdByReservedOrderId;
use Magento\GraphQl\Service\GraphQlRequest;
use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Quote\Model\Quote;
use Magento\SalesRule\Api\RuleRepositoryInterface;
use Magento\SalesRule\Model\Converter\ToModel;
use Magento\SalesRule\Model\Rule;
@@ -26,6 +27,7 @@
*
* @magentoAppArea graphql
* @magentoDbIsolation disabled
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class PlaceOrderWithStorePromotionsTest extends TestCase
{
@@ -47,6 +49,12 @@ class PlaceOrderWithStorePromotionsTest extends TestCase
/** @var SerializerInterface */
private $jsonSerializer;
+ /** @var CartRepositoryInterface */
+ private $quoteRepository;
+
+ /** @var SearchCriteriaBuilder */
+ private $criteriaBuilder;
+
protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
@@ -56,6 +64,8 @@ protected function setUp()
$this->resource = $this->objectManager->get(ResourceConnection::class);
$this->connection = $this->resource->getConnection();
$this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
+ $this->quoteRepository = $this->objectManager->get(CartRepositoryInterface::class);
+ $this->criteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
}
/**
@@ -75,7 +85,7 @@ protected function setUp()
*
* @return void
*/
- public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules(): void
+ public function testResolvePlaceOrderWithProductHavingCartPromotion(): void
{
$categoryId = 56;
$reservedOrderId = 'test_quote';
@@ -124,42 +134,19 @@ public function testResolvePlaceOrderWithMultipleProductsAndMultipleCartRules():
'TestRule_Label',
$this->jsonSerializer->unserialize($serializedCartDiscount)[$salesRuleId]['rule']
);
+ $quote = $this->getQuote();
+ $quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
+ $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getAmount());
+ $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseAmount());
+ $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getOriginalAmount());
+ $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseOriginalAmount());
+ $this->assertEquals('TestRule_Label', $quoteAddressItemDiscount[$salesRuleId]['rule']);
+
$addressType = 'shipping';
$selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
->where('address_type = ?', $addressType);
$resultFromQuoteAddress = $this->connection->fetchRow($selectFromQuoteAddress);
$this->assertNotEmpty($resultFromQuoteAddress, 'No record found in quote_address table');
- $serializedDiscountQuoteAddress = $resultFromQuoteAddress['discounts'];
-// $this->assertTrue(
-// array_key_exists(
-// $salesRuleId,
-// $this->jsonSerializer->unserialize(
-// $serializedDiscountQuoteAddress
-// )
-// )
-// );
- /*$this->assertEquals(
- 10,
- json_decode($this->jsonSerializer->unserialize(
- $serializedDiscountQuoteAddress
- )[$salesRuleId]['discount'], true)['amount']
- );*/
-
-// $this->assertEquals(
-// 10,
-// json_decode(
-// $this->jsonSerializer->unserialize(
-// $resultFromQuoteAddress['discounts']
-// )
-// [$salesRuleId]['discount'],
-// true
-// )
-// ['baseAmount']
-// );
- $this->assertEquals(
- 'TestRule_Label',
- $this->jsonSerializer->unserialize($serializedDiscountQuoteAddress)[$salesRuleId]['rule']
- );
}
/**
@@ -187,4 +174,19 @@ private function getSalesRule(string $name): Rule
return $converter->toModel($rule);
}
+
+ /**
+ * @return Quote
+ */
+ private function getQuote(): Quote
+ {
+ $searchCriteria = $this->criteriaBuilder->addFilter('reserved_order_id', 'test_quote')->create();
+ $carts = $this->quoteRepository->getList($searchCriteria)
+ ->getItems();
+ if (!$carts) {
+ throw new \RuntimeException('Cart not found');
+ }
+
+ return array_shift($carts);
+ }
}
From 7d05cf3c771929d66798e404aa09fd9053a9a2fe Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Fri, 11 Oct 2019 00:17:31 +0300
Subject: [PATCH 0347/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix merge conflict with 2.3-develop
---
.../Adminhtml/System/Currency/FetchRates.php | 11 +++++------
.../Model/Currency/Import/CurrencyConverterApi.php | 2 +-
app/code/Magento/Directory/etc/adminhtml/system.xml | 2 ++
3 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
index 2b5e68eba1a25..9140807121b83 100644
--- a/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
+++ b/app/code/Magento/CurrencySymbol/Controller/Adminhtml/System/Currency/FetchRates.php
@@ -1,6 +1,5 @@
getRequest()->getParam('rate_services');
@@ -90,18 +89,18 @@ public function execute(): Redirect
if (count($errors) > 0) {
foreach ($errors as $error) {
$escapedError = $this->escaper->escapeHtml($error);
- $this->messageManager->addWarning($escapedError);
+ $this->messageManager->addWarningMessage($escapedError);
}
- $this->messageManager->addWarning(
+ $this->messageManager->addWarningMessage(
__('Click "Save" to apply the rates we found.')
);
} else {
- $this->messageManager->addSuccess(__('Click "Save" to apply the rates we found.'));
+ $this->messageManager->addSuccessMessage(__('Click "Save" to apply the rates we found.'));
}
$this->backendSession->setRates($rates);
} catch (Exception $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
}
/** @var Redirect $resultRedirect */
diff --git a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
index 3f154113cb3fe..8e27b9905ed6f 100644
--- a/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
+++ b/app/code/Magento/Directory/Model/Currency/Import/CurrencyConverterApi.php
@@ -67,7 +67,7 @@ public function __construct(
/**
* @inheritdoc
*/
- public function fetchRates(): array
+ public function fetchRates()
{
$data = [];
$currencies = $this->_getCurrencyCodes();
diff --git a/app/code/Magento/Directory/etc/adminhtml/system.xml b/app/code/Magento/Directory/etc/adminhtml/system.xml
index eb3f2a0e9ef2b..93bd5f1d6b6d3 100644
--- a/app/code/Magento/Directory/etc/adminhtml/system.xml
+++ b/app/code/Magento/Directory/etc/adminhtml/system.xml
@@ -43,6 +43,7 @@
Connection Timeout in Seconds
+ validate-zero-or-greater validate-number
@@ -54,6 +55,7 @@
Connection Timeout in Seconds
+ validate-zero-or-greater validate-number
From 90557f9c2a0c1720792d4747c9473bd2647a2ec9 Mon Sep 17 00:00:00 2001
From: Alex Taranovsky
Date: Wed, 9 Oct 2019 15:17:18 +0300
Subject: [PATCH 0348/1978] magento/graphql-ce#977: [Test coverage] Cover
exceptions in AssignShippingAddressToCart, AssignBillingAddressToCart
---
.../Model/Cart/AssignBillingAddressToCart.php | 4 +-
.../Cart/AssignShippingAddressToCart.php | 4 +-
.../Customer/SetBillingAddressOnCartTest.php | 53 +++++++++++++++++++
.../Customer/SetShippingAddressOnCartTest.php | 43 +++++++++++++++
4 files changed, 100 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php
index dd6478b4873c6..95c46cdcca5dc 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignBillingAddressToCart.php
@@ -7,7 +7,7 @@
namespace Magento\QuoteGraphQl\Model\Cart;
-use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
@@ -52,7 +52,7 @@ public function execute(
$this->billingAddressManagement->assign($cart->getId(), $billingAddress, $useForShipping);
} catch (NoSuchEntityException $e) {
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
- } catch (LocalizedException $e) {
+ } catch (InputException $e) {
throw new GraphQlInputException(__($e->getMessage()), $e);
}
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php
index 527999b245a4c..4dbcfad31e84c 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/AssignShippingAddressToCart.php
@@ -7,7 +7,7 @@
namespace Magento\QuoteGraphQl\Model\Cart;
-use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
@@ -50,7 +50,7 @@ public function execute(
$this->shippingAddressManagement->assign($cart->getId(), $shippingAddress);
} catch (NoSuchEntityException $e) {
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
- } catch (LocalizedException $e) {
+ } catch (InputException $e) {
throw new GraphQlInputException(__($e->getMessage()), $e);
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 011930e723273..16f6510dbfa24 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -696,6 +696,59 @@ public function testSetBillingAddressWithLowerCaseCountry()
$this->assertNewAddressFields($billingAddressResponse);
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testWithInvalidBillingAddressInput()
+ {
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
+
+ $query = <<graphQlMutation($query, [], '', $this->getHeaderMap());
+ }
+
/**
* Verify the all the whitelisted fields for a New Address Object
*
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
index e74b7c41b3983..e24de031b4a87 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
@@ -657,6 +657,49 @@ public function testSetShippingAddressWithLowerCaseCountry()
$this->assertEquals('CA', $address['region']['code']);
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testWithInvalidShippingAddressesInput()
+ {
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
+
+ $query = <<graphQlMutation($query, [], '', $this->getHeaderMap());
+ }
+
/**
* Verify the all the whitelisted fields for a New Address Object
*
From 929b2b9437afedf8104076e8056e99fdcad15839 Mon Sep 17 00:00:00 2001
From: Yauhen_Lyskavets
Date: Fri, 11 Oct 2019 00:45:31 +0300
Subject: [PATCH 0349/1978] MAGETWO-94919: Non of predefined currecy rates
providers is working
- Fix merge conflict with MAGETWO-67450-rebase
---
.../ActionGroup/AdminCurrencyRatesActionGroup.xml | 11 +++++++++++
.../StorefrontCurrencyRatesActionGroup.xml | 9 +++++++++
.../Test/Mftf/Section/AdminCurrencyRatesSection.xml | 5 +++--
.../Section/StorefrontSwitchCurrencyRatesSection.xml | 1 +
4 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml
index 4898f731bc703..a2e25cf858a6e 100644
--- a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/AdminCurrencyRatesActionGroup.xml
@@ -21,4 +21,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml
index 2f6d1df102d06..02cf23c323a8a 100644
--- a/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/ActionGroup/StorefrontCurrencyRatesActionGroup.xml
@@ -17,4 +17,13 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml
index 39d059ad4bd2f..bc80a51c41c47 100644
--- a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/AdminCurrencyRatesSection.xml
@@ -9,9 +9,10 @@
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml
index 43512796a134d..ff922421e5db7 100644
--- a/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml
+++ b/app/code/Magento/CurrencySymbol/Test/Mftf/Section/StorefrontSwitchCurrencyRatesSection.xml
@@ -10,6 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
From ff1b35037cdbc806b7e9a6f0597892aa87a4011e Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 10 Oct 2019 18:29:34 -0500
Subject: [PATCH 0350/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../CatalogRule/Model/Indexer/IndexBuilder.php | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index a91efbba87f17..899c31c40db8f 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -246,9 +246,10 @@ public function reindexById($id)
$this->cleanProductIndex([$id]);
$products = $this->productLoader->getProducts([$id]);
- $product = array_values($products)[0];
$activeRules = $this->getActiveRules();
- $this->applyRules($activeRules, $product);
+ foreach ($products as $product) {
+ $this->applyRules($activeRules, $product);
+ }
$this->reindexRuleGroupWebsite->execute();
} catch (\Exception $e) {
@@ -386,11 +387,11 @@ protected function cleanByIds($productIds)
* Assign product to rule
*
* @param Rule $rule
- * @param int $productId
+ * @param int $productEntityId
* @param array $websiteIds
* @return void
*/
- private function assignProductToRule(Rule $rule, int $productId, array $websiteIds): void
+ private function assignProductToRule(Rule $rule, int $productEntityId, array $websiteIds): void
{
$ruleId = (int) $rule->getId();
$ruleProductTable = $this->getTable('catalogrule_product');
@@ -398,7 +399,7 @@ private function assignProductToRule(Rule $rule, int $productId, array $websiteI
$ruleProductTable,
[
'rule_id = ?' => $ruleId,
- 'product_id = ?' => $productId,
+ 'product_id = ?' => $productEntityId,
]
);
@@ -420,7 +421,7 @@ private function assignProductToRule(Rule $rule, int $productId, array $websiteI
'to_time' => $toTime,
'website_id' => $websiteId,
'customer_group_id' => $customerGroupId,
- 'product_id' => $productId,
+ 'product_id' => $productEntityId,
'action_operator' => $actionOperator,
'action_amount' => $actionAmount,
'action_stop' => $actionStop,
From dec4f2abd3dbd7cfdc30468ebe9aadb780660342 Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Fri, 11 Oct 2019 09:38:56 +0300
Subject: [PATCH 0351/1978] MC-20449: [Integration Test]Hide product images via
hide_from_product_page attribute during import CSV
---
.../Model/Import/ProductTest.php | 115 +++++++++++++++---
.../_files/hide_from_product_page_images.csv | 2 +
.../_files/import_with_filesystem_images.php | 15 ++-
3 files changed, 112 insertions(+), 20 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/hide_from_product_page_images.csv
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 553242f0daec6..0160d13c57499 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -917,15 +917,15 @@ public function testSaveMediaImageError()
*/
public static function mediaImportImageFixture()
{
- /** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
- $mediaDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+ /** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */
+ $varDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\Filesystem::class
)->getDirectoryWrite(
- DirectoryList::MEDIA
+ DirectoryList::VAR_DIR
);
- $mediaDirectory->create('import');
- $dirPath = $mediaDirectory->getAbsolutePath('import');
+ $varDirectory->create('import' . DIRECTORY_SEPARATOR . 'images');
+ $dirPath = $varDirectory->getAbsolutePath('import' . DIRECTORY_SEPARATOR . 'images');
$items = [
[
@@ -968,13 +968,15 @@ public static function mediaImportImageFixture()
*/
public static function mediaImportImageFixtureRollback()
{
- /** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
- $mediaDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+ $fileSystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\Filesystem::class
- )->getDirectoryWrite(
- DirectoryList::MEDIA
);
- $mediaDirectory->delete('import');
+ /** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
+ $mediaDirectory = $fileSystem->getDirectoryWrite(DirectoryList::MEDIA);
+
+ /** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */
+ $varDirectory = $fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $varDirectory->delete('import' . DIRECTORY_SEPARATOR . 'images');
$mediaDirectory->delete('catalog');
}
@@ -983,13 +985,13 @@ public static function mediaImportImageFixtureRollback()
*/
public static function mediaImportImageFixtureError()
{
- /** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
- $mediaDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+ /** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */
+ $varDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\Filesystem::class
)->getDirectoryWrite(
- DirectoryList::MEDIA
+ DirectoryList::VAR_DIR
);
- $dirPath = $mediaDirectory->getAbsolutePath('import');
+ $dirPath = $varDirectory->getAbsolutePath('import' . DIRECTORY_SEPARATOR . 'images');
$items = [
[
'source' => __DIR__ . '/_files/magento_additional_image_error.jpg',
@@ -2133,8 +2135,13 @@ private function importDataForMediaTest(string $fileName, int $expectedErrors =
$uploader = $this->_model->getUploader();
$mediaPath = $appParams[DirectoryList::MEDIA][DirectoryList::PATH];
- $destDir = $directory->getRelativePath($mediaPath . '/catalog/product');
- $tmpDir = $directory->getRelativePath($mediaPath . '/import');
+ $varPath = $appParams[DirectoryList::VAR_DIR][DirectoryList::PATH];
+ $destDir = $directory->getRelativePath(
+ $mediaPath . DIRECTORY_SEPARATOR . 'catalog' . DIRECTORY_SEPARATOR . 'product'
+ );
+ $tmpDir = $directory->getRelativePath(
+ $varPath . DIRECTORY_SEPARATOR . 'import' . DIRECTORY_SEPARATOR . 'images'
+ );
$directory->create($destDir);
$this->assertTrue($uploader->setDestDir($destDir));
@@ -2581,4 +2588,80 @@ private function importFile(string $fileName): void
$this->_model->importData();
}
+
+ /**
+ * Hide product images via hide_from_product_page attribute during import CSV.
+ *
+ * @magentoAppIsolation enabled
+ * @magentoDataFixture mediaImportImageFixture
+ * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ */
+ public function testImagesAreHiddenAfterImport()
+ {
+ $expectedActiveImages = [
+ [
+ 'file' => '/m/a/magento_additional_image_one.jpg',
+ 'label' => 'Additional Image Label One',
+ 'disabled' => '0'
+ ],
+ [
+ 'file' => '/m/a/magento_additional_image_two.jpg',
+ 'label' => 'Additional Image Label Two',
+ 'disabled' => '0'
+ ],
+ ];
+
+ $expectedHiddenImage = [
+ 'file' => '/m/a/magento_image.jpg',
+ 'label' => 'Image Alt Text',
+ 'disabled' => '1'
+ ];
+ $expectedAllProductImages = array_merge(
+ [$expectedHiddenImage],
+ $expectedActiveImages
+ );
+
+ $this->importDataForMediaTest('hide_from_product_page_images.csv');
+ $actualAllProductImages = [];
+ $product = $this->getProductBySku('simple');
+
+// Check that new images are imported and existing image is disabled after import
+ $productMediaData = $product->getData('media_gallery');
+
+ if (is_array($productMediaData['images'])) {
+ $allProductImages = $productMediaData['images'];
+ $this->assertCount(3, $productMediaData['images'], 'Images are imported incorrect');
+
+ foreach($productMediaData['images'] as $image) {
+ $actualAllProductImages[] = [
+ 'file' => $image['file'],
+ 'label' => $image['label'],
+ 'disabled' => $image['disabled'],
+ ];
+ }
+ }
+
+ $this->assertEquals(
+ $expectedAllProductImages,
+ $actualAllProductImages,
+ 'Images statuses are incorrect after import'
+ );
+
+// Check that on storefront only enabled images are shown
+ $actualActiveImages = array_values($product->getMediaGalleryImages()->getItems());
+ $this->assertCount(2, $actualActiveImages);
+
+ foreach ($actualActiveImages as $actualActiveImage) {
+ $this->assertNotEquals(
+ $expectedHiddenImage['file'],
+ $actualActiveImage->getFile(),
+ 'Image should be hidden after import'
+ );
+ $this->assertNotEquals(
+ $expectedHiddenImage['label'],
+ $actualActiveImage->getLabel(),
+ 'Image should be hidden after import'
+ );
+ }
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/hide_from_product_page_images.csv b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/hide_from_product_page_images.csv
new file mode 100644
index 0000000000000..5902723ae5024
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/hide_from_product_page_images.csv
@@ -0,0 +1,2 @@
+sku,store_view_code,attribute_set_code,product_type,categories,product_websites,name,description,short_description,weight,product_online,tax_class_name,visibility,price,special_price,special_price_from_date,special_price_to_date,url_key,meta_title,meta_keywords,meta_description,base_image,base_image_label,small_image,small_image_label,thumbnail_image,thumbnail_image_label,swatch_image,swatch_image_label1,created_at,updated_at,new_from_date,new_to_date,display_product_options_in,map_price,msrp_price,map_enabled,gift_message_available,custom_design,custom_design_from,custom_design_to,custom_layout_update,page_layout,product_options_container,msrp_display_actual_price_type,country_of_manufacture,additional_attributes,qty,out_of_stock_qty,use_config_min_qty,is_qty_decimal,allow_backorders,use_config_backorders,min_cart_qty,use_config_min_sale_qty,max_cart_qty,use_config_max_sale_qty,is_in_stock,notify_on_stock_below,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,related_skus,crosssell_skus,upsell_skus,additional_images,additional_image_labels,hide_from_product_page,custom_options,bundle_price_type,bundle_sku_type,bundle_price_view,bundle_weight_type,bundle_values
+simple,,Default,simple,,base,Simple Product,,,,1,Taxable Goods,"Catalog, Search",10,,,,,meta title,meta keyword,meta description,magento_additional_image_one.jpg,Additional Image Label One,magento_additional_image_one.jpg,Small Additional Image Label One,magento_additional_image_one.jpg,Thumbnail Label,magento_additional_image_one.jpg,Additional Image Label One,,,,,Block after Info Column,,,,,,,,,,,,,"has_options=1,quantity_and_stock_status=In Stock,required_options=1",100,0,1,0,0,1,1,1,10000,1,1,1,1,1,0,1,1,0,0,0,1,,,,"magento_additional_image_one.jpg,magento_additional_image_two.jpg","Additional Image Label One,Additional Image Label Two",/m/a/magento_image.jpg,,,,,,
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images.php
index 04b3092c8fa8a..0ee59aedd8979 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images.php
@@ -4,16 +4,23 @@
* See COPYING.txt for license details.
*/
-/** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
-$mediaDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+/** @var \Magento\Framework\Filesystem $fileSystem */
+$fileSystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\Filesystem::class
-)->getDirectoryWrite(
+);
+/** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
+$mediaDirectory = $fileSystem->getDirectoryWrite(
\Magento\Framework\App\Filesystem\DirectoryList::MEDIA
);
+/** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */
+$varDirectory = $fileSystem->getDirectoryWrite(
+ \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR
+);
$path = 'catalog' . DIRECTORY_SEPARATOR . 'product';
+$varImagesPath = 'import' . DIRECTORY_SEPARATOR . 'images';
// Is required for using importDataForMediaTest method.
-$mediaDirectory->create('import');
+$varDirectory->create($varImagesPath);
$mediaDirectory->create($path);
$dirPath = $mediaDirectory->getAbsolutePath($path);
From 1cb0fde57d7961c739aa474c4c8bfe92ed22c15e Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Fri, 11 Oct 2019 12:34:31 +0300
Subject: [PATCH 0352/1978] MC-20449: [Integration Test]Hide product images via
hide_from_product_page attribute during import CSV
---
.../Magento/CatalogImportExport/Model/Import/ProductTest.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 0160d13c57499..8e6d47de39d71 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -2592,7 +2592,6 @@ private function importFile(string $fileName): void
/**
* Hide product images via hide_from_product_page attribute during import CSV.
*
- * @magentoAppIsolation enabled
* @magentoDataFixture mediaImportImageFixture
* @magentoDataFixture Magento/Catalog/_files/product_with_image.php
*/
@@ -2630,9 +2629,9 @@ public function testImagesAreHiddenAfterImport()
if (is_array($productMediaData['images'])) {
$allProductImages = $productMediaData['images'];
- $this->assertCount(3, $productMediaData['images'], 'Images are imported incorrect');
+ $this->assertCount(3, $allProductImages, 'Images are imported incorrect');
- foreach($productMediaData['images'] as $image) {
+ foreach ($allProductImages as $image) {
$actualAllProductImages[] = [
'file' => $image['file'],
'label' => $image['label'],
From 1e2226f9dc11c62a8881392f5bf7c944aa4b81cc Mon Sep 17 00:00:00 2001
From: Stsiapan Korf
Date: Fri, 11 Oct 2019 13:14:30 +0300
Subject: [PATCH 0353/1978] MAGETWO-98703: CSV file is not exported
- Fix conflict with mainline
---
app/code/Magento/ImportExport/i18n/en_US.csv | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/ImportExport/i18n/en_US.csv b/app/code/Magento/ImportExport/i18n/en_US.csv
index 7075c69a3c29c..581714787a150 100644
--- a/app/code/Magento/ImportExport/i18n/en_US.csv
+++ b/app/code/Magento/ImportExport/i18n/en_US.csv
@@ -124,3 +124,5 @@ Summary,Summary
"All existing product data is replaced with the imported new data. Exercise caution when replacing data. All existing product data will be completely cleared and all references in the system will be lost. ","All existing product data is replaced with the imported new data. Exercise caution when replacing data. All existing product data will be completely cleared and all references in the system will be lost. "
"Any entities in the import data that match existing entities in the database are deleted from the database.","Any entities in the import data that match existing entities in the database are deleted from the database."
"Message is added to queue, wait to get your file soon. Make sure your cron job is running to export the file","Message is added to queue, wait to get your file soon. Make sure your cron job is running to export the file"
+"Invalid data","Invalid data"
+"Invalid response","Invalid response"
From ee1807bbcd027f37f0d3460710c713f9793b5395 Mon Sep 17 00:00:00 2001
From: Serhii Balko
Date: Fri, 11 Oct 2019 13:34:14 +0300
Subject: [PATCH 0354/1978] MC-5233: DateTime product attributes support
---
.../AdminCreateSimpleProductWithDatetimeAttributeTest.xml | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
index 019baa4ac153d..6772e95b6ec27 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminCreateSimpleProductWithDatetimeAttributeTest.xml
@@ -45,13 +45,15 @@
+
+
+
+
-
-
From cbfb8fe35fd1b8494b89442c9ee952e35f034fd7 Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Fri, 11 Oct 2019 14:45:54 +0300
Subject: [PATCH 0355/1978] MC-20449: [Integration Test]Hide product images via
hide_from_product_page attribute during import CSV
---
.../CatalogImportExport/Model/Import/ProductTest.php | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 8e6d47de39d71..dbb1f0f9f81e3 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -2594,26 +2594,28 @@ private function importFile(string $fileName): void
*
* @magentoDataFixture mediaImportImageFixture
* @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ *
+ * @return void
*/
- public function testImagesAreHiddenAfterImport()
+ public function testImagesAreHiddenAfterImport(): void
{
$expectedActiveImages = [
[
'file' => '/m/a/magento_additional_image_one.jpg',
'label' => 'Additional Image Label One',
- 'disabled' => '0'
+ 'disabled' => '0',
],
[
'file' => '/m/a/magento_additional_image_two.jpg',
'label' => 'Additional Image Label Two',
- 'disabled' => '0'
+ 'disabled' => '0',
],
];
$expectedHiddenImage = [
'file' => '/m/a/magento_image.jpg',
'label' => 'Image Alt Text',
- 'disabled' => '1'
+ 'disabled' => '1',
];
$expectedAllProductImages = array_merge(
[$expectedHiddenImage],
From 3dbe4a75119493e2802a01275cd9ba6fd63405e0 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Fri, 11 Oct 2019 15:04:50 +0300
Subject: [PATCH 0356/1978] MC-20668: Edit custom options of simple product
---
.../Product/Save/UpdateCustomOptionsTest.php | 18 +++---
.../Create/DataProvider/Type/Date/Date.php | 3 +-
.../DataProvider/Type/Date/DateTime.php | 3 +-
.../Create/DataProvider/Type/Date/Time.php | 3 +-
.../Create/DataProvider/Type/File/File.php | 3 +-
.../DataProvider/Type/Select/Checkbox.php | 3 +-
.../DataProvider/Type/Select/DropDown.php | 3 +-
.../Type/Select/MultipleSelect.php | 3 +-
.../DataProvider/Type/Select/RadioButtons.php | 3 +-
.../Create/DataProvider/Type/Text/Area.php | 3 +-
.../Create/DataProvider/Type/Text/Field.php | 3 +-
.../Model/Product/UpdateCustomOptionsTest.php | 55 +++++++++++--------
12 files changed, 63 insertions(+), 40 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
index d2fbaca0eb807..e20200b9e9f7f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\Data\ProductCustomOptionInterfaceFactory;
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product\Option;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -60,10 +61,12 @@ protected function setUp()
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
public function testUpdateCustomOptionWithTypeField(array $optionData, array $updateData): void
{
$product = $this->productRepository->get('simple');
+ /** @var ProductCustomOptionInterface|Option $option */
$option = $this->optionRepositoryFactory->create(['data' => $optionData]);
$option->setProductSku($product->getSku());
$product->setOptions([$option]);
@@ -87,9 +90,9 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
'price' => $currentOption->getPrice(),
'price_type' => $currentOption->getPriceType(),
'is_use_default' => false,
- ]
- ]
- ]
+ ],
+ ],
+ ],
];
foreach ($updateData as $methodKey => $newValue) {
@@ -100,7 +103,7 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
'options' => [
0 => [
$methodKey => $newValue,
- ]
+ ],
],
],
]
@@ -114,12 +117,11 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
);
$updatedOptions = $this->optionRepository->getProductOptions($product);
$this->assertCount(1, $updatedOptions);
- /** @var ProductCustomOptionInterface $updatedOption */
+ /** @var ProductCustomOptionInterface|Option $updatedOption */
$updatedOption = reset($updatedOptions);
- $methodName = str_replace('_', '', ucwords($methodKey, '_'));
- $this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
+ $this->assertEquals($newValue, $updatedOption->getDataUsingMethod($methodKey));
$this->assertEquals($option->getOptionId(), $updatedOption->getOptionId());
- $this->assertNotEquals($option->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
+ $this->assertNotEquals($option->getDataUsingMethod($methodKey), $updatedOption->getDataUsingMethod($methodKey));
}
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
index 6feb20f56e536..21a544028bc1d 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
/**
@@ -19,6 +20,6 @@ class Date extends AbstractBase
*/
protected function getType(): string
{
- return 'date';
+ return ProductCustomOptionInterface::OPTION_GROUP_DATE;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php
index 3b978403dd29f..24073db54eadf 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
/**
@@ -19,6 +20,6 @@ class DateTime extends AbstractBase
*/
protected function getType(): string
{
- return 'date_time';
+ return ProductCustomOptionInterface::OPTION_TYPE_DATE_TIME;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php
index 6d2fda5b577a4..616ec8ec27ba4 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
/**
@@ -19,6 +20,6 @@ class Time extends AbstractBase
*/
protected function getType(): string
{
- return 'time';
+ return ProductCustomOptionInterface::OPTION_TYPE_TIME;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php
index 88a57df71f246..fc3aed94269f1 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\File;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
/**
@@ -85,6 +86,6 @@ public function getDataForUpdateOptions(): array
*/
protected function getType(): string
{
- return 'file';
+ return ProductCustomOptionInterface::OPTION_TYPE_FILE;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
index 32d55f45a9757..9f0a4d186315e 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
/**
@@ -19,6 +20,6 @@ class Checkbox extends AbstractSelect
*/
protected function getType(): string
{
- return 'checkbox';
+ return ProductCustomOptionInterface::OPTION_TYPE_CHECKBOX;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php
index 5a6e020354ec2..181219907e195 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
/**
@@ -19,6 +20,6 @@ class DropDown extends AbstractSelect
*/
protected function getType(): string
{
- return 'drop_down';
+ return ProductCustomOptionInterface::OPTION_TYPE_DROP_DOWN;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php
index 0fff75649188e..ddadd380609f0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
/**
@@ -19,6 +20,6 @@ class MultipleSelect extends AbstractSelect
*/
protected function getType(): string
{
- return 'multiple';
+ return ProductCustomOptionInterface::OPTION_TYPE_MULTIPLE;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php
index bf2921d403326..d753b969f911b 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
/**
@@ -19,6 +20,6 @@ class RadioButtons extends AbstractSelect
*/
protected function getType(): string
{
- return 'radio';
+ return ProductCustomOptionInterface::OPTION_TYPE_RADIO;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
index f0dc1f5d7dbcd..f212ed9e3c16a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\AbstractText;
/**
@@ -19,6 +20,6 @@ class Area extends AbstractText
*/
protected function getType(): string
{
- return 'area';
+ return ProductCustomOptionInterface::OPTION_TYPE_AREA;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php
index 71c6754f6b53a..11e9ce3c7b825 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php
@@ -7,6 +7,7 @@
namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text;
+use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\AbstractText;
/**
@@ -19,6 +20,6 @@ class Field extends AbstractText
*/
protected function getType(): string
{
- return 'field';
+ return ProductCustomOptionInterface::OPTION_TYPE_FIELD;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
index d2df225596148..7ee29bf45fe0d 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
@@ -13,6 +13,7 @@
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
use Magento\Catalog\Api\ProductCustomOptionRepositoryInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product\Option\Value;
use Magento\Framework\ObjectManagerInterface;
use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\StoreManagerInterface;
@@ -103,6 +104,7 @@ protected function tearDown()
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
public function testUpdateAreaCustomOption(array $optionData, array $updateData): void
{
@@ -118,6 +120,7 @@ public function testUpdateAreaCustomOption(array $optionData, array $updateData)
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
public function testUpdateFileCustomOption(array $optionData, array $updateData): void
{
@@ -133,6 +136,7 @@ public function testUpdateFileCustomOption(array $optionData, array $updateData)
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
public function testUpdateDateCustomOption(array $optionData, array $updateData): void
{
@@ -148,6 +152,7 @@ public function testUpdateDateCustomOption(array $optionData, array $updateData)
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
public function testUpdateDateTimeCustomOption(array $optionData, array $updateData): void
{
@@ -163,6 +168,7 @@ public function testUpdateDateTimeCustomOption(array $optionData, array $updateD
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
public function testUpdateTimeCustomOption(array $optionData, array $updateData): void
{
@@ -180,6 +186,7 @@ public function testUpdateTimeCustomOption(array $optionData, array $updateData)
* @param array $optionValueData
* @param array $updateOptionData
* @param array $updateOptionValueData
+ * @return void
*/
public function testUpdateDropDownCustomOption(
array $optionData,
@@ -206,6 +213,7 @@ public function testUpdateDropDownCustomOption(
* @param array $optionValueData
* @param array $updateOptionData
* @param array $updateOptionValueData
+ * @return void
*/
public function testUpdateRadioButtonsCustomOption(
array $optionData,
@@ -232,6 +240,7 @@ public function testUpdateRadioButtonsCustomOption(
* @param array $optionValueData
* @param array $updateOptionData
* @param array $updateOptionValueData
+ * @return void
*/
public function testUpdateCheckboxCustomOption(
array $optionData,
@@ -258,6 +267,7 @@ public function testUpdateCheckboxCustomOption(
* @param array $optionValueData
* @param array $updateOptionData
* @param array $updateOptionValueData
+ * @return void
*/
public function testUpdateMultipleSelectCustomOption(
array $optionData,
@@ -278,6 +288,7 @@ public function testUpdateMultipleSelectCustomOption(
*
* @param array $optionData
* @param array $updateData
+ * @return void
*/
private function updateAndAssertNotSelectCustomOptions(array $optionData, array $updateData): void
{
@@ -286,9 +297,11 @@ private function updateAndAssertNotSelectCustomOptions(array $optionData, array
$updatedOption = $this->updateOptionWithValues($updateData, $productSku);
foreach ($updateData as $methodKey => $newValue) {
- $methodName = str_replace('_', '', ucwords($methodKey, '_'));
- $this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
- $this->assertNotEquals($createdOption->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
+ $this->assertEquals($newValue, $updatedOption->getDataUsingMethod($methodKey));
+ $this->assertNotEquals(
+ $createdOption->getDataUsingMethod($methodKey),
+ $updatedOption->getDataUsingMethod($methodKey)
+ );
}
$this->assertEquals($createdOption->getOptionId(), $updatedOption->getOptionId());
@@ -301,6 +314,7 @@ private function updateAndAssertNotSelectCustomOptions(array $optionData, array
* @param array $optionValueData
* @param array $updateOptionData
* @param array $updateOptionValueData
+ * @return void
*/
private function updateAndAssertSelectCustomOptions(
array $optionData,
@@ -315,17 +329,19 @@ private function updateAndAssertSelectCustomOptions(
$updatedOptionValue = $this->getOptionValue($updatedOption);
foreach ($updateOptionData as $methodKey => $newValue) {
- $methodName = str_replace('_', '', ucwords($methodKey, '_'));
- $this->assertEquals($newValue, $updatedOption->{'get' . $methodName}());
- $this->assertNotEquals($createdOption->{'get' . $methodName}(), $updatedOption->{'get' . $methodName}());
+ $this->assertEquals($newValue, $updatedOption->getDataUsingMethod($methodKey));
+ $this->assertNotEquals(
+ $createdOption->getDataUsingMethod($methodKey),
+ $updatedOption->getDataUsingMethod($methodKey)
+ );
}
foreach ($updateOptionValueData as $methodKey => $newValue) {
$methodName = str_replace('_', '', ucwords($methodKey, '_'));
$this->assertEquals($newValue, $updatedOptionValue->{'get' . $methodName}());
$this->assertNotEquals(
- $createdOptionValue->{'get' . $methodName}(),
- $updatedOptionValue->{'get' . $methodName}()
+ $createdOptionValue->getDataUsingMethod($methodKey),
+ $updatedOptionValue->getDataUsingMethod($methodKey)
);
}
@@ -337,7 +353,7 @@ private function updateAndAssertSelectCustomOptions(
*
* @param array $optionData
* @param string $productSku
- * @return ProductCustomOptionInterface
+ * @return ProductCustomOptionInterface|Option
*/
private function createCustomOption(array $optionData, string $productSku): ProductCustomOptionInterface
{
@@ -359,7 +375,7 @@ private function createCustomOption(array $optionData, string $productSku): Prod
* @param array $optionData
* @param array $optionValueData
* @param string $productSku
- * @return ProductCustomOptionInterface
+ * @return ProductCustomOptionInterface|Option
*/
private function createCustomOptionWithValue(
array $optionData,
@@ -377,7 +393,7 @@ private function createCustomOptionWithValue(
*
* @param array $updateData
* @param string $productSku
- * @return ProductCustomOptionInterface
+ * @return ProductCustomOptionInterface|Option
*/
private function updateOptionWithValues(array $updateData, string $productSku): ProductCustomOptionInterface
{
@@ -385,8 +401,7 @@ private function updateOptionWithValues(array $updateData, string $productSku):
$currentOption = $this->getProductOptionByProductSku($product->getSku());
$currentOption->setProductSku($product->getSku());
foreach ($updateData as $methodKey => $newValue) {
- $methodName = str_replace('_', '', ucwords($methodKey, '_'));
- $currentOption->{'set' . $methodName}($newValue);
+ $currentOption->setDataUsingMethod($methodKey, $newValue);
}
$product->setOptions([$currentOption]);
$this->productRepository->save($product);
@@ -400,7 +415,7 @@ private function updateOptionWithValues(array $updateData, string $productSku):
* @param array $optionUpdateData
* @param array $optionValueUpdateData
* @param string $productSku
- * @return ProductCustomOptionInterface
+ * @return ProductCustomOptionInterface|Option
*/
private function updateOptionAndValueWithValues(
array $optionUpdateData,
@@ -412,12 +427,10 @@ private function updateOptionAndValueWithValues(
$currentOption->setProductSku($product->getSku());
$optionValue = $this->getOptionValue($currentOption);
foreach ($optionUpdateData as $methodKey => $newValue) {
- $methodName = str_replace('_', '', ucwords($methodKey, '_'));
- $currentOption->{'set' . $methodName}($newValue);
+ $currentOption->setDataUsingMethod($methodKey, $newValue);
}
foreach ($optionValueUpdateData as $methodKey => $newValue) {
- $methodName = str_replace('_', '', ucwords($methodKey, '_'));
- $optionValue->{'set' . $methodName}($newValue);
+ $optionValue->setDataUsingMethod($methodKey, $newValue);
}
$currentOption->setValues([$optionValue]);
$product->setOptions([$currentOption]);
@@ -430,13 +443,12 @@ private function updateOptionAndValueWithValues(
* Get product option by product sku.
*
* @param string $productSku
- * @return ProductCustomOptionInterface
+ * @return ProductCustomOptionInterface|Option
*/
private function getProductOptionByProductSku(string $productSku): ProductCustomOptionInterface
{
$product = $this->productRepository->get($productSku);
$currentOptions = $this->optionRepository->getProductOptions($product);
- $this->assertCount(1, $currentOptions);
return reset($currentOptions);
}
@@ -445,12 +457,11 @@ private function getProductOptionByProductSku(string $productSku): ProductCustom
* Return custom option value.
*
* @param ProductCustomOptionInterface $customOption
- * @return ProductCustomOptionValuesInterface
+ * @return ProductCustomOptionValuesInterface|Value
*/
private function getOptionValue(ProductCustomOptionInterface $customOption): ProductCustomOptionValuesInterface
{
$optionValues = $customOption->getValues();
- $this->assertCount(1, $optionValues);
return reset($optionValues);
}
From a120e60c00af46df1cfb3872aa7fb80dc10ab708 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 11 Oct 2019 15:53:42 +0300
Subject: [PATCH 0357/1978] MC-20425: [Integration Test] Check behavior when
attribute set was changed to a new set with deleted attribute from the
previous set
---
.../Catalog/Controller/Product/ViewTest.php | 37 ++++++++-----------
...default_without_country_of_manufacture.php | 5 +--
...uct_simple_with_country_of_manufacture.php | 5 +--
3 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
index 84fbe15047ba2..f3b87fe324d4a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
@@ -19,7 +19,8 @@
use Magento\Eav\Model\Entity\Type;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
-use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\Filesystem\File\WriteInterface as FileWriteInterface;
+use Magento\Framework\Filesystem\Driver\File;
/**
* Integration test for product view front action.
@@ -84,11 +85,10 @@ public function testViewActionWithCanonicalTag(): void
* View product with custom attribute when attribute removed from it.
*
* It tests that after changing product attribute set from Default to Custom
- * there are no waring messages in log in case Custom not contains attribute from Default.
+ * there are no warning messages in log in case Custom not contains attribute from Default.
*
* @magentoDataFixture Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
* @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
- * @magentoDbIsolation disabled
* @return void
*/
public function testViewActionCustomAttributeSetWithoutCountryOfManufacture(): void
@@ -129,9 +129,7 @@ private function checkSystemLogForMessage(string $message): bool
*/
private function getProductBySku(string $sku): Product
{
- $product = $this->productRepository->get($sku);
-
- return $product;
+ return $this->productRepository->get($sku);
}
/**
@@ -175,8 +173,8 @@ private function getProductAttributeSetByName(string $attributeSetName): ?Set
private function getSystemLogContent(): string
{
$logDir = $this->getLogDirectoryWrite();
- $logFullFileName = $logDir->getAbsolutePath($this->systemLogFileName);
- $content = $this->tail($logFullFileName, 10);
+ $logFile = $logDir->openFile($this->systemLogFileName, 'rb');
+ $content = $this->tail($logFile, 10);
return $content;
}
@@ -184,22 +182,19 @@ private function getSystemLogContent(): string
/**
* Get file tail.
*
- * @param string $filename
+ * @param FileWriteInterface $file
* @param int $lines
* @param int $buffer
* @return false|string
*/
- private function tail(string $filename, int $lines = 10, int $buffer = 4096)
+ private function tail(FileWriteInterface $file, int $lines = 10, int $buffer = 4096)
{
- // Open the file
- $f = fopen($filename, "rb");
-
// Jump to last character
- fseek($f, -1, SEEK_END);
+ $file->seek(-1, SEEK_END);
// Read it and adjust line number if necessary
// (Otherwise the result would be wrong if file doesn't end with a blank line)
- if (fread($f, 1) != "\n") {
+ if ($file->read(1) != "\n") {
$lines--;
}
@@ -208,18 +203,18 @@ private function tail(string $filename, int $lines = 10, int $buffer = 4096)
$chunk = '';
// While we would like more
- while (ftell($f) > 0 && $lines >= 0) {
+ while ($file->tell() > 0 && $lines >= 0) {
// Figure out how far back we should jump
- $seek = min(ftell($f), $buffer);
+ $seek = min($file->tell(), $buffer);
// Do the jump (backwards, relative to where we are)
- fseek($f, -$seek, SEEK_CUR);
+ $file->seek(-$seek, SEEK_CUR);
// Read a chunk and prepend it to our output
- $output = ($chunk = fread($f, $seek)) . $output;
+ $output = ($chunk = $file->read($seek)) . $output;
// Jump back to where we started reading
- fseek($f, -mb_strlen($chunk, '8bit'), SEEK_CUR);
+ $file->seek(-mb_strlen($chunk, '8bit'), SEEK_CUR);
// Decrease our line counter
$lines -= substr_count($chunk, "\n");
@@ -233,7 +228,7 @@ private function tail(string $filename, int $lines = 10, int $buffer = 4096)
}
// Close file and return
- fclose($f);
+ $file->close();
return $output;
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
index 0d700215af037..eb25d261f531b 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
@@ -22,10 +22,9 @@
/** @var Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
$attributeSet = $objectManager->create(Set::class);
+/** @var Type $entityType */
$entityType = $objectManager->create(Type::class)
->loadByCode(Magento\Catalog\Model\Product::ENTITY);
-$defaultSetId = $objectManager->create(Product::class)
- ->getDefaultAttributeSetid();
$data = [
'attribute_set_name' => 'custom_attribute_set_wout_com',
'entity_type_id' => $entityType->getId(),
@@ -35,7 +34,7 @@
$attributeSet->setData($data);
$attributeSet->validate();
$attributeSet->save();
-$attributeSet->initFromSkeleton($defaultSetId);
+$attributeSet->initFromSkeleton($entityType->getDefaultAttributeSetId());
/** @var Group $group */
foreach ($attributeSet->getGroups() as $group) {
$groupAttributes = $group->getAttributes();
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
index 70fb8a598fa3a..fba611e7c67f5 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
@@ -21,12 +21,9 @@
$productFactory = $objectManager->create(ProductInterfaceFactory::class);
/** @var $product \Magento\Catalog\Model\Product */
-$defaultSetId = $objectManager->create(Product::class)
- ->getDefaultAttributeSetid();
-
$product = $productFactory->create();
$product->setTypeId(\Magento\Catalog\Model\Product\Type::TYPE_SIMPLE)
- ->setAttributeSetId($defaultSetId)
+ ->setAttributeSetId($product->getDefaultAttributeSetId())
->setWebsiteIds([1])
->setName('Simple Product With Country Of Manufacture')
->setSku('simple_with_com')
From 49a6a424f560a7f8f5520805845971007b714514 Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Fri, 11 Oct 2019 16:24:26 +0300
Subject: [PATCH 0358/1978] MC-20449: [Integration Test]Hide product images via
hide_from_product_page attribute during import CSV
---
.../Model/Import/ProductTest.php | 48 ++++++++-----------
...import_with_filesystem_images_rollback.php | 14 ++++--
2 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index dbb1f0f9f81e3..a5a034222e40d 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -976,7 +976,7 @@ public static function mediaImportImageFixtureRollback()
/** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */
$varDirectory = $fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
- $varDirectory->delete('import' . DIRECTORY_SEPARATOR . 'images');
+ $varDirectory->delete('import');
$mediaDirectory->delete('catalog');
}
@@ -2626,43 +2626,33 @@ public function testImagesAreHiddenAfterImport(): void
$actualAllProductImages = [];
$product = $this->getProductBySku('simple');
-// Check that new images are imported and existing image is disabled after import
+ // Check that new images are imported and existing image is disabled after import
$productMediaData = $product->getData('media_gallery');
- if (is_array($productMediaData['images'])) {
- $allProductImages = $productMediaData['images'];
- $this->assertCount(3, $allProductImages, 'Images are imported incorrect');
+ $this->assertNotEmpty($productMediaData['images']);
+ $allProductImages = $productMediaData['images'];
+ $this->assertCount(3, $allProductImages, 'Images are imported incorrect');
- foreach ($allProductImages as $image) {
- $actualAllProductImages[] = [
- 'file' => $image['file'],
- 'label' => $image['label'],
- 'disabled' => $image['disabled'],
- ];
- }
+ foreach ($allProductImages as $image) {
+ $actualAllProductImages[] = [
+ 'file' => $image['file'],
+ 'label' => $image['label'],
+ 'disabled' => $image['disabled'],
+ ];
}
$this->assertEquals(
$expectedAllProductImages,
$actualAllProductImages,
- 'Images statuses are incorrect after import'
+ 'Images are incorrect after import'
);
-// Check that on storefront only enabled images are shown
- $actualActiveImages = array_values($product->getMediaGalleryImages()->getItems());
- $this->assertCount(2, $actualActiveImages);
-
- foreach ($actualActiveImages as $actualActiveImage) {
- $this->assertNotEquals(
- $expectedHiddenImage['file'],
- $actualActiveImage->getFile(),
- 'Image should be hidden after import'
- );
- $this->assertNotEquals(
- $expectedHiddenImage['label'],
- $actualActiveImage->getLabel(),
- 'Image should be hidden after import'
- );
- }
+ // Check that on storefront only enabled images are shown
+ $actualActiveImages = $product->getMediaGalleryImages();
+ $this->assertSame(
+ $expectedActiveImages,
+ $actualActiveImages->toArray(['file', 'label', 'disabled'])['items'],
+ 'Hidden image is present on frontend after import'
+ );
}
}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images_rollback.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images_rollback.php
index 5c1db3ca045a6..a984cbf2e3529 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/_files/import_with_filesystem_images_rollback.php
@@ -4,11 +4,17 @@
* See COPYING.txt for license details.
*/
-/** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
-$mediaDirectory = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
+/** @var \Magento\Framework\Filesystem $fileSystem */
+$fileSystem = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
\Magento\Framework\Filesystem::class
-)->getDirectoryWrite(
+);
+/** @var \Magento\Framework\Filesystem\Directory\Write $mediaDirectory */
+$mediaDirectory = $fileSystem->getDirectoryWrite(
\Magento\Framework\App\Filesystem\DirectoryList::MEDIA
);
-$mediaDirectory->delete('import');
+/** @var \Magento\Framework\Filesystem\Directory\Write $varDirectory */
+$varDirectory = $fileSystem->getDirectoryWrite(
+ \Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR
+);
+$varDirectory->delete('import');
$mediaDirectory->delete('catalog');
From 25dc71fa77f97cbda6a685bf210fd8d0a7bfa6c8 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Fri, 11 Oct 2019 15:54:04 +0300
Subject: [PATCH 0359/1978] MC-21718: Storefront Category URL management
---
.../UrlRewrite/Controller/UrlRewriteTest.php | 48 +++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
index 795f29332876a..ced37bd5a3f07 100644
--- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
@@ -5,14 +5,29 @@
*/
namespace Magento\UrlRewrite\Controller;
+use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\TestFramework\TestCase\AbstractController;
use Magento\Framework\App\Response\Http as HttpResponse;
+use Zend\Http\Response;
/**
* Class to test Match corresponding URL Rewrite
*/
class UrlRewriteTest extends AbstractController
{
+ /** @var CategoryRepositoryInterface */
+ private $categoryRepository;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->categoryRepository = $this->_objectManager->get(CategoryRepositoryInterface::class);
+ }
+
/**
* @magentoDataFixture Magento/UrlRewrite/_files/url_rewrite.php
* @magentoDbIsolation disabled
@@ -84,4 +99,37 @@ public function requestDataProvider()
],
];
}
+
+ /**
+ * @magentoDbIsolation enabled
+ * @magentoConfigFixture default/catalog/seo/generate_category_product_rewrites 1
+ * @magentoDataFixture Magento/Catalog/_files/category_tree.php
+ * @dataProvider categoryRewriteProvider
+ * @param string $request
+ * @return void
+ */
+ public function testCategoryUrlRewrite(string $request): void
+ {
+ $this->dispatch($request);
+ $response = $this->getResponse();
+ $this->assertEquals(
+ Response::STATUS_CODE_200,
+ $response->getHttpResponseCode(),
+ 'Response code does not match expected value'
+ );
+ }
+
+ /**
+ * @return array
+ */
+ public function categoryRewriteProvider(): array
+ {
+ return [
+ [
+ 'category-1.html',
+ 'category-1/category-1-1.html',
+ 'category-1/category-1-1/category-1-1-1.html',
+ ],
+ ];
+ }
}
From 16a9295345d968e444dbbb1f04cbaab37ed203aa Mon Sep 17 00:00:00 2001
From: natalia
Date: Fri, 11 Oct 2019 16:45:43 +0300
Subject: [PATCH 0360/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error)
- StorefrontElasticsearch6SearchInvalidValueTest is fixed
---
.../Test/StorefrontElasticsearch6SearchInvalidValueTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
index 1c105bff9aa0b..e3a63b9c83338 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
@@ -79,7 +79,7 @@
-
+
From 2cf996c3ea93de58e6ddbb0dd1988390960cae83 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Fri, 11 Oct 2019 16:47:13 +0300
Subject: [PATCH 0361/1978] MC-21718: Storefront Category URL management
---
.../Magento/UrlRewrite/Controller/UrlRewriteTest.php | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
index ced37bd5a3f07..950ac0728bc59 100644
--- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\UrlRewrite\Controller;
use Magento\Catalog\Api\CategoryRepositoryInterface;
@@ -38,6 +40,7 @@ protected function setUp()
* @param string $request
* @param string $redirect
* @param int $expectedCode
+ * @return void
*
* @dataProvider requestDataProvider
*/
@@ -45,14 +48,14 @@ public function testMatchUrlRewrite(
string $request,
string $redirect,
int $expectedCode = 301
- ) {
+ ): void {
$this->dispatch($request);
/** @var HttpResponse $response */
$response = $this->getResponse();
$code = $response->getHttpResponseCode();
$this->assertEquals($expectedCode, $code, 'Invalid response code');
- if ($expectedCode !== 200) {
+ if ($expectedCode !== Response::STATUS_CODE_200) {
$location = $response->getHeader('Location')->getFieldValue();
$this->assertStringEndsWith(
$redirect,
@@ -65,7 +68,7 @@ public function testMatchUrlRewrite(
/**
* @return array
*/
- public function requestDataProvider()
+ public function requestDataProvider(): array
{
return [
'Use Case #1: Rewrite: page-one/ --(301)--> page-a/; Request: page-one/ --(301)--> page-a/' => [
@@ -95,7 +98,7 @@ public function requestDataProvider()
'Use Case #7: Request with query params' => [
'request' => '/enable-cookies/?test-param',
'redirect' => '',
- 200,
+ Response::STATUS_CODE_200,
],
];
}
From 84ba0e25d1a51a1cc8b8c59b0d3f71f77d79eff7 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Fri, 11 Oct 2019 16:47:44 +0300
Subject: [PATCH 0362/1978] MC-20668: Edit custom options of simple product
---
.../Adminhtml/Product/Save/UpdateCustomOptionsTest.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
index e20200b9e9f7f..70d5ce292c2cb 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
@@ -121,7 +121,10 @@ public function testUpdateCustomOptionWithTypeField(array $optionData, array $up
$updatedOption = reset($updatedOptions);
$this->assertEquals($newValue, $updatedOption->getDataUsingMethod($methodKey));
$this->assertEquals($option->getOptionId(), $updatedOption->getOptionId());
- $this->assertNotEquals($option->getDataUsingMethod($methodKey), $updatedOption->getDataUsingMethod($methodKey));
+ $this->assertNotEquals(
+ $option->getDataUsingMethod($methodKey),
+ $updatedOption->getDataUsingMethod($methodKey)
+ );
}
}
}
From 0c6cc013498dcc920b1be8fa700fc656da4b2076 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Fri, 11 Oct 2019 17:06:17 +0300
Subject: [PATCH 0363/1978] MC-20668: Edit custom options of simple product
---
.../Model/Product/Option/Create/DataProvider/Type/Date/Date.php | 2 +-
.../Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
index 21a544028bc1d..45dad58997339 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
@@ -20,6 +20,6 @@ class Date extends AbstractBase
*/
protected function getType(): string
{
- return ProductCustomOptionInterface::OPTION_GROUP_DATE;
+ return ProductCustomOptionInterface::OPTION_TYPE_DATE;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
index 7ee29bf45fe0d..00f424fb1b670 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
@@ -363,7 +363,6 @@ private function createCustomOption(array $optionData, string $productSku): Prod
$product->setOptions([$createdOption]);
$this->productRepository->save($product);
$productCustomOptions = $this->optionRepository->getProductOptions($product);
- $this->assertCount(1, $productCustomOptions);
$option = reset($productCustomOptions);
return $option;
From 5f1c0ee618d0ea16765c0da4413f988bbb76cfb5 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Fri, 11 Oct 2019 17:12:33 +0300
Subject: [PATCH 0364/1978] MC-21718: Storefront Category URL management
---
.../testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
index 950ac0728bc59..858401bf4eb69 100644
--- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
@@ -47,7 +47,7 @@ protected function setUp()
public function testMatchUrlRewrite(
string $request,
string $redirect,
- int $expectedCode = 301
+ int $expectedCode = Response::STATUS_CODE_301
): void {
$this->dispatch($request);
/** @var HttpResponse $response */
From c03ce073253d74655637f6635738cfc282c01d76 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 11 Oct 2019 17:26:19 +0300
Subject: [PATCH 0365/1978] MC-20425: [Integration Test] Check behavior when
attribute set was changed to a new set with deleted attribute from the
previous set
---
.../testsuite/Magento/Catalog/Controller/Product/ViewTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
index f3b87fe324d4a..dd55d88bfae71 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
@@ -26,6 +26,7 @@
* Integration test for product view front action.
*
* @magentoAppArea frontend
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ViewTest extends \Magento\TestFramework\TestCase\AbstractController
{
From fc8bfede0bc76e089bb9840e9dd8ce6c5e41c186 Mon Sep 17 00:00:00 2001
From: Yuliya Labudova
Date: Fri, 11 Oct 2019 17:32:56 +0300
Subject: [PATCH 0366/1978] MC-18824: Increase test coverage for Import /
export functional area
- Fix integration tests.
---
.../Magento/CatalogImportExport/Model/Import/ProductTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index 39292311243d1..194cf395c293c 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -862,7 +862,7 @@ public function testSaveHiddenImages()
$hiddenImages = array_filter(
$images,
static function (DataObject $image) {
- return $image->getDisabled() === 1;
+ return (int)$image->getDisabled() === 1;
}
);
From 5cf6e17dead915db8f617c38714dd7da48e08e86 Mon Sep 17 00:00:00 2001
From: Gabriel da Gama
Date: Fri, 11 Oct 2019 16:30:12 +0100
Subject: [PATCH 0367/1978] Changed accordion transition from forceDeactivate
to deactivate, fixing bug transition
---
lib/web/mage/accordion.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/lib/web/mage/accordion.js b/lib/web/mage/accordion.js
index 93cdb30777c54..6dbc00c1084fc 100644
--- a/lib/web/mage/accordion.js
+++ b/lib/web/mage/accordion.js
@@ -83,7 +83,12 @@ define([
*/
_closeOthers: function () {
if (!this.options.multipleCollapsible) {
- this._super();
+ var self = this;
+ $.each(this.collapsibles, function () {
+ $(this).on('beforeOpen', function () {
+ self.collapsibles.not(this).collapsible('deactivate');
+ });
+ });
}
$.each(this.collapsibles, function () {
$(this).on('beforeOpen', function () {
From 9b423da550221328dd3215ff057e06109924fdb1 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 11 Oct 2019 13:56:27 -0500
Subject: [PATCH 0368/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 899c31c40db8f..2646a48ce1467 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -294,7 +294,6 @@ protected function doReindexByIds($ids)
$activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
$rule->setProductsFilter($ids);
- $this->reindexRuleProduct->execute($rule, $this->batchCount);
}
$this->cleanProductPriceIndex($ids);
From c34d995aa05918b1bac44ddb34eb138272073460 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 11 Oct 2019 15:28:04 -0500
Subject: [PATCH 0369/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 2646a48ce1467..2ed26a044dbc9 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -290,14 +290,15 @@ protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
- /** @var Rule[] $activeRules */
- $activeRules = $this->getActiveRules()->getItems();
+ $activeRules = $this->getActiveRules();
foreach ($activeRules as $rule) {
+ /** @var Rule $rule */
$rule->setProductsFilter($ids);
+ $this->reindexRuleProduct->execute($rule, $this->batchCount);
}
- $this->cleanProductPriceIndex($ids);
foreach ($ids as $productId) {
+ $this->cleanProductPriceIndex($productId);
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
@@ -341,7 +342,7 @@ protected function doReindexFull()
[
$this->getTable('catalogrule_product'),
$this->getTable('catalogrule_product_price'),
- $this->getTable('catalogrule_group_website'),
+ $this->getTable('catalogrule_group_website')
]
);
}
From 69862e805bef83955f5df04a4ac0a1510698bd19 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 11 Oct 2019 16:40:48 -0500
Subject: [PATCH 0370/1978] MC-19652: Product Categories Indexer stuck
---
app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 2ed26a044dbc9..864c814775377 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -298,7 +298,7 @@ protected function doReindexByIds($ids)
}
foreach ($ids as $productId) {
- $this->cleanProductPriceIndex($productId);
+ $this->cleanProductPriceIndex([$productId]);
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
From e5095fbae95c4c40f10576da74d86e752fbe5362 Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Sat, 12 Oct 2019 01:48:37 +0300
Subject: [PATCH 0371/1978] Updates for code according to comments. Related
updates for unit test.
---
.../Quote/Api/CartManagementInterface.php | 3 +++
.../Magento/Quote/Model/QuoteManagement.php | 17 +++++++++++++----
.../Test/Unit/Model/QuoteManagementTest.php | 14 ++++++--------
3 files changed, 22 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Quote/Api/CartManagementInterface.php b/app/code/Magento/Quote/Api/CartManagementInterface.php
index 7aa4bc4c7603a..dc8ab7fedc870 100644
--- a/app/code/Magento/Quote/Api/CartManagementInterface.php
+++ b/app/code/Magento/Quote/Api/CartManagementInterface.php
@@ -52,6 +52,9 @@ public function getCartForCustomer($customerId);
* @param int $customerId The customer ID.
* @param int $storeId
* @return boolean
+ * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws \Magento\Framework\Exception\StateException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function assignCustomer($cartId, $customerId, $storeId);
diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php
index 1aea905706cd5..0ab4dcf4dd668 100644
--- a/app/code/Magento/Quote/Model/QuoteManagement.php
+++ b/app/code/Magento/Quote/Model/QuoteManagement.php
@@ -305,13 +305,22 @@ public function assignCustomer($cartId, $customerId, $storeId)
}
if ($customerActiveQuote) {
- /** Merge carts */
- $quote->merge($customerActiveQuote);
- $this->quoteRepository->delete($customerActiveQuote);
+ try {
+ /** Merge carts */
+ $quote->merge($customerActiveQuote);
+ $customerActiveQuote->setIsActive(0);
+ $this->quoteRepository->save($customerActiveQuote);
+ } catch (\Exception $e) {
+ $message = sprintf(
+ "The customer can't be assigned to the cart. Error on cart merging: %s",
+ $e->getMessage()
+ );
+ throw new StateException($message);
+ }
+
}
$quote->setCustomer($customer);
$quote->setCustomerIsGuest(0);
- $quote->setStoreId($storeId);
$quote->setIsActive(1);
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index e5753c8c27fa2..61ee7a146d164 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -510,12 +510,12 @@ public function testAssignCustomerWithActiveCart()
$quoteMock = $this->createPartialMock(
Quote::class,
- ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setIsActive', 'getIsActive', 'merge']
);
$activeQuoteMock = $this->createPartialMock(
Quote::class,
- ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setIsActive', 'getIsActive', 'merge']
);
$customerMock = $this->createMock(CustomerInterface::class);
@@ -556,17 +556,17 @@ public function testAssignCustomerWithActiveCart()
->willReturn($activeQuoteMock);
$quoteMock->expects($this->once())->method('merge')->with($activeQuoteMock)->willReturnSelf();
- $this->quoteRepositoryMock->expects($this->once())->method('delete')->with($activeQuoteMock);
+ $activeQuoteMock->expects($this->once())->method('setIsActive')->with(0);
+ $this->quoteRepositoryMock->expects($this->atLeastOnce())->method('save')->with($activeQuoteMock);
$quoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
$quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
- $quoteMock->expects($this->once())->method('setStoreId')->with($storeId);
$quoteMock->expects($this->once())->method('setIsActive')->with(1);
$this->quoteIdMock->expects($this->once())->method('load')->with($cartId, 'quote_id')->willReturnSelf();
$this->quoteIdMock->expects($this->once())->method('getId')->willReturn(10);
$this->quoteIdMock->expects($this->once())->method('delete');
- $this->quoteRepositoryMock->expects($this->once())->method('save')->with($quoteMock);
+ $this->quoteRepositoryMock->expects($this->atLeastOnce())->method('save')->with($quoteMock);
$this->model->assignCustomer($cartId, $customerId, $storeId);
}
@@ -585,7 +585,7 @@ public function testAssignCustomer()
$quoteMock = $this->createPartialMock(
Quote::class,
- ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setStoreId', 'setIsActive', 'getIsActive', 'merge']
+ ['getCustomerId', 'setCustomer', 'setCustomerIsGuest', 'setIsActive', 'getIsActive', 'merge']
);
$customerMock = $this->createMock(CustomerInterface::class);
@@ -629,11 +629,9 @@ public function testAssignCustomer()
$this->assertEquals(false, $activeQuoteMock);
$quoteMock->expects($this->never())->method('merge');
- $this->quoteRepositoryMock->expects($this->never())->method('delete');
$quoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
$quoteMock->expects($this->once())->method('setCustomerIsGuest')->with(0);
- $quoteMock->expects($this->once())->method('setStoreId')->with($storeId);
$quoteMock->expects($this->once())->method('setIsActive')->with(1);
$this->quoteIdMock->expects($this->once())->method('load')->with($cartId, 'quote_id')->willReturnSelf();
From da12ba00591eab643fa2692ee06c26fde117902a Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Sun, 13 Oct 2019 20:47:39 -0500
Subject: [PATCH 0372/1978] MC-20648: Implement the changes - Refactoring/
Added api for extension attributes
---
.../Model/Resolver/CartItemPrices.php | 4 +-
.../QuoteGraphQl/Model/Resolver/Discounts.php | 4 +-
.../SalesRule/Api/Data/DiscountInterface.php | 33 ++++++
.../SalesRule/Model/Data/RuleDiscount.php | 105 ++++++++++++++++++
.../SalesRule/Model/Plugin/Discount.php | 43 +++++--
.../Model/Plugin/ResourceModel/Discount.php | 9 +-
.../SalesRule/Model/Quote/Discount.php | 44 +++++---
.../Model/Quote/Item/Plugin/Discount.php | 11 +-
.../Magento/SalesRule/Model/RulesApplier.php | 24 +++-
app/code/Magento/SalesRule/etc/di.xml | 2 +
.../SalesRule/etc/extension_attributes.xml | 4 +-
.../PlaceOrderWithStorePromotionsTest.php | 20 ++--
12 files changed, 255 insertions(+), 48 deletions(-)
create mode 100644 app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
create mode 100644 app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
index 92a5f926a7d6a..d740ea0d18513 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
@@ -94,9 +94,9 @@ private function getDiscountValues($cartItem, $currencyCode)
$discount = [];
$amount = [];
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
- $discountData = $value['discount'];
+ $discountData = $value->getDiscountData();
$discountAmount = $discountData->getAmount();
- $discount['label'] = $value['rule'] ?: __('Discount');
+ $discount['label'] = $value->getRuleLabel() ?: __('Discount');
$amount['value'] = $discountAmount;
$amount['currency'] = $currencyCode;
$discount['amount'] = $amount;
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
index cfec52a9600e1..8d42d4484a360 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
@@ -46,9 +46,9 @@ private function getDiscountValues(Quote $quote)
foreach ($totalDiscounts as $value) {
$discount = [];
$amount = [];
- $discount['label'] = $value['rule'] ?: __('Discount');
+ $discount['label'] = $value->getRuleLabel() ?: __('Discount');
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
- $discountData = $value['discount'];
+ $discountData = $value->getDiscountData();
$amount['value'] = $discountData->getAmount();
$amount['currency'] = $quote->getQuoteCurrencyCode();
$discount['amount'] = $amount;
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
new file mode 100644
index 0000000000000..2c93cc95dcf3a
--- /dev/null
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
@@ -0,0 +1,33 @@
+_get(self::KEY_DISCOUNT_DATA);
+ }
+
+ /**
+ * Get Rule Label
+ *
+ * @return mixed|null
+ */
+ public function getRuleLabel()
+ {
+ return $this->_get(self::KEY_RULE_LABEL);
+ }
+
+ /**
+ * Set Discount Data
+ *
+ * @param Data $discountData
+ * @return RuleDiscount
+ */
+ public function setDiscountData(Data $discountData)
+ {
+ return $this->setData(self::KEY_DISCOUNT_DATA, $discountData);
+ }
+
+ /**
+ * Set Rule Label
+ *
+ * @param string $ruleLabel
+ * @return RuleDiscount
+ */
+ public function setRuleLabel(string $ruleLabel)
+ {
+ return $this->setData(self::KEY_RULE_LABEL, $ruleLabel);
+ }
+
+ /**
+ * Get Rule ID
+ *
+ * @return string
+ */
+ public function getRuleID()
+ {
+ return $this->_get(self::KEY_RULE_ID);
+ }
+
+ /**
+ * Set Rule ID
+ *
+ * @param string $ruleID
+ * @return RuleDiscount
+ */
+ public function setRuleID(string $ruleID)
+ {
+ return $this->setData(self::KEY_RULE_ID, $ruleID);
+ }
+
+ /**
+ * Retrieve existing extension attributes object or create a new one.
+ *
+ * @return DiscountInterface|null
+ */
+ public function getExtensionAttributes()
+ {
+ return $this->_getExtensionAttributes();
+ }
+
+ /**
+ * Set an extension attributes object.
+ *
+ * @param DiscountInterface $extensionAttributes
+ * @return $this
+ */
+ public function setExtensionAttributes(
+ DiscountInterface $extensionAttributes
+ ) {
+ return $this->_setExtensionAttributes($extensionAttributes);
+ }
+}
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
index af4d515374bea..4657b5bb5c9d3 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -9,6 +9,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Quote\Model\Quote;
use Magento\Framework\Data\Collection;
+use Magento\SalesRule\Api\Data\DiscountInterfaceFactory;
/**
* Plugin for persisting discounts along with Quote Address
@@ -25,14 +26,24 @@ class Discount
*/
private $discountFactory;
+ /**
+ * @var DiscountInterfaceFactory
+ */
+ private $discountInterfaceFactory;
+
/**
* @param Json $json
- * @param DataFactory|null $discountDataFactory
+ * @param DataFactory $discountDataFactory
+ * @param DiscountInterfaceFactory $discountInterfaceFactory
*/
- public function __construct(Json $json, DataFactory $discountDataFactory)
- {
+ public function __construct(
+ Json $json,
+ DataFactory $discountDataFactory,
+ DiscountInterfaceFactory $discountInterfaceFactory
+ ) {
$this->json = $json;
$this->discountFactory = $discountDataFactory;
+ $this->discountInterfaceFactory = $discountInterfaceFactory;
}
/**
@@ -49,9 +60,14 @@ public function afterGetItemsCollection(
) {
foreach ($result as $item) {
if ($item->getDiscounts() && !$item->getExtensionAttributes()->getDiscounts()) {
- $discounts = $this->json->unserialize($item->getDiscounts());
- foreach ($discounts as $key => $value) {
- $discounts[$key]['discount'] = $this->unserializeDiscountData($value['discount']);
+ $unserializeDiscounts = $this->json->unserialize($item->getDiscounts());
+ $discounts = [];
+ foreach ($unserializeDiscounts as $value) {
+ $itemDiscount = $this->discountInterfaceFactory->create();
+ $itemDiscount->setDiscountData($this->unserializeDiscountData($value['discount']));
+ $itemDiscount->setRuleLabel($value['rule']);
+ $itemDiscount->setRuleID($value['ruleID']);
+ $discounts[] = $itemDiscount;
}
$itemExtension = $item->getExtensionAttributes();
$itemExtension->setDiscounts($discounts);
@@ -74,12 +90,17 @@ public function afterGetAllAddresses(
) {
foreach ($result as $address) {
if ($address->getDiscounts() && !$address->getExtensionAttributes()->getDiscounts()) {
- $discounts = $this->json->unserialize($address->getDiscounts());
- foreach ($discounts as $key => $value) {
- $discounts[$key]['discount'] = $this->unserializeDiscountData($value['discount']);
+ $unserializedDiscounts = $this->json->unserialize($address->getDiscounts());
+ $discounts = [];
+ foreach ($unserializedDiscounts as $value) {
+ $cartDiscount = $this->discountInterfaceFactory->create();
+ $cartDiscount->setDiscountData($this->unserializeDiscountData($value['discount']));
+ $cartDiscount->setRuleLabel($value['rule']);
+ $cartDiscount->setRuleID($value['ruleID']);
+ $discounts[] = $cartDiscount;
}
- $itemExtension = $address->getExtensionAttributes();
- $itemExtension->setDiscounts($discounts);
+ $addressExtension = $address->getExtensionAttributes();
+ $addressExtension->setDiscounts($discounts);
}
}
return $result;
diff --git a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
index 8059c2574010c..10ac22265f47b 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
@@ -39,18 +39,21 @@ public function beforeSave(
) {
foreach ($object->getAllAddresses() as $address) {
$discounts = $address->getExtensionAttributes()->getDiscounts();
+ $serializedDiscounts= [];
if ($discounts) {
foreach ($discounts as $key => $value) {
- $discount = $value['discount'];
+ $discount = $value->getDiscountData();
$discountData = [
"amount" => $discount->getAmount(),
"baseAmount" => $discount->getBaseAmount(),
"originalAmount" => $discount->getOriginalAmount(),
"baseOriginalAmount" => $discount->getBaseOriginalAmount()
];
- $discounts[$key]['discount'] = $this->json->serialize($discountData);
+ $serializedDiscounts[$key]['discount'] = $this->json->serialize($discountData);
+ $serializedDiscounts[$key]['rule'] = $value->getRuleLabel();
+ $serializedDiscounts[$key]['ruleID'] = $value->getRuleID();
}
- $address->setDiscounts($this->json->serialize($discounts));
+ $address->setDiscounts($this->json->serialize($serializedDiscounts));
}
}
return [$object];
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index e3d1cd1454eed..36e8c81e0f4dd 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -7,6 +7,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Framework\App\ObjectManager;
+use Magento\SalesRule\Api\Data\DiscountInterfaceFactory;
/**
* Discount totals calculation model.
@@ -44,19 +45,26 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
*/
private $discountFactory;
+ /**
+ * @var DiscountInterfaceFactory
+ */
+ private $discountInterfaceFactory;
+
/**
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\SalesRule\Model\Validator $validator
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param DataFactory|null $discountDataFactory
+ * @param DiscountInterfaceFactory|null $discountInterfaceFactory
*/
public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\SalesRule\Model\Validator $validator,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
- DataFactory $discountDataFactory = null
+ DataFactory $discountDataFactory = null,
+ DiscountInterfaceFactory $discountInterfaceFactory = null
) {
$this->setCode(self::COLLECTOR_TYPE_CODE);
$this->eventManager = $eventManager;
@@ -64,6 +72,8 @@ public function __construct(
$this->storeManager = $storeManager;
$this->priceCurrency = $priceCurrency;
$this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
+ $this->discountInterfaceFactory = $discountInterfaceFactory
+ ?: ObjectManager::getInstance()->get(DiscountInterfaceFactory::class);
}
/**
@@ -103,6 +113,7 @@ public function collect(
$address->setDiscountDescription([]);
$items = $this->calculator->sortItemsByPriority($items, $address);
$address->getExtensionAttributes()->setDiscounts([]);
+ $addressDiscountAggregator = [];
/** @var \Magento\Quote\Model\Quote\Item $item */
foreach ($items as $item) {
@@ -142,7 +153,7 @@ public function collect(
$this->aggregateItemDiscount($item, $total);
}
if ($item->getExtensionAttributes()) {
- $this->aggregateDiscountPerRule($item, $address);
+ $this->aggregateDiscountPerRule($item, $address, $addressDiscountAggregator);
}
}
@@ -240,22 +251,25 @@ public function fetch(\Magento\Quote\Model\Quote $quote, \Magento\Quote\Model\Qu
*
* @param \Magento\Quote\Model\Quote\Item\AbstractItem $item
* @param \Magento\Quote\Api\Data\AddressInterface $address
+ * @param array $addressDiscountAggregator
* @return void
*/
private function aggregateDiscountPerRule(
\Magento\Quote\Model\Quote\Item\AbstractItem $item,
- \Magento\Quote\Api\Data\AddressInterface $address
+ \Magento\Quote\Api\Data\AddressInterface $address,
+ array &$addressDiscountAggregator
) {
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
- $discountPerRule = $address->getExtensionAttributes()->getDiscounts();
if ($discountBreakdown) {
- /** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
- foreach ($discountBreakdown as $key => $value) {
+ foreach ($discountBreakdown as $value) {
/* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
- $discount = $value['discount'];
- $ruleLabel = $value['rule'];
- if (isset($discountPerRule[$key])) {
- $discountData = $discountPerRule[$key]['discount'];
+ $discount = $value->getDiscountData();
+ $ruleLabel = $value->getRuleLabel();
+ $ruleID = $value->getRuleID();
+ if (isset($addressDiscountAggregator[$ruleID])) {
+ /** @var \Magento\SalesRule\Model\Data\RuleDiscount $cartDiscount */
+ $cartDiscount = $addressDiscountAggregator[$ruleID];
+ $discountData = $cartDiscount->getDiscountData();
$discountData->setBaseAmount($discountData->getBaseAmount()+$discount->getBaseAmount());
$discountData->setAmount($discountData->getAmount()+$discount->getAmount());
$discountData->setOriginalAmount($discountData->getOriginalAmount()+$discount->getOriginalAmount());
@@ -268,11 +282,15 @@ private function aggregateDiscountPerRule(
$discountData->setAmount($discount->getAmount());
$discountData->setOriginalAmount($discount->getOriginalAmount());
$discountData->setBaseOriginalAmount($discount->getBaseOriginalAmount());
- $discountPerRule[$key]['discount'] = $discountData;
+ /** @var \Magento\SalesRule\Model\Data\RuleDiscount $cartDiscount */
+ $cartDiscount = $this->discountInterfaceFactory->create();
+ $cartDiscount->setDiscountData($discountData);
+ $cartDiscount->setRuleLabel($ruleLabel);
+ $cartDiscount->setRuleID($ruleID);
+ $addressDiscountAggregator[$ruleID] = $cartDiscount;
}
- $discountPerRule[$key]['rule'] = $ruleLabel;
}
}
- $address->getExtensionAttributes()->setDiscounts($discountPerRule);
+ $address->getExtensionAttributes()->setDiscounts(array_values($addressDiscountAggregator));
}
}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
index 286061d2f333a..63d54e2c7fa88 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
@@ -39,18 +39,23 @@ public function beforeSave(CartItemPersister $subject, CartInterface $quote, Car
{
$cartExtension = $cartItem->getExtensionAttributes();
$discounts = $cartExtension->getDiscounts();
+ $serializedDiscount = [];
if ($discounts) {
foreach ($discounts as $key => $value) {
- $discount = $value['discount'];
+ $discount = $value->getDiscountData();
$discountData = [
"amount" => $discount->getAmount(),
"baseAmount" => $discount->getBaseAmount(),
"originalAmount" => $discount->getOriginalAmount(),
"baseOriginalAmount" => $discount->getBaseOriginalAmount(),
];
- $discounts[$key]['discount'] = $this->json->serialize($discountData);
+ $serializedDiscount[] = [
+ 'discount' => $this->json->serialize($discountData),
+ 'rule' => $value->getRuleLabel(),
+ 'ruleID' => $value->getRuleID(),
+ ];
}
- $cartItem->setDiscounts($this->json->serialize($discounts));
+ $cartItem->setDiscounts($this->json->serialize($serializedDiscount));
}
return [$quote, $cartItem];
}
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index fdd47cb821ad6..ec01ac541c09a 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -12,6 +12,7 @@
use Magento\SalesRule\Model\ResourceModel\Rule\Collection;
use Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory;
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
+use Magento\SalesRule\Api\Data\DiscountInterfaceFactory;
/**
* Class RulesApplier
@@ -47,19 +48,26 @@ class RulesApplier
*/
protected $discountFactory;
+ /**
+ * @var DiscountInterfaceFactory
+ */
+ private $discountInterfaceFactory;
+
/**
* @param CalculatorFactory $calculatorFactory
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param Utility $utility
* @param ChildrenValidationLocator|null $childrenValidationLocator
- * @param DataFactory $discountDataFactory
+ * @param DataFactory|null $discountDataFactory
+ * @param DiscountInterfaceFactory|null $discountInterfaceFactory
*/
public function __construct(
\Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory,
\Magento\Framework\Event\ManagerInterface $eventManager,
\Magento\SalesRule\Model\Utility $utility,
ChildrenValidationLocator $childrenValidationLocator = null,
- DataFactory $discountDataFactory = null
+ DataFactory $discountDataFactory = null,
+ DiscountInterfaceFactory $discountInterfaceFactory = null
) {
$this->calculatorFactory = $calculatorFactory;
$this->validatorUtility = $utility;
@@ -67,6 +75,8 @@ public function __construct(
$this->childrenValidationLocator = $childrenValidationLocator
?: ObjectManager::getInstance()->get(ChildrenValidationLocator::class);
$this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
+ $this->discountInterfaceFactory = $discountInterfaceFactory
+ ?: ObjectManager::getInstance()->get(DiscountInterfaceFactory::class);
}
/**
@@ -83,6 +93,7 @@ public function applyRules($item, $rules, $skipValidation, $couponCode)
{
$address = $item->getAddress();
$appliedRuleIds = [];
+ $item->getExtensionAttributes()->setDiscounts([]);
/* @var $rule Rule */
foreach ($rules as $rule) {
if (!$this->validatorUtility->canProcessRule($rule, $address)) {
@@ -219,8 +230,13 @@ private function setDiscountBreakdown($discountData, $item, $rule, $address)
$discount->setBaseAmount($discountData->getBaseAmount());
$discount->setOriginalAmount($discountData->getOriginalAmount());
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts() ?? [];
- $discountBreakdown[$rule->getId()]['discount'] = $discount;
- $discountBreakdown[$rule->getId()]['rule'] = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
+ $ruleLabel = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
+ /** @var \Magento\SalesRule\Model\Data\RuleDiscount $itemDiscount */
+ $itemDiscount = $this->discountInterfaceFactory->create();
+ $itemDiscount->setDiscountData($discount);
+ $itemDiscount->setRuleLabel($ruleLabel);
+ $itemDiscount->setRuleID($rule->getId());
+ $discountBreakdown[] = $itemDiscount;
$item->getExtensionAttributes()->setDiscounts($discountBreakdown);
}
return $this;
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index c4704df86c18f..af797750433f7 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -30,6 +30,8 @@
type="Magento\SalesRule\Model\Data\CouponMassDeleteResult" />
+
diff --git a/app/code/Magento/SalesRule/etc/extension_attributes.xml b/app/code/Magento/SalesRule/etc/extension_attributes.xml
index c6df13e50fd15..f7ebcaaa35063 100644
--- a/app/code/Magento/SalesRule/etc/extension_attributes.xml
+++ b/app/code/Magento/SalesRule/etc/extension_attributes.xml
@@ -7,9 +7,9 @@
-->
-
+
-
+
\ No newline at end of file
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
index 8ef212a73dd14..44228ac1d7cba 100644
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
@@ -119,28 +119,32 @@ public function testResolvePlaceOrderWithProductHavingCartPromotion(): void
$resultFromQuoteItem = $this->connection->fetchRow($selectFromQuoteItem);
$serializedCartDiscount = $resultFromQuoteItem['discounts'];
- $this->assertTrue(array_key_exists($salesRuleId, $this->jsonSerializer->unserialize($serializedCartDiscount)));
$this->assertEquals(
10,
json_decode(
$this->jsonSerializer->unserialize(
$serializedCartDiscount
)
- [$salesRuleId]['discount'],
+ [0]['discount'],
true
)['amount']
);
$this->assertEquals(
'TestRule_Label',
- $this->jsonSerializer->unserialize($serializedCartDiscount)[$salesRuleId]['rule']
+ $this->jsonSerializer->unserialize($serializedCartDiscount)[0]['rule']
+ );
+ $this->assertEquals(
+ $salesRuleId,
+ $this->jsonSerializer->unserialize($serializedCartDiscount)[0]['ruleID']
);
$quote = $this->getQuote();
$quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
- $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getAmount());
- $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseAmount());
- $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getOriginalAmount());
- $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseOriginalAmount());
- $this->assertEquals('TestRule_Label', $quoteAddressItemDiscount[$salesRuleId]['rule']);
+ $discountData = $quoteAddressItemDiscount[0]->getDiscountData();
+ $this->assertEquals(10, $discountData->getAmount());
+ $this->assertEquals(10, $discountData->getBaseAmount());
+ $this->assertEquals(10, $discountData->getOriginalAmount());
+ $this->assertEquals(10, $discountData->getBaseOriginalAmount());
+ $this->assertEquals('TestRule_Label', $quoteAddressItemDiscount[0]->getRuleLabel());
$addressType = 'shipping';
$selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
From ea0e3f745bb6f223b777768a0dece736c46c71cf Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Sun, 13 Oct 2019 22:44:59 -0500
Subject: [PATCH 0373/1978] MC-20648: Implement the changes - Integration/
static fixes
---
app/code/Magento/SalesRule/Api/Data/DiscountInterface.php | 4 ++--
app/code/Magento/SalesRule/Model/Quote/Discount.php | 2 --
.../Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php | 2 +-
app/code/Magento/SalesRule/Model/RulesApplier.php | 4 +++-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
index 2c93cc95dcf3a..fc2376ed66a8a 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
@@ -13,14 +13,14 @@ interface DiscountInterface
/**
* Get Discount Data
*
- * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
+ * @return mixed
*/
public function getDiscountData();
/**
* Get Rule Label
*
- * @return mixed
+ * @return string
*/
public function getRuleLabel();
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 36e8c81e0f4dd..132d66f3f5add 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -120,14 +120,12 @@ public function collect(
if ($item->getNoDiscount() || !$this->calculator->canApplyDiscount($item)) {
$item->setDiscountAmount(0);
$item->setBaseDiscountAmount(0);
- $item->getExtensionAttributes()->setDiscounts([]);
// ensure my children are zeroed out
if ($item->getHasChildren() && $item->isChildrenCalculated()) {
foreach ($item->getChildren() as $child) {
$child->setDiscountAmount(0);
$child->setBaseDiscountAmount(0);
- $item->getExtensionAttributes()->setDiscounts([]);
}
}
continue;
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
index 63d54e2c7fa88..3e228b9f524a5 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
@@ -41,7 +41,7 @@ public function beforeSave(CartItemPersister $subject, CartInterface $quote, Car
$discounts = $cartExtension->getDiscounts();
$serializedDiscount = [];
if ($discounts) {
- foreach ($discounts as $key => $value) {
+ foreach ($discounts as $value) {
$discount = $value->getDiscountData();
$discountData = [
"amount" => $discount->getAmount(),
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index ec01ac541c09a..ccd70d0f8e43b 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -93,7 +93,9 @@ public function applyRules($item, $rules, $skipValidation, $couponCode)
{
$address = $item->getAddress();
$appliedRuleIds = [];
- $item->getExtensionAttributes()->setDiscounts([]);
+ if ($item->getExtensionAttributes()) {
+ $item->getExtensionAttributes()->setDiscounts([]);
+ }
/* @var $rule Rule */
foreach ($rules as $rule) {
if (!$this->validatorUtility->canProcessRule($rule, $address)) {
From fae93e2078c3296cfad02f473ec4d918b485b393 Mon Sep 17 00:00:00 2001
From: Eden
Date: Mon, 14 Oct 2019 16:36:03 +0700
Subject: [PATCH 0374/1978] Resolve "Shopping Cart Summary" in backend is
different from frontend, and not following the setting #25036
---
.../Order/Create/Sidebar/AbstractSidebar.php | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
index 06c6a9eb0652b..2969009857410 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
@@ -3,9 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
+declare(strict_types=1);
+
namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
use Magento\Framework\Pricing\PriceCurrencyInterface;
+use Magento\Store\Model\ScopeInterface;
/**
* Adminhtml sales order create sidebar block
@@ -132,7 +136,20 @@ public function getItemCount()
{
$count = $this->getData('item_count');
if ($count === null) {
- $count = count($this->getItems());
+ $useQty = $this->_scopeConfig->getValue(
+ 'checkout/cart_link/use_qty',
+ ScopeInterface::SCOPE_STORE
+ );
+ $allItems = $this->getItems();
+ if ($useQty) {
+ $count = 0;
+ foreach ($allItems as $item) {
+ $count += $item->getQty();
+ }
+ } else {
+ $count = count($allItems);
+ }
+
$this->setData('item_count', $count);
}
return $count;
From ac52c3e72b247ad333420b769ed07234b7267d53 Mon Sep 17 00:00:00 2001
From: Veronika Kurochkina
Date: Mon, 14 Oct 2019 13:09:26 +0300
Subject: [PATCH 0375/1978] MAGETWO-98703: CSV file is not exported
- Fix functional test
---
.../Test/Constraint/AssertExportSubmittedMessage.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertExportSubmittedMessage.php b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertExportSubmittedMessage.php
index 59b1c7570c3de..363614825e568 100644
--- a/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertExportSubmittedMessage.php
+++ b/dev/tests/functional/tests/app/Magento/ImportExport/Test/Constraint/AssertExportSubmittedMessage.php
@@ -16,7 +16,8 @@ class AssertExportSubmittedMessage extends AbstractConstraint
/**
* Text value to be checked.
*/
- const MESSAGE = 'Message is added to queue, wait to get your file soon';
+ const MESSAGE = 'Message is added to queue, wait to get your file soon.'
+ . ' Make sure your cron job is running to export the file';
/**
* Assert that export submitted message is visible after exporting.
From 59d2ad877ab7690770904c665c7e85386a0bffb2 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Mon, 14 Oct 2019 09:17:22 -0500
Subject: [PATCH 0376/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../CatalogRule/Model/Indexer/IndexBuilder.php | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 864c814775377..ed0950588ca63 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -297,12 +297,14 @@ protected function doReindexByIds($ids)
$this->reindexRuleProduct->execute($rule, $this->batchCount);
}
- foreach ($ids as $productId) {
- $this->cleanProductPriceIndex([$productId]);
- $this->reindexRuleProductPrice->execute($this->batchCount, $productId);
+ $products = $this->productLoader->getProducts($ids);
+ if ($products) {
+ foreach ($products as $product) {
+ $this->cleanProductPriceIndex([$product->getId()]);
+ $this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
+ }
+ $this->reindexRuleGroupWebsite->execute();
}
-
- $this->reindexRuleGroupWebsite->execute();
}
/**
From 1b0df3d277a1fa4cccc45011a6e71f816976b9ec Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Mon, 14 Oct 2019 11:16:20 -0500
Subject: [PATCH 0377/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
app/code/Magento/Rule/Model/Condition/Sql/Builder.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php
index 33e1bf97c3474..eac211325d700 100644
--- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php
+++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php
@@ -268,6 +268,7 @@ public function attachConditionToCollection(
$condition = "'" . trim($condition) . "'";
}
$conditions = implode(', ', $conditions);
+ $collection->getSelect()->reset(Select::ORDER);
$collection->getSelect()->order("FIELD($attributeField, $conditions)");
}
} else {
From 4befb36d33b664e9bf3d8b5f913d7deaa6968e3e Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 14 Oct 2019 11:52:40 -0500
Subject: [PATCH 0378/1978] MC-20648: Implement the changes - Integration/
webapi fixes
---
.../Magento/SalesRule/Model/RulesApplier.php | 14 ++++++-----
.../Rule/Action/Discount/CartFixedTest.php | 24 +++++++++++--------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index ccd70d0f8e43b..e8392b036e1a3 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -53,6 +53,11 @@ class RulesApplier
*/
private $discountInterfaceFactory;
+ /**
+ * @var array
+ */
+ private $discountAggregator;
+
/**
* @param CalculatorFactory $calculatorFactory
* @param \Magento\Framework\Event\ManagerInterface $eventManager
@@ -93,9 +98,7 @@ public function applyRules($item, $rules, $skipValidation, $couponCode)
{
$address = $item->getAddress();
$appliedRuleIds = [];
- if ($item->getExtensionAttributes()) {
- $item->getExtensionAttributes()->setDiscounts([]);
- }
+ $this->discountAggregator = [];
/* @var $rule Rule */
foreach ($rules as $rule) {
if (!$this->validatorUtility->canProcessRule($rule, $address)) {
@@ -231,15 +234,14 @@ private function setDiscountBreakdown($discountData, $item, $rule, $address)
$discount->setAmount($discountData->getAmount());
$discount->setBaseAmount($discountData->getBaseAmount());
$discount->setOriginalAmount($discountData->getOriginalAmount());
- $discountBreakdown = $item->getExtensionAttributes()->getDiscounts() ?? [];
$ruleLabel = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
/** @var \Magento\SalesRule\Model\Data\RuleDiscount $itemDiscount */
$itemDiscount = $this->discountInterfaceFactory->create();
$itemDiscount->setDiscountData($discount);
$itemDiscount->setRuleLabel($ruleLabel);
$itemDiscount->setRuleID($rule->getId());
- $discountBreakdown[] = $itemDiscount;
- $item->getExtensionAttributes()->setDiscounts($discountBreakdown);
+ $this->discountAggregator[] = $itemDiscount;
+ $item->getExtensionAttributes()->setDiscounts($this->discountAggregator);
}
return $this;
}
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 9204bb840265c..a4ef344fcb05f 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
@@ -170,18 +170,22 @@ public function testDiscountsOnQuoteWithFixedDiscount(): void
/** @var CartItemInterface $item */
$item = $quote->getItems()[0];
$quoteItemDiscounts = $item->getExtensionAttributes()->getDiscounts();
- $this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getAmount());
- $this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getBaseAmount());
- $this->assertEquals(5, $quoteItemDiscounts[$salesRuleId]['discount']->getOriginalAmount());
- $this->assertEquals(10, $quoteItemDiscounts[$salesRuleId]['discount']->getBaseOriginalAmount());
- $this->assertEquals('TestRule_Coupon', $quoteItemDiscounts[$salesRuleId]['rule']);
+ $discountData = $quoteItemDiscounts[0]->getDiscountData();
+ $ruleLabel = $quoteItemDiscounts[0]->getRuleLabel();
+ $this->assertEquals(5, $discountData->getAmount());
+ $this->assertEquals(5, $discountData->getBaseAmount());
+ $this->assertEquals(5, $discountData->getOriginalAmount());
+ $this->assertEquals(10, $discountData->getBaseOriginalAmount());
+ $this->assertEquals('TestRule_Coupon', $ruleLabel);
$quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
- $this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getAmount());
- $this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseAmount());
- $this->assertEquals(5, $quoteAddressItemDiscount[$salesRuleId]['discount']->getOriginalAmount());
- $this->assertEquals(10, $quoteAddressItemDiscount[$salesRuleId]['discount']->getBaseOriginalAmount());
- $this->assertEquals('TestRule_Coupon', $quoteAddressItemDiscount[$salesRuleId]['rule']);
+ $discountData = $quoteAddressItemDiscount[0]->getDiscountData();
+ $ruleLabel = $quoteAddressItemDiscount[0]->getRuleLabel();
+ $this->assertEquals(5, $discountData->getAmount());
+ $this->assertEquals(5, $discountData->getBaseAmount());
+ $this->assertEquals(5, $discountData->getOriginalAmount());
+ $this->assertEquals(10, $discountData->getBaseOriginalAmount());
+ $this->assertEquals('TestRule_Coupon', $ruleLabel);
}
/**
From 90b4370a0726d55516d45d0ca9ad2d5ba14cb6c8 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Mon, 14 Oct 2019 12:48:02 -0500
Subject: [PATCH 0379/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../CatalogRule/Model/Indexer/IndexBuilder.php | 12 +++++-------
.../CatalogRule/Model/Indexer/ProductRuleReindex.php | 4 ++--
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index ed0950588ca63..ecdd124786efc 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -297,14 +297,12 @@ protected function doReindexByIds($ids)
$this->reindexRuleProduct->execute($rule, $this->batchCount);
}
- $products = $this->productLoader->getProducts($ids);
- if ($products) {
- foreach ($products as $product) {
- $this->cleanProductPriceIndex([$product->getId()]);
- $this->reindexRuleProductPrice->execute($this->batchCount, $product->getId());
- }
- $this->reindexRuleGroupWebsite->execute();
+ $this->cleanProductPriceIndex($ids);
+ foreach ($ids as $productId) {
+ $this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
+
+ $this->reindexRuleGroupWebsite->execute();
}
/**
diff --git a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php
index 9c66719334639..edc827ec57ac2 100644
--- a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php
+++ b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php
@@ -88,8 +88,8 @@ private function reindexSubProducts(
$subProducts = [];
if ($configurableIds) {
$subProducts = array_values($this->configurable->getChildrenIds($configurableIds)[0]);
- if ($subProducts) {
- $subject->executeList($subProducts);
+ foreach ($subProducts as $subProduct) {
+ $subject->executeRow($subProduct);
}
}
return $subProducts;
From f0af94e799676515a30327ff412a0d9bd9205e7b Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 14 Oct 2019 13:30:44 -0500
Subject: [PATCH 0380/1978] MC-20648: Implement the changes - static fix
---
.../SalesRule/Model/Rule/Action/Discount/CartFixedTest.php | 3 ---
1 file changed, 3 deletions(-)
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 a4ef344fcb05f..81793b52400d1 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
@@ -164,9 +164,6 @@ public function testDiscountsOnQuoteWithFixedDiscount(): void
$quote->setCouponCode('CART_FIXED_DISCOUNT_15');
$quote->collectTotals();
$this->quoteRepository->save($quote);
- /** @var Rule $rule */
- $rule = $this->getSalesRule('15$ fixed discount on whole cart');
- $salesRuleId = $rule->getRuleId();
/** @var CartItemInterface $item */
$item = $quote->getItems()[0];
$quoteItemDiscounts = $item->getExtensionAttributes()->getDiscounts();
From 995ddbe9756dc59edf78ec79724f222e1b9f11bc Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 14 Oct 2019 14:08:21 -0500
Subject: [PATCH 0381/1978] MC-18685: Remove custom layout updates from admin
---
.../Magento/Sales/Cron/CleanExpiredQuotesTest.php | 8 ++++++--
.../testsuite/Magento/Sales/_files/quotes.php | 11 +++++++++--
2 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php
index 1b68bc0520ce5..fc39972b5e9f7 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/Cron/CleanExpiredQuotesTest.php
@@ -53,10 +53,14 @@ protected function setUp()
*/
public function testExecute()
{
- $this->cleanExpiredQuotes->execute();
$searchCriteria = $this->searchCriteriaBuilder->create();
- $totalCount = $this->quoteRepository->getList($searchCriteria)->getTotalCount();
+ //Initial count - should be equal to stores number.
+ $this->assertEquals(2, $this->quoteRepository->getList($searchCriteria)->getTotalCount());
+ //Deleting expired quotes
+ $this->cleanExpiredQuotes->execute();
+ $totalCount = $this->quoteRepository->getList($searchCriteria)->getTotalCount();
+ //Only 1 will be deleted for the store that has all of them expired by config (default_store)
$this->assertEquals(
1,
$totalCount
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
index b916fc0240417..071889e74f56d 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
@@ -7,10 +7,12 @@
use Magento\Quote\Model\QuoteFactory;
use Magento\Quote\Model\QuoteRepository;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreFactory;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
-require dirname(dirname(__DIR__)) . '/Store/_files/second_store.php';
+require __DIR__ . '/../../Store/_files/second_store.php';
/** @var $objectManager ObjectManager */
$objectManager = Bootstrap::getObjectManager();
@@ -18,13 +20,18 @@
$quoteFactory = $objectManager->get(QuoteFactory::class);
/** @var QuoteRepository $quoteRepository */
$quoteRepository = $objectManager->get(QuoteRepository::class);
+/** @var StoreFactory $storeFactory */
+$storeFactory = $objectManager->get(StoreFactory::class);
+/** @var Store $secondStore */
+$secondStore = $storeFactory->create();
+$secondStore->load('fixture_second_store', 'code');
$quotes = [
'quote for first store' => [
'store' => 1,
],
'quote for second store' => [
- 'store' => 2,
+ 'store' => $secondStore->getId(),
],
];
From 0347c1d4eefe0708d1f454d9d636c143b01b5bd7 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 14 Oct 2019 15:29:13 -0500
Subject: [PATCH 0382/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Source/AbstractLayoutUpdate.php | 101 ++++++++++++++++++
.../Attribute/LayoutUpdateManager.php | 2 +-
.../Attribute/Source/LayoutUpdate.php | 54 +---------
.../Catalog/Model/Category/DataProvider.php | 2 +-
.../Product/Attribute/LayoutUpdateManager.php | 2 +-
.../Product/Attribute/Source/LayoutUpdate.php | 51 +--------
.../Product/Form/Modifier/Eav.php | 2 +-
.../Product/Form/Modifier/LayoutUpdate.php | 27 ++++-
app/code/Magento/Catalog/etc/di.xml | 4 +-
9 files changed, 137 insertions(+), 108 deletions(-)
create mode 100644 app/code/Magento/Catalog/Model/Attribute/Source/AbstractLayoutUpdate.php
diff --git a/app/code/Magento/Catalog/Model/Attribute/Source/AbstractLayoutUpdate.php b/app/code/Magento/Catalog/Model/Attribute/Source/AbstractLayoutUpdate.php
new file mode 100644
index 0000000000000..0003b9996c84b
--- /dev/null
+++ b/app/code/Magento/Catalog/Model/Attribute/Source/AbstractLayoutUpdate.php
@@ -0,0 +1,101 @@
+optionsText[$default] = $defaultText;
+
+ return [['label' => $defaultText, 'value' => $default]];
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getOptionText($value)
+ {
+ if (is_scalar($value) && array_key_exists($value, $this->optionsText)) {
+ return $this->optionsText[$value];
+ }
+
+ return false;
+ }
+
+ /**
+ * Extract attribute value.
+ *
+ * @param CustomAttributesDataInterface|AbstractExtensibleModel $entity
+ * @return mixed
+ */
+ private function extractAttributeValue(CustomAttributesDataInterface $entity)
+ {
+ $attrCode = 'custom_layout_update';
+ if ($entity instanceof AbstractExtensibleModel
+ && !$entity->hasData(CustomAttributesDataInterface::CUSTOM_ATTRIBUTES)
+ ) {
+ //Custom attributes were not loaded yet, using data array
+ return $entity->getData($attrCode);
+ }
+ //Fallback to customAttribute method
+ $attr = $entity->getCustomAttribute($attrCode);
+
+ return $attr ? $attr->getValue() : null;
+ }
+
+ /**
+ * List available layout update options for the entity.
+ *
+ * @param CustomAttributesDataInterface $entity
+ * @return string[]
+ */
+ abstract protected function listAvailableOptions(CustomAttributesDataInterface $entity): array;
+
+ /**
+ * @inheritDoc
+ *
+ * @param CustomAttributesDataInterface|AbstractExtensibleModel $entity
+ */
+ public function getOptionsFor(CustomAttributesDataInterface $entity): array
+ {
+ $options = $this->getAllOptions();
+ if ($this->extractAttributeValue($entity)) {
+ $existingValue = Backend::VALUE_USE_UPDATE_XML;
+ $existingLabel = 'Use existing';
+ $options[] = ['label' => $existingLabel, 'value' => $existingValue];
+ $this->optionsText[$existingValue] = $existingLabel;
+ }
+ foreach ($this->listAvailableOptions($entity) as $handle) {
+ $options[] = ['label' => $handle, 'value' => $handle];
+ $this->optionsText[$handle] = $handle;
+ }
+
+ return $options;
+ }
+}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
index 6cf8e93f2c3f1..f5694a46d3fb2 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/LayoutUpdateManager.php
@@ -121,7 +121,7 @@ function (string $handle) use ($category) : ?string {
*/
private function extractAttributeValue(CategoryInterface $category)
{
- if ($category instanceof Category && $category->hasData('custom_layout_update_file')) {
+ if ($category instanceof Category && !$category->hasData(CategoryInterface::CUSTOM_ATTRIBUTES)) {
return $category->getData('custom_layout_update_file');
}
if ($attr = $category->getCustomAttribute('custom_layout_update_file')) {
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index d3012b1b49587..1c307220aa9f8 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -8,23 +8,15 @@
namespace Magento\Catalog\Model\Category\Attribute\Source;
-use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
-use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
-use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Framework\Api\CustomAttributesDataInterface;
-use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as Backend;
+use Magento\Catalog\Model\Attribute\Source\AbstractLayoutUpdate;
/**
* List of layout updates available for a category.
*/
-class LayoutUpdate extends AbstractSource implements SpecificSourceInterface
+class LayoutUpdate extends AbstractLayoutUpdate
{
- /**
- * @var string[]
- */
- private $optionsText;
-
/**
* @var LayoutUpdateManager
*/
@@ -41,46 +33,8 @@ public function __construct(LayoutUpdateManager $manager)
/**
* @inheritDoc
*/
- public function getAllOptions()
- {
- $default = Backend::VALUE_NO_UPDATE;
- $defaultText = 'No update';
- $this->optionsText[$default] = $defaultText;
-
- return [['label' => $defaultText, 'value' => $default]];
- }
-
- /**
- * @inheritDoc
- */
- public function getOptionText($value)
+ protected function listAvailableOptions(CustomAttributesDataInterface $entity): array
{
- if (is_scalar($value) && array_key_exists($value, $this->optionsText)) {
- return $this->optionsText[$value];
- }
-
- return false;
- }
-
- /**
- * @inheritDoc
- *
- * @param CategoryInterface $entity
- */
- public function getOptionsFor(CustomAttributesDataInterface $entity): array
- {
- $options = $this->getAllOptions();
- if ($entity->getCustomAttribute('custom_layout_update')) {
- $existingValue = Backend::VALUE_USE_UPDATE_XML;
- $existingLabel = 'Use existing';
- $options[] = ['label' => $existingLabel, 'value' => $existingValue];
- $this->optionsText[$existingValue] = $existingLabel;
- }
- foreach ($this->manager->fetchAvailableFiles($entity) as $handle) {
- $options[] = ['label' => $handle, 'value' => $handle];
- $this->optionsText[$handle] = $handle;
- }
-
- return $options;
+ return $this->manager->fetchAvailableFiles($entity);
}
}
diff --git a/app/code/Magento/Catalog/Model/Category/DataProvider.php b/app/code/Magento/Catalog/Model/Category/DataProvider.php
index f7692e22314e4..283e3f87686b9 100644
--- a/app/code/Magento/Catalog/Model/Category/DataProvider.php
+++ b/app/code/Magento/Catalog/Model/Category/DataProvider.php
@@ -386,7 +386,7 @@ public function getAttributesMeta(Type $entityType)
if ($source instanceof SpecificSourceInterface && $currentCategory) {
$options = $source->getOptionsFor($currentCategory);
} else {
- $options = $attribute->getSource()->getAllOptions();
+ $options = $source->getAllOptions();
}
foreach ($options as &$option) {
$option['__disableTmpl'] = true;
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
index 91f84f88fa6d9..92ae989500076 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/LayoutUpdateManager.php
@@ -133,7 +133,7 @@ function (string $handle) use ($identifier) : ?string {
*/
private function extractAttributeValue(ProductInterface $product)
{
- if ($product instanceof Product && $product->hasData('custom_layout_update_file')) {
+ if ($product instanceof Product && !$product->hasData(ProductInterface::CUSTOM_ATTRIBUTES)) {
return $product->getData('custom_layout_update_file');
}
if ($attr = $product->getCustomAttribute('custom_layout_update_file')) {
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index 467bbfc629020..0ddb528e768cc 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -8,22 +8,15 @@
namespace Magento\Catalog\Model\Product\Attribute\Source;
+use Magento\Catalog\Model\Attribute\Source\AbstractLayoutUpdate;
use Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager;
-use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
-use Magento\Eav\Model\Entity\Attribute\Source\SpecificSourceInterface;
use Magento\Framework\Api\CustomAttributesDataInterface;
-use Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate as Backend;
/**
* List of layout updates available for a product.
*/
-class LayoutUpdate extends AbstractSource implements SpecificSourceInterface
+class LayoutUpdate extends AbstractLayoutUpdate
{
- /**
- * @var string[]
- */
- private $optionsText;
-
/**
* @var LayoutUpdateManager
*/
@@ -40,44 +33,8 @@ public function __construct(LayoutUpdateManager $manager)
/**
* @inheritDoc
*/
- public function getAllOptions()
- {
- $default = Backend::VALUE_NO_UPDATE;
- $defaultText = 'No update';
- $this->optionsText[$default] = $defaultText;
-
- return [['label' => $defaultText, 'value' => $default]];
- }
-
- /**
- * @inheritDoc
- */
- public function getOptionText($value)
+ protected function listAvailableOptions(CustomAttributesDataInterface $entity): array
{
- if (is_scalar($value) && array_key_exists($value, $this->optionsText)) {
- return $this->optionsText[$value];
- }
-
- return false;
- }
-
- /**
- * @inheritDoc
- */
- public function getOptionsFor(CustomAttributesDataInterface $entity): array
- {
- $options = $this->getAllOptions();
- if ($entity->getCustomAttribute('custom_layout_update')) {
- $existingValue = Backend::VALUE_USE_UPDATE_XML;
- $existingLabel = 'Use existing';
- $options[] = ['label' => $existingLabel, 'value' => $existingValue];
- $this->optionsText[$existingValue] = $existingLabel;
- }
- foreach ($this->manager->fetchAvailableFiles($entity) as $handle) {
- $options[] = ['label' => $handle, 'value' => $handle];
- $this->optionsText[$handle] = $handle;
- }
-
- return $options;
+ return $this->manager->fetchAvailableFiles($entity);
}
}
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
index 675e114032f92..8686527c29433 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav.php
@@ -697,7 +697,7 @@ public function setupAttributeMeta(ProductAttributeInterface $attribute, $groupC
if ($source instanceof SpecificSourceInterface) {
$options = $source->getOptionsFor($product);
} else {
- $options = $attributeModel->getSource()->getAllOptions(true, true);
+ $options = $source->getAllOptions(true, true);
}
foreach ($options as &$option) {
$option['__disableTmpl'] = true;
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
index de0e640e09d76..14c1eb9b95b27 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
@@ -8,7 +8,9 @@
namespace Magento\Catalog\Ui\DataProvider\Product\Form\Modifier;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Locator\LocatorInterface;
+use Magento\Catalog\Model\Product;
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
/**
@@ -29,6 +31,23 @@ public function __construct(LocatorInterface $locator)
$this->locator = $locator;
}
+ /**
+ * Extract custom layout value.
+ *
+ * @param ProductInterface|Product $product
+ * @return mixed
+ */
+ private function extractLayoutUpdate(ProductInterface $product)
+ {
+ if ($product instanceof Product && !$product->hasData(Product::CUSTOM_ATTRIBUTES)) {
+ return $product->getData('custom_layout_update');
+ }
+
+ $attr = $product->getCustomAttribute('custom_layout_update');
+
+ return $attr ? $attr->getValue() : null;
+ }
+
/**
* @inheritdoc
* @since 101.1.0
@@ -36,11 +55,9 @@ public function __construct(LocatorInterface $locator)
public function modifyData(array $data)
{
$product = $this->locator->getProduct();
- if ($oldLayout = $product->getCustomAttribute('custom_layout_update')) {
- if ($oldLayout->getValue()) {
- $data[$product->getId()][AbstractModifier::DATA_SOURCE_DEFAULT]['custom_layout_update_file']
- = \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
- }
+ if ($oldLayout = $this->extractLayoutUpdate($product)) {
+ $data[$product->getId()][AbstractModifier::DATA_SOURCE_DEFAULT]['custom_layout_update_file']
+ = \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
}
return $data;
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index b6304d5945bfe..f0e43f62b1fd5 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1176,12 +1176,12 @@
-
+
Magento\Framework\View\Design\Theme\FlyweightFactory\Proxy
-
+
Magento\Framework\View\Design\Theme\FlyweightFactory\Proxy
From 3903cde64ea177b6be19ea1ac7b7cd71d6963029 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 14 Oct 2019 15:39:35 -0500
Subject: [PATCH 0383/1978] MC-20648: Implement the changes - static test fix
---
.../Rule/Action/Discount/CartFixedTest.php | 28 -------------------
1 file changed, 28 deletions(-)
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 81793b52400d1..3fbfec24353a2 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
@@ -8,7 +8,6 @@
namespace Magento\SalesRule\Model\Rule\Action\Discount;
use Magento\Catalog\Api\Data\ProductInterface;
-use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductRepository;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -22,9 +21,7 @@
use Magento\Quote\Model\QuoteIdMask;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
-use Magento\SalesRule\Model\Rule;
use Magento\TestFramework\Helper\Bootstrap;
-use Magento\SalesRule\Api\RuleRepositoryInterface;
/**
* Tests for Magento\SalesRule\Model\Rule\Action\Discount\CartFixed.
@@ -291,29 +288,4 @@ private function getOrder(string $incrementId): OrderInterface
return array_pop($items);
}
- /**
- * Gets rule by name.
- *
- * @param string $name
- * @return \Magento\SalesRule\Model\Rule
- * @throws \Magento\Framework\Exception\InputException
- * @throws \Magento\Framework\Exception\NoSuchEntityException
- */
- private function getSalesRule(string $name): \Magento\SalesRule\Model\Rule
- {
- /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
- $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
- ->create();
-
- /** @var CartRepositoryInterface $quoteRepository */
- $ruleRepository = $this->objectManager->get(RuleRepositoryInterface::class);
- $items = $ruleRepository->getList($searchCriteria)->getItems();
-
- $rule = array_pop($items);
- /** @var \Magento\SalesRule\Model\Converter\ToModel $converter */
- $converter = $this->objectManager->get(\Magento\SalesRule\Model\Converter\ToModel::class);
-
- return $converter->toModel($rule);
- }
}
From e89b753d6965bb2c19e196084d0463a5ab09fa81 Mon Sep 17 00:00:00 2001
From: Daniel Renaud
Date: Mon, 14 Oct 2019 15:43:04 -0500
Subject: [PATCH 0384/1978] MC-21694: Boolean attributes show "_bucket" in
graphql search aggregations
---
.../AttributeOptionProvider.php | 19 ++++--
.../LayeredNavigation/Builder/Attribute.php | 4 +-
.../Catalog/ProductSearchAggregationsTest.php | 64 +++++++++++++++++++
.../_files/product_boolean_attribute.php | 47 ++++++++++++++
.../product_boolean_attribute_rollback.php | 21 ++++++
.../products_with_boolean_attribute.php | 35 ++++++++++
...oducts_with_boolean_attribute_rollback.php | 8 +++
7 files changed, 192 insertions(+), 6 deletions(-)
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php
diff --git a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php
index 7781473128754..320e0adc29b9f 100644
--- a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php
+++ b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php
@@ -41,10 +41,11 @@ public function __construct(ResourceConnection $resourceConnection)
* Get option data. Return list of attributes with option data
*
* @param array $optionIds
+ * @param array $attributeCodes
* @return array
* @throws \Zend_Db_Statement_Exception
*/
- public function getOptions(array $optionIds): array
+ public function getOptions(array $optionIds, array $attributeCodes = []): array
{
if (!$optionIds) {
return [];
@@ -60,20 +61,28 @@ public function getOptions(array $optionIds): array
'attribute_label' => 'a.frontend_label',
]
)
- ->joinInner(
+ ->joinLeft(
['options' => $this->resourceConnection->getTableName('eav_attribute_option')],
'a.attribute_id = options.attribute_id',
[]
)
- ->joinInner(
+ ->joinLeft(
['option_value' => $this->resourceConnection->getTableName('eav_attribute_option_value')],
'options.option_id = option_value.option_id',
[
'option_label' => 'option_value.value',
'option_id' => 'option_value.option_id',
]
- )
- ->where('option_value.option_id IN (?)', $optionIds);
+ );
+
+ $select->where('option_value.option_id IN (?)', $optionIds);
+
+ if (!empty($attributeCodes)) {
+ $select->orWhere(
+ 'a.attribute_code in (?) AND a.frontend_input = \'boolean\'',
+ $attributeCodes
+ );
+ }
return $this->formatResult($select);
}
diff --git a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php
index b70c9f6165fc6..0ec65c88024f2 100644
--- a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php
+++ b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php
@@ -139,7 +139,9 @@ private function isBucketEmpty(?BucketInterface $bucket): bool
private function getAttributeOptions(AggregationInterface $aggregation): array
{
$attributeOptionIds = [];
+ $attributes = [];
foreach ($this->getAttributeBuckets($aggregation) as $bucket) {
+ $attributes[] = \preg_replace('~_bucket$~', '', $bucket->getName());
$attributeOptionIds[] = \array_map(
function (AggregationValueInterface $value) {
return $value->getValue();
@@ -152,6 +154,6 @@ function (AggregationValueInterface $value) {
return [];
}
- return $this->attributeOptionProvider->getOptions(\array_merge(...$attributeOptionIds));
+ return $this->attributeOptionProvider->getOptions(\array_merge(...$attributeOptionIds), $attributes);
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php
new file mode 100644
index 0000000000000..113b342ddd79f
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php
@@ -0,0 +1,64 @@
+graphQlQuery($query);
+
+ $this->assertArrayNotHasKey('errors', $result);
+ $this->assertArrayHasKey('items', $result['products']);
+ $this->assertCount(5, $result['products']['items']);
+ $this->assertArrayHasKey('aggregations', $result['products']);
+
+ $booleanAggregation = array_filter(
+ $result['products']['aggregations'],
+ function ($a) {
+ return $a['attribute_code'] == 'boolean_attribute';
+ }
+ );
+ $this->assertNotEmpty($booleanAggregation);
+ $booleanAggregation = reset($booleanAggregation);
+ $this->assertEquals('Boolean Attribute', $booleanAggregation['label']);
+ $this->assertEquals('boolean_attribute', $booleanAggregation['attribute_code']);
+ $this->assertEquals(2, $booleanAggregation['count']);
+ $this->assertCount(2, $booleanAggregation['options']);
+ $this->assertContains(['label' => '0', 'value'=> '0', 'count' => '2'], $booleanAggregation['options']);
+ $this->assertContains(['label' => '1', 'value'=> '1', 'count' => '3'], $booleanAggregation['options']);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php
new file mode 100644
index 0000000000000..30900db5690ff
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php
@@ -0,0 +1,47 @@
+get(AttributeRepositoryInterface::class);
+/** @var Attribute $attribute */
+$attribute = $objectManager->create(Attribute::class);
+/** @var $installer \Magento\Catalog\Setup\CategorySetup */
+$installer = $objectManager->create(CategorySetup::class);
+
+$attribute->setData(
+ [
+ 'attribute_code' => 'boolean_attribute',
+ 'entity_type_id' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID,
+ 'is_global' => 0,
+ 'is_user_defined' => 1,
+ 'frontend_input' => 'boolean',
+ 'is_unique' => 0,
+ 'is_required' => 0,
+ 'is_searchable' => 1,
+ 'is_visible_in_advanced_search' => 1,
+ 'is_comparable' => 0,
+ 'is_filterable' => 1,
+ 'is_filterable_in_search' => 1,
+ 'is_used_for_promo_rules' => 0,
+ 'is_html_allowed_on_front' => 1,
+ 'is_visible_on_front' => 1,
+ 'used_in_product_listing' => 1,
+ 'used_for_sort_by' => 0,
+ 'frontend_label' => ['Boolean Attribute'],
+ 'backend_type' => 'int'
+ ]
+);
+
+$attributeRepository->save($attribute);
+
+/* Assign attribute to attribute set */
+$installer->addAttributeToGroup('catalog_product', 'Default', 'Attributes', $attribute->getId());
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php
new file mode 100644
index 0000000000000..c234eb91c84a6
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php
@@ -0,0 +1,21 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+/** @var Attribute $attribute */
+$attribute = $objectManager->create(Attribute::class);
+$attribute->load('boolean_attribute', 'attribute_code');
+$attribute->delete();
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php
new file mode 100644
index 0000000000000..65c8c5a251881
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php
@@ -0,0 +1,35 @@
+get(ProductRepositoryInterface::class);
+
+$yesIds = [101, 102, 104];
+$noIds = [103, 105];
+
+foreach ($yesIds as $id) {
+ $product = $productRepository->getById($id);
+ $product->setBooleanAttribute(1);
+ $productRepository->save($product);
+}
+foreach ($noIds as $id) {
+ $product = $productRepository->getById($id);
+ $product->setBooleanAttribute(0);
+ $productRepository->save($product);
+}
+CacheCleaner::cleanAll();
+/** @var \Magento\Indexer\Model\Indexer\Collection $indexerCollection */
+$indexerCollection = $objectManager->get(\Magento\Indexer\Model\Indexer\Collection::class);
+$indexerCollection->load();
+/** @var \Magento\Indexer\Model\Indexer $indexer */
+foreach ($indexerCollection->getItems() as $indexer) {
+ $indexer->reindexAll();
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php
new file mode 100644
index 0000000000000..8a70aead1f36d
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php
@@ -0,0 +1,8 @@
+
Date: Tue, 15 Oct 2019 00:09:10 +0300
Subject: [PATCH 0385/1978] Replaced hardcoded custom option types and groups
with injected array arguments (#24726)
---
.../Magento/Catalog/Model/Product/Option.php | 47 ++++++++++---------
app/code/Magento/Catalog/etc/di.xml | 23 ++++++++-
2 files changed, 47 insertions(+), 23 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 4f730834412e4..c4c042db3cdac 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option\Type\DefaultType;
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
use Magento\Catalog\Pricing\Price\BasePrice;
use Magento\Framework\EntityManager\MetadataPool;
@@ -98,6 +99,16 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
*/
protected $validatorPool;
+ /**
+ * @var DefaultType[]
+ */
+ private $groupsPool;
+
+ /**
+ * @var string[]
+ */
+ private $typesPool;
+
/**
* @var MetadataPool
*/
@@ -120,6 +131,8 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
+ * @param array $groupsPool
+ * @param array $typesPool
* @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -135,12 +148,16 @@ public function __construct(
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
+ array $groupsPool = [],
+ array $typesPool = [],
ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null
) {
$this->productOptionValue = $productOptionValue;
$this->optionTypeFactory = $optionFactory;
- $this->validatorPool = $validatorPool;
$this->string = $string;
+ $this->validatorPool = $validatorPool;
+ $this->groupsPool = $groupsPool;
+ $this->typesPool = $typesPool;
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
@@ -306,44 +323,30 @@ public function setProduct(Product $product = null)
/**
* Get group name of option by given option type
*
- * @param string $type
+ * @param string|null $type
* @return string
*/
- public function getGroupByType($type = null)
+ public function getGroupByType($type = null): string
{
if ($type === null) {
$type = $this->getType();
}
- $optionGroupsToTypes = [
- self::OPTION_TYPE_FIELD => self::OPTION_GROUP_TEXT,
- self::OPTION_TYPE_AREA => self::OPTION_GROUP_TEXT,
- self::OPTION_TYPE_FILE => self::OPTION_GROUP_FILE,
- self::OPTION_TYPE_DROP_DOWN => self::OPTION_GROUP_SELECT,
- self::OPTION_TYPE_RADIO => self::OPTION_GROUP_SELECT,
- self::OPTION_TYPE_CHECKBOX => self::OPTION_GROUP_SELECT,
- self::OPTION_TYPE_MULTIPLE => self::OPTION_GROUP_SELECT,
- self::OPTION_TYPE_DATE => self::OPTION_GROUP_DATE,
- self::OPTION_TYPE_DATE_TIME => self::OPTION_GROUP_DATE,
- self::OPTION_TYPE_TIME => self::OPTION_GROUP_DATE,
- ];
- return $optionGroupsToTypes[$type] ?? '';
+ return $this->typesPool[$type] ?? '';
}
/**
* Group model factory
*
* @param string $type Option type
- * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType
+ * @return DefaultType
* @throws LocalizedException
*/
- public function groupFactory($type)
+ public function groupFactory($type): DefaultType
{
$group = $this->getGroupByType($type);
- if (!empty($group)) {
- return $this->optionTypeFactory->create(
- 'Magento\Catalog\Model\Product\Option\Type\\' . $this->string->upperCaseWords($group)
- );
+ if (!empty($group) && isset($this->groupsPool[$group])) {
+ return $this->optionTypeFactory->create($this->groupsPool[$group]);
}
throw new LocalizedException(__('The option type to get group instance is incorrect.'));
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 570fa6e7f9ef7..6d9360dc3be97 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -72,7 +72,6 @@
-
@@ -411,6 +410,28 @@
+
+
+
+ - Magento\Catalog\Model\Product\Option\Type\Date
+ - Magento\Catalog\Model\Product\Option\Type\File
+ - Magento\Catalog\Model\Product\Option\Type\Select
+ - Magento\Catalog\Model\Product\Option\Type\Text
+
+
+ - text
+ - text
+ - file
+ - select
+ - select
+ - select
+ - select
+ - date
+ - date
+ - date
+
+
+
From c966fdc84c5e2fe276ff2523499a564f4536e82b Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 14 Oct 2019 17:03:49 -0500
Subject: [PATCH 0386/1978] MC-18685: Remove custom layout updates from admin
---
.../Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
index 14c1eb9b95b27..453be0c1a1582 100644
--- a/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/LayoutUpdate.php
@@ -55,7 +55,7 @@ private function extractLayoutUpdate(ProductInterface $product)
public function modifyData(array $data)
{
$product = $this->locator->getProduct();
- if ($oldLayout = $this->extractLayoutUpdate($product)) {
+ if ($this->extractLayoutUpdate($product)) {
$data[$product->getId()][AbstractModifier::DATA_SOURCE_DEFAULT]['custom_layout_update_file']
= \Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate::VALUE_USE_UPDATE_XML;
}
From 3345605e79b0ec719f5b0a05d73db0c9c78e571b Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Mon, 14 Oct 2019 17:15:43 -0500
Subject: [PATCH 0387/1978] MC-21808: MySQL performance query optimization
---
.../Search/Model/PopularSearchTerms.php | 26 ++++++++++++++-----
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Search/Model/PopularSearchTerms.php b/app/code/Magento/Search/Model/PopularSearchTerms.php
index d5ddc0e1dac5f..dfa682a3c8936 100644
--- a/app/code/Magento/Search/Model/PopularSearchTerms.php
+++ b/app/code/Magento/Search/Model/PopularSearchTerms.php
@@ -27,16 +27,24 @@ class PopularSearchTerms
*/
private $queryCollection;
+ /**
+ * @var \Magento\Search\Model\ResourceModel\Query
+ */
+ private $queryResource;
+
/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Search\Model\ResourceModel\Query\Collection
+ * @param ResourceModel\Query $queryResource
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
- \Magento\Search\Model\ResourceModel\Query\Collection $queryCollection
+ \Magento\Search\Model\ResourceModel\Query\Collection $queryCollection,
+ \Magento\Search\Model\ResourceModel\Query $queryResource
) {
$this->scopeConfig = $scopeConfig;
$this->queryCollection = $queryCollection;
+ $this->queryResource = $queryResource;
}
/**
@@ -48,13 +56,17 @@ public function __construct(
*/
public function isCacheable(string $term, int $storeId)
{
- $terms = $this->queryCollection
- ->setPopularQueryFilter($storeId)
- ->setPageSize($this->getMaxCountCacheableSearchTerms($storeId))
- ->load()
- ->getColumnValues('query_text');
+ $connection = $this->queryResource->getConnection();
+ $select = $connection->select();
+ $select->from($this->queryResource->getMainTable(), [$this->queryResource->getIdFieldName()])
+ ->where('query_text = ?', $term)
+ ->where('store_id = ?', $storeId)
+ ->where('num_results > 0')
+ ->order(['popularity DESC'])
+ ->limit($this->getMaxCountCacheableSearchTerms($storeId));
+ $queryId = $connection->fetchOne($select);
- return in_array($term, $terms);
+ return (bool) $queryId;
}
/**
From a1a64197377c297904e6bf32d54fa44fe9907f52 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Mon, 14 Oct 2019 17:38:15 -0500
Subject: [PATCH 0388/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 7 -------
.../CatalogRule/Model/Indexer/ProductRuleReindex.php | 4 ++--
2 files changed, 2 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index ecdd124786efc..703e28f4ed12f 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -296,13 +296,6 @@ protected function doReindexByIds($ids)
$rule->setProductsFilter($ids);
$this->reindexRuleProduct->execute($rule, $this->batchCount);
}
-
- $this->cleanProductPriceIndex($ids);
- foreach ($ids as $productId) {
- $this->reindexRuleProductPrice->execute($this->batchCount, $productId);
- }
-
- $this->reindexRuleGroupWebsite->execute();
}
/**
diff --git a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php
index edc827ec57ac2..9c66719334639 100644
--- a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php
+++ b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Indexer/ProductRuleReindex.php
@@ -88,8 +88,8 @@ private function reindexSubProducts(
$subProducts = [];
if ($configurableIds) {
$subProducts = array_values($this->configurable->getChildrenIds($configurableIds)[0]);
- foreach ($subProducts as $subProduct) {
- $subject->executeRow($subProduct);
+ if ($subProducts) {
+ $subject->executeList($subProducts);
}
}
return $subProducts;
From 1ea2179bb32805f8266bf4d8f0826b5dbf103276 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Mon, 14 Oct 2019 17:58:56 -0500
Subject: [PATCH 0389/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Backend/LayoutUpdate.php | 4 ++--
.../Attribute/Source/LayoutUpdate.php | 4 ++--
.../Catalog/Model/Category/Authorization.php | 22 ++++++++++---------
.../Attribute/Backend/LayoutUpdate.php | 4 ++--
.../Product/Attribute/Source/LayoutUpdate.php | 4 ++--
.../Catalog/Model/Product/Authorization.php | 22 ++++++++++---------
6 files changed, 32 insertions(+), 28 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index 215fe1c19bd8d..8e8b7bfda549c 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -25,9 +25,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager $manager
+ * @param LayoutUpdateManager\Proxy $manager
*/
- public function __construct(LayoutUpdateManager $manager)
+ public function __construct(LayoutUpdateManager\Proxy $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index 1c307220aa9f8..59e58c6b12109 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -23,9 +23,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager $manager
+ * @param LayoutUpdateManager\Proxy $manager
*/
- public function __construct(LayoutUpdateManager $manager)
+ public function __construct(LayoutUpdateManager\Proxy $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Category/Authorization.php b/app/code/Magento/Catalog/Model/Category/Authorization.php
index 407ce2c045b25..629a3c2319472 100644
--- a/app/code/Magento/Catalog/Model/Category/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Category/Authorization.php
@@ -77,15 +77,16 @@ private function extractAttributeValue(CategoryModel $category, AttributeInterfa
* Find values to compare the new one.
*
* @param AttributeInterface $attribute
- * @param CategoryModel|null $oldCategory
+ * @param array|null $oldCategory
* @return mixed[]
*/
- private function fetchOldValue(AttributeInterface $attribute, ?CategoryModel $oldCategory): array
+ private function fetchOldValue(AttributeInterface $attribute, ?array $oldCategory): array
{
$oldValues = [null];
+ $attrCode = $attribute->getAttributeCode();
if ($oldCategory) {
//New value must match saved value exactly
- $oldValues = [$oldCategory->getData($attribute->getAttributeCode())];
+ $oldValues = [!empty($oldCategory[$attrCode]) ? $oldCategory[$attrCode] : null];
if (empty($oldValues[0])) {
$oldValues[0] = null;
}
@@ -101,10 +102,10 @@ private function fetchOldValue(AttributeInterface $attribute, ?CategoryModel $ol
* Determine whether a category has design properties changed.
*
* @param CategoryModel $category
- * @param CategoryModel|null $oldCategory
+ * @param array|null $oldCategory
* @return bool
*/
- private function hasChanges(CategoryModel $category, ?CategoryModel $oldCategory): bool
+ private function hasChanges(CategoryModel $category, ?array $oldCategory): bool
{
foreach ($category->getDesignAttributes() as $designAttribute) {
$oldValues = $this->fetchOldValue($designAttribute, $oldCategory);
@@ -134,21 +135,22 @@ private function hasChanges(CategoryModel $category, ?CategoryModel $oldCategory
public function authorizeSavingOf(CategoryInterface $category): void
{
if (!$this->authorization->isAllowed('Magento_Catalog::edit_category_design')) {
- $savedCategory = null;
+ $oldData = null;
if ($category->getId()) {
- /** @var CategoryModel $savedCategory */
- $savedCategory = $this->categoryFactory->create();
if ($category->getOrigData()) {
- $savedCategory->setData($category->getOrigData());
+ $oldData = $category->getOrigData();
} else {
+ /** @var CategoryModel $savedCategory */
+ $savedCategory = $this->categoryFactory->create();
$savedCategory->load($category->getId());
if (!$savedCategory->getName()) {
throw NoSuchEntityException::singleField('id', $category->getId());
}
+ $oldData = $savedCategory->getData();
}
}
- if ($this->hasChanges($category, $savedCategory)) {
+ if ($this->hasChanges($category, $oldData)) {
throw new AuthorizationException(__('Not allowed to edit the category\'s design attributes'));
}
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index fa5a218824eea..16aee8e2830a7 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -25,9 +25,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager $manager
+ * @param LayoutUpdateManager\Proxy $manager
*/
- public function __construct(LayoutUpdateManager $manager)
+ public function __construct(LayoutUpdateManager\Proxy $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index 0ddb528e768cc..57c254e64f732 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -23,9 +23,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager $manager
+ * @param LayoutUpdateManager\Proxy $manager
*/
- public function __construct(LayoutUpdateManager $manager)
+ public function __construct(LayoutUpdateManager\Proxy $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Authorization.php b/app/code/Magento/Catalog/Model/Product/Authorization.php
index 13147d5787bd1..b8aa8f70ba70f 100644
--- a/app/code/Magento/Catalog/Model/Product/Authorization.php
+++ b/app/code/Magento/Catalog/Model/Product/Authorization.php
@@ -77,14 +77,15 @@ private function extractAttributeValue(ProductModel $product, AttributeInterface
* Prepare old values to compare to.
*
* @param AttributeInterface $attribute
- * @param ProductModel|null $oldProduct
+ * @param array|null $oldProduct
* @return array
*/
- private function fetchOldValues(AttributeInterface $attribute, ?ProductModel $oldProduct): array
+ private function fetchOldValues(AttributeInterface $attribute, ?array $oldProduct): array
{
+ $attrCode = $attribute->getAttributeCode();
if ($oldProduct) {
//New value may only be the saved value
- $oldValues = [$oldProduct->getData($attribute->getAttributeCode())];
+ $oldValues = [!empty($oldProduct[$attrCode]) ? $oldProduct[$attrCode] : null];
if (empty($oldValues[0])) {
$oldValues[0] = null;
}
@@ -100,10 +101,10 @@ private function fetchOldValues(AttributeInterface $attribute, ?ProductModel $ol
* Check whether the product has changed.
*
* @param ProductModel $product
- * @param ProductModel|null $oldProduct
+ * @param array|null $oldProduct
* @return bool
*/
- private function hasProductChanged(ProductModel $product, ?ProductModel $oldProduct = null): bool
+ private function hasProductChanged(ProductModel $product, ?array $oldProduct = null): bool
{
$designAttributes = [
'custom_design',
@@ -147,20 +148,21 @@ private function hasProductChanged(ProductModel $product, ?ProductModel $oldProd
public function authorizeSavingOf(ProductInterface $product): void
{
if (!$this->authorization->isAllowed('Magento_Catalog::edit_product_design')) {
- $savedProduct = null;
+ $oldData = null;
if ($product->getId()) {
- /** @var ProductModel $savedProduct */
- $savedProduct = $this->productFactory->create();
if ($product->getOrigData()) {
- $savedProduct->setData($product->getOrigData());
+ $oldData = $product->getOrigData();
} else {
+ /** @var ProductModel $savedProduct */
+ $savedProduct = $this->productFactory->create();
$savedProduct->load($product->getId());
if (!$savedProduct->getSku()) {
throw NoSuchEntityException::singleField('id', $product->getId());
}
+ $oldData = $product->getOrigData();
}
}
- if ($this->hasProductChanged($product, $savedProduct)) {
+ if ($this->hasProductChanged($product, $oldData)) {
throw new AuthorizationException(__('Not allowed to edit the product\'s design attributes'));
}
}
From caccf3867e88e831c97c9c7094f4eb93834044ea Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 14 Oct 2019 21:56:34 -0500
Subject: [PATCH 0390/1978] MC-20648: Implement the changes - reflection error
fix
---
app/code/Magento/SalesRule/Api/Data/DiscountInterface.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
index fc2376ed66a8a..69fb225b8a637 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
@@ -13,7 +13,7 @@ interface DiscountInterface
/**
* Get Discount Data
*
- * @return mixed
+ * @return array
*/
public function getDiscountData();
From 2867668b3e59a0ee23144370da4109e3a2b0097d Mon Sep 17 00:00:00 2001
From: Eden
Date: Tue, 15 Oct 2019 10:54:18 +0700
Subject: [PATCH 0391/1978] Resolve "Enable Single-Store Mode" is "Yes" but the
create New Rating has store view title issue25060
---
.../Block/Adminhtml/Rating/Edit/Tab/Form.php | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php b/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php
index e4b4da23ac629..a8a39b3326edd 100644
--- a/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php
+++ b/app/code/Magento/Review/Block/Adminhtml/Rating/Edit/Tab/Form.php
@@ -111,13 +111,16 @@ protected function addRatingFieldset()
]
);
- foreach ($this->systemStore->getStoreCollection() as $store) {
- $this->getFieldset('rating_form')->addField(
- 'rating_code_' . $store->getId(),
- 'text',
- ['label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']']
- );
+ if (!$this->_storeManager->isSingleStoreMode()) {
+ foreach ($this->systemStore->getStoreCollection() as $store) {
+ $this->getFieldset('rating_form')->addField(
+ 'rating_code_' . $store->getId(),
+ 'text',
+ ['label' => $store->getName(), 'name' => 'rating_codes[' . $store->getId() . ']']
+ );
+ }
}
+
$this->setRatingData();
}
From 29ea40d04cd4afb871482c88842f6cc474ee1cce Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Tue, 15 Oct 2019 09:32:46 +0300
Subject: [PATCH 0392/1978] MC-20668: Edit custom options of simple product
---
.../Option/DataProvider/Type}/AbstractBase.php | 2 +-
.../DataProvider/Type}/AbstractSelect.php | 4 ++--
.../Option/DataProvider/Type}/AbstractText.php | 4 ++--
.../Product/Option/DataProvider/Type}/Area.php | 4 ++--
.../Option/DataProvider/Type}/Checkbox.php | 4 ++--
.../Product/Option/DataProvider/Type}/Date.php | 4 ++--
.../Option/DataProvider/Type}/DateTime.php | 4 ++--
.../Option/DataProvider/Type}/DropDown.php | 4 ++--
.../Option/DataProvider/Type}/Field.php | 4 ++--
.../Product/Option/DataProvider/Type}/File.php | 4 ++--
.../DataProvider/Type}/MultipleSelect.php | 4 ++--
.../Option/DataProvider/Type}/RadioButtons.php | 4 ++--
.../Product/Option/DataProvider/Type}/Time.php | 4 ++--
.../Product/Save/UpdateCustomOptionsTest.php | 2 +-
.../Model/Product/UpdateCustomOptionsTest.php | 18 +++++++++---------
15 files changed, 35 insertions(+), 35 deletions(-)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/AbstractBase.php (98%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/AbstractSelect.php (97%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/AbstractText.php (92%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/Area.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/Checkbox.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/Date.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/DateTime.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/DropDown.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/Field.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/File.php (94%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/MultipleSelect.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/RadioButtons.php (73%)
rename dev/tests/integration/{testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date => framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type}/Time.php (73%)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractBase.php
similarity index 98%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractBase.php
index fd8db9d130dd0..36a4f6662cb09 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/AbstractBase.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractBase.php
@@ -5,7 +5,7 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
/**
* Base custom options data provider.
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractSelect.php
similarity index 97%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractSelect.php
index 62c9012b0997b..0cbe64bf1d965 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/AbstractSelect.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractSelect.php
@@ -5,9 +5,9 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
/**
* Abstract data provider for options from select group.
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/AbstractText.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractText.php
similarity index 92%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/AbstractText.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractText.php
index 9d66fcda37cc4..42028eee632be 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/AbstractText.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/AbstractText.php
@@ -5,9 +5,9 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
/**
* Abstract data provider for options from text group.
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Area.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Area.php
index f212ed9e3c16a..137e77412f7b9 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Area.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Area.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\AbstractText;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractText;
/**
* Data provider for custom options from text group with type "area".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Checkbox.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Checkbox.php
index 9f0a4d186315e..9a5f57d30946b 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/Checkbox.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Checkbox.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractSelect;
/**
* Data provider for custom options from select group with type "Checkbox".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Date.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Date.php
index 45dad58997339..501265849be93 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Date.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Date.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
/**
* Data provider for custom options from date group with type "date".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/DateTime.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/DateTime.php
index 24073db54eadf..e3e154cc386e0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/DateTime.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/DateTime.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
/**
* Data provider for custom options from date group with type "date & time".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/DropDown.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/DropDown.php
index 181219907e195..2c8b9f2f25dc6 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/DropDown.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/DropDown.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractSelect;
/**
* Data provider for custom options from select group with type "Drop-down".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Field.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Field.php
index 11e9ce3c7b825..12df838bd46c2 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Text/Field.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Field.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\AbstractText;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractText;
/**
* Data provider for custom options from text group with type "field".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/File.php
similarity index 94%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/File.php
index fc3aed94269f1..35f449a404410 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/File/File.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/File.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\File;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
/**
* Data provider for options from file group with type "file".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/MultipleSelect.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/MultipleSelect.php
index ddadd380609f0..3e958b1ac39a0 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/MultipleSelect.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/MultipleSelect.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractSelect;
/**
* Data provider for custom options from select group with type "Drop-down".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/RadioButtons.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/RadioButtons.php
index d753b969f911b..345aa289283e8 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Select/RadioButtons.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/RadioButtons.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\AbstractSelect;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractSelect;
/**
* Data provider for custom options from select group with type "Radio Buttons".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Time.php
similarity index 73%
rename from dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php
rename to dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Time.php
index 616ec8ec27ba4..cc6fb1e86a6c6 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Option/Create/DataProvider/Type/Date/Time.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Catalog/Model/Product/Option/DataProvider/Type/Time.php
@@ -5,10 +5,10 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date;
+namespace Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type;
use Magento\Catalog\Api\Data\ProductCustomOptionInterface;
-use Magento\Catalog\Model\Product\Option\Create\DataProvider\AbstractBase;
+use Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\AbstractBase;
/**
* Data provider for custom options from date group with type "time".
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
index 70d5ce292c2cb..ae4646ce66f7d 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/UpdateCustomOptionsTest.php
@@ -57,7 +57,7 @@ protected function setUp()
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\Field::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Field::getDataForUpdateOptions
*
* @param array $optionData
* @param array $updateData
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
index 00f424fb1b670..b8a24f3812e1a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/UpdateCustomOptionsTest.php
@@ -100,7 +100,7 @@ protected function tearDown()
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Text\Area::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Area::getDataForUpdateOptions
*
* @param array $optionData
* @param array $updateData
@@ -116,7 +116,7 @@ public function testUpdateAreaCustomOption(array $optionData, array $updateData)
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\File\File::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\File::getDataForUpdateOptions
*
* @param array $optionData
* @param array $updateData
@@ -132,7 +132,7 @@ public function testUpdateFileCustomOption(array $optionData, array $updateData)
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date\Date::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Date::getDataForUpdateOptions
*
* @param array $optionData
* @param array $updateData
@@ -148,7 +148,7 @@ public function testUpdateDateCustomOption(array $optionData, array $updateData)
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date\DateTime::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\DateTime::getDataForUpdateOptions
*
* @param array $optionData
* @param array $updateData
@@ -164,7 +164,7 @@ public function testUpdateDateTimeCustomOption(array $optionData, array $updateD
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Date\Time::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Time::getDataForUpdateOptions
*
* @param array $optionData
* @param array $updateData
@@ -180,7 +180,7 @@ public function testUpdateTimeCustomOption(array $optionData, array $updateData)
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\DropDown::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\DropDown::getDataForUpdateOptions
*
* @param array $optionData
* @param array $optionValueData
@@ -207,7 +207,7 @@ public function testUpdateDropDownCustomOption(
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\RadioButtons::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\RadioButtons::getDataForUpdateOptions
*
* @param array $optionData
* @param array $optionValueData
@@ -234,7 +234,7 @@ public function testUpdateRadioButtonsCustomOption(
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\Checkbox::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\Checkbox::getDataForUpdateOptions
*
* @param array $optionData
* @param array $optionValueData
@@ -261,7 +261,7 @@ public function testUpdateCheckboxCustomOption(
*
* @magentoDataFixture Magento/Catalog/_files/product_without_options.php
*
- * @dataProvider \Magento\Catalog\Model\Product\Option\Create\DataProvider\Type\Select\MultipleSelect::getDataForUpdateOptions
+ * @dataProvider \Magento\TestFramework\Catalog\Model\Product\Option\DataProvider\Type\MultipleSelect::getDataForUpdateOptions
*
* @param array $optionData
* @param array $optionValueData
From 063635528ec887da499c2bf2d7c29c5c0564b58c Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Tue, 15 Oct 2019 10:57:44 +0300
Subject: [PATCH 0393/1978] MC-21718: Storefront Category URL management
---
.../UrlRewrite/Controller/UrlRewriteTest.php | 23 ++++---------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
index 858401bf4eb69..50ef913594187 100644
--- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
@@ -7,29 +7,14 @@
namespace Magento\UrlRewrite\Controller;
-use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\TestFramework\TestCase\AbstractController;
use Magento\Framework\App\Response\Http as HttpResponse;
-use Zend\Http\Response;
/**
* Class to test Match corresponding URL Rewrite
*/
class UrlRewriteTest extends AbstractController
{
- /** @var CategoryRepositoryInterface */
- private $categoryRepository;
-
- /**
- * @inheritdoc
- */
- protected function setUp()
- {
- parent::setUp();
-
- $this->categoryRepository = $this->_objectManager->get(CategoryRepositoryInterface::class);
- }
-
/**
* @magentoDataFixture Magento/UrlRewrite/_files/url_rewrite.php
* @magentoDbIsolation disabled
@@ -47,7 +32,7 @@ protected function setUp()
public function testMatchUrlRewrite(
string $request,
string $redirect,
- int $expectedCode = Response::STATUS_CODE_301
+ int $expectedCode = HttpResponse::STATUS_CODE_301
): void {
$this->dispatch($request);
/** @var HttpResponse $response */
@@ -55,7 +40,7 @@ public function testMatchUrlRewrite(
$code = $response->getHttpResponseCode();
$this->assertEquals($expectedCode, $code, 'Invalid response code');
- if ($expectedCode !== Response::STATUS_CODE_200) {
+ if ($expectedCode !== HttpResponse::STATUS_CODE_200) {
$location = $response->getHeader('Location')->getFieldValue();
$this->assertStringEndsWith(
$redirect,
@@ -98,7 +83,7 @@ public function requestDataProvider(): array
'Use Case #7: Request with query params' => [
'request' => '/enable-cookies/?test-param',
'redirect' => '',
- Response::STATUS_CODE_200,
+ HttpResponse::STATUS_CODE_200,
],
];
}
@@ -116,7 +101,7 @@ public function testCategoryUrlRewrite(string $request): void
$this->dispatch($request);
$response = $this->getResponse();
$this->assertEquals(
- Response::STATUS_CODE_200,
+ HttpResponse::STATUS_CODE_200,
$response->getHttpResponseCode(),
'Response code does not match expected value'
);
From 3cfb3737ed0c53e4391b07f98321579f6ba83d05 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 15 Oct 2019 12:05:58 +0300
Subject: [PATCH 0394/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
.../Catalog/Test/Mftf/Data/ProductData.xml | 5 +++++
.../Catalog/Test/Mftf/Data/ProductOptionData.xml | 2 ++
...portCustomizableOptionToProductWithSKUTest.xml | 15 ++++-----------
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index aad43bb7011c1..f9191eeae1216 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -1303,4 +1303,9 @@
16.00
+
+
+ ProductOptionField
+ ProductOptionField2
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductOptionData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductOptionData.xml
index 720087917aad4..404a4771a0e73 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductOptionData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductOptionData.xml
@@ -11,6 +11,7 @@
OptionField
+ OptionField
field
true
1
@@ -21,6 +22,7 @@
OptionField2
+ OptionField2
field
true
1
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
index c191822b2c7e6..e1b0e563aba5b 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminImportCustomizableOptionToProductWithSKUTest.xml
@@ -24,6 +24,9 @@
+
+
+
@@ -40,16 +43,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -68,7 +61,7 @@
-
+
From 7fd9000d13d9681dfae2cdb999b080716e116d27 Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Tue, 15 Oct 2019 13:15:26 +0300
Subject: [PATCH 0395/1978] magento/magento2#25037: MFTF tests fix.
---
.../Order/Create/Sidebar/AbstractSidebar.php | 16 +----------
.../Adminhtml/Order/Create/Sidebar/Cart.php | 27 +++++++++++++++++++
...mpleProductToOrderFromShoppingCartTest.xml | 6 +++--
3 files changed, 32 insertions(+), 17 deletions(-)
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
index 2969009857410..737ca446bb8e9 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/AbstractSidebar.php
@@ -9,7 +9,6 @@
namespace Magento\Sales\Block\Adminhtml\Order\Create\Sidebar;
use Magento\Framework\Pricing\PriceCurrencyInterface;
-use Magento\Store\Model\ScopeInterface;
/**
* Adminhtml sales order create sidebar block
@@ -136,20 +135,7 @@ public function getItemCount()
{
$count = $this->getData('item_count');
if ($count === null) {
- $useQty = $this->_scopeConfig->getValue(
- 'checkout/cart_link/use_qty',
- ScopeInterface::SCOPE_STORE
- );
- $allItems = $this->getItems();
- if ($useQty) {
- $count = 0;
- foreach ($allItems as $item) {
- $count += $item->getQty();
- }
- } else {
- $count = count($allItems);
- }
-
+ $count = count($this->getItems());
$this->setData('item_count', $count);
}
return $count;
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php
index f2200e1c1a108..a927b7177294a 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Order/Create/Sidebar/Cart.php
@@ -9,6 +9,7 @@
use Magento\Catalog\Model\Product;
use Magento\Catalog\Pricing\Price\FinalPrice;
+use Magento\Store\Model\ScopeInterface;
/**
* Adminhtml sales order create sidebar cart block
@@ -146,4 +147,30 @@ private function getCartItemCustomPrice(Product $product): ?float
return null;
}
+
+ /**
+ * @inheritdoc
+ */
+ public function getItemCount()
+ {
+ $count = $this->getData('item_count');
+ if ($count === null) {
+ $useQty = $this->_scopeConfig->getValue(
+ 'checkout/cart_link/use_qty',
+ ScopeInterface::SCOPE_STORE
+ );
+ $allItems = $this->getItems();
+ if ($useQty) {
+ $count = 0;
+ foreach ($allItems as $item) {
+ $count += $item->getQty();
+ }
+ } else {
+ $count = count($allItems);
+ }
+ $this->setData('item_count', $count);
+ }
+
+ return $count;
+ }
}
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AddSimpleProductToOrderFromShoppingCartTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AddSimpleProductToOrderFromShoppingCartTest.xml
index 76be3a1094327..589da3e49dc89 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AddSimpleProductToOrderFromShoppingCartTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AddSimpleProductToOrderFromShoppingCartTest.xml
@@ -46,8 +46,9 @@
-
+
+
@@ -64,6 +65,7 @@
+
@@ -75,6 +77,6 @@
-
+
From 6df77f48803a7f74e2100e3f03898302193b6afa Mon Sep 17 00:00:00 2001
From: Dzmitry Tabusheu
Date: Tue, 15 Oct 2019 14:36:16 +0300
Subject: [PATCH 0396/1978] MC-21646: Integration Test failed with
elasticsearch6:
Magento\ProductAlert\Model\ObserverTest::testProcessPortuguese
- Fixed functional test
---
.../DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
index 5a94dd4f04d24..041cc35a6dacf 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
@@ -46,6 +46,7 @@
+
From 657dea230d020fbe062f5c929cdf956a8e327cee Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Tue, 15 Oct 2019 15:00:41 +0300
Subject: [PATCH 0397/1978] MC-20703: Admin: Delete a category
---
.../Adminhtml/Category/DeleteTest.php | 38 ++++++++++++++++
.../Catalog/Model/CategoryRepositoryTest.php | 45 ++++++++++++++++---
2 files changed, 78 insertions(+), 5 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
new file mode 100644
index 0000000000000..e5e90285bf767
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
@@ -0,0 +1,38 @@
+ $incorrectId];
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($postData);
+ $this->dispatch('backend/catalog/category/delete');
+ $this->assertSessionMessages(
+ $this->equalTo([(string)__(sprintf('No such entity with id = %s', $incorrectId))]),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
index f1e235f8c9bf2..0771f0b9e71af 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
@@ -11,7 +11,9 @@
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\Data\CategoryInterfaceFactory;
+use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Framework\Acl\Builder;
+use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
use Magento\TestFramework\Bootstrap as TestBootstrap;
@@ -43,6 +45,12 @@ class CategoryRepositoryTest extends TestCase
*/
private $categoryFactory;
+ /** @var CollectionFactory */
+ private $productCollectionFactory;
+
+ /** @var ObjectManagerInterface */
+ private $objectManager;
+
/**
* Sets up common objects.
*
@@ -50,10 +58,12 @@ class CategoryRepositoryTest extends TestCase
*/
protected function setUp()
{
- $this->repo = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class);
- $this->auth = Bootstrap::getObjectManager()->get(Auth::class);
- $this->aclBuilder = Bootstrap::getObjectManager()->get(Builder::class);
- $this->categoryFactory = Bootstrap::getObjectManager()->get(CategoryInterfaceFactory::class);
+ $this->objectManager = Bootstrap::getObjectManager();
+ $this->repo = $this->objectManager->create(CategoryRepositoryInterface::class);
+ $this->auth = $this->objectManager->get(Auth::class);
+ $this->aclBuilder = $this->objectManager->get(Builder::class);
+ $this->categoryFactory = $this->objectManager->get(CategoryInterfaceFactory::class);
+ $this->productCollectionFactory = $this->objectManager->get(CollectionFactory::class);
}
/**
@@ -74,8 +84,9 @@ protected function tearDown()
* @magentoAppArea adminhtml
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
+ * @return void
*/
- public function testSaveDesign()
+ public function testSaveDesign(): void
{
$category = $this->repo->get(333);
$this->auth->login(TestBootstrap::ADMIN_NAME, TestBootstrap::ADMIN_PASSWORD);
@@ -109,4 +120,28 @@ public function testSaveDesign()
$customDesignAttribute = $newCategory->getCustomAttribute('custom_design');
$this->assertTrue(!$customDesignAttribute || !$customDesignAttribute->getValue());
}
+
+ /**
+ * @magentoDbIsolation enabled
+ * @magentoDataFixture Magento/Catalog/_files/categories.php
+ * @magentoAppArea adminhtml
+ * @return void
+ */
+ public function testDeleteCategory(): void
+ {
+ $productCollection = $this->productCollectionFactory->create();
+ $deletedCategories = [3, 4, 5, 13];
+ $categoryCollection = $this->categoryFactory->create()->getCollection()->toArray();
+ $this->repo->deleteByIdentifier(3);
+ $this->assertEmpty(
+ $productCollection->addCategoriesFilter(['in' => $deletedCategories])->getItems(),
+ 'The category-products relations was not deleted after category delete'
+ );
+ $newCategoryCollection = $this->categoryFactory->create()->getCollection()->toArray();
+ $this->assertEquals(
+ $deletedCategories,
+ array_keys(array_diff_key($categoryCollection, $newCategoryCollection)),
+ 'Wrong categories was deleted'
+ );
+ }
}
From c5a33c37cd48dae1a3d7491eec4cca34e0f83f7f Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Tue, 15 Oct 2019 15:59:04 +0300
Subject: [PATCH 0398/1978] MC-20448: [Integration Test] WSDL Lists All
Available Methods
---
.../Magento/Webapi/Controller/SoapTest.php | 28 +++++++++++++++----
1 file changed, 23 insertions(+), 5 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php
index 211bc6f04538b..d3716a01f35ab 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php
+++ b/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php
@@ -6,6 +6,9 @@
namespace Magento\Webapi\Controller;
+/**
+ * Test for Magento\Webapi\Controller\Soap class.
+ */
class SoapTest extends \PHPUnit\Framework\TestCase
{
/**
@@ -24,16 +27,31 @@ protected function setUp()
$this->soapController = $this->objectManager->get(\Magento\Webapi\Controller\Soap::class);
}
- /*
+ /**
* Get the public wsdl with anonymous credentials
+ *
+ * @return void
*/
- public function testDispatchWsdlRequest()
+ public function testDispatchWsdlRequest(): void
{
$request = $this->objectManager->get(\Magento\Framework\Webapi\Request::class);
$request->setParam(\Magento\Webapi\Model\Soap\Server::REQUEST_PARAM_LIST_WSDL, true);
$response = $this->soapController->dispatch($request);
- $decoded_wsdl = json_decode($response->getContent(), true);
- $this->assertArrayHasKey("customerAccountManagementV1", $decoded_wsdl);
- $this->assertArrayHasKey("integrationAdminTokenServiceV1", $decoded_wsdl);
+ $decodedWsdl = json_decode($response->getContent(), true);
+
+ $this->assertWsdl($decodedWsdl);
+ }
+
+ /**
+ * Check wsdl available methods.
+ *
+ * @param array $decodedWsdl
+ *
+ * @return void
+ */
+ protected function assertWsdl(array $decodedWsdl): void
+ {
+ $this->assertArrayHasKey("customerAccountManagementV1", $decodedWsdl);
+ $this->assertArrayHasKey("integrationAdminTokenServiceV1", $decodedWsdl);
}
}
From f49fe7195f7082f5153da92318bc7ab974e0beb0 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Tue, 15 Oct 2019 08:22:24 -0500
Subject: [PATCH 0399/1978] magento/graphql-ce#977: [Test coverage] Cover
exceptions in AssignShippingAddressToCart, AssignBillingAddressToCart
---
.../GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php | 2 +-
.../GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 771ce8391ec07..d4f23854378fa 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -928,7 +928,7 @@ public function testWithInvalidBillingAddressInput()
}
}
QUERY;
- self::expectExceptionMessage('The address failed to save. Verify the address and try again.');
+ $this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
index f5f9d57ea96f3..8b1b678b0b3a4 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
@@ -748,7 +748,7 @@ public function testWithInvalidShippingAddressesInput()
}
}
QUERY;
- self::expectExceptionMessage('The address failed to save. Verify the address and try again.');
+ $this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
@@ -894,7 +894,6 @@ public function testSetNewShippingAddressWithNotSaveInAddressBook()
}
}
-
/**
* Verify the all the whitelisted fields for a New Address Object
*
From 50de44e95efb3fdac435ee9b8ebcc2a532f3d4e6 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Tue, 15 Oct 2019 16:42:13 +0300
Subject: [PATCH 0400/1978] MC-20703: Admin: Delete a category
---
.../Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
index e5e90285bf767..0325cf2bb1d5f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
@@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
declare(strict_types=1);
namespace Magento\Catalog\Controller\Adminhtml\Category;
From 22d9fb1fb8560b92c33004162e38cfa96f96e984 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Tue, 15 Oct 2019 08:52:28 -0500
Subject: [PATCH 0401/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 703e28f4ed12f..19628db1ef9c7 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -294,8 +294,8 @@ protected function doReindexByIds($ids)
foreach ($activeRules as $rule) {
/** @var Rule $rule */
$rule->setProductsFilter($ids);
- $this->reindexRuleProduct->execute($rule, $this->batchCount);
}
+ $this->reindexRuleGroupWebsite->execute();
}
/**
From a99a0b81c01e19e5a187149e48d91280454d61b3 Mon Sep 17 00:00:00 2001
From: Stas Kozar
Date: Tue, 15 Oct 2019 16:52:43 +0300
Subject: [PATCH 0402/1978] MC-20448: [Integration Test] WSDL Lists All
Available Methods
---
.../testsuite/Magento/Webapi/Controller/SoapTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php b/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php
index d3716a01f35ab..f219080755849 100644
--- a/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php
+++ b/dev/tests/integration/testsuite/Magento/Webapi/Controller/SoapTest.php
@@ -39,7 +39,7 @@ public function testDispatchWsdlRequest(): void
$response = $this->soapController->dispatch($request);
$decodedWsdl = json_decode($response->getContent(), true);
- $this->assertWsdl($decodedWsdl);
+ $this->assertWsdlServices($decodedWsdl);
}
/**
@@ -49,7 +49,7 @@ public function testDispatchWsdlRequest(): void
*
* @return void
*/
- protected function assertWsdl(array $decodedWsdl): void
+ protected function assertWsdlServices(array $decodedWsdl): void
{
$this->assertArrayHasKey("customerAccountManagementV1", $decodedWsdl);
$this->assertArrayHasKey("integrationAdminTokenServiceV1", $decodedWsdl);
From 0b57ccd403f18268ba15f9bf7ba78cf1fb3c0b1e Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 15 Oct 2019 10:55:39 -0500
Subject: [PATCH 0403/1978] MC-20648: Implement the changes - reflection error
fix
---
.../SalesRule/Api/Data/DiscountInterface.php | 2 +-
.../SalesRule/Model/Data/RuleDiscount.php | 2 +-
.../Model/Rule/Action/Discount/Data.php | 16 +++++++++++++++-
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
index 69fb225b8a637..608f7cbb818e4 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
@@ -13,7 +13,7 @@ interface DiscountInterface
/**
* Get Discount Data
*
- * @return array
+ * @return \Magento\SalesRule\Api\Data\DiscountDataInterface
*/
public function getDiscountData();
diff --git a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
index 21a2fa26bceeb..6bb5fa2d8943a 100644
--- a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
@@ -7,7 +7,7 @@
namespace Magento\SalesRule\Model\Data;
use Magento\SalesRule\Model\Rule\Action\Discount\Data;
-use \Magento\SalesRule\Api\Data\DiscountInterface;
+use Magento\SalesRule\Api\Data\DiscountInterface;
/**
* Data Model for Rule Discount
diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
index fe564690e08b8..fe68daa4369cd 100644
--- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
+++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
@@ -6,10 +6,12 @@
namespace Magento\SalesRule\Model\Rule\Action\Discount;
/**
+ * Discount Data
+ *
* @api
* @since 100.0.2
*/
-class Data
+class Data implements DiscountDataInterface
{
/**
* @var float
@@ -43,6 +45,8 @@ public function __construct()
}
/**
+ * Set Amount
+ *
* @param float $amount
* @return $this
*/
@@ -53,6 +57,8 @@ public function setAmount($amount)
}
/**
+ * Get Amount
+ *
* @return float
*/
public function getAmount()
@@ -61,6 +67,8 @@ public function getAmount()
}
/**
+ * Set Base Amount
+ *
* @param float $baseAmount
* @return $this
*/
@@ -71,6 +79,8 @@ public function setBaseAmount($baseAmount)
}
/**
+ * Get Base Amount
+ *
* @return float
*/
public function getBaseAmount()
@@ -79,6 +89,8 @@ public function getBaseAmount()
}
/**
+ * Set Original Amount
+ *
* @param float $originalAmount
* @return $this
*/
@@ -99,6 +111,8 @@ public function getOriginalAmount()
}
/**
+ * Set Base Original Amount
+ *
* @param float $baseOriginalAmount
* @return $this
*/
From 0e82323ff34d43fecee00ec198b593585bed1082 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Tue, 15 Oct 2019 10:56:44 -0500
Subject: [PATCH 0404/1978] MC-18685: Remove custom layout updates from admin
---
.../Attribute/Backend/LayoutUpdate.php | 4 ++--
.../Attribute/Source/LayoutUpdate.php | 4 ++--
.../Attribute/Backend/LayoutUpdate.php | 4 ++--
.../Product/Attribute/Source/LayoutUpdate.php | 4 ++--
app/code/Magento/Catalog/etc/di.xml | 20 +++++++++++++++++++
5 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
index 8e8b7bfda549c..215fe1c19bd8d 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Backend/LayoutUpdate.php
@@ -25,9 +25,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager\Proxy $manager
+ * @param LayoutUpdateManager $manager
*/
- public function __construct(LayoutUpdateManager\Proxy $manager)
+ public function __construct(LayoutUpdateManager $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
index 59e58c6b12109..1c307220aa9f8 100644
--- a/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Category/Attribute/Source/LayoutUpdate.php
@@ -23,9 +23,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager\Proxy $manager
+ * @param LayoutUpdateManager $manager
*/
- public function __construct(LayoutUpdateManager\Proxy $manager)
+ public function __construct(LayoutUpdateManager $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
index 16aee8e2830a7..fa5a218824eea 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/LayoutUpdate.php
@@ -25,9 +25,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager\Proxy $manager
+ * @param LayoutUpdateManager $manager
*/
- public function __construct(LayoutUpdateManager\Proxy $manager)
+ public function __construct(LayoutUpdateManager $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
index 57c254e64f732..0ddb528e768cc 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Source/LayoutUpdate.php
@@ -23,9 +23,9 @@ class LayoutUpdate extends AbstractLayoutUpdate
private $manager;
/**
- * @param LayoutUpdateManager\Proxy $manager
+ * @param LayoutUpdateManager $manager
*/
- public function __construct(LayoutUpdateManager\Proxy $manager)
+ public function __construct(LayoutUpdateManager $manager)
{
$this->manager = $manager;
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index f0e43f62b1fd5..ae79fd65e55ab 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1186,4 +1186,24 @@
Magento\Framework\View\Design\Theme\FlyweightFactory\Proxy
+
+
+ Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager\Proxy
+
+
+
+
+ Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager\Proxy
+
+
+
+
+ Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager\Proxy
+
+
+
+
+ Magento\Catalog\Model\Product\Attribute\LayoutUpdateManager\Proxy
+
+
From 6a98119287c3ae3b9d90e3cc1e70fb13602227b1 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 15 Oct 2019 10:56:45 -0500
Subject: [PATCH 0405/1978] MC-20648: Implement the changes - Added interface
for discount data
---
.../Api/Data/DiscountDataInterface.php | 37 +++++++++++++++++++
1 file changed, 37 insertions(+)
create mode 100644 app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
new file mode 100644
index 0000000000000..0d9f7187ff12d
--- /dev/null
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
@@ -0,0 +1,37 @@
+
Date: Tue, 15 Oct 2019 11:12:59 -0500
Subject: [PATCH 0406/1978] MC-20648: Implement the changes - Added interface
for discount data
---
app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
index fe68daa4369cd..c30c436751480 100644
--- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
+++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
@@ -11,7 +11,7 @@
* @api
* @since 100.0.2
*/
-class Data implements DiscountDataInterface
+class Data implements \Magento\SalesRule\Api\Data\DiscountDataInterface
{
/**
* @var float
From 96a257b0db9b43b7713e86a68f6ff16d8abea326 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 15 Oct 2019 11:39:30 -0500
Subject: [PATCH 0407/1978] MC-20648: Implement the changes - Renamed Discount
Interface to Rule Discount Interface
---
...DiscountInterface.php => RuleDiscountInterface.php} | 2 +-
app/code/Magento/SalesRule/Model/Data/RuleDiscount.php | 10 +++++-----
app/code/Magento/SalesRule/Model/Plugin/Discount.php | 8 ++++----
app/code/Magento/SalesRule/Model/Quote/Discount.php | 10 +++++-----
app/code/Magento/SalesRule/Model/RulesApplier.php | 10 +++++-----
app/code/Magento/SalesRule/etc/di.xml | 2 +-
.../Magento/SalesRule/etc/extension_attributes.xml | 4 ++--
7 files changed, 23 insertions(+), 23 deletions(-)
rename app/code/Magento/SalesRule/Api/Data/{DiscountInterface.php => RuleDiscountInterface.php} (94%)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php b/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
similarity index 94%
rename from app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
rename to app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
index 608f7cbb818e4..b67f83658de53 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
@@ -8,7 +8,7 @@
/**
* @api
*/
-interface DiscountInterface
+interface RuleDiscountInterface
{
/**
* Get Discount Data
diff --git a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
index 6bb5fa2d8943a..e379acc862317 100644
--- a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
@@ -7,12 +7,12 @@
namespace Magento\SalesRule\Model\Data;
use Magento\SalesRule\Model\Rule\Action\Discount\Data;
-use Magento\SalesRule\Api\Data\DiscountInterface;
+use Magento\SalesRule\Api\Data\RuleDiscountInterface;
/**
* Data Model for Rule Discount
*/
-class RuleDiscount extends \Magento\Framework\Api\AbstractExtensibleObject implements DiscountInterface
+class RuleDiscount extends \Magento\Framework\Api\AbstractExtensibleObject implements RuleDiscountInterface
{
const KEY_DISCOUNT_DATA = 'discount';
const KEY_RULE_LABEL = 'rule';
@@ -84,7 +84,7 @@ public function setRuleID(string $ruleID)
/**
* Retrieve existing extension attributes object or create a new one.
*
- * @return DiscountInterface|null
+ * @return RuleDiscountInterface|null
*/
public function getExtensionAttributes()
{
@@ -94,11 +94,11 @@ public function getExtensionAttributes()
/**
* Set an extension attributes object.
*
- * @param DiscountInterface $extensionAttributes
+ * @param RuleDiscountInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
- DiscountInterface $extensionAttributes
+ RuleDiscountInterface $extensionAttributes
) {
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
index 4657b5bb5c9d3..f1e7c3fa42aa3 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -9,7 +9,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Quote\Model\Quote;
use Magento\Framework\Data\Collection;
-use Magento\SalesRule\Api\Data\DiscountInterfaceFactory;
+use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
/**
* Plugin for persisting discounts along with Quote Address
@@ -27,19 +27,19 @@ class Discount
private $discountFactory;
/**
- * @var DiscountInterfaceFactory
+ * @var RuleDiscountInterfaceFactory
*/
private $discountInterfaceFactory;
/**
* @param Json $json
* @param DataFactory $discountDataFactory
- * @param DiscountInterfaceFactory $discountInterfaceFactory
+ * @param RuleDiscountInterfaceFactory $discountInterfaceFactory
*/
public function __construct(
Json $json,
DataFactory $discountDataFactory,
- DiscountInterfaceFactory $discountInterfaceFactory
+ RuleDiscountInterfaceFactory $discountInterfaceFactory
) {
$this->json = $json;
$this->discountFactory = $discountDataFactory;
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 132d66f3f5add..cfa8ac92a6ca6 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -7,7 +7,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Framework\App\ObjectManager;
-use Magento\SalesRule\Api\Data\DiscountInterfaceFactory;
+use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
/**
* Discount totals calculation model.
@@ -46,7 +46,7 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
private $discountFactory;
/**
- * @var DiscountInterfaceFactory
+ * @var RuleDiscountInterfaceFactory
*/
private $discountInterfaceFactory;
@@ -56,7 +56,7 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
* @param \Magento\SalesRule\Model\Validator $validator
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param DataFactory|null $discountDataFactory
- * @param DiscountInterfaceFactory|null $discountInterfaceFactory
+ * @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
*/
public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
@@ -64,7 +64,7 @@ public function __construct(
\Magento\SalesRule\Model\Validator $validator,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
DataFactory $discountDataFactory = null,
- DiscountInterfaceFactory $discountInterfaceFactory = null
+ RuleDiscountInterfaceFactory $discountInterfaceFactory = null
) {
$this->setCode(self::COLLECTOR_TYPE_CODE);
$this->eventManager = $eventManager;
@@ -73,7 +73,7 @@ public function __construct(
$this->priceCurrency = $priceCurrency;
$this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
$this->discountInterfaceFactory = $discountInterfaceFactory
- ?: ObjectManager::getInstance()->get(DiscountInterfaceFactory::class);
+ ?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
}
/**
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index e8392b036e1a3..878f12e413dcf 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -12,7 +12,7 @@
use Magento\SalesRule\Model\ResourceModel\Rule\Collection;
use Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory;
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
-use Magento\SalesRule\Api\Data\DiscountInterfaceFactory;
+use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
/**
* Class RulesApplier
@@ -49,7 +49,7 @@ class RulesApplier
protected $discountFactory;
/**
- * @var DiscountInterfaceFactory
+ * @var RuleDiscountInterfaceFactory
*/
private $discountInterfaceFactory;
@@ -64,7 +64,7 @@ class RulesApplier
* @param Utility $utility
* @param ChildrenValidationLocator|null $childrenValidationLocator
* @param DataFactory|null $discountDataFactory
- * @param DiscountInterfaceFactory|null $discountInterfaceFactory
+ * @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
*/
public function __construct(
\Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory,
@@ -72,7 +72,7 @@ public function __construct(
\Magento\SalesRule\Model\Utility $utility,
ChildrenValidationLocator $childrenValidationLocator = null,
DataFactory $discountDataFactory = null,
- DiscountInterfaceFactory $discountInterfaceFactory = null
+ RuleDiscountInterfaceFactory $discountInterfaceFactory = null
) {
$this->calculatorFactory = $calculatorFactory;
$this->validatorUtility = $utility;
@@ -81,7 +81,7 @@ public function __construct(
?: ObjectManager::getInstance()->get(ChildrenValidationLocator::class);
$this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
$this->discountInterfaceFactory = $discountInterfaceFactory
- ?: ObjectManager::getInstance()->get(DiscountInterfaceFactory::class);
+ ?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
}
/**
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index af797750433f7..c6eb2447d3aab 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -30,7 +30,7 @@
type="Magento\SalesRule\Model\Data\CouponMassDeleteResult" />
-
diff --git a/app/code/Magento/SalesRule/etc/extension_attributes.xml b/app/code/Magento/SalesRule/etc/extension_attributes.xml
index f7ebcaaa35063..c69c309d8741b 100644
--- a/app/code/Magento/SalesRule/etc/extension_attributes.xml
+++ b/app/code/Magento/SalesRule/etc/extension_attributes.xml
@@ -7,9 +7,9 @@
-->
-
+
-
+
\ No newline at end of file
From cb84c7acfdc490d321291741ef9d10da663f9242 Mon Sep 17 00:00:00 2001
From: Mikalai Shostka
Date: Tue, 15 Oct 2019 20:46:22 +0300
Subject: [PATCH 0408/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Added automated test script
---
...refrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
index 4ee0372688c09..903e79b2328bc 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartTotalValueWithFullDiscountUsingCartRuleTest.xml
@@ -88,8 +88,8 @@
-
-
+
+
From c33a88e11243f15e3c5f9d6f2c51b4872e9c0a90 Mon Sep 17 00:00:00 2001
From: Mikalai Shostka
Date: Tue, 15 Oct 2019 20:48:17 +0300
Subject: [PATCH 0409/1978] MC-17869: Cart Total is shown as NaN when 100%
discount applied through Cart Rule
- Fix integration test
---
.../testsuite/Magento/Sales/_files/quotes.php | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
index b916fc0240417..3c4c164f0a01f 100644
--- a/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
+++ b/dev/tests/integration/testsuite/Magento/Sales/_files/quotes.php
@@ -5,6 +5,7 @@
*/
declare(strict_types=1);
+use Magento\Store\Model\StoreRepository;
use Magento\Quote\Model\QuoteFactory;
use Magento\Quote\Model\QuoteRepository;
use Magento\TestFramework\Helper\Bootstrap;
@@ -18,13 +19,18 @@
$quoteFactory = $objectManager->get(QuoteFactory::class);
/** @var QuoteRepository $quoteRepository */
$quoteRepository = $objectManager->get(QuoteRepository::class);
+/** @var StoreRepository $storeRepository */
+$storeRepository = $objectManager->get(StoreRepository::class);
+
+$defaultStore = $storeRepository->getActiveStoreByCode('default');
+$secondStore = $storeRepository->getActiveStoreByCode('fixture_second_store');
$quotes = [
'quote for first store' => [
- 'store' => 1,
+ 'store' => $defaultStore->getId(),
],
'quote for second store' => [
- 'store' => 2,
+ 'store' => $secondStore->getId(),
],
];
From 8bbfe1cafc59bb19920c56b432ca8e7f552593b2 Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Tue, 15 Oct 2019 14:05:27 -0500
Subject: [PATCH 0410/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
...CheckOrderOfProdsInWidgetOnCMSPageTest.xml | 128 ++++++++++++++++++
1 file changed, 128 insertions(+)
create mode 100644 app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
new file mode 100644
index 0000000000000..b984e554ac34b
--- /dev/null
+++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 4a1f3ab77f8d0dbbb7fc4d8c6dbb6ec70c400e74 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Tue, 15 Oct 2019 22:38:16 +0300
Subject: [PATCH 0411/1978] Renamed options and groups properties. PHPUnit
changed Option object creation by adding option groups. (#24726)
---
.../Magento/Catalog/Model/Product/Option.php | 32 +++++++++----------
.../Test/Unit/Model/Product/OptionTest.php | 11 ++++++-
app/code/Magento/Catalog/etc/di.xml | 4 +--
3 files changed, 28 insertions(+), 19 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index c4c042db3cdac..8f8d85592f640 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -11,9 +11,9 @@
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
-use Magento\Catalog\Model\Product\Option\Type\DefaultType;
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
use Magento\Catalog\Pricing\Price\BasePrice;
+use Magento\Framework\DataObject;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractExtensibleModel;
@@ -100,14 +100,14 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
protected $validatorPool;
/**
- * @var DefaultType[]
+ * @var string[]
*/
- private $groupsPool;
+ private $optionGroups;
/**
* @var string[]
*/
- private $typesPool;
+ private $optionGroupsToTypes;
/**
* @var MetadataPool
@@ -131,8 +131,8 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
- * @param array $groupsPool
- * @param array $typesPool
+ * @param array $optionGroups
+ * @param array $optionGroupsToTypes
* @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -148,18 +148,18 @@ public function __construct(
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
array $data = [],
- array $groupsPool = [],
- array $typesPool = [],
- ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null
+ ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null,
+ array $optionGroups = [],
+ array $optionGroupsToTypes = []
) {
$this->productOptionValue = $productOptionValue;
$this->optionTypeFactory = $optionFactory;
$this->string = $string;
$this->validatorPool = $validatorPool;
- $this->groupsPool = $groupsPool;
- $this->typesPool = $typesPool;
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
+ $this->optionGroups = $optionGroups;
+ $this->optionGroupsToTypes = $optionGroupsToTypes;
parent::__construct(
$context,
@@ -332,21 +332,21 @@ public function getGroupByType($type = null): string
$type = $this->getType();
}
- return $this->typesPool[$type] ?? '';
+ return $this->optionGroupsToTypes[$type] ?? '';
}
/**
* Group model factory
*
* @param string $type Option type
- * @return DefaultType
+ * @return DataObject
* @throws LocalizedException
*/
- public function groupFactory($type): DefaultType
+ public function groupFactory($type)
{
$group = $this->getGroupByType($type);
- if (!empty($group) && isset($this->groupsPool[$group])) {
- return $this->optionTypeFactory->create($this->groupsPool[$group]);
+ if (!empty($group) && isset($this->optionGroups[$group])) {
+ return $this->optionTypeFactory->create($this->optionGroups[$group]);
}
throw new LocalizedException(__('The option type to get group instance is incorrect.'));
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
index 1bd85c4053263..e0c1f487a2420 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
@@ -24,7 +24,16 @@ protected function setUp()
{
$this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
$objectManager = new ObjectManager($this);
- $this->model = $objectManager->getObject(\Magento\Catalog\Model\Product\Option::class);
+ $this->model = $objectManager->getObject(
+ \Magento\Catalog\Model\Product\Option::class,
+ [
+ 'optionGroupsToTypes' => [
+ 'field' => 'text',
+ 'drop_down' => 'select',
+ 'file' => 'file',
+ ]
+ ]
+ );
$this->model->setProduct($this->productMock);
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 6d9360dc3be97..0591006c23404 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -412,13 +412,13 @@
-
+
- Magento\Catalog\Model\Product\Option\Type\Date
- Magento\Catalog\Model\Product\Option\Type\File
- Magento\Catalog\Model\Product\Option\Type\Select
- Magento\Catalog\Model\Product\Option\Type\Text
-
+
- text
- text
- file
From f503d79cf83daa875d4dd69756867b0dde330210 Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Tue, 15 Oct 2019 14:41:43 -0500
Subject: [PATCH 0412/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
.../CheckOrderOfProdsInWidgetOnCMSPageTest.xml | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
index b984e554ac34b..5dfe17f018ec2 100644
--- a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
@@ -50,10 +50,10 @@
stepKey="selectCategoryCondition"/>
-
-
+
@@ -62,17 +62,17 @@
-
+
-
+
-
+
@@ -110,7 +110,7 @@
-
+
From b5692d93b4fdae479a33ec698d92ff48359f81a9 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Tue, 15 Oct 2019 23:35:29 +0300
Subject: [PATCH 0413/1978] Fixed phpdoc arguments ordering of __construct
(#24726)
---
app/code/Magento/Catalog/Model/Product/Option.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 8f8d85592f640..3177171270b2c 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -131,9 +131,9 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
+ * @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
* @param array $optionGroups
* @param array $optionGroupsToTypes
- * @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
From 62f084b1cea8b87eed15fc01595a71bfa58b4a24 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 15 Oct 2019 15:38:32 -0500
Subject: [PATCH 0414/1978] MC-20648: Implement the changes - Review fixes
---
.../Api/Data/DiscountDataInterface.php | 42 +++++++++++++++++--
.../Api/Data/RuleDiscountInterface.php | 35 ++++++++++++++--
.../SalesRule/Model/Data/RuleDiscount.php | 30 ++++++-------
.../SalesRule/Model/Plugin/Discount.php | 11 +++--
.../Model/Plugin/ResourceModel/Discount.php | 4 +-
.../Model/Quote/Item/Plugin/Discount.php | 4 +-
.../Model/Rule/Action/Discount/Data.php | 16 +++----
7 files changed, 106 insertions(+), 36 deletions(-)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
index 0d9f7187ff12d..01d58470081ae 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\SalesRule\Api\Data;
interface DiscountDataInterface
@@ -12,26 +14,58 @@ interface DiscountDataInterface
*
* @return float
*/
- public function getAmount();
+ public function getAmount(): float;
+
+ /**
+ * Set Amount
+ *
+ * @param float $amount
+ * @return $this
+ */
+ public function setAmount(float $amount);
/**
* Get Base Amount
*
* @return float
*/
- public function getBaseAmount();
+ public function getBaseAmount(): float;
+
+ /**
+ * Set Base Amount
+ *
+ * @param float $baseAmount
+ * @return $this
+ */
+ public function setBaseAmount(float $baseAmount);
/**
* Get Original Amount
*
* @return float
*/
- public function getOriginalAmount();
+ public function getOriginalAmount(): float;
+
+ /**
+ * Set original Amount
+ *
+ * @param float $originalAmount
+ * @return $this
+ */
+ public function setOriginalAmount(float $originalAmount);
/**
* Get Base Original Amount
*
* @return float
*/
- public function getBaseOriginalAmount();
+ public function getBaseOriginalAmount(): float;
+
+ /**
+ * Set base original Amount
+ *
+ * @param float $baseOriginalAmount
+ * @return $this
+ */
+ public function setBaseOriginalAmount(float $baseOriginalAmount);
}
diff --git a/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php b/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
index b67f83658de53..061a52e13f318 100644
--- a/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
@@ -3,6 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
+declare(strict_types=1);
+
namespace Magento\SalesRule\Api\Data;
/**
@@ -15,19 +18,43 @@ interface RuleDiscountInterface
*
* @return \Magento\SalesRule\Api\Data\DiscountDataInterface
*/
- public function getDiscountData();
+ public function getDiscountData(): DiscountDataInterface;
+
+ /**
+ * Set discount data
+ *
+ * @param DiscountDataInterface $discountData
+ * @return $this
+ */
+ public function setDiscountData(DiscountDataInterface $discountData);
+
+ /**
+ * Set Rule Label
+ *
+ * @param string $ruleLabel
+ * @return $this
+ */
+ public function setRuleLabel(string $ruleLabel);
/**
* Get Rule Label
*
* @return string
*/
- public function getRuleLabel();
+ public function getRuleLabel(): ?string;
+
+ /**
+ * Set Rule Id
+ *
+ * @param int $ruleID
+ * @return $this
+ */
+ public function setRuleID(int $ruleID);
/**
* Get Rule ID
*
- * @return string
+ * @return int
*/
- public function getRuleID();
+ public function getRuleID(): ?int;
}
diff --git a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
index e379acc862317..f8afbda84f3d2 100644
--- a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
@@ -3,11 +3,13 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\SalesRule\Model\Data;
-use Magento\SalesRule\Model\Rule\Action\Discount\Data;
use Magento\SalesRule\Api\Data\RuleDiscountInterface;
+use Magento\SalesRule\Api\Data\DiscountDataInterface;
+use Magento\Framework\Api\ExtensionAttributesInterface;
/**
* Data Model for Rule Discount
@@ -21,9 +23,9 @@ class RuleDiscount extends \Magento\Framework\Api\AbstractExtensibleObject imple
/**
* Get Discount Data
*
- * @return Data
+ * @return DiscountDataInterface
*/
- public function getDiscountData()
+ public function getDiscountData(): DiscountDataInterface
{
return $this->_get(self::KEY_DISCOUNT_DATA);
}
@@ -31,9 +33,9 @@ public function getDiscountData()
/**
* Get Rule Label
*
- * @return mixed|null
+ * @return string
*/
- public function getRuleLabel()
+ public function getRuleLabel(): ?string
{
return $this->_get(self::KEY_RULE_LABEL);
}
@@ -41,10 +43,10 @@ public function getRuleLabel()
/**
* Set Discount Data
*
- * @param Data $discountData
+ * @param DiscountDataInterface $discountData
* @return RuleDiscount
*/
- public function setDiscountData(Data $discountData)
+ public function setDiscountData(DiscountDataInterface $discountData)
{
return $this->setData(self::KEY_DISCOUNT_DATA, $discountData);
}
@@ -63,9 +65,9 @@ public function setRuleLabel(string $ruleLabel)
/**
* Get Rule ID
*
- * @return string
+ * @return int
*/
- public function getRuleID()
+ public function getRuleID(): ?int
{
return $this->_get(self::KEY_RULE_ID);
}
@@ -73,10 +75,10 @@ public function getRuleID()
/**
* Set Rule ID
*
- * @param string $ruleID
+ * @param int $ruleID
* @return RuleDiscount
*/
- public function setRuleID(string $ruleID)
+ public function setRuleID(int $ruleID)
{
return $this->setData(self::KEY_RULE_ID, $ruleID);
}
@@ -84,7 +86,7 @@ public function setRuleID(string $ruleID)
/**
* Retrieve existing extension attributes object or create a new one.
*
- * @return RuleDiscountInterface|null
+ * @return ExtensionAttributesInterface|null
*/
public function getExtensionAttributes()
{
@@ -94,11 +96,11 @@ public function getExtensionAttributes()
/**
* Set an extension attributes object.
*
- * @param RuleDiscountInterface $extensionAttributes
+ * @param ExtensionAttributesInterface $extensionAttributes
* @return $this
*/
public function setExtensionAttributes(
- RuleDiscountInterface $extensionAttributes
+ ExtensionAttributesInterface $extensionAttributes
) {
return $this->_setExtensionAttributes($extensionAttributes);
}
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
index f1e7c3fa42aa3..b520a556ec4f8 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\SalesRule\Model\Plugin;
use Magento\Framework\Serialize\Serializer\Json;
@@ -10,6 +12,7 @@
use Magento\Quote\Model\Quote;
use Magento\Framework\Data\Collection;
use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
+use Magento\SalesRule\Model\Rule\Action\Discount\Data;
/**
* Plugin for persisting discounts along with Quote Address
@@ -57,7 +60,7 @@ public function __construct(
public function afterGetItemsCollection(
Quote $subject,
Collection $result
- ) {
+ ): Collection {
foreach ($result as $item) {
if ($item->getDiscounts() && !$item->getExtensionAttributes()->getDiscounts()) {
$unserializeDiscounts = $this->json->unserialize($item->getDiscounts());
@@ -87,7 +90,7 @@ public function afterGetItemsCollection(
public function afterGetAllAddresses(
Quote $subject,
array $result
- ) {
+ ): array {
foreach ($result as $address) {
if ($address->getDiscounts() && !$address->getExtensionAttributes()->getDiscounts()) {
$unserializedDiscounts = $this->json->unserialize($address->getDiscounts());
@@ -110,9 +113,9 @@ public function afterGetAllAddresses(
* Unserialize discount object
*
* @param string $serializedDiscount
- * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
+ * @return Data
*/
- private function unserializeDiscountData(string $serializedDiscount)
+ private function unserializeDiscountData(string $serializedDiscount): Data
{
$discountArray = $this->json->unserialize($serializedDiscount);
$discountData = $this->discountFactory->create();
diff --git a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
index 10ac22265f47b..767dba7993d1e 100644
--- a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\SalesRule\Model\Plugin\ResourceModel;
use Magento\Framework\Serialize\Serializer\Json;
@@ -36,7 +38,7 @@ public function __construct(Json $json)
public function beforeSave(
\Magento\Quote\Model\ResourceModel\Quote $subject,
\Magento\Framework\Model\AbstractModel $object
- ) {
+ ): array {
foreach ($object->getAllAddresses() as $address) {
$discounts = $address->getExtensionAttributes()->getDiscounts();
$serializedDiscounts= [];
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
index 3e228b9f524a5..680a07b7444f9 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\SalesRule\Model\Quote\Item\Plugin;
use Magento\Quote\Model\Quote\Item\CartItemPersister;
@@ -35,7 +37,7 @@ public function __construct(Json $json)
* @return array
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function beforeSave(CartItemPersister $subject, CartInterface $quote, CartItemInterface $cartItem)
+ public function beforeSave(CartItemPersister $subject, CartInterface $quote, CartItemInterface $cartItem): array
{
$cartExtension = $cartItem->getExtensionAttributes();
$discounts = $cartExtension->getDiscounts();
diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
index c30c436751480..9b5d0aa7506e7 100644
--- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
+++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
@@ -50,7 +50,7 @@ public function __construct()
* @param float $amount
* @return $this
*/
- public function setAmount($amount)
+ public function setAmount(float $amount)
{
$this->amount = $amount;
return $this;
@@ -61,7 +61,7 @@ public function setAmount($amount)
*
* @return float
*/
- public function getAmount()
+ public function getAmount(): float
{
return $this->amount;
}
@@ -72,7 +72,7 @@ public function getAmount()
* @param float $baseAmount
* @return $this
*/
- public function setBaseAmount($baseAmount)
+ public function setBaseAmount(float $baseAmount)
{
$this->baseAmount = $baseAmount;
return $this;
@@ -83,7 +83,7 @@ public function setBaseAmount($baseAmount)
*
* @return float
*/
- public function getBaseAmount()
+ public function getBaseAmount(): float
{
return $this->baseAmount;
}
@@ -94,7 +94,7 @@ public function getBaseAmount()
* @param float $originalAmount
* @return $this
*/
- public function setOriginalAmount($originalAmount)
+ public function setOriginalAmount(float $originalAmount)
{
$this->originalAmount = $originalAmount;
return $this;
@@ -105,7 +105,7 @@ public function setOriginalAmount($originalAmount)
*
* @return float
*/
- public function getOriginalAmount()
+ public function getOriginalAmount(): float
{
return $this->originalAmount;
}
@@ -116,7 +116,7 @@ public function getOriginalAmount()
* @param float $baseOriginalAmount
* @return $this
*/
- public function setBaseOriginalAmount($baseOriginalAmount)
+ public function setBaseOriginalAmount(float $baseOriginalAmount)
{
$this->baseOriginalAmount = $baseOriginalAmount;
return $this;
@@ -127,7 +127,7 @@ public function setBaseOriginalAmount($baseOriginalAmount)
*
* @return float
*/
- public function getBaseOriginalAmount()
+ public function getBaseOriginalAmount(): float
{
return $this->baseOriginalAmount;
}
From b3860bc3e02969c30c1eaf40c207d4c43dcda5fd Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Tue, 15 Oct 2019 15:43:10 -0500
Subject: [PATCH 0415/1978] MC-21808: MySQL performance query optimization
---
.../Search/Model/PopularSearchTerms.php | 26 +++++--------------
.../Model/ResourceModel/Query/Collection.php | 19 +++++---------
app/code/Magento/Search/etc/db_schema.xml | 4 +++
3 files changed, 18 insertions(+), 31 deletions(-)
diff --git a/app/code/Magento/Search/Model/PopularSearchTerms.php b/app/code/Magento/Search/Model/PopularSearchTerms.php
index dfa682a3c8936..d5ddc0e1dac5f 100644
--- a/app/code/Magento/Search/Model/PopularSearchTerms.php
+++ b/app/code/Magento/Search/Model/PopularSearchTerms.php
@@ -27,24 +27,16 @@ class PopularSearchTerms
*/
private $queryCollection;
- /**
- * @var \Magento\Search\Model\ResourceModel\Query
- */
- private $queryResource;
-
/**
* @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
* @param \Magento\Search\Model\ResourceModel\Query\Collection
- * @param ResourceModel\Query $queryResource
*/
public function __construct(
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
- \Magento\Search\Model\ResourceModel\Query\Collection $queryCollection,
- \Magento\Search\Model\ResourceModel\Query $queryResource
+ \Magento\Search\Model\ResourceModel\Query\Collection $queryCollection
) {
$this->scopeConfig = $scopeConfig;
$this->queryCollection = $queryCollection;
- $this->queryResource = $queryResource;
}
/**
@@ -56,17 +48,13 @@ public function __construct(
*/
public function isCacheable(string $term, int $storeId)
{
- $connection = $this->queryResource->getConnection();
- $select = $connection->select();
- $select->from($this->queryResource->getMainTable(), [$this->queryResource->getIdFieldName()])
- ->where('query_text = ?', $term)
- ->where('store_id = ?', $storeId)
- ->where('num_results > 0')
- ->order(['popularity DESC'])
- ->limit($this->getMaxCountCacheableSearchTerms($storeId));
- $queryId = $connection->fetchOne($select);
+ $terms = $this->queryCollection
+ ->setPopularQueryFilter($storeId)
+ ->setPageSize($this->getMaxCountCacheableSearchTerms($storeId))
+ ->load()
+ ->getColumnValues('query_text');
- return (bool) $queryId;
+ return in_array($term, $terms);
}
/**
diff --git a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
index e34c841f32bd1..a1bc1df3f9bdb 100644
--- a/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
+++ b/app/code/Magento/Search/Model/ResourceModel/Query/Collection.php
@@ -130,7 +130,6 @@ public function setQueryFilter($query)
*/
public function setPopularQueryFilter($storeIds = null)
{
-
$this->getSelect()->reset(
\Magento\Framework\DB\Select::FROM
)->reset(
@@ -140,13 +139,10 @@ public function setPopularQueryFilter($storeIds = null)
)->from(
['main_table' => $this->getTable('search_query')]
);
- if ($storeIds) {
- $this->addStoreFilter($storeIds);
- $this->getSelect()->where('num_results > 0');
- } elseif (null === $storeIds) {
- $this->addStoreFilter($this->_storeManager->getStore()->getId());
- $this->getSelect()->where('num_results > 0');
- }
+
+ $storeIds = $storeIds ?: $this->_storeManager->getStore()->getId();
+ $this->addStoreFilter($storeIds);
+ $this->getSelect()->where('num_results > 0');
$this->getSelect()->order(['popularity desc']);
@@ -172,10 +168,9 @@ public function setRecentQueryFilter()
*/
public function addStoreFilter($storeIds)
{
- if (!is_array($storeIds)) {
- $storeIds = [$storeIds];
- }
- $this->getSelect()->where('main_table.store_id IN (?)', $storeIds);
+ $condition = is_array($storeIds) ? 'main_table.store_id IN (?)' : 'main_table.store_id = ?';
+ $this->getSelect()->where($condition, $storeIds);
+
return $this;
}
}
diff --git a/app/code/Magento/Search/etc/db_schema.xml b/app/code/Magento/Search/etc/db_schema.xml
index ab4b54298c2a3..1a01ffa42401c 100644
--- a/app/code/Magento/Search/etc/db_schema.xml
+++ b/app/code/Magento/Search/etc/db_schema.xml
@@ -46,6 +46,10 @@
+
+
+
+
Date: Wed, 16 Oct 2019 12:38:28 +0530
Subject: [PATCH 0416/1978] Fixed: Undefined index: store_view_code.
---
.../CatalogImportExport/Model/Import/Product/Option.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
index 4d8088a235402..2955e7f9f9fbd 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
@@ -2086,7 +2086,11 @@ protected function _parseCustomOptions($rowData)
}
}
}
- $options[$name][$k]['_custom_option_store'] = $rowData[Product::COL_STORE_VIEW_CODE];
+ if (isset($rowData[Product::COL_STORE_VIEW_CODE])) {
+ $options[$name][$k][self::COLUMN_STORE] = $rowData[Product::COL_STORE_VIEW_CODE];
+ } else {
+ $options[$name][$k][self::COLUMN_STORE] = Store::DEFAULT_STORE_ID;
+ }
$k++;
}
$rowData['custom_options'] = $options;
From 2138e68aeced33886a98406c5f26e1036385a495 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Wed, 16 Oct 2019 12:52:30 +0530
Subject: [PATCH 0417/1978] Removed wrong code.
---
.../Magento/CatalogImportExport/Model/Import/Product/Option.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
index 2955e7f9f9fbd..98220208cda3e 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
@@ -2089,7 +2089,7 @@ protected function _parseCustomOptions($rowData)
if (isset($rowData[Product::COL_STORE_VIEW_CODE])) {
$options[$name][$k][self::COLUMN_STORE] = $rowData[Product::COL_STORE_VIEW_CODE];
} else {
- $options[$name][$k][self::COLUMN_STORE] = Store::DEFAULT_STORE_ID;
+ $options[$name][$k][self::COLUMN_STORE] = '';
}
$k++;
}
From 84daa3ff9fcecb49eefe8542c528e2f0ddf9fdec Mon Sep 17 00:00:00 2001
From: Nikita Shcherbatykh
Date: Wed, 16 Oct 2019 11:01:50 +0300
Subject: [PATCH 0418/1978] MC-21706: When products are added to a cart in the
admin from a non-default website, the cart empties and nothing is added
---
app/code/Magento/Quote/Model/QuoteRepository.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Quote/Model/QuoteRepository.php b/app/code/Magento/Quote/Model/QuoteRepository.php
index 30931821ddc7d..ccfd3df5fafa3 100644
--- a/app/code/Magento/Quote/Model/QuoteRepository.php
+++ b/app/code/Magento/Quote/Model/QuoteRepository.php
@@ -224,7 +224,7 @@ protected function loadQuote($loadMethod, $loadField, $identifier, array $shared
{
/** @var CartInterface $quote */
$quote = $this->cartFactory->create();
- if ($sharedStoreIds && method_exists($quote, 'setSharedStoreIds')) {
+ if ($sharedStoreIds && is_callable([$quote, 'setSharedStoreIds'])) {
$quote->setSharedStoreIds($sharedStoreIds);
}
$quote->setStoreId($this->storeManager->getStore()->getId())->$loadMethod($identifier);
From 4455b7b3843e4c8a7064266e5f8fa166ae2d4b07 Mon Sep 17 00:00:00 2001
From: Mikalai Shostka
Date: Wed, 16 Oct 2019 11:12:53 +0300
Subject: [PATCH 0419/1978] MC-18822: Increase test coverage for Content
functional area
- Automation test for MC-6192
---
.../Catalog/Test/Mftf/Section/AdminProductFormSection.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
index 31e635c7dcd30..fda2aa831dcf3 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
@@ -9,6 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
+
From 3953a4a1531a6ba49ab808436e41b1f958d4b7c3 Mon Sep 17 00:00:00 2001
From: Nikita Shcherbatykh
Date: Wed, 16 Oct 2019 14:13:21 +0300
Subject: [PATCH 0420/1978] MC-21706: When products are added to a cart in the
admin from a non-default website, the cart empties and nothing is added
---
.../Test/Unit/Model/QuoteRepositoryTest.php | 33 +++++++++++++++++--
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php
index 095e1760df86f..9c28a06fe83eb 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteRepositoryTest.php
@@ -9,6 +9,7 @@
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SortOrder;
use Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface;
+use PHPUnit\Framework\MockObject\Matcher\InvokedCount as InvokedCountMatch;
use Magento\Framework\ObjectManagerInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Quote\Api\Data\CartInterface;
@@ -284,7 +285,14 @@ public function testGetWithSharedStoreIds()
$this->assertEquals($this->quoteMock, $this->model->get($cartId, $sharedStoreIds));
}
- public function testGetForCustomer()
+ /**
+ * Test getForCustomer method
+ *
+ * @param InvokedCountMatch $invokeTimes
+ * @param array $sharedStoreIds
+ * @dataProvider getForCustomerDataProvider
+ */
+ public function testGetForCustomer(InvokedCountMatch $invokeTimes, array $sharedStoreIds)
{
$cartId = 17;
$customerId = 23;
@@ -298,7 +306,7 @@ public function testGetForCustomer()
$this->storeMock->expects(static::once())
->method('getId')
->willReturn(1);
- $this->quoteMock->expects(static::never())
+ $this->quoteMock->expects($invokeTimes)
->method('setSharedStoreIds');
$this->quoteMock->expects(static::once())
->method('loadByCustomer')
@@ -312,8 +320,27 @@ public function testGetForCustomer()
->method('load')
->with($this->quoteMock);
+ static::assertEquals($this->quoteMock, $this->model->getForCustomer($customerId, $sharedStoreIds));
static::assertEquals($this->quoteMock, $this->model->getForCustomer($customerId));
- static::assertEquals($this->quoteMock, $this->model->getForCustomer($customerId));
+ }
+
+ /**
+ * Checking how many times we invoke setSharedStoreIds() in protected method loadQuote()
+ *
+ * @return array
+ */
+ public function getForCustomerDataProvider()
+ {
+ return [
+ [
+ 'invoke_number_times' => static::never(),
+ 'shared_store_ids' => []
+ ],
+ [
+ 'invoke_number_times' => static::once(),
+ 'shared_store_ids' => [1]
+ ]
+ ];
}
/**
From 3171173fccbd6bbe5a3f39f0cd51aa85469e779b Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Wed, 16 Oct 2019 14:43:19 +0300
Subject: [PATCH 0421/1978] MC-21862: [Integration] Automate MC-11658
---
.../Customer/Controller/AccountTest.php | 60 +++++++++++++++++++
1 file changed, 60 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index 7116953d682b3..7a68c1533ead2 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -20,11 +20,14 @@
use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\Stdlib\CookieManagerInterface;
+use Magento\Store\Model\StoreManager;
+use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
use Magento\TestFramework\Request;
use Magento\TestFramework\Response;
use Magento\Theme\Controller\Result\MessagePlugin;
+use PHPUnit\Framework\Constraint\StringContains;
use Zend\Stdlib\Parameters;
/**
@@ -744,6 +747,63 @@ public function testLoginPostRedirect($redirectDashboard, string $redirectUrl)
$this->assertTrue($this->_objectManager->get(Session::class)->isLoggedIn());
}
+ /**
+ * Register Customer with email confirmation.
+ *
+ * @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php
+ * @return void
+ */
+ public function testRegisterCustomerWithEmailConfirmation(): void
+ {
+ $email = 'test_example@email.com';
+ $this->fillRequestWithAccountDataAndFormKey($email);
+ $this->dispatch('customer/account/createPost');
+ $this->assertRedirect($this->stringContains('customer/account/index/'));
+ $this->assertSessionMessages(
+ $this->equalTo(
+ [
+ 'You must confirm your account. Please check your email for the confirmation link or '
+ . 'click here for a new link.'
+ ]
+ ),
+ MessageInterface::TYPE_SUCCESS
+ );
+ /** @var CustomerRepositoryInterface $customerRepository */
+ $customerRepository = $this->_objectManager->create(CustomerRepositoryInterface::class);
+ /** @var CustomerInterface $customer */
+ $customer = $customerRepository->get($email);
+ $confirmation = $customer->getConfirmation();
+ $message = $this->transportBuilderMock->getSentMessage();
+ $rawMessage = $message->getBody()->getParts()[0]->getRawContent();
+ $messageConstraint = $this->logicalAnd(
+ new StringContains("You must confirm your {$email} email before you can sign in (link is only valid once"),
+ new StringContains("customer/account/confirm/?id={$customer->getId()}&key={$confirmation}")
+ );
+ $this->assertThat($rawMessage, $messageConstraint);
+
+ /** @var CookieManagerInterface $cookieManager */
+ $cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
+ $cookieManager->deleteCookie(MessagePlugin::MESSAGES_COOKIES_NAME);
+ $this->_objectManager->removeSharedInstance(Http::class);
+ $this->_objectManager->removeSharedInstance(Request::class);
+ $this->_request = null;
+
+ $this->getRequest()->setParam('id', $customer->getId());
+ $this->getRequest()->setParam('key', $confirmation);
+ $this->dispatch('customer/account/confirm');
+
+ /** @var StoreManager $store */
+ $store = $this->_objectManager->get(StoreManagerInterface::class);
+ $name = $store->getStore()->getFrontendName();
+
+ $this->assertRedirect($this->stringContains('customer/account/index/'));
+ $this->assertSessionMessages(
+ $this->equalTo(["Thank you for registering with {$name}."]),
+ MessageInterface::TYPE_SUCCESS
+ );
+ }
+
/**
* Test that confirmation email address displays special characters correctly.
*
From d3c971529b1d35891e4375bb7dd96eda85b19889 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Wed, 16 Oct 2019 14:44:06 +0300
Subject: [PATCH 0422/1978] MC-20703: Admin: Delete a category
---
.../Adminhtml/Category/DeleteTest.php | 18 +++++++++++----
.../Catalog/Model/CategoryRepositoryTest.php | 22 +++++++++++++------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
index 0325cf2bb1d5f..8db16fa2c4546 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Category/DeleteTest.php
@@ -15,23 +15,33 @@
* Test for class \Magento\Catalog\Controller\Adminhtml\Category\Delete
*
* @magentoAppArea adminhtml
- * @magentoDbIsolation enabled
*/
class DeleteTest extends AbstractBackendController
{
/**
* @return void
*/
- public function testWithError(): void
+ public function testDeleteMissingCategory(): void
{
$incorrectId = 825852;
- $postData = ['id' => $incorrectId];
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
- $this->getRequest()->setPostValue($postData);
+ $this->getRequest()->setPostValue(['id' => $incorrectId]);
$this->dispatch('backend/catalog/category/delete');
$this->assertSessionMessages(
$this->equalTo([(string)__(sprintf('No such entity with id = %s', $incorrectId))]),
MessageInterface::TYPE_ERROR
);
}
+
+ /**
+ * @magentoDbIsolation enabled
+ * @magentoDataFixture Magento/Catalog/_files/category.php
+ */
+ public function testDeleteCategory(): void
+ {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue(['id' => 333]);
+ $this->dispatch('backend/catalog/category/delete');
+ $this->assertSessionMessages($this->equalTo([(string)__('You deleted the category.')]));
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
index 0771f0b9e71af..c7353d10f5dcf 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\CategoryRepositoryInterface;
use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Api\Data\CategoryInterfaceFactory;
+use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
use Magento\Framework\Acl\Builder;
use Magento\Framework\ObjectManagerInterface;
@@ -51,6 +52,9 @@ class CategoryRepositoryTest extends TestCase
/** @var ObjectManagerInterface */
private $objectManager;
+ /** @var CategoryCollectionFactory */
+ private $categoryCollectionFactory;
+
/**
* Sets up common objects.
*
@@ -64,6 +68,7 @@ protected function setUp()
$this->aclBuilder = $this->objectManager->get(Builder::class);
$this->categoryFactory = $this->objectManager->get(CategoryInterfaceFactory::class);
$this->productCollectionFactory = $this->objectManager->get(CollectionFactory::class);
+ $this->categoryCollectionFactory = $this->objectManager->create(CategoryCollectionFactory::class);
}
/**
@@ -127,20 +132,23 @@ public function testSaveDesign(): void
* @magentoAppArea adminhtml
* @return void
*/
- public function testDeleteCategory(): void
+ public function testCheckCategoryBehaviourAfterDelete(): void
{
$productCollection = $this->productCollectionFactory->create();
- $deletedCategories = [3, 4, 5, 13];
- $categoryCollection = $this->categoryFactory->create()->getCollection()->toArray();
+ $deletedCategories = ['3', '4', '5', '13'];
+ $categoryCollectionIds = $this->categoryCollectionFactory->create()->getAllIds();
$this->repo->deleteByIdentifier(3);
- $this->assertEmpty(
- $productCollection->addCategoriesFilter(['in' => $deletedCategories])->getItems(),
+ $this->assertEquals(
+ 0,
+ $productCollection->addCategoriesFilter(['in' => $deletedCategories])->getSize(),
'The category-products relations was not deleted after category delete'
);
- $newCategoryCollection = $this->categoryFactory->create()->getCollection()->toArray();
+ $newCategoryCollectionIds = $this->categoryCollectionFactory->create()->getAllIds();
+ $difference = array_diff($categoryCollectionIds, $newCategoryCollectionIds);
+ sort($difference);
$this->assertEquals(
$deletedCategories,
- array_keys(array_diff_key($categoryCollection, $newCategoryCollection)),
+ $difference,
'Wrong categories was deleted'
);
}
From f16341bda58ddcfcb843a5b8d4aceb0fd2d00055 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Wed, 16 Oct 2019 14:52:57 +0300
Subject: [PATCH 0423/1978] MC-21862: [Integration] Automate MC-11658
---
.../testsuite/Magento/Customer/Controller/AccountTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index 7a68c1533ead2..23b94c133d0ba 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -802,6 +802,7 @@ public function testRegisterCustomerWithEmailConfirmation(): void
$this->equalTo(["Thank you for registering with {$name}."]),
MessageInterface::TYPE_SUCCESS
);
+ $this->assertEmpty($customerRepository->get($email)->getConfirmation());
}
/**
From 9310b485a98f2bfe832840dc8f4e397481c137c0 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Wed, 16 Oct 2019 14:55:17 +0300
Subject: [PATCH 0424/1978] MC-20689: Admin: Create new attribute set
---
.../Adminhtml/Product/Set/SaveTest.php | 197 ++++++++++++++----
1 file changed, 160 insertions(+), 37 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
index 187fddae1ce4f..3f56808e9bc70 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
@@ -7,26 +7,29 @@
namespace Magento\Catalog\Controller\Adminhtml\Product\Set;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product\Attribute\Repository;
+use Magento\Developer\Model\Logger\Handler\Syslog;
+use Magento\Eav\Api\AttributeManagementInterface;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Api\SearchCriteriaBuilder;
-use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\App\Request\Http as HttpRequest;
-use Magento\Eav\Api\AttributeManagementInterface;
-use Magento\Catalog\Api\Data\ProductInterfaceFactory;
-use Magento\Framework\Api\DataObjectHelper;
-use Magento\Catalog\Api\ProductRepositoryInterface;
-use Magento\Catalog\Api\Data\ProductInterface;
-use Magento\Developer\Model\Logger\Handler\Syslog;
+use Magento\Framework\Logger\Handler\System;
use Magento\Framework\Logger\Monolog;
-use Magento\Catalog\Model\Product\Attribute\Repository;
+use Magento\Framework\Message\MessageInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\TestCase\AbstractBackendController;
/**
- * Test save attribute set
+ * Testing for saving an existing or creating a new attribute set.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class SaveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
+class SaveTest extends AbstractBackendController
{
/**
* @var string
@@ -63,6 +66,11 @@ class SaveTest extends \Magento\TestFramework\TestCase\AbstractBackendController
*/
private $attributeRepository;
+ /**
+ * @var AttributeSetRepositoryInterface
+ */
+ private $attributeSetRepository;
+
/**
* @inheritDoc
*/
@@ -80,11 +88,11 @@ public function setUp()
$this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
$this->attributeRepository = $this->_objectManager->get(Repository::class);
$this->dataObjectHelper = $this->_objectManager->get(DataObjectHelper::class);
+ $this->attributeSetRepository = $this->_objectManager->get(AttributeSetRepositoryInterface::class);
}
/**
* @inheritdoc
- * @throws \Magento\Framework\Exception\FileSystemException
*/
public function tearDown()
{
@@ -93,9 +101,65 @@ public function tearDown()
}
/**
+ * Test that new attribute set based on default attribute set will be successfully created.
+ *
+ * @magentoDbIsolation enabled
+ *
+ * @return void
+ */
+ public function testCreateNewAttributeSetBasedOnDefaultAttributeSet(): void
+ {
+ $this->createAttributeSetBySkeletonAndAssert('Attribute set name for test', 4);
+ }
+
+ /**
+ * Test that new attribute set based on custom attribute set will be successfully created.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_with_renamed_group.php
+ *
+ * @magentoDbIsolation enabled
+ *
+ * @return void
+ */
+ public function testCreateNewAttributeSetBasedOnCustomAttributeSet(): void
+ {
+ $existCustomAttributeSet = $this->getAttributeSetByName('attribute_set_test');
+ $this->createAttributeSetBySkeletonAndAssert(
+ 'Attribute set name for test',
+ (int)$existCustomAttributeSet->getAttributeSetId()
+ );
+ }
+
+ /**
+ * Test that new attribute set based on custom attribute set will be successfully created.
+ *
+ * @magentoDbIsolation enabled
+ *
+ * @return void
+ */
+ public function testGotErrorDuringCreateAttributeSetWithoutName(): void
+ {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue(
+ [
+ 'gotoEdit' => '1',
+ 'skeleton_set' => 4,
+ ]
+ );
+ $this->dispatch('backend/catalog/product_set/save/');
+ $this->assertSessionMessages(
+ $this->contains('The attribute set name is empty. Enter the name and try again.'),
+ MessageInterface::TYPE_ERROR
+ );
+ }
+
+ /**
+ * Test that exception throws during save attribute set name process if name of attribute set already exists.
+ *
* @magentoDataFixture Magento/Catalog/_files/attribute_set_with_renamed_group.php
+ * @return void
*/
- public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated()
+ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated(): void
{
$attributeSet = $this->getAttributeSetByName('attribute_set_test');
$this->assertNotEmpty($attributeSet, 'Attribute set with name "attribute_set_test" is missed');
@@ -128,35 +192,16 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated()
);
}
- /**
- * @param string $attributeSetName
- * @return AttributeSetInterface|null
- */
- protected function getAttributeSetByName($attributeSetName)
- {
- $objectManager = Bootstrap::getObjectManager();
-
- /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
- $searchCriteriaBuilder = $objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
-
- /** @var AttributeSetRepositoryInterface $attributeSetRepository */
- $attributeSetRepository = $objectManager->get(AttributeSetRepositoryInterface::class);
- $result = $attributeSetRepository->getList($searchCriteriaBuilder->create());
-
- $items = $result->getItems();
- return $result->getTotalCount() ? array_pop($items) : null;
- }
-
/**
* Test behavior when attribute set was changed to a new set
- * with deleted attribute from the previous set
+ * with deleted attribute from the previous set.
*
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
* @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default.php
* @magentoDbIsolation disabled
+ * @return void
*/
- public function testRemoveAttributeFromAttributeSet()
+ public function testRemoveAttributeFromAttributeSet(): void
{
$message = 'Attempt to load value of nonexistent EAV attribute';
$this->removeSyslog();
@@ -178,7 +223,7 @@ public function testRemoveAttributeFromAttributeSet()
}
/**
- * Retrieve system.log file path
+ * Retrieve system.log file path.
*
* @return string
*/
@@ -186,7 +231,7 @@ private function getSyslogPath(): string
{
if (!$this->systemLogPath) {
foreach ($this->logger->getHandlers() as $handler) {
- if ($handler instanceof \Magento\Framework\Logger\Handler\System) {
+ if ($handler instanceof System) {
$this->systemLogPath = $handler->getUrl();
}
}
@@ -200,11 +245,89 @@ private function getSyslogPath(): string
*
* @return void
*/
- private function removeSyslog()
+ private function removeSyslog(): void
{
$this->syslogHandler->close();
if (file_exists($this->getSyslogPath())) {
unlink($this->getSyslogPath());
}
}
+
+ /**
+ * Search and return attribute set by name.
+ *
+ * @param string $attributeSetName
+ * @return AttributeSetInterface|null
+ */
+ private function getAttributeSetByName(string $attributeSetName): ?AttributeSetInterface
+ {
+ /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
+ $searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
+ $searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
+ $result = $this->attributeSetRepository->getList($searchCriteriaBuilder->create());
+ $items = $result->getItems();
+
+ return $result->getTotalCount() ? array_pop($items) : null;
+ }
+
+ /**
+ * Create attribute set by skeleton attribute set id and assert that attribute set
+ * created successfully and attributes from skeleton attribute set and created attribute set are equals.
+ *
+ * @param string $attributeSetName
+ * @param int $skeletonAttributeSetId
+ */
+ private function createAttributeSetBySkeletonAndAssert(
+ string $attributeSetName,
+ int $skeletonAttributeSetId
+ ): void {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue(
+ [
+ 'attribute_set_name' => $attributeSetName,
+ 'gotoEdit' => '1',
+ 'skeleton_set' => $skeletonAttributeSetId,
+ ]
+ );
+ $this->dispatch('backend/catalog/product_set/save/');
+ $this->assertSessionMessages(
+ $this->contains('You saved the attribute set.'),
+ MessageInterface::TYPE_SUCCESS
+ );
+ $createdAttributeSet = $this->getAttributeSetByName($attributeSetName);
+ $existAttributeSet = $this->attributeSetRepository->get($skeletonAttributeSetId);
+
+ $this->assertNotNull($createdAttributeSet);
+ $this->assertEquals($attributeSetName, $createdAttributeSet->getAttributeSetName());
+
+ $this->assertAttributeSetsAttributesAreEquals($createdAttributeSet, $existAttributeSet);
+ }
+
+ /**
+ * Assert that both attribute sets contains identical attributes by attribute ids.
+ *
+ * @param AttributeSetInterface $createdAttributeSet
+ * @param AttributeSetInterface $existAttributeSet
+ */
+ private function assertAttributeSetsAttributesAreEquals(
+ AttributeSetInterface $createdAttributeSet,
+ AttributeSetInterface $existAttributeSet
+ ): void {
+ $expectedAttributeIds = array_keys(
+ $this->attributeManagement->getAttributes(
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
+ $existAttributeSet->getAttributeSetId()
+ )
+ );
+ $actualAttributeIds = array_keys(
+ $this->attributeManagement->getAttributes(
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
+ $createdAttributeSet->getAttributeSetId()
+ )
+ );
+ $this->assertEquals(count($expectedAttributeIds), count($actualAttributeIds));
+ foreach ($actualAttributeIds as $attributeId) {
+ $this->assertTrue(in_array($attributeId, $expectedAttributeIds, true));
+ }
+ }
}
From c9f098940b0157e8fbe0d8047b6ff9b75179d135 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Wed, 16 Oct 2019 16:19:53 +0300
Subject: [PATCH 0425/1978] MC-20703: Admin: Delete a category
---
.../testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
index c7353d10f5dcf..e5e94cb13ab52 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryRepositoryTest.php
@@ -132,7 +132,7 @@ public function testSaveDesign(): void
* @magentoAppArea adminhtml
* @return void
*/
- public function testCheckCategoryBehaviourAfterDelete(): void
+ public function testCategoryBehaviourAfterDelete(): void
{
$productCollection = $this->productCollectionFactory->create();
$deletedCategories = ['3', '4', '5', '13'];
From b688f57d8f46bc0809f88070da28a19f2dfba025 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Wed, 16 Oct 2019 16:26:21 +0300
Subject: [PATCH 0426/1978] MC-20689: Admin: Create new attribute set
---
.../Adminhtml/Product/Set/SaveTest.php | 52 +++++++++++++++----
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
index 3f56808e9bc70..aa6e85f1d6a51 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
@@ -15,12 +15,14 @@
use Magento\Eav\Api\AttributeManagementInterface;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Eav\Model\Config;
use Magento\Framework\Api\DataObjectHelper;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Logger\Handler\System;
use Magento\Framework\Logger\Monolog;
use Magento\Framework\Message\MessageInterface;
+use Magento\Framework\Serialize\Serializer\Json;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -71,6 +73,16 @@ class SaveTest extends AbstractBackendController
*/
private $attributeSetRepository;
+ /**
+ * @var Config
+ */
+ private $eavConfig;
+
+ /**
+ * @var Json
+ */
+ private $json;
+
/**
* @inheritDoc
*/
@@ -89,6 +101,8 @@ public function setUp()
$this->attributeRepository = $this->_objectManager->get(Repository::class);
$this->dataObjectHelper = $this->_objectManager->get(DataObjectHelper::class);
$this->attributeSetRepository = $this->_objectManager->get(AttributeSetRepositoryInterface::class);
+ $this->eavConfig = $this->_objectManager->get(Config::class);
+ $this->json = $this->_objectManager->get(Json::class);
}
/**
@@ -109,7 +123,10 @@ public function tearDown()
*/
public function testCreateNewAttributeSetBasedOnDefaultAttributeSet(): void
{
- $this->createAttributeSetBySkeletonAndAssert('Attribute set name for test', 4);
+ $this->createAttributeSetBySkeletonAndAssert(
+ 'Attribute set name for test',
+ $this->getCatalogProductDefaultAttributeSetId()
+ );
}
/**
@@ -143,12 +160,12 @@ public function testGotErrorDuringCreateAttributeSetWithoutName(): void
$this->getRequest()->setPostValue(
[
'gotoEdit' => '1',
- 'skeleton_set' => 4,
+ 'skeleton_set' => $this->getCatalogProductDefaultAttributeSetId(),
]
);
$this->dispatch('backend/catalog/product_set/save/');
$this->assertSessionMessages(
- $this->contains('The attribute set name is empty. Enter the name and try again.'),
+ $this->equalTo([(string)__('The attribute set name is empty. Enter the name and try again.')]),
MessageInterface::TYPE_ERROR
);
}
@@ -167,7 +184,7 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated():
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue(
'data',
- json_encode(
+ $this->json->serialize(
[
'attribute_set_name' => 'attribute_set_test',
'groups' => [
@@ -183,12 +200,12 @@ public function testAlreadyExistsExceptionProcessingWhenGroupCodeIsDuplicated():
);
$this->dispatch('backend/catalog/product_set/save/id/' . $attributeSet->getAttributeSetId());
- $jsonResponse = json_decode($this->getResponse()->getBody());
+ $jsonResponse = $this->json->unserialize($this->getResponse()->getBody());
$this->assertNotNull($jsonResponse);
- $this->assertEquals(1, $jsonResponse->error);
+ $this->assertEquals(1, $jsonResponse['error']);
$this->assertContains(
- 'Attribute group with same code already exist. Please rename "attribute-group-name" group',
- $jsonResponse->message
+ (string)__('Attribute group with same code already exist. Please rename "attribute-group-name" group'),
+ $jsonResponse['message']
);
}
@@ -265,9 +282,10 @@ private function getAttributeSetByName(string $attributeSetName): ?AttributeSetI
$searchCriteriaBuilder = $this->_objectManager->get(SearchCriteriaBuilder::class);
$searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
$result = $this->attributeSetRepository->getList($searchCriteriaBuilder->create());
+
$items = $result->getItems();
- return $result->getTotalCount() ? array_pop($items) : null;
+ return array_pop($items);
}
/**
@@ -276,6 +294,7 @@ private function getAttributeSetByName(string $attributeSetName): ?AttributeSetI
*
* @param string $attributeSetName
* @param int $skeletonAttributeSetId
+ * @return void
*/
private function createAttributeSetBySkeletonAndAssert(
string $attributeSetName,
@@ -308,6 +327,7 @@ private function createAttributeSetBySkeletonAndAssert(
*
* @param AttributeSetInterface $createdAttributeSet
* @param AttributeSetInterface $existAttributeSet
+ * @return void
*/
private function assertAttributeSetsAttributesAreEquals(
AttributeSetInterface $createdAttributeSet,
@@ -327,7 +347,19 @@ private function assertAttributeSetsAttributesAreEquals(
);
$this->assertEquals(count($expectedAttributeIds), count($actualAttributeIds));
foreach ($actualAttributeIds as $attributeId) {
- $this->assertTrue(in_array($attributeId, $expectedAttributeIds, true));
+ $this->assertContains($attributeId, $expectedAttributeIds);
}
}
+
+ /**
+ * Retrieve default catalog product attribute set ID.
+ *
+ * @return int
+ */
+ private function getCatalogProductDefaultAttributeSetId(): int
+ {
+ return (int)$this->eavConfig
+ ->getEntityType(ProductAttributeInterface::ENTITY_TYPE_CODE)
+ ->getDefaultAttributeSetId();
+ }
}
From a8ef3e1569317e17fb28068d52598e47eaf0877a Mon Sep 17 00:00:00 2001
From: Alex Taranovsky
Date: Wed, 16 Oct 2019 17:33:40 +0300
Subject: [PATCH 0427/1978] magento/graphql-ce#: Editorial. Fix
CustomerOrder.increment_id description
---
app/code/Magento/SalesGraphQl/etc/schema.graphqls | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/SalesGraphQl/etc/schema.graphqls b/app/code/Magento/SalesGraphQl/etc/schema.graphqls
index a7c30f582e752..a687ee59031ea 100644
--- a/app/code/Magento/SalesGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/SalesGraphQl/etc/schema.graphqls
@@ -7,7 +7,7 @@ type Query {
type CustomerOrder @doc(description: "Order mapping fields") {
id: Int
- increment_id: String @deprecated(reason: "Use the order_number instaed.")
+ increment_id: String @deprecated(reason: "Use the order_number instead.")
order_number: String! @doc(description: "The order number")
created_at: String
grand_total: Float
From 3811aea3332d9117c85f7ebe1425b654a677ee46 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 16 Oct 2019 09:50:31 -0500
Subject: [PATCH 0428/1978] MC-21808: MySQL performance query optimization
---
app/code/Magento/Search/etc/db_schema_whitelist.json | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Search/etc/db_schema_whitelist.json b/app/code/Magento/Search/etc/db_schema_whitelist.json
index 71adbc68887d0..16bbd0ce9fa3c 100644
--- a/app/code/Magento/Search/etc/db_schema_whitelist.json
+++ b/app/code/Magento/Search/etc/db_schema_whitelist.json
@@ -17,7 +17,8 @@
"SEARCH_QUERY_QUERY_TEXT_STORE_ID_POPULARITY": true,
"SEARCH_QUERY_STORE_ID": true,
"SEARCH_QUERY_IS_PROCESSED": true,
- "SEARCH_QUERY_SYNONYM_FOR": true
+ "SEARCH_QUERY_SYNONYM_FOR": true,
+ "SEARCH_QUERY_STORE_ID_POPULARITY": true
},
"constraint": {
"PRIMARY": true,
@@ -43,4 +44,4 @@
"SEARCH_SYNONYMS_WEBSITE_ID_STORE_WEBSITE_WEBSITE_ID": true
}
}
-}
\ No newline at end of file
+}
From 526b6ae4fdc8dfab378c41f8588cc35ddcb0d3c7 Mon Sep 17 00:00:00 2001
From: Andrii-Deineha
Date: Wed, 16 Oct 2019 17:51:34 +0300
Subject: [PATCH 0429/1978] MC-20441: Category rules should apply to grouped
product with invisible individual products
---
.../Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
index 215a1cba76ed9..469e647fab5ca 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/StorefrontProductCartActionGroup.xml
@@ -158,4 +158,4 @@
-
+
\ No newline at end of file
From 1e5defbe4315572c277fce11297bc2bf2165bc52 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 16 Oct 2019 10:24:13 -0500
Subject: [PATCH 0430/1978] magento/graphql-ce#914: [Customer] Improve
consistency of country field in customer address
---
.../CustomerGraphQl/etc/schema.graphqls | 4 +-
.../Customer/CreateCustomerAddressTest.php | 60 ++++---------
.../Customer/UpdateCustomerAddressTest.php | 89 +++++++++----------
3 files changed, 59 insertions(+), 94 deletions(-)
diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
index 9ce2d61aa458d..86ab39bbee25c 100644
--- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
@@ -28,7 +28,7 @@ input CustomerAddressInput {
city: String @doc(description: "The city or town")
region: CustomerAddressRegionInput @doc(description: "An object containing the region name, region code, and region ID")
postcode: String @doc(description: "The customer's ZIP or postal code")
- country_id: CountryCodeEnum @doc(description: "Deprecated, use country_code instead.")
+ country_id: CountryCodeEnum @doc(description: "Deprecated: use `country_code` instead.")
country_code: CountryCodeEnum @doc(description: "The customer's country")
default_shipping: Boolean @doc(description: "Indicates whether the address is the default shipping address")
default_billing: Boolean @doc(description: "Indicates whether the address is the default billing address")
@@ -103,7 +103,7 @@ type CustomerAddress @doc(description: "CustomerAddress contains detailed inform
customer_id: Int @doc(description: "The customer ID") @deprecated(reason: "customer_id is not needed as part of CustomerAddress, address ID (id) is unique identifier for the addresses.")
region: CustomerAddressRegion @doc(description: "An object containing the region name, region code, and region ID")
region_id: Int @deprecated(reason: "Region ID is excessive on storefront and region code should suffice for all scenarios")
- country_id: String @doc(description: "The customer's country") @deprecated(reason: "Use country_code instead.")
+ country_id: String @doc(description: "The customer's country") @deprecated(reason: "Use `country_code` instead.")
country_code: CountryCodeEnum @doc(description: "The customer's country")
street: [String] @doc(description: "An array of strings that define the street number and name")
company: String @doc(description: "The customer's company")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
index 9ccd3b0d46c7a..bbe111c41db98 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php
@@ -49,7 +49,7 @@ public function testCreateCustomerAddress()
'region_id' => 4,
'region_code' => 'AZ'
],
- 'country_id' => 'US',
+ 'country_code' => 'US',
'street' => ['Line 1 Street', 'Line 2'],
'company' => 'Company name',
'telephone' => '123456789',
@@ -75,7 +75,7 @@ public function testCreateCustomerAddress()
region_id: {$newAddress['region']['region_id']}
region_code: "{$newAddress['region']['region_code']}"
}
- country_id: {$newAddress['country_id']}
+ country_code: {$newAddress['country_code']}
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"]
company: "{$newAddress['company']}"
telephone: "{$newAddress['telephone']}"
@@ -98,7 +98,7 @@ public function testCreateCustomerAddress()
region_id
region_code
}
- country_id
+ country_code
street
company
telephone
@@ -134,10 +134,12 @@ public function testCreateCustomerAddress()
}
/**
+ * Test case for deprecated `country_id` field.
+ *
* @magentoApiDataFixture Magento/Customer/_files/customer_without_addresses.php
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testCreateCustomerAddressWithCountryCode()
+ public function testCreateCustomerAddressWithCountryId()
{
$newAddress = [
'region' => [
@@ -145,7 +147,7 @@ public function testCreateCustomerAddressWithCountryCode()
'region_id' => 4,
'region_code' => 'AZ'
],
- 'country_code' => 'US',
+ 'country_id' => 'US',
'street' => ['Line 1 Street', 'Line 2'],
'company' => 'Company name',
'telephone' => '123456789',
@@ -171,7 +173,7 @@ public function testCreateCustomerAddressWithCountryCode()
region_id: {$newAddress['region']['region_id']}
region_code: "{$newAddress['region']['region_code']}"
}
- country_code: {$newAddress['country_code']}
+ country_id: {$newAddress['country_id']}
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"]
company: "{$newAddress['company']}"
telephone: "{$newAddress['telephone']}"
@@ -187,28 +189,7 @@ public function testCreateCustomerAddressWithCountryCode()
default_shipping: true
default_billing: false
}) {
- id
- customer_id
- region {
- region
- region_id
- region_code
- }
- country_code
- street
- company
- telephone
- fax
- postcode
- city
- firstname
- lastname
- middlename
- prefix
- suffix
- vat_id
- default_shipping
- default_billing
+ country_id
}
}
MUTATION;
@@ -218,15 +199,7 @@ public function testCreateCustomerAddressWithCountryCode()
$response = $this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
$this->assertArrayHasKey('createCustomerAddress', $response);
- $this->assertArrayHasKey('customer_id', $response['createCustomerAddress']);
- $this->assertEquals(null, $response['createCustomerAddress']['customer_id']);
- $this->assertArrayHasKey('id', $response['createCustomerAddress']);
-
- $address = $this->addressRepository->getById($response['createCustomerAddress']['id']);
- $this->assertEquals($address->getId(), $response['createCustomerAddress']['id']);
-
- $this->assertCustomerAddressesFields($address, $response['createCustomerAddress'], 'country_code');
- $this->assertCustomerAddressesFields($address, $newAddress, 'country_code');
+ $this->assertEquals($newAddress['country_id'], $response['createCustomerAddress']['country_id']);
}
/**
@@ -249,7 +222,7 @@ public function testCreateCustomerAddressIfUserIsNotAuthorized()
region: {
region_id: 1
}
- country_id: US
+ country_code: US
postcode: "9999"
default_shipping: true
default_billing: false
@@ -278,7 +251,7 @@ public function testCreateCustomerAddressWithMissingAttribute()
region: {
region_id: 1
}
- country_id: US
+ country_code: US
street: ["Line 1 Street","Line 2"]
company: "Company name"
telephone: "123456789"
@@ -310,7 +283,7 @@ public function testCreateCustomerAddressWithRedundantStreetLine()
'region_id' => 4,
'region_code' => 'AZ'
],
- 'country_id' => 'US',
+ 'country_code' => 'US',
'street' => ['Line 1 Street', 'Line 2', 'Line 3'],
'company' => 'Company name',
'telephone' => '123456789',
@@ -336,7 +309,7 @@ public function testCreateCustomerAddressWithRedundantStreetLine()
region_id: {$newAddress['region']['region_id']}
region_code: "{$newAddress['region']['region_code']}"
}
- country_id: {$newAddress['country_id']}
+ country_code: {$newAddress['country_code']}
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}","{$newAddress['street'][2]}"]
company: "{$newAddress['company']}"
telephone: "{$newAddress['telephone']}"
@@ -413,12 +386,11 @@ public function invalidInputDataProvider()
*/
private function assertCustomerAddressesFields(
AddressInterface $address,
- array $actualResponse,
- string $countryFieldName = 'country_id'
+ array $actualResponse
): void {
/** @var $addresses */
$assertionMap = [
- ['response_field' => $countryFieldName, 'expected_value' => $address->getCountryId()],
+ ['response_field' => 'country_code', 'expected_value' => $address->getCountryId()],
['response_field' => 'street', 'expected_value' => $address->getStreet()],
['response_field' => 'company', 'expected_value' => $address->getCompany()],
['response_field' => 'telephone', 'expected_value' => $address->getTelephone()],
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
index d92c003c080ef..025a994ec4ae3 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
@@ -77,30 +77,53 @@ public function testUpdateCustomerAddress()
}
/**
+ * Test case for deprecated `country_id` field.
+ *
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Customer/_files/customer_address.php
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testUpdateCustomerAddressWithCountryCode()
+ public function testUpdateCustomerAddressWithCountryId()
{
$userName = 'customer@example.com';
$password = 'password';
$addressId = 1;
- $mutation = $this->getMutationWithCountryCode($addressId);
+ $updateAddress = $this->getAddressData();
+
+ $mutation = $mutation
+ = <<graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
$this->assertArrayHasKey('updateCustomerAddress', $response);
- $this->assertArrayHasKey('customer_id', $response['updateCustomerAddress']);
- $this->assertEquals(null, $response['updateCustomerAddress']['customer_id']);
- $this->assertArrayHasKey('id', $response['updateCustomerAddress']);
-
- $address = $this->addressRepository->getById($addressId);
- $this->assertEquals($address->getId(), $response['updateCustomerAddress']['id']);
- $this->assertCustomerAddressesFields($address, $response['updateCustomerAddress'], 'country_code');
-
- $updateAddress = $this->getAddressDataCanadaCountry();
- $this->assertCustomerAddressesFields($address, $updateAddress, 'country_code');
+ $this->assertEquals($updateAddress['country_code'], $response['updateCustomerAddress']['country_id']);
}
/**
@@ -162,12 +185,11 @@ public function testUpdateCustomerAddressWithMissingAttribute()
*/
private function assertCustomerAddressesFields(
AddressInterface $address,
- $actualResponse,
- string $countryFieldName = 'country_id'
+ $actualResponse
): void {
/** @var $addresses */
$assertionMap = [
- ['response_field' => $countryFieldName, 'expected_value' => $address->getCountryId()],
+ ['response_field' => 'country_code', 'expected_value' => $address->getCountryId()],
['response_field' => 'street', 'expected_value' => $address->getStreet()],
['response_field' => 'company', 'expected_value' => $address->getCompany()],
['response_field' => 'telephone', 'expected_value' => $address->getTelephone()],
@@ -218,7 +240,7 @@ public function testUpdateCustomerAddressWithMissingId()
region_id: {$updateAddress['region']['region_id']}
region_code: "{$updateAddress['region']['region_code']}"
}
- country_id: {$updateAddress['country_id']}
+ country_code: {$updateAddress['country_code']}
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"]
company: "{$updateAddress['company']}"
telephone: "{$updateAddress['telephone']}"
@@ -274,7 +296,7 @@ public function testUpdateCustomerAddressWithInvalidIdType()
region_id: {$updateAddress['region']['region_id']}
region_code: "{$updateAddress['region']['region_code']}"
}
- country_id: {$updateAddress['country_id']}
+ country_code: {$updateAddress['country_code']}
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"]
company: "{$updateAddress['company']}"
telephone: "{$updateAddress['telephone']}"
@@ -410,35 +432,6 @@ private function getCustomerAuthHeaders(string $email, string $password): array
* @return array
*/
private function getAddressData(): array
- {
- return [
- 'region' => [
- 'region' => 'Alaska',
- 'region_id' => 2,
- 'region_code' => 'AK'
- ],
- 'country_id' => 'US',
- 'street' => ['Line 1 Street', 'Line 2'],
- 'company' => 'Company Name',
- 'telephone' => '123456789',
- 'fax' => '123123123',
- 'postcode' => '7777',
- 'city' => 'City Name',
- 'firstname' => 'Adam',
- 'lastname' => 'Phillis',
- 'middlename' => 'A',
- 'prefix' => 'Mr.',
- 'suffix' => 'Jr.',
- 'vat_id' => '1',
- 'default_shipping' => true,
- 'default_billing' => true
- ];
- }
-
- /**
- * @return array
- */
- private function getAddressDataCanadaCountry(): array
{
return [
'region' => [
@@ -483,7 +476,7 @@ private function getMutation(int $addressId): string
region_id: {$updateAddress['region']['region_id']}
region_code: "{$updateAddress['region']['region_code']}"
}
- country_id: {$updateAddress['country_id']}
+ country_code: {$updateAddress['country_code']}
street: ["{$updateAddress['street'][0]}","{$updateAddress['street'][1]}"]
company: "{$updateAddress['company']}"
telephone: "{$updateAddress['telephone']}"
@@ -506,7 +499,7 @@ private function getMutation(int $addressId): string
region_id
region_code
}
- country_id
+ country_code
street
company
telephone
From bf95fdd9219c33331212a6a17ca54001e6b16353 Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Wed, 16 Oct 2019 10:42:27 -0500
Subject: [PATCH 0431/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
.../CheckProductsOrderActionGroup.xml | 3 +-
...CheckOrderOfProdsInWidgetOnCMSPageTest.xml | 120 +++++++++---------
2 files changed, 64 insertions(+), 59 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index 7fbe71cbee301..0ab997ebcbebc 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -13,11 +13,12 @@
Goes to the Storefront. Validates that the 2 provided Products appear in the correct order.
+
-
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
index 5dfe17f018ec2..985015ef163af 100644
--- a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
@@ -28,76 +28,79 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
@@ -109,18 +112,19 @@
-
-
+
+
-
+
+
From 21749ccc5c3de8d82e6902893f1180f9cda804a5 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 16 Oct 2019 10:44:54 -0500
Subject: [PATCH 0432/1978] magento/graphql-ce#914: [Customer] Improve
consistency of country field in customer address
---
.../Customer/UpdateCustomerAddressTest.php | 63 -------------------
1 file changed, 63 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
index 025a994ec4ae3..e214d770920d0 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
@@ -516,69 +516,6 @@ private function getMutation(int $addressId): string
default_billing
}
}
-MUTATION;
- return $mutation;
- }
-
- /**
- * @param int $addressId
- * @return string
- */
- private function getMutationWithCountryCode(int $addressId): string
- {
- $updateAddress = $this->getAddressDataCanadaCountry();
- $defaultShippingText = $updateAddress['default_shipping'] ? 'true' : 'false';
- $defaultBillingText = $updateAddress['default_billing'] ? 'true' : 'false';
-
- $mutation
- = <<
Date: Wed, 16 Oct 2019 10:52:32 -0500
Subject: [PATCH 0433/1978] MC-20648: Implement the changes - Removed parameter
enforcements and marked DiscountDataInterface with @api
---
.../Api/Data/DiscountDataInterface.php | 19 +++++++++++--------
.../Model/Rule/Action/Discount/Data.php | 16 ++++++++--------
2 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
index 01d58470081ae..70765821db252 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
@@ -7,6 +7,9 @@
namespace Magento\SalesRule\Api\Data;
+/**
+ * @api
+ */
interface DiscountDataInterface
{
/**
@@ -14,7 +17,7 @@ interface DiscountDataInterface
*
* @return float
*/
- public function getAmount(): float;
+ public function getAmount();
/**
* Set Amount
@@ -22,14 +25,14 @@ public function getAmount(): float;
* @param float $amount
* @return $this
*/
- public function setAmount(float $amount);
+ public function setAmount($amount);
/**
* Get Base Amount
*
* @return float
*/
- public function getBaseAmount(): float;
+ public function getBaseAmount();
/**
* Set Base Amount
@@ -37,14 +40,14 @@ public function getBaseAmount(): float;
* @param float $baseAmount
* @return $this
*/
- public function setBaseAmount(float $baseAmount);
+ public function setBaseAmount($baseAmount);
/**
* Get Original Amount
*
* @return float
*/
- public function getOriginalAmount(): float;
+ public function getOriginalAmount();
/**
* Set original Amount
@@ -52,14 +55,14 @@ public function getOriginalAmount(): float;
* @param float $originalAmount
* @return $this
*/
- public function setOriginalAmount(float $originalAmount);
+ public function setOriginalAmount($originalAmount);
/**
* Get Base Original Amount
*
* @return float
*/
- public function getBaseOriginalAmount(): float;
+ public function getBaseOriginalAmount();
/**
* Set base original Amount
@@ -67,5 +70,5 @@ public function getBaseOriginalAmount(): float;
* @param float $baseOriginalAmount
* @return $this
*/
- public function setBaseOriginalAmount(float $baseOriginalAmount);
+ public function setBaseOriginalAmount($baseOriginalAmount);
}
diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
index 9b5d0aa7506e7..c30c436751480 100644
--- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
+++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
@@ -50,7 +50,7 @@ public function __construct()
* @param float $amount
* @return $this
*/
- public function setAmount(float $amount)
+ public function setAmount($amount)
{
$this->amount = $amount;
return $this;
@@ -61,7 +61,7 @@ public function setAmount(float $amount)
*
* @return float
*/
- public function getAmount(): float
+ public function getAmount()
{
return $this->amount;
}
@@ -72,7 +72,7 @@ public function getAmount(): float
* @param float $baseAmount
* @return $this
*/
- public function setBaseAmount(float $baseAmount)
+ public function setBaseAmount($baseAmount)
{
$this->baseAmount = $baseAmount;
return $this;
@@ -83,7 +83,7 @@ public function setBaseAmount(float $baseAmount)
*
* @return float
*/
- public function getBaseAmount(): float
+ public function getBaseAmount()
{
return $this->baseAmount;
}
@@ -94,7 +94,7 @@ public function getBaseAmount(): float
* @param float $originalAmount
* @return $this
*/
- public function setOriginalAmount(float $originalAmount)
+ public function setOriginalAmount($originalAmount)
{
$this->originalAmount = $originalAmount;
return $this;
@@ -105,7 +105,7 @@ public function setOriginalAmount(float $originalAmount)
*
* @return float
*/
- public function getOriginalAmount(): float
+ public function getOriginalAmount()
{
return $this->originalAmount;
}
@@ -116,7 +116,7 @@ public function getOriginalAmount(): float
* @param float $baseOriginalAmount
* @return $this
*/
- public function setBaseOriginalAmount(float $baseOriginalAmount)
+ public function setBaseOriginalAmount($baseOriginalAmount)
{
$this->baseOriginalAmount = $baseOriginalAmount;
return $this;
@@ -127,7 +127,7 @@ public function setBaseOriginalAmount(float $baseOriginalAmount)
*
* @return float
*/
- public function getBaseOriginalAmount(): float
+ public function getBaseOriginalAmount()
{
return $this->baseOriginalAmount;
}
From 0861a3077135f40d9728dc1e6cfec3ab7387f3a3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 16 Oct 2019 11:13:11 -0500
Subject: [PATCH 0434/1978] MC-21756: Persistent Shopping Cart Issue
- Magento should process the order with the persistent information including tier pricing
---
.../Checkout/view/frontend/web/js/view/form/element/email.js | 4 ++++
app/code/Magento/Persistent/Model/QuoteManager.php | 1 -
.../Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php | 3 +--
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js b/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js
index c0de643d3a223..74b1e6ac55ea6 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js
@@ -185,6 +185,10 @@ define([
* @returns {Boolean} - initial visibility state.
*/
resolveInitialPasswordVisibility: function () {
+ if (checkoutData.getInputFieldEmailValue() !== '' && checkoutData.getCheckedEmailValue() === '') {
+ return true;
+ }
+
if (checkoutData.getInputFieldEmailValue() !== '') {
return checkoutData.getInputFieldEmailValue() === checkoutData.getCheckedEmailValue();
}
diff --git a/app/code/Magento/Persistent/Model/QuoteManager.php b/app/code/Magento/Persistent/Model/QuoteManager.php
index 8ae22e4c26c6f..c7e22a05eb3ba 100644
--- a/app/code/Magento/Persistent/Model/QuoteManager.php
+++ b/app/code/Magento/Persistent/Model/QuoteManager.php
@@ -121,7 +121,6 @@ public function convertCustomerCartToGuest()
->setCustomerEmail(null)
->setCustomerFirstname(null)
->setCustomerLastname(null)
- ->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID)
->setIsPersistent(false);
$quote->getAddressesCollection()->walk('setCustomerAddressId', ['customerAddressId' => null]);
$quote->getAddressesCollection()->walk('setCustomerId', ['customerId' => null]);
diff --git a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php
index e5de8e7d4aade..62c7339c9c38a 100644
--- a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php
+++ b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php
@@ -258,8 +258,7 @@ public function testConvertCustomerCartToGuest()
->method('setCustomerFirstname')->with(null)->willReturn($this->quoteMock);
$this->quoteMock->expects($this->once())
->method('setCustomerLastname')->with(null)->willReturn($this->quoteMock);
- $this->quoteMock->expects($this->once())->method('setCustomerGroupId')
- ->with(\Magento\Customer\Model\GroupManagement::NOT_LOGGED_IN_ID)
+ $this->quoteMock->expects($this->never())->method('setCustomerGroupId')
->willReturn($this->quoteMock);
$this->quoteMock->expects($this->once())
->method('setIsPersistent')->with(false)->willReturn($this->quoteMock);
From f5eff95803249d1284e784f26d433709d1adbb64 Mon Sep 17 00:00:00 2001
From: Mikalai Shostka
Date: Wed, 16 Oct 2019 19:20:06 +0300
Subject: [PATCH 0435/1978] MC-18822: Increase test coverage for Content
functional area
- Fix functional test
---
.../Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml
index e93fd62a74999..bb920e66b3d0b 100644
--- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml
+++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateStoreGroupTest.xml
@@ -21,6 +21,14 @@
+
+
+
+
+
+
+
+
From 1109bbd6a6fa2e0e2ef27997dbca83f0e0178f98 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Wed, 16 Oct 2019 20:10:52 +0300
Subject: [PATCH 0436/1978] Reverted changes not referred to an issue. Added
backward compatibility and reverted initial version of unit tests because of
backward compatibility (#24726)
---
.../Magento/Catalog/Model/Product/Option.php | 20 +++++++++++++++++--
.../Test/Unit/Model/Product/OptionTest.php | 11 +---------
app/code/Magento/Catalog/etc/di.xml | 1 +
3 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 3177171270b2c..38ef19590c41e 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -158,8 +158,24 @@ public function __construct(
$this->validatorPool = $validatorPool;
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
- $this->optionGroups = $optionGroups;
- $this->optionGroupsToTypes = $optionGroupsToTypes;
+ $this->optionGroups = $optionGroups ?: [
+ 'date' => 'Magento\Catalog\Model\Product\Option\Type\Date',
+ 'file' => 'Magento\Catalog\Model\Product\Option\Type\File',
+ 'select' => 'Magento\Catalog\Model\Product\Option\Type\Select',
+ 'text' => 'Magento\Catalog\Model\Product\Option\Type\Text',
+ ];
+ $this->optionGroupsToTypes = $optionGroupsToTypes ?: [
+ 'field' => 'text',
+ 'area' => 'text',
+ 'file' => 'file',
+ 'drop_down' => 'select',
+ 'radio' => 'select',
+ 'checkbox' => 'select',
+ 'multiple' => 'select',
+ 'date' => 'date',
+ 'date_time' => 'date',
+ 'time' => 'date',
+ ];
parent::__construct(
$context,
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
index e0c1f487a2420..1bd85c4053263 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/OptionTest.php
@@ -24,16 +24,7 @@ protected function setUp()
{
$this->productMock = $this->createMock(\Magento\Catalog\Model\Product::class);
$objectManager = new ObjectManager($this);
- $this->model = $objectManager->getObject(
- \Magento\Catalog\Model\Product\Option::class,
- [
- 'optionGroupsToTypes' => [
- 'field' => 'text',
- 'drop_down' => 'select',
- 'file' => 'file',
- ]
- ]
- );
+ $this->model = $objectManager->getObject(\Magento\Catalog\Model\Product\Option::class);
$this->model->setProduct($this->productMock);
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 0591006c23404..85fda0a2fc8f0 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -72,6 +72,7 @@
+
From 600c9a8d602ff00b3a883f04d109629fd7d51bf2 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Wed, 16 Oct 2019 20:14:45 +0300
Subject: [PATCH 0437/1978] Reverted @return phpdoc (#24726)
---
app/code/Magento/Catalog/Model/Product/Option.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 38ef19590c41e..99bef6090c8de 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -11,9 +11,9 @@
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option\Type\DefaultType;
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
use Magento\Catalog\Pricing\Price\BasePrice;
-use Magento\Framework\DataObject;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractExtensibleModel;
@@ -355,7 +355,7 @@ public function getGroupByType($type = null): string
* Group model factory
*
* @param string $type Option type
- * @return DataObject
+ * @return DefaultType
* @throws LocalizedException
*/
public function groupFactory($type)
From aff179a2403f8077ef4c79473d368b97bddffe73 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 16 Oct 2019 12:30:04 -0500
Subject: [PATCH 0438/1978] MC-21756: Persistent Shopping Cart Issue
- Fix static
---
.../Test/Unit/Model/QuoteManagerTest.php | 32 ++++++++++++-------
1 file changed, 20 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php
index 62c7339c9c38a..afabf18079fbc 100644
--- a/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php
+++ b/app/code/Magento/Persistent/Test/Unit/Model/QuoteManagerTest.php
@@ -55,7 +55,9 @@ protected function setUp()
{
$this->persistentSessionMock = $this->createMock(\Magento\Persistent\Helper\Session::class);
$this->sessionMock =
- $this->createPartialMock(\Magento\Persistent\Model\Session::class, [
+ $this->createPartialMock(
+ \Magento\Persistent\Model\Session::class,
+ [
'setLoadInactive',
'setCustomerData',
'clearQuote',
@@ -63,7 +65,8 @@ protected function setUp()
'getQuote',
'removePersistentCookie',
'__wakeup',
- ]);
+ ]
+ );
$this->persistentDataMock = $this->createMock(\Magento\Persistent\Helper\Data::class);
$this->checkoutSessionMock = $this->createMock(\Magento\Checkout\Model\Session::class);
@@ -71,7 +74,9 @@ protected function setUp()
$this->createMock(\Magento\Eav\Model\Entity\Collection\AbstractCollection::class);
$this->quoteRepositoryMock = $this->createMock(\Magento\Quote\Api\CartRepositoryInterface::class);
- $this->quoteMock = $this->createPartialMock(\Magento\Quote\Model\Quote::class, [
+ $this->quoteMock = $this->createPartialMock(
+ \Magento\Quote\Model\Quote::class,
+ [
'getId',
'getIsPersistent',
'getPaymentsCollection',
@@ -90,7 +95,8 @@ protected function setUp()
'getIsActive',
'getCustomerId',
'__wakeup'
- ]);
+ ]
+ );
$this->model = new QuoteManager(
$this->persistentSessionMock,
@@ -264,14 +270,16 @@ public function testConvertCustomerCartToGuest()
->method('setIsPersistent')->with(false)->willReturn($this->quoteMock);
$this->quoteMock->expects($this->exactly(3))
->method('getAddressesCollection')->willReturn($this->abstractCollectionMock);
- $this->abstractCollectionMock->expects($this->exactly(3))->method('walk')->with($this->logicalOr(
- $this->equalTo('setCustomerAddressId'),
- $this->equalTo($addressArgs),
- $this->equalTo('setCustomerId'),
- $this->equalTo($customerIdArgs),
- $this->equalTo('setEmail'),
- $this->equalTo($emailArgs)
- ));
+ $this->abstractCollectionMock->expects($this->exactly(3))->method('walk')->with(
+ $this->logicalOr(
+ $this->equalTo('setCustomerAddressId'),
+ $this->equalTo($addressArgs),
+ $this->equalTo('setCustomerId'),
+ $this->equalTo($customerIdArgs),
+ $this->equalTo('setEmail'),
+ $this->equalTo($emailArgs)
+ )
+ );
$this->quoteMock->expects($this->once())->method('collectTotals')->willReturn($this->quoteMock);
$this->persistentSessionMock->expects($this->once())
->method('getSession')->willReturn($this->sessionMock);
From de29ee24df829e8dc6e3bc431bd753e693517d04 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Wed, 16 Oct 2019 21:31:47 +0300
Subject: [PATCH 0439/1978] Fixed static tests by replacing string names with
::class notation (#24726)
---
app/code/Magento/Catalog/Model/Product/Option.php | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 99bef6090c8de..dfddeb4ca2104 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -11,7 +11,11 @@
use Magento\Catalog\Api\Data\ProductCustomOptionValuesInterfaceFactory;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\Product\Option\Type\Date;
use Magento\Catalog\Model\Product\Option\Type\DefaultType;
+use Magento\Catalog\Model\Product\Option\Type\File;
+use Magento\Catalog\Model\Product\Option\Type\Select;
+use Magento\Catalog\Model\Product\Option\Type\Text;
use Magento\Catalog\Model\ResourceModel\Product\Option\Value\Collection;
use Magento\Catalog\Pricing\Price\BasePrice;
use Magento\Framework\EntityManager\MetadataPool;
@@ -159,10 +163,10 @@ public function __construct(
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
$this->optionGroups = $optionGroups ?: [
- 'date' => 'Magento\Catalog\Model\Product\Option\Type\Date',
- 'file' => 'Magento\Catalog\Model\Product\Option\Type\File',
- 'select' => 'Magento\Catalog\Model\Product\Option\Type\Select',
- 'text' => 'Magento\Catalog\Model\Product\Option\Type\Text',
+ 'date' => Date::class,
+ 'file' => File::class,
+ 'select' => Select::class,
+ 'text' => Text::class,
];
$this->optionGroupsToTypes = $optionGroupsToTypes ?: [
'field' => 'text',
From 20b0f26d66a7dad6cd87f64c88f033fce2254347 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Wed, 16 Oct 2019 22:20:15 +0300
Subject: [PATCH 0440/1978] Replaced string values with constants (#24726)
---
.../Magento/Catalog/Model/Product/Option.php | 28 +++++++++----------
app/code/Magento/Catalog/etc/di.xml | 20 ++++++-------
2 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index dfddeb4ca2104..7bb0ff37f3c62 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -163,22 +163,22 @@ public function __construct(
$this->customOptionValuesFactory = $customOptionValuesFactory ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(ProductCustomOptionValuesInterfaceFactory::class);
$this->optionGroups = $optionGroups ?: [
- 'date' => Date::class,
- 'file' => File::class,
- 'select' => Select::class,
- 'text' => Text::class,
+ self::OPTION_GROUP_DATE => Date::class,
+ self::OPTION_GROUP_FILE => File::class,
+ self::OPTION_GROUP_SELECT => Select::class,
+ self::OPTION_GROUP_TEXT => Text::class,
];
$this->optionGroupsToTypes = $optionGroupsToTypes ?: [
- 'field' => 'text',
- 'area' => 'text',
- 'file' => 'file',
- 'drop_down' => 'select',
- 'radio' => 'select',
- 'checkbox' => 'select',
- 'multiple' => 'select',
- 'date' => 'date',
- 'date_time' => 'date',
- 'time' => 'date',
+ self::OPTION_TYPE_FIELD => self::OPTION_GROUP_TEXT,
+ self::OPTION_TYPE_AREA => self::OPTION_GROUP_TEXT,
+ self::OPTION_TYPE_FILE => self::OPTION_GROUP_FILE,
+ self::OPTION_TYPE_DROP_DOWN => self::OPTION_GROUP_SELECT,
+ self::OPTION_TYPE_RADIO => self::OPTION_GROUP_SELECT,
+ self::OPTION_TYPE_CHECKBOX => self::OPTION_GROUP_SELECT,
+ self::OPTION_TYPE_MULTIPLE => self::OPTION_GROUP_SELECT,
+ self::OPTION_TYPE_DATE => self::OPTION_GROUP_DATE,
+ self::OPTION_TYPE_DATE_TIME => self::OPTION_GROUP_DATE,
+ self::OPTION_TYPE_TIME => self::OPTION_GROUP_DATE,
];
parent::__construct(
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 85fda0a2fc8f0..6519a08f91c2a 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -420,16 +420,16 @@
- Magento\Catalog\Model\Product\Option\Type\Text
- - text
- - text
- - file
- - select
- - select
- - select
- - select
- - date
- - date
- - date
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_TEXT
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_TEXT
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_FILE
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_SELECT
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE
+ - Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_DATE
From be5a95e3f6ea1c8187033589cdb0ef0ed36f362e Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Wed, 16 Oct 2019 15:04:46 -0500
Subject: [PATCH 0441/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
.../Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index 0ab997ebcbebc..6b60c9e93e8b6 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -13,7 +13,7 @@
Goes to the Storefront. Validates that the 2 provided Products appear in the correct order.
-
+
From 91cbae9788b4f24829828f3a1d506297d736fc3d Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Wed, 16 Oct 2019 15:47:44 -0500
Subject: [PATCH 0442/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
.../CheckOrderOfProdsInWidgetOnCMSPageTest.xml | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
index 985015ef163af..ce093144e6a2a 100644
--- a/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Test/CheckOrderOfProdsInWidgetOnCMSPageTest.xml
@@ -31,20 +31,23 @@
-
+
-
+
-
+
+
@@ -99,7 +102,10 @@
-
+
+
From 2ed496aa1c3f141b2ea495916d2b637ffb607f89 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Thu, 17 Oct 2019 09:35:30 +0300
Subject: [PATCH 0443/1978] MC-20689: Admin: Create new attribute set
---
.../Controller/Adminhtml/Product/Set/SaveTest.php | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
index aa6e85f1d6a51..3a49c72291c71 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/SaveTest.php
@@ -310,7 +310,7 @@ private function createAttributeSetBySkeletonAndAssert(
);
$this->dispatch('backend/catalog/product_set/save/');
$this->assertSessionMessages(
- $this->contains('You saved the attribute set.'),
+ $this->equalTo([(string)__('You saved the attribute set.')]),
MessageInterface::TYPE_SUCCESS
);
$createdAttributeSet = $this->getAttributeSetByName($attributeSetName);
@@ -339,16 +339,15 @@ private function assertAttributeSetsAttributesAreEquals(
$existAttributeSet->getAttributeSetId()
)
);
+ sort($expectedAttributeIds);
$actualAttributeIds = array_keys(
$this->attributeManagement->getAttributes(
ProductAttributeInterface::ENTITY_TYPE_CODE,
$createdAttributeSet->getAttributeSetId()
)
);
- $this->assertEquals(count($expectedAttributeIds), count($actualAttributeIds));
- foreach ($actualAttributeIds as $attributeId) {
- $this->assertContains($attributeId, $expectedAttributeIds);
- }
+ sort($actualAttributeIds);
+ $this->assertSame($expectedAttributeIds, $actualAttributeIds);
}
/**
From 9be8a92a48c86c48b5f5c780bb4472baebcbc6d1 Mon Sep 17 00:00:00 2001
From: Andrii Meysar
Date: Thu, 17 Oct 2019 10:41:43 +0300
Subject: [PATCH 0444/1978] MC-11032: Flaky MFTF Test - MAGETWO-68209: Quotes
displaying in multi-siting environment
---
.../Test/Mftf/Data/CustomerConfigData.xml | 10 ++++++++++
.../Test/Mftf/Data/CurrencyConfigData.xml | 16 ++++++++++++++++
2 files changed, 26 insertions(+)
create mode 100644 app/code/Magento/Directory/Test/Mftf/Data/CurrencyConfigData.xml
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/CustomerConfigData.xml b/app/code/Magento/Customer/Test/Mftf/Data/CustomerConfigData.xml
index ab4307082595d..3eb14604220e9 100644
--- a/app/code/Magento/Customer/Test/Mftf/Data/CustomerConfigData.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Data/CustomerConfigData.xml
@@ -51,4 +51,14 @@
5
5
+
+ customer/account_share/scope
+ Per Website
+ 1
+
+
+ customer/account_share/scope
+ Global
+ 0
+
diff --git a/app/code/Magento/Directory/Test/Mftf/Data/CurrencyConfigData.xml b/app/code/Magento/Directory/Test/Mftf/Data/CurrencyConfigData.xml
new file mode 100644
index 0000000000000..fb21ee42fe2fc
--- /dev/null
+++ b/app/code/Magento/Directory/Test/Mftf/Data/CurrencyConfigData.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+ currency/options/base
+ Russian Ruble
+ RUB
+
+
From db894cad31bd174dc3495783b13ea0918d985bff Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Thu, 17 Oct 2019 11:24:11 +0300
Subject: [PATCH 0445/1978] MC-20425: [Integration Test] Check behavior when
attribute set was changed to a new set with deleted attribute from the
previous set
---
.../Catalog/Controller/Product/ViewTest.php | 135 +++++-------------
...default_without_country_of_manufacture.php | 1 -
...uct_simple_with_country_of_manufacture.php | 1 -
3 files changed, 35 insertions(+), 102 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
index dd55d88bfae71..e2e803ff20bef 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
@@ -7,20 +7,21 @@
namespace Magento\Catalog\Controller\Product;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Eav\Model\AttributeSetSearchResults;
use Magento\Eav\Model\Entity\Attribute\Set;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Api\SortOrderBuilder;
-use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Data\Collection;
use Magento\Catalog\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Model\Entity\Type;
-use Magento\Framework\Filesystem;
-use Magento\Framework\Filesystem\Directory\WriteInterface;
-use Magento\Framework\Filesystem\File\WriteInterface as FileWriteInterface;
-use Magento\Framework\Filesystem\Driver\File;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
+use Magento\Catalog\Api\Data\ProductAttributeInterface;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
+use Magento\Framework\Logger\Monolog as MagentoMonologLogger;
/**
* Integration test for product view front action.
@@ -45,6 +46,11 @@ class ViewTest extends \Magento\TestFramework\TestCase\AbstractController
*/
private $attributeSetRepository;
+ /**
+ * @var ProductAttributeRepositoryInterface $attributeSetRepository
+ */
+ private $attributeRepository;
+
/**
* @var Type $productEntityType
*/
@@ -59,6 +65,7 @@ protected function setUp()
$this->productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
$this->attributeSetRepository = $this->_objectManager->create(AttributeSetRepositoryInterface::class);
+ $this->attributeRepository = $this->_objectManager->create(ProductAttributeRepositoryInterface::class);
$this->productEntityType = $this->_objectManager->create(Type::class)
->loadByCode(Product::ENTITY);
}
@@ -94,32 +101,42 @@ public function testViewActionWithCanonicalTag(): void
*/
public function testViewActionCustomAttributeSetWithoutCountryOfManufacture(): void
{
+ /** @var MockObject|LoggerInterface $logger */
+ $logger = $this->setupLoggerMock();
+
$product = $this->getProductBySku('simple_with_com');
$attributeSetCustom = $this->getProductAttributeSetByName('custom_attribute_set_wout_com');
-
$product->setAttributeSetId($attributeSetCustom->getAttributeSetId());
$this->productRepository->save($product);
+ /** @var ProductAttributeInterface $attributeCountryOfManufacture */
+ $attributeCountryOfManufacture = $this->attributeRepository->get('country_of_manufacture');
+ $logger->expects($this->never())
+ ->method('warning')
+ ->with(
+ "Attempt to load value of nonexistent EAV attribute",
+ [
+ 'attribute_id' => $attributeCountryOfManufacture->getAttributeId(),
+ 'entity_type' => ProductInterface::class,
+ ]
+ );
+
$this->dispatch(sprintf('catalog/product/view/id/%s/', $product->getId()));
- $message = 'Attempt to load value of nonexistent EAV attribute';
- $this->assertFalse(
- $this->checkSystemLogForMessage($message),
- sprintf("Warning message found in %s: %s", $this->systemLogFileName, $message)
- );
}
/**
- * Check system log file for error message.
+ * Setup logger mock to check there are no warning messages logged.
*
- * @param string $message
- * @return bool
+ * @return MockObject
*/
- private function checkSystemLogForMessage(string $message): bool
+ private function setupLoggerMock() : MockObject
{
- $content = $this->getSystemLogContent();
- $pos = strpos($content, $message);
+ $logger = $this->getMockBuilder(LoggerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->_objectManager->addSharedInstance($logger, MagentoMonologLogger::class);
- return $pos !== false;
+ return $logger;
}
/**
@@ -165,86 +182,4 @@ private function getProductAttributeSetByName(string $attributeSetName): ?Set
return null;
}
-
- /**
- * Get system log content.
- *
- * @return string
- */
- private function getSystemLogContent(): string
- {
- $logDir = $this->getLogDirectoryWrite();
- $logFile = $logDir->openFile($this->systemLogFileName, 'rb');
- $content = $this->tail($logFile, 10);
-
- return $content;
- }
-
- /**
- * Get file tail.
- *
- * @param FileWriteInterface $file
- * @param int $lines
- * @param int $buffer
- * @return false|string
- */
- private function tail(FileWriteInterface $file, int $lines = 10, int $buffer = 4096)
- {
- // Jump to last character
- $file->seek(-1, SEEK_END);
-
- // Read it and adjust line number if necessary
- // (Otherwise the result would be wrong if file doesn't end with a blank line)
- if ($file->read(1) != "\n") {
- $lines--;
- }
-
- // Start reading
- $output = '';
- $chunk = '';
-
- // While we would like more
- while ($file->tell() > 0 && $lines >= 0) {
- // Figure out how far back we should jump
- $seek = min($file->tell(), $buffer);
-
- // Do the jump (backwards, relative to where we are)
- $file->seek(-$seek, SEEK_CUR);
-
- // Read a chunk and prepend it to our output
- $output = ($chunk = $file->read($seek)) . $output;
-
- // Jump back to where we started reading
- $file->seek(-mb_strlen($chunk, '8bit'), SEEK_CUR);
-
- // Decrease our line counter
- $lines -= substr_count($chunk, "\n");
- }
-
- // While we have too many lines
- // (Because of buffer size we might have read too many)
- while ($lines++ < 0) {
- // Find first newline and remove all text before that
- $output = substr($output, strpos($output, "\n") + 1);
- }
-
- // Close file and return
- $file->close();
-
- return $output;
- }
-
- /**
- * Get current LOG directory write.
- *
- * @return WriteInterface
- */
- private function getLogDirectoryWrite()
- {
- /** @var Filesystem $filesystem */
- $filesystem = $this->_objectManager->create(Filesystem::class);
- $logDirectory = $filesystem->getDirectoryWrite(DirectoryList::LOG);
-
- return $logDirectory;
- }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
index eb25d261f531b..3db6516577d88 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_without_country_of_manufacture.php
@@ -7,7 +7,6 @@
use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
-use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Attribute\Group;
use Magento\Eav\Model\Entity\Attribute\Set;
use Magento\Eav\Model\Entity\Type;
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
index fba611e7c67f5..83d7c5a837e93 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_country_of_manufacture.php
@@ -8,7 +8,6 @@
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\TestFramework\Helper\Bootstrap;
-use Magento\Catalog\Model\Product;
Bootstrap::getInstance()->reinitialize();
From b5787de0a17e13c749cf4bc5a3df771f8435829d Mon Sep 17 00:00:00 2001
From: Namrata Vora
Date: Thu, 17 Oct 2019 14:04:45 +0530
Subject: [PATCH 0446/1978] Added translate for strings and added missing node
in existing translate attribute on xml.
---
app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml | 2 +-
app/code/Magento/Analytics/etc/adminhtml/system.xml | 2 +-
.../view/adminhtml/ui_component/bulk_listing.xml | 2 +-
.../Magento_Backend/layout/layout_test_grid_handle.xml | 4 ++--
4 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml b/app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml
index 63c78e07c7bfc..905dd3e7d1819 100644
--- a/app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml
+++ b/app/code/Magento/AdvancedSearch/etc/adminhtml/system.xml
@@ -60,7 +60,7 @@
1
-
+
Show Results Count for Each Suggestion
Magento\Config\Model\Config\Source\Yesno
When you enable this option your site may slow down.
diff --git a/app/code/Magento/Analytics/etc/adminhtml/system.xml b/app/code/Magento/Analytics/etc/adminhtml/system.xml
index c7da840b7e665..79dd914cb3c1d 100644
--- a/app/code/Magento/Analytics/etc/adminhtml/system.xml
+++ b/app/code/Magento/Analytics/etc/adminhtml/system.xml
@@ -29,7 +29,7 @@
Magento\Analytics\Block\Adminhtml\System\Config\CollectionTimeLabel
Magento\Analytics\Model\Config\Backend\CollectionTime
-
+
Industry Data
Industry
In order to personalize your Advanced Reporting experience, please select your industry.
diff --git a/app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml b/app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml
index 512b08d6a8de2..87dc0525eb1c0 100644
--- a/app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml
+++ b/app/code/Magento/AsynchronousOperations/view/adminhtml/ui_component/bulk_listing.xml
@@ -92,7 +92,7 @@
id
- Action
+ Action
diff --git a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml
index 621e9f13409f1..70bf2af6a5fcf 100644
--- a/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml
+++ b/dev/tests/integration/testsuite/Magento/Backend/Block/_files/design/adminhtml/Magento/test_default/Magento_Backend/layout/layout_test_grid_handle.xml
@@ -55,12 +55,12 @@
-
- Option One
- */*/option1
- - Test
+ - Test
-
- Option Two
- */*/option2
- - Are you sure?
+ - Are you sure?
-
- Option Three
From c248a181ea5cab666465591d3c943aff755334c6 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Thu, 17 Oct 2019 13:01:26 +0300
Subject: [PATCH 0447/1978] MC-21862: [Integration] Automate MC-11658
---
.../testsuite/Magento/Customer/Controller/AccountTest.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index 23b94c133d0ba..d381873c58bfa 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -789,8 +789,9 @@ public function testRegisterCustomerWithEmailConfirmation(): void
$this->_objectManager->removeSharedInstance(Request::class);
$this->_request = null;
- $this->getRequest()->setParam('id', $customer->getId());
- $this->getRequest()->setParam('key', $confirmation);
+ $this->getRequest()
+ ->setParam('id', $customer->getId())
+ ->setParam('key', $confirmation);
$this->dispatch('customer/account/confirm');
/** @var StoreManager $store */
From c82a26039ccf9acc8af4782c9d24e97d3b65f483 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Thu, 17 Oct 2019 13:02:53 +0300
Subject: [PATCH 0448/1978] MC-20425: [Integration Test] Check behavior when
attribute set was changed to a new set with deleted attribute from the
previous set
---
.../Magento/Catalog/Controller/Product/ViewTest.php | 5 -----
1 file changed, 5 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
index e2e803ff20bef..e18a4d1bc8f4c 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/ViewTest.php
@@ -31,11 +31,6 @@
*/
class ViewTest extends \Magento\TestFramework\TestCase\AbstractController
{
- /**
- * @var string
- */
- private $systemLogFileName = 'system.log';
-
/**
* @var ProductRepositoryInterface $productRepository
*/
From d8b86dee15078a3155f8f755a40cf9af21f17122 Mon Sep 17 00:00:00 2001
From: Roman Zhupanyn
Date: Thu, 17 Oct 2019 13:07:58 +0300
Subject: [PATCH 0449/1978] MC-20675: Admin: Add/edit/delete related, up-sells,
cross-sells products
---
.../Adminhtml/Product/Save/LinksTest.php | 154 +++++++++++
.../Catalog/Model/Product/LinksTest.php | 255 ++++++++++++++++++
2 files changed, 409 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
new file mode 100644
index 0000000000000..6f5b4f1a6c454
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
@@ -0,0 +1,154 @@
+productRepository = $this->_objectManager->create(ProductRepositoryInterface::class);
+ }
+
+ /**
+ * Test add simple related, up-sells, cross-sells product
+ *
+ * @dataProvider addRelatedUpSellCrossSellProductsProvider
+ * @magentoDataFixture Magento/Catalog/_files/multiple_products.php
+ * @magentoDbIsolation enabled
+ * @param array $postData
+ * @return void
+ */
+ public function testAddRelatedUpSellCrossSellProducts(array $postData)
+ {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue($postData);
+ $this->dispatch('backend/catalog/product/save');
+
+ /** @var Product $product */
+ $product = $this->productRepository->get('simple');
+
+ $expectedLinks = $this->getExpectedLinks($postData['links']);
+ $actualLinks = $this->getActualLinks($product);
+ $this->assertEquals(
+ $expectedLinks,
+ $actualLinks,
+ "Expected linked products do not match actual linked products!"
+ );
+ }
+
+ /**
+ * Provide test data for testAddRelatedUpSellCrossSellProducts().
+ *
+ * @return array
+ */
+ public function addRelatedUpSellCrossSellProductsProvider(): array
+ {
+ return [
+ [
+ 'post_data' => [
+ 'product' => [
+ 'attribute_set_id' => '4',
+ 'status' => '1',
+ 'name' => 'Simple Product',
+ 'sku' => 'simple',
+ 'url_key' => 'simple-product',
+ ],
+ 'links' => [
+ 'upsell' => [
+ ['id' => '10'],
+ ],
+ 'crosssell' => [
+ ['id' => '11'],
+ ],
+ 'related' => [
+ ['id' => '12'],
+ ],
+ ]
+ ]
+ ]
+ ];
+ }
+
+ /**
+ * Set an array of expected related, up-sells, cross-sells product identifiers
+ *
+ * @param array $links
+ * @return array
+ */
+ private function getExpectedLinks(array $links): array
+ {
+ $expectedLinks = [];
+ foreach ($this->linkTypes as $linkType) {
+ $expectedLinks[$linkType] = [];
+ foreach ($links[$linkType] as $productData) {
+ $expectedLinks[$linkType][$productData['id']] = $productData;
+ }
+ }
+
+ return $expectedLinks;
+ }
+
+ /**
+ * Get an array of received related, up-sells, cross-sells products
+ *
+ * @param Product $product
+ * @return array
+ */
+ private function getActualLinks(Product $product): array
+ {
+ $actualLinks = [];
+ foreach ($this->linkTypes as $linkType) {
+ $products = [];
+ $actualLinks[$linkType] = [];
+ switch ($linkType) {
+ case 'upsell':
+ $products = $product->getUpSellProducts();
+ break;
+ case 'crosssell':
+ $products = $product->getCrossSellProducts();
+ break;
+ case 'related':
+ $products = $product->getRelatedProducts();
+ break;
+ }
+ /** @var Product $product */
+ foreach ($products as $productItem) {
+ $actualLinks[$linkType][$productItem->getId()] = [
+ 'id' => $productItem->getId(),
+ ];
+ }
+ }
+
+ return $actualLinks;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
new file mode 100644
index 0000000000000..2e489a6db17e3
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
@@ -0,0 +1,255 @@
+ '2',
+ 'sku' => 'custom-design-simple-product',
+ 'position' => 1,
+ ],
+ [
+ 'id' => '10',
+ 'sku' => 'simple1',
+ 'position' => 2,
+ ],
+ ];
+
+ /** @var array */
+ private $existingProducts = [
+ [
+ 'id' => '10',
+ 'sku' => 'simple1',
+ 'position' => 1,
+ ],
+ [
+ 'id' => '11',
+ 'sku' => 'simple2',
+ 'position' => 2,
+ ],
+ [
+ 'id' => '12',
+ 'sku' => 'simple3',
+ 'position' => 3,
+ ],
+ ];
+
+ /** @var ProductRepository $productRepository */
+ private $productRepository;
+
+ /** @var ObjectManager */
+ private $objectManager;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->objectManager = Bootstrap::getObjectManager();
+ $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ }
+
+ /**
+ * Test edit and remove simple related, up-sells, cross-sells products in an existing product
+ *
+ * @dataProvider editDeleteRelatedUpSellCrossSellProductsProvider
+ * @magentoDataFixture Magento/Catalog/_files/products.php
+ * @magentoDataFixture Magento/Catalog/_files/multiple_products.php
+ * @magentoDbIsolation enabled
+ * @param array $data
+ * @return void
+ */
+ public function testEditRemoveRelatedUpSellCrossSellProducts(array $data): void
+ {
+ /** @var Product $product */
+ $product = $this->productRepository->get('simple');
+ $this->setCustomProductLinks($product, $this->getProductData($data['defaultLinks']));
+ $this->productRepository->save($product);
+
+ $productData = $this->getProductData($data['productLinks']);
+ $this->setCustomProductLinks($product, $productData);
+ $product->save();
+
+ $product = $this->productRepository->get('simple');
+ $expectedLinks = isset($data['expectedProductLinks'])
+ ? $this->getProductData($data['expectedProductLinks'])
+ : $productData;
+ $actualLinks = $this->getActualLinks($product);
+
+ $this->assertEquals(
+ $expectedLinks,
+ $actualLinks,
+ "Expected linked products do not match actual linked products!"
+ );
+ }
+
+ /**
+ * Provide test data for testEditDeleteRelatedUpSellCrossSellProducts().
+ *
+ * @return array
+ */
+ public function editDeleteRelatedUpSellCrossSellProductsProvider(): array
+ {
+ return [
+ 'update' => [
+ 'data' => [
+ 'defaultLinks' => $this->defaultDataFixture,
+ 'productLinks' => $this->existingProducts,
+ ],
+ ],
+ 'delete' => [
+ 'data' => [
+ 'defaultLinks' => $this->defaultDataFixture,
+ 'productLinks' => []
+ ],
+ ],
+ 'same' => [
+ 'data' => [
+ 'defaultLinks' => $this->existingProducts,
+ 'productLinks' => $this->existingProducts,
+ ],
+ ],
+ 'change_position' => [
+ 'data' => [
+ 'defaultLinks' => $this->existingProducts,
+ 'productLinks' => array_replace_recursive(
+ $this->existingProducts,
+ [
+ ['position' => 4],
+ ['position' => 5],
+ ['position' => 6],
+ ]
+ ),
+ ],
+ ],
+ 'without_position' => [
+ 'data' => [
+ 'defaultLinks' => $this->defaultDataFixture,
+ 'productLinks' => array_replace_recursive(
+ $this->existingProducts,
+ [
+ ['position' => null],
+ ['position' => null],
+ ['position' => null],
+ ]
+ ),
+ 'expectedProductLinks' => array_replace_recursive(
+ $this->existingProducts,
+ [
+ ['position' => 1],
+ ['position' => 2],
+ ['position' => 3],
+ ]
+ ),
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Create an array of products by link type that will be linked
+ *
+ * @param array $productFixture
+ * @return array
+ */
+ private function getProductData(array $productFixture): array
+ {
+ $productData = [];
+ foreach ($this->linkTypes as $linkType) {
+ $productData[$linkType] = [];
+ foreach ($productFixture as $data) {
+ $productData[$linkType][$data['id']] = $data;
+ }
+ }
+ return $productData;
+ }
+
+ /**
+ * Link related, up-sells, cross-sells products received from the array
+ *
+ * @param Product $product
+ * @param array $productData
+ */
+ private function setCustomProductLinks(Product $product, array $productData): void
+ {
+ $productLinks = [];
+ foreach ($productData as $linkType => $links) {
+ foreach ($links as $data) {
+ /** @var Link $productLink */
+ $productLink = $this->objectManager->create(ProductLinkInterface::class);
+ $productLink->setSku('simple');
+ $productLink->setLinkedProductSku($data['sku']);
+ if (isset($data['position'])) {
+ $productLink->setPosition($data['position']);
+ }
+ $productLink->setLinkType($linkType);
+ $productLinks[] = $productLink;
+ }
+ }
+ $product->setProductLinks($productLinks);
+ }
+
+ /**
+ * Get an array of received related, up-sells, cross-sells products
+ *
+ * @param Product $product
+ * @return array
+ */
+ private function getActualLinks(Product $product): array
+ {
+ $actualLinks = [];
+ foreach ($this->linkTypes as $linkType) {
+ $products = [];
+ $actualLinks[$linkType] = [];
+ switch ($linkType) {
+ case 'upsell':
+ $products = $product->getUpSellProducts();
+ break;
+ case 'crosssell':
+ $products = $product->getCrossSellProducts();
+ break;
+ case 'related':
+ $products = $product->getRelatedProducts();
+ break;
+ }
+ /** @var Product $product */
+ foreach ($products as $productItem) {
+ $actualLinks[$linkType][$productItem->getId()] = [
+ 'id' => $productItem->getId(),
+ 'sku' => $productItem->getSku(),
+ 'position' => $productItem->getPosition(),
+ ];
+ }
+ }
+
+ return $actualLinks;
+ }
+}
From 47c3fed2e5ce27afa0744173936c83c4c53ab8f3 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Thu, 17 Oct 2019 15:56:14 +0300
Subject: [PATCH 0450/1978] MC-20420: [Integration Test] Customer can't reset
his password if email address is changed
---
.../Customer/Controller/AccountTest.php | 137 ++++++++++++++++++
1 file changed, 137 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
index 7116953d682b3..7edfc9925459d 100644
--- a/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
+++ b/dev/tests/integration/testsuite/Magento/Customer/Controller/AccountTest.php
@@ -9,6 +9,7 @@
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\Account\Redirect;
+use Magento\Customer\Model\CustomerRegistry;
use Magento\Customer\Model\Session;
use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
@@ -25,6 +26,7 @@
use Magento\TestFramework\Request;
use Magento\TestFramework\Response;
use Magento\Theme\Controller\Result\MessagePlugin;
+use PHPUnit\Framework\Constraint\StringContains;
use Zend\Stdlib\Parameters;
/**
@@ -796,6 +798,141 @@ public function testConfirmationEmailWithSpecialCharacters(): void
);
}
+ /**
+ * Check that Customer which change email can't log in with old email.
+ *
+ * @magentoDataFixture Magento/Customer/_files/customer.php
+ * @magentoConfigFixture current_store customer/captcha/enable 0
+ *
+ * @return void
+ */
+ public function testResetPasswordWhenEmailChanged(): void
+ {
+ $email = 'customer@example.com';
+ $newEmail = 'new_customer@example.com';
+
+ /* Reset password and check mail with token */
+ $this->getRequest()->setPostValue(['email' => $email]);
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+
+ $this->dispatch('customer/account/forgotPasswordPost');
+ $this->assertRedirect($this->stringContains('customer/account/'));
+ $this->assertSessionMessages(
+ $this->equalTo(
+ [
+ "If there is an account associated with {$email} you will receive an email with a link "
+ . "to reset your password."
+ ]
+ ),
+ MessageInterface::TYPE_SUCCESS
+ );
+
+ /** @var CustomerRegistry $customerRegistry */
+ $customerRegistry = $this->_objectManager->get(CustomerRegistry::class);
+ $customerData = $customerRegistry->retrieveByEmail($email);
+ $token = $customerData->getRpToken();
+ $this->assertForgotPasswordEmailContent($token);
+
+ /* Set new email */
+ /** @var CustomerRepositoryInterface $customerRepository */
+ $customerRepository = $this->_objectManager->create(CustomerRepositoryInterface::class);
+ /** @var \Magento\Customer\Api\Data\CustomerInterface $customer */
+ $customer = $customerRepository->getById($customerData->getId());
+ $customer->setEmail($newEmail);
+ $customerRepository->save($customer);
+
+ /* Goes through the link in a mail */
+ $this->resetRequest();
+ $this->getRequest()
+ ->setParam('token', $token)
+ ->setParam('id', $customerData->getId());
+
+ $this->dispatch('customer/account/createPassword');
+
+ $this->assertRedirect($this->stringContains('customer/account/forgotpassword'));
+ $this->assertSessionMessages(
+ $this->equalTo(['Your password reset link has expired.']),
+ MessageInterface::TYPE_ERROR
+ );
+ /* Trying to log in with old email */
+ $this->resetRequest();
+ $this->clearCookieMessagesList();
+ $customerRegistry->removeByEmail($email);
+
+ $this->dispatchLoginPostAction($email, 'password');
+ $this->assertSessionMessages(
+ $this->equalTo(
+ [
+ 'The account sign-in was incorrect or your account is disabled temporarily. '
+ . 'Please wait and try again later.'
+ ]
+ ),
+ MessageInterface::TYPE_ERROR
+ );
+ $this->assertRedirect($this->stringContains('customer/account/login'));
+ /** @var Session $session */
+ $session = $this->_objectManager->get(Session::class);
+ $this->assertFalse($session->isLoggedIn());
+
+ /* Trying to log in with correct(new) email */
+ $this->resetRequest();
+ $this->dispatchLoginPostAction($newEmail, 'password');
+ $this->assertRedirect($this->stringContains('customer/account/'));
+ $this->assertTrue($session->isLoggedIn());
+ $session->logout();
+ }
+
+ /**
+ * Set needed parameters and dispatch Customer loginPost action.
+ *
+ * @param string $email
+ * @param string $password
+ * @return void
+ */
+ private function dispatchLoginPostAction(string $email, string $password): void
+ {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue(
+ [
+ 'login' => [
+ 'username' => $email,
+ 'password' => $password,
+ ],
+ ]
+ );
+ $this->dispatch('customer/account/loginPost');
+ }
+
+ /**
+ * Check that 'Forgot password' email contains correct data.
+ *
+ * @param string $token
+ * @return void
+ */
+ private function assertForgotPasswordEmailContent(string $token): void
+ {
+ $message = $this->transportBuilderMock->getSentMessage();
+ $pattern = "//";
+ $rawMessage = $message->getBody()->getParts()[0]->getRawContent();
+ $messageConstraint = $this->logicalAnd(
+ new StringContains('There was recently a request to change the password for your account.'),
+ $this->matchesRegularExpression($pattern)
+ );
+ $this->assertThat($rawMessage, $messageConstraint);
+ }
+
+ /**
+ * Clear request object.
+ *
+ * @return void
+ */
+ private function resetRequest(): void
+ {
+ $this->_objectManager->removeSharedInstance(Http::class);
+ $this->_objectManager->removeSharedInstance(Request::class);
+ $this->_request = null;
+ }
+
/**
* Data provider for testLoginPostRedirect.
*
From 4d7b951f2fcb836e3ca08c508137a182f0cd846c Mon Sep 17 00:00:00 2001
From: Roman Zhupanyn
Date: Thu, 17 Oct 2019 17:33:52 +0300
Subject: [PATCH 0451/1978] MC-20675: Admin: Add/edit/delete related, up-sells,
cross-sells products
---
.../Catalog/Controller/Adminhtml/Product/Save/LinksTest.php | 2 +-
.../testsuite/Magento/Catalog/Model/Product/LinksTest.php | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
index 6f5b4f1a6c454..840b05dfe2b98 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
@@ -5,7 +5,7 @@
*/
declare(strict_types=1);
-namespace Magento\Catalog\Controller\Adminhtml;
+namespace Magento\Catalog\Controller\Adminhtml\Product\Save;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
index 2e489a6db17e3..45387e6d0f5d8 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
@@ -83,6 +83,7 @@ protected function setUp()
* @dataProvider editDeleteRelatedUpSellCrossSellProductsProvider
* @magentoDataFixture Magento/Catalog/_files/products.php
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
+ * @magentoAppIsolation enabled
* @magentoDbIsolation enabled
* @param array $data
* @return void
From a18b0e194ba8520d1898ebb0827d0bee5a188290 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 17 Oct 2019 10:26:19 -0500
Subject: [PATCH 0452/1978] magento graphql-ce#970 Cannot return several
errors for one GraphQL request
---
.../Exception/GraphQlInputException.php | 31 +++++++++++++++++--
.../Framework/GraphQl/Query/ErrorHandler.php | 25 +++++++++------
2 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php b/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php
index 429b7c04b7475..11aad3d6f7f96 100644
--- a/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php
+++ b/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php
@@ -7,13 +7,15 @@
namespace Magento\Framework\GraphQl\Exception;
-use Magento\Framework\Exception\InputException;
+use Magento\Framework\Exception\AggregateExceptionInterface;
+use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Phrase;
+use GraphQL\Error\ClientAware;
/**
* Exception for GraphQL to be thrown when user supplies invalid input
*/
-class GraphQlInputException extends InputException implements \GraphQL\Error\ClientAware
+class GraphQlInputException extends LocalizedException implements AggregateExceptionInterface, ClientAware
{
const EXCEPTION_CATEGORY = 'graphql-input';
@@ -22,6 +24,13 @@ class GraphQlInputException extends InputException implements \GraphQL\Error\Cli
*/
private $isSafe;
+ /**
+ * The array of errors that have been added via the addError() method
+ *
+ * @var \Magento\Framework\Exception\LocalizedException[]
+ */
+ private $errors = [];
+
/**
* Initialize object
*
@@ -51,4 +60,22 @@ public function getCategory() : string
{
return self::EXCEPTION_CATEGORY;
}
+
+ /**
+ * @param LocalizedException $exception
+ * @return $this
+ */
+ public function addError(LocalizedException $exception): self
+ {
+ $this->errors[] = $exception;
+ return $this;
+ }
+
+ /**
+ * @return LocalizedException[]
+ */
+ public function getErrors(): array
+ {
+ return $this->errors;
+ }
}
diff --git a/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php b/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php
index 2661034116f9d..b3d78790892f1 100644
--- a/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php
+++ b/lib/internal/Magento/Framework/GraphQl/Query/ErrorHandler.php
@@ -7,7 +7,7 @@
namespace Magento\Framework\GraphQl\Query;
-use GraphQL\Error\ClientAware;
+use Magento\Framework\Exception\AggregateExceptionInterface;
use Psr\Log\LoggerInterface;
/**
@@ -36,13 +36,20 @@ public function __construct(
*/
public function handle(array $errors, callable $formatter): array
{
- return array_map(
- function (ClientAware $error) use ($formatter) {
- $this->logger->error($error);
-
- return $formatter($error);
- },
- $errors
- );
+ $formattedErrors = [];
+ foreach ($errors as $error) {
+ $this->logger->error($error);
+ $previousError = $error->getPrevious();
+ if ($previousError instanceof AggregateExceptionInterface && !empty($previousError->getErrors())) {
+ $aggregatedErrors = $previousError->getErrors();
+ foreach ($aggregatedErrors as $aggregatedError) {
+ $this->logger->error($aggregatedError);
+ $formattedErrors[] = $formatter($aggregatedError);
+ }
+ } else {
+ $formattedErrors[] = $formatter($error);
+ }
+ }
+ return $formattedErrors;
}
}
From badea3978a104bf54266540cd5e427e3dd5000cc Mon Sep 17 00:00:00 2001
From: Buba Suma
Date: Wed, 16 Oct 2019 10:44:27 -0500
Subject: [PATCH 0453/1978] MC-21737: MySql slow queries on url_rewrite
- Add composite index (entity_id,entity_type) to url_rewrite table
---
app/code/Magento/UrlRewrite/etc/db_schema.xml | 3 +++
app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json | 5 +++--
2 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/UrlRewrite/etc/db_schema.xml b/app/code/Magento/UrlRewrite/etc/db_schema.xml
index 06d4949e63d9a..93e84d8e02a0f 100644
--- a/app/code/Magento/UrlRewrite/etc/db_schema.xml
+++ b/app/code/Magento/UrlRewrite/etc/db_schema.xml
@@ -37,5 +37,8 @@
+
+
+
diff --git a/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json b/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json
index bdaed647587a6..658673959a734 100644
--- a/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json
+++ b/app/code/Magento/UrlRewrite/etc/db_schema_whitelist.json
@@ -14,11 +14,12 @@
},
"index": {
"URL_REWRITE_TARGET_PATH": true,
- "URL_REWRITE_STORE_ID_ENTITY_ID": true
+ "URL_REWRITE_STORE_ID_ENTITY_ID": true,
+ "URL_REWRITE_ENTITY_ID": true
},
"constraint": {
"PRIMARY": true,
"URL_REWRITE_REQUEST_PATH_STORE_ID": true
}
}
-}
\ No newline at end of file
+}
From 39042ac2e2afa306730134d35bde9a4c33e12340 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 17 Oct 2019 11:00:51 -0500
Subject: [PATCH 0454/1978] magento/graphql-ce#970 Cannot return several
errors for one GraphQL request
---
.../Framework/GraphQl/Exception/GraphQlInputException.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php b/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php
index 11aad3d6f7f96..28b91c753c7e7 100644
--- a/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php
+++ b/lib/internal/Magento/Framework/GraphQl/Exception/GraphQlInputException.php
@@ -62,6 +62,8 @@ public function getCategory() : string
}
/**
+ * Add child error if used as aggregate exception
+ *
* @param LocalizedException $exception
* @return $this
*/
@@ -72,6 +74,8 @@ public function addError(LocalizedException $exception): self
}
/**
+ * Get child errors if used as aggregate exception
+ *
* @return LocalizedException[]
*/
public function getErrors(): array
From a5cd690f126bdf6cd71a12d54fdf96a72f055a84 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 17 Oct 2019 12:44:57 -0500
Subject: [PATCH 0455/1978] MC-21897: Fatal error catalogpermissions_product
indexer does not exist during cron reindex
---
lib/internal/Magento/Framework/Mview/View.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/Mview/View.php b/lib/internal/Magento/Framework/Mview/View.php
index e6f2d9fe03996..a7d16758c823d 100644
--- a/lib/internal/Magento/Framework/Mview/View.php
+++ b/lib/internal/Magento/Framework/Mview/View.php
@@ -240,7 +240,7 @@ public function unsubscribe()
*/
public function update()
{
- if ($this->getState()->getStatus() !== View\StateInterface::STATUS_IDLE) {
+ if (!$this->isIdle() || !$this->isEnabled()) {
return;
}
From ec1c8585d99d28a171801b1723ab1cf09f455be5 Mon Sep 17 00:00:00 2001
From: Roman Lytvynenko
Date: Thu, 17 Oct 2019 13:01:31 -0500
Subject: [PATCH 0456/1978] MC-21876: "Same as Billing Address" checkbox is
checked automatically when re-ordering an order with different
billing/shipping via Admin Panel.
---
app/code/Magento/Quote/Model/Quote/Address.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php
index 3ecbc69b80785..68bfcdffadc7c 100644
--- a/app/code/Magento/Quote/Model/Quote/Address.php
+++ b/app/code/Magento/Quote/Model/Quote/Address.php
@@ -425,9 +425,11 @@ protected function _populateBeforeSaveData()
*/
protected function _isSameAsBilling()
{
+ $quoteSameAsBilling = $this->getQuote()->getShippingAddress()->getSameAsBilling();
+
return $this->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING &&
- ($this->_isNotRegisteredCustomer() ||
- $this->_isDefaultShippingNullOrSameAsBillingAddress());
+ ($this->_isNotRegisteredCustomer() || $this->_isDefaultShippingNullOrSameAsBillingAddress()) &&
+ ($quoteSameAsBilling || $quoteSameAsBilling === 0 || $quoteSameAsBilling === null);
}
/**
From 09b1502b7316275abced9eb58fafe25b42412e5d Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 17 Oct 2019 13:14:17 -0500
Subject: [PATCH 0457/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 24 +++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 19628db1ef9c7..f0bb92d1fc742 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -290,11 +290,31 @@ protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
- $activeRules = $this->getActiveRules();
+ /** @var Rule[] $activeRules */
+ $activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
- /** @var Rule $rule */
+ $ruleWebsiteIds = $rule->getWebsiteIds();
+ if (!$rule->getIsActive() || empty($ruleWebsiteIds)) {
+ continue;
+ }
+
$rule->setProductsFilter($ids);
+ $productIds = $rule->getMatchingProductIds();
+ if (!is_array($ruleWebsiteIds)) {
+ $ruleWebsiteIds = explode(',', $ruleWebsiteIds);
+ }
+ foreach ($productIds as $productId => $validationByWebsite) {
+ $productWebsiteIds = array_keys(array_filter($validationByWebsite));
+ $websiteIds = array_intersect($productWebsiteIds, $ruleWebsiteIds);
+ $this->assignProductToRule($rule, $productId, $websiteIds);
+ }
+ }
+
+ $this->cleanProductPriceIndex($ids);
+ foreach ($ids as $productId) {
+ $this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
+
$this->reindexRuleGroupWebsite->execute();
}
From f6638860a53d92bcc3bbd7cebac50781bcffd6c2 Mon Sep 17 00:00:00 2001
From: Roman Lytvynenko
Date: Thu, 17 Oct 2019 13:46:03 -0500
Subject: [PATCH 0458/1978] MC-21876: "Same as Billing Address" checkbox is
checked automatically when re-ordering an order with different
billing/shipping via Admin Panel.
---
.../Magento/Quote/Model/Quote/Address.php | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php
index 68bfcdffadc7c..3bb83b941fc80 100644
--- a/app/code/Magento/Quote/Model/Quote/Address.php
+++ b/app/code/Magento/Quote/Model/Quote/Address.php
@@ -473,7 +473,7 @@ protected function _isDefaultShippingNullOrSameAsBillingAddress()
/**
* Declare address quote model object
*
- * @param \Magento\Quote\Model\Quote $quote
+ * @param \Magento\Quote\Model\Quote $quote
* @return $this
*/
public function setQuote(\Magento\Quote\Model\Quote $quote)
@@ -693,7 +693,7 @@ public function getItemQty($itemId = 0)
*/
public function hasItems()
{
- return sizeof($this->getAllItems()) > 0;
+ return count($this->getAllItems()) > 0;
}
/**
@@ -1227,8 +1227,8 @@ public function setBaseShippingAmount($value, $alreadyExclTax = false)
/**
* Set total amount value
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function setTotalAmount($code, $amount)
@@ -1245,8 +1245,8 @@ public function setTotalAmount($code, $amount)
/**
* Set total amount value in base store currency
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function setBaseTotalAmount($code, $amount)
@@ -1263,8 +1263,8 @@ public function setBaseTotalAmount($code, $amount)
/**
* Add amount total amount value
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function addTotalAmount($code, $amount)
@@ -1278,8 +1278,8 @@ public function addTotalAmount($code, $amount)
/**
* Add amount total amount value in base store currency
*
- * @param string $code
- * @param float $amount
+ * @param string $code
+ * @param float $amount
* @return $this
*/
public function addBaseTotalAmount($code, $amount)
From 65378b98541bf5792500ac03cf9f4c5fe132fa03 Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Thu, 17 Oct 2019 22:40:02 +0300
Subject: [PATCH 0459/1978] refactoring
---
.../AdminCreatesNewIntegrationActionGroup.xml | 2 --
...AdminSubmitNewIntegrationFormActionGroup.xml | 17 +++++++++++++++++
.../Mftf/Section/AdminIntegrationsSection.xml | 12 ++++++++----
.../Test/AdminDeleteIntegrationEntityTest.xml | 2 ++
4 files changed, 27 insertions(+), 6 deletions(-)
create mode 100644 app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
index 533bbb6760573..89e29d7d751a0 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
@@ -17,7 +17,5 @@
-
-
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml
new file mode 100644
index 0000000000000..23ddc2969a55e
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
index 4e43cd3babdf6..4af25b9be9714 100644
--- a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
+++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
@@ -9,18 +9,22 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
index bc226a70375f0..6f46bbf99d218 100644
--- a/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
+++ b/app/code/Magento/Integration/Test/Mftf/Test/AdminDeleteIntegrationEntityTest.xml
@@ -32,6 +32,8 @@
+
+
From 90ca5f0803c827d7484d9c239f10ff3de1b09030 Mon Sep 17 00:00:00 2001
From: zhartaunik
Date: Thu, 17 Oct 2019 22:47:31 +0300
Subject: [PATCH 0460/1978] Applied more relevant name for property
optionGroupsToTypes (#24726)
---
app/code/Magento/Catalog/Model/Product/Option.php | 10 +++++-----
app/code/Magento/Catalog/etc/di.xml | 2 +-
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 7bb0ff37f3c62..03131013bc298 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -111,7 +111,7 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
/**
* @var string[]
*/
- private $optionGroupsToTypes;
+ private $optionTypesToGroups;
/**
* @var MetadataPool
@@ -137,7 +137,7 @@ class Option extends AbstractExtensibleModel implements ProductCustomOptionInter
* @param array $data
* @param ProductCustomOptionValuesInterfaceFactory|null $customOptionValuesFactory
* @param array $optionGroups
- * @param array $optionGroupsToTypes
+ * @param array $optionTypesToGroups
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -154,7 +154,7 @@ public function __construct(
array $data = [],
ProductCustomOptionValuesInterfaceFactory $customOptionValuesFactory = null,
array $optionGroups = [],
- array $optionGroupsToTypes = []
+ array $optionTypesToGroups = []
) {
$this->productOptionValue = $productOptionValue;
$this->optionTypeFactory = $optionFactory;
@@ -168,7 +168,7 @@ public function __construct(
self::OPTION_GROUP_SELECT => Select::class,
self::OPTION_GROUP_TEXT => Text::class,
];
- $this->optionGroupsToTypes = $optionGroupsToTypes ?: [
+ $this->optionTypesToGroups = $optionTypesToGroups ?: [
self::OPTION_TYPE_FIELD => self::OPTION_GROUP_TEXT,
self::OPTION_TYPE_AREA => self::OPTION_GROUP_TEXT,
self::OPTION_TYPE_FILE => self::OPTION_GROUP_FILE,
@@ -352,7 +352,7 @@ public function getGroupByType($type = null): string
$type = $this->getType();
}
- return $this->optionGroupsToTypes[$type] ?? '';
+ return $this->optionTypesToGroups[$type] ?? '';
}
/**
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 6519a08f91c2a..74761e2b761b4 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -419,7 +419,7 @@
- Magento\Catalog\Model\Product\Option\Type\Select
- Magento\Catalog\Model\Product\Option\Type\Text
-
+
- Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_TEXT
- Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_TEXT
- Magento\Catalog\Api\Data\ProductCustomOptionInterface::OPTION_GROUP_FILE
From 216540f3f9577ad0d57785790c5160505e823f1a Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Thu, 17 Oct 2019 21:58:39 +0300
Subject: [PATCH 0461/1978] Replace multiple string concatenation by joining
array of strings
---
.../App/ObjectManager/ConfigLoader/Compiled.php | 2 +-
.../Framework/View/Element/AbstractBlock.php | 14 ++++++++++++--
lib/internal/Magento/Framework/View/Layout.php | 14 ++++++++------
3 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
index 01e5031461f85..1dec1666d526a 100644
--- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
+++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
@@ -42,6 +42,6 @@ public function load($area)
public static function getFilePath($area)
{
$diPath = DirectoryList::getDefaultConfig()[DirectoryList::GENERATED_METADATA][DirectoryList::PATH];
- return BP . '/' . $diPath . '/' . $area . '.php';
+ return join('', [BP, '/', $diPath, '/', $area, '.php']);
}
}
diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php
index f8e8d2fee264a..1788fba3386f4 100644
--- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php
+++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php
@@ -517,9 +517,14 @@ public function getChildHtml($alias = '', $useCache = true)
$out = $layout->renderElement($childName, $useCache);
}
} else {
+ $outParts = [];
foreach ($layout->getChildNames($name) as $child) {
- $out .= $layout->renderElement($child, $useCache);
+ $elementHtml = $layout->renderElement($child, $useCache);
+ if (!empty($elementHtml)) {
+ $outParts[] = $elementHtml;
+ }
}
+ $out = join('', $outParts);
}
return $out;
@@ -548,9 +553,14 @@ public function getChildChildHtml($alias, $childChildAlias = '', $useCache = tru
$childChildName = $layout->getChildName($childName, $childChildAlias);
$out = $layout->renderElement($childChildName, $useCache);
} else {
+ $outParts = [];
foreach ($layout->getChildNames($childName) as $childChild) {
- $out .= $layout->renderElement($childChild, $useCache);
+ $elementHtml = $layout->renderElement($childChild, $useCache);
+ if (!empty($elementHtml)) {
+ $outParts[] = $elementHtml;
+ }
}
+ $out = join('', $outParts);
}
return $out;
}
diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php
index a622006f32a1e..994a19b03695d 100644
--- a/lib/internal/Magento/Framework/View/Layout.php
+++ b/lib/internal/Magento/Framework/View/Layout.php
@@ -586,13 +586,16 @@ protected function _renderUiComponent($name)
*/
protected function _renderContainer($name, $useCache = true)
{
- $html = '';
+ $htmlParts = [];
$children = $this->getChildNames($name);
foreach ($children as $child) {
- $html .= $this->renderElement($child, $useCache);
+ $childHtml = $this->renderElement($child, $useCache);
+ if (!empty($childHtml)) {
+ $htmlParts[] = $childHtml;
+ }
}
- if ($html == '' || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
- return $html;
+ if (empty($htmlParts) || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
+ return join('', $htmlParts);
}
$htmlId = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_ID);
@@ -606,8 +609,7 @@ protected function _renderContainer($name, $useCache = true)
}
$htmlTag = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG);
-
- $html = sprintf('<%1$s%2$s%3$s>%4$s%1$s>', $htmlTag, $htmlId, $htmlClass, $html);
+ $html = sprintf('<%1$s%2$s%3$s>%4$s%1$s>', $htmlTag, $htmlId, $htmlClass, join('', $htmlParts));
return $html;
}
From e917b007ed8a233007c1a19d22776315eb7870d4 Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Thu, 17 Oct 2019 21:59:32 +0300
Subject: [PATCH 0462/1978] Replace two calls to str_replace() by single
strtr()
I've tested: str_replace() is slower than strtr() in this case
---
lib/internal/Magento/Framework/Phrase/Renderer/Translate.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/internal/Magento/Framework/Phrase/Renderer/Translate.php b/lib/internal/Magento/Framework/Phrase/Renderer/Translate.php
index c9329caf49370..e2c8a737c344b 100644
--- a/lib/internal/Magento/Framework/Phrase/Renderer/Translate.php
+++ b/lib/internal/Magento/Framework/Phrase/Renderer/Translate.php
@@ -50,8 +50,7 @@ public function render(array $source, array $arguments)
{
$text = end($source);
/* If phrase contains escaped quotes then use translation for phrase with non-escaped quote */
- $text = str_replace('\"', '"', $text);
- $text = str_replace("\\'", "'", $text);
+ $text = strtr($text, ['\"' => '"', "\\'" => "'"]);
try {
$data = $this->translator->getData();
From aa068f94560b90f40aa5392d426c53f76aa7a895 Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Thu, 17 Oct 2019 22:00:34 +0300
Subject: [PATCH 0463/1978] Replace in_array() by isset()
---
.../Model/ResourceModel/Eav/Attribute.php | 25 ++++++++++---------
.../Framework/DB/Select/SelectRenderer.php | 8 +++++-
lib/internal/Magento/Framework/Module/Dir.php | 16 ++++++------
3 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
index 355561c5e384d..97f126e388730 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Eav/Attribute.php
@@ -38,6 +38,18 @@ class Attribute extends \Magento\Eav\Model\Entity\Attribute implements
const KEY_IS_GLOBAL = 'is_global';
+ private const ALLOWED_INPUT_TYPES = [
+ 'boolean' => true,
+ 'date' => true,
+ 'datetime' => true,
+ 'multiselect' => true,
+ 'price' => true,
+ 'select' => true,
+ 'text' => true,
+ 'textarea' => true,
+ 'weight' => true,
+ ];
+
/**
* @var LockValidatorInterface
*/
@@ -403,18 +415,7 @@ public function getSourceModel()
*/
public function isAllowedForRuleCondition()
{
- $allowedInputTypes = [
- 'boolean',
- 'date',
- 'datetime',
- 'multiselect',
- 'price',
- 'select',
- 'text',
- 'textarea',
- 'weight',
- ];
- return $this->getIsVisible() && in_array($this->getFrontendInput(), $allowedInputTypes);
+ return $this->getIsVisible() && isset(self::ALLOWED_INPUT_TYPES[$this->getFrontendInput()]);
}
/**
diff --git a/lib/internal/Magento/Framework/DB/Select/SelectRenderer.php b/lib/internal/Magento/Framework/DB/Select/SelectRenderer.php
index 11dbaeb82317a..ce53c07789bde 100644
--- a/lib/internal/Magento/Framework/DB/Select/SelectRenderer.php
+++ b/lib/internal/Magento/Framework/DB/Select/SelectRenderer.php
@@ -12,6 +12,11 @@
*/
class SelectRenderer implements RendererInterface
{
+ private const MANDATORY_SELECT_PARTS = [
+ Select::COLUMNS => true,
+ Select::FROM => true
+ ];
+
/**
* @var RendererInterface[]
*/
@@ -67,7 +72,8 @@ public function render(Select $select, $sql = '')
{
$sql = Select::SQL_SELECT;
foreach ($this->renderers as $renderer) {
- if (in_array($renderer['part'], [Select::COLUMNS, Select::FROM]) || $select->getPart($renderer['part'])) {
+ $part = $renderer['part'];
+ if (isset(self::MANDATORY_SELECT_PARTS[$part]) || $select->getPart($part)) {
$sql = $renderer['renderer']->render($select, $sql);
}
}
diff --git a/lib/internal/Magento/Framework/Module/Dir.php b/lib/internal/Magento/Framework/Module/Dir.php
index e6b60453b9577..4baf5f2f10ec6 100644
--- a/lib/internal/Magento/Framework/Module/Dir.php
+++ b/lib/internal/Magento/Framework/Module/Dir.php
@@ -22,6 +22,14 @@ class Dir
const MODULE_SETUP_DIR = 'Setup';
/**#@-*/
+ private const ALLOWED_DIR_TYPES = [
+ self::MODULE_ETC_DIR => true,
+ self::MODULE_I18N_DIR => true,
+ self::MODULE_VIEW_DIR => true,
+ self::MODULE_CONTROLLER_DIR => true,
+ self::MODULE_SETUP_DIR => true
+ ];
+
/**#@-*/
private $componentRegistrar;
@@ -52,13 +60,7 @@ public function getDir($moduleName, $type = '')
}
if ($type) {
- if (!in_array($type, [
- self::MODULE_ETC_DIR,
- self::MODULE_I18N_DIR,
- self::MODULE_VIEW_DIR,
- self::MODULE_CONTROLLER_DIR,
- self::MODULE_SETUP_DIR
- ])) {
+ if (!isset(self::ALLOWED_DIR_TYPES[$type])) {
throw new \InvalidArgumentException("Directory type '{$type}' is not recognized.");
}
$path .= '/' . $type;
From c0ce7eac9a5f9f233b12b4e354b09664dbaf3d26 Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Thu, 17 Oct 2019 22:01:17 +0300
Subject: [PATCH 0464/1978] Micro optimization: Replace != with !==
---
.../Attribute/Backend/GroupPrice/AbstractGroupPrice.php | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
index e26717e47274c..d301cc7b63c52 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
@@ -97,17 +97,16 @@ protected function _getWebsiteCurrencyRates()
);
foreach ($this->_storeManager->getWebsites() as $website) {
/* @var $website \Magento\Store\Model\Website */
- if ($website->getBaseCurrencyCode() != $baseCurrency) {
+ $websiteBaseCurrency = $website->getBaseCurrencyCode();
+ if ($websiteBaseCurrency !== $baseCurrency) {
$rate = $this->_currencyFactory->create()->load(
$baseCurrency
- )->getRate(
- $website->getBaseCurrencyCode()
- );
+ )->getRate($websiteBaseCurrency);
if (!$rate) {
$rate = 1;
}
$this->_rates[$website->getId()] = [
- 'code' => $website->getBaseCurrencyCode(),
+ 'code' => $websiteBaseCurrency,
'rate' => $rate,
];
} else {
From 87dff07de468c103dfe546d8c43769673e4f548d Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 17 Oct 2019 15:37:45 -0500
Subject: [PATCH 0465/1978] MC-19607: Mass delete deletes all products
---
.../Ui/DataProvider/Product/AddFulltextFilterToCollection.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php b/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php
index f312178e0bf0b..af5020a2f8c94 100644
--- a/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php
+++ b/app/code/Magento/CatalogSearch/Ui/DataProvider/Product/AddFulltextFilterToCollection.php
@@ -40,6 +40,10 @@ public function addFilter(Collection $collection, $field, $condition = null)
if (isset($condition['fulltext']) && (string)$condition['fulltext'] !== '') {
$this->searchCollection->addBackendSearchFilter($condition['fulltext']);
$productIds = $this->searchCollection->load()->getAllIds();
+ if (empty($productIds)) {
+ //add dummy id to prevent returning full unfiltered collection
+ $productIds = -1;
+ }
$collection->addIdFilter($productIds);
}
}
From ce056bbb7a95fd9b7888f6e47120449fb28212c1 Mon Sep 17 00:00:00 2001
From: Roman Lytvynenko
Date: Thu, 17 Oct 2019 15:55:45 -0500
Subject: [PATCH 0466/1978] MC-21876: "Same as Billing Address" checkbox is
checked automatically when re-ordering an order with different
billing/shipping via Admin Panel.
---
app/code/Magento/Quote/Model/Quote/Address.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php
index 3bb83b941fc80..0e2bf1ce48ec7 100644
--- a/app/code/Magento/Quote/Model/Quote/Address.php
+++ b/app/code/Magento/Quote/Model/Quote/Address.php
@@ -425,7 +425,7 @@ protected function _populateBeforeSaveData()
*/
protected function _isSameAsBilling()
{
- $quoteSameAsBilling = $this->getQuote()->getShippingAddress()->getSameAsBilling();
+ $quoteSameAsBilling = $this->getSameAsBilling();
return $this->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING &&
($this->_isNotRegisteredCustomer() || $this->_isDefaultShippingNullOrSameAsBillingAddress()) &&
From 0d4cd77d783827620196aaedf76ff8dba468bc3b Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 17 Oct 2019 16:13:58 -0500
Subject: [PATCH 0467/1978] MC-21897: Fatal error catalogpermissions_product
indexer does not exist during cron reindex
---
lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php
index 3f806b319ef48..c44c46acea45b 100644
--- a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php
+++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php
@@ -273,6 +273,9 @@ public function testUpdate()
$this->stateMock->expects($this->once())
->method('setVersionId')
->will($this->returnSelf());
+ $this->stateMock->expects($this->atLeastOnce())
+ ->method('getMode')
+ ->willReturn(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED);
$this->stateMock->expects($this->exactly(2))
->method('getStatus')
->will($this->returnValue(\Magento\Framework\Mview\View\StateInterface::STATUS_IDLE));
@@ -335,6 +338,9 @@ public function testUpdateWithException()
->will($this->returnValue($lastVersionId));
$this->stateMock->expects($this->never())
->method('setVersionId');
+ $this->stateMock->expects($this->atLeastOnce())
+ ->method('getMode')
+ ->willReturn(\Magento\Framework\Mview\View\StateInterface::MODE_ENABLED);
$this->stateMock->expects($this->exactly(2))
->method('getStatus')
->will($this->returnValue(\Magento\Framework\Mview\View\StateInterface::STATUS_IDLE));
From bd096124afd849de1e1940987e8cfec29270cf8f Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 17 Oct 2019 16:26:45 -0500
Subject: [PATCH 0468/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../CatalogRule/Model/Indexer/IndexBuilder.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index f0bb92d1fc742..ca5fc0090b4ed 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -290,6 +290,7 @@ protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
+ $products = $this->productLoader->getProducts($ids);
/** @var Rule[] $activeRules */
$activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
@@ -298,15 +299,16 @@ protected function doReindexByIds($ids)
continue;
}
- $rule->setProductsFilter($ids);
- $productIds = $rule->getMatchingProductIds();
if (!is_array($ruleWebsiteIds)) {
$ruleWebsiteIds = explode(',', $ruleWebsiteIds);
}
- foreach ($productIds as $productId => $validationByWebsite) {
- $productWebsiteIds = array_keys(array_filter($validationByWebsite));
- $websiteIds = array_intersect($productWebsiteIds, $ruleWebsiteIds);
- $this->assignProductToRule($rule, $productId, $websiteIds);
+ foreach ($products as $product) {
+ if (!$rule->validate($product)) {
+ continue;
+ }
+
+ $websiteIds = array_intersect($product->getWebsiteIds(), $ruleWebsiteIds);
+ $this->assignProductToRule($rule, $product->getId(), $websiteIds);
}
}
From f686793606cb6745d7024f46425d9004c67a7dcc Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 17 Oct 2019 16:51:23 -0500
Subject: [PATCH 0469/1978] MC-19607: Mass delete deletes all products
---
.../AddFulltextFilterToCollectionTest.php | 74 +++++++++++++++++++
1 file changed, 74 insertions(+)
create mode 100644 app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php
diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php
new file mode 100644
index 0000000000000..881c843ecf92b
--- /dev/null
+++ b/app/code/Magento/CatalogSearch/Test/Unit/Ui/DataProvider/Product/AddFulltextFilterToCollectionTest.php
@@ -0,0 +1,74 @@
+objectManager = new ObjectManagerHelper($this);
+
+ $this->searchCollection = $this->getMockBuilder(SearchCollection::class)
+ ->setMethods(['addBackendSearchFilter', 'load', 'getAllIds'])
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->searchCollection->expects($this->any())
+ ->method('load')
+ ->willReturnSelf();
+ $this->collection = $this->getMockBuilder(Collection::class)
+ ->setMethods(['addIdFilter'])
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->model = $this->objectManager->getObject(
+ AddFulltextFilterToCollection::class,
+ [
+ 'searchCollection' => $this->searchCollection
+ ]
+ );
+ }
+
+ public function testAddFilter()
+ {
+ $this->searchCollection->expects($this->once())
+ ->method('addBackendSearchFilter')
+ ->with('test');
+ $this->searchCollection->expects($this->once())
+ ->method('getAllIds')
+ ->willReturn([]);
+ $this->collection->expects($this->once())
+ ->method('addIdFilter')
+ ->with(-1);
+ $this->model->addFilter($this->collection, 'test', ['fulltext' => 'test']);
+ }
+}
From 8dac4c39acc5da037c49a0cc0823e827e33eeec8 Mon Sep 17 00:00:00 2001
From: Roman Lytvynenko
Date: Thu, 17 Oct 2019 17:02:49 -0500
Subject: [PATCH 0470/1978] MC-21876: "Same as Billing Address" checkbox is
checked automatically when re-ordering an order with different
billing/shipping via Admin Panel.
---
app/code/Magento/Quote/Model/Quote/Address.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php
index 0e2bf1ce48ec7..d0daf5d5c7baa 100644
--- a/app/code/Magento/Quote/Model/Quote/Address.php
+++ b/app/code/Magento/Quote/Model/Quote/Address.php
@@ -429,7 +429,7 @@ protected function _isSameAsBilling()
return $this->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING &&
($this->_isNotRegisteredCustomer() || $this->_isDefaultShippingNullOrSameAsBillingAddress()) &&
- ($quoteSameAsBilling || $quoteSameAsBilling === 0 || $quoteSameAsBilling === null);
+ ($quoteSameAsBilling || $quoteSameAsBilling === null);
}
/**
From ea1632940f48105b3f55cdf5b0d375ba206dcbcc Mon Sep 17 00:00:00 2001
From: Roman Lytvynenko
Date: Thu, 17 Oct 2019 18:28:56 -0500
Subject: [PATCH 0471/1978] MC-21876: "Same as Billing Address" checkbox is
checked automatically when re-ordering an order with different
billing/shipping via Admin Panel.
---
app/code/Magento/Quote/Model/Quote/Address.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Quote/Model/Quote/Address.php b/app/code/Magento/Quote/Model/Quote/Address.php
index d0daf5d5c7baa..0e2bf1ce48ec7 100644
--- a/app/code/Magento/Quote/Model/Quote/Address.php
+++ b/app/code/Magento/Quote/Model/Quote/Address.php
@@ -429,7 +429,7 @@ protected function _isSameAsBilling()
return $this->getAddressType() == \Magento\Quote\Model\Quote\Address::TYPE_SHIPPING &&
($this->_isNotRegisteredCustomer() || $this->_isDefaultShippingNullOrSameAsBillingAddress()) &&
- ($quoteSameAsBilling || $quoteSameAsBilling === null);
+ ($quoteSameAsBilling || $quoteSameAsBilling === 0 || $quoteSameAsBilling === null);
}
/**
From 30eebde175442b3439650659298cdd955112be4e Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 18 Oct 2019 08:27:09 +0300
Subject: [PATCH 0472/1978] Magento 2.3.2 - PWA - graphQl fetching Issue for
phtml file called in static block #960
---
.../Model/Resolver/DataProvider/Block.php | 29 ++-----------------
.../Widget/Model/Template/FilterEmulate.php | 17 ++++++++++-
2 files changed, 18 insertions(+), 28 deletions(-)
diff --git a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
index 8eda6d27a1c72..fa4944381b858 100644
--- a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
+++ b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
@@ -11,7 +11,6 @@
use Magento\Cms\Api\Data\BlockInterface;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Widget\Model\Template\FilterEmulate;
-use Magento\Framework\App\State;
/**
* Cms block data provider
@@ -28,24 +27,16 @@ class Block
*/
private $widgetFilter;
- /**
- * @var State
- */
- private $state;
-
/**
* @param BlockRepositoryInterface $blockRepository
* @param FilterEmulate $widgetFilter
- * @param State $state
*/
public function __construct(
BlockRepositoryInterface $blockRepository,
- FilterEmulate $widgetFilter,
- State $state
+ FilterEmulate $widgetFilter
) {
$this->blockRepository = $blockRepository;
$this->widgetFilter = $widgetFilter;
- $this->state = $state;
}
/**
@@ -65,11 +56,7 @@ public function getData(string $blockIdentifier): array
);
}
- $renderedContent = $this->state->emulateAreaCode(
- \Magento\Framework\App\Area::AREA_FRONTEND,
- [$this, 'getRenderedBlockContent'],
- [$block->getContent()]
- );
+ $renderedContent = $this->widgetFilter->filter($block->getContent());
$blockData = [
BlockInterface::BLOCK_ID => $block->getId(),
@@ -79,16 +66,4 @@ public function getData(string $blockIdentifier): array
];
return $blockData;
}
-
- /**
- * Get block data as it rendered on frontend
- *
- * @param string $blockContent
- *
- * @return string
- */
- public function getRenderedBlockContent(string $blockContent) : string
- {
- return $this->widgetFilter->filter($blockContent);
- }
}
diff --git a/app/code/Magento/Widget/Model/Template/FilterEmulate.php b/app/code/Magento/Widget/Model/Template/FilterEmulate.php
index 9e3b571587a50..40c4ddcbdd41b 100644
--- a/app/code/Magento/Widget/Model/Template/FilterEmulate.php
+++ b/app/code/Magento/Widget/Model/Template/FilterEmulate.php
@@ -1,4 +1,4 @@
-_appState->emulateAreaCode('frontend', [$this, 'generateWidget'], [$construction]);
}
+
+ /**
+ * @param string $value
+ *
+ * @return string
+ * @throws \Exception
+ */
+ public function filter($value) : string
+ {
+ return $this->_appState->emulateAreaCode(
+ \Magento\Framework\App\Area::AREA_FRONTEND,
+ [$this, 'parent::filter'],
+ [$value]
+ );
+ }
}
From 0977e9417605e7ffe7a37e9678142f16fde322ca Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 18 Oct 2019 09:06:14 +0300
Subject: [PATCH 0473/1978] [Wishlist] Remove name from WishlistOutput #920
---
.../Model/Resolver/CustomerWishlistsResolver.php | 10 ++++------
app/code/Magento/WishlistGraphQl/etc/schema.graphqls | 2 +-
2 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
index a2b8280fc3d0d..ad32f953ef9c4 100644
--- a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
+++ b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
@@ -41,18 +41,16 @@ public function resolve(
array $value = null,
array $args = null
) {
- $customerId = $context->getUserId();
-
/* Guest checking */
- if (!$customerId && 0 === $customerId) {
+ if (false === $context->getExtensionAttributes()->getIsCustomer()) {
throw new GraphQlAuthorizationException(__('The current user cannot perform operations on wishlist'));
}
- $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($customerId);
- $wishlists = $collection->getItems();
+ $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($context->getUserId());
$wishlistsData = [];
- if (0 === count($wishlists)) {
+ if (0 === $collection->getSize()) {
return $wishlistsData;
}
+ $wishlists = $collection->getItems();
foreach ($wishlists as $wishlist) {
$wishlistsData [] = [
diff --git a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
index 28d80c4a21884..6a833efd7c2a5 100644
--- a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
@@ -10,7 +10,7 @@ type Customer {
}
type WishlistOutput @doc(description: "Deprecated: 'Wishlist' type should be used instead") {
- items: [WishlistItem] @deprecated(reason: "Use field `items` from type `Wishlist` instead") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"),
+ items: [WishlistItem] @deprecated(reason: "Use field `items` from type `Wishlist` instead") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"),
items_count: Int @deprecated(reason: "Use field `items_count` from type `Wishlist` instead") @doc(description: "The number of items in the wish list"),
name: String @deprecated(reason: "This field is related to Commerce functionality and is always null in Open source edition") @doc(description: "When multiple wish lists are enabled, the name the customer assigns to the wishlist"),
sharing_code: String @deprecated(reason: "Use field `sharing_code` from type `Wishlist` instead") @doc(description: "An encrypted code that Magento uses to link to the wish list"),
From bff6344dea315ca27a9932cc84171ac5ca404bd6 Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 18 Oct 2019 09:10:21 +0300
Subject: [PATCH 0474/1978] [Wishlist] Remove name from WishlistOutput #920
---
.../Model/Resolver/CustomerWishlistsResolver.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
index ad32f953ef9c4..3556eefe36a9c 100644
--- a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
+++ b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
@@ -47,7 +47,7 @@ public function resolve(
}
$collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($context->getUserId());
$wishlistsData = [];
- if (0 === $collection->getSize()) {
+ if (0 === $collection->getSize()) {
return $wishlistsData;
}
$wishlists = $collection->getItems();
From 6295376d97bc95dfbff051583fbdbf63eeafa93f Mon Sep 17 00:00:00 2001
From: Ievgenii Gryshkun
Date: Fri, 18 Oct 2019 09:18:41 +0300
Subject: [PATCH 0475/1978] Magento 2.3.2 - PWA - graphQl fetching Issue for
phtml file called in static block #960
---
app/code/Magento/Widget/Model/Template/FilterEmulate.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Widget/Model/Template/FilterEmulate.php b/app/code/Magento/Widget/Model/Template/FilterEmulate.php
index 40c4ddcbdd41b..9e57ebb34f0ed 100644
--- a/app/code/Magento/Widget/Model/Template/FilterEmulate.php
+++ b/app/code/Magento/Widget/Model/Template/FilterEmulate.php
@@ -5,13 +5,20 @@
*/
namespace Magento\Widget\Model\Template;
+/**
+ * Class FilterEmulate
+ *
+ * @package Magento\Widget\Model\Template
+ */
class FilterEmulate extends Filter
{
/**
* Generate widget with emulation frontend area
*
* @param string[] $construction
- * @return string
+ *
+ * @return mixed|string
+ * @throws \Exception
*/
public function widgetDirective($construction)
{
From 6ea86bbf765429d233bc9ab8515a9e3eae856af4 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Fri, 18 Oct 2019 11:49:25 +0530
Subject: [PATCH 0476/1978] condition updated and removed else part as its not
required.
---
.../Magento/CatalogImportExport/Model/Import/Product/Option.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
index 98220208cda3e..ee39c347e71f3 100644
--- a/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
+++ b/app/code/Magento/CatalogImportExport/Model/Import/Product/Option.php
@@ -2088,8 +2088,6 @@ protected function _parseCustomOptions($rowData)
}
if (isset($rowData[Product::COL_STORE_VIEW_CODE])) {
$options[$name][$k][self::COLUMN_STORE] = $rowData[Product::COL_STORE_VIEW_CODE];
- } else {
- $options[$name][$k][self::COLUMN_STORE] = '';
}
$k++;
}
From 5d17c6200ed50cba0c04aa4d2806323ba800f596 Mon Sep 17 00:00:00 2001
From: DianaRusin
Date: Fri, 18 Oct 2019 11:41:32 +0300
Subject: [PATCH 0477/1978] MC-20423: [Integration Test] Import Table Rates to
be used in Configuration Settings
---
.../Config/ImportExportTableratesTest.php | 118 ++++++++++++++++++
.../_files/tablerate_create_file_in_tmp.php | 20 +++
.../tablerate_create_file_in_tmp_rollback.php | 17 +++
.../OfflineShipping/_files/tablerates.csv | 2 +
4 files changed, 157 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
create mode 100644 dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php
create mode 100644 dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerates.csv
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php
new file mode 100644
index 0000000000000..e4277683808d2
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php
@@ -0,0 +1,118 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->fileSystem = $this->objectManager->get(Filesystem::class);
+ $this->varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+
+ parent::setUp();
+ }
+
+ /**
+ * Import Table Rates to be used in Configuration Settings.
+ *
+ * @magentoDataFixture Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
+ * @return void
+ */
+ public function testImportExportTablerates(): void
+ {
+ $importCsv = 'tablerates.csv';
+ $tmpDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
+ $importCsvPath = $tmpDirectory->getAbsolutePath($importCsv);
+
+ $_FILES['groups'] = [
+ 'name' => ['tablerate' => ['fields' => ['import' => ['value' => $importCsv]]]],
+ 'type' => ['tablerate' => ['fields' => ['import' => ['value' => 'text/csv']]]],
+ 'tmp_name' => ['tablerate' => ['fields' => ['import' => ['value' => $importCsvPath]]]],
+ 'error'=> ['tablerate' => ['fields' => ['import' => ['value' => 0]]]],
+ 'size' => ['tablerate' => ['fields' => ['import' => ['value' => 102]]]],
+ ];
+
+ $this->getRequest()->setPostValue(
+ [
+ 'groups' => [
+ 'tablerate' => [
+ 'fields' => [
+ 'condition_name' => ['value' => 'package_weight'],
+ 'import' => ['value' => microtime(true)],
+ ],
+ ],
+ ],
+ ]
+ )->setMethod(HttpRequest::METHOD_POST);
+
+ $this->dispatch('backend/admin/system_config/save/section/carriers/website/1/');
+ $this->assertSessionMessages(
+ $this->equalTo([(string)__('You saved the configuration.')]),
+ MessageInterface::TYPE_SUCCESS
+ );
+
+ $tablerateResourceModel = $this->objectManager->create(Tablerate::class);
+ $connection = $tablerateResourceModel->getConnection();
+
+ $selectData = $connection->select()->from($tablerateResourceModel->getTable('shipping_tablerate'));
+ $this->assertNotEmpty($connection->fetchRow($selectData));
+
+ $exportCsv = $this->getTablerateCsv();
+ $exportCsvContent = $this->varDirectory->openFile($exportCsv['value'], 'r')->readAll();
+ $importCsvContent = $tmpDirectory->openFile($importCsvPath, 'r')->readAll();
+
+ $this->assertEquals($importCsvContent, $exportCsvContent);
+ }
+
+ /**
+ * @return array
+ */
+ private function getTablerateCsv(): array
+ {
+ /** @var Grid $gridBlock */
+ $gridBlock = $this->objectManager->get(LayoutInterface::class)->createBlock(Grid::class);
+ $exportCsv = $gridBlock->setWebsiteId(1)->setConditionName('package_weight')->getCsvFile();
+
+ return $exportCsv;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
new file mode 100644
index 0000000000000..e12fbf8967b62
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
@@ -0,0 +1,20 @@
+get(Filesystem::class);
+
+$tmpDirectory = $fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
+$importCsvPath = $tmpDirectory->getAbsolutePath($importCsv);
+
+$fixtureDir = realpath(__DIR__);
+copy($fixtureDir . DIRECTORY_SEPARATOR . $importCsv, $importCsvPath);
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php
new file mode 100644
index 0000000000000..24448a56a4263
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php
@@ -0,0 +1,17 @@
+get(Filesystem::class);
+$tmpDirectory = $fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
+$fileName = 'tablerates.csv';
+
+unlink($tmpDirectory->getAbsolutePath($fileName));
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerates.csv b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerates.csv
new file mode 100644
index 0000000000000..de92b11c93242
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerates.csv
@@ -0,0 +1,2 @@
+Country,Region/State,"Zip/Postal Code","Weight (and above)","Shipping Price"
+USA,*,*,10.0000,666.0000
From 92d53a17f00f856bc080f40eea5072e93e8ed2d4 Mon Sep 17 00:00:00 2001
From: Roman Zhupanyn
Date: Fri, 18 Oct 2019 11:58:22 +0300
Subject: [PATCH 0478/1978] MC-20675: Admin: Add/edit/delete related, up-sells,
cross-sells products
---
.../Adminhtml/Product/Save/LinksTest.php | 27 ++++++----------
.../Catalog/Model/Product/LinksTest.php | 31 +++++++++++--------
2 files changed, 28 insertions(+), 30 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
index 840b05dfe2b98..791e45a22ca88 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
@@ -9,7 +9,7 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
-use Magento\Catalog\Model\ProductRepository;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -27,7 +27,7 @@ class LinksTest extends AbstractBackendController
'related',
];
- /** @var ProductRepository $productRepository */
+ /** @var ProductRepositoryInterface $productRepository */
private $productRepository;
/**
@@ -48,20 +48,15 @@ protected function setUp()
* @param array $postData
* @return void
*/
- public function testAddRelatedUpSellCrossSellProducts(array $postData)
+ public function testAddRelatedUpSellCrossSellProducts(array $postData): void
{
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product/save');
-
- /** @var Product $product */
$product = $this->productRepository->get('simple');
-
- $expectedLinks = $this->getExpectedLinks($postData['links']);
- $actualLinks = $this->getActualLinks($product);
$this->assertEquals(
- $expectedLinks,
- $actualLinks,
+ $this->getExpectedLinks($postData['links']),
+ $this->getActualLinks($product),
"Expected linked products do not match actual linked products!"
);
}
@@ -111,7 +106,7 @@ private function getExpectedLinks(array $links): array
foreach ($this->linkTypes as $linkType) {
$expectedLinks[$linkType] = [];
foreach ($links[$linkType] as $productData) {
- $expectedLinks[$linkType][$productData['id']] = $productData;
+ $expectedLinks[$linkType][] = $productData['id'];
}
}
@@ -121,10 +116,10 @@ private function getExpectedLinks(array $links): array
/**
* Get an array of received related, up-sells, cross-sells products
*
- * @param Product $product
+ * @param ProductInterface|Product $product
* @return array
*/
- private function getActualLinks(Product $product): array
+ private function getActualLinks(ProductInterface $product): array
{
$actualLinks = [];
foreach ($this->linkTypes as $linkType) {
@@ -141,11 +136,9 @@ private function getActualLinks(Product $product): array
$products = $product->getRelatedProducts();
break;
}
- /** @var Product $product */
+ /** @var ProductInterface|Product $productItem */
foreach ($products as $productItem) {
- $actualLinks[$linkType][$productItem->getId()] = [
- 'id' => $productItem->getId(),
- ];
+ $actualLinks[$linkType][] = $productItem->getId();
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
index 45387e6d0f5d8..19fce2abe2aff 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
@@ -7,11 +7,12 @@
namespace Magento\Catalog\Model\Product;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\ProductLinkInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductLink\Link;
-use Magento\Catalog\Model\ProductRepository;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
use PHPUnit\Framework\TestCase;
@@ -61,12 +62,15 @@ class LinksTest extends TestCase
],
];
- /** @var ProductRepository $productRepository */
+ /** @var ProductRepositoryInterface $productRepository */
private $productRepository;
/** @var ObjectManager */
private $objectManager;
+ /** @var ProductResource */
+ private $productResource;
+
/**
* @inheritdoc
*/
@@ -75,6 +79,7 @@ protected function setUp()
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ $this->productResource = $this->objectManager->create(ProductResource::class);
}
/**
@@ -90,24 +95,23 @@ protected function setUp()
*/
public function testEditRemoveRelatedUpSellCrossSellProducts(array $data): void
{
- /** @var Product $product */
+ /** @var ProductInterface|Product $product */
$product = $this->productRepository->get('simple');
$this->setCustomProductLinks($product, $this->getProductData($data['defaultLinks']));
$this->productRepository->save($product);
$productData = $this->getProductData($data['productLinks']);
$this->setCustomProductLinks($product, $productData);
- $product->save();
+ $this->productResource->save($product);
$product = $this->productRepository->get('simple');
$expectedLinks = isset($data['expectedProductLinks'])
? $this->getProductData($data['expectedProductLinks'])
: $productData;
- $actualLinks = $this->getActualLinks($product);
$this->assertEquals(
$expectedLinks,
- $actualLinks,
+ $this->getActualLinks($product),
"Expected linked products do not match actual linked products!"
);
}
@@ -187,19 +191,20 @@ private function getProductData(array $productFixture): array
foreach ($this->linkTypes as $linkType) {
$productData[$linkType] = [];
foreach ($productFixture as $data) {
- $productData[$linkType][$data['id']] = $data;
+ $productData[$linkType][] = $data;
}
}
+
return $productData;
}
/**
* Link related, up-sells, cross-sells products received from the array
*
- * @param Product $product
+ * @param ProductInterface|Product $product
* @param array $productData
*/
- private function setCustomProductLinks(Product $product, array $productData): void
+ private function setCustomProductLinks(ProductInterface $product, array $productData): void
{
$productLinks = [];
foreach ($productData as $linkType => $links) {
@@ -221,10 +226,10 @@ private function setCustomProductLinks(Product $product, array $productData): vo
/**
* Get an array of received related, up-sells, cross-sells products
*
- * @param Product $product
+ * @param ProductInterface|Product $product
* @return array
*/
- private function getActualLinks(Product $product): array
+ private function getActualLinks(ProductInterface $product): array
{
$actualLinks = [];
foreach ($this->linkTypes as $linkType) {
@@ -241,9 +246,9 @@ private function getActualLinks(Product $product): array
$products = $product->getRelatedProducts();
break;
}
- /** @var Product $product */
+ /** @var ProductInterface|Product $productItem */
foreach ($products as $productItem) {
- $actualLinks[$linkType][$productItem->getId()] = [
+ $actualLinks[$linkType][] = [
'id' => $productItem->getId(),
'sku' => $productItem->getSku(),
'position' => $productItem->getPosition(),
From 8865386a4c9c22b89f6875bd0a9b63881c5d0a2b Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Fri, 18 Oct 2019 12:10:46 +0300
Subject: [PATCH 0479/1978] MC-21715: Storefront: view product images
---
.../Block/Product/View/GalleryTest.php | 363 ++++++++++++++++++
.../Model/Product/Gallery/ReadHandlerTest.php | 312 +++++++++++++--
2 files changed, 641 insertions(+), 34 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
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..bb936591344cc
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
@@ -0,0 +1,363 @@
+ '/m/a/magento_image.jpg',
+ 'img' => '/m/a/magento_image.jpg',
+ 'full' => '/m/a/magento_image.jpg',
+ 'caption' => 'Image Alt Text',
+ 'position' => '1',
+ 'isMain' => false,
+ 'type' => 'image',
+ 'videoUrl' => null,
+ ];
+
+ /**
+ * @var array
+ */
+ private $thumbnailExpectation = [
+ 'thumb' => '/m/a/magento_thumbnail.jpg',
+ 'img' => '/m/a/magento_thumbnail.jpg',
+ 'full' => '/m/a/magento_thumbnail.jpg',
+ 'caption' => 'Thumbnail Image',
+ 'position' => '2',
+ 'isMain' => false,
+ 'type' => 'image',
+ 'videoUrl' => null,
+ ];
+
+ /**
+ * @var array
+ */
+ private $placeholderExpectation = [
+ 'thumb' => '/placeholder/thumbnail.jpg',
+ 'img' => '/placeholder/image.jpg',
+ 'full' => '/placeholder/image.jpg',
+ 'caption' => '',
+ 'position' => '0',
+ 'isMain' => true,
+ 'type' => 'image',
+ 'videoUrl' => null,
+ ];
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ $this->objectManager = Bootstrap::getObjectManager();
+ $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ $this->productResource = $this->objectManager->get(ProductResource::class);
+ $this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
+ $this->galleryProcessor = $this->objectManager->create(Processor::class);
+ $this->serializer = $this->objectManager->get(Json::class);
+ $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Gallery::class);
+ }
+
+ /**
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testGetGalleryImagesJsonWithoutImages(): void
+ {
+ $this->block->setData('product', $this->getProduct());
+ $result = $this->serializer->unserialize($this->block->getGalleryImagesJson());
+ $this->assertImages(reset($result), $this->placeholderExpectation);
+ }
+
+ /**
+ * @dataProvider galleryDisabledImagesDataProvider
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDbIsolation enabled
+ * @param array $images
+ * @param array $expectation
+ * @return void
+ */
+ public function testGetGalleryImagesJsonWithDisabledImage(array $images, array $expectation): void
+ {
+ $product = $this->getProduct();
+ $this->setGalleryImages($product, $images);
+ $this->block->setData('product', $this->getProduct());
+ $firstImage = $this->serializer->unserialize($this->block->getGalleryImagesJson());
+ $this->assertImages(reset($firstImage), $expectation);
+ }
+
+
+ /**
+ * @dataProvider galleryDisabledImagesDataProvider
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDataFixture Magento/Store/_files/second_store.php
+ * @magentoDbIsolation enabled
+ * @param array $images
+ * @param array $expectation
+ * @return void
+ */
+ public function testGetGalleryImagesJsonOnStoreWithDisabledImage(array $images, array $expectation): void
+ {
+ $secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
+ $product = $this->getProduct($secondStoreId);
+ $this->setGalleryImages($product, $images);
+ $this->block->setData('product', $this->getProduct($secondStoreId));
+ $firstImage = $this->serializer->unserialize($this->block->getGalleryImagesJson());
+ $this->assertImages(reset($firstImage), $expectation);
+ }
+
+ /**
+ * @return array
+ */
+ public function galleryDisabledImagesDataProvider(): array
+ {
+ return [
+ [
+ 'images' => [
+ '/m/a/magento_image.jpg' => ['disabled' => true],
+ '/m/a/magento_thumbnail.jpg' => [],
+ ],
+ 'expectation' => $this->thumbnailExpectation,
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider galleryImagesDataProvider
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDbIsolation enabled
+ * @param array $images
+ * @param array $expectation
+ * @return void
+ */
+ public function testGetGalleryImagesJson(array $images, array $expectation): void
+ {
+ $product = $this->getProduct();
+ $this->setGalleryImages($product, $images);
+ $this->block->setData('product', $this->getProduct());
+ [$firstImage, $secondImage] = $this->serializer->unserialize($this->block->getGalleryImagesJson());
+ [$firstExpectedImage, $secondExpectedImage] = $expectation;
+ $this->assertImages($firstImage, $firstExpectedImage);
+ $this->assertImages($secondImage, $secondExpectedImage);
+ }
+
+ /**
+ * @return array
+ */
+ public function galleryImagesDataProvider(): array
+ {
+ return [
+ 'with_main_image' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => [],
+ '/m/a/magento_thumbnail.jpg' => ['main' => true],
+ ],
+ 'expectation' => [
+ $this->imageExpectation,
+ array_merge($this->thumbnailExpectation, ['isMain' => true]),
+ ],
+ ],
+ 'without_main_image' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => [],
+ '/m/a/magento_thumbnail.jpg' => [],
+ ],
+ 'expectation' => [
+ array_merge($this->imageExpectation, ['isMain' => true]),
+ $this->thumbnailExpectation,
+ ],
+ ],
+ 'with_changed_position' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => ['position' => '2'],
+ '/m/a/magento_thumbnail.jpg' => ['position' => '1'],
+ ],
+ 'expectation' => [
+ array_merge($this->thumbnailExpectation, ['position' => '1']),
+ array_merge($this->imageExpectation, ['position' => '2', 'isMain' => true]),
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider galleryImagesOnStoreViewDataProvider
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDataFixture Magento/Store/_files/second_store.php
+ * @magentoDbIsolation enabled
+ * @param array $images
+ * @param array $expectation
+ * @return void
+ */
+ public function testGetGalleryImagesJsonOnStoreView(array $images, array $expectation): void
+ {
+ $secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
+ $product = $this->getProduct($secondStoreId);
+ $this->setGalleryImages($product, $images);
+ $this->block->setData('product', $this->getProduct($secondStoreId));
+ [$firstImage, $secondImage] = $this->serializer->unserialize($this->block->getGalleryImagesJson());
+ [$firstExpectedImage, $secondExpectedImage] = $expectation;
+ $this->assertImages($firstImage, $firstExpectedImage);
+ $this->assertImages($secondImage, $secondExpectedImage);
+ }
+
+ /**
+ * @return array
+ */
+ public function galleryImagesOnStoreViewDataProvider(): array
+ {
+ return [
+ 'with_store_labels' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => ['label' => 'Some store label'],
+ '/m/a/magento_thumbnail.jpg' => [],
+ ],
+ 'expectation' => [
+ array_merge($this->imageExpectation, ['isMain' => true, 'caption' => 'Some store label']),
+ $this->thumbnailExpectation,
+ ],
+ ],
+ 'with_changed_position' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => ['position' => '3'],
+ '/m/a/magento_thumbnail.jpg' => [],
+ ],
+ 'expectation' => [
+ array_merge($this->thumbnailExpectation, ['position' => '2']),
+ array_merge($this->imageExpectation, ['position' => '3', 'isMain' => true]),
+ ],
+ ],
+ 'with_main_store_image' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => [],
+ '/m/a/magento_thumbnail.jpg' => ['main' => true],
+ ],
+ 'expectation' => [
+ $this->imageExpectation,
+ array_merge($this->thumbnailExpectation, ['isMain' => true]),
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Updates product gallery images and saves product.
+ *
+ * @param Product $product
+ * @param array $images
+ * @param int|null $storeId
+ * @return void
+ */
+ private function setGalleryImages(Product $product, array $images, int $storeId = null): void
+ {
+ $product->setImage(null);
+ foreach ($images as $file => $data) {
+ if (!empty($data)) {
+ $this->galleryProcessor->updateImage($product, $file, $data);
+ }
+
+ if (!empty($data['main'])) {
+ $product->setImage($file);
+ }
+ }
+
+ if ($storeId) {
+ $product->setStoreId($storeId);
+ }
+
+ $this->productResource->save($product);
+ }
+
+ /**
+ * Returns current product.
+ *
+ * @param int|null $storeId
+ * @return Product
+ */
+ private function getProduct(int $storeId = null): Product
+ {
+ return $this->product = $this->productRepository->get('simple', false, $storeId, true);
+ }
+
+ /**
+ * Asserts gallery image data.
+ *
+ * @param array $image
+ * @param array $expectedImage
+ * @return void
+ */
+ private function assertImages(array $image, array $expectedImage): void
+ {
+ $this->assertStringEndsWith($expectedImage['thumb'], $image['thumb']);
+ $this->assertStringEndsWith($expectedImage['img'], $image['img']);
+ $this->assertStringEndsWith($expectedImage['full'], $image['full']);
+ $this->assertEquals($expectedImage['caption'], $image['caption']);
+ $this->assertEquals($expectedImage['position'], $image['position']);
+ $this->assertEquals($expectedImage['isMain'], $image['isMain']);
+ $this->assertEquals($expectedImage['type'], $image['type']);
+ $this->assertEquals($expectedImage['videoUrl'], $image['videoUrl']);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
index 35c995ec552a5..4c28e9d6e834f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
@@ -3,75 +3,319 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Model\Product\Gallery;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
+use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Store\Api\StoreRepositoryInterface;
+use Magento\Store\Model\Store;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\ObjectManager;
/**
- * Test class for \Magento\Catalog\Model\Product\Gallery\ReadHandler.
- *
- * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ * Provide tests for loading gallery images on product load.
*/
class ReadHandlerTest extends \PHPUnit\Framework\TestCase
{
/**
- * @var \Magento\TestFramework\ObjectManager
+ * @var ObjectManager
+ */
+ private $objectManager;
+
+ /**
+ * @var ReadHandler
*/
- protected $objectManager;
+ private $readHandler;
/**
- * @var \Magento\Catalog\Model\Product\Gallery\ReadHandler
+ * @var ProductRepositoryInterface
*/
- protected $readHandler;
+ private $productRepository;
+ /**
+ * @var ProductResource
+ */
+ private $productResource;
+
+ /**
+ * @var StoreRepositoryInterface
+ */
+ private $storeRepository;
+
+ /**
+ * @var Processor
+ */
+ private $galleryProcessor;
+
+ /**
+ * @var EntityMetadata
+ */
+ private $metadata;
+
+ /**
+ * @inheritdoc
+ */
protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
-
- $this->readHandler = $this->objectManager->create(
- \Magento\Catalog\Model\Product\Gallery\ReadHandler::class
- );
+ $this->readHandler = $this->objectManager->create(ReadHandler::class);
+ $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $this->productResource = $this->objectManager->get(ProductResource::class);
+ $this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
+ $this->galleryProcessor = $this->objectManager->create(Processor::class);
+ $this->metadata = $this->objectManager->get(MetadataPool::class)->getMetadata(ProductInterface::class);
}
/**
- * @covers \Magento\Catalog\Model\Product\Gallery\ReadHandler::execute
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoDbIsolation enabled
+ * @return void
*/
- public function testExecute()
+ public function testExecuteWithoutImages(): void
{
- /** @var \Magento\Catalog\Model\Product $product */
- $product = $this->objectManager->create(
- \Magento\Catalog\Model\Product::class
- );
-
- /**
- * @var $entityMetadata \Magento\Framework\EntityManager\EntityMetadata
- */
- $entityMetadata = $this->objectManager
- ->get(MetadataPool::class)
- ->getMetadata(ProductInterface::class);
- $productRepository = $this->objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
- $linkFieldId = $productRepository->get('simple')->getData($entityMetadata->getLinkField());
-
- $product->setData($entityMetadata->getLinkField(), $linkFieldId);
+ $product = $this->getProductInstance();
$this->readHandler->execute($product);
-
$data = $product->getData();
-
$this->assertArrayHasKey('media_gallery', $data);
$this->assertArrayHasKey('images', $data['media_gallery']);
+ $this->assertCount(0, $data['media_gallery']['images']);
+ }
+ /**
+ * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testExecuteWithOneImage(): void
+ {
+ $product = $this->getProductInstance();
+ $this->readHandler->execute($product);
+ $data = $product->getData();
+ $this->assertArrayHasKey('media_gallery', $data);
+ $this->assertArrayHasKey('images', $data['media_gallery']);
$this->assertCount(1, $data['media_gallery']['images']);
+ $galleryImage = reset($data['media_gallery']['images']);
+ $this->assertEquals('/m/a/magento_image.jpg', $galleryImage['file']);
+ $this->assertEquals(1, $galleryImage['position']);
+ $this->assertEquals('Image Alt Text', $galleryImage['label']);
+ $this->assertEquals(0, $galleryImage['disabled']);
+ }
+
+ /**
+ * @dataProvider executeWithTwoImagesDataProvider
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDbIsolation enabled
+ * @param array $images
+ * @param array $expectation
+ * @return void
+ */
+ public function testExecuteWithTwoImages(array $images, array $expectation): void
+ {
+ $product = $this->getProduct();
+ foreach ($images as $file => $data) {
+ if (!empty($data)) {
+ $this->galleryProcessor->updateImage($product, $file, $data);
+ }
+ }
+ $this->saveProduct($product);
+ $productInstance = $this->getProductInstance();
+ $this->readHandler->execute($productInstance);
+ $data = $productInstance->getData();
+ $this->assertArrayHasKey('media_gallery', $data);
+ $this->assertArrayHasKey('images', $data['media_gallery']);
+ $this->assertCount(count($expectation), $data['media_gallery']['images']);
+ $imagesToAssert = [];
foreach ($data['media_gallery']['images'] as $valueId => $imageData) {
- $this->assertEquals(
- 'Image Alt Text',
- $imageData['label']
- );
+ $imagesToAssert[] = [
+ 'file' => $imageData['file'],
+ 'label' => $imageData['label'],
+ 'position' => $imageData['position'],
+ 'disabled' => $imageData['disabled'],
+ ];
$this->assertEquals(
$imageData['value_id'],
$valueId
);
}
+ $this->assertEquals($expectation, $imagesToAssert);
+ }
+
+ /**
+ * @return array
+ */
+ public function executeWithTwoImagesDataProvider(): array
+ {
+ return [
+ 'with_two_images' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => [],
+ '/m/a/magento_thumbnail.jpg' => [],
+ ],
+ 'expectation' => [
+ [
+ 'file' => '/m/a/magento_image.jpg',
+ 'label' => 'Image Alt Text',
+ 'position' => '1',
+ 'disabled' => '0',
+ ],
+ [
+ 'file' => '/m/a/magento_thumbnail.jpg',
+ 'label' => 'Thumbnail Image',
+ 'position' => '2',
+ 'disabled' => '0',
+ ],
+ ],
+ ],
+ 'with_two_images_and_changed_position_and_one_disabled' => [
+ 'images' => [
+ '/m/a/magento_image.jpg' => [
+ 'position' => '2',
+ 'disabled' => '0',
+ ],
+ '/m/a/magento_thumbnail.jpg' => [
+ 'position' => '1',
+ 'disabled' => '1',
+ ],
+ ],
+ 'expectation' => [
+ [
+ 'file' => '/m/a/magento_thumbnail.jpg',
+ 'label' => 'Thumbnail Image',
+ 'position' => '1',
+ 'disabled' => '1',
+ ],
+ [
+ 'file' => '/m/a/magento_image.jpg',
+ 'label' => 'Image Alt Text',
+ 'position' => '2',
+ 'disabled' => '0',
+ ],
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider executeOnStoreViewDataProvider
+ * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ * @magentoDataFixture Magento/Store/_files/second_store.php
+ * @magentoDbIsolation enabled
+ * @param string $file
+ * @param string $field
+ * @param string $value
+ * @param array $expectation
+ * @return void
+ */
+ public function testExecuteOnStoreView(string $file, string $field, string $value, array $expectation): void
+ {
+ $product = $this->getProduct();
+ $this->galleryProcessor->updateImage($product, $file, [$field => $value]);
+ $secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
+ $this->saveProduct($product, (int)$secondStoreId);
+ $productInstance = $this->getProductInstance($secondStoreId);
+ $this->readHandler->execute($productInstance);
+ $data = $productInstance->getData();
+ $this->assertArrayHasKey('media_gallery', $data);
+ $this->assertArrayHasKey('images', $data['media_gallery']);
+ $image = reset($data['media_gallery']['images']);
+ $dataToAssert = [
+ $field => $image[$field],
+ $field . '_default' => $image[$field . '_default'],
+ ];
+ $this->assertEquals($expectation, $dataToAssert);
+ }
+
+ /**
+ * @return array
+ */
+ public function executeOnStoreViewDataProvider(): array
+ {
+ return [
+ 'with_store_label' => [
+ 'file' => '/m/a/magento_image.jpg',
+ 'field' => 'label',
+ 'value' => 'Some store label',
+ 'expectation' => [
+ 'label' => 'Some store label',
+ 'label_default' => 'Image Alt Text',
+ ],
+ ],
+ 'with_store_position' => [
+ 'file' => '/m/a/magento_image.jpg',
+ 'field' => 'position',
+ 'value' => '2',
+ 'expectation' => [
+ 'position' => '2',
+ 'position_default' => '1',
+ ],
+ ],
+ 'with_store_disabled' => [
+ 'file' => '/m/a/magento_image.jpg',
+ 'field' => 'disabled',
+ 'value' => '1',
+ 'expectation' => [
+ 'disabled' => '1',
+ 'disabled_default' => '0',
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Returns product for testing.
+ *
+ * @return Product
+ */
+ private function getProduct(): Product
+ {
+ /** @var Product $product */
+ $product = $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID);
+
+ return $product;
+ }
+
+ /**
+ * Saves product via resource model.
+ * Uses product resource, because saving via repository requires image in base64 format.
+ *
+ * @param Product $product
+ * @param int|null $storeId
+ * @return void
+ */
+ private function saveProduct(Product $product, int $storeId = null): void
+ {
+ if ($storeId) {
+ $product->setStoreId($storeId);
+ }
+
+ $this->productResource->save($product);
+ }
+
+ /**
+ * Returns empty product instance.
+ *
+ * @param int|null $storeId
+ * @return Product
+ */
+ private function getProductInstance(int $storeId = null): Product
+ {
+ /** @var Product $product */
+ $product = $this->objectManager->create(Product::class);
+ $product->setData(
+ $this->metadata->getLinkField(),
+ $this->getProduct()->getData($this->metadata->getLinkField())
+ );
+
+ if ($storeId) {
+ $product->setStoreId($storeId);
+ }
+
+ return $product;
}
}
From 59c98b7cffe7d087e0272ff77bf3203fdb0b9df7 Mon Sep 17 00:00:00 2001
From: Dmytro Androshchuk
Date: Fri, 18 Oct 2019 12:53:15 +0300
Subject: [PATCH 0480/1978] Fixes #25120 stores the attribute url_path for
non-default Stores
---
.../Observer/CategoryUrlPathAutogeneratorObserver.php | 2 +-
.../Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php | 3 +++
2 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php
index 54ef7102fcc47..0d0b0fb995706 100644
--- a/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php
+++ b/app/code/Magento/CatalogUrlRewrite/Observer/CategoryUrlPathAutogeneratorObserver.php
@@ -94,7 +94,7 @@ public function execute(\Magento\Framework\Event\Observer $observer)
$resultUrlKey = $this->categoryUrlPathGenerator->getUrlKey($category);
$this->updateUrlKey($category, $resultUrlKey);
} elseif ($useDefaultAttribute) {
- if (!$category->isObjectNew()) {
+ if (!$category->isObjectNew() && $category->getStoreId() === Store::DEFAULT_STORE_ID) {
$resultUrlKey = $category->formatUrlKey($category->getOrigData('name'));
$this->updateUrlKey($category, $resultUrlKey);
}
diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php
index 0a570adab309a..9e2090e36f08e 100644
--- a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php
+++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Observer/CategoryUrlPathAutogeneratorObserverTest.php
@@ -159,6 +159,9 @@ public function testShouldThrowExceptionIfUrlKeyIsEmpty($useDefaultUrlKey, $isOb
$this->expectExceptionMessage('Invalid URL key');
$categoryData = ['use_default' => ['url_key' => $useDefaultUrlKey], 'url_key' => '', 'url_path' => ''];
$this->category->setData($categoryData);
+ $this->category
+ ->method('getStoreId')
+ ->willReturn(\Magento\Store\Model\Store::DEFAULT_STORE_ID);
$this->category->isObjectNew($isObjectNew);
$this->assertEquals($isObjectNew, $this->category->isObjectNew());
$this->assertEquals($categoryData['url_key'], $this->category->getUrlKey());
From de9ca56b01c7c8cf4805d189fc6c6052a8491a38 Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky <51681487+engcom-Foxtrot@users.noreply.github.com>
Date: Fri, 18 Oct 2019 12:57:49 +0300
Subject: [PATCH 0481/1978] magento/magento2#25055: Backward compatibility fix.
---
app/code/Magento/Catalog/Model/Product/Option.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Option.php b/app/code/Magento/Catalog/Model/Product/Option.php
index 03131013bc298..e56cd2bcafd67 100644
--- a/app/code/Magento/Catalog/Model/Product/Option.php
+++ b/app/code/Magento/Catalog/Model/Product/Option.php
@@ -346,7 +346,7 @@ public function setProduct(Product $product = null)
* @param string|null $type
* @return string
*/
- public function getGroupByType($type = null): string
+ public function getGroupByType($type = null)
{
if ($type === null) {
$type = $this->getType();
From 4e7cd44ba2b1ecbb54caeb2b2e347660737444fc Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Fri, 18 Oct 2019 14:01:35 +0300
Subject: [PATCH 0482/1978] MC-21715: Storefront: view product images
---
.../Block/Product/View/GalleryTest.php | 19 ++++---
.../Model/Product/Gallery/ReadHandlerTest.php | 53 ++++++++++---------
2 files changed, 38 insertions(+), 34 deletions(-)
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
index bb936591344cc..bf6d081ce4316 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
@@ -9,7 +9,6 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
-use Magento\Catalog\Model\Product\Gallery\Processor;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\LayoutInterface;
@@ -44,11 +43,6 @@ class GalleryTest extends \PHPUnit\Framework\TestCase
*/
private $storeRepository;
- /**
- * @var Processor
- */
- private $galleryProcessor;
-
/**
* @var Json
*/
@@ -115,7 +109,6 @@ protected function setUp()
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$this->productResource = $this->objectManager->get(ProductResource::class);
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
- $this->galleryProcessor = $this->objectManager->create(Processor::class);
$this->serializer = $this->objectManager->get(Json::class);
$this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Gallery::class);
}
@@ -149,7 +142,6 @@ public function testGetGalleryImagesJsonWithDisabledImage(array $images, array $
$this->assertImages(reset($firstImage), $expectation);
}
-
/**
* @dataProvider galleryDisabledImagesDataProvider
* @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
@@ -315,10 +307,17 @@ private function setGalleryImages(Product $product, array $images, int $storeId
{
$product->setImage(null);
foreach ($images as $file => $data) {
- if (!empty($data)) {
- $this->galleryProcessor->updateImage($product, $file, $data);
+ $mediaGalleryData = $product->getData('media_gallery');
+ foreach ($mediaGalleryData['images'] as &$image) {
+ if ($image['file'] == $file) {
+ foreach ($data as $key => $value) {
+ $image[$key] = $value;
+ }
+ }
}
+ $product->setData('media_gallery', $mediaGalleryData);
+
if (!empty($data['main'])) {
$product->setImage($file);
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
index 4c28e9d6e834f..b3b612d229e68 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
@@ -11,7 +11,6 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
-use Magento\Framework\EntityManager\EntityMetadata;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Model\Store;
@@ -49,14 +48,9 @@ class ReadHandlerTest extends \PHPUnit\Framework\TestCase
private $storeRepository;
/**
- * @var Processor
+ * @var string
*/
- private $galleryProcessor;
-
- /**
- * @var EntityMetadata
- */
- private $metadata;
+ private $productLinkField;
/**
* @inheritdoc
@@ -68,8 +62,9 @@ protected function setUp()
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
$this->productResource = $this->objectManager->get(ProductResource::class);
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
- $this->galleryProcessor = $this->objectManager->create(Processor::class);
- $this->metadata = $this->objectManager->get(MetadataPool::class)->getMetadata(ProductInterface::class);
+ $this->productLinkField = $this->objectManager->get(MetadataPool::class)
+ ->getMetadata(ProductInterface::class)
+ ->getLinkField();
}
/**
@@ -117,13 +112,7 @@ public function testExecuteWithOneImage(): void
*/
public function testExecuteWithTwoImages(array $images, array $expectation): void
{
- $product = $this->getProduct();
- foreach ($images as $file => $data) {
- if (!empty($data)) {
- $this->galleryProcessor->updateImage($product, $file, $data);
- }
- }
- $this->saveProduct($product);
+ $this->setGalleryImages($this->getProduct(), $images);
$productInstance = $this->getProductInstance();
$this->readHandler->execute($productInstance);
$data = $productInstance->getData();
@@ -215,9 +204,8 @@ public function executeWithTwoImagesDataProvider(): array
public function testExecuteOnStoreView(string $file, string $field, string $value, array $expectation): void
{
$product = $this->getProduct();
- $this->galleryProcessor->updateImage($product, $file, [$field => $value]);
$secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
- $this->saveProduct($product, (int)$secondStoreId);
+ $this->setGalleryImages($product, [$file => [$field => $value]], (int)$secondStoreId);
$productInstance = $this->getProductInstance($secondStoreId);
$this->readHandler->execute($productInstance);
$data = $productInstance->getData();
@@ -281,15 +269,32 @@ private function getProduct(): Product
}
/**
- * Saves product via resource model.
- * Uses product resource, because saving via repository requires image in base64 format.
+ * Updates product gallery images and saves product.
*
* @param Product $product
+ * @param array $images
* @param int|null $storeId
* @return void
*/
- private function saveProduct(Product $product, int $storeId = null): void
+ private function setGalleryImages(Product $product, array $images, int $storeId = null): void
{
+ $product->setImage(null);
+ foreach ($images as $file => $data) {
+ $mediaGalleryData = $product->getData('media_gallery');
+ foreach ($mediaGalleryData['images'] as &$image) {
+ if ($image['file'] == $file) {
+ foreach ($data as $key => $value) {
+ $image[$key] = $value;
+ }
+ }
+ }
+
+ $product->setData('media_gallery', $mediaGalleryData);
+ if (!empty($data['main'])) {
+ $product->setImage($file);
+ }
+ }
+
if ($storeId) {
$product->setStoreId($storeId);
}
@@ -308,8 +313,8 @@ private function getProductInstance(int $storeId = null): Product
/** @var Product $product */
$product = $this->objectManager->create(Product::class);
$product->setData(
- $this->metadata->getLinkField(),
- $this->getProduct()->getData($this->metadata->getLinkField())
+ $this->productLinkField,
+ $this->getProduct()->getData($this->productLinkField)
);
if ($storeId) {
From a5413163cb48d646220b5206f3462143dfdcda80 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Thu, 17 Oct 2019 16:28:11 +0300
Subject: [PATCH 0483/1978] MC-21654: View category on storefront
---
.../Catalog/Block/Category/TopMenuTest.php | 103 ++++++++++++++++++
.../Catalog/Controller/CategoryTest.php | 102 +++++++++++++----
.../Catalog/_files/inactive_category.php | 28 +++++
.../_files/inactive_category_rollback.php | 28 +++++
4 files changed, 238 insertions(+), 23 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Block/Category/TopMenuTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category_rollback.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Block/Category/TopMenuTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Block/Category/TopMenuTest.php
new file mode 100644
index 0000000000000..0dc8016c3ef8b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Category/TopMenuTest.php
@@ -0,0 +1,103 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->categoryFactory = $this->objectManager->create(CategoryFactory::class);
+ $this->categoryRepository = $this->objectManager->create(CategoryRepositoryInterface::class);
+ $this->block = $this->objectManager->get(LayoutInterface::class)->createBlock(Topmenu::class);
+ }
+
+ /**
+ * Checks menu item displaying.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/category.php
+ * @return void
+ */
+ public function testTopMenuItemDisplay(): void
+ {
+ $output = $this->block->getHtml('level-top', 'submenu', 0);
+ $this->assertContains('Category 1', $output);
+ }
+
+ /**
+ * Checks that menu item is not displayed if the category is disabled or include in menu is disabled.
+ *
+ * @dataProvider invisibilityDataProvider
+ * @param array $data
+ * @return void
+ */
+ public function testTopMenuItemInvisibility(array $data): void
+ {
+ $category = $this->categoryFactory->create();
+ $category->setData($data);
+ $this->categoryRepository->save($category);
+ $output = $this->block->getHtml('level-top', 'submenu', 0);
+ $this->assertEmpty($output, 'The category is displayed in top menu navigation');
+ }
+
+ /**
+ * @return array
+ */
+ public function invisibilityDataProvider(): array
+ {
+ return [
+ 'include_in_menu_disable' => [
+ 'data' => [
+ 'name' => 'Test Category',
+ 'path' => '1/2/',
+ 'is_active' => '1',
+ 'include_in_menu' => false,
+ ],
+ ],
+ 'category_disable' => [
+ 'data' => [
+ 'name' => 'Test Category 2',
+ 'path' => '1/2/',
+ 'is_active' => false,
+ 'include_in_menu' => true,
+ ],
+ ],
+ ];
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
index 87b8d4a117e2d..71763ef958a57 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
@@ -3,24 +3,65 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Controller;
+use Magento\Catalog\Model\Category;
+use Magento\Catalog\Model\Session;
+use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\Registry as Registry;
+use Magento\Framework\View\LayoutInterface;
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\TestCase\AbstractController;
+
/**
- * Test class for \Magento\Catalog\Controller\Category.
+ * Responsible for testing category view action on strorefront.
*
+ * @see \Magento\Catalog\Controller\Category\View
* @magentoAppArea frontend
*/
-class CategoryTest extends \Magento\TestFramework\TestCase\AbstractController
+class CategoryTest extends AbstractController
{
+ /** @var ObjectManagerInterface */
+ private $objectManager;
+
+ /** @var Registry */
+ private $registry;
+
+ /** @var Session */
+ private $session;
+
+ /** @var LayoutInterface */
+ private $layout;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->objectManager = Bootstrap::getObjectManager();
+ $this->registry = $this->objectManager->get(Registry::class);
+ $this->layout = $this->objectManager->get(LayoutInterface::class);
+ $this->session = $this->objectManager->get(Session::class);
+ }
+
+ /**
+ * @inheritdoc
+ */
public function assert404NotFound()
{
parent::assert404NotFound();
- /** @var $objectManager \Magento\TestFramework\ObjectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- $this->assertNull($objectManager->get(\Magento\Framework\Registry::class)->registry('current_category'));
+
+ $this->assertNull($this->registry->registry('current_category'));
}
- public function getViewActionDataProvider()
+ /**
+ * @return array
+ */
+ public function getViewActionDataProvider(): array
{
return [
'category without children' => [
@@ -56,51 +97,66 @@ public function getViewActionDataProvider()
* @dataProvider getViewActionDataProvider
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories_with_product_ids.php
* @magentoDbIsolation disabled
+ * @param int $categoryId
+ * @param array $expectedHandles
+ * @param array $expectedContent
+ * @return void
*/
- public function testViewAction($categoryId, array $expectedHandles, array $expectedContent)
+ public function testViewAction(int $categoryId, array $expectedHandles, array $expectedContent): void
{
$this->dispatch("catalog/category/view/id/{$categoryId}");
-
- /** @var $objectManager \Magento\TestFramework\ObjectManager */
- $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-
- /** @var $currentCategory \Magento\Catalog\Model\Category */
- $currentCategory = $objectManager->get(\Magento\Framework\Registry::class)->registry('current_category');
- $this->assertInstanceOf(\Magento\Catalog\Model\Category::class, $currentCategory);
+ /** @var $currentCategory Category */
+ $currentCategory = $this->registry->registry('current_category');
+ $this->assertInstanceOf(Category::class, $currentCategory);
$this->assertEquals($categoryId, $currentCategory->getId(), 'Category in registry.');
- $lastCategoryId = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
- \Magento\Catalog\Model\Session::class
- )->getLastVisitedCategoryId();
+ $lastCategoryId = $this->session->getLastVisitedCategoryId();
$this->assertEquals($categoryId, $lastCategoryId, 'Last visited category.');
/* Layout updates */
- $handles = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
- \Magento\Framework\View\LayoutInterface::class
- )->getUpdate()->getHandles();
+ $handles = $this->layout->getUpdate()->getHandles();
foreach ($expectedHandles as $expectedHandleName) {
$this->assertContains($expectedHandleName, $handles);
}
$responseBody = $this->getResponse()->getBody();
-
/* Response content */
foreach ($expectedContent as $expectedText) {
$this->assertStringMatchesFormat($expectedText, $responseBody);
}
}
- public function testViewActionNoCategoryId()
+ /**
+ * @return void
+ */
+ public function testViewActionNoCategoryId(): void
{
$this->dispatch('catalog/category/view/');
$this->assert404NotFound();
}
- public function testViewActionInactiveCategory()
+ /**
+ * @return void
+ */
+ public function testViewActionInactiveCategory(): void
{
$this->dispatch('catalog/category/view/id/8');
$this->assert404NotFound();
}
+
+ /**
+ * Checks that disabled category is not available in storefront
+ *
+ * @magentoDbIsolation disabled
+ * @magentoDataFixture Magento/Catalog/_files/inactive_category.php
+ * @return void
+ */
+ public function testViewActionDisabledCategory(): void
+ {
+ $this->dispatch('catalog/category/view/id/111');
+
+ $this->assert404NotFound();
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category.php
new file mode 100644
index 0000000000000..e604d4e9f061b
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category.php
@@ -0,0 +1,28 @@
+create(CategoryResource::class);
+/** @var Category $category */
+$category = $objectManager->get(CategoryFactory::class)->create();
+$category->isObjectNew(true);
+$data = [
+ 'entity_id' => 111,
+ 'path' => '1/2/111',
+ 'name' => 'Test Category',
+ 'attribute_set_id' => $category->getDefaultAttributeSetId(),
+ 'parent_id' => 2,
+ 'is_active' => false,
+ 'include_in_menu' => true,
+];
+$category->setData($data);
+$categoryResource->save($category);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category_rollback.php
new file mode 100644
index 0000000000000..706a0bd9d05b0
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/inactive_category_rollback.php
@@ -0,0 +1,28 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+/** @var CategoryRepositoryInterface $categoryRepository */
+$categoryRepository = $objectManager->get(CategoryRepositoryInterface::class);
+
+try {
+ $category = $categoryRepository->get(111);
+ $categoryRepository->delete($category);
+} catch (NoSuchEntityException $e) {
+ //category already removed
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From 22b4562b7c0b3640b3b69dbf358a325fa20b11e2 Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Fri, 18 Oct 2019 15:59:41 +0300
Subject: [PATCH 0484/1978] MC-21654: View category on storefront
---
.../testsuite/Magento/Catalog/Controller/CategoryTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
index 71763ef958a57..ca1fdb220b6a2 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
@@ -139,7 +139,7 @@ public function testViewActionNoCategoryId(): void
/**
* @return void
*/
- public function testViewActionInactiveCategory(): void
+ public function testViewActionNotExistingCategory(): void
{
$this->dispatch('catalog/category/view/id/8');
From ce37a79acf36fc5cd2bed0f37e1211325cb16c92 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Fri, 18 Oct 2019 16:26:38 +0300
Subject: [PATCH 0485/1978] MC-21715: Storefront: view product images
---
.../Block/Product/View/GalleryTest.php | 17 ++++-------
.../Model/Product/Gallery/ReadHandlerTest.php | 29 ++++++++++---------
2 files changed, 22 insertions(+), 24 deletions(-)
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
index bf6d081ce4316..d082f7751234b 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Block/Product/View/GalleryTest.php
@@ -7,8 +7,8 @@
namespace Magento\Catalog\Block\Product\View;
+use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\ProductRepositoryInterface;
-use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\Framework\View\LayoutInterface;
@@ -48,11 +48,6 @@ class GalleryTest extends \PHPUnit\Framework\TestCase
*/
private $serializer;
- /**
- * @var Product
- */
- private $product;
-
/**
* @var Gallery
*/
@@ -298,12 +293,12 @@ public function galleryImagesOnStoreViewDataProvider(): array
/**
* Updates product gallery images and saves product.
*
- * @param Product $product
+ * @param ProductInterface $product
* @param array $images
* @param int|null $storeId
* @return void
*/
- private function setGalleryImages(Product $product, array $images, int $storeId = null): void
+ private function setGalleryImages(ProductInterface $product, array $images, int $storeId = null): void
{
$product->setImage(null);
foreach ($images as $file => $data) {
@@ -334,11 +329,11 @@ private function setGalleryImages(Product $product, array $images, int $storeId
* Returns current product.
*
* @param int|null $storeId
- * @return Product
+ * @return ProductInterface
*/
- private function getProduct(int $storeId = null): Product
+ private function getProduct(?int $storeId = null): ProductInterface
{
- return $this->product = $this->productRepository->get('simple', false, $storeId, true);
+ return $this->productRepository->get('simple', false, $storeId, true);
}
/**
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
index b3b612d229e68..a59d47d64ebd2 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
@@ -8,8 +8,8 @@
namespace Magento\Catalog\Model\Product\Gallery;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\Data\ProductInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
-use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Store\Api\StoreRepositoryInterface;
@@ -37,6 +37,11 @@ class ReadHandlerTest extends \PHPUnit\Framework\TestCase
*/
private $productRepository;
+ /**
+ * @var ProductInterfaceFactory
+ */
+ private $productFactory;
+
/**
* @var ProductResource
*/
@@ -60,6 +65,7 @@ protected function setUp()
$this->objectManager = Bootstrap::getObjectManager();
$this->readHandler = $this->objectManager->create(ReadHandler::class);
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $this->productFactory = $this->objectManager->get(ProductInterfaceFactory::class);
$this->productResource = $this->objectManager->get(ProductResource::class);
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
$this->productLinkField = $this->objectManager->get(MetadataPool::class)
@@ -258,25 +264,22 @@ public function executeOnStoreViewDataProvider(): array
/**
* Returns product for testing.
*
- * @return Product
+ * @return ProductInterface
*/
- private function getProduct(): Product
+ private function getProduct(): ProductInterface
{
- /** @var Product $product */
- $product = $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID);
-
- return $product;
+ return $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID);
}
/**
* Updates product gallery images and saves product.
*
- * @param Product $product
+ * @param ProductInterface $product
* @param array $images
* @param int|null $storeId
* @return void
*/
- private function setGalleryImages(Product $product, array $images, int $storeId = null): void
+ private function setGalleryImages(ProductInterface $product, array $images, ?int $storeId = null): void
{
$product->setImage(null);
foreach ($images as $file => $data) {
@@ -306,12 +309,12 @@ private function setGalleryImages(Product $product, array $images, int $storeId
* Returns empty product instance.
*
* @param int|null $storeId
- * @return Product
+ * @return ProductInterface
*/
- private function getProductInstance(int $storeId = null): Product
+ private function getProductInstance(?int $storeId = null): ProductInterface
{
- /** @var Product $product */
- $product = $this->objectManager->create(Product::class);
+ /** @var ProductInterface $product */
+ $product = $this->productFactory->create();
$product->setData(
$this->productLinkField,
$this->getProduct()->getData($this->productLinkField)
From 7a78b66764245683396f27e087ea74d278ee4eaf Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Fri, 18 Oct 2019 08:49:38 -0500
Subject: [PATCH 0486/1978] MC-21897: Fatal error catalogpermissions_product
indexer does not exist during cron reindex
---
.../Framework/Mview/Test/Unit/ViewTest.php | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php
index c44c46acea45b..54f6351e9651c 100644
--- a/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php
+++ b/lib/internal/Magento/Framework/Mview/Test/Unit/ViewTest.php
@@ -51,7 +51,10 @@ protected function setUp()
['getView']
);
$this->actionFactoryMock = $this->createPartialMock(\Magento\Framework\Mview\ActionFactory::class, ['get']);
- $this->stateMock = $this->createPartialMock(\Magento\Indexer\Model\Mview\View\State::class, ['getViewId',
+ $this->stateMock = $this->createPartialMock(
+ \Magento\Indexer\Model\Mview\View\State::class,
+ [
+ 'getViewId',
'loadByView',
'getVersionId',
'setVersionId',
@@ -62,7 +65,8 @@ protected function setUp()
'setMode',
'save',
'__wakeup',
- ]);
+ ]
+ );
$this->changelogMock = $this->createPartialMock(
\Magento\Framework\Mview\View\Changelog::class,
['getViewId', 'setViewId', 'create', 'drop', 'getVersion', 'getList', 'clear']
@@ -182,11 +186,11 @@ public function testSubscribeWithException()
$this->changelogMock->expects($this->once())
->method('create')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () {
throw new \Exception();
}
- ));
+ );
$this->loadView();
$this->model->subscribe();
@@ -245,11 +249,11 @@ public function testUnsubscribeWithException()
$subscriptionMock = $this->createPartialMock(\Magento\Framework\Mview\View\Subscription::class, ['remove']);
$subscriptionMock->expects($this->exactly(1))
->method('remove')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function () {
throw new \Exception();
}
- ));
+ );
$this->subscriptionFactoryMock->expects($this->exactly(1))
->method('create')
->will($this->returnValue($subscriptionMock));
From 02438a7fbaffb193ceb6ab7281b1d20c86e5673b Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Fri, 18 Oct 2019 16:56:02 +0300
Subject: [PATCH 0487/1978] MC-20691: Admin: Update attribute set
---
.../TestFramework/Eav/Model/AttributeSet.php | 56 +++++
.../Adminhtml/Product/Set/UpdateTest.php | 229 ++++++++++++++++++
.../Modifier/Eav/AttributeSetGroupsTest.php | 121 +++++++++
...set_based_on_default_with_custom_group.php | 52 ++++
..._on_default_with_custom_group_rollback.php | 33 +++
.../product_with_test_attribute_set.php | 39 +++
...oduct_with_test_attribute_set_rollback.php | 30 +++
7 files changed, 560 insertions(+)
create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php
new file mode 100644
index 0000000000000..e933d43a84807
--- /dev/null
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php
@@ -0,0 +1,56 @@
+searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->attributeSetRepository = $attributeSetRepository;
+ }
+
+ /**
+ * Search and return attribute set by name.
+ *
+ * @param string $attributeSetName
+ * @return AttributeSetInterface|null
+ */
+ public function getAttributeSetByName(string $attributeSetName): ?AttributeSetInterface
+ {
+ $this->searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
+ $searchCriteria = $this->searchCriteriaBuilder->create();
+ $result = $this->attributeSetRepository->getList($searchCriteria);
+ $items = $result->getItems();
+
+ return array_pop($items);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
new file mode 100644
index 0000000000000..702188207ec6e
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
@@ -0,0 +1,229 @@
+json = $this->_objectManager->get(Json::class);
+ $this->attributeSetRepository = $this->_objectManager->get(AttributeSetRepositoryInterface::class);
+ $this->attributeManagement = $this->_objectManager->get(AttributeManagementInterface::class);
+ $this->attributeGroupCollectionFactory = $this->_objectManager->get(CollectionFactory::class);
+ $this->attributeSet = $this->_objectManager->get(AttributeSet::class);
+ }
+
+ /**
+ * Test that name of attribute set will update/change correctly.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default.php
+ *
+ * @magentoDbIsolation disabled
+ *
+ * @return void
+ */
+ public function testUpdateAttributeSetName(): void
+ {
+ $attributeSet = $this->attributeSet->getAttributeSetByName('new_attribute_set');
+ $currentAttrSetName = $attributeSet->getAttributeSetName();
+ $this->assertNotNull($attributeSet);
+ $postData = $this->prepareDataToRequest($attributeSet);
+ $updateName = 'New attribute set name';
+ $postData['attribute_set_name'] = $updateName;
+ $this->performRequest((int)$attributeSet->getAttributeSetId(), $postData);
+ $updatedAttributeSet = $this->attributeSetRepository->get((int)$attributeSet->getAttributeSetId());
+ $this->assertEquals($updateName, $updatedAttributeSet->getAttributeSetName());
+ $updatedAttributeSet->setAttributeSetName($currentAttrSetName);
+ $this->attributeSetRepository->save($updatedAttributeSet);
+ }
+
+ /**
+ * Test add new group to custom attribute set.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default.php
+ *
+ * @magentoDbIsolation disabled
+ *
+ * @return void
+ */
+ public function testUpdateAttributeSetWithNewGroup(): void
+ {
+ $currentAttrSet = $this->attributeSet->getAttributeSetByName('new_attribute_set');
+ $this->assertNotNull($currentAttrSet);
+ $attrSetId = (int)$currentAttrSet->getAttributeSetId();
+ $currentAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
+ $newGroupName = 'Test attribute group name';
+ $newGroupSortOrder = 11;
+ $postData = $this->prepareDataToRequest($currentAttrSet);
+ $postData['groups'][] = [
+ null,
+ $newGroupName,
+ $newGroupSortOrder,
+ ];
+ $this->performRequest($attrSetId, $postData);
+ $updatedAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
+ $diffGroups = array_diff_key($updatedAttrGroups, $currentAttrGroups);
+ $this->assertCount(1, $diffGroups);
+ /** @var AttributeGroupInterface $newGroup */
+ $newGroup = reset($diffGroups);
+ $this->assertEquals($newGroupName, $newGroup->getAttributeGroupName());
+ $this->assertEquals($newGroupSortOrder, $newGroup->getSortOrder());
+ }
+
+ /**
+ * Test delete custom group from custom attribute set.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
+ *
+ * @magentoDbIsolation disabled
+ *
+ * @return void
+ */
+ public function testDeleteCustomGroupFromCustomAttributeSet(): void
+ {
+ $testGroupName = 'Test attribute group name';
+ $currentAttrSet = $this->attributeSet->getAttributeSetByName('new_attribute_set');
+ $this->assertNotNull($currentAttrSet);
+ $attrSetId = (int)$currentAttrSet->getAttributeSetId();
+ $currentAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
+ $customGroup = null;
+ /** @var AttributeGroupInterface $attrGroup */
+ foreach ($currentAttrGroups as $attrGroup) {
+ if ($attrGroup->getAttributeGroupName() === $testGroupName) {
+ $customGroup = $attrGroup;
+ break;
+ }
+ }
+ $this->assertNotNull($customGroup);
+ $postData = $this->prepareDataToRequest($currentAttrSet);
+ $postData['removeGroups'] = [
+ $customGroup->getAttributeGroupId()
+ ];
+ $this->performRequest($attrSetId, $postData);
+ $updatedAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
+ $diffGroups = array_diff_key($currentAttrGroups, $updatedAttrGroups);
+ $this->assertCount(1, $diffGroups);
+ /** @var AttributeGroupInterface $deletedGroup */
+ $deletedGroup = reset($diffGroups);
+ $this->assertEquals($testGroupName, $deletedGroup->getAttributeGroupName());
+ }
+
+ /**
+ * Process attribute set save request.
+ *
+ * @param int $attributeSetId
+ * @param array $postData
+ * @return void
+ */
+ private function performRequest(int $attributeSetId, array $postData = []): void
+ {
+ $this->getRequest()->setMethod(HttpRequest::METHOD_POST);
+ $this->getRequest()->setPostValue(
+ 'data',
+ $this->json->serialize($postData)
+ );
+ $this->dispatch('backend/catalog/product_set/save/id/' . $attributeSetId);
+ }
+
+ /**
+ * Prepare default data to request from attribute set.
+ *
+ * @param AttributeSetInterface $attributeSet
+ * @return array
+ */
+ private function prepareDataToRequest(AttributeSetInterface $attributeSet): array
+ {
+ $result = [
+ 'attribute_set_name' => $attributeSet->getAttributeSetName(),
+ 'removeGroups' => [],
+ 'not_attributes' => [],
+ ];
+ $groups = $attributes = [];
+ /** @var AttributeGroupInterface $group */
+ foreach ($this->getAttributeSetGroupCollection((int)$attributeSet->getAttributeSetId()) as $group) {
+ $groups[] = [
+ $group->getAttributeGroupId(),
+ $group->getAttributeGroupName(),
+ $group->getSortOrder(),
+ ];
+ }
+ $attributeSetAttributes = $this->attributeManagement->getAttributes(
+ ProductAttributeInterface::ENTITY_TYPE_CODE,
+ $attributeSet->getAttributeSetId()
+ );
+ foreach ($attributeSetAttributes as $attribute) {
+ $attributes[] = [
+ $attribute->getAttributeId(),
+ $attribute->getAttributeGroupId(),
+ $attribute->getSortOrder(),
+ ];
+ }
+ $result['groups'] = $groups;
+ $result['attributes'] = $attributes;
+
+ return $result;
+ }
+
+ /**
+ * Build attribute set groups collection by attribute set id.
+ *
+ * @param int $attributeSetId
+ * @return Collection
+ */
+ private function getAttributeSetGroupCollection(int $attributeSetId): Collection
+ {
+ $groupCollection = $this->attributeGroupCollectionFactory->create();
+ $groupCollection->setAttributeSetFilter($attributeSetId);
+
+ return $groupCollection;
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
new file mode 100644
index 0000000000000..ebaf755876b10
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
@@ -0,0 +1,121 @@
+objectManager = Bootstrap::getObjectManager();
+ $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $store = $this->objectManager->get(StoreInterface::class);
+ $this->locatorMock = $this->createMock(LocatorInterface::class);
+ $this->locatorMock->expects($this->any())->method('getStore')->willReturn($store);
+ $this->formElement = $this->objectManager->create(
+ FormElement::class,
+ [
+ 'mappings' => [],
+ ]
+ );
+ $this->metaPropertiesMapper = $this->objectManager->create(
+ MetaProperties::class,
+ [
+ 'mappings' => [],
+ ]
+ );
+ $this->compositeConfigProcessor = $this->objectManager->create(
+ CompositeConfigProcessor::class,
+ [
+ 'eavWysiwygDataProcessors' => [],
+ ]
+ );
+ $this->productFormModifier = $this->objectManager->create(
+ Eav::class,
+ [
+ 'locator' => $this->locatorMock,
+ 'formElementMapper' => $this->formElement,
+ 'metaPropertiesMapper' => $this->metaPropertiesMapper,
+ 'wysiwygConfigProcessor' => $this->compositeConfigProcessor,
+ ]
+ );
+ parent::setUp();
+ }
+
+ /**
+ * Check that custom group fro custom attribute set not added to product form modifier meta data.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
+ * @magentoDataFixture Magento/Catalog/_files/product_with_test_attribute_set.php
+ *
+ * @magentoDbIsolation disabled
+ *
+ * @return void
+ */
+ public function testGroupDoesNotAddToProductFormMeta(): void
+ {
+ $product = $this->productRepository->get('simple');
+ $this->locatorMock->expects($this->any())->method('getProduct')->willReturn($product);
+ $meta = $this->productFormModifier->modifyMeta([]);
+ $this->assertArrayNotHasKey(
+ 'test-attribute-group-name',
+ $meta,
+ 'Attribute set group without attributes appear on product page in admin panel'
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
new file mode 100644
index 0000000000000..333f286277924
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
@@ -0,0 +1,52 @@
+get(AttributeSetRepositoryInterface::class);
+/** @var AttributeSetInterfaceFactory $attributeSetFactory */
+$attributeSetFactory = $objectManager->get(AttributeSetInterfaceFactory::class);
+/** @var Type $entityType */
+$entityType = $objectManager->create(Type::class)->loadByCode(ProductAttributeInterface::ENTITY_TYPE_CODE);
+/** @var ProductInterface $product */
+$product = $objectManager->create(ProductInterface::class);
+$attributeSet = $attributeSetFactory->create(
+ [
+ 'data' => [
+ 'id' => null,
+ 'attribute_set_name' => 'new_attribute_set',
+ 'entity_type_id' => $entityType->getId(),
+ 'sort_order' => 300,
+ ],
+ ]
+);
+$attributeSet->isObjectNew(true);
+$attributeSet->setHasDataChanges(true);
+$attributeSet->validate();
+$attributeSetRepository->save($attributeSet);
+$attributeSet->initFromSkeleton($product->getDefaultAttributeSetid());
+/** @var AttributeGroupInterface $newGroup */
+$newGroup = $objectManager->get(GroupFactory::class)->create();
+$newGroup->setId(null)
+ ->setAttributeGroupName('Test attribute group name')
+ ->setAttributeSetId($attributeSet->getAttributeSetId())
+ ->setSortOrder(11)
+ ->setAttributes([]);
+/** @var AttributeGroupInterface[] $groups */
+$groups = $attributeSet->getGroups();
+array_push($groups, $newGroup);
+$attributeSet->setGroups($groups);
+$attributeSetRepository->save($attributeSet);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
new file mode 100644
index 0000000000000..701a45e303589
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
@@ -0,0 +1,33 @@
+get(AttributeSetRepositoryInterface::class);
+/** @var Type $entityType */
+$entityType = $objectManager->create(Type::class)->loadByCode(ProductAttributeInterface::ENTITY_TYPE_CODE);
+/** @var Collection $attributeSetCollection */
+$attributeSetCollection = $objectManager->create(CollectionFactory::class)->create();
+$attributeSetCollection->addFilter('attribute_set_name', 'new_attribute_set');
+$attributeSetCollection->addFilter('entity_type_id', $entityType->getId());
+$attributeSetCollection->setOrder('attribute_set_id');
+$attributeSetCollection->setPageSize(1);
+$attributeSetCollection->load();
+/** @var AttributeSetInterface $attributeSet */
+$attributeSet = $attributeSetCollection->fetchItem();
+
+if ($attributeSet) {
+ $attributeSetRepository->delete($attributeSet);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
new file mode 100644
index 0000000000000..abc78d1c850ed
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
@@ -0,0 +1,39 @@
+get(ProductRepositoryInterface::class);
+/** @var ProductFactory $productFactory */
+$productFactory = $objectManager->get(ProductFactory::class);
+/** @var AttributeSet $attributeSet */
+$attributeSet = $objectManager->get(AttributeSet::class);
+$customAttributeSet = $attributeSet->getAttributeSetByName('new_attribute_set');
+$product = $productFactory->create();
+$product
+ ->setTypeId('simple')
+ ->setId(1)
+ ->setAttributeSetId($customAttributeSet->getAttributeSetId())
+ ->setWebsiteIds([1])
+ ->setName('Simple Product')
+ ->setSku('simple')
+ ->setPrice(10)
+ ->setMetaTitle('meta title')
+ ->setMetaKeyword('meta keyword')
+ ->setMetaDescription('meta description')
+ ->setVisibility(Visibility::VISIBILITY_BOTH)
+ ->setStatus(Status::STATUS_ENABLED)
+ ->setStockData(['use_config_manage_stock' => 1, 'qty' => 22, 'is_in_stock' => 1])
+ ->setQty(22);
+$productRepository->save($product);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
new file mode 100644
index 0000000000000..cef2f3ac75451
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
@@ -0,0 +1,30 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = $objectManager->get(ProductRepositoryInterface::class);
+/** @var StockRegistryStorage $stockRegistryStorage */
+$stockRegistryStorage = $objectManager->get(StockRegistryStorage::class);
+try {
+ $product = $productRepository->get('simple');
+ $productRepository->delete($product);
+} catch (\Exception $e) {
+
+}
+$stockRegistryStorage->clean();
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From 0eda742596238c112e2a1e7a4fcd4f39193533bc Mon Sep 17 00:00:00 2001
From: Roman Zhupanyn
Date: Fri, 18 Oct 2019 17:04:34 +0300
Subject: [PATCH 0488/1978] MC-20675: Admin: Add/edit/delete related, up-sells,
cross-sells products
---
.../Adminhtml/Product/Save/LinksTest.php | 65 +++++++++----------
.../Catalog/Model/Product/LinksTest.php | 12 +++-
2 files changed, 40 insertions(+), 37 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
index 791e45a22ca88..e6e11b1f5b432 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Model\Product;
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\TestCase\AbstractBackendController;
/**
@@ -42,17 +43,21 @@ protected function setUp()
/**
* Test add simple related, up-sells, cross-sells product
*
- * @dataProvider addRelatedUpSellCrossSellProductsProvider
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
* @magentoDbIsolation enabled
* @param array $postData
* @return void
*/
- public function testAddRelatedUpSellCrossSellProducts(array $postData): void
+ public function testAddRelatedUpSellCrossSellProducts(): void
{
+ $postData = $this->getPostData();
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($postData);
$this->dispatch('backend/catalog/product/save');
+ $this->assertSessionMessages(
+ $this->equalTo(['You saved the product.']),
+ MessageInterface::TYPE_SUCCESS
+ );
$product = $this->productRepository->get('simple');
$this->assertEquals(
$this->getExpectedLinks($postData['links']),
@@ -62,34 +67,30 @@ public function testAddRelatedUpSellCrossSellProducts(array $postData): void
}
/**
- * Provide test data for testAddRelatedUpSellCrossSellProducts().
+ * Get post data for the request
*
* @return array
*/
- public function addRelatedUpSellCrossSellProductsProvider(): array
+ public function getPostData(): array
{
return [
- [
- 'post_data' => [
- 'product' => [
- 'attribute_set_id' => '4',
- 'status' => '1',
- 'name' => 'Simple Product',
- 'sku' => 'simple',
- 'url_key' => 'simple-product',
- ],
- 'links' => [
- 'upsell' => [
- ['id' => '10'],
- ],
- 'crosssell' => [
- ['id' => '11'],
- ],
- 'related' => [
- ['id' => '12'],
- ],
- ]
- ]
+ 'product' => [
+ 'attribute_set_id' => '4',
+ 'status' => '1',
+ 'name' => 'Simple Product',
+ 'sku' => 'simple',
+ 'url_key' => 'simple-product',
+ ],
+ 'links' => [
+ 'upsell' => [
+ ['id' => '10'],
+ ],
+ 'crosssell' => [
+ ['id' => '11'],
+ ],
+ 'related' => [
+ ['id' => '12'],
+ ],
]
];
}
@@ -123,23 +124,19 @@ private function getActualLinks(ProductInterface $product): array
{
$actualLinks = [];
foreach ($this->linkTypes as $linkType) {
- $products = [];
- $actualLinks[$linkType] = [];
+ $ids = [];
switch ($linkType) {
case 'upsell':
- $products = $product->getUpSellProducts();
+ $ids = $product->getUpSellProductIds();
break;
case 'crosssell':
- $products = $product->getCrossSellProducts();
+ $ids = $product->getCrossSellProductIds();
break;
case 'related':
- $products = $product->getRelatedProducts();
+ $ids = $product->getRelatedProductIds();
break;
}
- /** @var ProductInterface|Product $productItem */
- foreach ($products as $productItem) {
- $actualLinks[$linkType][] = $productItem->getId();
- }
+ $actualLinks[$linkType] = $ids;
}
return $actualLinks;
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
index 19fce2abe2aff..b8be34f460dcb 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/LinksTest.php
@@ -9,6 +9,7 @@
use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Catalog\Api\Data\ProductLinkInterface;
+use Magento\Catalog\Api\Data\ProductLinkInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ProductLink\Link;
@@ -62,7 +63,7 @@ class LinksTest extends TestCase
],
];
- /** @var ProductRepositoryInterface $productRepository */
+ /** @var ProductRepositoryInterface */
private $productRepository;
/** @var ObjectManager */
@@ -71,6 +72,9 @@ class LinksTest extends TestCase
/** @var ProductResource */
private $productResource;
+ /** @var ProductLinkInterfaceFactory */
+ private $productLinkInterfaceFactory;
+
/**
* @inheritdoc
*/
@@ -80,6 +84,7 @@ protected function setUp()
$this->objectManager = Bootstrap::getObjectManager();
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$this->productResource = $this->objectManager->create(ProductResource::class);
+ $this->productLinkInterfaceFactory = $this->objectManager->create(ProductLinkInterfaceFactory::class);
}
/**
@@ -203,14 +208,15 @@ private function getProductData(array $productFixture): array
*
* @param ProductInterface|Product $product
* @param array $productData
+ * @return void
*/
private function setCustomProductLinks(ProductInterface $product, array $productData): void
{
$productLinks = [];
foreach ($productData as $linkType => $links) {
foreach ($links as $data) {
- /** @var Link $productLink */
- $productLink = $this->objectManager->create(ProductLinkInterface::class);
+ /** @var ProductLinkInterface|Link $productLink */
+ $productLink = $this->productLinkInterfaceFactory->create();
$productLink->setSku('simple');
$productLink->setLinkedProductSku($data['sku']);
if (isset($data['position'])) {
From b02c84836ba8b1a35fc88f2bec55f9aa3f18d13c Mon Sep 17 00:00:00 2001
From: Yurii Sapiha
Date: Fri, 18 Oct 2019 17:06:26 +0300
Subject: [PATCH 0489/1978] MC-21654: View category on storefront
---
.../testsuite/Magento/Catalog/Controller/CategoryTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
index ca1fdb220b6a2..c0b7e8831a627 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/CategoryTest.php
@@ -149,7 +149,7 @@ public function testViewActionNotExistingCategory(): void
/**
* Checks that disabled category is not available in storefront
*
- * @magentoDbIsolation disabled
+ * @magentoDbIsolation enabled
* @magentoDataFixture Magento/Catalog/_files/inactive_category.php
* @return void
*/
From dabb9078a3f99020ebf4a0ef1747532a8fd2f90c Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Fri, 18 Oct 2019 17:53:57 +0300
Subject: [PATCH 0490/1978] MC-20691: Admin: Update attribute set
---
.../Controller/Adminhtml/Product/Set/UpdateTest.php | 13 +++++++++++++
.../Form/Modifier/Eav/AttributeSetGroupsTest.php | 2 +-
.../_files/product_with_test_attribute_set.php | 4 ++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
index 702188207ec6e..70b0ea66ea549 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
@@ -15,6 +15,7 @@
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\Collection;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Group\CollectionFactory;
use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Serialize\Serializer\Json;
use Magento\TestFramework\Eav\Model\AttributeSet;
use Magento\TestFramework\TestCase\AbstractBackendController;
@@ -80,6 +81,10 @@ public function testUpdateAttributeSetName(): void
$updateName = 'New attribute set name';
$postData['attribute_set_name'] = $updateName;
$this->performRequest((int)$attributeSet->getAttributeSetId(), $postData);
+ $this->assertSessionMessages(
+ $this->equalTo([(string)__('You saved the attribute set.')]),
+ MessageInterface::TYPE_SUCCESS
+ );
$updatedAttributeSet = $this->attributeSetRepository->get((int)$attributeSet->getAttributeSetId());
$this->assertEquals($updateName, $updatedAttributeSet->getAttributeSetName());
$updatedAttributeSet->setAttributeSetName($currentAttrSetName);
@@ -110,6 +115,10 @@ public function testUpdateAttributeSetWithNewGroup(): void
$newGroupSortOrder,
];
$this->performRequest($attrSetId, $postData);
+ $this->assertSessionMessages(
+ $this->equalTo([(string)__('You saved the attribute set.')]),
+ MessageInterface::TYPE_SUCCESS
+ );
$updatedAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
$diffGroups = array_diff_key($updatedAttrGroups, $currentAttrGroups);
$this->assertCount(1, $diffGroups);
@@ -149,6 +158,10 @@ public function testDeleteCustomGroupFromCustomAttributeSet(): void
$customGroup->getAttributeGroupId()
];
$this->performRequest($attrSetId, $postData);
+ $this->assertSessionMessages(
+ $this->equalTo([(string)__('You saved the attribute set.')]),
+ MessageInterface::TYPE_SUCCESS
+ );
$updatedAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
$diffGroups = array_diff_key($currentAttrGroups, $updatedAttrGroups);
$this->assertCount(1, $diffGroups);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
index ebaf755876b10..152f826e5969f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
@@ -98,7 +98,7 @@ protected function setUp()
}
/**
- * Check that custom group fro custom attribute set not added to product form modifier meta data.
+ * Check that custom group for custom attribute set not added to product form modifier meta data.
*
* @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
* @magentoDataFixture Magento/Catalog/_files/product_with_test_attribute_set.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
index abc78d1c850ed..31fdc4bc704b9 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
@@ -11,8 +11,11 @@
use Magento\Catalog\Model\ProductFactory;
use Magento\TestFramework\Eav\Model\AttributeSet;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Store\Model\StoreManagerInterface;
$objectManager = Bootstrap::getObjectManager();
+/** @var StoreManagerInterface $storeManager */
+$storeManager = $objectManager->get(StoreManagerInterface::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
/** @var ProductFactory $productFactory */
@@ -26,6 +29,7 @@
->setId(1)
->setAttributeSetId($customAttributeSet->getAttributeSetId())
->setWebsiteIds([1])
+ ->setStoreId($storeManager->getStore('admin')->getId())
->setName('Simple Product')
->setSku('simple')
->setPrice(10)
From c51fa5eb1b004c209c8466e5b56ab905c6ceee36 Mon Sep 17 00:00:00 2001
From: Mastiuhin Olexandr
Date: Fri, 18 Oct 2019 18:32:25 +0300
Subject: [PATCH 0491/1978] MC-20387: Coupon code for Free shipping is not
displayed unlike other coupon codes
---
...elDescriptionInOrderSummaryActionGroup.xml | 22 ++++
.../Mftf/ActionGroup/CheckoutActionGroup.xml | 9 ++
.../Section/CheckoutOrderSummarySection.xml | 1 +
.../frontend/web/js/view/summary/shipping.js | 33 +++++-
.../Magento/Sales/Block/Adminhtml/Totals.php | 84 ++++++---------
app/code/Magento/Sales/Block/Order/Totals.php | 40 ++++---
...ppingDescriptionInOrderViewActionGroup.xml | 22 ++++
...ppingDescriptionInOrderViewActionGroup.xml | 22 ++++
.../Mftf/Section/AdminOrderTotalSection.xml | 1 +
.../Section/StorefrontOrderDetailsSection.xml | 1 +
...frontCartRuleCouponForFreeShippingTest.xml | 100 ++++++++++++++++++
.../Magento/Tax/Block/Sales/Order/Tax.php | 28 ++++-
.../checkout/cart/totals/shipping.html | 12 +++
.../template/checkout/summary/shipping.html | 12 +++
14 files changed, 318 insertions(+), 69 deletions(-)
create mode 100644 app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontShippingLabelDescriptionInOrderSummaryActionGroup.xml
create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminShippingDescriptionInOrderViewActionGroup.xml
create mode 100644 app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertStorefrontShippingDescriptionInOrderViewActionGroup.xml
create mode 100644 app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartRuleCouponForFreeShippingTest.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontShippingLabelDescriptionInOrderSummaryActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontShippingLabelDescriptionInOrderSummaryActionGroup.xml
new file mode 100644
index 0000000000000..6a8efdb507c3e
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/AssertStorefrontShippingLabelDescriptionInOrderSummaryActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Validates that the Shipping label description is present and correct.
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
index 66f8ed541ffd9..492ec8490ca48 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
@@ -171,6 +171,15 @@
+
+
+
+ Clicks next on Checkout Shipping step
+
+
+
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutOrderSummarySection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutOrderSummarySection.xml
index d3ad2aed96946..bcf8a8ee8d95a 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutOrderSummarySection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutOrderSummarySection.xml
@@ -19,5 +19,6 @@
+
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js b/app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js
index 10d49265e3bb9..22e278bea947e 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/view/summary/shipping.js
@@ -6,8 +6,9 @@
define([
'jquery',
'Magento_Checkout/js/view/summary/abstract-total',
- 'Magento_Checkout/js/model/quote'
-], function ($, Component, quote) {
+ 'Magento_Checkout/js/model/quote',
+ 'Magento_SalesRule/js/view/summary/discount'
+], function ($, Component, quote, discountView) {
'use strict';
return Component.extend({
@@ -57,6 +58,34 @@ define([
price = this.totals()['shipping_amount'];
return this.getFormattedPrice(price);
+ },
+
+ /**
+ * If is set coupon code, but there wasn't displayed discount view.
+ *
+ * @return {Boolean}
+ */
+ haveToShowCoupon: function () {
+ var couponCode = this.totals()['coupon_code'];
+
+ if (typeof couponCode === 'undefined') {
+ couponCode = false;
+ }
+
+ return couponCode && !discountView().isDisplayed();
+ },
+
+ /**
+ * Returns coupon code description.
+ *
+ * @return {String}
+ */
+ getCouponDescription: function () {
+ if (!this.haveToShowCoupon()) {
+ return '';
+ }
+
+ return '(' + this.totals()['coupon_code'] + ')';
}
});
});
diff --git a/app/code/Magento/Sales/Block/Adminhtml/Totals.php b/app/code/Magento/Sales/Block/Adminhtml/Totals.php
index 8172a3c0db4ad..68843952035c8 100644
--- a/app/code/Magento/Sales/Block/Adminhtml/Totals.php
+++ b/app/code/Magento/Sales/Block/Adminhtml/Totals.php
@@ -5,7 +5,7 @@
*/
namespace Magento\Sales\Block\Adminhtml;
-use Magento\Sales\Model\Order;
+use Magento\Framework\DataObject;
/**
* Adminhtml sales totals block
@@ -57,60 +57,65 @@ public function formatValue($total)
protected function _initTotals()
{
$this->_totals = [];
- $this->_totals['subtotal'] = new \Magento\Framework\DataObject(
+ $order = $this->getSource();
+
+ $this->_totals['subtotal'] = new DataObject(
[
'code' => 'subtotal',
- 'value' => $this->getSource()->getSubtotal(),
- 'base_value' => $this->getSource()->getBaseSubtotal(),
+ 'value' => $order->getSubtotal(),
+ 'base_value' => $order->getBaseSubtotal(),
'label' => __('Subtotal'),
]
);
/**
- * Add shipping
+ * Add discount
*/
- if (!$this->getSource()->getIsVirtual() && ((double)$this->getSource()->getShippingAmount() ||
- $this->getSource()->getShippingDescription())
- ) {
- $shippingLabel = __('Shipping & Handling');
- if ($this->isFreeShipping($this->getOrder()) && $this->getSource()->getDiscountDescription()) {
- $shippingLabel .= sprintf(' (%s)', $this->getSource()->getDiscountDescription());
+ if ((double)$order->getDiscountAmount() != 0) {
+ if ($order->getDiscountDescription()) {
+ $discountLabel = __('Discount (%1)', $order->getDiscountDescription());
+ } else {
+ $discountLabel = __('Discount');
}
- $this->_totals['shipping'] = new \Magento\Framework\DataObject(
+ $this->_totals['discount'] = new DataObject(
[
- 'code' => 'shipping',
- 'value' => $this->getSource()->getShippingAmount(),
- 'base_value' => $this->getSource()->getBaseShippingAmount(),
- 'label' => $shippingLabel,
+ 'code' => 'discount',
+ 'value' => $order->getDiscountAmount(),
+ 'base_value' => $order->getBaseDiscountAmount(),
+ 'label' => $discountLabel,
]
);
}
/**
- * Add discount
+ * Add shipping
*/
- if ((double)$this->getSource()->getDiscountAmount() != 0) {
- if ($this->getSource()->getDiscountDescription()) {
- $discountLabel = __('Discount (%1)', $this->getSource()->getDiscountDescription());
- } else {
- $discountLabel = __('Discount');
+ if (!$order->getIsVirtual()
+ && ((double)$order->getShippingAmount()
+ || $order->getShippingDescription())
+ ) {
+ $shippingLabel = __('Shipping & Handling');
+
+ if ($order->getCouponCode() && !isset($this->_totals['discount'])) {
+ $shippingLabel .= " ({$order->getCouponCode()})";
}
- $this->_totals['discount'] = new \Magento\Framework\DataObject(
+
+ $this->_totals['shipping'] = new DataObject(
[
- 'code' => 'discount',
- 'value' => $this->getSource()->getDiscountAmount(),
- 'base_value' => $this->getSource()->getBaseDiscountAmount(),
- 'label' => $discountLabel,
+ 'code' => 'shipping',
+ 'value' => $order->getShippingAmount(),
+ 'base_value' => $order->getBaseShippingAmount(),
+ 'label' => $shippingLabel,
]
);
}
- $this->_totals['grand_total'] = new \Magento\Framework\DataObject(
+ $this->_totals['grand_total'] = new DataObject(
[
'code' => 'grand_total',
'strong' => true,
- 'value' => $this->getSource()->getGrandTotal(),
- 'base_value' => $this->getSource()->getBaseGrandTotal(),
+ 'value' => $order->getGrandTotal(),
+ 'base_value' => $order->getBaseGrandTotal(),
'label' => __('Grand Total'),
'area' => 'footer',
]
@@ -118,23 +123,4 @@ protected function _initTotals()
return $this;
}
-
- /**
- * Availability of free shipping in at least one order item
- *
- * @param Order $order
- * @return bool
- */
- private function isFreeShipping(Order $order): bool
- {
- $isFreeShipping = false;
- foreach ($order->getItems() as $orderItem) {
- if ($orderItem->getFreeShipping() == '1') {
- $isFreeShipping = true;
- break;
- }
- }
-
- return $isFreeShipping;
- }
}
diff --git a/app/code/Magento/Sales/Block/Order/Totals.php b/app/code/Magento/Sales/Block/Order/Totals.php
index 3720db76b5778..80ce5e2e689c6 100644
--- a/app/code/Magento/Sales/Block/Order/Totals.php
+++ b/app/code/Magento/Sales/Block/Order/Totals.php
@@ -8,6 +8,8 @@
use Magento\Sales\Model\Order;
/**
+ * Order totals.
+ *
* @api
* @since 100.0.2
*/
@@ -85,6 +87,8 @@ public function getOrder()
}
/**
+ * Sets order.
+ *
* @param Order $order
* @return $this
*/
@@ -118,20 +122,6 @@ protected function _initTotals()
['code' => 'subtotal', 'value' => $source->getSubtotal(), 'label' => __('Subtotal')]
);
- /**
- * Add shipping
- */
- if (!$source->getIsVirtual() && ((double)$source->getShippingAmount() || $source->getShippingDescription())) {
- $this->_totals['shipping'] = new \Magento\Framework\DataObject(
- [
- 'code' => 'shipping',
- 'field' => 'shipping_amount',
- 'value' => $this->getSource()->getShippingAmount(),
- 'label' => __('Shipping & Handling'),
- ]
- );
- }
-
/**
* Add discount
*/
@@ -151,6 +141,25 @@ protected function _initTotals()
);
}
+ /**
+ * Add shipping
+ */
+ if (!$source->getIsVirtual() && ((double)$source->getShippingAmount() || $source->getShippingDescription())) {
+ $label = __('Shipping & Handling');
+ if ($this->getSource()->getCouponCode() && !isset($this->_totals['discount'])) {
+ $label = __('Shipping & Handling (%1)', $this->getSource()->getCouponCode());
+ }
+
+ $this->_totals['shipping'] = new \Magento\Framework\DataObject(
+ [
+ 'code' => 'shipping',
+ 'field' => 'shipping_amount',
+ 'value' => $this->getSource()->getShippingAmount(),
+ 'label' => $label,
+ ]
+ );
+ }
+
$this->_totals['grand_total'] = new \Magento\Framework\DataObject(
[
'code' => 'grand_total',
@@ -286,7 +295,6 @@ public function removeTotal($code)
* $totalCode => $totalSortOrder
* )
*
- *
* @param array $order
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
@@ -303,7 +311,7 @@ function ($code1, $code2) use ($order) {
}
/**
- * get totals array for visualization
+ * Get totals array for visualization
*
* @param array|null $area
* @return array
diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminShippingDescriptionInOrderViewActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminShippingDescriptionInOrderViewActionGroup.xml
new file mode 100644
index 0000000000000..1e4c0a958b2e4
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertAdminShippingDescriptionInOrderViewActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Validates that the Shipping Description will shown in Shipping total description.
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertStorefrontShippingDescriptionInOrderViewActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertStorefrontShippingDescriptionInOrderViewActionGroup.xml
new file mode 100644
index 0000000000000..27e91883eb15c
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AssertStorefrontShippingDescriptionInOrderViewActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Validates that the Shipping Description will shown in Shipping total description.
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml
index 9b7356127df69..eb9c32d6ced9f 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderTotalSection.xml
@@ -11,6 +11,7 @@
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/StorefrontOrderDetailsSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/StorefrontOrderDetailsSection.xml
index c255e15cd6ecf..d262dfa9b010c 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/StorefrontOrderDetailsSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/StorefrontOrderDetailsSection.xml
@@ -12,6 +12,7 @@
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartRuleCouponForFreeShippingTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartRuleCouponForFreeShippingTest.xml
new file mode 100644
index 0000000000000..9e95e39e4791e
--- /dev/null
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/StorefrontCartRuleCouponForFreeShippingTest.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ 0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Tax/Block/Sales/Order/Tax.php b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
index 0adaec9311ee6..05ef4eaf92c16 100644
--- a/app/code/Magento/Tax/Block/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
@@ -214,6 +214,7 @@ protected function _initSubtotal()
protected function _initShipping()
{
$store = $this->getStore();
+ /** @var \Magento\Sales\Block\Order\Totals $parent */
$parent = $this->getParentBlock();
$shipping = $parent->getTotal('shipping');
if (!$shipping) {
@@ -232,12 +233,14 @@ protected function _initShipping()
$baseShippingIncl = $baseShipping + (double)$this->_source->getBaseShippingTaxAmount();
}
+ $couponDescription = $this->getCouponDescription();
+
$totalExcl = new \Magento\Framework\DataObject(
[
'code' => 'shipping',
'value' => $shipping,
'base_value' => $baseShipping,
- 'label' => __('Shipping & Handling (Excl.Tax)'),
+ 'label' => __('Shipping & Handling (Excl.Tax)') . $couponDescription,
]
);
$totalIncl = new \Magento\Framework\DataObject(
@@ -245,7 +248,7 @@ protected function _initShipping()
'code' => 'shipping_incl',
'value' => $shippingIncl,
'base_value' => $baseShippingIncl,
- 'label' => __('Shipping & Handling (Incl.Tax)'),
+ 'label' => __('Shipping & Handling (Incl.Tax)') . $couponDescription,
]
);
$parent->addTotal($totalExcl, 'shipping');
@@ -355,4 +358,25 @@ public function getValueProperties()
{
return $this->getParentBlock()->getValueProperties();
}
+
+ /**
+ * Returns additional information about coupon code if it is not displayed in totals.
+ *
+ * @return string
+ */
+ private function getCouponDescription(): string
+ {
+ $couponDescription = "";
+
+ /** @var \Magento\Sales\Block\Order\Totals $parent */
+ $parent = $this->getParentBlock();
+ $couponCode = $parent->getSource()
+ ->getCouponCode();
+
+ if ($couponCode && !$parent->getTotal('discount')) {
+ $couponDescription = " ({$couponCode})";
+ }
+
+ return $couponDescription;
+ }
}
diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/cart/totals/shipping.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/cart/totals/shipping.html
index 9f8574a9438d1..269b447cfe66e 100644
--- a/app/code/Magento/Tax/view/frontend/web/template/checkout/cart/totals/shipping.html
+++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/cart/totals/shipping.html
@@ -9,6 +9,9 @@
+
+
+
@@ -19,6 +22,9 @@
+
+
+
@@ -31,6 +37,9 @@
+
+
+
@@ -43,6 +52,9 @@
+
+
+
diff --git a/app/code/Magento/Tax/view/frontend/web/template/checkout/summary/shipping.html b/app/code/Magento/Tax/view/frontend/web/template/checkout/summary/shipping.html
index 007e7ded68210..82ab993bb63eb 100644
--- a/app/code/Magento/Tax/view/frontend/web/template/checkout/summary/shipping.html
+++ b/app/code/Magento/Tax/view/frontend/web/template/checkout/summary/shipping.html
@@ -9,6 +9,9 @@
+
+
+
@@ -25,6 +28,9 @@
+
+
+
@@ -43,6 +49,9 @@
+
+
+
@@ -61,6 +70,9 @@
+
+
+
From 8aafc695c751fdb785041a6654f63ca5ca2aadd2 Mon Sep 17 00:00:00 2001
From: Eden
Date: Fri, 18 Oct 2019 23:13:22 +0700
Subject: [PATCH 0492/1978] Resolve "Redirect to CMS-page if Cookies are
Disabled" is "No" but it still redirect issue25148
---
.../Magento/Cookie/Block/RequireCookie.php | 12 +++++++++--
app/code/Magento/Cookie/i18n/en_US.csv | 2 ++
.../view/frontend/web/js/require-cookie.js | 20 +++++++++++++++----
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Cookie/Block/RequireCookie.php b/app/code/Magento/Cookie/Block/RequireCookie.php
index 0a836e5441540..29846e6e1f153 100644
--- a/app/code/Magento/Cookie/Block/RequireCookie.php
+++ b/app/code/Magento/Cookie/Block/RequireCookie.php
@@ -3,15 +3,20 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-
+declare(strict_types=1);
/**
* Frontend form key content block
*/
namespace Magento\Cookie\Block;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+
/**
* @api
* @since 100.0.2
+ *
+ * Class \Magento\Cookie\Block\RequireCookie
*/
class RequireCookie extends \Magento\Framework\View\Element\Template
{
@@ -22,9 +27,12 @@ class RequireCookie extends \Magento\Framework\View\Element\Template
*/
public function getScriptOptions()
{
+ $isRedirectCmsPage = ObjectManager::getInstance()->get(ScopeConfigInterface::class)
+ ->getValue('web/browser_capabilities/cookies');
$params = [
'noCookieUrl' => $this->escapeUrl($this->getUrl('cookie/index/noCookies/')),
- 'triggers' => $this->escapeHtml($this->getTriggers())
+ 'triggers' => $this->escapeHtml($this->getTriggers()),
+ 'isRedirectCmsPage' => (boolean)$isRedirectCmsPage
];
return json_encode($params);
}
diff --git a/app/code/Magento/Cookie/i18n/en_US.csv b/app/code/Magento/Cookie/i18n/en_US.csv
index 09424c22833fe..7fc98c0ad4c58 100644
--- a/app/code/Magento/Cookie/i18n/en_US.csv
+++ b/app/code/Magento/Cookie/i18n/en_US.csv
@@ -11,3 +11,5 @@
"Cookie Domain","Cookie Domain"
"Use HTTP Only","Use HTTP Only"
"Cookie Restriction Mode","Cookie Restriction Mode"
+"Cookies are disabled in your browser.","Cookies are disabled in your browser."
+
diff --git a/app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js b/app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js
index 0a175136f034e..e82d7f2af29ca 100644
--- a/app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js
+++ b/app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js
@@ -8,15 +8,19 @@
*/
define([
'jquery',
- 'jquery-ui-modules/widget'
-], function ($) {
+ 'Magento_Ui/js/modal/alert',
+ 'jquery-ui-modules/widget',
+ 'mage/mage',
+ 'mage/translate'
+], function ($, alert) {
'use strict';
$.widget('mage.requireCookie', {
options: {
event: 'click',
noCookieUrl: 'enable-cookies',
- triggers: ['.action.login', '.action.submit']
+ triggers: ['.action.login', '.action.submit'],
+ isRedirectCmsPage: true
},
/**
@@ -49,8 +53,16 @@ define([
if (navigator.cookieEnabled) {
return;
}
+
event.preventDefault();
- window.location = this.options.noCookieUrl;
+
+ if (this.options.isRedirectCmsPage) {
+ window.location = this.options.noCookieUrl;
+ } else {
+ alert({
+ content: $.mage.__('Cookies are disabled in your browser.')
+ });
+ }
}
});
From e18562217158ecf1e77b914db05e57c8dc6419a6 Mon Sep 17 00:00:00 2001
From: Eden
Date: Fri, 18 Oct 2019 23:41:07 +0700
Subject: [PATCH 0493/1978] Fix static test issue 25148
---
app/code/Magento/Cookie/Block/RequireCookie.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Cookie/Block/RequireCookie.php b/app/code/Magento/Cookie/Block/RequireCookie.php
index 29846e6e1f153..08228adba694e 100644
--- a/app/code/Magento/Cookie/Block/RequireCookie.php
+++ b/app/code/Magento/Cookie/Block/RequireCookie.php
@@ -13,6 +13,8 @@
use Magento\Framework\App\Config\ScopeConfigInterface;
/**
+ * Block Require Cookie
+ *
* @api
* @since 100.0.2
*
From 33c7de98bbc6f1baa6c9d1712b6a7e6d94a506ad Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Fri, 18 Oct 2019 19:52:53 +0300
Subject: [PATCH 0494/1978] Fixes for PHPCS
---
.../Attribute/Backend/GroupPrice/AbstractGroupPrice.php | 4 ++++
.../Framework/App/ObjectManager/ConfigLoader/Compiled.php | 8 ++++----
lib/internal/Magento/Framework/Module/Dir.php | 3 +++
.../Magento/Framework/Phrase/Renderer/Translate.php | 3 +++
.../Magento/Framework/View/Element/AbstractBlock.php | 3 +++
5 files changed, 17 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
index d301cc7b63c52..68aeabfc70d34 100644
--- a/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
+++ b/app/code/Magento/Catalog/Model/Product/Attribute/Backend/GroupPrice/AbstractGroupPrice.php
@@ -186,6 +186,7 @@ public function validate($object)
}
$compare = implode(
'-',
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge(
[$priceRow['website_id'], $priceRow['cust_group']],
$this->_getAdditionalUniqueFields($priceRow)
@@ -209,6 +210,7 @@ public function validate($object)
if ($price['website_id'] == 0) {
$compare = implode(
'-',
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge(
[$price['website_id'], $price['cust_group']],
$this->_getAdditionalUniqueFields($price)
@@ -233,6 +235,7 @@ public function validate($object)
$globalCompare = implode(
'-',
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
array_merge([0, $priceRow['cust_group']], $this->_getAdditionalUniqueFields($priceRow))
);
$websiteCurrency = $rates[$priceRow['website_id']]['code'];
@@ -278,6 +281,7 @@ public function preparePriceData(array $priceData, $productTypeId, $websiteId)
if (!array_filter($v)) {
continue;
}
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge
$key = implode('-', array_merge([$v['cust_group']], $this->_getAdditionalUniqueFields($v)));
if ($v['website_id'] == $websiteId) {
$data[$key] = $v;
diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
index 1dec1666d526a..5fc668e2d9c5e 100644
--- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
+++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
@@ -1,6 +1,5 @@
Date: Fri, 18 Oct 2019 12:16:50 -0500
Subject: [PATCH 0495/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../CatalogRule/Model/Indexer/IndexBuilder.php | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index ca5fc0090b4ed..207bacd03bebc 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -290,7 +290,10 @@ protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
- $products = $this->productLoader->getProducts($ids);
+ $products = [];
+ foreach ($this->productLoader->getProducts($ids) as $product) {
+ $products[$product->getId()] = $product;
+ }
/** @var Rule[] $activeRules */
$activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
@@ -299,14 +302,13 @@ protected function doReindexByIds($ids)
continue;
}
+ $rule->setProductsFilter(array_keys($products));
+ $matchingProductIds = $rule->getMatchingProductIds();
if (!is_array($ruleWebsiteIds)) {
$ruleWebsiteIds = explode(',', $ruleWebsiteIds);
}
- foreach ($products as $product) {
- if (!$rule->validate($product)) {
- continue;
- }
-
+ foreach ($matchingProductIds as $matchingProductId => $validationByWebsite) {
+ $product = $products[$matchingProductId];
$websiteIds = array_intersect($product->getWebsiteIds(), $ruleWebsiteIds);
$this->assignProductToRule($rule, $product->getId(), $websiteIds);
}
From 9f5c8ad2aa259e8747628c8280295fc2f3aa1c77 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 18 Oct 2019 13:19:56 -0500
Subject: [PATCH 0496/1978] MC-21882: Product url_key not updating on
duplicating
- Fix a case when url_key for store view is equal to value from default store
---
.../Model/Attribute/ScopeOverriddenValue.php | 2 +-
.../Magento/Catalog/Model/Product/Copier.php | 32 ++++++++----
.../Test/Unit/Model/Product/CopierTest.php | 11 +++-
.../Catalog/Model/Product/CopierTest.php | 47 +++++++++++++++++
...product_simple_multistore_with_url_key.php | 50 +++++++++++++++++++
...imple_multistore_with_url_key_rollback.php | 22 ++++++++
6 files changed, 151 insertions(+), 13 deletions(-)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php
diff --git a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php
index 0940ca7a234a3..80674d09cab1c 100644
--- a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php
+++ b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php
@@ -81,7 +81,7 @@ public function containsValue($entityType, $entity, $attributeCode, $storeId)
if ((int)$storeId === Store::DEFAULT_STORE_ID) {
return false;
}
- if ($this->attributesValues === null) {
+ if (!isset($this->attributesValues[$storeId])) {
$this->initAttributeValues($entityType, $entity, (int)$storeId);
}
diff --git a/app/code/Magento/Catalog/Model/Product/Copier.php b/app/code/Magento/Catalog/Model/Product/Copier.php
index 44ebdf0f1f283..a7f7bad1a5167 100644
--- a/app/code/Magento/Catalog/Model/Product/Copier.php
+++ b/app/code/Magento/Catalog/Model/Product/Copier.php
@@ -6,7 +6,9 @@
namespace Magento\Catalog\Model\Product;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
use Magento\Catalog\Model\Product;
+use Magento\Catalog\Model\ProductFactory;
/**
* Catalog product copier.
@@ -28,7 +30,7 @@ class Copier
protected $copyConstructor;
/**
- * @var \Magento\Catalog\Model\ProductFactory
+ * @var ProductFactory
*/
protected $productFactory;
@@ -36,17 +38,24 @@ class Copier
* @var \Magento\Framework\EntityManager\MetadataPool
*/
protected $metadataPool;
+ /**
+ * @var ScopeOverriddenValue
+ */
+ private $scopeOverriddenValue;
/**
* @param CopyConstructorInterface $copyConstructor
- * @param \Magento\Catalog\Model\ProductFactory $productFactory
+ * @param ProductFactory $productFactory
+ * @param ScopeOverriddenValue $scopeOverriddenValue
*/
public function __construct(
CopyConstructorInterface $copyConstructor,
- \Magento\Catalog\Model\ProductFactory $productFactory
+ ProductFactory $productFactory,
+ ScopeOverriddenValue $scopeOverriddenValue
) {
$this->productFactory = $productFactory;
$this->copyConstructor = $copyConstructor;
+ $this->scopeOverriddenValue = $scopeOverriddenValue;
}
/**
@@ -121,19 +130,20 @@ private function setStoresUrl(Product $product, Product $duplicate) : void
$storeIds = $duplicate->getStoreIds();
$productId = $product->getId();
$productResource = $product->getResource();
- $defaultUrlKey = $productResource->getAttributeRawValue(
- $productId,
- 'url_key',
- \Magento\Store\Model\Store::DEFAULT_STORE_ID
- );
$duplicate->setData('save_rewrites_history', false);
foreach ($storeIds as $storeId) {
+ $useDefault = !$this->scopeOverriddenValue->containsValue(
+ ProductInterface::class,
+ $product,
+ 'url_key',
+ $storeId
+ );
+ if ($useDefault) {
+ continue;
+ }
$isDuplicateSaved = false;
$duplicate->setStoreId($storeId);
$urlKey = $productResource->getAttributeRawValue($productId, 'url_key', $storeId);
- if ($urlKey === $defaultUrlKey) {
- continue;
- }
do {
$urlKey = $this->modifyUrl($urlKey);
$duplicate->setUrlKey($urlKey);
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
index 80b6db2a516bd..86b43d2e898d7 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
@@ -6,6 +6,7 @@
namespace Magento\Catalog\Test\Unit\Model\Product;
use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Model\Attribute\ScopeOverriddenValue;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\Product\Copier;
@@ -46,6 +47,11 @@ class CopierTest extends \PHPUnit\Framework\TestCase
*/
protected $metadata;
+ /**
+ * @var ScopeOverriddenValue|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $scopeOverriddenValue;
+
protected function setUp()
{
$this->copyConstructorMock = $this->createMock(\Magento\Catalog\Model\Product\CopyConstructorInterface::class);
@@ -59,6 +65,7 @@ protected function setUp()
$this->optionRepositoryMock;
$this->productMock = $this->createMock(Product::class);
$this->productMock->expects($this->any())->method('getEntityId')->willReturn(1);
+ $this->scopeOverriddenValue = $this->createMock(ScopeOverriddenValue::class);
$this->metadata = $this->getMockBuilder(\Magento\Framework\EntityManager\EntityMetadata::class)
->disableOriginalConstructor()
@@ -67,9 +74,11 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
$metadataPool->expects($this->any())->method('getMetadata')->willReturn($this->metadata);
+
$this->_model = new Copier(
$this->copyConstructorMock,
- $this->productFactoryMock
+ $this->productFactoryMock,
+ $this->scopeOverriddenValue
);
$this->setProperties($this->_model, [
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php
new file mode 100644
index 0000000000000..6510e048f0e2d
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CopierTest.php
@@ -0,0 +1,47 @@
+get(ProductRepository::class);
+ $copier = Bootstrap::getObjectManager()->get(Copier::class);
+
+ $product = $productRepository->get($productSKU);
+ $duplicate = $copier->copy($product);
+
+ $duplicateStoreView = $productRepository->getById($duplicate->getId(), false, Store::DISTRO_STORE_ID);
+ $productStoreView = $productRepository->get($productSKU, false, Store::DISTRO_STORE_ID);
+
+ $this->assertNotEquals(
+ $duplicateStoreView->getUrlKey(),
+ $productStoreView->getUrlKey(),
+ 'url_key of product duplicate should be different then url_key of the product for the same store view'
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php
new file mode 100644
index 0000000000000..82a1cd4b98e35
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key.php
@@ -0,0 +1,50 @@
+create(Product::class);
+$product->isObjectNew(true);
+$product->setTypeId(Type::TYPE_SIMPLE)
+ ->setStoreId(Store::DEFAULT_STORE_ID)
+ ->setAttributeSetId(4)
+ ->setWebsiteIds([1])
+ ->setName('Simple Product 100')
+ ->setSku('simple_100')
+ ->setUrlKey('url-key')
+ ->setPrice(10)
+ ->setWeight(1)
+ ->setVisibility(Visibility::VISIBILITY_BOTH)
+ ->setStatus(Status::STATUS_ENABLED);
+
+/** @var StockItemInterface $stockItem */
+$stockItem = $objectManager->create(StockItemInterface::class);
+$stockItem->setQty(100)
+ ->setIsInStock(true);
+$extensionAttributes = $product->getExtensionAttributes();
+$extensionAttributes->setStockItem($stockItem);
+
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = $objectManager->get(ProductRepositoryInterface::class);
+$product = $productRepository->save($product);
+
+$product->setStoreId(Store::DISTRO_STORE_ID)
+ ->setName('StoreTitle')
+ ->setUrlKey('url-key');
+$productRepository->save($product);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php
new file mode 100644
index 0000000000000..7130a7c4a5612
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_multistore_with_url_key_rollback.php
@@ -0,0 +1,22 @@
+get(ProductRepositoryInterface::class);
+try {
+ $productRepository->deleteById('simple_100');
+} catch (NoSuchEntityException $e) {
+ //Entity already deleted
+}
From 9c47fba3bd0028ac4289f7823838232d6e00bada Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 18 Oct 2019 14:58:50 -0500
Subject: [PATCH 0497/1978] MC-21882: Product url_key not updating on
duplicating
- Fix static
---
.../Model/Attribute/ScopeOverriddenValue.php | 4 +++
.../Test/Unit/Model/Product/CopierTest.php | 29 ++++++++++++-------
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php
index 80674d09cab1c..cf194615b1f3b 100644
--- a/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php
+++ b/app/code/Magento/Catalog/Model/Attribute/ScopeOverriddenValue.php
@@ -110,6 +110,8 @@ public function getDefaultValues($entityType, $entity)
}
/**
+ * Init attribute values.
+ *
* @param string $entityType
* @param \Magento\Catalog\Model\AbstractModel $entity
* @param int $storeId
@@ -158,6 +160,8 @@ private function initAttributeValues($entityType, $entity, $storeId)
}
/**
+ * Returns entity attributes.
+ *
* @param string $entityType
* @return \Magento\Eav\Api\Data\AttributeInterface[]
*/
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
index 86b43d2e898d7..809fa0225278c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Product/CopierTest.php
@@ -81,10 +81,13 @@ protected function setUp()
$this->scopeOverriddenValue
);
- $this->setProperties($this->_model, [
- 'optionRepository' => $this->optionRepositoryMock,
- 'metadataPool' => $metadataPool,
- ]);
+ $this->setProperties(
+ $this->_model,
+ [
+ 'optionRepository' => $this->optionRepositoryMock,
+ 'metadataPool' => $metadataPool,
+ ]
+ );
}
/**
@@ -112,10 +115,12 @@ public function testCopy()
];
$this->productMock->expects($this->atLeastOnce())->method('getWebsiteIds');
$this->productMock->expects($this->atLeastOnce())->method('getCategoryIds');
- $this->productMock->expects($this->any())->method('getData')->willReturnMap([
- ['', null, $productData],
- ['linkField', null, '1'],
- ]);
+ $this->productMock->expects($this->any())->method('getData')->willReturnMap(
+ [
+ ['', null, $productData],
+ ['linkField', null, '1'],
+ ]
+ );
$entityMock = $this->getMockForAbstractClass(
\Magento\Eav\Model\Entity\AbstractEntity::class,
@@ -200,9 +205,11 @@ public function testCopy()
$this->metadata->expects($this->any())->method('getLinkField')->willReturn('linkField');
- $duplicateMock->expects($this->any())->method('getData')->willReturnMap([
- ['linkField', null, '2'],
- ]);
+ $duplicateMock->expects($this->any())->method('getData')->willReturnMap(
+ [
+ ['linkField', null, '2'],
+ ]
+ );
$this->optionRepositoryMock->expects($this->once())
->method('duplicate')
->with($this->productMock, $duplicateMock);
From 843458a3466142a27976b797803cb2da7f6119bb Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Fri, 18 Oct 2019 15:09:55 -0500
Subject: [PATCH 0498/1978] MC-21933: Possible type mismatch in product
collection
---
.../Catalog/Model/ResourceModel/Product/Collection.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php
index e1350ebb25c87..0811f630083bc 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php
@@ -2520,10 +2520,10 @@ public function getPricesCount()
/**
* Add is_saleable attribute to filter
*
- * @param array|null $condition
+ * @param mixed $condition
* @return $this
*/
- private function addIsSaleableAttributeToFilter(?array $condition): self
+ private function addIsSaleableAttributeToFilter($condition): self
{
$columns = $this->getSelect()->getPart(Select::COLUMNS);
foreach ($columns as $columnEntry) {
@@ -2551,10 +2551,10 @@ private function addIsSaleableAttributeToFilter(?array $condition): self
* Add tier price attribute to filter
*
* @param string $attribute
- * @param array|null $condition
+ * @param mixed $condition
* @return $this
*/
- private function addTierPriceAttributeToFilter(string $attribute, ?array $condition): self
+ private function addTierPriceAttributeToFilter(string $attribute, $condition): self
{
$attrCode = $attribute;
$connection = $this->getConnection();
From 16745cb8a96d17cf64e0c7e4ed80489a54c85ee3 Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Fri, 18 Oct 2019 15:41:32 -0500
Subject: [PATCH 0499/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
.../Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
index 6b60c9e93e8b6..a267b5693e6aa 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/CheckProductsOrderActionGroup.xml
@@ -18,7 +18,7 @@
-
+
From 6ea1f0df9e90a9996a9ced31a2ef95f6b9e7d4fb Mon Sep 17 00:00:00 2001
From: Eden
Date: Sat, 19 Oct 2019 05:06:11 +0700
Subject: [PATCH 0500/1978] Fix automation test issue 25148
---
app/code/Magento/Cookie/Block/RequireCookie.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Cookie/Block/RequireCookie.php b/app/code/Magento/Cookie/Block/RequireCookie.php
index 08228adba694e..a9c2310b2dfc1 100644
--- a/app/code/Magento/Cookie/Block/RequireCookie.php
+++ b/app/code/Magento/Cookie/Block/RequireCookie.php
@@ -29,12 +29,11 @@ class RequireCookie extends \Magento\Framework\View\Element\Template
*/
public function getScriptOptions()
{
- $isRedirectCmsPage = ObjectManager::getInstance()->get(ScopeConfigInterface::class)
- ->getValue('web/browser_capabilities/cookies');
+ $isRedirectCmsPage = (boolean)$this->_scopeConfig->getValue('web/browser_capabilities/cookies');
$params = [
'noCookieUrl' => $this->escapeUrl($this->getUrl('cookie/index/noCookies/')),
'triggers' => $this->escapeHtml($this->getTriggers()),
- 'isRedirectCmsPage' => (boolean)$isRedirectCmsPage
+ 'isRedirectCmsPage' => $isRedirectCmsPage
];
return json_encode($params);
}
From 4fb5da819cb2517de204e7dcf8c545505eeabd2c Mon Sep 17 00:00:00 2001
From: Pavel Bystritsky
Date: Sat, 19 Oct 2019 19:41:02 +0300
Subject: [PATCH 0501/1978] magento/magento2#22856: Catalog price rules are not
working with custom options as expected.
---
.../CalculateCustomOptionCatalogRule.php | 50 +++-
.../CalculateCustomOptionCatalogRuleTest.php | 266 ++++++++++++++++++
2 files changed, 301 insertions(+), 15 deletions(-)
create mode 100644 app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php
diff --git a/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php b/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php
index 91ff8f921566c..b3f3ac7bf68ef 100644
--- a/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php
+++ b/app/code/Magento/Catalog/Pricing/Price/CalculateCustomOptionCatalogRule.php
@@ -53,24 +53,31 @@ public function execute(
float $optionPriceValue,
bool $isPercent
): float {
- $basePrice = $this->getGetBasePriceWithOutCatalogRules($product);
- if ($isPercent) {
- $optionPrice = $basePrice * $optionPriceValue / 100;
- } else {
- $optionPrice = $optionPriceValue;
- }
-
- $totalPriceModified = $this->priceModifier->modifyPrice(
- $basePrice + $optionPrice,
- $product
- );
- $basePriceModified = $this->priceModifier->modifyPrice(
- $basePrice,
+ $regularPrice = (float)$product->getPriceInfo()
+ ->getPrice(RegularPrice::PRICE_CODE)
+ ->getValue();
+ $catalogRulePrice = $this->priceModifier->modifyPrice(
+ $regularPrice,
$product
);
- $price = $totalPriceModified - $basePriceModified;
+ $basePriceWithOutCatalogRules = (float)$this->getGetBasePriceWithOutCatalogRules($product);
+ // Apply catalog price rules to product options only if catalog price rules are applied to product.
+ if ($catalogRulePrice < $basePriceWithOutCatalogRules) {
+ $optionPrice = $this->getOptionPriceWithoutPriceRule($optionPriceValue, $isPercent, $regularPrice);
+ $totalCatalogRulePrice = $this->priceModifier->modifyPrice(
+ $regularPrice + $optionPrice,
+ $product
+ );
+ $finalOptionPrice = $totalCatalogRulePrice - $catalogRulePrice;
+ } else {
+ $finalOptionPrice = $this->getOptionPriceWithoutPriceRule(
+ $optionPriceValue,
+ $isPercent,
+ $this->getGetBasePriceWithOutCatalogRules($product)
+ );
+ }
- return $this->priceCurrency->convertAndRound($price);
+ return $this->priceCurrency->convertAndRound($finalOptionPrice);
}
/**
@@ -96,4 +103,17 @@ private function getGetBasePriceWithOutCatalogRules(Product $product): float
return $basePrice ?? $product->getPrice();
}
+
+ /**
+ * Calculate option price without catalog price rule discount.
+ *
+ * @param float $optionPriceValue
+ * @param bool $isPercent
+ * @param float $basePrice
+ * @return float
+ */
+ private function getOptionPriceWithoutPriceRule(float $optionPriceValue, bool $isPercent, float $basePrice): float
+ {
+ return $isPercent ? $basePrice * $optionPriceValue / 100 : $optionPriceValue;
+ }
}
diff --git a/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php
new file mode 100644
index 0000000000000..1a99ac5d451f0
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Unit/Pricing/Price/CalculateCustomOptionCatalogRuleTest.php
@@ -0,0 +1,266 @@
+saleableItemMock = $this->createMock(Product::class);
+ $this->regularPriceMock = $this->createMock(RegularPrice::class);
+ $this->specialPriceMock = $this->createMock(SpecialPrice::class);
+ $this->catalogRulePriceMock = $this->createMock(CatalogRulePrice::class);
+ $priceInfoMock = $this->createMock(Base::class);
+ $this->saleableItemMock->expects($this->any())
+ ->method('getPriceInfo')
+ ->willReturn($priceInfoMock);
+ $this->regularPriceMock->expects($this->any())
+ ->method('getPriceCode')
+ ->willReturn(RegularPrice::PRICE_CODE);
+ $this->specialPriceMock->expects($this->any())
+ ->method('getPriceCode')
+ ->willReturn(SpecialPrice::PRICE_CODE);
+ $this->catalogRulePriceMock->expects($this->any())
+ ->method('getPriceCode')
+ ->willReturn(CatalogRulePrice::PRICE_CODE);
+ $priceInfoMock->expects($this->any())
+ ->method('getPrices')
+ ->willReturn(
+ [
+ 'regular_price' => $this->regularPriceMock,
+ 'special_price' => $this->specialPriceMock,
+ 'catalog_rule_price' => $this->catalogRulePriceMock
+ ]
+ );
+ $priceInfoMock->expects($this->any())
+ ->method('getPrice')
+ ->willReturnMap(
+ [
+ ['regular_price', $this->regularPriceMock],
+ ['special_price', $this->specialPriceMock],
+ ['catalog_rule_price', $this->catalogRulePriceMock],
+ ]
+ );
+ $priceCurrencyMock = $this->createMock(PriceCurrency::class);
+ $priceCurrencyMock->expects($this->any())
+ ->method('convertAndRound')
+ ->willReturnArgument(0);
+ $this->priceModifierMock = $this->createMock(PriceModifier::class);
+
+ $this->calculateCustomOptionCatalogRule = $objectManager->getObject(
+ CalculateCustomOptionCatalogRule::class,
+ [
+ 'priceCurrency' => $priceCurrencyMock,
+ 'priceModifier' => $this->priceModifierMock,
+ ]
+ );
+ }
+
+ /**
+ * Tests correct option price calculation with different catalog rules and special prices combination.
+ *
+ * @dataProvider executeDataProvider
+ * @param array $prices
+ * @param float $catalogRulePriceModifier
+ * @param float $optionPriceValue
+ * @param bool $isPercent
+ * @param float $expectedResult
+ */
+ public function testExecute(
+ array $prices,
+ float $catalogRulePriceModifier,
+ float $optionPriceValue,
+ bool $isPercent,
+ float $expectedResult
+ ) {
+ $this->regularPriceMock->expects($this->any())
+ ->method('getValue')
+ ->willReturn($prices['regularPriceValue']);
+ $this->specialPriceMock->expects($this->any())
+ ->method('getValue')
+ ->willReturn($prices['specialPriceValue']);
+ $this->priceModifierMock->expects($this->any())
+ ->method('modifyPrice')
+ ->willReturnCallback(
+ function ($price) use ($catalogRulePriceModifier) {
+ return $price * $catalogRulePriceModifier;
+ }
+ );
+
+ $finalPrice = $this->calculateCustomOptionCatalogRule->execute(
+ $this->saleableItemMock,
+ $optionPriceValue,
+ $isPercent
+ );
+
+ $this->assertSame($expectedResult, $finalPrice);
+ }
+
+ /**
+ * Data provider for testExecute.
+ *
+ * "Active" means this price type has biggest discount, so other prices doesn't count.
+ *
+ * @return array
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function executeDataProvider(): array
+ {
+ return [
+ 'No special price, no catalog price rules, fixed option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 1000,
+ ],
+ 'catalogRulePriceModifier' => 1.0,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => false,
+ 'expectedResult' => 100.0
+ ],
+ 'No special price, no catalog price rules, percent option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 1000,
+ ],
+ 'catalogRulePriceModifier' => 1.0,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => true,
+ 'expectedResult' => 1000.0
+ ],
+ 'No special price, catalog price rule set, fixed option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 1000,
+ ],
+ 'catalogRulePriceModifier' => 0.9,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => false,
+ 'expectedResult' => 90.0
+ ],
+ 'No special price, catalog price rule set, percent option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 1000,
+ ],
+ 'catalogRulePriceModifier' => 0.9,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => true,
+ 'expectedResult' => 900.0
+ ],
+ 'Special price set, no catalog price rule, fixed option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 900,
+ ],
+ 'catalogRulePriceModifier' => 1.0,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => false,
+ 'expectedResult' => 100.0
+ ],
+ 'Special price set, no catalog price rule, percent option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 900,
+ ],
+ 'catalogRulePriceModifier' => 1.0,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => true,
+ 'expectedResult' => 900.0
+ ],
+ 'Special price set and active, catalog price rule set, fixed option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 800,
+ ],
+ 'catalogRulePriceModifier' => 0.9,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => false,
+ 'expectedResult' => 100.0
+ ],
+ 'Special price set and active, catalog price rule set, percent option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 800,
+ ],
+ 'catalogRulePriceModifier' => 0.9,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => true,
+ 'expectedResult' => 800.0
+ ],
+ 'Special price set, catalog price rule set and active, fixed option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 950,
+ ],
+ 'catalogRulePriceModifier' => 0.9,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => false,
+ 'expectedResult' => 90.0
+ ],
+ 'Special price set, catalog price rule set and active, percent option price' => [
+ 'prices' => [
+ 'regularPriceValue' => 1000,
+ 'specialPriceValue' => 950,
+ ],
+ 'catalogRulePriceModifier' => 0.9,
+ 'optionPriceValue' => 100.0,
+ 'isPercent' => true,
+ 'expectedResult' => 900.0
+ ],
+ ];
+ }
+}
From a9d641617a5d384136b56a23d7fcdef54a24df87 Mon Sep 17 00:00:00 2001
From: rahul
Date: Sun, 20 Oct 2019 18:52:55 +0530
Subject: [PATCH 0502/1978] Fixed Issue #25167:Terms and Conditions css height
do nothing on frontend
---
.../CheckoutAgreements/Model/AgreementsConfigProvider.php | 3 ++-
.../view/frontend/web/js/view/checkout-agreements.js | 2 ++
.../frontend/web/template/checkout/checkout-agreements.html | 2 +-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php b/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php
index 1217270d780e1..ff77db60a64e6 100644
--- a/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php
+++ b/app/code/Magento/CheckoutAgreements/Model/AgreementsConfigProvider.php
@@ -102,7 +102,8 @@ protected function getAgreementsConfig()
: nl2br($this->escaper->escapeHtml($agreement->getContent())),
'checkboxText' => $this->escaper->escapeHtml($agreement->getCheckboxText()),
'mode' => $agreement->getMode(),
- 'agreementId' => $agreement->getAgreementId()
+ 'agreementId' => $agreement->getAgreementId(),
+ 'contentHeight' => $agreement->getContentHeight()
];
}
diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js
index 434676fc04116..a189c42918099 100644
--- a/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js
+++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/js/view/checkout-agreements.js
@@ -23,6 +23,7 @@ define([
agreements: agreementsConfig.agreements,
modalTitle: ko.observable(null),
modalContent: ko.observable(null),
+ contentHeight: ko.observable(null),
modalWindow: null,
/**
@@ -42,6 +43,7 @@ define([
showContent: function (element) {
this.modalTitle(element.checkboxText);
this.modalContent(element.content);
+ this.contentHeight(element.contentHeight ? element.contentHeight : 'auto');
agreementsModal.showModal();
},
diff --git a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html
index 4b1a68624e547..f1c807fab3d22 100644
--- a/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html
+++ b/app/code/Magento/CheckoutAgreements/view/frontend/web/template/checkout/checkout-agreements.html
@@ -35,7 +35,7 @@
From ca502c3970ea846b3be81b220ddde074c0a2b0f8 Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Sun, 20 Oct 2019 17:25:46 +0300
Subject: [PATCH 0503/1978] Rollback some changes after benchmarking on PHP 7.2
---
.../Framework/App/ObjectManager/ConfigLoader/Compiled.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
index 5fc668e2d9c5e..7408e8b230bd9 100644
--- a/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
+++ b/lib/internal/Magento/Framework/App/ObjectManager/ConfigLoader/Compiled.php
@@ -42,6 +42,6 @@ public function load($area)
public static function getFilePath($area)
{
$diPath = DirectoryList::getDefaultConfig()[DirectoryList::GENERATED_METADATA][DirectoryList::PATH];
- return join('', [BP, '/', $diPath, '/', $area, '.php']);
+ return BP . '/' . $diPath . '/' . $area . '.php';
}
}
From 66613c8ef36ff6ff6110e4665d96a56df7280cca Mon Sep 17 00:00:00 2001
From: rahul
Date: Sun, 20 Oct 2019 19:56:36 +0530
Subject: [PATCH 0504/1978] test case updated
---
.../Test/Unit/Model/AgreementsConfigProviderTest.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php
index c8309bacb0a86..6b8477e0b4919 100644
--- a/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php
+++ b/app/code/Magento/CheckoutAgreements/Test/Unit/Model/AgreementsConfigProviderTest.php
@@ -77,6 +77,7 @@ public function testGetConfigIfContentIsHtml()
$escapedCheckboxText = 'escaped_checkbox_text';
$mode = \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_AUTO;
$agreementId = 100;
+ $contentHeight = '100px';
$expectedResult = [
'checkoutAgreements' => [
'isEnabled' => 1,
@@ -86,6 +87,7 @@ public function testGetConfigIfContentIsHtml()
'checkboxText' => $escapedCheckboxText,
'mode' => $mode,
'agreementId' => $agreementId,
+ 'contentHeight' => $contentHeight
],
],
],
@@ -116,6 +118,7 @@ public function testGetConfigIfContentIsHtml()
$agreement->expects($this->once())->method('getCheckboxText')->willReturn($checkboxText);
$agreement->expects($this->once())->method('getMode')->willReturn($mode);
$agreement->expects($this->once())->method('getAgreementId')->willReturn($agreementId);
+ $agreement->expects($this->once())->method('getContentHeight')->willReturn($contentHeight);
$this->assertEquals($expectedResult, $this->model->getConfig());
}
@@ -133,6 +136,7 @@ public function testGetConfigIfContentIsNotHtml()
$escapedCheckboxText = 'escaped_checkbox_text';
$mode = \Magento\CheckoutAgreements\Model\AgreementModeOptions::MODE_AUTO;
$agreementId = 100;
+ $contentHeight = '100px';
$expectedResult = [
'checkoutAgreements' => [
'isEnabled' => 1,
@@ -142,6 +146,7 @@ public function testGetConfigIfContentIsNotHtml()
'checkboxText' => $escapedCheckboxText,
'mode' => $mode,
'agreementId' => $agreementId,
+ 'contentHeight' => $contentHeight
],
],
],
@@ -172,6 +177,7 @@ public function testGetConfigIfContentIsNotHtml()
$agreement->expects($this->once())->method('getCheckboxText')->willReturn($checkboxText);
$agreement->expects($this->once())->method('getMode')->willReturn($mode);
$agreement->expects($this->once())->method('getAgreementId')->willReturn($agreementId);
+ $agreement->expects($this->once())->method('getContentHeight')->willReturn($contentHeight);
$this->assertEquals($expectedResult, $this->model->getConfig());
}
From 79fdffbe72600ccfeb49b7e5b02ea864e6f3baf0 Mon Sep 17 00:00:00 2001
From: Eden
Date: Sun, 20 Oct 2019 22:47:45 +0700
Subject: [PATCH 0505/1978] Add validation in catalog rule and shopping cart
rule form
---
.../ui_component/catalog_rule_form.xml | 4 ++++
.../ui_component/sales_rule_form.xml | 20 +++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml
index 2af8bb0770b20..35fd7d8a192f4 100644
--- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml
+++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml
@@ -208,6 +208,10 @@
+
+ true
+ true
+
text
Priority
sort_order
diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml
index 639e12006232b..63faf29afd769 100644
--- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml
+++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml
@@ -297,6 +297,9 @@
+
+ true
+
text
Uses per Coupon
uses_per_coupon
@@ -309,6 +312,9 @@
+
+ true
+
Usage limit enforced for logged in customers only.
@@ -356,6 +362,10 @@
+
+ true
+ true
+
text
Priority
sort_order
@@ -422,6 +432,8 @@
true
+ true
+ true
text
Discount Amount
@@ -435,6 +447,10 @@
+
+ true
+ true
+
text
Maximum Qty Discount is Applied To
discount_qty
@@ -447,6 +463,10 @@
+
+ true
+ true
+
text
Discount Qty Step (Buy X)
discount_step
From 7b921998cafc1d5fe389c389170b5837cd94ca0b Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Sun, 20 Oct 2019 11:59:58 -0500
Subject: [PATCH 0506/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - Reverted Db and API changes
---
app/code/Magento/Quote/etc/db_schema.xml | 2 -
.../Api/Data/DiscountDataInterface.php | 74 -------
.../Api/Data/RuleDiscountInterface.php | 34 +--
.../SalesRule/Model/Data/RuleDiscount.php | 43 +---
.../SalesRule/Model/Plugin/Discount.php | 128 ------------
.../Model/Plugin/ResourceModel/Discount.php | 63 ------
.../SalesRule/Model/Quote/Discount.php | 10 +-
.../Model/Quote/Item/Plugin/Discount.php | 64 ------
.../Model/Rule/Action/Discount/Data.php | 2 +-
.../Magento/SalesRule/Model/RulesApplier.php | 10 +-
app/code/Magento/SalesRule/etc/di.xml | 9 -
.../PlaceOrderWithStorePromotionsTest.php | 196 ------------------
12 files changed, 23 insertions(+), 612 deletions(-)
delete mode 100644 app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
delete mode 100644 app/code/Magento/SalesRule/Model/Plugin/Discount.php
delete mode 100644 app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
delete mode 100644 app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
delete mode 100644 dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
diff --git a/app/code/Magento/Quote/etc/db_schema.xml b/app/code/Magento/Quote/etc/db_schema.xml
index 0e9ad766fdb3f..d41591c619cde 100644
--- a/app/code/Magento/Quote/etc/db_schema.xml
+++ b/app/code/Magento/Quote/etc/db_schema.xml
@@ -175,7 +175,6 @@
-
-
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
deleted file mode 100644
index 70765821db252..0000000000000
--- a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
+++ /dev/null
@@ -1,74 +0,0 @@
-_get(self::KEY_DISCOUNT_DATA);
}
@@ -35,54 +35,21 @@ public function getDiscountData(): DiscountDataInterface
*
* @return string
*/
- public function getRuleLabel(): ?string
+ public function getRuleLabel()
{
return $this->_get(self::KEY_RULE_LABEL);
}
- /**
- * Set Discount Data
- *
- * @param DiscountDataInterface $discountData
- * @return RuleDiscount
- */
- public function setDiscountData(DiscountDataInterface $discountData)
- {
- return $this->setData(self::KEY_DISCOUNT_DATA, $discountData);
- }
-
- /**
- * Set Rule Label
- *
- * @param string $ruleLabel
- * @return RuleDiscount
- */
- public function setRuleLabel(string $ruleLabel)
- {
- return $this->setData(self::KEY_RULE_LABEL, $ruleLabel);
- }
-
/**
* Get Rule ID
*
* @return int
*/
- public function getRuleID(): ?int
+ public function getRuleID()
{
return $this->_get(self::KEY_RULE_ID);
}
- /**
- * Set Rule ID
- *
- * @param int $ruleID
- * @return RuleDiscount
- */
- public function setRuleID(int $ruleID)
- {
- return $this->setData(self::KEY_RULE_ID, $ruleID);
- }
-
/**
* Retrieve existing extension attributes object or create a new one.
*
diff --git a/app/code/Magento/SalesRule/Model/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/Discount.php
deleted file mode 100644
index b520a556ec4f8..0000000000000
--- a/app/code/Magento/SalesRule/Model/Plugin/Discount.php
+++ /dev/null
@@ -1,128 +0,0 @@
-json = $json;
- $this->discountFactory = $discountDataFactory;
- $this->discountInterfaceFactory = $discountInterfaceFactory;
- }
-
- /**
- * Plugin for adding item discounts to extension attributes
- *
- * @param Quote $subject
- * @param Collection $result
- * @return Collection
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function afterGetItemsCollection(
- Quote $subject,
- Collection $result
- ): Collection {
- foreach ($result as $item) {
- if ($item->getDiscounts() && !$item->getExtensionAttributes()->getDiscounts()) {
- $unserializeDiscounts = $this->json->unserialize($item->getDiscounts());
- $discounts = [];
- foreach ($unserializeDiscounts as $value) {
- $itemDiscount = $this->discountInterfaceFactory->create();
- $itemDiscount->setDiscountData($this->unserializeDiscountData($value['discount']));
- $itemDiscount->setRuleLabel($value['rule']);
- $itemDiscount->setRuleID($value['ruleID']);
- $discounts[] = $itemDiscount;
- }
- $itemExtension = $item->getExtensionAttributes();
- $itemExtension->setDiscounts($discounts);
- }
- }
- return $result;
- }
-
- /**
- * Plugin for adding address level discounts to extension attributes
- *
- * @param Quote $subject
- * @param array $result
- * @return array
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function afterGetAllAddresses(
- Quote $subject,
- array $result
- ): array {
- foreach ($result as $address) {
- if ($address->getDiscounts() && !$address->getExtensionAttributes()->getDiscounts()) {
- $unserializedDiscounts = $this->json->unserialize($address->getDiscounts());
- $discounts = [];
- foreach ($unserializedDiscounts as $value) {
- $cartDiscount = $this->discountInterfaceFactory->create();
- $cartDiscount->setDiscountData($this->unserializeDiscountData($value['discount']));
- $cartDiscount->setRuleLabel($value['rule']);
- $cartDiscount->setRuleID($value['ruleID']);
- $discounts[] = $cartDiscount;
- }
- $addressExtension = $address->getExtensionAttributes();
- $addressExtension->setDiscounts($discounts);
- }
- }
- return $result;
- }
-
- /**
- * Unserialize discount object
- *
- * @param string $serializedDiscount
- * @return Data
- */
- private function unserializeDiscountData(string $serializedDiscount): Data
- {
- $discountArray = $this->json->unserialize($serializedDiscount);
- $discountData = $this->discountFactory->create();
- $discountData->setBaseOriginalAmount($discountArray['baseOriginalAmount']);
- $discountData->setOriginalAmount($discountArray['originalAmount']);
- $discountData->setAmount($discountArray['amount']);
- $discountData->setBaseAmount($discountArray['baseAmount']);
- return $discountData;
- }
-}
diff --git a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php b/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
deleted file mode 100644
index 767dba7993d1e..0000000000000
--- a/app/code/Magento/SalesRule/Model/Plugin/ResourceModel/Discount.php
+++ /dev/null
@@ -1,63 +0,0 @@
-json = $json;
- }
-
- /**
- * Plugin method for persisting data from extension attribute
- *
- * @param \Magento\Quote\Model\ResourceModel\Quote $subject
- * @param \Magento\Framework\Model\AbstractModel $object
- * @return array
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function beforeSave(
- \Magento\Quote\Model\ResourceModel\Quote $subject,
- \Magento\Framework\Model\AbstractModel $object
- ): array {
- foreach ($object->getAllAddresses() as $address) {
- $discounts = $address->getExtensionAttributes()->getDiscounts();
- $serializedDiscounts= [];
- if ($discounts) {
- foreach ($discounts as $key => $value) {
- $discount = $value->getDiscountData();
- $discountData = [
- "amount" => $discount->getAmount(),
- "baseAmount" => $discount->getBaseAmount(),
- "originalAmount" => $discount->getOriginalAmount(),
- "baseOriginalAmount" => $discount->getBaseOriginalAmount()
- ];
- $serializedDiscounts[$key]['discount'] = $this->json->serialize($discountData);
- $serializedDiscounts[$key]['rule'] = $value->getRuleLabel();
- $serializedDiscounts[$key]['ruleID'] = $value->getRuleID();
- }
- $address->setDiscounts($this->json->serialize($serializedDiscounts));
- }
- }
- return [$object];
- }
-}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index cfa8ac92a6ca6..efd8e01ebc470 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -280,11 +280,13 @@ private function aggregateDiscountPerRule(
$discountData->setAmount($discount->getAmount());
$discountData->setOriginalAmount($discount->getOriginalAmount());
$discountData->setBaseOriginalAmount($discount->getBaseOriginalAmount());
+ $data = [
+ 'discount' => $discountData,
+ 'rule' => $ruleLabel,
+ 'rule_id' => $ruleID,
+ ];
/** @var \Magento\SalesRule\Model\Data\RuleDiscount $cartDiscount */
- $cartDiscount = $this->discountInterfaceFactory->create();
- $cartDiscount->setDiscountData($discountData);
- $cartDiscount->setRuleLabel($ruleLabel);
- $cartDiscount->setRuleID($ruleID);
+ $cartDiscount = $this->discountInterfaceFactory->create(['data' => $data]);
$addressDiscountAggregator[$ruleID] = $cartDiscount;
}
}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
deleted file mode 100644
index 680a07b7444f9..0000000000000
--- a/app/code/Magento/SalesRule/Model/Quote/Item/Plugin/Discount.php
+++ /dev/null
@@ -1,64 +0,0 @@
-json = $json;
- }
-
- /**
- * Plugin method for persisting data from extension attributes
- *
- * @param CartItemPersister $subject
- * @param CartInterface $quote
- * @param CartItemInterface $cartItem
- * @return array
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function beforeSave(CartItemPersister $subject, CartInterface $quote, CartItemInterface $cartItem): array
- {
- $cartExtension = $cartItem->getExtensionAttributes();
- $discounts = $cartExtension->getDiscounts();
- $serializedDiscount = [];
- if ($discounts) {
- foreach ($discounts as $value) {
- $discount = $value->getDiscountData();
- $discountData = [
- "amount" => $discount->getAmount(),
- "baseAmount" => $discount->getBaseAmount(),
- "originalAmount" => $discount->getOriginalAmount(),
- "baseOriginalAmount" => $discount->getBaseOriginalAmount(),
- ];
- $serializedDiscount[] = [
- 'discount' => $this->json->serialize($discountData),
- 'rule' => $value->getRuleLabel(),
- 'ruleID' => $value->getRuleID(),
- ];
- }
- $cartItem->setDiscounts($this->json->serialize($serializedDiscount));
- }
- return [$quote, $cartItem];
- }
-}
diff --git a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
index c30c436751480..f9892fb48547c 100644
--- a/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
+++ b/app/code/Magento/SalesRule/Model/Rule/Action/Discount/Data.php
@@ -11,7 +11,7 @@
* @api
* @since 100.0.2
*/
-class Data implements \Magento\SalesRule\Api\Data\DiscountDataInterface
+class Data
{
/**
* @var float
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index 878f12e413dcf..a3cfba26b7cb6 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -235,11 +235,13 @@ private function setDiscountBreakdown($discountData, $item, $rule, $address)
$discount->setBaseAmount($discountData->getBaseAmount());
$discount->setOriginalAmount($discountData->getOriginalAmount());
$ruleLabel = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
+ $data = [
+ 'discount' => $discount,
+ 'rule' => $ruleLabel,
+ 'rule_id' => $rule->getId(),
+ ];
/** @var \Magento\SalesRule\Model\Data\RuleDiscount $itemDiscount */
- $itemDiscount = $this->discountInterfaceFactory->create();
- $itemDiscount->setDiscountData($discount);
- $itemDiscount->setRuleLabel($ruleLabel);
- $itemDiscount->setRuleID($rule->getId());
+ $itemDiscount = $this->discountInterfaceFactory->create(['data' => $data]);
$this->discountAggregator[] = $itemDiscount;
$item->getExtensionAttributes()->setDiscounts($this->discountAggregator);
}
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index c6eb2447d3aab..eb1d1ef89a575 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -48,9 +48,6 @@
-
-
-
@@ -183,12 +180,6 @@
-
-
-
-
-
-
diff --git a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php b/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
deleted file mode 100644
index 44228ac1d7cba..0000000000000
--- a/dev/tests/integration/testsuite/Magento/QuoteGraphQl/Model/Resolver/PlaceOrderWithStorePromotionsTest.php
+++ /dev/null
@@ -1,196 +0,0 @@
-objectManager = Bootstrap::getObjectManager();
- $this->graphQlRequest = $this->objectManager->create(GraphQlRequest::class);
- $this->getMaskedQuoteIdByReservedOrderId = $this->objectManager
- ->get(GetMaskedQuoteIdByReservedOrderId::class);
- $this->resource = $this->objectManager->get(ResourceConnection::class);
- $this->connection = $this->resource->getConnection();
- $this->jsonSerializer = $this->objectManager->get(SerializerInterface::class);
- $this->quoteRepository = $this->objectManager->get(CartRepositoryInterface::class);
- $this->criteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- }
-
- /**
- * Test successful place Order with Cart promotions and verify discounts are inserted into
- * quote_item and quote_address tables
- *
- * @magentoDataFixture Magento/Sales/_files/default_rollback.php
- * @magentoDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
- * @magentoDataFixture Magento/SalesRule/_files/cart_rule_product_in_category.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/guest/set_guest_email.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/set_flatrate_shipping_method.php
- * @magentoDataFixture Magento/GraphQl/Quote/_files/set_checkmo_payment_method.php
- *
- * @return void
- */
- public function testResolvePlaceOrderWithProductHavingCartPromotion(): void
- {
- $categoryId = 56;
- $reservedOrderId = 'test_quote';
- $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute($reservedOrderId);
- /** @var Rule $rule */
- $rule = $this->getSalesRule('50% Off on Large Orders');
- $salesRuleId = $rule->getRuleId();
- /** @var categoryLinkManagementInterface $categoryLinkManagement */
- $categoryLinkManagement = $this->objectManager->create(CategoryLinkManagementInterface::class);
- $categoryLinkManagement->assignProductToCategories('simple_product', [$categoryId]);
-
- $query
- = <<graphQlRequest->send($query);
- $responseContent = $this->jsonSerializer->unserialize($response->getContent());
- $this->assertArrayNotHasKey('errors', $responseContent);
- $this->assertArrayHasKey('data', $responseContent);
- $orderIdFromResponse = $responseContent['data']['placeOrder']['order']['order_id'];
- $this->assertEquals($reservedOrderId, $orderIdFromResponse);
-
- $selectFromQuoteItem = $this->connection->select()->from($this->resource->getTableName('quote_item'));
- $resultFromQuoteItem = $this->connection->fetchRow($selectFromQuoteItem);
- $serializedCartDiscount = $resultFromQuoteItem['discounts'];
-
- $this->assertEquals(
- 10,
- json_decode(
- $this->jsonSerializer->unserialize(
- $serializedCartDiscount
- )
- [0]['discount'],
- true
- )['amount']
- );
- $this->assertEquals(
- 'TestRule_Label',
- $this->jsonSerializer->unserialize($serializedCartDiscount)[0]['rule']
- );
- $this->assertEquals(
- $salesRuleId,
- $this->jsonSerializer->unserialize($serializedCartDiscount)[0]['ruleID']
- );
- $quote = $this->getQuote();
- $quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
- $discountData = $quoteAddressItemDiscount[0]->getDiscountData();
- $this->assertEquals(10, $discountData->getAmount());
- $this->assertEquals(10, $discountData->getBaseAmount());
- $this->assertEquals(10, $discountData->getOriginalAmount());
- $this->assertEquals(10, $discountData->getBaseOriginalAmount());
- $this->assertEquals('TestRule_Label', $quoteAddressItemDiscount[0]->getRuleLabel());
-
- $addressType = 'shipping';
- $selectFromQuoteAddress = $this->connection->select()->from($this->resource->getTableName('quote_address'))
- ->where('address_type = ?', $addressType);
- $resultFromQuoteAddress = $this->connection->fetchRow($selectFromQuoteAddress);
- $this->assertNotEmpty($resultFromQuoteAddress, 'No record found in quote_address table');
- }
-
- /**
- * Gets rule by name.
- *
- * @param string $name
- * @return \Magento\SalesRule\Model\Rule
- * @throws \Magento\Framework\Exception\InputException
- * @throws \Magento\Framework\Exception\NoSuchEntityException
- */
- private function getSalesRule(string $name): Rule
- {
- /** @var SearchCriteriaBuilder $searchCriteriaBuilder */
- $searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
- $searchCriteria = $searchCriteriaBuilder->addFilter('name', $name)
- ->create();
-
- /** @var CartRepositoryInterface $quoteRepository */
- $ruleRepository = $this->objectManager->get(RuleRepositoryInterface::class);
- $items = $ruleRepository->getList($searchCriteria)->getItems();
-
- $rule = array_pop($items);
- /** @var \Magento\SalesRule\Model\Converter\ToModel $converter */
- $converter = $this->objectManager->get(ToModel::class);
-
- return $converter->toModel($rule);
- }
-
- /**
- * @return Quote
- */
- private function getQuote(): Quote
- {
- $searchCriteria = $this->criteriaBuilder->addFilter('reserved_order_id', 'test_quote')->create();
- $carts = $this->quoteRepository->getList($searchCriteria)
- ->getItems();
- if (!$carts) {
- throw new \RuntimeException('Cart not found');
- }
-
- return array_shift($carts);
- }
-}
From 62971990536fea8aadb9eb91f407c4b7eda61d10 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Sun, 20 Oct 2019 21:11:56 +0300
Subject: [PATCH 0507/1978] GraphQl-890: added shipping addresses to tests
---
.../Customer/AddSimpleProductToCartTest.php | 16 ++++++++++++++++
.../Quote/Guest/AddSimpleProductToCartTest.php | 16 ++++++++++++++++
2 files changed, 32 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
index f861b9db98fe7..f7ba5b4d924fb 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/AddSimpleProductToCartTest.php
@@ -50,6 +50,8 @@ public function testAddSimpleProductToCart()
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);
+ self::assertArrayHasKey('shipping_addresses', $response['addSimpleProductsToCart']['cart']);
+ self::assertEmpty($response['addSimpleProductsToCart']['cart']['shipping_addresses']);
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
@@ -303,6 +305,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
}
}
}
+ shipping_addresses {
+ firstname
+ lastname
+ company
+ street
+ city
+ postcode
+ telephone
+ country {
+ code
+ label
+ }
+ __typename
+ }
}
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
index 1a3a1c8a738e5..5f65ac666ab97 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php
@@ -45,6 +45,8 @@ public function testAddSimpleProductToCart()
$response = $this->graphQlMutation($query);
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);
+ self::assertArrayHasKey('shipping_addresses', $response['addSimpleProductsToCart']['cart']);
+ self::assertEmpty($response['addSimpleProductsToCart']['cart']['shipping_addresses']);
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
@@ -272,6 +274,20 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
}
}
}
+ shipping_addresses {
+ firstname
+ lastname
+ company
+ street
+ city
+ postcode
+ telephone
+ country {
+ code
+ label
+ }
+ __typename
+ }
}
}
}
From 493971936b3a29957632dadb3b2b551388876f58 Mon Sep 17 00:00:00 2001
From: Vitaliy Boyko
Date: Sun, 20 Oct 2019 22:31:48 +0300
Subject: [PATCH 0508/1978] GraphQl-903: fixed priority of `same as shipping`
---
.../Model/Cart/SetBillingAddressOnCart.php | 6 +-
.../Customer/SetBillingAddressOnCartTest.php | 76 ++++++++++++++++++
.../Guest/SetBillingAddressOnCartTest.php | 79 ++++++++++++++++++-
3 files changed, 156 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 45713f9372e7b..0d937cc64a857 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -65,10 +65,10 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
{
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
$addressInput = $billingAddressInput['address'] ?? null;
- $useForShipping = isset($billingAddressInput['use_for_shipping'])
- ? (bool)$billingAddressInput['use_for_shipping'] : false;
$sameAsShipping = isset($billingAddressInput['same_as_shipping'])
- ? (bool)$billingAddressInput['same_as_shipping'] : $useForShipping;
+ ? (bool)$billingAddressInput['same_as_shipping'] : false;
+ $sameAsShipping = isset($billingAddressInput['use_for_shipping'])
+ ? (bool)$billingAddressInput['use_for_shipping'] : $sameAsShipping;
if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 2e4fa0a4cdc96..65497a993da6a 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -208,6 +208,82 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
$this->assertNewAddressFields($shippingAddressResponse, 'ShippingCartAddress');
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testSetNewBillingAddressWithUseForShippingParameter()
+ {
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
+
+ $query = <<graphQlMutation($query, [], '', $this->getHeaderMap());
+
+ self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
+ $cartResponse = $response['setBillingAddressOnCart']['cart'];
+ self::assertArrayHasKey('billing_address', $cartResponse);
+ $billingAddressResponse = $cartResponse['billing_address'];
+ self::assertArrayHasKey('shipping_addresses', $cartResponse);
+ $shippingAddressResponse = current($cartResponse['shipping_addresses']);
+ $this->assertNewAddressFields($billingAddressResponse);
+ $this->assertNewAddressFields($shippingAddressResponse, 'ShippingCartAddress');
+ }
+
/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Customer/_files/customer_two_addresses.php
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
index 891b4425fe23e..8d3f62f68a82a 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/SetBillingAddressOnCartTest.php
@@ -84,12 +84,87 @@ public function testSetNewBillingAddress()
$this->assertNewAddressFields($billingAddressResponse);
}
+ /**
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testSetNewBillingAddressWithSameAsShippingParameter()
+ {
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
+
+ $query = <<graphQlMutation($query);
+
+ self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
+ $cartResponse = $response['setBillingAddressOnCart']['cart'];
+ self::assertArrayHasKey('billing_address', $cartResponse);
+ $billingAddressResponse = $cartResponse['billing_address'];
+ self::assertArrayHasKey('shipping_addresses', $cartResponse);
+ $shippingAddressResponse = current($cartResponse['shipping_addresses']);
+ $this->assertNewAddressFields($billingAddressResponse);
+ $this->assertNewAddressFields($shippingAddressResponse, 'ShippingCartAddress');
+ }
+
/**
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
- public function testSetNewBillingAddressWithSameAsShippingParameter()
+ public function testSetNewBillingAddressWithUseForShippingParameter()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
@@ -110,7 +185,7 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
country_code: "US"
telephone: "88776655"
}
- same_as_shipping: true
+ use_for_shipping: true
}
}
) {
From 5912c53d024575a560693f790cac9579ffa75e8f Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Sun, 20 Oct 2019 15:04:11 -0500
Subject: [PATCH 0509/1978] MC-21691: [Integration Tests] Failing -
Magento.Braintree.Model.MultishippingTest.testCreateOrdersWithBraintreePaypal
- pr build fix
---
app/code/Magento/SalesRule/Model/Data/RuleDiscount.php | 1 -
.../SalesRule/{Api => Model}/Data/RuleDiscountInterface.php | 4 ++--
app/code/Magento/SalesRule/Model/Quote/Discount.php | 2 +-
app/code/Magento/SalesRule/Model/RulesApplier.php | 2 +-
app/code/Magento/SalesRule/etc/di.xml | 2 +-
app/code/Magento/SalesRule/etc/extension_attributes.xml | 4 ++--
6 files changed, 7 insertions(+), 8 deletions(-)
rename app/code/Magento/SalesRule/{Api => Model}/Data/RuleDiscountInterface.php (81%)
diff --git a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
index 526e59fe36932..a6fe5288a0efd 100644
--- a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
@@ -8,7 +8,6 @@
namespace Magento\SalesRule\Model\Data;
use Magento\SalesRule\Model\Rule\Action\Discount\Data;
-use Magento\SalesRule\Api\Data\RuleDiscountInterface;
use Magento\Framework\Api\ExtensionAttributesInterface;
/**
diff --git a/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscountInterface.php
similarity index 81%
rename from app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
rename to app/code/Magento/SalesRule/Model/Data/RuleDiscountInterface.php
index 6e404f762140d..622d3b5dd75a7 100644
--- a/app/code/Magento/SalesRule/Api/Data/RuleDiscountInterface.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscountInterface.php
@@ -6,7 +6,7 @@
declare(strict_types=1);
-namespace Magento\SalesRule\Api\Data;
+namespace Magento\SalesRule\Model\Data;
/**
* Rule discount Interface
@@ -16,7 +16,7 @@ interface RuleDiscountInterface
/**
* Get Discount Data
*
- * @return mixed | \Magento\SalesRule\Model\Rule\Action\Discount\Data
+ * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
*/
public function getDiscountData();
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index efd8e01ebc470..dac1b210693e0 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -7,7 +7,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Framework\App\ObjectManager;
-use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
+use Magento\SalesRule\Model\Data\RuleDiscountInterfaceFactory;
/**
* Discount totals calculation model.
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index a3cfba26b7cb6..e33adba4aa795 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -12,7 +12,7 @@
use Magento\SalesRule\Model\ResourceModel\Rule\Collection;
use Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory;
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
-use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
+use Magento\SalesRule\Model\Data\RuleDiscountInterfaceFactory;
/**
* Class RulesApplier
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index eb1d1ef89a575..d84cb443a0bb1 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -30,7 +30,7 @@
type="Magento\SalesRule\Model\Data\CouponMassDeleteResult" />
-
diff --git a/app/code/Magento/SalesRule/etc/extension_attributes.xml b/app/code/Magento/SalesRule/etc/extension_attributes.xml
index c69c309d8741b..c6df13e50fd15 100644
--- a/app/code/Magento/SalesRule/etc/extension_attributes.xml
+++ b/app/code/Magento/SalesRule/etc/extension_attributes.xml
@@ -7,9 +7,9 @@
-->
-
+
-
+
\ No newline at end of file
From 1c7bd5df08502541c77b4d4ea5831495c46320cd Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Sun, 20 Oct 2019 20:00:48 -0500
Subject: [PATCH 0510/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - fixed return type
---
app/code/Magento/SalesRule/Model/Data/RuleDiscount.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
index a6fe5288a0efd..6108924fcae64 100644
--- a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
@@ -7,7 +7,6 @@
namespace Magento\SalesRule\Model\Data;
-use Magento\SalesRule\Model\Rule\Action\Discount\Data;
use Magento\Framework\Api\ExtensionAttributesInterface;
/**
@@ -22,7 +21,7 @@ class RuleDiscount extends \Magento\Framework\Api\AbstractExtensibleObject imple
/**
* Get Discount Data
*
- * @return Data
+ * @return \Magento\SalesRule\Model\Rule\Action\Discount\Data
*/
public function getDiscountData()
{
From 836bbca791aacbe3a820efc3945f7e5015b4f6ba Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Sun, 20 Oct 2019 23:38:27 -0500
Subject: [PATCH 0511/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - b2b error fix
---
.../Api/Data/DiscountDataInterface.php | 39 +++++++++++++++++++
.../Data/RuleDiscountInterface.php | 4 +-
.../SalesRule/Model/Data/RuleDiscount.php | 1 +
.../SalesRule/Model/Quote/Discount.php | 2 +-
.../Magento/SalesRule/Model/RulesApplier.php | 2 +-
app/code/Magento/SalesRule/etc/di.xml | 2 +-
.../SalesRule/etc/extension_attributes.xml | 4 +-
7 files changed, 47 insertions(+), 7 deletions(-)
create mode 100644 app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
rename app/code/Magento/SalesRule/{Model => Api}/Data/RuleDiscountInterface.php (82%)
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
new file mode 100644
index 0000000000000..d5bb5a678a050
--- /dev/null
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
@@ -0,0 +1,39 @@
+
-
diff --git a/app/code/Magento/SalesRule/etc/extension_attributes.xml b/app/code/Magento/SalesRule/etc/extension_attributes.xml
index c6df13e50fd15..c69c309d8741b 100644
--- a/app/code/Magento/SalesRule/etc/extension_attributes.xml
+++ b/app/code/Magento/SalesRule/etc/extension_attributes.xml
@@ -7,9 +7,9 @@
-->
-
+
-
+
\ No newline at end of file
From 8703b104d86a511e959d539eb3b290dd5dc8ab29 Mon Sep 17 00:00:00 2001
From: Roman Zhupanyn
Date: Mon, 21 Oct 2019 09:43:45 +0300
Subject: [PATCH 0512/1978] MC-20675: Admin: Add/edit/delete related, up-sells,
cross-sells products
---
.../Catalog/Controller/Adminhtml/Product/Save/LinksTest.php | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
index e6e11b1f5b432..cc8d87ece656a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
@@ -45,7 +45,6 @@ protected function setUp()
*
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
* @magentoDbIsolation enabled
- * @param array $postData
* @return void
*/
public function testAddRelatedUpSellCrossSellProducts(): void
@@ -71,7 +70,7 @@ public function testAddRelatedUpSellCrossSellProducts(): void
*
* @return array
*/
- public function getPostData(): array
+ private function getPostData(): array
{
return [
'product' => [
From 6007afbb3c0bba249ce62d5b367858b917742059 Mon Sep 17 00:00:00 2001
From: DianaRusin
Date: Mon, 21 Oct 2019 10:56:06 +0300
Subject: [PATCH 0513/1978] MC-20423: [Integration Test] Import Table Rates to
be used in Configuration Settings
---
.../Config/ImportExportTableratesTest.php | 44 ++++++++++++-------
.../_files/tablerate_create_file_in_tmp.php | 4 +-
.../tablerate_create_file_in_tmp_rollback.php | 5 ++-
3 files changed, 35 insertions(+), 18 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php
index e4277683808d2..58549f594c033 100644
--- a/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/Controller/Adminhtml/System/Config/ImportExportTableratesTest.php
@@ -9,10 +9,12 @@
namespace Magento\OfflineShipping\Controller\Adminhtml\System\Config;
use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\Message\MessageInterface;
use Magento\Framework\View\LayoutInterface;
use Magento\OfflineShipping\Block\Adminhtml\Carrier\Tablerate\Grid;
-use Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate;
+use Magento\OfflineShipping\Model\ResourceModel\Carrier\Tablerate\Collection;
+use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\ObjectManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Framework\Filesystem;
@@ -36,9 +38,14 @@ class ImportExportTableratesTest extends \Magento\TestFramework\TestCase\Abstrac
private $fileSystem;
/**
- * @var DirectoryList
+ * @var StoreManagerInterface
*/
- private $varDirectory;
+ private $storeManager;
+
+ /**
+ * @var int
+ */
+ private $websiteId;
/**
* @inheritdoc
@@ -47,7 +54,8 @@ protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
$this->fileSystem = $this->objectManager->get(Filesystem::class);
- $this->varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $this->storeManager = Bootstrap::getObjectManager()->get(StoreManagerInterface::class);
+ $this->websiteId = $this->storeManager->getWebsite()->getId();
parent::setUp();
}
@@ -85,34 +93,38 @@ public function testImportExportTablerates(): void
]
)->setMethod(HttpRequest::METHOD_POST);
- $this->dispatch('backend/admin/system_config/save/section/carriers/website/1/');
+ $this->dispatch('backend/admin/system_config/save/section/carriers/website/' . $this->websiteId . '/');
$this->assertSessionMessages(
$this->equalTo([(string)__('You saved the configuration.')]),
MessageInterface::TYPE_SUCCESS
);
- $tablerateResourceModel = $this->objectManager->create(Tablerate::class);
- $connection = $tablerateResourceModel->getConnection();
+ /** @var Collection $tablerateCollection */
+ $tablerateCollection = $this->objectManager->create(Collection::class);
+ $tablerateData = $tablerateCollection->setConditionFilter('package_weight')->getItems()[0]->getData();
+ $this->assertEquals('666.0000', $tablerateData['price']);
+ $this->assertEquals('USA', $tablerateData['dest_country']);
+ $this->assertEquals('10.0000', $tablerateData['condition_value']);
- $selectData = $connection->select()->from($tablerateResourceModel->getTable('shipping_tablerate'));
- $this->assertNotEmpty($connection->fetchRow($selectData));
-
- $exportCsv = $this->getTablerateCsv();
- $exportCsvContent = $this->varDirectory->openFile($exportCsv['value'], 'r')->readAll();
+ $exportCsvContent = $this->getTablerateCsv();
$importCsvContent = $tmpDirectory->openFile($importCsvPath, 'r')->readAll();
$this->assertEquals($importCsvContent, $exportCsvContent);
}
/**
- * @return array
+ * @return string
*/
- private function getTablerateCsv(): array
+ private function getTablerateCsv(): string
{
+ /** @var WriteInterface $varDirectory */
+ $varDirectory = $this->fileSystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+
/** @var Grid $gridBlock */
$gridBlock = $this->objectManager->get(LayoutInterface::class)->createBlock(Grid::class);
- $exportCsv = $gridBlock->setWebsiteId(1)->setConditionName('package_weight')->getCsvFile();
+ $exportCsv = $gridBlock->setWebsiteId($this->websiteId)->setConditionName('package_weight')->getCsvFile();
+ $exportCsvContent = $varDirectory->openFile($exportCsv['value'], 'r')->readAll();
- return $exportCsv;
+ return $exportCsvContent;
}
}
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
index e12fbf8967b62..edeb533ad6470 100644
--- a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp.php
@@ -8,11 +8,13 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
$importCsv = 'tablerates.csv';
$objectManager = Bootstrap::getObjectManager();
+/** @var Filesystem $fileSystem */
$fileSystem = $objectManager->get(Filesystem::class);
-
+/** @var WriteInterface $tmpDirectory */
$tmpDirectory = $fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
$importCsvPath = $tmpDirectory->getAbsolutePath($importCsv);
diff --git a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php
index 24448a56a4263..2333e48ee71e5 100644
--- a/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/OfflineShipping/_files/tablerate_create_file_in_tmp_rollback.php
@@ -8,10 +8,13 @@
use Magento\Framework\App\Filesystem\DirectoryList;
use Magento\Framework\Filesystem;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
$objectManager = Bootstrap::getObjectManager();
+/** @var Filesystem $fileSystem */
$fileSystem = $objectManager->get(Filesystem::class);
+/** @var WriteInterface $tmpDirectory */
$tmpDirectory = $fileSystem->getDirectoryWrite(DirectoryList::SYS_TMP);
$fileName = 'tablerates.csv';
-unlink($tmpDirectory->getAbsolutePath($fileName));
+$tmpDirectory->delete($fileName);
From 7cc4507e664596e89c1d50ccc4757c16039f567f Mon Sep 17 00:00:00 2001
From: Christos Stergianos
Date: Mon, 21 Oct 2019 12:11:58 +0200
Subject: [PATCH 0514/1978] Fix label being cutoff in Newsletter registration
In this commit the label to Register in the newsletter that exists in the homepage had the text completely cut off on Tablet iOS devices
To solve this the width property was altered to use the max-content value, and a max-width property is also added. Also some paddings were set to 0 because Safari keeps adding some default padding values.
---
.../luma/Magento_Newsletter/web/css/source/_module.less | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
index d7ee1319c9a43..5e8edf7fa21d3 100644
--- a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
@@ -46,7 +46,8 @@
}
input {
- padding-left: 35px;
+ padding: 0 0 0 35px; // Reset some default Safari padding values.
+ margin-right: 35px;
}
.title {
@@ -78,7 +79,8 @@
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.block.newsletter {
- width: 34%;
+ .lib-css(width, max-content);
+ max-width: 44%;
}
}
From 991b9141060108420cec21d9ade2ace0d1313222 Mon Sep 17 00:00:00 2001
From: Christos Stergianos
Date: Mon, 21 Oct 2019 12:36:30 +0200
Subject: [PATCH 0515/1978] Sort alphabetically the less properties
During deployment an error was thrown that the properties are not sorted alphabetically. This is now solved.
---
.../Magento/luma/Magento_Newsletter/web/css/source/_module.less | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
index 5e8edf7fa21d3..cae67fdb9bf25 100644
--- a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
@@ -46,8 +46,8 @@
}
input {
- padding: 0 0 0 35px; // Reset some default Safari padding values.
margin-right: 35px;
+ padding: 0 0 0 35px; // Reset some default Safari padding values.
}
.title {
From 0fc0384978c391812469a998d779c98cb68c46ef Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Mon, 21 Oct 2019 13:48:51 +0300
Subject: [PATCH 0516/1978] MC-20691: Admin: Update attribute set
---
...ibuteSet.php => GetAttributeSetByName.php} | 4 +--
.../Adminhtml/Product/Set/UpdateTest.php | 30 ++++++++-----------
..._on_default_with_custom_group_rollback.php | 20 +++----------
.../product_with_test_attribute_set.php | 9 +++---
...oduct_with_test_attribute_set_rollback.php | 5 ++--
5 files changed, 26 insertions(+), 42 deletions(-)
rename dev/tests/integration/framework/Magento/TestFramework/Eav/Model/{AttributeSet.php => GetAttributeSetByName.php} (92%)
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
similarity index 92%
rename from dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php
rename to dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
index e933d43a84807..12ff978a12e12 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/AttributeSet.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
@@ -14,7 +14,7 @@
/**
* Attribute set additional functions.
*/
-class AttributeSet
+class GetAttributeSetByName
{
/**
* @var SearchCriteriaBuilder
@@ -44,7 +44,7 @@ public function __construct(
* @param string $attributeSetName
* @return AttributeSetInterface|null
*/
- public function getAttributeSetByName(string $attributeSetName): ?AttributeSetInterface
+ public function execute(string $attributeSetName): ?AttributeSetInterface
{
$this->searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
$searchCriteria = $this->searchCriteriaBuilder->create();
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
index 70b0ea66ea549..765f59b15be83 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/UpdateTest.php
@@ -17,7 +17,7 @@
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Serialize\Serializer\Json;
-use Magento\TestFramework\Eav\Model\AttributeSet;
+use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
use Magento\TestFramework\TestCase\AbstractBackendController;
/**
@@ -46,9 +46,9 @@ class UpdateTest extends AbstractBackendController
private $attributeGroupCollectionFactory;
/**
- * @var AttributeSet
+ * @var GetAttributeSetByName
*/
- private $attributeSet;
+ private $getAttributeSetByName;
/**
* @inheritdoc
@@ -60,7 +60,7 @@ protected function setUp()
$this->attributeSetRepository = $this->_objectManager->get(AttributeSetRepositoryInterface::class);
$this->attributeManagement = $this->_objectManager->get(AttributeManagementInterface::class);
$this->attributeGroupCollectionFactory = $this->_objectManager->get(CollectionFactory::class);
- $this->attributeSet = $this->_objectManager->get(AttributeSet::class);
+ $this->getAttributeSetByName = $this->_objectManager->get(GetAttributeSetByName::class);
}
/**
@@ -74,7 +74,7 @@ protected function setUp()
*/
public function testUpdateAttributeSetName(): void
{
- $attributeSet = $this->attributeSet->getAttributeSetByName('new_attribute_set');
+ $attributeSet = $this->getAttributeSetByName->execute('new_attribute_set');
$currentAttrSetName = $attributeSet->getAttributeSetName();
$this->assertNotNull($attributeSet);
$postData = $this->prepareDataToRequest($attributeSet);
@@ -102,7 +102,7 @@ public function testUpdateAttributeSetName(): void
*/
public function testUpdateAttributeSetWithNewGroup(): void
{
- $currentAttrSet = $this->attributeSet->getAttributeSetByName('new_attribute_set');
+ $currentAttrSet = $this->getAttributeSetByName->execute('new_attribute_set');
$this->assertNotNull($currentAttrSet);
$attrSetId = (int)$currentAttrSet->getAttributeSetId();
$currentAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
@@ -140,18 +140,14 @@ public function testUpdateAttributeSetWithNewGroup(): void
public function testDeleteCustomGroupFromCustomAttributeSet(): void
{
$testGroupName = 'Test attribute group name';
- $currentAttrSet = $this->attributeSet->getAttributeSetByName('new_attribute_set');
+ $currentAttrSet = $this->getAttributeSetByName->execute('new_attribute_set');
$this->assertNotNull($currentAttrSet);
$attrSetId = (int)$currentAttrSet->getAttributeSetId();
- $currentAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
- $customGroup = null;
- /** @var AttributeGroupInterface $attrGroup */
- foreach ($currentAttrGroups as $attrGroup) {
- if ($attrGroup->getAttributeGroupName() === $testGroupName) {
- $customGroup = $attrGroup;
- break;
- }
- }
+ $currentAttrGroupsCollection = $this->getAttributeSetGroupCollection($attrSetId);
+ $customGroup = $currentAttrGroupsCollection->getItemByColumnValue(
+ AttributeGroupInterface::GROUP_NAME,
+ $testGroupName
+ );
$this->assertNotNull($customGroup);
$postData = $this->prepareDataToRequest($currentAttrSet);
$postData['removeGroups'] = [
@@ -163,7 +159,7 @@ public function testDeleteCustomGroupFromCustomAttributeSet(): void
MessageInterface::TYPE_SUCCESS
);
$updatedAttrGroups = $this->getAttributeSetGroupCollection($attrSetId)->getItems();
- $diffGroups = array_diff_key($currentAttrGroups, $updatedAttrGroups);
+ $diffGroups = array_diff_key($currentAttrGroupsCollection->getItems(), $updatedAttrGroups);
$this->assertCount(1, $diffGroups);
/** @var AttributeGroupInterface $deletedGroup */
$deletedGroup = reset($diffGroups);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
index 701a45e303589..f8628ea2d6ddb 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
@@ -5,28 +5,16 @@
*/
declare(strict_types=1);
-use Magento\Catalog\Api\Data\ProductAttributeInterface;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
-use Magento\Eav\Api\Data\AttributeSetInterface;
-use Magento\Eav\Model\Entity\Type;
-use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\Collection;
-use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory;
+use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
use Magento\TestFramework\Helper\Bootstrap;
$objectManager = Bootstrap::getObjectManager();
+/** @var GetAttributeSetByName $getAttributeSetByName */
+$getAttributeSetByName = $objectManager->get(GetAttributeSetByName::class);
/** @var AttributeSetRepositoryInterface $attributeSetRepository */
$attributeSetRepository = $objectManager->get(AttributeSetRepositoryInterface::class);
-/** @var Type $entityType */
-$entityType = $objectManager->create(Type::class)->loadByCode(ProductAttributeInterface::ENTITY_TYPE_CODE);
-/** @var Collection $attributeSetCollection */
-$attributeSetCollection = $objectManager->create(CollectionFactory::class)->create();
-$attributeSetCollection->addFilter('attribute_set_name', 'new_attribute_set');
-$attributeSetCollection->addFilter('entity_type_id', $entityType->getId());
-$attributeSetCollection->setOrder('attribute_set_id');
-$attributeSetCollection->setPageSize(1);
-$attributeSetCollection->load();
-/** @var AttributeSetInterface $attributeSet */
-$attributeSet = $attributeSetCollection->fetchItem();
+$attributeSet = $getAttributeSetByName->execute('new_attribute_set');
if ($attributeSet) {
$attributeSetRepository->delete($attributeSet);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
index 31fdc4bc704b9..5d276073cbd3f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
@@ -9,7 +9,7 @@
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Catalog\Model\ProductFactory;
-use Magento\TestFramework\Eav\Model\AttributeSet;
+use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\Store\Model\StoreManagerInterface;
@@ -20,13 +20,12 @@
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
/** @var ProductFactory $productFactory */
$productFactory = $objectManager->get(ProductFactory::class);
-/** @var AttributeSet $attributeSet */
-$attributeSet = $objectManager->get(AttributeSet::class);
-$customAttributeSet = $attributeSet->getAttributeSetByName('new_attribute_set');
+/** @var GetAttributeSetByName $attributeSet */
+$attributeSet = $objectManager->get(GetAttributeSetByName::class);
+$customAttributeSet = $attributeSet->execute('new_attribute_set');
$product = $productFactory->create();
$product
->setTypeId('simple')
- ->setId(1)
->setAttributeSetId($customAttributeSet->getAttributeSetId())
->setWebsiteIds([1])
->setStoreId($storeManager->getStore('admin')->getId())
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
index cef2f3ac75451..f92eb61865b70 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
@@ -7,6 +7,7 @@
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\CatalogInventory\Model\StockRegistryStorage;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Registry;
use Magento\TestFramework\Helper\Bootstrap;
@@ -22,8 +23,8 @@
try {
$product = $productRepository->get('simple');
$productRepository->delete($product);
-} catch (\Exception $e) {
-
+} catch (NoSuchEntityException $e) {
+ //Product already deleted.
}
$stockRegistryStorage->clean();
$registry->unregister('isSecureArea');
From 06cf340e5f6cc6ded9cd7f6e5ee7cb59db7c947a Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Mon, 21 Oct 2019 14:43:16 +0300
Subject: [PATCH 0517/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
index d3546d06492be..342a8324ae18c 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
@@ -37,6 +37,7 @@
+
From a7a72fd34854856ff8fa0e03e2498da9e1762c6f Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Mon, 21 Oct 2019 15:54:39 +0300
Subject: [PATCH 0518/1978] MC-20691: Admin: Update attribute set
---
.../Product/Form/Modifier/Eav/AttributeSetGroupsTest.php | 1 -
.../Magento/Catalog/_files/product_with_test_attribute_set.php | 2 ++
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
index 152f826e5969f..71030adff29da 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/AttributeSetGroupsTest.php
@@ -100,7 +100,6 @@ protected function setUp()
/**
* Check that custom group for custom attribute set not added to product form modifier meta data.
*
- * @magentoDataFixture Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
* @magentoDataFixture Magento/Catalog/_files/product_with_test_attribute_set.php
*
* @magentoDbIsolation disabled
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
index 5d276073cbd3f..8f2f6ebf737ee 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
@@ -5,6 +5,8 @@
*/
declare(strict_types=1);
+require __DIR__ . '/attribute_set_based_on_default_with_custom_group.php';
+
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Catalog\Model\Product\Visibility;
From 18fb48296860b0fad99c80a44995f104f550f42c Mon Sep 17 00:00:00 2001
From: paul-stolk-webdiensten
<32934145+paul-stolk-webdiensten@users.noreply.github.com>
Date: Mon, 21 Oct 2019 15:12:51 +0200
Subject: [PATCH 0519/1978] Filter error array by unique values
---
app/code/Magento/Catalog/Model/Product/Type/AbstractType.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
index e6804d9246faa..7321a95c7aa68 100644
--- a/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
+++ b/app/code/Magento/Catalog/Model/Product/Type/AbstractType.php
@@ -603,7 +603,7 @@ protected function _prepareOptions(\Magento\Framework\DataObject $buyRequest, $p
}
}
if (count($results) > 0) {
- throw new LocalizedException(__(implode("\n", $results)));
+ throw new LocalizedException(__(implode("\n", array_unique($results))));
}
}
From c1bd70ef62790314ce129d8f96c494eaa2e0c2e3 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Mon, 21 Oct 2019 16:29:27 +0300
Subject: [PATCH 0520/1978] MC-20691: Admin: Update attribute set
---
.../Catalog/_files/product_with_test_attribute_set.php | 6 ++----
.../_files/product_with_test_attribute_set_rollback.php | 2 ++
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
index 8f2f6ebf737ee..0616a22b1deee 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
@@ -11,13 +11,11 @@
use Magento\Catalog\Model\Product\Attribute\Source\Status;
use Magento\Catalog\Model\Product\Visibility;
use Magento\Catalog\Model\ProductFactory;
+use Magento\Store\Model\Store;
use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
use Magento\TestFramework\Helper\Bootstrap;
-use Magento\Store\Model\StoreManagerInterface;
$objectManager = Bootstrap::getObjectManager();
-/** @var StoreManagerInterface $storeManager */
-$storeManager = $objectManager->get(StoreManagerInterface::class);
/** @var ProductRepositoryInterface $productRepository */
$productRepository = $objectManager->get(ProductRepositoryInterface::class);
/** @var ProductFactory $productFactory */
@@ -30,7 +28,7 @@
->setTypeId('simple')
->setAttributeSetId($customAttributeSet->getAttributeSetId())
->setWebsiteIds([1])
- ->setStoreId($storeManager->getStore('admin')->getId())
+ ->setStoreId(Store::DEFAULT_STORE_ID)
->setName('Simple Product')
->setSku('simple')
->setPrice(10)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
index f92eb61865b70..1ec341cd4fd58 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
@@ -29,3 +29,5 @@
$stockRegistryStorage->clean();
$registry->unregister('isSecureArea');
$registry->register('isSecureArea', false);
+
+require __DIR__ . '/attribute_set_based_on_default_with_custom_group_rollback.php';
From 5109a4541b0989b33868ed26caf32dd5d5eea293 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Mon, 21 Oct 2019 16:44:53 +0300
Subject: [PATCH 0521/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
index 342a8324ae18c..d3e66c0134c4c 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
@@ -19,14 +19,14 @@
-
+
-
-
+
+
@@ -34,10 +34,12 @@
-
-
-
+
+
+
+
+
From 20c42166307cdb828f21fd6ee62c0e82c0486018 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 21 Oct 2019 09:52:19 -0500
Subject: [PATCH 0522/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - semantic fix
---
.../Model/Resolver/CartItemPrices.php | 2 +-
.../QuoteGraphQl/Model/Resolver/Discounts.php | 2 +-
.../Api/Data/DiscountDataInterface.php | 11 +-
.../SalesRule/Model/Data/DiscountData.php | 106 ++++++++++++++++++
.../SalesRule/Model/Quote/Discount.php | 26 +++--
.../Magento/SalesRule/Model/RulesApplier.php | 32 ++++--
app/code/Magento/SalesRule/etc/di.xml | 2 +
7 files changed, 158 insertions(+), 23 deletions(-)
create mode 100644 app/code/Magento/SalesRule/Model/Data/DiscountData.php
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
index d740ea0d18513..f0d97780845e8 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CartItemPrices.php
@@ -93,7 +93,7 @@ private function getDiscountValues($cartItem, $currencyCode)
foreach ($itemDiscounts as $value) {
$discount = [];
$amount = [];
- /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
+ /* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discountData */
$discountData = $value->getDiscountData();
$discountAmount = $discountData->getAmount();
$discount['label'] = $value->getRuleLabel() ?: __('Discount');
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
index 8d42d4484a360..f457c7783b799 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
@@ -47,7 +47,7 @@ private function getDiscountValues(Quote $quote)
$discount = [];
$amount = [];
$discount['label'] = $value->getRuleLabel() ?: __('Discount');
- /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discountData */
+ /* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discountData */
$discountData = $value->getDiscountData();
$amount['value'] = $discountData->getAmount();
$amount['currency'] = $quote->getQuoteCurrencyCode();
diff --git a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
index d5bb5a678a050..38ac93dc9762f 100644
--- a/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
+++ b/app/code/Magento/SalesRule/Api/Data/DiscountDataInterface.php
@@ -7,6 +7,9 @@
namespace Magento\SalesRule\Api\Data;
+/**
+ * Discount Data Interface
+ */
interface DiscountDataInterface
{
/**
@@ -14,26 +17,26 @@ interface DiscountDataInterface
*
* @return float
*/
- public function getAmount(): float;
+ public function getAmount();
/**
* Get Base Amount
*
* @return float
*/
- public function getBaseAmount(): float;
+ public function getBaseAmount();
/**
* Get Original Amount
*
* @return float
*/
- public function getOriginalAmount(): float;
+ public function getOriginalAmount();
/**
* Get Base Original Amount
*
* @return float
*/
- public function getBaseOriginalAmount(): float;
+ public function getBaseOriginalAmount();
}
diff --git a/app/code/Magento/SalesRule/Model/Data/DiscountData.php b/app/code/Magento/SalesRule/Model/Data/DiscountData.php
new file mode 100644
index 0000000000000..10aefab3adc78
--- /dev/null
+++ b/app/code/Magento/SalesRule/Model/Data/DiscountData.php
@@ -0,0 +1,106 @@
+_get(self::AMOUNT);
+ }
+
+ /**
+ * Set Amount
+ *
+ * @param float $amount
+ * @return $this
+ */
+ public function setAmount(float $amount)
+ {
+ return $this->setData(self::AMOUNT, $amount);
+ }
+
+ /**
+ * Get Base Amount
+ *
+ * @return float
+ */
+ public function getBaseAmount()
+ {
+ return $this->_get(self::BASE_AMOUNT);
+ }
+
+ /**
+ * Set Base Amount
+ *
+ * @param float $amount
+ * @return $this
+ */
+ public function setBaseAmount(float $amount)
+ {
+ return $this->setData(self::BASE_AMOUNT, $amount);
+ }
+
+ /**
+ * Get Original Amount
+ *
+ * @return float
+ */
+ public function getOriginalAmount()
+ {
+ return $this->_get(self::ORIGINAL_AMOUNT);
+ }
+
+ /**
+ * Set Original Amount
+ *
+ * @param float $amount
+ * @return $this
+ */
+ public function setOriginalAmount(float $amount)
+ {
+ return $this->setData(self::ORIGINAL_AMOUNT, $amount);
+ }
+
+ /**
+ * Get Base Original Amount
+ *
+ * @return float
+ */
+ public function getBaseOriginalAmount()
+ {
+ return $this->_get(self::BASE_ORIGINAL_AMOUNT);
+ }
+
+ /**
+ * Set Base Original Amount
+ *
+ * @param float $amount
+ * @return $this
+ */
+ public function setBaseOriginalAmount(float $amount)
+ {
+ return $this->setData(self::BASE_ORIGINAL_AMOUNT, $amount);
+ }
+}
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index efd8e01ebc470..839b637728cd2 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -8,6 +8,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Framework\App\ObjectManager;
use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
+use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory;
/**
* Discount totals calculation model.
@@ -50,6 +51,11 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
*/
private $discountInterfaceFactory;
+ /**
+ * @var DiscountDataInterfaceFactory
+ */
+ private $discountDataInterfaceFactory;
+
/**
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -57,6 +63,7 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
* @param DataFactory|null $discountDataFactory
* @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
+ * @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory
*/
public function __construct(
\Magento\Framework\Event\ManagerInterface $eventManager,
@@ -64,7 +71,8 @@ public function __construct(
\Magento\SalesRule\Model\Validator $validator,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
DataFactory $discountDataFactory = null,
- RuleDiscountInterfaceFactory $discountInterfaceFactory = null
+ RuleDiscountInterfaceFactory $discountInterfaceFactory = null,
+ DiscountDataInterfaceFactory $discountDataInterfaceFactory = null
) {
$this->setCode(self::COLLECTOR_TYPE_CODE);
$this->eventManager = $eventManager;
@@ -74,6 +82,8 @@ public function __construct(
$this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
$this->discountInterfaceFactory = $discountInterfaceFactory
?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
+ $this->discountDataInterfaceFactory = $discountDataInterfaceFactory
+ ?: ObjectManager::getInstance()->get(DiscountDataInterfaceFactory::class);
}
/**
@@ -260,7 +270,7 @@ private function aggregateDiscountPerRule(
$discountBreakdown = $item->getExtensionAttributes()->getDiscounts();
if ($discountBreakdown) {
foreach ($discountBreakdown as $value) {
- /* @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
+ /* @var \Magento\SalesRule\Api\Data\DiscountDataInterface $discount */
$discount = $value->getDiscountData();
$ruleLabel = $value->getRuleLabel();
$ruleID = $value->getRuleID();
@@ -275,11 +285,13 @@ private function aggregateDiscountPerRule(
$discountData->getBaseOriginalAmount()+$discount->getBaseOriginalAmount()
);
} else {
- $discountData = $this->discountFactory->create();
- $discountData->setBaseAmount($discount->getBaseAmount());
- $discountData->setAmount($discount->getAmount());
- $discountData->setOriginalAmount($discount->getOriginalAmount());
- $discountData->setBaseOriginalAmount($discount->getBaseOriginalAmount());
+ $data = [
+ 'amount' => $discount->getAmount(),
+ 'base_amount' => $discount->getBaseAmount(),
+ 'original_amount' => $discount->getOriginalAmount(),
+ 'base_original_amount' => $discount->getBaseOriginalAmount()
+ ];
+ $discountData = $this->discountDataInterfaceFactory->create(['data' => $data]);
$data = [
'discount' => $discountData,
'rule' => $ruleLabel,
diff --git a/app/code/Magento/SalesRule/Model/RulesApplier.php b/app/code/Magento/SalesRule/Model/RulesApplier.php
index a3cfba26b7cb6..270732c8e0278 100644
--- a/app/code/Magento/SalesRule/Model/RulesApplier.php
+++ b/app/code/Magento/SalesRule/Model/RulesApplier.php
@@ -13,6 +13,7 @@
use Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory;
use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
+use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory;
/**
* Class RulesApplier
@@ -53,18 +54,25 @@ class RulesApplier
*/
private $discountInterfaceFactory;
+ /**
+ * @var DiscountDataInterfaceFactory
+ */
+ private $discountDataInterfaceFactory;
+
/**
* @var array
*/
private $discountAggregator;
/**
+ * RulesApplier constructor.
* @param CalculatorFactory $calculatorFactory
* @param \Magento\Framework\Event\ManagerInterface $eventManager
* @param Utility $utility
* @param ChildrenValidationLocator|null $childrenValidationLocator
* @param DataFactory|null $discountDataFactory
* @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
+ * @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory
*/
public function __construct(
\Magento\SalesRule\Model\Rule\Action\Discount\CalculatorFactory $calculatorFactory,
@@ -72,7 +80,8 @@ public function __construct(
\Magento\SalesRule\Model\Utility $utility,
ChildrenValidationLocator $childrenValidationLocator = null,
DataFactory $discountDataFactory = null,
- RuleDiscountInterfaceFactory $discountInterfaceFactory = null
+ RuleDiscountInterfaceFactory $discountInterfaceFactory = null,
+ DiscountDataInterfaceFactory $discountDataInterfaceFactory = null
) {
$this->calculatorFactory = $calculatorFactory;
$this->validatorUtility = $utility;
@@ -82,6 +91,8 @@ public function __construct(
$this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
$this->discountInterfaceFactory = $discountInterfaceFactory
?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
+ $this->discountDataInterfaceFactory = $discountDataInterfaceFactory
+ ?: ObjectManager::getInstance()->get(DiscountDataInterfaceFactory::class);
}
/**
@@ -228,21 +239,22 @@ protected function getDiscountData($item, $rule, $address)
private function setDiscountBreakdown($discountData, $item, $rule, $address)
{
if ($discountData->getAmount() > 0 && $item->getExtensionAttributes()) {
- /** @var \Magento\SalesRule\Model\Rule\Action\Discount\Data $discount */
- $discount = $this->discountFactory->create();
- $discount->setBaseOriginalAmount($discountData->getBaseOriginalAmount());
- $discount->setAmount($discountData->getAmount());
- $discount->setBaseAmount($discountData->getBaseAmount());
- $discount->setOriginalAmount($discountData->getOriginalAmount());
+ $data = [
+ 'amount' => $discountData->getAmount(),
+ 'base_amount' => $discountData->getBaseAmount(),
+ 'original_amount' => $discountData->getOriginalAmount(),
+ 'base_original_amount' => $discountData->getBaseOriginalAmount()
+ ];
+ $itemDiscount = $this->discountDataInterfaceFactory->create(['data' => $data]);
$ruleLabel = $rule->getStoreLabel($address->getQuote()->getStore()) ?: __('Discount');
$data = [
- 'discount' => $discount,
+ 'discount' => $itemDiscount,
'rule' => $ruleLabel,
'rule_id' => $rule->getId(),
];
/** @var \Magento\SalesRule\Model\Data\RuleDiscount $itemDiscount */
- $itemDiscount = $this->discountInterfaceFactory->create(['data' => $data]);
- $this->discountAggregator[] = $itemDiscount;
+ $ruleDiscount = $this->discountInterfaceFactory->create(['data' => $data]);
+ $this->discountAggregator[] = $ruleDiscount;
$item->getExtensionAttributes()->setDiscounts($this->discountAggregator);
}
return $this;
diff --git a/app/code/Magento/SalesRule/etc/di.xml b/app/code/Magento/SalesRule/etc/di.xml
index eb1d1ef89a575..abb581175e36a 100644
--- a/app/code/Magento/SalesRule/etc/di.xml
+++ b/app/code/Magento/SalesRule/etc/di.xml
@@ -32,6 +32,8 @@
type="Magento\SalesRule\Model\Service\CouponManagementService" />
+
From b62c1a0173eac89678395a3376b743e08a7e464e Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 21 Oct 2019 11:02:59 -0500
Subject: [PATCH 0523/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - static error fix
---
.../SalesRule/Model/Data/DiscountData.php | 23 +++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/app/code/Magento/SalesRule/Model/Data/DiscountData.php b/app/code/Magento/SalesRule/Model/Data/DiscountData.php
index 10aefab3adc78..cfad4b5c09c55 100644
--- a/app/code/Magento/SalesRule/Model/Data/DiscountData.php
+++ b/app/code/Magento/SalesRule/Model/Data/DiscountData.php
@@ -8,6 +8,7 @@
namespace Magento\SalesRule\Model\Data;
use Magento\SalesRule\Api\Data\DiscountDataInterface;
+use Magento\Framework\Api\ExtensionAttributesInterface;
/**
* Discount Data Model
@@ -103,4 +104,26 @@ public function setBaseOriginalAmount(float $amount)
{
return $this->setData(self::BASE_ORIGINAL_AMOUNT, $amount);
}
+
+ /**
+ * Retrieve existing extension attributes object or create a new one.
+ *
+ * @return ExtensionAttributesInterface|null
+ */
+ public function getExtensionAttributes()
+ {
+ return $this->_getExtensionAttributes();
+ }
+
+ /**
+ * Set an extension attributes object.
+ *
+ * @param ExtensionAttributesInterface $extensionAttributes
+ * @return $this
+ */
+ public function setExtensionAttributes(
+ ExtensionAttributesInterface $extensionAttributes
+ ) {
+ return $this->_setExtensionAttributes($extensionAttributes);
+ }
}
From 21112c6f1bec019dea0d1f9c12f59274ccbc50a2 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 21 Oct 2019 11:56:17 -0500
Subject: [PATCH 0524/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - static error fix
---
app/code/Magento/SalesRule/Model/Quote/Discount.php | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/app/code/Magento/SalesRule/Model/Quote/Discount.php b/app/code/Magento/SalesRule/Model/Quote/Discount.php
index 839b637728cd2..69abac8309f90 100644
--- a/app/code/Magento/SalesRule/Model/Quote/Discount.php
+++ b/app/code/Magento/SalesRule/Model/Quote/Discount.php
@@ -5,7 +5,6 @@
*/
namespace Magento\SalesRule\Model\Quote;
-use Magento\SalesRule\Model\Rule\Action\Discount\DataFactory;
use Magento\Framework\App\ObjectManager;
use Magento\SalesRule\Api\Data\RuleDiscountInterfaceFactory;
use Magento\SalesRule\Api\Data\DiscountDataInterfaceFactory;
@@ -41,11 +40,6 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
*/
protected $priceCurrency;
- /**
- * @var \Magento\SalesRule\Model\Rule\Action\Discount\DataFactory
- */
- private $discountFactory;
-
/**
* @var RuleDiscountInterfaceFactory
*/
@@ -61,7 +55,6 @@ class Discount extends \Magento\Quote\Model\Quote\Address\Total\AbstractTotal
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\SalesRule\Model\Validator $validator
* @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency
- * @param DataFactory|null $discountDataFactory
* @param RuleDiscountInterfaceFactory|null $discountInterfaceFactory
* @param DiscountDataInterfaceFactory|null $discountDataInterfaceFactory
*/
@@ -70,7 +63,6 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\SalesRule\Model\Validator $validator,
\Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency,
- DataFactory $discountDataFactory = null,
RuleDiscountInterfaceFactory $discountInterfaceFactory = null,
DiscountDataInterfaceFactory $discountDataInterfaceFactory = null
) {
@@ -79,7 +71,6 @@ public function __construct(
$this->calculator = $validator;
$this->storeManager = $storeManager;
$this->priceCurrency = $priceCurrency;
- $this->discountFactory = $discountDataFactory ?: ObjectManager::getInstance()->get(DataFactory::class);
$this->discountInterfaceFactory = $discountInterfaceFactory
?: ObjectManager::getInstance()->get(RuleDiscountInterfaceFactory::class);
$this->discountDataInterfaceFactory = $discountDataInterfaceFactory
From 89e8ff7416d411854be0ae8ff3bc77e0942020f6 Mon Sep 17 00:00:00 2001
From: Krishna Abothu
Date: Mon, 21 Oct 2019 13:45:06 -0500
Subject: [PATCH 0525/1978] MC-21430: [Functional Test]
Magento\FunctionalTestingFramework.functional\MSI_Multi_Mode.MinAndMaxQtyInShoppingCartAppliedToSimpleProductOnProductPageAndCheckedInAdminTest
"Modified locator to identify the right product quantity field"
---
.../Test/Mftf/Section/AdminCustomerCreateNewOrderSection.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerCreateNewOrderSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerCreateNewOrderSection.xml
index a01687990999e..6b0cafe8dc00b 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerCreateNewOrderSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerCreateNewOrderSection.xml
@@ -12,7 +12,7 @@
-
+
From 51e006225f6f5a236c92521782c9de6ddc5236c6 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Mon, 21 Oct 2019 14:17:37 -0500
Subject: [PATCH 0526/1978] MC-21933: Possible type mismatch in product
collection
---
.../ResourceModel/Product/CollectionTest.php | 50 +++++++++++++++++--
1 file changed, 46 insertions(+), 4 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php
index de0e881474cf0..86dcf9d96d086 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/Product/CollectionTest.php
@@ -277,15 +277,57 @@ public function testAddAttributeToFilterAffectsGetSize(): void
}
/**
- * Add tier price attribute filter to collection
+ * Add tier price attribute filter to collection with different condition types.
*
+ * @param mixed $condition
* @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/few_simple_products.php
* @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
+ *
+ * @dataProvider addAttributeTierPriceToFilterDataProvider
+ */
+ public function testAddAttributeTierPriceToFilter($condition): void
+ {
+ $this->collection->addAttributeToFilter('tier_price', $condition);
+ $this->assertEquals(1, $this->collection->getSize());
+ }
+
+ /**
+ * @return array
+ */
+ public function addAttributeTierPriceToFilterDataProvider(): array
+ {
+ return [
+ 'condition is array' => [['eq' => 8]],
+ 'condition is string' => ['8'],
+ 'condition is int' => [8],
+ 'condition is null' => [null]
+ ];
+ }
+
+ /**
+ * Add is_saleable attribute filter to collection with different condition types.
+ *
+ * @param mixed $condition
+ * @magentoDataFixture Magento/Catalog/Model/ResourceModel/_files/product_simple.php
+ *
+ * @dataProvider addAttributeIsSaleableToFilterDataProvider
*/
- public function testAddAttributeTierPriceToFilter(): void
+ public function testAddAttributeIsSaleableToFilter($condition): void
{
- $this->assertEquals(11, $this->collection->getSize());
- $this->collection->addAttributeToFilter('tier_price', ['gt' => 0]);
+ $this->collection->addAttributeToFilter('is_saleable', $condition);
$this->assertEquals(1, $this->collection->getSize());
}
+
+ /**
+ * @return array
+ */
+ public function addAttributeIsSaleableToFilterDataProvider(): array
+ {
+ return [
+ 'condition is array' => [['eq' => 1]],
+ 'condition is string' => ['1'],
+ 'condition is int' => [1],
+ 'condition is null' => [null]
+ ];
+ }
}
From 2fa5e83ab66b74f9d44391023b959ff3780117f4 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Mon, 21 Oct 2019 23:05:24 +0300
Subject: [PATCH 0527/1978] MC-20421: [Integration Test] Verifying of email
notifications about changes in the Company Credit
---
.../_files/product_simple_tax_none.php | 42 +++++++++++++++++++
.../product_simple_tax_none_rollback.php | 33 +++++++++++++++
2 files changed, 75 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none_rollback.php
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none.php
new file mode 100644
index 0000000000000..35bf3705493ed
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none.php
@@ -0,0 +1,42 @@
+get(ProductInterfaceFactory::class);
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = $objectManager->get(ProductRepositoryInterface::class);
+
+/** @var $product \Magento\Catalog\Model\Product */
+$product = $productFactory->create();
+$product->setTypeId('simple')
+ ->setAttributeSetId($product->getDefaultAttributeSetId())
+ ->setWebsiteIds([1])
+ ->setName('Simple Product Tax None')
+ ->setSku('simple-product-tax-none')
+ ->setPrice(205)
+ ->setWeight(1)
+ ->setMetaTitle('meta title')
+ ->setMetaKeyword('meta keyword')
+ ->setMetaDescription('meta description')
+ ->setVisibility(Visibility::VISIBILITY_BOTH)
+ ->setStatus(Status::STATUS_ENABLED)
+ ->setStockData(
+ [
+ 'use_config_manage_stock' => 1,
+ 'qty' => 100,
+ 'is_in_stock' => 1
+ ]
+ );
+
+$productRepository->save($product);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none_rollback.php
new file mode 100644
index 0000000000000..ceffb1c87d970
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_tax_none_rollback.php
@@ -0,0 +1,33 @@
+get(ProductRepositoryInterface::class);
+/** @var \Magento\Framework\Registry $registry */
+$registry =$objectManager->get(\Magento\Framework\Registry::class);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+try {
+ /** @var ProductInterface $product */
+ $product = $productRepository->get('simple-product-tax-none', false, null, true);
+ $productRepository->delete($product);
+} catch (NoSuchEntityException $e) {
+ // isolation on
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From c8ba3c8c8b2ae88114fdbefb1979514300c66dfc Mon Sep 17 00:00:00 2001
From: Arnob Saha
Date: Fri, 11 Oct 2019 15:38:41 -0500
Subject: [PATCH 0528/1978] MC-21716: URL rewrites for not default root
category
- strict URL rewrite
---
.../Product/AnchorUrlRewriteGenerator.php | 4 +
.../Product/AnchorUrlRewriteGeneratorTest.php | 140 ++++++++++++++++++
.../Model/CategoryUrlRewriteGeneratorTest.php | 14 +-
3 files changed, 146 insertions(+), 12 deletions(-)
create mode 100644 app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/AnchorUrlRewriteGeneratorTest.php
diff --git a/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php b/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php
index 4a191b54dea68..5d08ea33ff8a1 100644
--- a/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php
+++ b/app/code/Magento/CatalogUrlRewrite/Model/Product/AnchorUrlRewriteGenerator.php
@@ -6,6 +6,7 @@
namespace Magento\CatalogUrlRewrite\Model\Product;
use Magento\Catalog\Api\CategoryRepositoryInterface;
+use Magento\Catalog\Model\Category;
use Magento\Catalog\Model\Product;
use Magento\CatalogUrlRewrite\Model\ObjectRegistry;
use Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator;
@@ -67,6 +68,9 @@ public function generate($storeId, Product $product, ObjectRegistry $productCate
if ($anchorCategoryIds) {
foreach ($anchorCategoryIds as $anchorCategoryId) {
$anchorCategory = $this->categoryRepository->get($anchorCategoryId);
+ if ((int)$anchorCategory->getParentId() === Category::TREE_ROOT_ID) {
+ continue;
+ }
$urls[] = $this->urlRewriteFactory->create()
->setEntityType(ProductUrlRewriteGenerator::ENTITY_TYPE)
->setEntityId($product->getId())
diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/AnchorUrlRewriteGeneratorTest.php b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/AnchorUrlRewriteGeneratorTest.php
new file mode 100644
index 0000000000000..662e156b8f100
--- /dev/null
+++ b/app/code/Magento/CatalogUrlRewrite/Test/Unit/Model/Product/AnchorUrlRewriteGeneratorTest.php
@@ -0,0 +1,140 @@
+urlRewriteFactory = $this->getMockBuilder(\Magento\UrlRewrite\Service\V1\Data\UrlRewriteFactory::class)
+ ->setMethods(['create'])
+ ->disableOriginalConstructor()->getMock();
+ $this->urlRewrite = $this->getMockBuilder(\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::class)
+ ->disableOriginalConstructor()->getMock();
+ $this->product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)
+ ->disableOriginalConstructor()->getMock();
+ $this->categoryRepositoryInterface = $this->getMockBuilder(
+ \Magento\Catalog\Api\CategoryRepositoryInterface::class
+ )->disableOriginalConstructor()->getMock();
+ $this->categoryRegistry = $this->getMockBuilder(\Magento\CatalogUrlRewrite\Model\ObjectRegistry::class)
+ ->disableOriginalConstructor()->getMock();
+ $this->productUrlPathGenerator = $this->getMockBuilder(
+ \Magento\CatalogUrlRewrite\Model\ProductUrlPathGenerator::class
+ )->disableOriginalConstructor()->getMock();
+ $this->anchorUrlRewriteGenerator = (new ObjectManager($this))->getObject(
+ \Magento\CatalogUrlRewrite\Model\Product\AnchorUrlRewriteGenerator::class,
+ [
+ 'productUrlPathGenerator' => $this->productUrlPathGenerator,
+ 'urlRewriteFactory' => $this->urlRewriteFactory,
+ 'categoryRepository' => $this->categoryRepositoryInterface
+ ]
+ );
+ }
+
+ public function testGenerateEmpty()
+ {
+ $this->categoryRegistry->expects($this->any())->method('getList')->will($this->returnValue([]));
+
+ $this->assertEquals(
+ [],
+ $this->anchorUrlRewriteGenerator->generate(1, $this->product, $this->categoryRegistry)
+ );
+ }
+
+ public function testGenerateCategories()
+ {
+ $urlPathWithCategory = 'category1/category2/category3/simple-product.html';
+ $storeId = 10;
+ $productId = 12;
+ $canonicalUrlPathWithCategory = 'canonical-path-with-category';
+ $categoryParentId = '1';
+ $categoryIds = [$categoryParentId,'2','3','4'];
+ $urls = ['category1/simple-product.html',
+ 'category1/category2/simple-product.html',
+ 'category1/category2/category3/simple-product.html'];
+
+ $this->product->expects($this->any())->method('getId')->will($this->returnValue($productId));
+ $this->productUrlPathGenerator->expects($this->any())->method('getUrlPathWithSuffix')
+ ->will($this->returnValue($urlPathWithCategory));
+ $this->productUrlPathGenerator->expects($this->any())->method('getCanonicalUrlPath')
+ ->will($this->returnValue($canonicalUrlPathWithCategory));
+ $category = $this->createMock(\Magento\Catalog\Model\Category::class);
+ $category->expects($this->any())->method('getId')->will($this->returnValue($categoryIds));
+ $category->expects($this->any())->method('getAnchorsAbove')->will($this->returnValue($categoryIds));
+ $category->expects($this->any())->method('getParentId')->will(
+ $this->onConsecutiveCalls(
+ $categoryIds[0],
+ $categoryIds[1],
+ $categoryIds[2],
+ $categoryIds[3]
+ )
+ );
+ $this->categoryRepositoryInterface
+ ->expects($this->any())
+ ->method('get')
+ ->withConsecutive(
+ [ 'category_id' => $categoryIds[0]],
+ [ 'category_id' => $categoryIds[1]],
+ [ 'category_id' => $categoryIds[2]]
+ )
+ ->will($this->returnValue($category));
+ $this->categoryRegistry->expects($this->any())->method('getList')
+ ->will($this->returnValue([$category]));
+ $this->urlRewrite->expects($this->any())->method('setStoreId')
+ ->with($storeId)
+ ->will($this->returnSelf());
+ $this->urlRewrite->expects($this->any())->method('setEntityId')
+ ->with($productId)
+ ->will($this->returnSelf());
+ $this->urlRewrite->expects($this->any())->method('setEntityType')
+ ->with(ProductUrlRewriteGenerator::ENTITY_TYPE)
+ ->will($this->returnSelf());
+ $this->urlRewrite->expects($this->any())->method('setRequestPath')
+ ->will($this->returnSelf());
+ $this->urlRewrite->expects($this->any())->method('setTargetPath')
+ ->will($this->returnSelf());
+ $this->urlRewrite->expects($this->any())->method('setMetadata')
+ ->will(
+ $this->onConsecutiveCalls(
+ $urls[0],
+ $urls[1],
+ $urls[2]
+ )
+ );
+ $this->urlRewriteFactory->expects($this->any())->method('create')->will(
+ $this->returnValue($this->urlRewrite)
+ );
+
+ $this->assertEquals(
+ $urls,
+ $this->anchorUrlRewriteGenerator->generate($storeId, $this->product, $this->categoryRegistry)
+ );
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php
index 1c2ee602c3bd4..b6fa2fac2ca80 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogUrlRewrite/Model/CategoryUrlRewriteGeneratorTest.php
@@ -98,12 +98,6 @@ public function testGenerateUrlRewritesWithoutSaveHistory()
'catalog/product/view/id/' . $productForTest . '/category/4',
1,
0
- ],
- [
- '/simple-product-two.html',
- 'catalog/product/view/id/' . $productForTest . '/category/2',
- 1,
- 0
]
];
@@ -187,12 +181,6 @@ public function testGenerateUrlRewritesWithSaveHistory()
1,
0
],
- [
- '/simple-product-two.html',
- 'catalog/product/view/id/' . $productForTest . '/category/2',
- 1,
- 0
- ],
[
'category-1/simple-product-two.html',
'new-url/simple-product-two.html',
@@ -329,6 +317,8 @@ public function testGenerateUrlRewritesWithoutGenerateProductRewrites()
* @magentoAppIsolation enabled
*
* @return void
+ * @throws NoSuchEntityException
+ * @throws \Magento\Framework\Exception\StateException
*/
public function testRemoveCatalogUrlRewrites()
{
From 4b7555acf82faea169e780e7b61e37d3f71f787c Mon Sep 17 00:00:00 2001
From: Krishna Abothu
Date: Mon, 21 Oct 2019 18:42:45 -0500
Subject: [PATCH 0529/1978] MC-21430: [Functional Test]
Magento\FunctionalTestingFramework.functional\MSI_Multi_Mode.MinAndMaxQtyInShoppingCartAppliedToSimpleProductOnProductPageAndCheckedInAdminTest
---
.../Catalog/Test/Mftf/Section/AdminProductFormSection.xml | 2 +-
.../Test/Mftf/Section/AdminProductFormSection.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
index 7388ebc8408dd..9e8b167972630 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml
@@ -38,7 +38,7 @@
-
+
diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
index f4b79b17b3fc3..2ac14a918957d 100644
--- a/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
@@ -9,6 +9,6 @@
From 7b32bee3e1f28732bda42c5425e7ea5badc34d51 Mon Sep 17 00:00:00 2001
From: Krishna Abothu
Date: Mon, 21 Oct 2019 22:25:27 -0500
Subject: [PATCH 0530/1978] MC-21430: [Functional Test]
Magento\FunctionalTestingFramework.functional\MSI_Multi_Mode.MinAndMaxQtyInShoppingCartAppliedToSimpleProductOnProductPageAndCheckedInAdminTest
---
.../Test/Mftf/Section/AdminProductFormSection.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
index 2ac14a918957d..91c6084b70155 100644
--- a/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
@@ -9,6 +9,6 @@
From 95527864388ff9d494c80664d4e6dee27866225e Mon Sep 17 00:00:00 2001
From: Krishna Abothu
Date: Mon, 21 Oct 2019 23:58:21 -0500
Subject: [PATCH 0531/1978] MC-21430: [Functional Test]
Magento\FunctionalTestingFramework.functional\MSI_Multi_Mode.MinAndMaxQtyInShoppingCartAppliedToSimpleProductOnProductPageAndCheckedInAdminTest
---
.../Test/Mftf/Section/AdminProductFormSection.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml b/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
index 91c6084b70155..945613ee753d6 100644
--- a/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
+++ b/app/code/Magento/CatalogInventory/Test/Mftf/Section/AdminProductFormSection.xml
@@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
From b69de86a54beab1d1447322b9bfecbe1aeff9f56 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Tue, 8 Oct 2019 12:51:04 +0530
Subject: [PATCH 0532/1978] Replaced model->save() with service contract
---
.../Invoice/AbstractInvoice/View.php | 41 ++++++++-----------
.../Adminhtml/Order/Invoice/AddComment.php | 34 +++++++++++----
.../Order/Invoice/AddCommentTest.php | 15 ++++---
3 files changed, 53 insertions(+), 37 deletions(-)
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php
index 300b7ee37f2ef..6e7c2e5ce5609 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Invoice/AbstractInvoice/View.php
@@ -1,17 +1,22 @@
registry = $registry;
parent::__construct($context);
+ $this->registry = $registry;
$this->resultForwardFactory = $resultForwardFactory;
+ $this->invoiceRepository = $invoiceRepository ?:
+ ObjectManager::getInstance()->get(InvoiceRepositoryInterface::class);
}
/**
@@ -70,13 +79,14 @@ public function execute()
}
/**
+ * Get invoice using invoice Id from request params
+ *
* @return \Magento\Sales\Model\Order\Invoice|bool
*/
protected function getInvoice()
{
try {
- $invoice = $this->getInvoiceRepository()
- ->get($this->getRequest()->getParam('invoice_id'));
+ $invoice = $this->invoiceRepository->get($this->getRequest()->getParam('invoice_id'));
$this->registry->register('current_invoice', $invoice);
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(__('Invoice capturing error'));
@@ -85,19 +95,4 @@ protected function getInvoice()
return $invoice;
}
-
- /**
- * @return InvoiceRepository
- *
- * @deprecated 100.1.0
- */
- private function getInvoiceRepository()
- {
- if ($this->invoiceRepository === null) {
- $this->invoiceRepository = ObjectManager::getInstance()
- ->get(InvoiceRepositoryInterface::class);
- }
-
- return $this->invoiceRepository;
- }
}
diff --git a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php
index 515c0753542a0..23dcae3a858cc 100644
--- a/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php
+++ b/app/code/Magento/Sales/Controller/Adminhtml/Order/Invoice/AddComment.php
@@ -1,23 +1,30 @@
invoiceCommentSender = $invoiceCommentSender;
$this->resultJsonFactory = $resultJsonFactory;
$this->resultPageFactory = $resultPageFactory;
$this->resultRawFactory = $resultRawFactory;
- parent::__construct($context, $registry, $resultForwardFactory);
+ $this->invoiceRepository = $invoiceRepository ?:
+ ObjectManager::getInstance()->get(InvoiceRepositoryInterface::class);
+ parent::__construct($context, $registry, $resultForwardFactory, $invoiceRepository);
}
/**
@@ -90,7 +106,7 @@ public function execute()
);
$this->invoiceCommentSender->send($invoice, !empty($data['is_customer_notified']), $data['comment']);
- $invoice->save();
+ $this->invoiceRepository->save($invoice);
/** @var \Magento\Backend\Model\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
diff --git a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php
index 053df53949296..9fe3042fa6bdf 100644
--- a/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php
+++ b/app/code/Magento/Sales/Test/Unit/Controller/Adminhtml/Order/Invoice/AddCommentTest.php
@@ -3,6 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
+declare(strict_types=1);
+
namespace Magento\Sales\Test\Unit\Controller\Adminhtml\Order\Invoice;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
@@ -186,7 +189,8 @@ protected function setUp()
'invoiceCommentSender' => $this->commentSenderMock,
'resultPageFactory' => $this->resultPageFactoryMock,
'resultRawFactory' => $this->resultRawFactoryMock,
- 'resultJsonFactory' => $this->resultJsonFactoryMock
+ 'resultJsonFactory' => $this->resultJsonFactoryMock,
+ 'invoiceRepository' => $this->invoiceRepository
]
);
@@ -230,8 +234,9 @@ public function testExecute()
$invoiceMock->expects($this->once())
->method('addComment')
->with($data['comment'], false, false);
- $invoiceMock->expects($this->once())
- ->method('save');
+ $this->invoiceRepository->expects($this->once())
+ ->method('save')
+ ->with($invoiceMock);
$this->invoiceRepository->expects($this->once())
->method('get')
@@ -307,11 +312,11 @@ public function testExecuteModelException()
public function testExecuteException()
{
$response = ['error' => true, 'message' => 'Cannot add new comment.'];
- $e = new \Exception('test');
+ $error = new \Exception('test');
$this->requestMock->expects($this->once())
->method('getParam')
- ->will($this->throwException($e));
+ ->will($this->throwException($error));
$this->resultJsonFactoryMock->expects($this->once())
->method('create')
From 53a6f93696c2a974bbc6d9f5e509ddc75b13e85e Mon Sep 17 00:00:00 2001
From: Vova Yatsyuk
Date: Tue, 22 Oct 2019 09:46:46 +0300
Subject: [PATCH 0533/1978] Fixed broken resources page when acl has quote (')
in title.
---
.../Integration/view/adminhtml/templates/resourcetree.phtml | 4 ++--
.../Magento/User/view/adminhtml/templates/role/edit.phtml | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml b/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml
index 7d6c27954d836..bf90d15917f42 100644
--- a/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml
+++ b/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml
@@ -39,12 +39,12 @@
[
"treeInitData" => $block->getTree(),
"treeInitSelectedData" => $block->getSelectedResources(),
],
- ]); ?>'>
+ ])); ?>'>
diff --git a/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml b/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml
index edee167dc1b8a..6fa3dba7b301d 100644
--- a/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml
+++ b/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml
@@ -39,12 +39,12 @@
[
"treeInitData" => $block->getTree(),
"treeInitSelectedData" => $block->getSelectedResources(),
],
- ]); ?>'>
+ ])); ?>'>
From 1a38d55f4aaf953cee40458cdbb87155ca574ba4 Mon Sep 17 00:00:00 2001
From: Krishna Abothu
Date: Tue, 22 Oct 2019 02:36:26 -0500
Subject: [PATCH 0534/1978] MC-21430: [Functional Test]
Magento\FunctionalTestingFramework.functional\MSI_Multi_Mode.MinAndMaxQtyInShoppingCartAppliedToSimpleProductOnProductPageAndCheckedInAdminTest
---
.../AdminClickOnAdvancedInventoryLinkActionGroup.xml | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickOnAdvancedInventoryLinkActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickOnAdvancedInventoryLinkActionGroup.xml
index 60438e23e084c..a0cff133cbbed 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickOnAdvancedInventoryLinkActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminClickOnAdvancedInventoryLinkActionGroup.xml
@@ -18,4 +18,15 @@
+
+
+
+
+ Clicks on the 'Advanced Inventory' link on the Admin Product creation/edit page.
+
+
+
+
+
From 94277efe424e87bbc566fd4ebcf5d9008d06e7e2 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Tue, 22 Oct 2019 11:26:53 +0300
Subject: [PATCH 0535/1978] MC-20694: Admin: Delete attribute set
---
.../Eav/Model/GetAttributeSetByName.php | 56 +++++++
.../Adminhtml/Product/Set/DeleteTest.php | 138 +++++++++++++++---
...set_based_on_default_with_custom_group.php | 52 +++++++
..._on_default_with_custom_group_rollback.php | 21 +++
.../product_with_test_attribute_set.php | 42 ++++++
...oduct_with_test_attribute_set_rollback.php | 33 +++++
6 files changed, 325 insertions(+), 17 deletions(-)
create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
new file mode 100644
index 0000000000000..12ff978a12e12
--- /dev/null
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
@@ -0,0 +1,56 @@
+searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->attributeSetRepository = $attributeSetRepository;
+ }
+
+ /**
+ * Search and return attribute set by name.
+ *
+ * @param string $attributeSetName
+ * @return AttributeSetInterface|null
+ */
+ public function execute(string $attributeSetName): ?AttributeSetInterface
+ {
+ $this->searchCriteriaBuilder->addFilter('attribute_set_name', $attributeSetName);
+ $searchCriteria = $this->searchCriteriaBuilder->create();
+ $result = $this->attributeSetRepository->getList($searchCriteria);
+ $items = $result->getItems();
+
+ return array_pop($items);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php
index 7e034b8b3cb7e..5cb1f862054ba 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Set/DeleteTest.php
@@ -3,42 +3,146 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Controller\Adminhtml\Product\Set;
-use Magento\Framework\Message\MessageInterface;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\Product;
+use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Framework\App\Request\Http as HttpRequest;
+use Magento\Framework\Escaper;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\Message\MessageInterface;
+use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
+use Magento\TestFramework\TestCase\AbstractBackendController;
-class DeleteTest extends \Magento\TestFramework\TestCase\AbstractBackendController
+/**
+ * Test for attribute set deleting.
+ *
+ * @magentoAppArea adminhtml
+ * @magentoDbIsolation enabled
+ */
+class DeleteTest extends AbstractBackendController
{
/**
+ * @var GetAttributeSetByName
+ */
+ private $getAttributeSetByName;
+
+ /**
+ * @var ProductInterface|Product
+ */
+ private $product;
+
+ /**
+ * @var AttributeSetRepositoryInterface
+ */
+ private $attributeSetRepository;
+
+ /**
+ * @var Escaper
+ */
+ private $escaper;
+
+ /**
+ * @var ProductRepositoryInterface
+ */
+ private $productRepository;
+
+ /**
+ * @inheritdoc
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->getAttributeSetByName = $this->_objectManager->get(GetAttributeSetByName::class);
+ $this->product = $this->_objectManager->get(ProductInterface::class);
+ $this->attributeSetRepository = $this->_objectManager->get(AttributeSetRepositoryInterface::class);
+ $this->escaper = $this->_objectManager->get(Escaper::class);
+ $this->productRepository = $this->_objectManager->get(ProductRepositoryInterface::class);
+ }
+
+ /**
+ * Assert that default attribute set is not deleted.
+ *
+ * @return void
+ */
+ public function testDefaultAttributeSetIsNotDeleted(): void
+ {
+ $productDefaultAttrSetId = (int)$this->product->getDefaultAttributeSetId();
+ $this->performDeleteAttributeSetRequest($productDefaultAttrSetId);
+ $expectedSessionMessage = $this->escaper->escapeHtml((string)__('We can\'t delete this set right now.'));
+ $this->assertSessionMessages(
+ $this->equalTo([$expectedSessionMessage]),
+ MessageInterface::TYPE_ERROR
+ );
+ try {
+ $this->attributeSetRepository->get($productDefaultAttrSetId);
+ } catch (NoSuchEntityException $e) {
+ $this->fail(sprintf('Default attribute set was deleted. Message: %s', $e->getMessage()));
+ }
+ }
+
+ /**
+ * Assert that custom attribute set deleting properly.
+ *
* @magentoDataFixture Magento/Eav/_files/empty_attribute_set.php
+ *
+ * @return void
*/
- public function testDeleteById()
+ public function testDeleteCustomAttributeSetById(): void
{
- $attributeSet = $this->getAttributeSetByName('empty_attribute_set');
- $this->getRequest()->setParam('id', $attributeSet->getId())->setMethod(HttpRequest::METHOD_POST);
+ $this->deleteAttributeSetByNameAndAssert('empty_attribute_set');
+ }
- $this->dispatch('backend/catalog/product_set/delete/');
+ /**
+ * Assert that product will be deleted if delete attribute set which the product is attached.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_test_attribute_set.php
+ *
+ * @return void
+ */
+ public function testProductIsDeletedAfterDeleteItsAttributeSet(): void
+ {
+ $this->deleteAttributeSetByNameAndAssert('new_attribute_set');
+ $this->expectExceptionObject(
+ new NoSuchEntityException(
+ __('The product that was requested doesn\'t exist. Verify the product and try again.')
+ )
+ );
+ $this->productRepository->get('simple');
+ }
- $this->assertNull($this->getAttributeSetByName('empty_attribute_set'));
+ /**
+ * Perform request to delete attribute set and assert that attribute set is deleted.
+ *
+ * @param string $attributeSetName
+ * @return void
+ */
+ private function deleteAttributeSetByNameAndAssert(string $attributeSetName): void
+ {
+ $attributeSet = $this->getAttributeSetByName->execute($attributeSetName);
+ $this->performDeleteAttributeSetRequest((int)$attributeSet->getAttributeSetId());
$this->assertSessionMessages(
- $this->equalTo(['The attribute set has been removed.']),
+ $this->equalTo([(string)__('The attribute set has been removed.')]),
MessageInterface::TYPE_SUCCESS
);
- $this->assertRedirect($this->stringContains('catalog/product_set/index/'));
+ $this->assertNull($this->getAttributeSetByName->execute($attributeSetName));
}
/**
- * Retrieve attribute set based on given name.
+ * Perform "catalog/product_set/delete" controller dispatch.
*
- * @param string $attributeSetName
- * @return \Magento\Eav\Model\Entity\Attribute\Set|null
+ * @param int $attributeSetId
+ * @return void
*/
- protected function getAttributeSetByName($attributeSetName)
+ private function performDeleteAttributeSetRequest(int $attributeSetId): void
{
- $attributeSet = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
- \Magento\Eav\Model\Entity\Attribute\Set::class
- )->load($attributeSetName, 'attribute_set_name');
- return $attributeSet->getId() === null ? null : $attributeSet;
+ $this->getRequest()
+ ->setParam('id', $attributeSetId)
+ ->setMethod(HttpRequest::METHOD_POST);
+ $this->dispatch('backend/catalog/product_set/delete/');
}
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
new file mode 100644
index 0000000000000..333f286277924
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
@@ -0,0 +1,52 @@
+get(AttributeSetRepositoryInterface::class);
+/** @var AttributeSetInterfaceFactory $attributeSetFactory */
+$attributeSetFactory = $objectManager->get(AttributeSetInterfaceFactory::class);
+/** @var Type $entityType */
+$entityType = $objectManager->create(Type::class)->loadByCode(ProductAttributeInterface::ENTITY_TYPE_CODE);
+/** @var ProductInterface $product */
+$product = $objectManager->create(ProductInterface::class);
+$attributeSet = $attributeSetFactory->create(
+ [
+ 'data' => [
+ 'id' => null,
+ 'attribute_set_name' => 'new_attribute_set',
+ 'entity_type_id' => $entityType->getId(),
+ 'sort_order' => 300,
+ ],
+ ]
+);
+$attributeSet->isObjectNew(true);
+$attributeSet->setHasDataChanges(true);
+$attributeSet->validate();
+$attributeSetRepository->save($attributeSet);
+$attributeSet->initFromSkeleton($product->getDefaultAttributeSetid());
+/** @var AttributeGroupInterface $newGroup */
+$newGroup = $objectManager->get(GroupFactory::class)->create();
+$newGroup->setId(null)
+ ->setAttributeGroupName('Test attribute group name')
+ ->setAttributeSetId($attributeSet->getAttributeSetId())
+ ->setSortOrder(11)
+ ->setAttributes([]);
+/** @var AttributeGroupInterface[] $groups */
+$groups = $attributeSet->getGroups();
+array_push($groups, $newGroup);
+$attributeSet->setGroups($groups);
+$attributeSetRepository->save($attributeSet);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
new file mode 100644
index 0000000000000..f8628ea2d6ddb
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group_rollback.php
@@ -0,0 +1,21 @@
+get(GetAttributeSetByName::class);
+/** @var AttributeSetRepositoryInterface $attributeSetRepository */
+$attributeSetRepository = $objectManager->get(AttributeSetRepositoryInterface::class);
+$attributeSet = $getAttributeSetByName->execute('new_attribute_set');
+
+if ($attributeSet) {
+ $attributeSetRepository->delete($attributeSet);
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
new file mode 100644
index 0000000000000..0616a22b1deee
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set.php
@@ -0,0 +1,42 @@
+get(ProductRepositoryInterface::class);
+/** @var ProductFactory $productFactory */
+$productFactory = $objectManager->get(ProductFactory::class);
+/** @var GetAttributeSetByName $attributeSet */
+$attributeSet = $objectManager->get(GetAttributeSetByName::class);
+$customAttributeSet = $attributeSet->execute('new_attribute_set');
+$product = $productFactory->create();
+$product
+ ->setTypeId('simple')
+ ->setAttributeSetId($customAttributeSet->getAttributeSetId())
+ ->setWebsiteIds([1])
+ ->setStoreId(Store::DEFAULT_STORE_ID)
+ ->setName('Simple Product')
+ ->setSku('simple')
+ ->setPrice(10)
+ ->setMetaTitle('meta title')
+ ->setMetaKeyword('meta keyword')
+ ->setMetaDescription('meta description')
+ ->setVisibility(Visibility::VISIBILITY_BOTH)
+ ->setStatus(Status::STATUS_ENABLED)
+ ->setStockData(['use_config_manage_stock' => 1, 'qty' => 22, 'is_in_stock' => 1])
+ ->setQty(22);
+$productRepository->save($product);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
new file mode 100644
index 0000000000000..1ec341cd4fd58
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_test_attribute_set_rollback.php
@@ -0,0 +1,33 @@
+get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+/** @var ProductRepositoryInterface $productRepository */
+$productRepository = $objectManager->get(ProductRepositoryInterface::class);
+/** @var StockRegistryStorage $stockRegistryStorage */
+$stockRegistryStorage = $objectManager->get(StockRegistryStorage::class);
+try {
+ $product = $productRepository->get('simple');
+ $productRepository->delete($product);
+} catch (NoSuchEntityException $e) {
+ //Product already deleted.
+}
+$stockRegistryStorage->clean();
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
+
+require __DIR__ . '/attribute_set_based_on_default_with_custom_group_rollback.php';
From daede858a4838d013c728f2e12d749a233f34b2a Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Tue, 22 Oct 2019 11:28:10 +0300
Subject: [PATCH 0536/1978] Update for merging carts with replacing code into
try/catch block
---
.../Magento/Quote/Model/QuoteManagement.php | 23 +++++--------------
.../Test/Unit/Model/QuoteManagementTest.php | 1 -
2 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Quote/Model/QuoteManagement.php b/app/code/Magento/Quote/Model/QuoteManagement.php
index 0ab4dcf4dd668..3a81341e2b02a 100644
--- a/app/code/Magento/Quote/Model/QuoteManagement.php
+++ b/app/code/Magento/Quote/Model/QuoteManagement.php
@@ -299,26 +299,15 @@ public function assignCustomer($cartId, $customerId, $storeId)
}
try {
$customerActiveQuote = $this->quoteRepository->getForCustomer($customerId);
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
- /** This exception appear when customer have no active cart*/
- $customerActiveQuote = false;
- }
- if ($customerActiveQuote) {
- try {
- /** Merge carts */
- $quote->merge($customerActiveQuote);
- $customerActiveQuote->setIsActive(0);
- $this->quoteRepository->save($customerActiveQuote);
- } catch (\Exception $e) {
- $message = sprintf(
- "The customer can't be assigned to the cart. Error on cart merging: %s",
- $e->getMessage()
- );
- throw new StateException($message);
- }
+ $quote->merge($customerActiveQuote);
+ $customerActiveQuote->setIsActive(0);
+ $this->quoteRepository->save($customerActiveQuote);
+ // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
+ } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
}
+
$quote->setCustomer($customer);
$quote->setCustomerIsGuest(0);
$quote->setIsActive(1);
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index 61ee7a146d164..89f87f2ee483b 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -627,7 +627,6 @@ public function testAssignCustomer()
->with($customerId)
->willThrowException(new \Magento\Framework\Exception\NoSuchEntityException());
- $this->assertEquals(false, $activeQuoteMock);
$quoteMock->expects($this->never())->method('merge');
$quoteMock->expects($this->once())->method('setCustomer')->with($customerMock);
From 274dbb6520ece44e3dc3896feb852e6a349c90b8 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Tue, 22 Oct 2019 11:29:55 +0300
Subject: [PATCH 0537/1978] MC-21833: [Setup-Integration] Automate MC-6315
---
.../remove_fk_declaration/db_schema.xml | 39 ++++++++++
.../db_schema_whitelist.json | 28 +++++++
.../db_schema_whitelist.json | 29 +++++++
.../Magento/Setup/SafeInstallerTest.php | 78 ++++++++++++++++---
4 files changed, 165 insertions(+), 9 deletions(-)
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema.xml
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema_whitelist.json
create mode 100644 dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/restore_fk_declaration_to_wl/db_schema_whitelist.json
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema.xml b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema.xml
new file mode 100644
index 0000000000000..3ecaf2b3ac1b8
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema_whitelist.json b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema_whitelist.json
new file mode 100644
index 0000000000000..c9274c9477fa6
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/remove_fk_declaration/db_schema_whitelist.json
@@ -0,0 +1,28 @@
+{
+ "test_table": {
+ "column": {
+ "smallint": true,
+ "tinyint": true,
+ "bigint": true,
+ "float": true,
+ "double": true,
+ "decimal": true,
+ "date": true,
+ "timestamp": true,
+ "datetime": true,
+ "longtext": true,
+ "mediumtext": true,
+ "varchar": true,
+ "mediumblob": true,
+ "blob": true,
+ "boolean": true,
+ "varbinary_rename": true
+ },
+ "index": {
+ "TEST_TABLE_TINYINT_BIGINT": true
+ },
+ "constraint": {
+ "TEST_TABLE_SMALLINT_BIGINT": true
+ }
+ }
+}
diff --git a/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/restore_fk_declaration_to_wl/db_schema_whitelist.json b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/restore_fk_declaration_to_wl/db_schema_whitelist.json
new file mode 100644
index 0000000000000..a800d2cbf58ee
--- /dev/null
+++ b/dev/tests/setup-integration/_files/Magento/TestSetupDeclarationModule6/revisions/restore_fk_declaration_to_wl/db_schema_whitelist.json
@@ -0,0 +1,29 @@
+{
+ "test_table": {
+ "column": {
+ "smallint": true,
+ "tinyint": true,
+ "bigint": true,
+ "float": true,
+ "double": true,
+ "decimal": true,
+ "date": true,
+ "timestamp": true,
+ "datetime": true,
+ "longtext": true,
+ "mediumtext": true,
+ "varchar": true,
+ "mediumblob": true,
+ "blob": true,
+ "boolean": true,
+ "varbinary_rename": true
+ },
+ "index": {
+ "TEST_TABLE_TINYINT_BIGINT": true
+ },
+ "constraint": {
+ "TEST_TABLE_SMALLINT_BIGINT": true,
+ "TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF": true
+ }
+ }
+}
diff --git a/dev/tests/setup-integration/testsuite/Magento/Setup/SafeInstallerTest.php b/dev/tests/setup-integration/testsuite/Magento/Setup/SafeInstallerTest.php
index 5b42e6cf43e13..cb0746a66504f 100644
--- a/dev/tests/setup-integration/testsuite/Magento/Setup/SafeInstallerTest.php
+++ b/dev/tests/setup-integration/testsuite/Magento/Setup/SafeInstallerTest.php
@@ -7,11 +7,8 @@
namespace Magento\Setup;
use Magento\Framework\App\ResourceConnection;
-use Magento\Framework\Setup\Declaration\Schema\Diff\SchemaDiff;
-use Magento\Framework\Setup\Declaration\Schema\SchemaConfigInterface;
-use Magento\Framework\Setup\Declaration\Schema\Sharding;
+use Magento\Framework\Setup\Declaration\Schema\Db\DbSchemaReaderInterface;
use Magento\TestFramework\Deploy\CliCommand;
-use Magento\TestFramework\Deploy\DescribeTable;
use Magento\TestFramework\Deploy\TestModuleManager;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\SetupTestCase;
@@ -29,19 +26,28 @@ class SafeInstallerTest extends SetupTestCase
/**
* @var CliCommand
*/
- private $cliCommad;
+ private $cliCommand;
/**
* @var ResourceConnection
*/
private $resourceConnection;
+ /**
+ * @var DbSchemaReaderInterface
+ */
+ private $dbSchemaReader;
+
+ /**
+ * @inheritdoc
+ */
public function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->moduleManager = $objectManager->get(TestModuleManager::class);
- $this->cliCommad = $objectManager->get(CliCommand::class);
+ $this->cliCommand = $objectManager->get(CliCommand::class);
$this->resourceConnection = $objectManager->get(ResourceConnection::class);
+ $this->dbSchemaReader = $objectManager->get(DbSchemaReaderInterface::class);
}
/**
@@ -52,7 +58,7 @@ public function testInstallation()
{
$testTableData = $this->getData();
$row = reset($testTableData);
- $this->cliCommad->install(['Magento_TestSetupDeclarationModule4']);
+ $this->cliCommand->install(['Magento_TestSetupDeclarationModule4']);
$adapter = $this->resourceConnection->getConnection();
$testTableName = $this->resourceConnection->getTableName('test_table');
$adapter->insertArray(
@@ -67,7 +73,7 @@ public function testInstallation()
'db_schema.xml',
'etc'
);
- $this->cliCommad->upgrade(
+ $this->cliCommand->upgrade(
[
'safe-mode' => true,
]
@@ -79,7 +85,7 @@ public function testInstallation()
'db_schema.xml',
'etc'
);
- $this->cliCommad->upgrade(
+ $this->cliCommand->upgrade(
[
'data-restore' => true,
]
@@ -87,4 +93,58 @@ public function testInstallation()
$testTableSelect = $adapter->select()->from($testTableName);
self::assertEquals($testTableData, $adapter->fetchAll($testTableSelect));
}
+
+ /**
+ * Tests that not whitelisted elements should not be removed from DB to avoid backwards-incompatible change.
+ *
+ * @moduleName Magento_TestSetupDeclarationModule6
+ */
+ public function testDestructiveOperationBehaviour()
+ {
+ $this->cliCommand->install(['Magento_TestSetupDeclarationModule6']);
+ $this->assertForeignKeyPresence('test_table', 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF');
+
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule6',
+ 'remove_fk_declaration',
+ 'db_schema.xml',
+ 'etc'
+ );
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule6',
+ 'remove_fk_declaration',
+ 'db_schema_whitelist.json',
+ 'etc'
+ );
+ $this->cliCommand->upgrade();
+ $this->assertForeignKeyPresence('test_table', 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF');
+
+ $this->moduleManager->updateRevision(
+ 'Magento_TestSetupDeclarationModule6',
+ 'restore_fk_declaration_to_wl',
+ 'db_schema_whitelist.json',
+ 'etc'
+ );
+ $this->cliCommand->upgrade();
+ $this->assertForeignKeyPresence('test_table', 'TEST_TABLE_TINYINT_REFERENCE_TABLE_TINYINT_REF', false);
+ }
+
+ /**
+ * Asserts foreign key presence.
+ *
+ * @param string $tableName
+ * @param string $foreignKeyName
+ * @param bool $isPresent
+ * @return void
+ */
+ private function assertForeignKeyPresence(string $tableName, string $foreignKeyName, bool $isPresent = true): void
+ {
+ $foreignKeys = $this->dbSchemaReader
+ ->readReferences($this->resourceConnection->getTableName($tableName), 'default');
+ if ($isPresent) {
+ $this->assertArrayHasKey($foreignKeyName, $foreignKeys);
+ } else {
+ $this->assertArrayNotHasKey($foreignKeyName, $foreignKeys);
+ }
+ }
}
From e28fa66447c96198dec9cc3603f30b940f1f067e Mon Sep 17 00:00:00 2001
From: Arvinda kumar
Date: Tue, 22 Oct 2019 14:11:34 +0530
Subject: [PATCH 0538/1978] Subscribed to Newsletter Label and respective
checkbox not aligned proper #25207 issue fixed
Subscribed to Newsletter Label and respective checkbox not aligned proper #25207 issue fixed
---
.../Magento/backend/web/css/styles-old.less | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/app/design/adminhtml/Magento/backend/web/css/styles-old.less b/app/design/adminhtml/Magento/backend/web/css/styles-old.less
index b2afde435a627..70b16060a7b64 100644
--- a/app/design/adminhtml/Magento/backend/web/css/styles-old.less
+++ b/app/design/adminhtml/Magento/backend/web/css/styles-old.less
@@ -3958,6 +3958,20 @@
.grid tr.headings th > span {
white-space: normal;
}
+ .field{
+ &.field-subscription {
+ .admin__field-label{
+ margin-left: 10px;
+ float: none;
+ cursor: pointer;
+ }
+ .admin__field-control {
+ float: left;
+ width: auto;
+ margin: 6px 0px 0px 0px;
+ }
+ }
+ }
}
}
From 7f04255d52a463414d5cdb6a981414909a2dd846 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Tue, 22 Oct 2019 12:03:53 +0300
Subject: [PATCH 0539/1978] MC-20694: Admin: Delete attribute set
---
.../attribute_set_based_on_default_with_custom_group.php | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
index 333f286277924..ccca2b7e4dbce 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_based_on_default_with_custom_group.php
@@ -6,7 +6,6 @@
declare(strict_types=1);
use Magento\Catalog\Api\Data\ProductAttributeInterface;
-use Magento\Catalog\Api\Data\ProductInterface;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Api\Data\AttributeGroupInterface;
use Magento\Eav\Api\Data\AttributeSetInterfaceFactory;
@@ -21,8 +20,6 @@
$attributeSetFactory = $objectManager->get(AttributeSetInterfaceFactory::class);
/** @var Type $entityType */
$entityType = $objectManager->create(Type::class)->loadByCode(ProductAttributeInterface::ENTITY_TYPE_CODE);
-/** @var ProductInterface $product */
-$product = $objectManager->create(ProductInterface::class);
$attributeSet = $attributeSetFactory->create(
[
'data' => [
@@ -37,7 +34,7 @@
$attributeSet->setHasDataChanges(true);
$attributeSet->validate();
$attributeSetRepository->save($attributeSet);
-$attributeSet->initFromSkeleton($product->getDefaultAttributeSetid());
+$attributeSet->initFromSkeleton($entityType->getDefaultAttributeSetId());
/** @var AttributeGroupInterface $newGroup */
$newGroup = $objectManager->get(GroupFactory::class)->create();
$newGroup->setId(null)
From 08fb9aec1e152181b817a342c55ce6ff2644a55e Mon Sep 17 00:00:00 2001
From: Ivan Koliadynskyy
Date: Tue, 22 Oct 2019 12:07:50 +0300
Subject: [PATCH 0540/1978] Fix for unit test
---
app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
index 89f87f2ee483b..2c61c192ead62 100644
--- a/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
+++ b/app/code/Magento/Quote/Test/Unit/Model/QuoteManagementTest.php
@@ -576,7 +576,6 @@ public function testAssignCustomer()
$cartId = 220;
$customerId = 455;
$storeId = 5;
- $activeQuoteMock = null;
$this->getPropertyValue($this->model, 'quoteIdMaskFactory')
->expects($this->once())
From aa6586a0526f4d990e1ea0f66a5858e21cb5f786 Mon Sep 17 00:00:00 2001
From: Jean-Bernard Valentaten
Date: Fri, 18 Oct 2019 18:21:54 +0200
Subject: [PATCH 0541/1978] MC-5374: Adds static test that checks PHP
compatibility
---
composer.json | 2 +
composer.lock | 128 +++++++++++++++++-
.../Tool/CompatibilityInterface.php | 22 +++
.../CodingStandard/Tool/PhpCompatibility.php | 25 ++++
.../Magento/Test/Php/LiveCodeTest.php | 97 ++++++++++++-
.../PHPCompatibilityMagento/ruleset.xml | 13 ++
6 files changed, 279 insertions(+), 8 deletions(-)
create mode 100644 dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CompatibilityInterface.php
create mode 100644 dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/PhpCompatibility.php
create mode 100644 dev/tests/static/testsuite/Magento/Test/Php/_files/PHPCompatibilityMagento/ruleset.xml
diff --git a/composer.json b/composer.json
index ba7f28678ffdd..281297fc2cce0 100644
--- a/composer.json
+++ b/composer.json
@@ -84,11 +84,13 @@
},
"require-dev": {
"allure-framework/allure-phpunit": "~1.2.0",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.5.0",
"friendsofphp/php-cs-fixer": "~2.14.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "~4.0.0",
"magento/magento2-functional-testing-framework": "2.5.0",
"pdepend/pdepend": "2.5.2",
+ "phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "~6.5.0",
"sebastian/phpcpd": "~3.0.0",
diff --git a/composer.lock b/composer.lock
index 3d9f7d19530fc..6091f2f293396 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "7ff21794a9a2266584e59855a064c992",
+ "content-hash": "f1498772c5931b80604037605f7e49c2",
"packages": [
{
"name": "braintree/braintree_php",
@@ -5966,6 +5966,72 @@
"description": "Guzzle6 transport for Vault PHP client",
"time": "2019-03-10T06:17:37+00:00"
},
+ {
+ "name": "dealerdirect/phpcodesniffer-composer-installer",
+ "version": "v0.5.0",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Dealerdirect/phpcodesniffer-composer-installer.git",
+ "reference": "e749410375ff6fb7a040a68878c656c2e610b132"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Dealerdirect/phpcodesniffer-composer-installer/zipball/e749410375ff6fb7a040a68878c656c2e610b132",
+ "reference": "e749410375ff6fb7a040a68878c656c2e610b132",
+ "shasum": ""
+ },
+ "require": {
+ "composer-plugin-api": "^1.0",
+ "php": "^5.3|^7",
+ "squizlabs/php_codesniffer": "^2|^3"
+ },
+ "require-dev": {
+ "composer/composer": "*",
+ "phpcompatibility/php-compatibility": "^9.0",
+ "sensiolabs/security-checker": "^4.1.0"
+ },
+ "type": "composer-plugin",
+ "extra": {
+ "class": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin"
+ },
+ "autoload": {
+ "psr-4": {
+ "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Franck Nijhof",
+ "email": "franck.nijhof@dealerdirect.com",
+ "homepage": "http://www.frenck.nl",
+ "role": "Developer / IT Manager"
+ }
+ ],
+ "description": "PHP_CodeSniffer Standards Composer Installer Plugin",
+ "homepage": "http://www.dealerdirect.com",
+ "keywords": [
+ "PHPCodeSniffer",
+ "PHP_CodeSniffer",
+ "code quality",
+ "codesniffer",
+ "composer",
+ "installer",
+ "phpcs",
+ "plugin",
+ "qa",
+ "quality",
+ "standard",
+ "standards",
+ "style guide",
+ "stylecheck",
+ "tests"
+ ],
+ "time": "2018-10-26T13:21:45+00:00"
+ },
{
"name": "dflydev/dot-access-data",
"version": "v1.1.0",
@@ -7592,6 +7658,64 @@
],
"time": "2015-05-17T12:39:23+00:00"
},
+ {
+ "name": "phpcompatibility/php-compatibility",
+ "version": "9.3.2",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/PHPCompatibility/PHPCompatibility.git",
+ "reference": "bfca2be3992f40e92206e5a7ebe5eaee37280b58"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/PHPCompatibility/PHPCompatibility/zipball/bfca2be3992f40e92206e5a7ebe5eaee37280b58",
+ "reference": "bfca2be3992f40e92206e5a7ebe5eaee37280b58",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3",
+ "squizlabs/php_codesniffer": "^2.3 || ^3.0.2"
+ },
+ "conflict": {
+ "squizlabs/php_codesniffer": "2.6.2"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "~4.5 || ^5.0 || ^6.0 || ^7.0"
+ },
+ "suggest": {
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.5 || This Composer plugin will sort out the PHPCS 'installed_paths' automatically.",
+ "roave/security-advisories": "dev-master || Helps prevent installing dependencies with known security issues."
+ },
+ "type": "phpcodesniffer-standard",
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "LGPL-3.0-or-later"
+ ],
+ "authors": [
+ {
+ "name": "Wim Godden",
+ "homepage": "https://github.com/wimg",
+ "role": "lead"
+ },
+ {
+ "name": "Juliette Reinders Folmer",
+ "homepage": "https://github.com/jrfnl",
+ "role": "lead"
+ },
+ {
+ "name": "Contributors",
+ "homepage": "https://github.com/PHPCompatibility/PHPCompatibility/graphs/contributors"
+ }
+ ],
+ "description": "A set of sniffs for PHP_CodeSniffer that checks for PHP cross-version compatibility.",
+ "homepage": "http://techblog.wimgodden.be/tag/codesniffer/",
+ "keywords": [
+ "compatibility",
+ "phpcs",
+ "standards"
+ ],
+ "time": "2019-10-16T21:24:24+00:00"
+ },
{
"name": "phpdocumentor/reflection-common",
"version": "2.0.0",
diff --git a/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CompatibilityInterface.php b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CompatibilityInterface.php
new file mode 100644
index 0000000000000..63afaacf33817
--- /dev/null
+++ b/dev/tests/static/framework/Magento/TestFramework/CodingStandard/Tool/CompatibilityInterface.php
@@ -0,0 +1,22 @@
+composer.json of project.
+ *
+ * @return string
+ */
+ private function getLowestPhpVersion(): string
+ {
+ $composerJson = json_decode(file_get_contents(BP . '/composer.json'), true);
+ $phpVersion = '7.0';
+
+ if (isset($composerJson['require']['php'])) {
+ $versions = explode('||', $composerJson['require']['php']);
+
+ //normalize version constraints
+ foreach ($versions as $key => $version) {
+ $version = ltrim($version, '^~');
+ $version = str_replace('*', '999', $version);
+
+ $versions[$key] = $version;
+ }
+
+ //sort versions
+ usort($versions, 'version_compare');
+
+ $lowestVersion = array_shift($versions);
+ $versionParts = explode('.', $lowestVersion);
+ $phpVersion = sprintf('%s.%s', $versionParts[0], $versionParts[1] ?? '0');
+ }
+
+ return $phpVersion;
+ }
+
+ /**
+ * Returns whether a full scan was requested.
+ *
+ * This can be set in the `phpunit.xml` used to run these test cases, by setting the constant
+ * `TESTCODESTYLE_IS_FULL_SCAN` to `1`, e.g.:
+ * ```xml
+ *
+ *
+ *
+ *
+ * ```
+ *
+ * @return bool
+ */
+ private function isFullScan(): bool
+ {
+ return defined('TESTCODESTYLE_IS_FULL_SCAN') && TESTCODESTYLE_IS_FULL_SCAN === '1';
+ }
+
/**
* Test code quality using phpcs
*/
public function testCodeStyle()
{
- $isFullScan = defined('TESTCODESTYLE_IS_FULL_SCAN') && TESTCODESTYLE_IS_FULL_SCAN === '1';
$reportFile = self::$reportDir . '/phpcs_report.txt';
if (!file_exists($reportFile)) {
touch($reportFile);
}
$codeSniffer = new CodeSniffer('Magento', $reportFile, new Wrapper());
- $result = $codeSniffer->run($isFullScan ? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml']));
+ $result = $codeSniffer->run(
+ $this->isFullScan() ? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml'])
+ );
$report = file_get_contents($reportFile);
$this->assertEquals(
0,
@@ -325,6 +381,7 @@ public function testCopyPaste()
$blackList = [];
foreach (glob(__DIR__ . '/_files/phpcpd/blacklist/*.txt') as $list) {
+ // phpcs:ignore Magento2.Performance.ForeachArrayMerge.ForeachArrayMerge
$blackList = array_merge($blackList, file($list, FILE_IGNORE_NEW_LINES));
}
@@ -380,4 +437,32 @@ public function testStrictTypes()
. implode(PHP_EOL, $filesMissingStrictTyping)
);
}
+
+ /**
+ * Test for compatibility to lowest PHP version declared in composer.json .
+ */
+ public function testPhpCompatibility()
+ {
+ $targetVersion = $this->getLowestPhpVersion();
+ $reportFile = self::$reportDir . '/phpcompatibility_report.txt';
+ $rulesetDir = __DIR__ . '/_files/PHPCompatibilityMagento';
+
+ if (!file_exists($reportFile)) {
+ touch($reportFile);
+ }
+
+ $codeSniffer = new PhpCompatibility($rulesetDir, $reportFile, new Wrapper());
+ $codeSniffer->setTestVersion($targetVersion);
+
+ $result = $codeSniffer->run(
+ $this->isFullScan() ? $this->getFullWhitelist() : self::getWhitelist(['php', 'phtml'])
+ );
+ $report = file_get_contents($reportFile);
+
+ $this->assertEquals(
+ 0,
+ $result,
+ 'PHP Compatibility detected violation(s):' . PHP_EOL . $report
+ );
+ }
}
diff --git a/dev/tests/static/testsuite/Magento/Test/Php/_files/PHPCompatibilityMagento/ruleset.xml b/dev/tests/static/testsuite/Magento/Test/Php/_files/PHPCompatibilityMagento/ruleset.xml
new file mode 100644
index 0000000000000..579a6d2416f20
--- /dev/null
+++ b/dev/tests/static/testsuite/Magento/Test/Php/_files/PHPCompatibilityMagento/ruleset.xml
@@ -0,0 +1,13 @@
+
+
+
+ Magento 2 specific ruleset which checks for PHP cross version compatibility.
+
+
+
+
From 7cde27c1e26ff6585a13f11367c83d14dd0648f2 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Tue, 22 Oct 2019 13:30:14 +0300
Subject: [PATCH 0542/1978] MC-20694: Admin: Delete attribute set
---
.../Magento/TestFramework/Eav/Model/GetAttributeSetByName.php | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
index 12ff978a12e12..e9164f5dcd87f 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
@@ -12,7 +12,7 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
/**
- * Attribute set additional functions.
+ * Search and return attribute set by name.
*/
class GetAttributeSetByName
{
@@ -39,8 +39,6 @@ public function __construct(
}
/**
- * Search and return attribute set by name.
- *
* @param string $attributeSetName
* @return AttributeSetInterface|null
*/
From 156c689eedb3fd39b91d771c60e8d7eda611f4be Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Tue, 22 Oct 2019 13:49:18 +0300
Subject: [PATCH 0543/1978] Revert string concat optimizations - there is no
real improvement
I've run performance tests for string concat vs. array join:
https://gist.github.com/andrey-legayev/24ed101a34d4775bf1b6f9879581f51a
No real performance improvement (which surprised me).
But anyway - I'm rolling back string concatenation improvements, because it doesn't make any sense.
---
.../Framework/View/Element/AbstractBlock.php | 14 ++------------
lib/internal/Magento/Framework/View/Layout.php | 14 ++++++--------
2 files changed, 8 insertions(+), 20 deletions(-)
diff --git a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php
index 57cf1f68efca6..0d7e3154440e9 100644
--- a/lib/internal/Magento/Framework/View/Element/AbstractBlock.php
+++ b/lib/internal/Magento/Framework/View/Element/AbstractBlock.php
@@ -520,14 +520,9 @@ public function getChildHtml($alias = '', $useCache = true)
$out = $layout->renderElement($childName, $useCache);
}
} else {
- $outParts = [];
foreach ($layout->getChildNames($name) as $child) {
- $elementHtml = $layout->renderElement($child, $useCache);
- if (!empty($elementHtml)) {
- $outParts[] = $elementHtml;
- }
+ $out .= $layout->renderElement($child, $useCache);
}
- $out = join('', $outParts);
}
return $out;
@@ -556,14 +551,9 @@ public function getChildChildHtml($alias, $childChildAlias = '', $useCache = tru
$childChildName = $layout->getChildName($childName, $childChildAlias);
$out = $layout->renderElement($childChildName, $useCache);
} else {
- $outParts = [];
foreach ($layout->getChildNames($childName) as $childChild) {
- $elementHtml = $layout->renderElement($childChild, $useCache);
- if (!empty($elementHtml)) {
- $outParts[] = $elementHtml;
- }
+ $out .= $layout->renderElement($childChild, $useCache);
}
- $out = join('', $outParts);
}
return $out;
}
diff --git a/lib/internal/Magento/Framework/View/Layout.php b/lib/internal/Magento/Framework/View/Layout.php
index 994a19b03695d..a622006f32a1e 100644
--- a/lib/internal/Magento/Framework/View/Layout.php
+++ b/lib/internal/Magento/Framework/View/Layout.php
@@ -586,16 +586,13 @@ protected function _renderUiComponent($name)
*/
protected function _renderContainer($name, $useCache = true)
{
- $htmlParts = [];
+ $html = '';
$children = $this->getChildNames($name);
foreach ($children as $child) {
- $childHtml = $this->renderElement($child, $useCache);
- if (!empty($childHtml)) {
- $htmlParts[] = $childHtml;
- }
+ $html .= $this->renderElement($child, $useCache);
}
- if (empty($htmlParts) || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
- return join('', $htmlParts);
+ if ($html == '' || !$this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG)) {
+ return $html;
}
$htmlId = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_ID);
@@ -609,7 +606,8 @@ protected function _renderContainer($name, $useCache = true)
}
$htmlTag = $this->structure->getAttribute($name, Element::CONTAINER_OPT_HTML_TAG);
- $html = sprintf('<%1$s%2$s%3$s>%4$s%1$s>', $htmlTag, $htmlId, $htmlClass, join('', $htmlParts));
+
+ $html = sprintf('<%1$s%2$s%3$s>%4$s%1$s>', $htmlTag, $htmlId, $htmlClass, $html);
return $html;
}
From 824ed399323d49815592e2975a0cadf821d77ade Mon Sep 17 00:00:00 2001
From: Arvinda kumar
Date: Tue, 22 Oct 2019 16:39:15 +0530
Subject: [PATCH 0544/1978] #25208 issue updated
---
.../adminhtml/Magento/backend/web/css/styles-old.less | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/design/adminhtml/Magento/backend/web/css/styles-old.less b/app/design/adminhtml/Magento/backend/web/css/styles-old.less
index 70b16060a7b64..c9ecf2e6670c1 100644
--- a/app/design/adminhtml/Magento/backend/web/css/styles-old.less
+++ b/app/design/adminhtml/Magento/backend/web/css/styles-old.less
@@ -3958,13 +3958,15 @@
.grid tr.headings th > span {
white-space: normal;
}
- .field{
+
+ .field {
&.field-subscription {
- .admin__field-label{
+ .admin__field-label {
margin-left: 10px;
float: none;
cursor: pointer;
}
+
.admin__field-control {
float: left;
width: auto;
From 9af76e7b827801d0207d3a63736aa44d86582cbf Mon Sep 17 00:00:00 2001
From: "vishesh.dwivedi"
Date: Tue, 22 Oct 2019 18:30:54 +0530
Subject: [PATCH 0545/1978] #25214 fixed
---
app/code/Magento/Backend/Block/Store/Switcher.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Backend/Block/Store/Switcher.php b/app/code/Magento/Backend/Block/Store/Switcher.php
index 9c35cfb5df81d..2b9f70844df86 100644
--- a/app/code/Magento/Backend/Block/Store/Switcher.php
+++ b/app/code/Magento/Backend/Block/Store/Switcher.php
@@ -592,7 +592,7 @@ public function getHintHtml()
'What is this?'
) . '"' . ' class="admin__field-tooltip-action action-help">' . __(
'What is this?'
- ) . ' ' . ' ';
+ ) . '' . ' ';
}
return $html;
}
From 93f3711c6914b225d1b95368f3ec6c10caf7fcdc Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 22 Oct 2019 16:21:13 +0300
Subject: [PATCH 0546/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
.../Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 925cc4d1590c5..86c9e02f021e9 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -59,7 +59,7 @@
-
+
From 724ccefa2872b9971c8f088423b4e9ddb7a39356 Mon Sep 17 00:00:00 2001
From: Viktor Sevch
Date: Tue, 22 Oct 2019 17:22:35 +0300
Subject: [PATCH 0547/1978] MC-18280: Dynamic Block based on segment not
displaying correctly for visitor
---
.../AdminCreateAndSaveWidgetActionGroup.xml | 2 +-
.../AdminCreateWidgetActionGroup.xml | 29 +++++++++++++++++--
.../Mftf/Section/AdminNewWidgetSection.xml | 5 ++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml
index 00f593a2d3bc8..d70eb50da4de5 100644
--- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml
+++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml
@@ -12,7 +12,7 @@
EXTENDS: AdminCreateWidgetActionGroup. Clicks on Save. Validates that the Success Message is present and correct.
-
+
diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
index 797abdb6f56ae..51bb8c4547e3f 100644
--- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
+++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
@@ -30,7 +30,32 @@
-
+
+
+ Fill widget main fields and widget layout by index for specified page DisplayOn option
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -54,7 +79,7 @@
EXTENDS: AdminCreateWidgetActionGroup. Creates a Dynamic Block Rotate Widget.
-
+
diff --git a/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml b/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml
index eebd6c10b5085..e492fb7ae33f3 100644
--- a/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml
+++ b/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml
@@ -14,9 +14,14 @@
+
+
+
+
+
From 0fe0cdcc30a925422756452224bebdd667542e9c Mon Sep 17 00:00:00 2001
From: Andrey Legayev
Date: Tue, 22 Oct 2019 18:57:05 +0300
Subject: [PATCH 0548/1978] Braintree - Skip generation Client Token if payment
method is not active
For now Braintree module requests ClientToken via curl request
on every shopping cart and checkout page load.
Curl request takes 0.3-0.5 sec to respond for servers in N.Virginia
---
app/code/Magento/Braintree/Model/Ui/ConfigProvider.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php
index ab23037b4e98e..1ba696839a95d 100644
--- a/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php
+++ b/app/code/Magento/Braintree/Model/Ui/ConfigProvider.php
@@ -67,11 +67,12 @@ public function __construct(
public function getConfig()
{
$storeId = $this->session->getStoreId();
+ $isActive = $this->config->isActive($storeId);
return [
'payment' => [
self::CODE => [
- 'isActive' => $this->config->isActive($storeId),
- 'clientToken' => $this->getClientToken(),
+ 'isActive' => $isActive,
+ 'clientToken' => $isActive ? $this->getClientToken() : null,
'ccTypesMapper' => $this->config->getCcTypesMapper(),
'sdkUrl' => $this->config->getSdkUrl(),
'hostedFieldsSdkUrl' => $this->config->getHostedFieldsSdkUrl(),
From 2c1c40dc356f3c569349ee393ec96fd9d8bfb3d1 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Tue, 22 Oct 2019 15:05:48 -0500
Subject: [PATCH 0549/1978] MC-19226: Cart Promotions :: Store promotions
detail on the quote - review fixes
---
app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php | 2 +-
app/code/Magento/SalesRule/Model/Data/RuleDiscount.php | 3 ++-
.../SalesRule/Model/Rule/Action/Discount/CartFixedTest.php | 2 ++
.../Magento/SalesRule/_files/coupon_cart_fixed_discount.php | 1 -
4 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
index f457c7783b799..703015fd7ddb1 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/Discounts.php
@@ -42,7 +42,7 @@ private function getDiscountValues(Quote $quote)
$discountValues=[];
$address = $quote->getShippingAddress();
$totalDiscounts = $address->getExtensionAttributes()->getDiscounts();
- if ($totalDiscounts) {
+ if ($totalDiscounts && is_array($totalDiscounts)) {
foreach ($totalDiscounts as $value) {
$discount = [];
$amount = [];
diff --git a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
index 950b9385fdd1b..aaf657c06b4fc 100644
--- a/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
+++ b/app/code/Magento/SalesRule/Model/Data/RuleDiscount.php
@@ -9,11 +9,12 @@
use Magento\Framework\Api\ExtensionAttributesInterface;
use Magento\SalesRule\Api\Data\RuleDiscountInterface;
+use Magento\Framework\Api\AbstractExtensibleObject;
/**
* Data Model for Rule Discount
*/
-class RuleDiscount extends \Magento\Framework\Api\AbstractExtensibleObject implements RuleDiscountInterface
+class RuleDiscount extends AbstractExtensibleObject implements RuleDiscountInterface
{
const KEY_DISCOUNT_DATA = 'discount';
const KEY_RULE_LABEL = 'rule';
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 3fbfec24353a2..f56fb0a2c6135 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
@@ -164,6 +164,7 @@ public function testDiscountsOnQuoteWithFixedDiscount(): void
/** @var CartItemInterface $item */
$item = $quote->getItems()[0];
$quoteItemDiscounts = $item->getExtensionAttributes()->getDiscounts();
+ $this->assertArrayHasKey('0', $quoteItemDiscounts);
$discountData = $quoteItemDiscounts[0]->getDiscountData();
$ruleLabel = $quoteItemDiscounts[0]->getRuleLabel();
$this->assertEquals(5, $discountData->getAmount());
@@ -173,6 +174,7 @@ public function testDiscountsOnQuoteWithFixedDiscount(): void
$this->assertEquals('TestRule_Coupon', $ruleLabel);
$quoteAddressItemDiscount = $quote->getShippingAddressesItems()[0]->getExtensionAttributes()->getDiscounts();
+ $this->assertArrayHasKey('0', $quoteAddressItemDiscount);
$discountData = $quoteAddressItemDiscount[0]->getDiscountData();
$ruleLabel = $quoteAddressItemDiscount[0]->getRuleLabel();
$this->assertEquals(5, $discountData->getAmount());
diff --git a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php
index 545efd082adb2..7cdc611702c98 100644
--- a/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php
+++ b/dev/tests/integration/testsuite/Magento/SalesRule/_files/coupon_cart_fixed_discount.php
@@ -41,7 +41,6 @@
'store_id' => 0,
'store_label' => 'TestRule_Coupon',
-
]
]
);
From 9ff11dd8b62fd94379ee95969338ced760582301 Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Tue, 22 Oct 2019 16:26:43 -0500
Subject: [PATCH 0550/1978] MC-15759: Elasticsearch: Searches That Contain
Question Mark Followed by Semicolon Will Result In Error Page (Multiple
Queries Error) Remove cache clean and reindex
---
.../Test/StorefrontElasticsearch6SearchInvalidValueTest.xml | 2 --
1 file changed, 2 deletions(-)
diff --git a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
index e3a63b9c83338..52d7c6914b438 100644
--- a/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
+++ b/app/code/Magento/Elasticsearch6/Test/Mftf/Test/StorefrontElasticsearch6SearchInvalidValueTest.xml
@@ -78,8 +78,6 @@
-
-
From 392fb119bb906f2bdb281a9574b2b9b1a88fec41 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Tue, 22 Oct 2019 17:56:56 -0500
Subject: [PATCH 0551/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 16 ++++-----------
.../Model/Rule/ConfigurableProductHandler.php | 20 +++++++++++++++++++
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 207bacd03bebc..9465847d21fe1 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -290,10 +290,6 @@ protected function doReindexByIds($ids)
{
$this->cleanProductIndex($ids);
- $products = [];
- foreach ($this->productLoader->getProducts($ids) as $product) {
- $products[$product->getId()] = $product;
- }
/** @var Rule[] $activeRules */
$activeRules = $this->getActiveRules()->getItems();
foreach ($activeRules as $rule) {
@@ -302,20 +298,16 @@ protected function doReindexByIds($ids)
continue;
}
- $rule->setProductsFilter(array_keys($products));
+ $rule->setProductsFilter($ids);
$matchingProductIds = $rule->getMatchingProductIds();
- if (!is_array($ruleWebsiteIds)) {
- $ruleWebsiteIds = explode(',', $ruleWebsiteIds);
- }
foreach ($matchingProductIds as $matchingProductId => $validationByWebsite) {
- $product = $products[$matchingProductId];
- $websiteIds = array_intersect($product->getWebsiteIds(), $ruleWebsiteIds);
- $this->assignProductToRule($rule, $product->getId(), $websiteIds);
+ $websiteIds = array_keys(array_filter($validationByWebsite));
+ $this->assignProductToRule($rule, $matchingProductId, $websiteIds);
}
}
- $this->cleanProductPriceIndex($ids);
foreach ($ids as $productId) {
+ $this->cleanProductPriceIndex([$productId]);
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
diff --git a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php
index d27c424ed9ea3..e846c10bf49ef 100644
--- a/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php
+++ b/app/code/Magento/CatalogRuleConfigurable/Plugin/CatalogRule/Model/Rule/ConfigurableProductHandler.php
@@ -41,6 +41,26 @@ public function __construct(
$this->configurableProductsProvider = $configurableProductsProvider;
}
+ /**
+ * @param \Magento\CatalogRule\Model\Rule $rule
+ * @param int|array $productIds
+ * @return array
+ */
+ public function beforeSetProductsFilter(\Magento\CatalogRule\Model\Rule $rule, $productIds)
+ {
+ if ($productIds) {
+ $configurableProductIds = $this->configurable->getParentIdsByChild($productIds);
+ if ($configurableProductIds) {
+ $productIds = array_merge((array) $productIds, $configurableProductIds);
+
+ }
+ }
+
+ return [
+ $productIds,
+ ];
+ }
+
/**
* @param \Magento\CatalogRule\Model\Rule $rule
* @param array $productIds
From c69aae4aeaac06cd887b5d40116b58f0d5b728b2 Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Tue, 22 Oct 2019 18:57:02 -0500
Subject: [PATCH 0552/1978] MC-16108: [Performance] EAV attribute is not cached
---
app/code/Magento/Catalog/Model/Config.php | 7 +-
app/code/Magento/Catalog/etc/di.xml | 34 +++++
app/code/Magento/Eav/Model/Config.php | 142 +++++++++++++++++-
.../Eav/Model/Entity/AbstractEntity.php | 73 ++++-----
.../Entity/Attribute/AbstractAttribute.php | 4 +-
5 files changed, 205 insertions(+), 55 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php
index 5dce940308a4f..330416a4767d9 100644
--- a/app/code/Magento/Catalog/Model/Config.php
+++ b/app/code/Magento/Catalog/Model/Config.php
@@ -133,6 +133,7 @@ class Config extends \Magento\Eav\Model\Config
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Config $eavConfig
* @param SerializerInterface $serializer
+ * @param array $data
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -149,7 +150,8 @@ public function __construct(
\Magento\Eav\Model\ResourceModel\Entity\Attribute\Set\CollectionFactory $setCollectionFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Eav\Model\Config $eavConfig,
- SerializerInterface $serializer = null
+ SerializerInterface $serializer = null,
+ $data = []
) {
$this->_scopeConfig = $scopeConfig;
$this->_configFactory = $configFactory;
@@ -165,7 +167,8 @@ public function __construct(
$entityTypeCollectionFactory,
$cacheState,
$universalFactory,
- $serializer
+ $serializer,
+ $data
);
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index ff2fab73e0379..e58485ef42636 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1176,4 +1176,38 @@
+
+
+
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+
+
+
diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php
index 0eecca21b0d54..2a0effb4e3593 100644
--- a/app/code/Magento/Eav/Model/Config.php
+++ b/app/code/Magento/Eav/Model/Config.php
@@ -7,7 +7,10 @@
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
use Magento\Eav\Model\Entity\Type;
+use Magento\Eav\Model\ResourceModel\Attribute\DefaultEntityAttributes\ProviderInterface;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Serialize\SerializerInterface;
/**
@@ -123,6 +126,20 @@ class Config
*/
private $attributesPerSet = [];
+ /**
+ * Is system attributes loaded flag.
+ *
+ * @var array
+ */
+ private $isSystemAttributesLoaded = [];
+
+ /**
+ * List of predefined system attributes.
+ *
+ * @var array
+ */
+ private $data;
+
/**
* @param \Magento\Framework\App\CacheInterface $cache
* @param \Magento\Eav\Model\Entity\TypeFactory $entityTypeFactory
@@ -130,6 +147,7 @@ class Config
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
* @param SerializerInterface $serializer
+ * @param array $data
* @codeCoverageIgnore
*/
public function __construct(
@@ -138,7 +156,8 @@ public function __construct(
\Magento\Eav\Model\ResourceModel\Entity\Type\CollectionFactory $entityTypeCollectionFactory,
\Magento\Framework\App\Cache\StateInterface $cacheState,
\Magento\Framework\Validator\UniversalFactory $universalFactory,
- SerializerInterface $serializer = null
+ SerializerInterface $serializer = null,
+ $data = []
) {
$this->_cache = $cache;
$this->_entityTypeFactory = $entityTypeFactory;
@@ -146,6 +165,7 @@ public function __construct(
$this->_cacheState = $cacheState;
$this->_universalFactory = $universalFactory;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
+ $this->data = $data;
}
/**
@@ -487,7 +507,7 @@ public function getAttributes($entityType)
* @param mixed $entityType
* @param mixed $code
* @return AbstractAttribute
- * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws LocalizedException
*/
public function getAttribute($entityType, $code)
{
@@ -507,9 +527,27 @@ public function getAttribute($entityType, $code)
return $this->attributes[$entityTypeCode][$code];
}
- $attributes = $this->loadAttributes($entityTypeCode);
- $attribute = isset($attributes[$code]) ? $attributes[$code] : null;
- if (!$attribute) {
+ if (array_key_exists($code, $this->data) && in_array($entityTypeCode, array_values($this->data), true)) {
+ $this->initSystemAttributes($entityType, $this->data);
+ }
+ if (isset($this->attributes[$entityTypeCode][$code])) {
+ \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__);
+ return $this->attributes[$entityTypeCode][$code];
+ }
+ $cacheKey = self::ATTRIBUTES_CACHE_ID . '-attribute-' . $entityTypeCode . '-' . $code;
+ $attributeData = $this->isCacheEnabled() && ($attribute = $this->_cache->load($cacheKey))
+ ? $this->serializer->unserialize($attribute)
+ : null;
+ if ($attributeData) {
+ if (isset($attributeData['attribute_id'])) {
+ $attribute = $this->_createAttribute($entityType, $attributeData);
+ } else {
+ $entityType = $this->getEntityType($entityType);
+ $attribute = $this->createAttribute($entityType->getAttributeModel());
+ $attribute->setAttributeCode($code);
+ $attribute = $this->setAttributeData($attribute, $entityType);
+ }
+ } else {
$attribute = $this->createAttributeByAttributeCode($entityType, $code);
$this->_addAttributeReference(
$attribute->getAttributeId(),
@@ -517,11 +555,87 @@ public function getAttribute($entityType, $code)
$entityTypeCode
);
$this->saveAttribute($attribute, $entityTypeCode, $attribute->getAttributeCode());
+ if ($this->isCacheEnabled()) {
+ $this->_cache->save(
+ $this->serializer->serialize($attribute->getData()),
+ $cacheKey,
+ [
+ \Magento\Eav\Model\Cache\Type::CACHE_TAG,
+ \Magento\Eav\Model\Entity\Attribute::CACHE_TAG
+ ]
+ );
+ }
}
\Magento\Framework\Profiler::stop('EAV: ' . __METHOD__);
return $attribute;
}
+ /**
+ * Initialize predefined system attributes.
+ *
+ * @param string $entityType
+ * @param array $systemAttributes
+ * @return $this|bool|void
+ * @throws LocalizedException
+ */
+ private function initSystemAttributes($entityType, $systemAttributes)
+ {
+ $entityType = $this->getEntityType($entityType);
+ $entityTypeCode = $entityType->getEntityTypeCode();
+ if (!empty($this->isSystemAttributesLoaded[$entityTypeCode])) {
+ return;
+ }
+
+ $cacheKey = self::ATTRIBUTES_CACHE_ID . '-' . $entityTypeCode . '-preload';
+ if ($this->isCacheEnabled() && ($attributes = $this->_cache->load($cacheKey))) {
+ $attributes = $this->serializer->unserialize($attributes);
+ if ($attributes) {
+ foreach ($attributes as $attribute) {
+ $attributeObject = $this->_createAttribute($entityType, $attribute);
+ $this->saveAttribute($attributeObject, $entityTypeCode, $attributeObject->getAttributeCode());
+ }
+ return true;
+ }
+ }
+
+ \Magento\Framework\Profiler::start('EAV: ' . __METHOD__, ['group' => 'EAV', 'method' => __METHOD__]);
+
+ /** @var \Magento\Eav\Model\ResourceModel\Entity\Attribute\Collection $attributes */
+ $attributes = $this->_universalFactory->create(
+ $entityType->getEntityAttributeCollection()
+ )->setEntityTypeFilter(
+ $entityType
+ )->addFieldToFilter(
+ 'attribute_code',
+ ['in' => array_keys($systemAttributes)]
+ )->getData();
+
+ $attributeData = [];
+ foreach ($attributes as $attribute) {
+ if (empty($attribute['attribute_model'])) {
+ $attribute['attribute_model'] = $entityType->getAttributeModel();
+ }
+ $attributeObject = $this->_createAttribute($entityType, $attribute);
+ $this->saveAttribute($attributeObject, $entityTypeCode, $attributeObject->getAttributeCode());
+ $attributeData[$attribute['attribute_code']] = $attributeObject->toArray();
+ }
+ if ($this->isCacheEnabled()) {
+ $this->_cache->save(
+ $this->serializer->serialize($attributeData),
+ $cacheKey,
+ [
+ \Magento\Eav\Model\Cache\Type::CACHE_TAG,
+ \Magento\Eav\Model\Entity\Attribute::CACHE_TAG
+ ]
+ );
+ }
+
+ \Magento\Framework\Profiler::stop('EAV: ' . __METHOD__);
+ $this->isSystemAttributesLoaded[$entityTypeCode] = true;
+
+ return $this;
+ }
+
/**
* Create attribute
*
@@ -708,6 +822,7 @@ public function importAttributesData($entityType, array $attributes)
* @param string $entityType
* @param string $attributeCode
* @return AbstractAttribute
+ * @throws LocalizedException
*/
private function createAttributeByAttributeCode($entityType, $attributeCode)
{
@@ -723,13 +838,28 @@ private function createAttributeByAttributeCode($entityType, $attributeCode)
$attribute->setAttributeCode($attributeCode);
}
+ $attribute = $this->setAttributeData($attribute, $entityType);
+
+ return $attribute;
+ }
+
+ /**
+ * Set entity type id, backend type, is global to attribute.
+ *
+ * @param AbstractAttribute $attribute
+ * @param AbstractModel $entityType
+ * @return AbstractAttribute
+ */
+ private function setAttributeData($attribute, $entityType): AbstractAttribute
+ {
$entity = $entityType->getEntity();
- if ($entity instanceof \Magento\Eav\Model\ResourceModel\Attribute\DefaultEntityAttributes\ProviderInterface
+ if ($entity instanceof ProviderInterface
&& in_array($attribute->getAttributeCode(), $entity->getDefaultAttributes(), true)
) {
$attribute->setBackendType(AbstractAttribute::TYPE_STATIC)->setIsGlobal(1);
}
$attribute->setEntityType($entityType)->setEntityTypeId($entityType->getId());
+
return $attribute;
}
diff --git a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
index 1fd71e446e6bb..ff314832f528e 100644
--- a/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
+++ b/app/code/Magento/Eav/Model/Entity/AbstractEntity.php
@@ -11,17 +11,17 @@
use Magento\Eav\Model\Entity\Attribute\Frontend\AbstractFrontend;
use Magento\Eav\Model\Entity\Attribute\Source\AbstractSource;
use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;
+use Magento\Eav\Model\ResourceModel\Attribute\DefaultEntityAttributes\ProviderInterface as DefaultAttributesProvider;
use Magento\Framework\App\Config\Element;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\DataObject;
use Magento\Framework\DB\Adapter\DuplicateException;
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractModel;
+use Magento\Framework\Model\ResourceModel\AbstractResource;
use Magento\Framework\Model\ResourceModel\Db\ObjectRelationProcessor;
use Magento\Framework\Model\ResourceModel\Db\TransactionManagerInterface;
-use Magento\Eav\Model\ResourceModel\Attribute\DefaultEntityAttributes\ProviderInterface as DefaultAttributesProvider;
-use Magento\Framework\Model\ResourceModel\AbstractResource;
-use Magento\Framework\App\ObjectManager;
/**
* Entity/Attribute/Model - entity abstract
@@ -412,61 +412,44 @@ protected function _getConfig()
*
* @param string|int|Element $attribute
* @return AbstractAttribute|false
+ * @throws LocalizedException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
public function getAttribute($attribute)
{
/** @var $config \Magento\Eav\Model\Config */
$config = $this->_getConfig();
- if (is_numeric($attribute)) {
- $attributeId = $attribute;
- $attributeInstance = $config->getAttribute($this->getEntityType(), $attributeId);
- if ($attributeInstance) {
- $attributeCode = $attributeInstance->getAttributeCode();
- }
- } elseif (is_string($attribute)) {
- $attributeCode = $attribute;
- $attributeInstance = $config->getAttribute($this->getEntityType(), $attributeCode);
- if (!$attributeInstance->getAttributeCode() && in_array($attribute, $this->getDefaultAttributes())) {
- $attributeInstance->setAttributeCode(
- $attribute
- )->setBackendType(
- AbstractAttribute::TYPE_STATIC
- )->setIsGlobal(
- 1
- )->setEntity(
- $this
- )->setEntityType(
- $this->getEntityType()
- )->setEntityTypeId(
- $this->getEntityType()->getId()
- );
- }
- } elseif ($attribute instanceof AbstractAttribute) {
- $attributeInstance = $attribute;
- $attributeCode = $attributeInstance->getAttributeCode();
+
+ $attributeInstance = $config->getAttribute($this->getEntityType(), $attribute);
+
+ if (!$attributeInstance->getAttributeCode() && in_array($attribute, $this->getDefaultAttributes(), true)) {
+ $attributeInstance = clone $attributeInstance;
+ $attributeInstance->setData([]);
+ $attributeInstance->setAttributeCode(
+ $attribute
+ )->setBackendType(
+ AbstractAttribute::TYPE_STATIC
+ )->setIsGlobal(
+ 1
+ )->setEntity(
+ $this
+ )->setEntityType(
+ $this->getEntityType()
+ )->setEntityTypeId(
+ $this->getEntityType()->getId()
+ );
}
- if (empty($attributeInstance)
- || !$attributeInstance instanceof AbstractAttribute
- || !$attributeInstance->getId()
- && !in_array($attributeInstance->getAttributeCode(), $this->getDefaultAttributes())
+ if (!$attributeInstance instanceof AbstractAttribute
+ || (!$attributeInstance->getId()
+ && !in_array($attributeInstance->getAttributeCode(), $this->getDefaultAttributes(), true))
) {
return false;
}
- $attribute = $attributeInstance;
-
- if (!$attribute->getAttributeCode()) {
- $attribute->setAttributeCode($attributeCode);
- }
- if (!$attribute->getAttributeModel()) {
- $attribute->setAttributeModel($this->_getDefaultAttributeModel());
- }
-
- $this->addAttribute($attribute);
+ $this->addAttribute($attributeInstance);
- return $attribute;
+ return $attributeInstance;
}
/**
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
index 16fe495de18db..faea6754d36bd 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
@@ -329,9 +329,9 @@ public function getAttributeCode()
}
/**
- * Set attribute model
+ * Set attribute model class.
*
- * @param array $data
+ * @param string $data
* @return $this
* @codeCoverageIgnore
*/
From a73d53788e138eeda42d6bc16f7ca9bc52438bbf Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Wed, 23 Oct 2019 09:26:30 +0300
Subject: [PATCH 0553/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
.../Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 86c9e02f021e9..5e008353c7ac7 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -59,7 +59,7 @@
-
+
From 32b966e5f6893e6911f09d14264905b155ad5f79 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Wed, 23 Oct 2019 11:15:31 +0300
Subject: [PATCH 0554/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
...UpdateProductAttributesGlobalScopeTest.xml | 6 ++--
.../AdminConfigurableProductUpdateTest.xml | 30 +++++++++----------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 5e008353c7ac7..7cbc706f0286b 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -36,7 +36,7 @@
-
+
@@ -63,8 +63,8 @@
-
-
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
index 76b9bd208444d..7c6cd57097591 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductUpdateTest.xml
@@ -21,13 +21,13 @@
-
+
-
+
-
+
@@ -35,9 +35,9 @@
-
-
-
+
+
+
@@ -46,7 +46,7 @@
-
+
@@ -57,28 +57,28 @@
-
+
-
-
+
+
-
-
+
+
-
+
-
+
-
+
From 6e4fe74c476e53c92cdfd06f6fa2c840d0aa5a97 Mon Sep 17 00:00:00 2001
From: Mateusz Krzeszowiak
Date: Wed, 23 Oct 2019 10:21:00 +0200
Subject: [PATCH 0555/1978] Fix fullscreen gallery image swiping for touch
devices
Fixes https://github.com/magento/magento2/issues/25231
---
lib/web/magnifier/magnify.js | 2 --
1 file changed, 2 deletions(-)
diff --git a/lib/web/magnifier/magnify.js b/lib/web/magnifier/magnify.js
index 9d673092b806c..559e7782f2476 100644
--- a/lib/web/magnifier/magnify.js
+++ b/lib/web/magnifier/magnify.js
@@ -680,8 +680,6 @@ define([
$image.removeClass(imageDraggableClass);
}
} else if (gallery.fullScreen && (!transitionEnabled || !transitionActive)) {
- e.preventDefault();
-
imagePosY = getTop($image);
imagePosX = $image.offset().left;
From 0a3ff4ecead0625da250022d34b7a36e2c7cdb1a Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Wed, 23 Oct 2019 13:17:54 +0300
Subject: [PATCH 0556/1978] MC-20195: Move test MC-13104 to infrastructure
---
.../Catalog/_files/product_simple_with_custom_file_option.php | 2 --
1 file changed, 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
index 0a375a5f25820..1cd36e7f4726f 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_custom_file_option.php
@@ -16,8 +16,6 @@
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\ObjectManager;
-Bootstrap::getInstance()->reinitialize();
-
/** @var ObjectManager $objectManager */
$objectManager = Bootstrap::getObjectManager();
From 07040480b673c09284e47072288d7176aa9e06dc Mon Sep 17 00:00:00 2001
From: Arvinda kumar
Date: Wed, 23 Oct 2019 16:23:48 +0530
Subject: [PATCH 0557/1978] Other PayPal Payment Solutions Title Not design
like other and alignment not proper #25240 issue fixed
Other PayPal Payment Solutions Title Not design like other and alignment not proper #25240 issue fixed
---
app/code/Magento/Paypal/view/adminhtml/web/styles.css | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Paypal/view/adminhtml/web/styles.css b/app/code/Magento/Paypal/view/adminhtml/web/styles.css
index 9d63dbff5f3f9..ee0bb1d0c420b 100644
--- a/app/code/Magento/Paypal/view/adminhtml/web/styles.css
+++ b/app/code/Magento/Paypal/view/adminhtml/web/styles.css
@@ -28,9 +28,9 @@
.paypal-recommended-header > .admin__collapsible-block > a::before {content: "" !important;}
.paypal-other-header > .admin__collapsible-block > a::before {content: '' !important; width: 0; height: 0; border-color: transparent; border-top-color: #000; border-style: solid; border-width: .8rem .5rem 0 .5rem; margin-top:1px; transition: all .2s linear;}
.paypal-other-header > .admin__collapsible-block > a.open::before {border-color: transparent; border-bottom-color: #000; border-width: 0 .5rem .8rem .5rem;}
-.paypal-other-header > .admin__collapsible-block > a {color: #007bdb !important; text-align: right;}
.payments-other-header > .admin__collapsible-block > a,
-.paypal-recommended-header > .admin__collapsible-block > a {display: inline-block;}
+.paypal-recommended-header > .admin__collapsible-block > a,
+.paypal-other-header > .admin__collapsible-block > a {display: inline-block;}
.payments-other-header > .admin__collapsible-block > a::before,
.paypal-recommended-header > .admin__collapsible-block > a::before {content: '' !important; width: 0; height: 0; border-color: transparent; border-top-color: #000; border-style: solid; border-width: .8rem .5rem 0 .5rem; margin-top:1px; transition: all .2s linear;}
.payments-other-header > .admin__collapsible-block > a.open::before,
From 15e9d924698bd6dce988771d2594c7a90f03ddc6 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Wed, 23 Oct 2019 15:06:11 +0300
Subject: [PATCH 0558/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Product/Gallery/UpdateHandlerTest.php | 315 +++++++++++++++++-
1 file changed, 297 insertions(+), 18 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
index 559dd6d1b747d..7e818b4246a92 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
@@ -8,18 +8,24 @@
namespace Magento\Catalog\Model\Product\Gallery;
+use Magento\Catalog\Api\Data\ProductInterface;
+use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\Product;
-use Magento\Framework\Filesystem;
+use Magento\Catalog\Model\Product\Media\Config;
+use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
+use Magento\Catalog\Model\ResourceModel\Product\Gallery;
use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\Filesystem;
+use Magento\Framework\Filesystem\Directory\WriteInterface;
use Magento\Framework\ObjectManagerInterface;
+use Magento\Store\Api\StoreRepositoryInterface;
+use Magento\Store\Model\Store;
use Magento\TestFramework\Helper\Bootstrap;
-use Magento\Framework\Filesystem\Directory\WriteInterface;
/**
- * Test for \Magento\Catalog\Model\Product\Gallery\UpdateHandler.
+ * Provides tests for media gallery images update during product save.
*
- * @magentoDataFixture Magento/Catalog/_files/product_simple.php
- * @magentoDataFixture Magento/Catalog/_files/product_image.php
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
{
@@ -33,15 +39,35 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
*/
private $updateHandler;
+ /**
+ * @var ProductRepositoryInterface
+ */
+ private $productRepository;
+
+ /**
+ * @var StoreRepositoryInterface
+ */
+ private $storeRepository;
+
+ /**
+ * @var Gallery
+ */
+ private $galleryResource;
+
+ /**
+ * @var ProductResource
+ */
+ private $productResource;
+
/**
* @var WriteInterface
*/
private $mediaDirectory;
/**
- * @var Filesystem
+ * @var Config
*/
- private $filesystem;
+ private $config;
/**
* @var string
@@ -54,47 +80,300 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->fileName = 'image.txt';
-
$this->objectManager = Bootstrap::getObjectManager();
$this->updateHandler = $this->objectManager->create(UpdateHandler::class);
- $this->filesystem = $this->objectManager->get(Filesystem::class);
- $this->mediaDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::MEDIA);
+ $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
+ $this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
+ $this->galleryResource = $this->objectManager->create(Gallery::class);
+ $this->productResource = Bootstrap::getObjectManager()->get(ProductResource::class);
+ $this->config = $this->objectManager->get(Config::class);
+ $this->mediaDirectory = $this->objectManager->get(Filesystem::class)
+ ->getDirectoryWrite(DirectoryList::MEDIA);
$this->mediaDirectory->writeFile($this->fileName, 'Test');
}
/**
+ * Tests updating image with illegal filename during product save.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoDataFixture Magento/Catalog/_files/product_image.php
+ *
* @return void
*/
public function testExecuteWithIllegalFilename(): void
{
- $filePath = str_repeat('/..', 2) . DIRECTORY_SEPARATOR . $this->fileName;
-
- /** @var $product Product */
- $product = Bootstrap::getObjectManager()->create(Product::class);
- $product->load(1);
+ $product = $this->getProduct();
$product->setData(
'media_gallery',
[
'images' => [
'image' => [
'value_id' => '100',
- 'file' => $filePath,
+ 'file' => str_repeat('/..', 2) . DIRECTORY_SEPARATOR . $this->fileName,
'label' => 'New image',
'removed' => 1,
],
],
]
);
-
$this->updateHandler->execute($product);
$this->assertFileExists($this->mediaDirectory->getAbsolutePath($this->fileName));
}
/**
+ * Tests updating image label, position and disabling during product save.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testExecuteWithOneImage(): void
+ {
+ $product = $this->getProduct();
+ $this->prepareProductWithOneImage($product, ['label' => 'New image', 'disabled' => '1']);
+ $this->updateHandler->execute($product);
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId(
+ $product,
+ $this->productResource->getAttribute('media_gallery')->getAttributeId()
+ );
+ $updatedImage = reset($productImages);
+ $this->assertEquals('New image', $updatedImage['label']);
+ $this->assertEquals('New image', $updatedImage['label_default']);
+ $this->assertEquals('1', $updatedImage['disabled']);
+ $this->assertEquals('1', $updatedImage['disabled_default']);
+ }
+
+ /**
+ * Tests updating image roles during product save.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @dataProvider executeWithTwoImagesAndRolesDataProvider
+ * @magentoDbIsolation enabled
+ * @param array $roles
+ * @return void
+ */
+ public function testExecuteWithTwoImagesAndDifferentRoles(array $roles): void
+ {
+ $imageRoles = ['image', 'small_image', 'thumbnail', 'swatch_image'];
+ $product = $this->getProduct();
+ foreach ($roles as $role => $value) {
+ $product->setData($role, $value);
+ }
+ $this->updateHandler->execute($product);
+ $productsImageData = $this->productResource->getAttributeRawValue(
+ $product->getId(),
+ $imageRoles,
+ $product->getStoreId()
+ );
+ foreach ($roles as $role => $value) {
+ $this->assertEquals($value, $productsImageData[$role]);
+ }
+ }
+
+ /**
+ * Tests updating image roles during product save on non default store view..
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDataFixture Magento/Store/_files/second_store.php
+ * @dataProvider executeWithTwoImagesAndRolesDataProvider
+ * @magentoDbIsolation enabled
+ * @param array $roles
+ * @return void
+ */
+ public function testExecuteWithTwoImagesAndDifferentRolesOnStoreView(array $roles): void
+ {
+ $secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
+ $imageRoles = ['image', 'small_image', 'thumbnail', 'swatch_image'];
+ $product = $this->getProduct($secondStoreId);
+ foreach ($roles as $role => $value) {
+ $product->setData($role, $value);
+ }
+ $this->updateHandler->execute($product);
+
+ $storeImages = $this->productResource->getAttributeRawValue(
+ $product->getId(),
+ $imageRoles,
+ $secondStoreId
+ );
+ foreach ($roles as $role => $value) {
+ $this->assertEquals($value, $storeImages[$role]);
+ }
+
+ $defaultImages = $this->productResource->getAttributeRawValue(
+ $product->getId(),
+ $imageRoles,
+ Store::DEFAULT_STORE_ID
+ );
+ $this->assertEquals('/m/a/magento_image.jpg', $defaultImages['image']);
+ $this->assertEquals('/m/a/magento_image.jpg', $defaultImages['small_image']);
+ $this->assertEquals('/m/a/magento_thumbnail.jpg', $defaultImages['thumbnail']);
+ $this->assertEquals('/m/a/magento_thumbnail.jpg', $defaultImages['swatch_image']);
+ }
+
+ /**
+ * @return array
+ */
+ public function executeWithTwoImagesAndRolesDataProvider(): array
+ {
+ return [
+ 'unassign_all_roles' => [
+ 'roles' => [
+ 'image' => 'no_selection',
+ 'small_image' =>'no_selection',
+ 'thumbnail' => 'no_selection',
+ 'swatch_image' => 'no_selection',
+ ],
+ ],
+ 'assign_already_used_role' => [
+ 'roles' => [
+ 'image' => '/m/a/magento_image.jpg',
+ 'small_image' => '/m/a/magento_thumbnail.jpg',
+ 'thumbnail' => '/m/a/magento_thumbnail.jpg',
+ 'swatch_image' => '/m/a/magento_image.jpg',
+ ],
+ ],
+ ];
+ }
+
+ /**
+ * Tests updating image position during product save.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testExecuteWithTwoImagesAndChangedPosition(): void
+ {
+ $positionMap = [
+ '/m/a/magento_image.jpg' => '2',
+ '/m/a/magento_thumbnail.jpg' => '1',
+ ];
+ $product = $this->getProduct();
+ $images = $product->getData('media_gallery')['images'];
+ foreach ($images as &$image) {
+ $image['position'] = $positionMap[$image['file']];
+ }
+ $product->setData('store_id', Store::DEFAULT_STORE_ID);
+ $product->setData('media_gallery', ['images' => $images]);
+ $this->updateHandler->execute($product);
+ $galleryAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $galleryAttributeId);
+ foreach ($productImages as $updatedImage) {
+ $this->assertEquals($positionMap[$updatedImage['file']], $updatedImage['position']);
+ $this->assertEquals($positionMap[$updatedImage['file']], $updatedImage['position_default']);
+ }
+ }
+
+ /**
+ * Tests image remove during product save.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_image.php
+ * @magentoDbIsolation enabled
+ * @return void
+ */
+ public function testExecuteWithImageToDelete(): void
+ {
+ $product = $this->getProduct();
+ $this->prepareProductWithOneImage($product, ['removed' => '1']);
+ $this->updateHandler->execute($product);
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId(
+ $product,
+ $this->productResource->getAttribute('media_gallery')->getAttributeId()
+ );
+ $this->assertCount(0, $productImages);
+ $this->assertFileNotExists(
+ $this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . '/m/a/magento_image.jpg')
+ );
+ $defaultImages = $this->productResource->getAttributeRawValue(
+ $product->getId(),
+ ['image', 'small_image', 'thumbnail', 'swatch_image'],
+ Store::DEFAULT_STORE_ID
+ );
+ $this->assertEquals('no_selection', $defaultImages['image']);
+ $this->assertEquals('no_selection', $defaultImages['small_image']);
+ $this->assertEquals('no_selection', $defaultImages['thumbnail']);
+ }
+
+ /**
+ * Tests updating images data during product save on non default store view.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
+ * @magentoDataFixture Magento/Store/_files/second_store.php
+ * @magentoDbIsolation enabled
* @return void
*/
- protected function tearDown(): void
+ public function testExecuteWithTwoImagesOnStoreView(): void
+ {
+ $secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
+ $storeImages = [
+ '/m/a/magento_image.jpg' => [
+ 'label' => 'Store image',
+ 'label_default' => 'Image Alt Text',
+ 'disabled' => '1',
+ 'disabled_default' => '0',
+ 'position' => '2',
+ 'position_default' => '1',
+ ],
+ '/m/a/magento_thumbnail.jpg' => [
+ 'label' => 'Store thumbnail',
+ 'label_default' => 'Thumbnail Image',
+ 'disabled' => '0',
+ 'disabled_default' => '0',
+ 'position' => '1',
+ 'position_default' => '2',
+ ],
+ ];
+ $product = $this->getProduct($secondStoreId);
+ $images = $product->getData('media_gallery')['images'];
+ foreach ($images as &$image) {
+ $image['label'] = $storeImages[$image['file']]['label'];
+ $image['disabled'] = $storeImages[$image['file']]['disabled'];
+ $image['position'] = $storeImages[$image['file']]['position'];
+ }
+ $product->setData('media_gallery', ['images' => $images]);
+ $this->updateHandler->execute($product);
+ $galleryAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $galleryAttributeId);
+ foreach ($productImages as $image) {
+ $this->assertEquals($storeImages[$image['file']]['label'], $image['label']);
+ $this->assertEquals($storeImages[$image['file']]['label_default'], $image['label_default']);
+ $this->assertEquals($storeImages[$image['file']]['disabled'], $image['disabled']);
+ $this->assertEquals($storeImages[$image['file']]['disabled_default'], $image['disabled_default']);
+ $this->assertEquals($storeImages[$image['file']]['position'], $image['position']);
+ $this->assertEquals($storeImages[$image['file']]['position_default'], $image['position_default']);
+ }
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
{
$this->mediaDirectory->getDriver()->deleteFile($this->mediaDirectory->getAbsolutePath($this->fileName));
}
+
+ /**
+ * Returns current product.
+ *
+ * @param array $data
+ * @param int|null $storeId
+ * @return ProductInterface|Product
+ */
+ private function getProduct(?int $storeId = null): ProductInterface
+ {
+ return $this->productRepository->get('simple', false, $storeId, true);
+ }
+
+ /**
+ * @param ProductInterface|Product $product
+ * @param array $imageData
+ * @return void
+ */
+ private function prepareProductWithOneImage(ProductInterface $product, array $imageData): void
+ {
+ $images = $product->getData('media_gallery')['images'];
+ $image = reset($images);
+ $product->setData('store_id', Store::DEFAULT_STORE_ID);
+ $product->setData('media_gallery', ['images' => ['image' => array_merge($image, $imageData)]]);
+ }
}
From 5e059717af8097660daadce7cf1c04e2bcdbaab4 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Wed, 23 Oct 2019 15:19:11 +0300
Subject: [PATCH 0559/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
.../Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index 7cbc706f0286b..f8d9cbcdda24a 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -59,8 +59,8 @@
-
-
+
+
From d0802f05b2807f9e28cd2126fc94274d3a3c7cc5 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Wed, 23 Oct 2019 17:01:49 +0300
Subject: [PATCH 0560/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
index d3e66c0134c4c..e594d90e502b7 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
@@ -35,7 +35,10 @@
-
+
+
+
+
From cabae10b45bf72b175d28056f7b1c114c2e70a09 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Tue, 22 Oct 2019 13:54:10 +0530
Subject: [PATCH 0561/1978] Resovled issue #25137
---
.../web/css/source/module/_minicart.less | 17 +++++++++++----
.../web/css/source/module/_minicart.less | 21 +++++++++++++------
2 files changed, 28 insertions(+), 10 deletions(-)
diff --git a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less
index 65f3eeef63b01..5f69db5acec4b 100644
--- a/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less
+++ b/app/design/frontend/Magento/blank/Magento_Checkout/web/css/source/module/_minicart.less
@@ -110,7 +110,7 @@
@_dropdown-list-position-right: 0,
@_dropdown-list-pointer-position: right,
@_dropdown-list-pointer-position-left-right: 26px,
- @_dropdown-list-z-index: 101,
+ @_dropdown-list-z-index: 101,
@_dropdown-toggle-icon-content: @icon-cart,
@_dropdown-toggle-active-icon-content: @icon-cart,
@_dropdown-list-item-padding: false,
@@ -304,7 +304,7 @@
.weee[data-label] {
.lib-font-size(11);
-
+
.label {
&:extend(.abs-no-display all);
}
@@ -340,7 +340,6 @@
}
.item-qty {
- margin-right: @indent__s;
text-align: center;
width: 45px;
}
@@ -390,6 +389,16 @@
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__s) {
.minicart-wrapper {
margin-top: @indent__s;
+ .lib-clearfix();
+ .product {
+ .actions {
+ float: left;
+ margin: 10px 0 0 0;
+ }
+ }
+ .update-cart-item {
+ float: right;
+ }
}
}
@@ -400,7 +409,7 @@
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.minicart-wrapper {
margin-left: 13px;
-
+
.block-minicart {
right: -15px;
width: 390px;
diff --git a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less
index af94dd7b97bbb..d6cc62c2ddef3 100644
--- a/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less
+++ b/app/design/frontend/Magento/luma/Magento_Checkout/web/css/source/module/_minicart.less
@@ -120,7 +120,7 @@
@_dropdown-list-position-right: -10px,
@_dropdown-list-pointer-position: right,
@_dropdown-list-pointer-position-left-right: 12px,
- @_dropdown-list-z-index: 101,
+ @_dropdown-list-z-index: 101,
@_dropdown-toggle-icon-content: @icon-cart,
@_dropdown-toggle-active-icon-content: @icon-cart,
@_dropdown-list-item-padding: false,
@@ -136,7 +136,7 @@
.block-minicart {
.lib-css(padding, 25px @minicart__padding-horizontal);
-
+
.block-title {
display: none;
}
@@ -233,7 +233,7 @@
.minicart-items {
.lib-list-reset-styles();
-
+
.product-item {
padding: @indent__base 0;
@@ -316,7 +316,7 @@
&:extend(.abs-toggling-title all);
border: 0;
padding: 0 @indent__xl @indent__xs 0;
-
+
&:after {
.lib-css(color, @color-gray56);
margin: 0 0 0 @indent__xs;
@@ -349,7 +349,7 @@
@_icon-font-position: after
);
}
-
+
> span {
&:extend(.abs-visually-hidden-reset all);
}
@@ -369,7 +369,6 @@
}
.item-qty {
- margin-right: @indent__s;
text-align: center;
width: 60px;
}
@@ -419,6 +418,16 @@
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
.minicart-wrapper {
margin-top: @indent__s;
+ .lib-clearfix();
+ .product {
+ .actions {
+ float: left;
+ margin: 10px 0 0 0;
+ }
+ }
+ .update-cart-item {
+ float: right;
+ }
}
}
From 7b345f0be1e059aa48227e945b81de8ac0c6ced8 Mon Sep 17 00:00:00 2001
From: Alex Taranovsky
Date: Wed, 23 Oct 2019 10:52:06 +0300
Subject: [PATCH 0562/1978] magento/graphql-ce#1009: [Test Coverage] Cover
exception in SalesGraphQl\Model\Resolver\Orders
---
.../Magento/GraphQl/Sales/OrdersTest.php | 20 +++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/OrdersTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/OrdersTest.php
index 11a2216b6668f..5d1f5847e8419 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/OrdersTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/OrdersTest.php
@@ -7,6 +7,7 @@
namespace Magento\GraphQl\Sales;
+use Exception;
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\TestFramework\TestCase\GraphQlAbstract;
use Magento\TestFramework\Helper\Bootstrap;
@@ -99,6 +100,25 @@ public function testOrdersQuery()
}
}
+ /**
+ * @expectedException Exception
+ * @expectedExceptionMessage The current customer isn't authorized.
+ */
+ public function testOrdersQueryNotAuthorized()
+ {
+ $query = <<graphQlQuery($query);
+ }
+
/**
* @param string $email
* @param string $password
From 073e5049fcfe3ec1678fe0612f07c78508b5fcff Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 23 Oct 2019 10:31:46 -0500
Subject: [PATCH 0563/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 9465847d21fe1..1657a18b55aaf 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -300,6 +300,7 @@ protected function doReindexByIds($ids)
$rule->setProductsFilter($ids);
$matchingProductIds = $rule->getMatchingProductIds();
+ $matchingProductIds = array_intersect_key($matchingProductIds, array_flip($ids));
foreach ($matchingProductIds as $matchingProductId => $validationByWebsite) {
$websiteIds = array_keys(array_filter($validationByWebsite));
$this->assignProductToRule($rule, $matchingProductId, $websiteIds);
From 68531d9fe93fac5385626bc51e549f61cb57292e Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Wed, 23 Oct 2019 18:37:45 +0300
Subject: [PATCH 0564/1978] MC-20071: Fix Skipped MFTF Tests From MC-17140:
MAGETWO-98211, MC-56, MC-88
---
...AdminMassUpdateProductAttributesGlobalScopeTest.xml | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
index f8d9cbcdda24a..989431941b279 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMassUpdateProductAttributesGlobalScopeTest.xml
@@ -16,11 +16,12 @@
-
-
+
+
+
@@ -36,6 +37,7 @@
+
@@ -70,7 +72,7 @@
-
+
@@ -82,7 +84,7 @@
-
+
From 82a1858dcef0f6f9ea8d29a4283b0b3c6b3837f9 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 23 Oct 2019 10:59:58 -0500
Subject: [PATCH 0565/1978] MC-22006: PayPal Express Checkout button always
display on product page
---
app/code/Magento/Paypal/Model/SmartButtonConfig.php | 2 +-
.../Paypal/Test/Unit/Model/_files/expected_config.php | 10 +++++-----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Paypal/Model/SmartButtonConfig.php b/app/code/Magento/Paypal/Model/SmartButtonConfig.php
index ede9cacf25d40..59e4db6d84201 100644
--- a/app/code/Magento/Paypal/Model/SmartButtonConfig.php
+++ b/app/code/Magento/Paypal/Model/SmartButtonConfig.php
@@ -83,7 +83,7 @@ public function getConfig(string $page): array
'allowedFunding' => $this->getAllowedFunding($page),
'disallowedFunding' => $this->getDisallowedFunding(),
'styles' => $this->getButtonStyles($page),
- 'isVisibleOnProductPage' => $this->config->getValue('visible_on_product'),
+ 'isVisibleOnProductPage' => (bool)$this->config->getValue('visible_on_product'),
'isGuestCheckoutAllowed' => $isGuestCheckoutAllowed
];
}
diff --git a/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php b/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php
index 478607f9956e6..7256984ab5226 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/_files/expected_config.php
@@ -32,7 +32,7 @@
'label' => 'installment',
'installmentperiod' => 0
],
- 'isVisibleOnProductPage' => 0,
+ 'isVisibleOnProductPage' => false,
'isGuestCheckoutAllowed' => true
]
],
@@ -62,7 +62,7 @@
'label' => 'installment',
'installmentperiod' => 0
],
- 'isVisibleOnProductPage' => 0,
+ 'isVisibleOnProductPage' => false,
'isGuestCheckoutAllowed' => true
]
],
@@ -91,7 +91,7 @@
'shape' => 'rect',
'label' => 'paypal'
],
- 'isVisibleOnProductPage' => 0,
+ 'isVisibleOnProductPage' => false,
'isGuestCheckoutAllowed' => true
]
],
@@ -120,7 +120,7 @@
'shape' => 'rect',
'label' => 'paypal'
],
- 'isVisibleOnProductPage' => 0,
+ 'isVisibleOnProductPage' => false,
'isGuestCheckoutAllowed' => true
]
],
@@ -149,7 +149,7 @@
'shape' => 'rect',
'label' => 'paypal',
],
- 'isVisibleOnProductPage' => 0,
+ 'isVisibleOnProductPage' => false,
'isGuestCheckoutAllowed' => true
]
]
From 1b66fb468d52868e2c5708fbc6ec7def4acaffc6 Mon Sep 17 00:00:00 2001
From: Eden
Date: Wed, 23 Oct 2019 23:23:38 +0700
Subject: [PATCH 0566/1978] cover issue 25172 with mftf test
---
.../CatalogPriceRuleActionGroup.xml | 19 +++++++
.../Test/Mftf/Data/CatalogRuleData.xml | 15 ++++++
.../AdminNewCatalogPriceRuleSection.xml | 2 +
.../Test/AdminCreateCatalogPriceRuleTest.xml | 23 ++++++++
.../ui_component/catalog_rule_form.xml | 3 +-
.../Test/Mftf/Data/SalesRuleData.xml | 9 ++++
.../AdminCartPriceRulesFormSection.xml | 2 +
.../Mftf/Test/AdminCreateInvalidRuleTest.xml | 53 +++++++++++++++++++
.../ui_component/sales_rule_form.xml | 3 +-
9 files changed, 125 insertions(+), 4 deletions(-)
create mode 100644 app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml
index 09053b5ad14a3..620f61b9ec27a 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/ActionGroup/CatalogPriceRuleActionGroup.xml
@@ -208,4 +208,23 @@
+
+
+
+ Goes to the Catalog Price Rule grid. Clicks on Add. Fills in the provided Catalog Rule details with invalid data.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml
index 75a7484324576..2920a895f607d 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Data/CatalogRuleData.xml
@@ -173,4 +173,19 @@
Free Shipping in conditions
Free Shipping in conditions
+
+
+ CatalogPriceRule
+ Catalog Price Rule Description
+ 1
+
+ - 0
+
+
+ - 1
+
+ by_percent
+ 10
+ ten
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
index c736dd8dde2cb..61f2e7ac55ef7 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Section/AdminNewCatalogPriceRuleSection.xml
@@ -37,6 +37,8 @@
+
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml
index 09b924603c54a..ee61af180d350 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminCreateCatalogPriceRuleTest.xml
@@ -196,4 +196,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml
index 35fd7d8a192f4..59e3c4668e8a4 100644
--- a/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml
+++ b/app/code/Magento/CatalogRule/view/adminhtml/ui_component/catalog_rule_form.xml
@@ -209,8 +209,7 @@
- true
- true
+ true
text
Priority
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
index c1ec728a6cfb9..8b1f27812b6cd 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
@@ -457,4 +457,13 @@
SalesRuleLabelDefault
SalesRuleLabelStore1
+
+
+ one
+ one
+ one
+ one
+ one
+ one
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
index 3849d153be465..a45baad7f0910 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
@@ -98,5 +98,7 @@
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml
new file mode 100644
index 0000000000000..620112e323ff5
--- /dev/null
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminCreateInvalidRuleTest.xml
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml
index 63faf29afd769..e1c12f45012ee 100644
--- a/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml
+++ b/app/code/Magento/SalesRule/view/adminhtml/ui_component/sales_rule_form.xml
@@ -363,8 +363,7 @@
- true
- true
+ true
text
Priority
From 91f6e2ed30ec1638fd2032747b37adec3bee57cb Mon Sep 17 00:00:00 2001
From: Kieu Phan
Date: Wed, 23 Oct 2019 12:38:19 -0500
Subject: [PATCH 0567/1978] MC-18822: Increase test coverage for Content
functional area Add clear cache and reindex for layer navigation of test
MC-6192
---
.../Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
index 3857f83a71453..37de78abfc45e 100644
--- a/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
+++ b/app/code/Magento/LayeredNavigation/Test/Mftf/Test/AdminCheckResultsOfColorAndOtherFiltersTest.xml
@@ -8,6 +8,8 @@
+
+
From ee8373fa27727abb5139747ea5547a81fa3735ac Mon Sep 17 00:00:00 2001
From: Michal Sz
Date: Wed, 23 Oct 2019 20:04:10 +0200
Subject: [PATCH 0568/1978] Implement catching for all Errors - ref Magento
issue #23350
---
lib/internal/Magento/Framework/App/Bootstrap.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index 717b810cffd29..57b40faabc764 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -269,6 +269,8 @@ public function run(AppInterface $application)
}
} catch (\Exception $e) {
$this->terminate($e);
+ } catch (\Error $e) {
+ $this->terminate($e);
}
} // phpcs:enable
@@ -418,12 +420,12 @@ public function isDeveloperMode()
/**
* Display an exception and terminate program execution
*
- * @param \Exception $e
+ * @param \Throwable $e
* @return void
*
* phpcs:disable Magento2.Security.LanguageConstruct, Squiz.Commenting.FunctionCommentThrowTag
*/
- protected function terminate(\Exception $e)
+ protected function terminate(\Throwable $e)
{
if ($this->isDeveloperMode()) {
From 8e61d9550f7a6282b64bf4c822c2a3d1a6352b94 Mon Sep 17 00:00:00 2001
From: Ievgen Kolesov
Date: Wed, 23 Oct 2019 13:05:58 -0500
Subject: [PATCH 0569/1978] PB-48: The order of product SKU is not respected if
combined with category condition
---
.../Rule/Model/Condition/Sql/Builder.php | 22 ++++++++-----------
.../Rule/Model/Condition/Sql/BuilderTest.php | 11 ++++++++--
2 files changed, 18 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php
index 3e876c2d54333..a0812aeaa9c5e 100644
--- a/app/code/Magento/Rule/Model/Condition/Sql/Builder.php
+++ b/app/code/Magento/Rule/Model/Condition/Sql/Builder.php
@@ -270,26 +270,22 @@ private function buildConditions(AbstractCollection $collection, Combine $combin
$conditions = '';
$attributeField = '';
foreach ($combine->getConditions() as $condition) {
- if ($condition->getData('attribute') === \Magento\Catalog\Api\Data\ProductInterface::SKU) {
+ if ($condition->getData('attribute') === \Magento\Catalog\Api\Data\ProductInterface::SKU
+ && $condition->getData('operator') === '()'
+ ) {
$conditions = $condition->getData('value');
- $attributeField = $condition->getMappedSqlField();
+ $attributeField = $this->_connection->quoteIdentifier($condition->getMappedSqlField());
}
}
if (!empty($conditions) && !empty($attributeField)) {
- $conditions = explode(',', $conditions);
- foreach ($conditions as &$condition) {
- $condition = trim($condition);
- }
- $conditions = implode(', ', $conditions);
+ $conditions = $this->_connection->quote(
+ array_map('trim', explode(',', $conditions))
+ );
$collection->getSelect()->reset(Select::ORDER);
$collection->getSelect()->order(
- $this->_connection->quoteInto(
- "FIELD(?, ?)",
- [
- $attributeField,
- $conditions
- ]
+ $this->_expressionFactory->create(
+ ['expression' => "FIELD($attributeField, $conditions)"]
)
);
}
diff --git a/dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql/BuilderTest.php b/dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql/BuilderTest.php
index 4473d31047d4b..edf456f17fd9c 100644
--- a/dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql/BuilderTest.php
+++ b/dev/tests/integration/testsuite/Magento/Rule/Model/Condition/Sql/BuilderTest.php
@@ -60,13 +60,20 @@ public function testAttachConditionToCollection(): void
'operator' => '==',
'value' => '2017-09-15',
],
+ '1--3' => [
+ 'type' => ProductCondition::class,
+ 'attribute' => 'sku',
+ 'operator' => '()',
+ 'value' => ' :( , :) ',
+ ]
],
];
$rule->loadPost($ruleConditionArray);
$this->model->attachConditionToCollection($collection, $rule->getConditions());
- $whereString = "/\(category_id IN \('3'\).+\(IFNULL\(`e`\.`entity_id`,.+\) = '2017-09-15'\)/";
- $this->assertNotFalse(preg_match($whereString, $collection->getSelectSql(true)));
+ $whereString = "/\(category_id IN \('3'\).+\(IFNULL\(`e`\.`entity_id`,.+\) = '2017-09-15'\)"
+ . ".+ORDER BY \(FIELD\(`e`.`sku`, ':\(', ':\)'\)\)/";
+ $this->assertEquals(1, preg_match($whereString, $collection->getSelectSql(true)));
}
}
From 4de504d4f2fa8c52f3b812a311aba7a36590871d Mon Sep 17 00:00:00 2001
From: eduard13
Date: Wed, 23 Oct 2019 21:15:12 +0300
Subject: [PATCH 0570/1978] Making system configs dependent by Enabled field
---
.../CardinalCommerce/etc/adminhtml/system.xml | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/app/code/Magento/CardinalCommerce/etc/adminhtml/system.xml b/app/code/Magento/CardinalCommerce/etc/adminhtml/system.xml
index 532fcdd0f598f..046475baba676 100644
--- a/app/code/Magento/CardinalCommerce/etc/adminhtml/system.xml
+++ b/app/code/Magento/CardinalCommerce/etc/adminhtml/system.xml
@@ -19,26 +19,41 @@
Environment
Magento\CardinalCommerce\Model\Adminhtml\Source\Environment
three_d_secure/cardinal/environment
+
+ 1
+
Org Unit Id
three_d_secure/cardinal/org_unit_id
Magento\Config\Model\Config\Backend\Encrypted
+
+ 1
+
API Key
three_d_secure/cardinal/api_key
Magento\Config\Model\Config\Backend\Encrypted
+
+ 1
+
API Identifier
three_d_secure/cardinal/api_identifier
Magento\Config\Model\Config\Backend\Encrypted
+
+ 1
+
Debug
Magento\Config\Model\Config\Source\Yesno
three_d_secure/cardinal/debug
+
+ 1
+
From bb25f9a9809cd08573f71adefaf18ddcdeec9197 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 14:07:08 -0500
Subject: [PATCH 0571/1978] magento/graphql-ce#903: [Checkout] Replace
use_for_shipping with same_as_shipping
---
.../Model/Cart/SetBillingAddressOnCart.php | 7 ++-
.../Customer/SetBillingAddressOnCartTest.php | 60 +------------------
.../Guest/SetBillingAddressOnCartTest.php | 60 +------------------
3 files changed, 9 insertions(+), 118 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 0d937cc64a857..7c8126194777f 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -65,10 +65,11 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
{
$customerAddressId = $billingAddressInput['customer_address_id'] ?? null;
$addressInput = $billingAddressInput['address'] ?? null;
- $sameAsShipping = isset($billingAddressInput['same_as_shipping'])
- ? (bool)$billingAddressInput['same_as_shipping'] : false;
+ // Need to keep this for BC of `use_for_shipping` field
$sameAsShipping = isset($billingAddressInput['use_for_shipping'])
- ? (bool)$billingAddressInput['use_for_shipping'] : $sameAsShipping;
+ ? (bool)$billingAddressInput['use_for_shipping'] : false;
+ $sameAsShipping = isset($billingAddressInput['same_as_shipping'])
+ ? (bool)$billingAddressInput['same_as_shipping'] : $sameAsShipping;
if (null === $customerAddressId && null === $addressInput) {
throw new GraphQlInputException(
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 65497a993da6a..065354114b301 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -86,64 +86,6 @@ public function testSetNewBillingAddress()
$query = <<graphQlMutation($query, [], '', $this->getHeaderMap());
-
- self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
- $cartResponse = $response['setBillingAddressOnCart']['cart'];
- self::assertArrayHasKey('billing_address', $cartResponse);
- $billingAddressResponse = $cartResponse['billing_address'];
- $this->assertNewAddressFields($billingAddressResponse);
- }
-
- /**
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
- * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
- */
- public function testSetNewBillingAddressWithSameAsShippingParameter()
- {
- $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
-
- $query = <<graphQlMutation($query);
-
- self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
- $cartResponse = $response['setBillingAddressOnCart']['cart'];
- self::assertArrayHasKey('billing_address', $cartResponse);
- $billingAddressResponse = $cartResponse['billing_address'];
- $this->assertNewAddressFields($billingAddressResponse);
- }
-
- /**
- * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
- */
- public function testSetNewBillingAddressWithSameAsShippingParameter()
- {
- $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
-
- $query = <<assertNewAddressFields($billingAddressResponse);
self::assertArrayHasKey('shipping_addresses', $cartResponse);
$shippingAddressResponse = current($cartResponse['shipping_addresses']);
$this->assertNewAddressFields($billingAddressResponse);
@@ -160,6 +104,8 @@ public function testSetNewBillingAddressWithSameAsShippingParameter()
}
/**
+ * Test case for deprecated `use_for_shipping` param.
+ *
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
From 795931f1bb0ca75389a974710d4dfff37561af00 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 14:14:48 -0500
Subject: [PATCH 0572/1978] magento/graphql-ce#890: [Checkout] Replace usage of
CartItemQuantity with CartItemInterface
---
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index cd72e90344c6f..494af6c633efa 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -228,9 +228,9 @@ type BillingCartAddress implements CartAddressInterface {
customer_notes: String @deprecated (reason: "The field is used only in shipping address")
}
-type CartItemQuantity @deprecated(reason: "All fields in CartItemQuantity should be deprecated (so this type can be completely removed in the future releases)") {
- cart_item_id: Int!
- quantity: Float!
+type CartItemQuantity @doc(description:"Deprecated: `cart_items` field of `ShippingCartAddress` returns now `CartItemInterface` instead of `CartItemQuantity`") {
+ cart_item_id: Int! @deprecated(reason: "`cart_items` field of `ShippingCartAddress` returns now `CartItemInterface` instead of `CartItemQuantity`")
+ quantity: Float! @deprecated(reason: "`cart_items` field of `ShippingCartAddress` returns now `CartItemInterface` instead of `CartItemQuantity`")
}
type CartAddressRegion {
From 02ce71f3e46571d7b1369b3edae0b34106206c28 Mon Sep 17 00:00:00 2001
From: Soumya Unnikrishnan
Date: Wed, 23 Oct 2019 14:16:13 -0500
Subject: [PATCH 0573/1978] MQE-1836: Bump MFTF version in Magento - 2.5.2
---
composer.json | 2 +-
composer.lock | 27 ++++++++++++++-------------
2 files changed, 15 insertions(+), 14 deletions(-)
diff --git a/composer.json b/composer.json
index 34dd9aa5a50e9..8229cb93b8c11 100644
--- a/composer.json
+++ b/composer.json
@@ -87,7 +87,7 @@
"friendsofphp/php-cs-fixer": "~2.14.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "~4.0.0",
- "magento/magento2-functional-testing-framework": "2.5.0",
+ "magento/magento2-functional-testing-framework": "2.5.2",
"pdepend/pdepend": "2.5.2",
"phpmd/phpmd": "@stable",
"phpunit/phpunit": "~6.5.0",
diff --git a/composer.lock b/composer.lock
index a53d81ec69346..08e9e7b3560df 100644
--- a/composer.lock
+++ b/composer.lock
@@ -1,10 +1,10 @@
{
"_readme": [
"This file locks the dependencies of your project to a known state",
- "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
+ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "86a1369b80e7beabe9ea3dcb38b89ca4",
+ "content-hash": "ac243d11cd92b4d01c2e2c7407808c61",
"packages": [
{
"name": "braintree/braintree_php",
@@ -7135,21 +7135,22 @@
},
{
"name": "magento/magento2-functional-testing-framework",
- "version": "2.5.0",
+ "version": "2.5.2",
"source": {
"type": "git",
"url": "https://github.com/magento/magento2-functional-testing-framework.git",
- "reference": "5aa379674def88d1efc180d936dae1e4654c238a"
+ "reference": "e254e738b3a3fa2eceec9be0590c2aad0e689640"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/magento/magento2-functional-testing-framework/zipball/5aa379674def88d1efc180d936dae1e4654c238a",
- "reference": "5aa379674def88d1efc180d936dae1e4654c238a",
+ "url": "https://api.github.com/repos/magento/magento2-functional-testing-framework/zipball/e254e738b3a3fa2eceec9be0590c2aad0e689640",
+ "reference": "e254e738b3a3fa2eceec9be0590c2aad0e689640",
"shasum": ""
},
"require": {
"allure-framework/allure-codeception": "~1.3.0",
"codeception/codeception": "~2.3.4 || ~2.4.0 ",
+ "composer/composer": "^1.4",
"consolidation/robo": "^1.0.0",
"csharpru/vault-php": "~3.5.3",
"csharpru/vault-php-guzzle6-transport": "^2.0",
@@ -7208,7 +7209,7 @@
"magento",
"testing"
],
- "time": "2019-09-18T14:52:11+00:00"
+ "time": "2019-10-23T14:50:28+00:00"
},
{
"name": "mikey179/vfsstream",
@@ -7782,20 +7783,20 @@
"authors": [
{
"name": "Manuel Pichler",
- "role": "Project Founder",
"email": "github@manuel-pichler.de",
- "homepage": "https://github.com/manuelpichler"
+ "homepage": "https://github.com/manuelpichler",
+ "role": "Project Founder"
},
{
"name": "Marc Würth",
- "role": "Project Maintainer",
"email": "ravage@bluewin.ch",
- "homepage": "https://github.com/ravage84"
+ "homepage": "https://github.com/ravage84",
+ "role": "Project Maintainer"
},
{
"name": "Other contributors",
- "role": "Contributors",
- "homepage": "https://github.com/phpmd/phpmd/graphs/contributors"
+ "homepage": "https://github.com/phpmd/phpmd/graphs/contributors",
+ "role": "Contributors"
}
],
"description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.",
From 87e72e92b58c2dd8f29faf3d7daab9caa62d9dea Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 23 Oct 2019 14:41:16 -0500
Subject: [PATCH 0574/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../CatalogRule/Model/Indexer/IndexBuilder.php | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 1657a18b55aaf..9e93e3f93f5ef 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -298,12 +298,11 @@ protected function doReindexByIds($ids)
continue;
}
- $rule->setProductsFilter($ids);
- $matchingProductIds = $rule->getMatchingProductIds();
- $matchingProductIds = array_intersect_key($matchingProductIds, array_flip($ids));
- foreach ($matchingProductIds as $matchingProductId => $validationByWebsite) {
- $websiteIds = array_keys(array_filter($validationByWebsite));
- $this->assignProductToRule($rule, $matchingProductId, $websiteIds);
+ foreach ($ids as $productId) {
+ $rule->setProductsFilter([$productId]);
+ if ($rule->getMatchingProductIds()) {
+ $this->assignProductToRule($rule, $productId, $ruleWebsiteIds);
+ }
}
}
From 8b51315687fe2891ed731ef821c0719a6d995765 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 15:50:26 -0500
Subject: [PATCH 0575/1978] magento/graphql-ce#890: [Checkout] Replace usage of
CartItemQuantity with CartItemInterface
---
.../QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php | 9 ++++++---
.../Quote/Guest/GetAvailableShippingMethodsTest.php | 5 ++++-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php
index 27dd1959cb5d7..86e00bfe42c81 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php
@@ -68,10 +68,13 @@ public function execute(QuoteAddress $address): array
} else {
$itemId = $addressItem->getQuoteItemId();
}
-
+ $productData = $addressItem->getProduct()->getData();
+ $productData['model'] = $addressItem->getProduct();
$addressItemsData[] = [
- 'cart_item_id' => $itemId,
- 'quantity' => $addressItem->getQty()
+ 'id' => $itemId,
+ 'quantity' => $addressItem->getQty(),
+ 'product' => $productData,
+ 'model' => $addressItem,
];
}
$addressData['cart_items'] = $addressItemsData;
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
index 0d64d73965d2b..f076c0aaa4678 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
@@ -137,8 +137,11 @@ private function getQuery(string $maskedQuoteId): string
cart (cart_id: "{$maskedQuoteId}") {
shipping_addresses {
cart_items {
- cart_item_id
+ id
quantity
+ product {
+ sku
+ }
}
available_shipping_methods {
amount {
From 42bb373cc1d70f2360e46dd564fe01dd4b0f34d4 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Wed, 23 Oct 2019 16:13:45 -0500
Subject: [PATCH 0576/1978] MC-21811: Canonical_url displays the backend domain
instead of relative
- added test
---
.../Catalog/ProductCanonicalUrlTest.php | 80 +++++++++++++++++++
1 file changed, 80 insertions(+)
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php
new file mode 100644
index 0000000000000..9f857121d1fae
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php
@@ -0,0 +1,80 @@
+graphQlQuery($query);
+
+ $this->assertEquals(
+ $response['products']['items'][0]['canonical_url'],
+ 'simple-product.html'
+ );
+ $this->assertEquals($response['products']['items'][0]['sku'], 'simple');
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoConfigFixture default_store catalog/seo/product_canonical_tag 0
+ */
+ public function testProductWithCanonicalLinksMetaTagSettingsDisabled()
+ {
+ $productSku = 'simple';
+ $query
+ = <<graphQlQuery($query);
+ $this->assertNull(
+ $response['products']['items'][0]['canonical_url']
+ );
+ $this->assertEquals($response['products']['items'][0]['sku'], 'simple');
+ }
+}
From e9a701f758de3e5449933567eee62b26a7639e1e Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 16:21:31 -0500
Subject: [PATCH 0577/1978] magento/graphql-ce#961:
ShippingAddressInput.postcode: String, is not required by Schema
---
.../Model/Cart/SetBillingAddressOnCart.php | 10 ++++-
.../Model/Cart/SetShippingAddressesOnCart.php | 42 +++----------------
.../Customer/SetBillingAddressOnCartTest.php | 16 +++++++
3 files changed, 29 insertions(+), 39 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index 3a8d4e06d8aab..a264c9bbc91ec 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -129,9 +129,15 @@ private function createBillingAddress(
(int)$context->getUserId()
);
}
+ $errors = $billingAddress->validate();
-
- $this->validateAddress($billingAddress);
+ if (true !== $errors) {
+ $e = new GraphQlInputException(__('Billing address errors'));
+ foreach ($errors as $error){
+ $e->addError(new GraphQlInputException($error));
+ }
+ throw $e;
+ }
return $billingAddress;
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
index a8820d8a70688..07964a70ecaf7 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
@@ -53,46 +53,14 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
$shippingAddress = $this->getShippingAddress->execute($context, $shippingAddressInput);
- $this->validateAddress($shippingAddress);
-
- $this->assignShippingAddressToCart->execute($cart, $shippingAddress);
- }
-
- /**
- * Validate quote address.
- *
- * @param Address $shippingAddress
- *
- * @throws GraphQlInputException
- */
- private function validateAddress(Address $shippingAddress)
- {
$errors = $shippingAddress->validate();
if (true !== $errors) {
- throw new GraphQlInputException(
- __('Shipping address error: %message', ['message' => $this->getAddressErrors($errors)])
- );
+ $e = new GraphQlInputException(__('Shipping address error'));
+ foreach ($errors as $error){
+ $e->addError(new GraphQlInputException($error));
+ }
+ throw $e;
}
}
-
- /**
- * Collecting errors.
- *
- * @param array $errors
- * @return string
- *
- * @todo change implementation in https://github.com/magento/graphql-ce/issues/970.
- */
- private function getAddressErrors(array $errors): string
- {
- $errorMessages = [];
-
- /** @var \Magento\Framework\Phrase $error */
- foreach ($errors as $error) {
- $errorMessages[] = $error->render();
- }
-
- return implode(PHP_EOL, $errorMessages);
- }
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index ff75a4fa828ca..cca126e25896e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -658,6 +658,22 @@ public function dataProviderSetWithoutRequiredParameters(): array
}',
'"regionId" is required. Enter and try again.'
],
+ 'missed_multiple_fields' => [
+ 'cart_id: "cart_id_value"
+ billing_address: {
+ address: {
+ firstname: "test firstname"
+ lastname: "test lastname"
+ company: "test company"
+ street: ["test street 1", "test street 2"]
+ city: "test city"
+ country_code: "US"
+ telephone: "88776655"
+ }
+ }',
+ '"postcode" is required. Enter and try again.
+"regionId" is required. Enter and try again.'
+ ]
];
}
From 344648f002ecbd5ced22680e445ce4dfa82d3637 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 16:43:07 -0500
Subject: [PATCH 0578/1978] magento/graphql-ce#890: [Checkout] Replace usage of
CartItemQuantity with CartItemInterface
---
.../QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php | 9 +++++----
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 3 ++-
.../Quote/Guest/GetAvailableShippingMethodsTest.php | 7 +++++++
3 files changed, 14 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php
index 86e00bfe42c81..468ef4b8f879c 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/ExtractQuoteAddressData.php
@@ -61,7 +61,6 @@ public function execute(QuoteAddress $address): array
return $addressData;
}
- $addressItemsData = [];
foreach ($address->getAllItems() as $addressItem) {
if ($addressItem instanceof \Magento\Quote\Model\Quote\Item) {
$itemId = $addressItem->getItemId();
@@ -70,15 +69,17 @@ public function execute(QuoteAddress $address): array
}
$productData = $addressItem->getProduct()->getData();
$productData['model'] = $addressItem->getProduct();
- $addressItemsData[] = [
+ $addressData['cart_items'][] = [
+ 'cart_item_id' => $itemId,
+ 'quantity' => $addressItem->getQty()
+ ];
+ $addressData['cart_items_v2'][] = [
'id' => $itemId,
'quantity' => $addressItem->getQty(),
'product' => $productData,
'model' => $addressItem,
];
}
- $addressData['cart_items'] = $addressItemsData;
-
return $addressData;
}
}
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index 7074be249fbca..afdb08ebab915 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -221,7 +221,8 @@ type ShippingCartAddress implements CartAddressInterface {
selected_shipping_method: SelectedShippingMethod @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\ShippingAddress\\SelectedShippingMethod")
customer_notes: String
items_weight: Float @deprecated(reason: "This information shoud not be exposed on frontend")
- cart_items: [CartItemInterface]
+ cart_items: [CartItemQuantity] @deprecated(reason: "`cart_items_v2` should be used instead")
+ cart_items_v2: [CartItemInterface]
}
type BillingCartAddress implements CartAddressInterface {
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
index f076c0aaa4678..1d477666d3d8b 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
@@ -73,6 +73,9 @@ public function testGetAvailableShippingMethods()
$expectedAddressData,
$response['cart']['shipping_addresses'][0]['available_shipping_methods'][0]
);
+ self::assertCount(1, $response['cart']['shipping_addresses'][0]['cart_items']);
+ self::assertCount(1, $response['cart']['shipping_addresses'][0]['cart_items_v2']);
+ self::assertEquals('simple_product', $response['cart']['shipping_addresses'][0]['cart_items_v2'][0]['product']['sku']);
}
/**
@@ -137,6 +140,10 @@ private function getQuery(string $maskedQuoteId): string
cart (cart_id: "{$maskedQuoteId}") {
shipping_addresses {
cart_items {
+ cart_item_id
+ quantity
+ }
+ cart_items_v2 {
id
quantity
product {
From 9ced73c76cd168ddbd7c138efa29996e7b6443e2 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 16:47:44 -0500
Subject: [PATCH 0579/1978] magento/graphql-ce#961:
ShippingAddressInput.postcode: String, is not required by Schema
---
.../QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php | 2 +-
.../QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
index a264c9bbc91ec..e70ce5a106661 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetBillingAddressOnCart.php
@@ -133,7 +133,7 @@ private function createBillingAddress(
if (true !== $errors) {
$e = new GraphQlInputException(__('Billing address errors'));
- foreach ($errors as $error){
+ foreach ($errors as $error) {
$e->addError(new GraphQlInputException($error));
}
throw $e;
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
index 07964a70ecaf7..2c24acbdf63e6 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
@@ -56,8 +56,8 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
$errors = $shippingAddress->validate();
if (true !== $errors) {
- $e = new GraphQlInputException(__('Shipping address error'));
- foreach ($errors as $error){
+ $e = new GraphQlInputException(__('Shipping address errors'));
+ foreach ($errors as $error) {
$e->addError(new GraphQlInputException($error));
}
throw $e;
From b9f708bc25f4cb389bdb3e109e01a543d4179a85 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Wed, 23 Oct 2019 17:03:37 -0500
Subject: [PATCH 0580/1978] magento/graphql-ce#890: [Checkout] Replace usage of
CartItemQuantity with CartItemInterface
---
.../GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
index 1d477666d3d8b..867aaab7b3a58 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetAvailableShippingMethodsTest.php
@@ -75,7 +75,10 @@ public function testGetAvailableShippingMethods()
);
self::assertCount(1, $response['cart']['shipping_addresses'][0]['cart_items']);
self::assertCount(1, $response['cart']['shipping_addresses'][0]['cart_items_v2']);
- self::assertEquals('simple_product', $response['cart']['shipping_addresses'][0]['cart_items_v2'][0]['product']['sku']);
+ self::assertEquals(
+ 'simple_product',
+ $response['cart']['shipping_addresses'][0]['cart_items_v2'][0]['product']['sku']
+ );
}
/**
From 9735ea812194dba04e8cd75757c418c6ef4c515f Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Wed, 23 Oct 2019 17:36:45 -0500
Subject: [PATCH 0581/1978] MC-21811: Canonical_url displays the backend domain
instead of relative
- return canonical url without the domain and path
---
.../CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
index 9047eaee4b568..9616c54676bbe 100644
--- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
+++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
@@ -34,8 +34,8 @@ public function resolve(
/* @var $product Product */
$product = $value['model'];
- $url = $product->getUrlModel()->getUrl($product, ['_ignore_category' => true]);
+ $product->getUrlModel()->getUrl($product, ['_ignore_category' => true]);
- return $url;
+ return $product->getRequestPath();
}
}
From 0ccc1eeff89965ec15eaf4d72f06613c2eb506e8 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Wed, 23 Oct 2019 17:40:19 -0500
Subject: [PATCH 0582/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 25 ++++++++++---------
1 file changed, 13 insertions(+), 12 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 9e93e3f93f5ef..fe5e6c7f24c4d 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -292,25 +292,26 @@ protected function doReindexByIds($ids)
/** @var Rule[] $activeRules */
$activeRules = $this->getActiveRules()->getItems();
- foreach ($activeRules as $rule) {
- $ruleWebsiteIds = $rule->getWebsiteIds();
- if (!$rule->getIsActive() || empty($ruleWebsiteIds)) {
- continue;
- }
+ foreach ($ids as $productId) {
+ foreach ($activeRules as $activeRule) {
+ $rule = clone $activeRule;
+ $rule->setProductsFilter($productId);
+ $matchedProductIds = $rule->getMatchingProductIds();
+ if (!isset($matchedProductIds[$productId])) {
+ continue;
+ }
- foreach ($ids as $productId) {
- $rule->setProductsFilter([$productId]);
- if ($rule->getMatchingProductIds()) {
- $this->assignProductToRule($rule, $productId, $ruleWebsiteIds);
+ $websiteIds = array_keys(array_filter($matchedProductIds[$productId]));
+ if (empty($websiteIds)) {
+ continue;
}
+
+ $this->assignProductToRule($rule, $productId, $websiteIds);
}
- }
- foreach ($ids as $productId) {
$this->cleanProductPriceIndex([$productId]);
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
-
$this->reindexRuleGroupWebsite->execute();
}
From a1d73709c6dd75bf6d41be4992318cc931a72099 Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Wed, 23 Oct 2019 18:38:59 -0500
Subject: [PATCH 0583/1978] MC-16108: EAV attribute is not cached
- Add customer, custom address, catalog category eav attributes to cache;
---
app/code/Magento/Catalog/Model/Config.php | 6 +-
app/code/Magento/Catalog/etc/di.xml | 124 ++++++++++++++++++----
app/code/Magento/Customer/etc/di.xml | 51 +++++++++
app/code/Magento/Eav/Model/Config.php | 14 +--
4 files changed, 164 insertions(+), 31 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php
index 330416a4767d9..2c06766800c5f 100644
--- a/app/code/Magento/Catalog/Model/Config.php
+++ b/app/code/Magento/Catalog/Model/Config.php
@@ -133,7 +133,7 @@ class Config extends \Magento\Eav\Model\Config
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Config $eavConfig
* @param SerializerInterface $serializer
- * @param array $data
+ * @param array $systemAttributes
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -151,7 +151,7 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Eav\Model\Config $eavConfig,
SerializerInterface $serializer = null,
- $data = []
+ $systemAttributes = []
) {
$this->_scopeConfig = $scopeConfig;
$this->_configFactory = $configFactory;
@@ -168,7 +168,7 @@ public function __construct(
$cacheState,
$universalFactory,
$serializer,
- $data
+ $systemAttributes
);
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index e58485ef42636..5c5f655ad73d9 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1178,35 +1178,115 @@
-
- - catalog_product
- - catalog_product
- - catalog_product
+
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
- catalog_product
- catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
- catalog_product
- - catalog_product
- catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml
index 6086a61157ddc..3bb8d3fb3f41a 100644
--- a/app/code/Magento/Customer/etc/di.xml
+++ b/app/code/Magento/Customer/etc/di.xml
@@ -473,4 +473,55 @@
+
+
+
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+
+
+
diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php
index 2a0effb4e3593..b01bd7d2b25e4 100644
--- a/app/code/Magento/Eav/Model/Config.php
+++ b/app/code/Magento/Eav/Model/Config.php
@@ -138,7 +138,7 @@ class Config
*
* @var array
*/
- private $data;
+ private $systemAttributes;
/**
* @param \Magento\Framework\App\CacheInterface $cache
@@ -147,7 +147,7 @@ class Config
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
* @param SerializerInterface $serializer
- * @param array $data
+ * @param array $systemAttributes
* @codeCoverageIgnore
*/
public function __construct(
@@ -157,7 +157,7 @@ public function __construct(
\Magento\Framework\App\Cache\StateInterface $cacheState,
\Magento\Framework\Validator\UniversalFactory $universalFactory,
SerializerInterface $serializer = null,
- $data = []
+ $systemAttributes = []
) {
$this->_cache = $cache;
$this->_entityTypeFactory = $entityTypeFactory;
@@ -165,7 +165,7 @@ public function __construct(
$this->_cacheState = $cacheState;
$this->_universalFactory = $universalFactory;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
- $this->data = $data;
+ $this->systemAttributes = $systemAttributes;
}
/**
@@ -527,8 +527,10 @@ public function getAttribute($entityType, $code)
return $this->attributes[$entityTypeCode][$code];
}
- if (array_key_exists($code, $this->data) && in_array($entityTypeCode, array_values($this->data), true)) {
- $this->initSystemAttributes($entityType, $this->data);
+ if (array_key_exists($code, $this->systemAttributes)
+ && in_array($entityTypeCode, array_values($this->systemAttributes), true)
+ ) {
+ $this->initSystemAttributes($entityType, $this->systemAttributes);
}
if (isset($this->attributes[$entityTypeCode][$code])) {
\Magento\Framework\Profiler::stop('EAV: ' . __METHOD__);
From eec82d3ef1c2855c696b5d5222d962db3a0051ab Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Wed, 23 Oct 2019 19:36:45 -0500
Subject: [PATCH 0584/1978] MC-18685: Remove custom layout updates from admin
---
.../Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml | 3 ++-
.../testsuite/Magento/Cms/Model/PageRepositoryTest.php | 4 ++--
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml
index 755bb92c897ea..33dff8aefa334 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchByPriceToTest.xml
@@ -27,7 +27,8 @@
-
+
+
diff --git a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
index 145830ab08259..5e7e0c962fcde 100644
--- a/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
+++ b/dev/tests/integration/testsuite/Magento/Cms/Model/PageRepositoryTest.php
@@ -54,7 +54,7 @@ public function testSaveUpdateXml(): void
$page = $this->repo->save($page);
//New value is not accepted.
- $page->setCustomLayoutUpdateXml($page->getCustomLayoutUpdateXml() .'TEST');
+ $page->setCustomLayoutUpdateXml(' ');
$forbidden = false;
try {
$page = $this->repo->save($page);
@@ -64,7 +64,7 @@ public function testSaveUpdateXml(): void
$this->assertTrue($forbidden);
//New value is not accepted.
- $page->setLayoutUpdateXml($page->getLayoutUpdateXml() .'TEST');
+ $page->setLayoutUpdateXml(' ');
$forbidden = false;
try {
$page = $this->repo->save($page);
From 9313854cd63a8882989ed6f6064dc1b0b9074334 Mon Sep 17 00:00:00 2001
From: Eden
Date: Thu, 24 Oct 2019 12:13:59 +0700
Subject: [PATCH 0585/1978] Resolve "Disable Automatic Group Change Based on
VAT ID" in "New Customer" form at Backend is not respect Setting "Default
Value for Disable Automatic Group Changes Based on VAT ID"
---
...AdminCustomerAccountInformationSection.xml | 1 +
...DefaultValueDisableAutoGroupChangeTest.xml | 70 +++++++++++++++++++
.../Form/Field/DisableAutoGroupChange.php | 70 +++++++++++++++++++
.../view/base/ui_component/customer_form.xml | 2 +-
4 files changed, 142 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml
create mode 100644 app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml
index 4b36486f0bd17..2c9e66c15bbab 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml
@@ -17,6 +17,7 @@
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml
new file mode 100644
index 0000000000000..ec1c38224602b
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1
+ grabDisableAutomaticGroupChange
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+ grabDisableAutomaticGroupChange
+
+
+
diff --git a/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php b/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php
new file mode 100644
index 0000000000000..55d6d8cb20b6b
--- /dev/null
+++ b/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php
@@ -0,0 +1,70 @@
+addressHelper = $addressHelper;
+ parent::__construct($context, $uiComponentFactory, $components, $data);
+ }
+
+ /**
+ * Prepare component configuration
+ *
+ * @return void
+ * @throws \Magento\Framework\Exception\LocalizedException
+ */
+ public function prepare()
+ {
+ parent::prepare();
+
+ if ($this->addressHelper->isDisableAutoGroupAssignDefaultValue()) {
+ $currentConfig = $this->getData('config');
+ $currentConfig['default'] = self::DISABLE_AUTO_GROUP_CHANGE_YES;
+ $this->setData('config', $currentConfig);
+ }
+ }
+}
diff --git a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml
index 954b44ec19bbb..14e5abec58b08 100644
--- a/app/code/Magento/Customer/view/base/ui_component/customer_form.xml
+++ b/app/code/Magento/Customer/view/base/ui_component/customer_form.xml
@@ -169,7 +169,7 @@
number
-
+
-
- group_id
From 5c054e111d7ec9ccfe1a4cba6c89905a53dc8efb Mon Sep 17 00:00:00 2001
From: Michal Sz
Date: Thu, 24 Oct 2019 07:46:13 +0200
Subject: [PATCH 0586/1978] Unifying the catch statement - ref Magento issue
#23350
---
lib/internal/Magento/Framework/App/Bootstrap.php | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/lib/internal/Magento/Framework/App/Bootstrap.php b/lib/internal/Magento/Framework/App/Bootstrap.php
index 57b40faabc764..d3290f8518b6e 100644
--- a/lib/internal/Magento/Framework/App/Bootstrap.php
+++ b/lib/internal/Magento/Framework/App/Bootstrap.php
@@ -267,11 +267,10 @@ public function run(AppInterface $application)
throw $e;
}
}
- } catch (\Exception $e) {
- $this->terminate($e);
- } catch (\Error $e) {
+ } catch (\Throwable $e) {
$this->terminate($e);
}
+
} // phpcs:enable
/**
From d304f8185c2cf40b7d110cabb313a5d111a9a27a Mon Sep 17 00:00:00 2001
From: Eden
Date: Thu, 24 Oct 2019 13:04:44 +0700
Subject: [PATCH 0587/1978] Fix automation test Magento Health Index
---
.../Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php b/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php
index 55d6d8cb20b6b..3404a0e92230c 100644
--- a/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php
+++ b/app/code/Magento/Customer/Ui/Component/Form/Field/DisableAutoGroupChange.php
@@ -29,7 +29,7 @@ class DisableAutoGroupChange extends \Magento\Ui\Component\Form\Field
*
* @var AddressHelper
*/
- protected $addressHelper;
+ private $addressHelper;
/**
* Constructor
From 9f55a6f13aa0cd466fdaa028ad794f0a1c20784e Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 24 Oct 2019 09:09:50 +0300
Subject: [PATCH 0588/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Product/Gallery/UpdateHandlerTest.php | 36 ++++++++-----------
1 file changed, 15 insertions(+), 21 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
index 7e818b4246a92..af6b066b6481a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
@@ -85,7 +85,7 @@ protected function setUp()
$this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
$this->galleryResource = $this->objectManager->create(Gallery::class);
- $this->productResource = Bootstrap::getObjectManager()->get(ProductResource::class);
+ $this->productResource = $this->objectManager->create(ProductResource::class);
$this->config = $this->objectManager->get(Config::class);
$this->mediaDirectory = $this->objectManager->get(Filesystem::class)
->getDirectoryWrite(DirectoryList::MEDIA);
@@ -156,22 +156,18 @@ public function testExecuteWithTwoImagesAndDifferentRoles(array $roles): void
{
$imageRoles = ['image', 'small_image', 'thumbnail', 'swatch_image'];
$product = $this->getProduct();
- foreach ($roles as $role => $value) {
- $product->setData($role, $value);
- }
+ $product->addData($roles);
$this->updateHandler->execute($product);
$productsImageData = $this->productResource->getAttributeRawValue(
$product->getId(),
$imageRoles,
$product->getStoreId()
);
- foreach ($roles as $role => $value) {
- $this->assertEquals($value, $productsImageData[$role]);
- }
+ $this->assertEquals($roles, $productsImageData);
}
/**
- * Tests updating image roles during product save on non default store view..
+ * Tests updating image roles during product save on non default store view.
*
* @magentoDataFixture Magento/Catalog/_files/product_with_multiple_images.php
* @magentoDataFixture Magento/Store/_files/second_store.php
@@ -185,9 +181,7 @@ public function testExecuteWithTwoImagesAndDifferentRolesOnStoreView(array $role
$secondStoreId = (int)$this->storeRepository->get('fixture_second_store')->getId();
$imageRoles = ['image', 'small_image', 'thumbnail', 'swatch_image'];
$product = $this->getProduct($secondStoreId);
- foreach ($roles as $role => $value) {
- $product->setData($role, $value);
- }
+ $product->addData($roles);
$this->updateHandler->execute($product);
$storeImages = $this->productResource->getAttributeRawValue(
@@ -195,9 +189,7 @@ public function testExecuteWithTwoImagesAndDifferentRolesOnStoreView(array $role
$imageRoles,
$secondStoreId
);
- foreach ($roles as $role => $value) {
- $this->assertEquals($value, $storeImages[$role]);
- }
+ $this->assertEquals($roles, $storeImages);
$defaultImages = $this->productResource->getAttributeRawValue(
$product->getId(),
@@ -335,12 +327,15 @@ public function testExecuteWithTwoImagesOnStoreView(): void
$galleryAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
$productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $galleryAttributeId);
foreach ($productImages as $image) {
- $this->assertEquals($storeImages[$image['file']]['label'], $image['label']);
- $this->assertEquals($storeImages[$image['file']]['label_default'], $image['label_default']);
- $this->assertEquals($storeImages[$image['file']]['disabled'], $image['disabled']);
- $this->assertEquals($storeImages[$image['file']]['disabled_default'], $image['disabled_default']);
- $this->assertEquals($storeImages[$image['file']]['position'], $image['position']);
- $this->assertEquals($storeImages[$image['file']]['position_default'], $image['position_default']);
+ $imageToAssert = [
+ 'label' => $image['label'],
+ 'label_default' =>$image['label_default'],
+ 'disabled' =>$image['disabled'],
+ 'disabled_default' => $image['disabled_default'],
+ 'position' => $image['position'],
+ 'position_default' => $image['position_default'],
+ ];
+ $this->assertEquals($storeImages[$image['file']], $imageToAssert);
}
}
@@ -355,7 +350,6 @@ protected function tearDown()
/**
* Returns current product.
*
- * @param array $data
* @param int|null $storeId
* @return ProductInterface|Product
*/
From bc74e334a92d0419ce3fd1bf573d90de36c3e88a Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Thu, 24 Oct 2019 10:37:44 +0300
Subject: [PATCH 0589/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
index e594d90e502b7..36ac5156f48ff 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleTest.xml
@@ -39,6 +39,7 @@
+
From cc728faa3450d2d67579c902b11b7b9f86d84dd0 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 24 Oct 2019 10:49:20 +0300
Subject: [PATCH 0590/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Product/Gallery/UpdateHandlerTest.php | 29 ++++++++-----------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
index af6b066b6481a..d323ce654b497 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
@@ -73,6 +73,7 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
* @var string
*/
private $fileName;
+ private $mediaAttributeId;
/**
* @inheritdoc
@@ -86,6 +87,7 @@ protected function setUp()
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
$this->galleryResource = $this->objectManager->create(Gallery::class);
$this->productResource = $this->objectManager->create(ProductResource::class);
+ $this->mediaAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
$this->config = $this->objectManager->get(Config::class);
$this->mediaDirectory = $this->objectManager->get(Filesystem::class)
->getDirectoryWrite(DirectoryList::MEDIA);
@@ -109,7 +111,7 @@ public function testExecuteWithIllegalFilename(): void
'images' => [
'image' => [
'value_id' => '100',
- 'file' => str_repeat('/..', 2) . DIRECTORY_SEPARATOR . $this->fileName,
+ 'file' => '/../..' . DIRECTORY_SEPARATOR . $this->fileName,
'label' => 'New image',
'removed' => 1,
],
@@ -130,13 +132,11 @@ public function testExecuteWithIllegalFilename(): void
public function testExecuteWithOneImage(): void
{
$product = $this->getProduct();
- $this->prepareProductWithOneImage($product, ['label' => 'New image', 'disabled' => '1']);
+ $this->updateProductGalleryImages($product, ['label' => 'New image', 'disabled' => '1']);
$this->updateHandler->execute($product);
- $productImages = $this->galleryResource->loadProductGalleryByAttributeId(
- $product,
- $this->productResource->getAttribute('media_gallery')->getAttributeId()
- );
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $this->mediaAttributeId);
$updatedImage = reset($productImages);
+ $this->assertTrue(is_array($updatedImage));
$this->assertEquals('New image', $updatedImage['label']);
$this->assertEquals('New image', $updatedImage['label_default']);
$this->assertEquals('1', $updatedImage['disabled']);
@@ -248,8 +248,7 @@ public function testExecuteWithTwoImagesAndChangedPosition(): void
$product->setData('store_id', Store::DEFAULT_STORE_ID);
$product->setData('media_gallery', ['images' => $images]);
$this->updateHandler->execute($product);
- $galleryAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
- $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $galleryAttributeId);
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $this->mediaAttributeId);
foreach ($productImages as $updatedImage) {
$this->assertEquals($positionMap[$updatedImage['file']], $updatedImage['position']);
$this->assertEquals($positionMap[$updatedImage['file']], $updatedImage['position_default']);
@@ -266,12 +265,9 @@ public function testExecuteWithTwoImagesAndChangedPosition(): void
public function testExecuteWithImageToDelete(): void
{
$product = $this->getProduct();
- $this->prepareProductWithOneImage($product, ['removed' => '1']);
+ $this->updateProductGalleryImages($product, ['removed' => '1']);
$this->updateHandler->execute($product);
- $productImages = $this->galleryResource->loadProductGalleryByAttributeId(
- $product,
- $this->productResource->getAttribute('media_gallery')->getAttributeId()
- );
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $this->mediaAttributeId);
$this->assertCount(0, $productImages);
$this->assertFileNotExists(
$this->mediaDirectory->getAbsolutePath($this->config->getBaseMediaPath() . '/m/a/magento_image.jpg')
@@ -324,8 +320,7 @@ public function testExecuteWithTwoImagesOnStoreView(): void
}
$product->setData('media_gallery', ['images' => $images]);
$this->updateHandler->execute($product);
- $galleryAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
- $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $galleryAttributeId);
+ $productImages = $this->galleryResource->loadProductGalleryByAttributeId($product, $this->mediaAttributeId);
foreach ($productImages as $image) {
$imageToAssert = [
'label' => $image['label'],
@@ -363,10 +358,10 @@ private function getProduct(?int $storeId = null): ProductInterface
* @param array $imageData
* @return void
*/
- private function prepareProductWithOneImage(ProductInterface $product, array $imageData): void
+ private function updateProductGalleryImages(ProductInterface $product, array $imageData): void
{
$images = $product->getData('media_gallery')['images'];
- $image = reset($images);
+ $image = reset($images) ?: [];
$product->setData('store_id', Store::DEFAULT_STORE_ID);
$product->setData('media_gallery', ['images' => ['image' => array_merge($image, $imageData)]]);
}
From 825fcb1fe5ae60cb03228884f4aa5e6f0dcbe810 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 24 Oct 2019 13:21:01 +0530
Subject: [PATCH 0591/1978] Fixed frontend tax sorting issue and on order
email.
---
app/code/Magento/Tax/Block/Sales/Order/Tax.php | 4 ++--
app/code/Magento/Weee/Block/Sales/Order/Totals.php | 8 +++++---
.../view/adminhtml/layout/sales_order_creditmemo_new.xml | 2 +-
.../view/adminhtml/layout/sales_order_creditmemo_view.xml | 2 +-
.../view/adminhtml/layout/sales_order_invoice_new.xml | 2 +-
.../view/adminhtml/layout/sales_order_invoice_view.xml | 2 +-
.../Weee/view/adminhtml/layout/sales_order_view.xml | 2 +-
.../Weee/view/frontend/layout/sales_email_order_items.xml | 2 +-
8 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/app/code/Magento/Tax/Block/Sales/Order/Tax.php b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
index c05bbb0244c1b..fabdb63eb98c8 100644
--- a/app/code/Magento/Tax/Block/Sales/Order/Tax.php
+++ b/app/code/Magento/Tax/Block/Sales/Order/Tax.php
@@ -106,7 +106,7 @@ protected function _addTax($after = 'discount')
{
$taxTotal = new \Magento\Framework\DataObject(['code' => 'tax', 'block_name' => $this->getNameInLayout()]);
$totals = $this->getParentBlock()->getTotals();
- if ($totals['grand_total']) {
+ if (isset($totals['grand_total_incl'])) {
$this->getParentBlock()->addTotal($taxTotal, 'grand_total');
}
$this->getParentBlock()->addTotal($taxTotal, $after);
@@ -319,8 +319,8 @@ protected function _initGrandTotal()
'label' => __('Grand Total (Incl.Tax)'),
]
);
- $parent->addTotal($totalExcl, 'grand_total');
$parent->addTotal($totalIncl, 'grand_total');
+ $parent->addTotal($totalExcl, 'tax');
$this->_addTax('grand_total');
}
return $this;
diff --git a/app/code/Magento/Weee/Block/Sales/Order/Totals.php b/app/code/Magento/Weee/Block/Sales/Order/Totals.php
index 8aeefecb14cc9..047bbec3cb821 100644
--- a/app/code/Magento/Weee/Block/Sales/Order/Totals.php
+++ b/app/code/Magento/Weee/Block/Sales/Order/Totals.php
@@ -54,6 +54,8 @@ public function initTotals()
$weeeTotal = $this->weeeData->getTotalAmounts($items, $store);
$weeeBaseTotal = $this->weeeData->getBaseTotalAmounts($items, $store);
if ($weeeTotal) {
+ $totals = $this->getParentBlock()->getTotals();
+
// Add our total information to the set of other totals
$total = new \Magento\Framework\DataObject(
[
@@ -63,10 +65,10 @@ public function initTotals()
'base_value' => $weeeBaseTotal
]
);
- if ($this->getBeforeCondition()) {
- $this->getParentBlock()->addTotalBefore($total, $this->getBeforeCondition());
+ if (isset($totals['grand_total_incl'])) {
+ $this->getParentBlock()->addTotalBefore($total, 'grand_total');
} else {
- $this->getParentBlock()->addTotal($total, $this->getAfterCondition());
+ $this->getParentBlock()->addTotalBefore($total, $this->getBeforeCondition());
}
}
return $this;
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml
index 04522be9cb625..94a77534d94e8 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_new.xml
@@ -10,7 +10,7 @@
- grand_total
+ tax
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml
index 04522be9cb625..94a77534d94e8 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_creditmemo_view.xml
@@ -10,7 +10,7 @@
- grand_total
+ tax
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml
index 8a89806c429c9..d14bba1395385 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_new.xml
@@ -10,7 +10,7 @@
- grand_total
+ tax
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml
index 8a89806c429c9..d14bba1395385 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_invoice_view.xml
@@ -10,7 +10,7 @@
- grand_total
+ tax
diff --git a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml
index 5be6eba2d8b12..f31acedf94447 100644
--- a/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml
+++ b/app/code/Magento/Weee/view/adminhtml/layout/sales_order_view.xml
@@ -10,7 +10,7 @@
- grand_total
+ tax
diff --git a/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml
index f31acedf94447..5be6eba2d8b12 100644
--- a/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml
+++ b/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml
@@ -10,7 +10,7 @@
- tax
+ grand_total
From 32a3c1846c6a48d553b6152e2c2baac488242388 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 24 Oct 2019 13:23:16 +0530
Subject: [PATCH 0592/1978] Fixed order email tax sorting.
---
.../Weee/view/frontend/layout/sales_email_order_items.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml b/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml
index 5be6eba2d8b12..f31acedf94447 100644
--- a/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml
+++ b/app/code/Magento/Weee/view/frontend/layout/sales_email_order_items.xml
@@ -10,7 +10,7 @@
- grand_total
+ tax
From 296a0905267003b033bc9d71ecd1a4f8921e1f3d Mon Sep 17 00:00:00 2001
From: phil
Date: Thu, 24 Oct 2019 09:41:54 +0100
Subject: [PATCH 0593/1978] Allow autoplay for vimeo thumb click
Currently on click a video thumb the video does not start, but the code to autoplay is incorrect since 2017
https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
---
.../Magento/ProductVideo/view/frontend/web/js/load-player.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js b/app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js
index ede0d2019309d..aead951043448 100644
--- a/app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js
+++ b/app/code/Magento/ProductVideo/view/frontend/web/js/load-player.js
@@ -344,6 +344,7 @@ define([
.attr('mozallowfullscreen', '')
.attr('allowfullscreen', '')
.attr('referrerPolicy', 'origin')
+ .attr('allow', 'autoplay')
);
this._player = window.$f(this.element.children(':first')[0]);
From d7c0d5c60df0d5f04f1efc5399453b8ed2d56dd9 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 24 Oct 2019 11:50:35 +0300
Subject: [PATCH 0594/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Catalog/Model/Product/Gallery/UpdateHandlerTest.php | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
index d323ce654b497..f71600c6ebd15 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
@@ -73,6 +73,10 @@ class UpdateHandlerTest extends \PHPUnit\Framework\TestCase
* @var string
*/
private $fileName;
+
+ /**
+ * @var int
+ */
private $mediaAttributeId;
/**
@@ -87,7 +91,7 @@ protected function setUp()
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
$this->galleryResource = $this->objectManager->create(Gallery::class);
$this->productResource = $this->objectManager->create(ProductResource::class);
- $this->mediaAttributeId = $this->productResource->getAttribute('media_gallery')->getAttributeId();
+ $this->mediaAttributeId = (int)$this->productResource->getAttribute('media_gallery')->getAttributeId();
$this->config = $this->objectManager->get(Config::class);
$this->mediaDirectory = $this->objectManager->get(Filesystem::class)
->getDirectoryWrite(DirectoryList::MEDIA);
From 45c2a9586bd7daba7aa0bbb7d90a1f27436a0ffb Mon Sep 17 00:00:00 2001
From: Eden
Date: Thu, 24 Oct 2019 15:55:45 +0700
Subject: [PATCH 0595/1978] Split test and create action group
---
...ableAutoGroupInCustomerFormActionGroup.xml | 29 ++++++++
...ultValueDisableAutoGroupChangeIsNoTest.xml | 34 +++++++++
...ltValueDisableAutoGroupChangeIsYesTest.xml | 36 ++++++++++
...DefaultValueDisableAutoGroupChangeTest.xml | 70 -------------------
4 files changed, 99 insertions(+), 70 deletions(-)
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml
delete mode 100644 app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
new file mode 100644
index 0000000000000..ed34f871005ee
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+ Check Default Value for Disable Automatic Group Changes Based on VAT ID in Create Customer form.
+
+
+
+
+
+
+
+
+
+
+ {{isChecked}}
+ grabDisableAutomaticGroupChange
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml
new file mode 100644
index 0000000000000..432100a35b9c9
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml
@@ -0,0 +1,34 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml
new file mode 100644
index 0000000000000..e200ff2edf847
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml
deleted file mode 100644
index ec1c38224602b..0000000000000
--- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeTest.xml
+++ /dev/null
@@ -1,70 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1
- grabDisableAutomaticGroupChange
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
- grabDisableAutomaticGroupChange
-
-
-
From a30f40a80b4c11cc0959cee82c7bdf3f6a71c8e0 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Thu, 24 Oct 2019 14:28:20 +0530
Subject: [PATCH 0596/1978] Fixed ObjectManager usage and respective unit tests
---
.../Magento/Email/Model/Template/Filter.php | 56 +++++++++----------
.../Test/Unit/Model/Template/FilterTest.php | 48 +++++++++++++---
2 files changed, 65 insertions(+), 39 deletions(-)
diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php
index a29b1165d83c8..f0704e97c297c 100644
--- a/app/code/Magento/Email/Model/Template/Filter.php
+++ b/app/code/Magento/Email/Model/Template/Filter.php
@@ -165,15 +165,20 @@ class Filter extends \Magento\Framework\Filter\Template
protected $configVariables;
/**
- * @var \Magento\Email\Model\Template\Css\Processor
+ * @var Css\Processor
*/
private $cssProcessor;
/**
- * @var ReadInterface
+ * @var Filesystem
*/
private $pubDirectory;
+ /**
+ * @var \Magento\Framework\Filesystem\Directory\Read
+ */
+ private $pubDirectoryRead;
+
/**
* @param \Magento\Framework\Stdlib\StringUtils $string
* @param \Psr\Log\LoggerInterface $logger
@@ -190,7 +195,8 @@ class Filter extends \Magento\Framework\Filter\Template
* @param \Magento\Variable\Model\Source\Variables $configVariables
* @param array $variables
* @param \Magento\Framework\Css\PreProcessor\Adapter\CssInliner|null $cssInliner
- *
+ * @param Css\Processor|null $cssProcessor
+ * @param Filesystem|null $pubDirectory
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -208,7 +214,9 @@ public function __construct(
\Pelago\Emogrifier $emogrifier,
\Magento\Variable\Model\Source\Variables $configVariables,
$variables = [],
- \Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner = null
+ \Magento\Framework\Css\PreProcessor\Adapter\CssInliner $cssInliner = null,
+ Css\Processor $cssProcessor = null,
+ Filesystem $pubDirectory = null
) {
$this->_escaper = $escaper;
$this->_assetRepo = $assetRepo;
@@ -224,6 +232,10 @@ public function __construct(
$this->emogrifier = $emogrifier;
$this->cssInliner = $cssInliner ?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class);
+ $this->cssProcessor = $cssProcessor ?: ObjectManager::getInstance()
+ ->get(Css\Processor::class);
+ $this->pubDirectory = $pubDirectory ?: ObjectManager::getInstance()
+ ->get(Filesystem::class);
$this->configVariables = $configVariables;
parent::__construct($string, $variables);
}
@@ -321,32 +333,14 @@ public function setDesignParams(array $designParams)
}
/**
- * Get CSS processor
- *
- * @deprecated 100.1.2
- * @return Css\Processor
- */
- private function getCssProcessor()
- {
- if (!$this->cssProcessor) {
- $this->cssProcessor = ObjectManager::getInstance()->get(Css\Processor::class);
- }
- return $this->cssProcessor;
- }
-
- /**
- * Get pub directory
+ * Sets pub directory
*
- * @deprecated 100.1.2
* @param string $dirType
- * @return ReadInterface
+ * @return void
*/
- private function getPubDirectory($dirType)
+ private function setPubDirectory($dirType)
{
- if (!$this->pubDirectory) {
- $this->pubDirectory = ObjectManager::getInstance()->get(Filesystem::class)->getDirectoryRead($dirType);
- }
- return $this->pubDirectory;
+ $this->pubDirectoryRead = $this->pubDirectory->getDirectoryRead($dirType);
}
/**
@@ -844,7 +838,7 @@ public function cssDirective($construction)
return '/* ' . __('"file" parameter must be specified') . ' */';
}
- $css = $this->getCssProcessor()->process(
+ $css = $this->cssProcessor->process(
$this->getCssFilesContent([$params['file']])
);
@@ -947,9 +941,9 @@ public function getCssFilesContent(array $files)
try {
foreach ($files as $file) {
$asset = $this->_assetRepo->createAsset($file, $designParams);
- $pubDirectory = $this->getPubDirectory($asset->getContext()->getBaseDirType());
- if ($pubDirectory->isExist($asset->getPath())) {
- $css .= $pubDirectory->readFile($asset->getPath());
+ $this->setPubDirectory($asset->getContext()->getBaseDirType());
+ if ($this->pubDirectoryRead->isExist($asset->getPath())) {
+ $css .= $this->pubDirectoryRead->readFile($asset->getPath());
} else {
$css .= $asset->getContent();
}
@@ -979,7 +973,7 @@ public function applyInlineCss($html)
$cssToInline = $this->getCssFilesContent(
$this->getInlineCssFiles()
);
- $cssToInline = $this->getCssProcessor()->process($cssToInline);
+ $cssToInline = $this->cssProcessor->process($cssToInline);
// Only run Emogrify if HTML and CSS contain content
if ($html && $cssToInline) {
diff --git a/app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php b/app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php
index 2c9fdae111fd8..86536ba553589 100644
--- a/app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php
+++ b/app/code/Magento/Email/Test/Unit/Model/Template/FilterTest.php
@@ -3,6 +3,9 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+
+declare(strict_types=1);
+
namespace Magento\Email\Test\Unit\Model\Template;
use Magento\Email\Model\Template\Css\Processor;
@@ -14,6 +17,7 @@
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * @SuppressWarnings(PHPMD.TooManyFields)
*/
class FilterTest extends \PHPUnit\Framework\TestCase
{
@@ -92,6 +96,21 @@ class FilterTest extends \PHPUnit\Framework\TestCase
*/
private $cssInliner;
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Email\Model\Template\Css\Processor
+ */
+ private $cssProcessor;
+
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\Filesystem
+ */
+ private $pubDirectory;
+
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|\Magento\Framework\Filesystem\Directory\Read
+ */
+ private $pubDirectoryRead;
+
protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -147,6 +166,18 @@ protected function setUp()
$this->cssInliner = $this->objectManager->getObject(
\Magento\Framework\Css\PreProcessor\Adapter\CssInliner::class
);
+
+ $this->cssProcessor = $this->getMockBuilder(\Magento\Email\Model\Template\Css\Processor::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->pubDirectory = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->pubDirectoryRead = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Read::class)
+ ->disableOriginalConstructor()
+ ->getMock();
}
/**
@@ -173,6 +204,8 @@ protected function getModel($mockedMethods = null)
$this->configVariables,
[],
$this->cssInliner,
+ $this->cssProcessor,
+ $this->pubDirectory
]
)
->setMethods($mockedMethods)
@@ -329,17 +362,16 @@ public function testGetCssFilesContent()
->with($file, $designParams)
->willReturn($asset);
- $pubDirectory = $this->getMockBuilder(ReadInterface::class)
- ->getMockForAbstractClass();
- $reflectionClass = new \ReflectionClass(Filter::class);
- $reflectionProperty = $reflectionClass->getProperty('pubDirectory');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($filter, $pubDirectory);
- $pubDirectory->expects($this->once())
+ $this->pubDirectory
+ ->expects($this->once())
+ ->method('getDirectoryRead')
+ ->willReturn($this->pubDirectoryRead);
+
+ $this->pubDirectoryRead->expects($this->once())
->method('isExist')
->with($path . DIRECTORY_SEPARATOR . $file)
->willReturn(true);
- $pubDirectory->expects($this->once())
+ $this->pubDirectoryRead->expects($this->once())
->method('readFile')
->with($path . DIRECTORY_SEPARATOR . $file)
->willReturn($css);
From 4a11963715a95e80aa642d61c5fe3979a72f9c4e Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Thu, 24 Oct 2019 14:43:41 +0530
Subject: [PATCH 0597/1978] Replaced deprecated usages of MessageManager
methods
---
.../Review/Controller/Adminhtml/Product/Delete.php | 6 +++---
.../Review/Controller/Adminhtml/Product/MassDelete.php | 8 ++++----
.../Controller/Adminhtml/Product/MassUpdateStatus.php | 8 ++++----
.../Review/Controller/Adminhtml/Product/MassVisibleIn.php | 8 ++++----
.../Magento/Review/Controller/Adminhtml/Product/Post.php | 6 +++---
.../Magento/Review/Controller/Adminhtml/Product/Save.php | 8 ++++----
.../Magento/Review/Controller/Adminhtml/Rating/Delete.php | 4 ++--
.../Magento/Review/Controller/Adminhtml/Rating/Save.php | 4 ++--
app/code/Magento/Review/Controller/Product/Post.php | 8 ++++----
.../Review/Test/Unit/Controller/Product/PostTest.php | 2 +-
10 files changed, 31 insertions(+), 31 deletions(-)
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Delete.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Delete.php
index 1b9c9eaa22be7..14a3271e7196d 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Delete.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Delete.php
@@ -33,7 +33,7 @@ public function execute()
try {
$this->getModel()->aggregate()->delete();
- $this->messageManager->addSuccess(__('The review has been deleted.'));
+ $this->messageManager->addSuccessMessage(__('The review has been deleted.'));
if ($this->getRequest()->getParam('ret') == 'pending') {
$resultRedirect->setPath('review/*/pending');
} else {
@@ -41,9 +41,9 @@ public function execute()
}
return $resultRedirect;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addException($e, __('Something went wrong deleting this review.'));
+ $this->messageManager->addExceptionMessage($e, __('Something went wrong deleting this review.'));
}
return $resultRedirect->setPath('review/*/edit/', ['id' => $reviewId]);
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/MassDelete.php b/app/code/Magento/Review/Controller/Adminhtml/Product/MassDelete.php
index 95f9ca3aa79d2..44b267dc5aa7c 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/MassDelete.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/MassDelete.php
@@ -59,19 +59,19 @@ public function execute()
{
$reviewsIds = $this->getRequest()->getParam('reviews');
if (!is_array($reviewsIds)) {
- $this->messageManager->addError(__('Please select review(s).'));
+ $this->messageManager->addErrorMessage(__('Please select review(s).'));
} else {
try {
foreach ($this->getCollection() as $model) {
$model->delete();
}
- $this->messageManager->addSuccess(
+ $this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been deleted.', count($reviewsIds))
);
} catch (LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addException($e, __('Something went wrong while deleting these records.'));
+ $this->messageManager->addExceptionMessage($e, __('Something went wrong while deleting these records.'));
}
}
/** @var \Magento\Backend\Model\View\Result\Redirect $resultRedirect */
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/MassUpdateStatus.php b/app/code/Magento/Review/Controller/Adminhtml/Product/MassUpdateStatus.php
index 9e93fb8fce63e..ff4acfb964898 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/MassUpdateStatus.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/MassUpdateStatus.php
@@ -59,20 +59,20 @@ public function execute()
{
$reviewsIds = $this->getRequest()->getParam('reviews');
if (!is_array($reviewsIds)) {
- $this->messageManager->addError(__('Please select review(s).'));
+ $this->messageManager->addErrorMessage(__('Please select review(s).'));
} else {
try {
$status = $this->getRequest()->getParam('status');
foreach ($this->getCollection() as $model) {
$model->setStatusId($status)->save()->aggregate();
}
- $this->messageManager->addSuccess(
+ $this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been updated.', count($reviewsIds))
);
} catch (LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addException(
+ $this->messageManager->addExceptionMessage(
$e,
__('Something went wrong while updating these review(s).')
);
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php b/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php
index eca37d3fe24da..246a513023717 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php
@@ -18,7 +18,7 @@ public function execute()
{
$reviewsIds = $this->getRequest()->getParam('reviews');
if (!is_array($reviewsIds)) {
- $this->messageManager->addError(__('Please select review(s).'));
+ $this->messageManager->addErrorMessage(__('Please select review(s).'));
} else {
try {
$stores = $this->getRequest()->getParam('stores');
@@ -27,13 +27,13 @@ public function execute()
$model->setSelectStores($stores);
$model->save();
}
- $this->messageManager->addSuccess(
+ $this->messageManager->addSuccessMessage(
__('A total of %1 record(s) have been updated.', count($reviewsIds))
);
} catch (LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addException(
+ $this->messageManager->addExceptionMessage(
$e,
__('Something went wrong while updating these review(s).')
);
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php
index b42dd3b3063f6..96e6cc48fb496 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Post.php
@@ -56,7 +56,7 @@ public function execute()
$review->aggregate();
- $this->messageManager->addSuccess(__('You saved the review.'));
+ $this->messageManager->addSuccessMessage(__('You saved the review.'));
if ($this->getRequest()->getParam('ret') == 'pending') {
$resultRedirect->setPath('review/*/pending');
} else {
@@ -64,9 +64,9 @@ public function execute()
}
return $resultRedirect;
} catch (LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addException($e, __('Something went wrong while saving this review.'));
+ $this->messageManager->addExceptionMessage($e, __('Something went wrong while saving this review.'));
}
}
$resultRedirect->setPath('review/*/');
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php
index 5b8ad106987e5..a7a0c96b7e48f 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/Save.php
@@ -34,7 +34,7 @@ public function execute()
if (($data = $this->getRequest()->getPostValue()) && ($reviewId = $this->getRequest()->getParam('id'))) {
$review = $this->getModel();
if (!$review->getId()) {
- $this->messageManager->addError(__('The review was removed by another user or does not exist.'));
+ $this->messageManager->addErrorMessage(__('The review was removed by another user or does not exist.'));
} else {
try {
$review->addData($data)->save();
@@ -63,11 +63,11 @@ public function execute()
$review->aggregate();
- $this->messageManager->addSuccess(__('You saved the review.'));
+ $this->messageManager->addSuccessMessage(__('You saved the review.'));
} catch (LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addException($e, __('Something went wrong while saving this review.'));
+ $this->messageManager->addExceptionMessage($e, __('Something went wrong while saving this review.'));
}
}
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
index b25db6e498fe0..77c331ba883e9 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
@@ -23,9 +23,9 @@ public function execute()
/** @var \Magento\Review\Model\Rating $model */
$model = $this->_objectManager->create(\Magento\Review\Model\Rating::class);
$model->load($this->getRequest()->getParam('id'))->delete();
- $this->messageManager->addSuccess(__('You deleted the rating.'));
+ $this->messageManager->addSuccessMessage(__('You deleted the rating.'));
} catch (\Exception $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
$resultRedirect->setPath('review/rating/edit', ['id' => $this->getRequest()->getParam('id')]);
return $resultRedirect;
}
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
index 5dd464f7eb611..7ae3ad6c54f79 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
@@ -58,10 +58,10 @@ public function execute()
}
}
- $this->messageManager->addSuccess(__('You saved the rating.'));
+ $this->messageManager->addSuccessMessage(__('You saved the rating.'));
$this->_objectManager->get(\Magento\Backend\Model\Session::class)->setRatingData(false);
} catch (\Exception $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
$this->_objectManager->get(\Magento\Backend\Model\Session::class)
->setRatingData($this->getRequest()->getPostValue());
$resultRedirect->setPath('review/rating/edit', ['id' => $this->getRequest()->getParam('id')]);
diff --git a/app/code/Magento/Review/Controller/Product/Post.php b/app/code/Magento/Review/Controller/Product/Post.php
index 32838eb6acbbb..3677eaa0f9c2a 100644
--- a/app/code/Magento/Review/Controller/Product/Post.php
+++ b/app/code/Magento/Review/Controller/Product/Post.php
@@ -63,19 +63,19 @@ public function execute()
}
$review->aggregate();
- $this->messageManager->addSuccess(__('You submitted your review for moderation.'));
+ $this->messageManager->addSuccessMessage(__('You submitted your review for moderation.'));
} catch (\Exception $e) {
$this->reviewSession->setFormData($data);
- $this->messageManager->addError(__('We can\'t post your review right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t post your review right now.'));
}
} else {
$this->reviewSession->setFormData($data);
if (is_array($validate)) {
foreach ($validate as $errorMessage) {
- $this->messageManager->addError($errorMessage);
+ $this->messageManager->addErrorMessage($errorMessage);
}
} else {
- $this->messageManager->addError(__('We can\'t post your review right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t post your review right now.'));
}
}
}
diff --git a/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php b/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php
index 1526e80f8190a..e5fd52bf8cf97 100644
--- a/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php
+++ b/app/code/Magento/Review/Test/Unit/Controller/Product/PostTest.php
@@ -299,7 +299,7 @@ public function testExecute()
->willReturnSelf();
$this->review->expects($this->once())->method('aggregate')
->willReturnSelf();
- $this->messageManager->expects($this->once())->method('addSuccess')
+ $this->messageManager->expects($this->once())->method('addSuccessMessage')
->with(__('You submitted your review for moderation.'))
->willReturnSelf();
$this->reviewSession->expects($this->once())->method('getRedirectUrl')
From 2eb25ea53c4be31e7e0366317654bc0a5789393c Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 24 Oct 2019 14:44:49 +0530
Subject: [PATCH 0598/1978] Static test fixed.
---
app/code/Magento/Weee/Block/Sales/Order/Totals.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/code/Magento/Weee/Block/Sales/Order/Totals.php b/app/code/Magento/Weee/Block/Sales/Order/Totals.php
index 047bbec3cb821..02f386bf4a289 100644
--- a/app/code/Magento/Weee/Block/Sales/Order/Totals.php
+++ b/app/code/Magento/Weee/Block/Sales/Order/Totals.php
@@ -6,6 +6,8 @@
namespace Magento\Weee\Block\Sales\Order;
/**
+ * Wee tax total column block
+ *
* @api
* @since 100.0.2
*/
From e80515c70ec72a9ca67b976ea0c219548c6a19e3 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 24 Oct 2019 17:50:11 +0530
Subject: [PATCH 0599/1978] Static test fixed whitespace removed.
---
app/code/Magento/Weee/Block/Sales/Order/Totals.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Weee/Block/Sales/Order/Totals.php b/app/code/Magento/Weee/Block/Sales/Order/Totals.php
index 02f386bf4a289..bc04b3a3985f3 100644
--- a/app/code/Magento/Weee/Block/Sales/Order/Totals.php
+++ b/app/code/Magento/Weee/Block/Sales/Order/Totals.php
@@ -7,7 +7,7 @@
/**
* Wee tax total column block
- *
+ *
* @api
* @since 100.0.2
*/
From 6f0623f3f0f95ecdb960f5de89371fb8c8d51abc Mon Sep 17 00:00:00 2001
From: "rostyslav.hymon"
Date: Thu, 24 Oct 2019 15:21:59 +0300
Subject: [PATCH 0600/1978] MC-21568: The shipping information was unable to be
saved. verify the input data and try again.
---
app/code/Magento/Persistent/Model/QuoteManager.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Persistent/Model/QuoteManager.php b/app/code/Magento/Persistent/Model/QuoteManager.php
index 8ae22e4c26c6f..a295d2b5a1ddb 100644
--- a/app/code/Magento/Persistent/Model/QuoteManager.php
+++ b/app/code/Magento/Persistent/Model/QuoteManager.php
@@ -89,7 +89,6 @@ public function setGuest($checkQuote = false)
->setCustomerLastname(null)
->setCustomerGroupId(\Magento\Customer\Api\Data\GroupInterface::NOT_LOGGED_IN_ID)
->setIsPersistent(false)
- ->setCustomerIsGuest(true)
->removeAllAddresses();
//Create guest addresses
$quote->getShippingAddress();
From d135cb1efafa0191007f27e8c3e8cedf2ca118e0 Mon Sep 17 00:00:00 2001
From: korostii <24894168+korostii@users.noreply.github.com>
Date: Thu, 24 Oct 2019 15:25:36 +0300
Subject: [PATCH 0601/1978] Fix #23031 (patch apply attempt should check patch
aliases)
---
.../Framework/Setup/Patch/PatchApplier.php | 6 +
.../Test/Unit/Patch/PatchApplierTest.php | 156 ++++++++++++++++--
2 files changed, 145 insertions(+), 17 deletions(-)
diff --git a/lib/internal/Magento/Framework/Setup/Patch/PatchApplier.php b/lib/internal/Magento/Framework/Setup/Patch/PatchApplier.php
index bdaca77e5b4eb..e1b0e2842628d 100644
--- a/lib/internal/Magento/Framework/Setup/Patch/PatchApplier.php
+++ b/lib/internal/Magento/Framework/Setup/Patch/PatchApplier.php
@@ -161,6 +161,9 @@ public function applyDataPatch($moduleName = null)
$this->moduleDataSetup->getConnection()->beginTransaction();
$dataPatch->apply();
$this->patchHistory->fixPatch(get_class($dataPatch));
+ foreach ($dataPatch->getAliases() as $patchAlias) {
+ $this->patchHistory->fixPatch($patchAlias);
+ }
$this->moduleDataSetup->getConnection()->commit();
} catch (\Exception $e) {
$this->moduleDataSetup->getConnection()->rollBack();
@@ -237,6 +240,9 @@ public function applySchemaPatch($moduleName = null)
$schemaPatch = $this->patchFactory->create($schemaPatch, ['schemaSetup' => $this->schemaSetup]);
$schemaPatch->apply();
$this->patchHistory->fixPatch(get_class($schemaPatch));
+ foreach ($schemaPatch->getAliases() as $patchAlias) {
+ $this->patchHistory->fixPatch($patchAlias);
+ }
} catch (\Exception $e) {
throw new SetupException(
new Phrase(
diff --git a/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchApplierTest.php b/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchApplierTest.php
index cb40845bcc488..b649f6f062e9e 100644
--- a/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchApplierTest.php
+++ b/lib/internal/Magento/Framework/Setup/Test/Unit/Patch/PatchApplierTest.php
@@ -10,8 +10,11 @@
use Magento\Framework\DB\Adapter\AdapterInterface;
use Magento\Framework\Module\ModuleResource;
use Magento\Framework\ObjectManagerInterface;
+use Magento\Framework\Setup\Exception;
use Magento\Framework\Setup\ModuleDataSetupInterface;
+use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchBackwardCompatability;
+use Magento\Framework\Setup\Patch\PatchInterface;
use Magento\Framework\Setup\SchemaSetupInterface;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\Setup\Patch\PatchApplier;
@@ -169,8 +172,10 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
$patch1 = $this->createMock(\SomeDataPatch::class);
$patch1->expects($this->once())->method('apply');
+ $patch1->expects($this->once())->method('getAliases')->willReturn([]);
$patch2 = $this->createMock(\OtherDataPatch::class);
$patch2->expects($this->once())->method('apply');
+ $patch2->expects($this->once())->method('getAliases')->willReturn([]);
$this->objectManagerMock->expects($this->any())->method('create')->willReturnMap(
[
['\\' . \SomeDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch1],
@@ -188,6 +193,60 @@ public function testApplyDataPatchForNewlyInstalledModule($moduleName, $dataPatc
$this->patchApllier->applyDataPatch($moduleName);
}
+ /**
+ * @param $moduleName
+ * @param $dataPatches
+ * @param $moduleVersionInDb
+ *
+ * @dataProvider applyDataPatchDataNewModuleProvider()
+ *
+ * @expectedException Exception
+ * @expectedExceptionMessageRegExp "Unable to apply data patch .+ cannot be applied twice"
+ */
+ public function testApplyDataPatchForAlias($moduleName, $dataPatches, $moduleVersionInDb)
+ {
+ $this->dataPatchReaderMock->expects($this->once())
+ ->method('read')
+ ->with($moduleName)
+ ->willReturn($dataPatches);
+
+ $this->moduleResourceMock->expects($this->any())->method('getDataVersion')->willReturnMap(
+ [
+ [$moduleName, $moduleVersionInDb]
+ ]
+ );
+
+ $patch1 = $this->createMock(DataPatchInterface::class);
+ $patch1->expects($this->once())->method('getAliases')->willReturn(['PatchAlias']);
+ $patchClass = get_class($patch1);
+
+ $patchRegistryMock = $this->createAggregateIteratorMock(PatchRegistry::class, [$patchClass], ['registerPatch']);
+ $patchRegistryMock->expects($this->any())
+ ->method('registerPatch');
+
+ $this->patchRegistryFactoryMock->expects($this->any())
+ ->method('create')
+ ->willReturn($patchRegistryMock);
+
+ $this->objectManagerMock->expects($this->any())->method('create')->willReturnMap(
+ [
+ ['\\' . $patchClass, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch1],
+ ]
+ );
+ $this->connectionMock->expects($this->exactly(1))->method('beginTransaction');
+ $this->connectionMock->expects($this->never())->method('commit');
+ $this->patchHistoryMock->expects($this->any())->method('fixPatch')->will(
+ $this->returnCallback(
+ function ($param1) {
+ if ($param1 == 'PatchAlias') {
+ throw new \LogicException(sprintf("Patch %s cannot be applied twice", $param1));
+ }
+ }
+ )
+ );
+ $this->patchApllier->applyDataPatch($moduleName);
+ }
+
/**
* @return array
*/
@@ -243,8 +302,10 @@ public function testApplyDataPatchForInstalledModule($moduleName, $dataPatches,
$patch1 = $this->createMock(\SomeDataPatch::class);
$patch1->expects(self::never())->method('apply');
+ $patch1->expects(self::any())->method('getAliases')->willReturn([]);
$patch2 = $this->createMock(\OtherDataPatch::class);
$patch2->expects(self::once())->method('apply');
+ $patch2->expects(self::any())->method('getAliases')->willReturn([]);
$this->objectManagerMock->expects(self::any())->method('create')->willReturnMap(
[
['\\' . \SomeDataPatch::class, ['moduleDataSetup' => $this->moduleDataSetupMock], $patch1],
@@ -279,7 +340,7 @@ public function applyDataPatchDataInstalledModuleProvider()
* @param $dataPatches
* @param $moduleVersionInDb
*
- * @expectedException \Magento\Framework\Setup\Exception
+ * @expectedException Exception
* @expectedExceptionMessage Patch Apply Error
*
* @dataProvider applyDataPatchDataInstalledModuleProvider()
@@ -328,7 +389,7 @@ public function testApplyDataPatchRollback($moduleName, $dataPatches, $moduleVer
}
/**
- * @expectedException \Magento\Framework\Setup\Exception
+ * @expectedException Exception
* @expectedExceptionMessageRegExp "Patch [a-zA-Z0-9\_]+ should implement DataPatchInterface"
*/
public function testNonDataPatchApply()
@@ -434,8 +495,10 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
$patch1 = $this->createMock(\SomeSchemaPatch::class);
$patch1->expects($this->never())->method('apply');
+ $patch1->expects($this->any())->method('getAliases')->willReturn([]);
$patch2 = $this->createMock(\OtherSchemaPatch::class);
$patch2->expects($this->once())->method('apply');
+ $patch2->expects($this->any())->method('getAliases')->willReturn([]);
$this->patchFactoryMock->expects($this->any())->method('create')->willReturnMap(
[
[\SomeSchemaPatch::class, ['schemaSetup' => $this->schemaSetupMock], $patch1],
@@ -448,6 +511,55 @@ public function testSchemaPatchAplly($moduleName, $schemaPatches, $moduleVersion
$this->patchApllier->applySchemaPatch($moduleName);
}
+ /**
+ * @param $moduleName
+ * @param $schemaPatches
+ * @param $moduleVersionInDb
+ *
+ * @dataProvider schemaPatchDataProvider()
+ *
+ * @expectedException Exception
+ * @expectedExceptionMessageRegExp "Unable to apply patch .+ cannot be applied twice"
+ */
+ public function testSchemaPatchApplyForPatchAlias($moduleName, $schemaPatches, $moduleVersionInDb)
+ {
+ $this->schemaPatchReaderMock->expects($this->once())
+ ->method('read')
+ ->with($moduleName)
+ ->willReturn($schemaPatches);
+
+ $this->moduleResourceMock->expects($this->any())->method('getDbVersion')->willReturnMap(
+ [
+ [$moduleName, $moduleVersionInDb]
+ ]
+ );
+
+ $patch1 = $this->createMock(PatchInterface::class);
+ $patch1->expects($this->once())->method('getAliases')->willReturn(['PatchAlias']);
+ $patchClass = get_class($patch1);
+
+ $patchRegistryMock = $this->createAggregateIteratorMock(PatchRegistry::class, [$patchClass], ['registerPatch']);
+ $patchRegistryMock->expects($this->any())
+ ->method('registerPatch');
+
+ $this->patchRegistryFactoryMock->expects($this->any())
+ ->method('create')
+ ->willReturn($patchRegistryMock);
+
+ $this->patchFactoryMock->expects($this->any())->method('create')->willReturn($patch1);
+ $this->patchHistoryMock->expects($this->any())->method('fixPatch')->will(
+ $this->returnCallback(
+ function ($param1) {
+ if ($param1 == 'PatchAlias') {
+ throw new \LogicException(sprintf("Patch %s cannot be applied twice", $param1));
+ }
+ }
+ )
+ );
+
+ $this->patchApllier->applySchemaPatch($moduleName);
+ }
+
public function testRevertDataPatches()
{
$patches = [\RevertableDataPatch::class];
@@ -534,33 +646,43 @@ private function createAggregateIteratorMock($className, array $items = [], arra
$someIterator->expects($this->any())
->method('rewind')
- ->willReturnCallback(function () use ($iterator) {
- $iterator->rewind();
- });
+ ->willReturnCallback(
+ function () use ($iterator) {
+ $iterator->rewind();
+ }
+ );
$someIterator->expects($this->any())
->method('current')
- ->willReturnCallback(function () use ($iterator) {
- return $iterator->current();
- });
+ ->willReturnCallback(
+ function () use ($iterator) {
+ return $iterator->current();
+ }
+ );
$someIterator->expects($this->any())
->method('key')
- ->willReturnCallback(function () use ($iterator) {
- return $iterator->key();
- });
+ ->willReturnCallback(
+ function () use ($iterator) {
+ return $iterator->key();
+ }
+ );
$someIterator->expects($this->any())
->method('next')
- ->willReturnCallback(function () use ($iterator) {
- $iterator->next();
- });
+ ->willReturnCallback(
+ function () use ($iterator) {
+ $iterator->next();
+ }
+ );
$someIterator->expects($this->any())
->method('valid')
- ->willReturnCallback(function () use ($iterator) {
- return $iterator->valid();
- });
+ ->willReturnCallback(
+ function () use ($iterator) {
+ return $iterator->valid();
+ }
+ );
return $mockIteratorAggregate;
}
From 1fb8db702cdf30a244245413c5dd08e7d8a8ee1c Mon Sep 17 00:00:00 2001
From: Viktor Sevch
Date: Thu, 24 Oct 2019 15:46:00 +0300
Subject: [PATCH 0602/1978] MC-17175: Unstable MFTF Tests For Creating Poor
Schedule Updates
---
...esRuleWithComplexConditionsAndVerifyDeleteMessageTest.xml | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminDeleteActiveSalesRuleWithComplexConditionsAndVerifyDeleteMessageTest.xml b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminDeleteActiveSalesRuleWithComplexConditionsAndVerifyDeleteMessageTest.xml
index d106c086a6065..9a71210aac1c6 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Test/AdminDeleteActiveSalesRuleWithComplexConditionsAndVerifyDeleteMessageTest.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Test/AdminDeleteActiveSalesRuleWithComplexConditionsAndVerifyDeleteMessageTest.xml
@@ -16,9 +16,6 @@
-
-
-
@@ -60,6 +57,8 @@
+
+
From 910415f6cb2179af76c488842a32b399161b885a Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Thu, 24 Oct 2019 08:56:45 -0500
Subject: [PATCH 0603/1978] MC-21524: Schema introspection return incomplete
results
- Added changes for the schema return
---
lib/internal/Magento/Framework/GraphQl/Query/Fields.php | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/internal/Magento/Framework/GraphQl/Query/Fields.php b/lib/internal/Magento/Framework/GraphQl/Query/Fields.php
index a34c0a9d42187..f3f4ed7aba23d 100644
--- a/lib/internal/Magento/Framework/GraphQl/Query/Fields.php
+++ b/lib/internal/Magento/Framework/GraphQl/Query/Fields.php
@@ -49,7 +49,8 @@ public function setQuery($query, array $variables = null)
} catch (\Exception $e) {
// If a syntax error is encountered do not collect fields
}
- if (isset($queryFields['IntrospectionQuery'])) {
+ if (isset($queryFields['IntrospectionQuery']) || (isset($queryFields['__schema'])) ||
+ (isset($queryFields['__type']))) {
// It must be possible to query any fields during introspection query
$queryFields = [];
}
@@ -60,7 +61,7 @@ public function setQuery($query, array $variables = null)
* Get list of fields used in GraphQL query.
*
* This method is stateful and relies on the query being set with setQuery.
- *
+ *-
* @return string[]
*/
public function getFieldsUsedInQuery()
From b944f82281450c6dc89189e034e403e1e7417992 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 24 Oct 2019 09:29:34 -0500
Subject: [PATCH 0604/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index fe5e6c7f24c4d..2d8ef2b52d2c5 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -295,18 +295,17 @@ protected function doReindexByIds($ids)
foreach ($ids as $productId) {
foreach ($activeRules as $activeRule) {
$rule = clone $activeRule;
- $rule->setProductsFilter($productId);
+ $rule->setProductsFilter($ids);
$matchedProductIds = $rule->getMatchingProductIds();
- if (!isset($matchedProductIds[$productId])) {
- continue;
+ $matchedProductIds = array_intersect_key($matchedProductIds, array_flip($ids));
+ foreach ($matchedProductIds as $matchedProductId => $validationByWebsite) {
+ $websiteIds = array_keys(array_filter($validationByWebsite));
+ if (empty($websiteIds)) {
+ continue;
+ }
+
+ $this->assignProductToRule($rule, $matchedProductId, $websiteIds);
}
-
- $websiteIds = array_keys(array_filter($matchedProductIds[$productId]));
- if (empty($websiteIds)) {
- continue;
- }
-
- $this->assignProductToRule($rule, $productId, $websiteIds);
}
$this->cleanProductPriceIndex([$productId]);
From 5aa774b18c82fc7af5610bb1fd470cb6ac064766 Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 24 Oct 2019 20:00:11 +0530
Subject: [PATCH 0605/1978] Changed Function name checkRequredFields to
checkRequiredFields
---
.../Model/Address/Validator/General.php | 32 ++++++++++++++++++-
1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Customer/Model/Address/Validator/General.php b/app/code/Magento/Customer/Model/Address/Validator/General.php
index 679f288712b4b..67912f8f52385 100644
--- a/app/code/Magento/Customer/Model/Address/Validator/General.php
+++ b/app/code/Magento/Customer/Model/Address/Validator/General.php
@@ -41,7 +41,7 @@ public function __construct(
public function validate(AbstractAddress $address)
{
$errors = array_merge(
- $this->checkRequredFields($address),
+ $this->checkRequiredFields($address),
$this->checkOptionalFields($address)
);
@@ -55,6 +55,36 @@ public function validate(AbstractAddress $address)
* @return array
* @throws \Zend_Validate_Exception
*/
+ private function checkRequiredFields(AbstractAddress $address)
+ {
+ $errors = [];
+ if (!\Zend_Validate::is($address->getFirstname(), 'NotEmpty')) {
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'firstname']);
+ }
+
+ if (!\Zend_Validate::is($address->getLastname(), 'NotEmpty')) {
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'lastname']);
+ }
+
+ if (!\Zend_Validate::is($address->getStreetLine(1), 'NotEmpty')) {
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'street']);
+ }
+
+ if (!\Zend_Validate::is($address->getCity(), 'NotEmpty')) {
+ $errors[] = __('"%fieldName" is required. Enter and try again.', ['fieldName' => 'city']);
+ }
+
+ return $errors;
+ }
+
+ /**
+ * @deprecated
+ * Check fields that are generally required.
+ *
+ * @param AbstractAddress $address
+ * @return array
+ * @throws \Zend_Validate_Exception
+ */
private function checkRequredFields(AbstractAddress $address)
{
$errors = [];
From 2e4cd74a7287db2c53e911fbd8403b1338e67541 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 24 Oct 2019 09:49:36 -0500
Subject: [PATCH 0606/1978] magento/graphql-ce#961:
ShippingAddressInput.postcode: String, is not required by Schema
---
.../QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
index 2c24acbdf63e6..e058913dde1d3 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/SetShippingAddressesOnCart.php
@@ -62,5 +62,6 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
}
throw $e;
}
+ $this->assignShippingAddressToCart->execute($cart, $shippingAddress);
}
}
From 700039d3f0cb64a0a1b724f79d53b30a4daa808d Mon Sep 17 00:00:00 2001
From: mahesh
Date: Thu, 24 Oct 2019 20:31:31 +0530
Subject: [PATCH 0607/1978] Some static test fixed.
---
app/code/Magento/Customer/Model/Address/Validator/General.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Customer/Model/Address/Validator/General.php b/app/code/Magento/Customer/Model/Address/Validator/General.php
index 67912f8f52385..ac05efd158bef 100644
--- a/app/code/Magento/Customer/Model/Address/Validator/General.php
+++ b/app/code/Magento/Customer/Model/Address/Validator/General.php
@@ -78,7 +78,8 @@ private function checkRequiredFields(AbstractAddress $address)
}
/**
- * @deprecated
+ * @deprecated because function name incorrect spelled
+ *
* Check fields that are generally required.
*
* @param AbstractAddress $address
From 106f398556586d08613ae76092ac06b415f7f118 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 24 Oct 2019 10:02:57 -0500
Subject: [PATCH 0608/1978] magento/graphql-ce#960: PWA - graphQl fetching
Issue for phtml file called in static block
---
.../CmsGraphQl/Model/Resolver/DataProvider/Block.php | 2 +-
.../Magento/Widget/Model/Template/FilterEmulate.php | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
index fa4944381b858..21bdca732b606 100644
--- a/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
+++ b/app/code/Magento/CmsGraphQl/Model/Resolver/DataProvider/Block.php
@@ -56,7 +56,7 @@ public function getData(string $blockIdentifier): array
);
}
- $renderedContent = $this->widgetFilter->filter($block->getContent());
+ $renderedContent = $this->widgetFilter->filterDirective($block->getContent());
$blockData = [
BlockInterface::BLOCK_ID => $block->getId(),
diff --git a/app/code/Magento/Widget/Model/Template/FilterEmulate.php b/app/code/Magento/Widget/Model/Template/FilterEmulate.php
index 9e57ebb34f0ed..4312003c7f34e 100644
--- a/app/code/Magento/Widget/Model/Template/FilterEmulate.php
+++ b/app/code/Magento/Widget/Model/Template/FilterEmulate.php
@@ -1,8 +1,10 @@
-_appState->emulateAreaCode(
\Magento\Framework\App\Area::AREA_FRONTEND,
- [$this, 'parent::filter'],
+ [$this, 'filter'],
[$value]
);
}
From 19bcd9cab5991cccb70be36c26f6269b4c9bcd70 Mon Sep 17 00:00:00 2001
From: Ji Lu
Date: Thu, 24 Oct 2019 10:05:22 -0500
Subject: [PATCH 0609/1978] MQE-1840: Convert
DeleteProductsFromWishlistOnFrontendTest to MFTF
---
...refrontDeleteBundleDynamicProductFromWishlistTest.xml | 6 +++---
...torefrontDeleteBundleFixedProductFromWishlistTest.xml | 7 ++++---
...orefrontDeleteConfigurableProductFromWishlistTest.xml | 9 ++++-----
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml
index 88621b241db89..ae65a4171d883 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleDynamicProductFromWishlistTest.xml
@@ -13,8 +13,8 @@
-
-
+
+
@@ -84,7 +84,7 @@
-
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml
index cb8b5b1de859f..a0bff949f00f5 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteBundleFixedProductFromWishlistTest.xml
@@ -13,8 +13,8 @@
-
-
+
+
@@ -54,6 +54,7 @@
+
@@ -76,7 +77,7 @@
-
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml
index f23f09129cb63..8e5ff5694480f 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontDeleteConfigurableProductFromWishlistTest.xml
@@ -8,13 +8,13 @@
-
+
-
-
+
+
@@ -133,12 +133,11 @@
-
-
+
From 6047c8623be28742c5871bb8cb5d4fcf6f0c6237 Mon Sep 17 00:00:00 2001
From: Dan Mooney
Date: Thu, 24 Oct 2019 10:13:50 -0500
Subject: [PATCH 0610/1978] MC-21994: Integration Test failure:
UploadTest::testUploadActionWithErrors
---
.../Adminhtml/Product/Gallery/Upload.php | 15 ---------------
.../Adminhtml/Product/Gallery/UploadTest.php | 6 ++----
2 files changed, 2 insertions(+), 19 deletions(-)
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php
index f4c7891d00849..d43b313c43b3e 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Gallery/Upload.php
@@ -89,11 +89,6 @@ public function execute()
['fileId' => 'image']
);
$uploader->setAllowedExtensions($this->getAllowedExtensions());
-
- if (!$uploader->checkMimeType($this->getAllowedMimeTypes())) {
- throw new LocalizedException(__('Disallowed File Type.'));
- }
-
$imageAdapter = $this->adapterFactory->create();
$uploader->addValidateCallback('catalog_product_image', $imageAdapter, 'validateUploadFile');
$uploader->setAllowRenameFiles(true);
@@ -133,14 +128,4 @@ private function getAllowedExtensions()
{
return array_keys($this->allowedMimeTypes);
}
-
- /**
- * Get the set of allowed mime types.
- *
- * @return array
- */
- private function getAllowedMimeTypes()
- {
- return array_values($this->allowedMimeTypes);
- }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php
index a786e7fa821b6..683fbc1a358c1 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Gallery/UploadTest.php
@@ -154,8 +154,6 @@ public function uploadActionDataProvider(): array
*/
public function testUploadActionWithErrors(array $file, array $expectation): void
{
- $this->markTestSkipped('MC-21994');
-
if (!empty($file['create_file'])) {
$this->createFileInSysTmpDir($file['name']);
} elseif (!empty($file['copy_file'])) {
@@ -165,8 +163,8 @@ public function testUploadActionWithErrors(array $file, array $expectation): voi
$this->getRequest()->setMethod($this->httpMethod);
$this->dispatch($this->uri);
$jsonBody = $this->serializer->unserialize($this->getResponse()->getBody());
- $this->assertEquals($jsonBody['error'], $expectation['message']);
- $this->assertEquals($jsonBody['errorcode'], $expectation['errorcode']);
+ $this->assertEquals($expectation['message'], $jsonBody['error']);
+ $this->assertEquals($expectation['errorcode'], $jsonBody['errorcode']);
if (!empty($expectation['tmp_media_path'])) {
$this->assertFileNotExists(
From 282b09b430ef06972e7adcaa4724e8041699c849 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 24 Oct 2019 10:31:30 -0500
Subject: [PATCH 0611/1978] magento/graphql-ce#920: [Wishlist] Remove name from
WishlistOutput
---
.../Model/Resolver/CustomerWishlistsResolver.php | 8 ++++----
app/code/Magento/WishlistGraphQl/etc/schema.graphqls | 6 +++---
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
index 3556eefe36a9c..804814c424810 100644
--- a/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
+++ b/app/code/Magento/WishlistGraphQl/Model/Resolver/CustomerWishlistsResolver.php
@@ -21,14 +21,14 @@ class CustomerWishlistsResolver implements ResolverInterface
/**
* @var CollectionFactory
*/
- private $_wishlistCollectionFactory;
+ private $wishlistCollectionFactory;
/**
* @param CollectionFactory $wishlistCollectionFactory
*/
public function __construct(CollectionFactory $wishlistCollectionFactory)
{
- $this->_wishlistCollectionFactory = $wishlistCollectionFactory;
+ $this->wishlistCollectionFactory = $wishlistCollectionFactory;
}
/**
@@ -43,9 +43,9 @@ public function resolve(
) {
/* Guest checking */
if (false === $context->getExtensionAttributes()->getIsCustomer()) {
- throw new GraphQlAuthorizationException(__('The current user cannot perform operations on wishlist'));
+ throw new GraphQlAuthorizationException(__('The current customer isn\'t authorized.'));
}
- $collection = $this->_wishlistCollectionFactory->create()->filterByCustomerId($context->getUserId());
+ $collection = $this->wishlistCollectionFactory->create()->filterByCustomerId($context->getUserId());
$wishlistsData = [];
if (0 === $collection->getSize()) {
return $wishlistsData;
diff --git a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
index 6a833efd7c2a5..1009b6f803d93 100644
--- a/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/WishlistGraphQl/etc/schema.graphqls
@@ -9,10 +9,10 @@ type Customer {
wishlists: [Wishlist]! @resolver(class:"\\Magento\\WishlistGraphQl\\Model\\Resolver\\CustomerWishlistsResolver") @doc(description: "The wishlist query returns the contents of a customer's wish lists") @cache(cacheable: false)
}
-type WishlistOutput @doc(description: "Deprecated: 'Wishlist' type should be used instead") {
+type WishlistOutput @doc(description: "Deprecated: `Wishlist` type should be used instead") {
items: [WishlistItem] @deprecated(reason: "Use field `items` from type `Wishlist` instead") @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\WishlistItemsResolver") @doc(description: "An array of items in the customer's wish list"),
items_count: Int @deprecated(reason: "Use field `items_count` from type `Wishlist` instead") @doc(description: "The number of items in the wish list"),
- name: String @deprecated(reason: "This field is related to Commerce functionality and is always null in Open source edition") @doc(description: "When multiple wish lists are enabled, the name the customer assigns to the wishlist"),
+ name: String @deprecated(reason: "This field is related to Commerce functionality and is always `null` in Open Source edition") @doc(description: "When multiple wish lists are enabled, the name the customer assigns to the wishlist"),
sharing_code: String @deprecated(reason: "Use field `sharing_code` from type `Wishlist` instead") @doc(description: "An encrypted code that Magento uses to link to the wish list"),
updated_at: String @deprecated(reason: "Use field `updated_at` from type `Wishlist` instead") @doc(description: "The time of the last modification to the wish list")
}
@@ -30,4 +30,4 @@ type WishlistItem {
description: String @doc(description: "The customer's comment about this item"),
added_at: String @doc(description: "The time when the customer added the item to the wish list"),
product: ProductInterface @resolver(class: "\\Magento\\WishlistGraphQl\\Model\\Resolver\\ProductResolver")
-}
\ No newline at end of file
+}
From 1c96b6d5b45e79531241a77433ff185cfdf34268 Mon Sep 17 00:00:00 2001
From: Dmytro Horytskyi
Date: Thu, 24 Oct 2019 10:47:07 -0500
Subject: [PATCH 0612/1978] MC-19646: [Magento Cloud] - Catalog Product Rule
Indexer stuck
---
.../Model/Indexer/IndexBuilder.php | 31 +++++++++++--------
1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
index 2d8ef2b52d2c5..ae76a20cdf762 100644
--- a/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
+++ b/app/code/Magento/CatalogRule/Model/Indexer/IndexBuilder.php
@@ -292,25 +292,30 @@ protected function doReindexByIds($ids)
/** @var Rule[] $activeRules */
$activeRules = $this->getActiveRules()->getItems();
- foreach ($ids as $productId) {
- foreach ($activeRules as $activeRule) {
- $rule = clone $activeRule;
- $rule->setProductsFilter($ids);
- $matchedProductIds = $rule->getMatchingProductIds();
- $matchedProductIds = array_intersect_key($matchedProductIds, array_flip($ids));
- foreach ($matchedProductIds as $matchedProductId => $validationByWebsite) {
- $websiteIds = array_keys(array_filter($validationByWebsite));
- if (empty($websiteIds)) {
- continue;
- }
-
- $this->assignProductToRule($rule, $matchedProductId, $websiteIds);
+ foreach ($activeRules as $activeRule) {
+ $rule = clone $activeRule;
+ $rule->setProductsFilter($ids);
+ $matchedProductIds = $rule->getMatchingProductIds();
+ if (empty($matchedProductIds)) {
+ continue;
+ }
+
+ $matchedProductIds = array_intersect_key($matchedProductIds, array_flip($ids));
+ foreach ($matchedProductIds as $matchedProductId => $validationByWebsite) {
+ $websiteIds = array_keys(array_filter($validationByWebsite));
+ if (empty($websiteIds)) {
+ continue;
}
+
+ $this->assignProductToRule($rule, $matchedProductId, $websiteIds);
}
+ }
+ foreach ($ids as $productId) {
$this->cleanProductPriceIndex([$productId]);
$this->reindexRuleProductPrice->execute($this->batchCount, $productId);
}
+
$this->reindexRuleGroupWebsite->execute();
}
From b72a5c6fa149582bf4ab80360639b040b1f018b5 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 24 Oct 2019 10:47:36 -0500
Subject: [PATCH 0613/1978] magento/graphql-ce#961:
ShippingAddressInput.postcode: String, is not required by Schema
---
.../QuoteGraphQl/Model/Cart/QuoteAddressFactory.php | 8 ++++++--
.../Quote/Customer/SetBillingAddressOnCartTest.php | 8 ++++----
.../Quote/Customer/SetShippingAddressOnCartTest.php | 6 +++---
3 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
index 0fca8a19aa03f..2b0a903a97254 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
@@ -11,6 +11,7 @@
use Magento\CustomerGraphQl\Model\Customer\Address\GetCustomerAddress;
use Magento\Directory\Api\CountryInformationAcquirerInterface;
use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
@@ -58,7 +59,6 @@ public function __construct(
$this->getCustomerAddress = $getCustomerAddress;
$this->addressHelper = $addressHelper;
$this->countryInformationAcquirer = $countryInformationAcquirer;
- $this->countryInformationAcquirer = $countryInformationAcquirer;
}
/**
@@ -78,7 +78,11 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress
}
if ($addressInput['country_id'] && isset($addressInput['region'])) {
- $countryInformation = $this->countryInformationAcquirer->getCountryInfo($addressInput['country_id']);
+ try {
+ $countryInformation = $this->countryInformationAcquirer->getCountryInfo($addressInput['country_id']);
+ } catch (NoSuchEntityException $e) {
+ throw new GraphQlInputException(__('The country isn\'t available.'));
+ }
$availableRegions = $countryInformation->getAvailableRegions();
if (null !== $availableRegions) {
$addressInput['region_code'] = $addressInput['region'];
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index cca126e25896e..da8af077866ee 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -798,7 +798,7 @@ public function testSetNewBillingAddressWithSaveInAddressBook()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -865,7 +865,7 @@ public function testSetNewBillingAddressWithNotSaveInAddressBook()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -933,7 +933,7 @@ public function testWithInvalidBillingAddressInput()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "USS"
telephone: "88776655"
@@ -960,7 +960,7 @@ public function testWithInvalidBillingAddressInput()
}
}
QUERY;
- $this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
+ $this->expectExceptionMessage('The country isn\'t available.');
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
index 2d380785b47f1..9e03c3932cc84 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
@@ -780,7 +780,7 @@ public function testWithInvalidShippingAddressesInput()
}
}
QUERY;
- $this->expectExceptionMessage('The address failed to save. Verify the address and try again.');
+ $this->expectExceptionMessage('The country isn\'t available.');
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
@@ -806,7 +806,7 @@ public function testSetNewShippingAddressWithSaveInAddressBook()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -877,7 +877,7 @@ public function testSetNewShippingAddressWithNotSaveInAddressBook()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
From 90b8b3adf7086b2e37e377b45800be1730b3580f Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 24 Oct 2019 11:02:05 -0500
Subject: [PATCH 0614/1978] MC-21811: Canonical_url displays the backend domain
instead of relative
- add config
---
.../Model/Resolver/Product/CanonicalUrl.php | 22 ++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
index 9616c54676bbe..a4f1cbd7da4df 100644
--- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
+++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
@@ -12,12 +12,25 @@
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
+use Magento\Catalog\Helper\Product as ProductHelper;
+use Magento\Store\Api\Data\StoreInterface;
/**
* Resolve data for product canonical URL
*/
class CanonicalUrl implements ResolverInterface
{
+ /** @var ProductHelper */
+ private $productHelper;
+
+ /**
+ * @param Product $productHelper
+ */
+ public function __construct(ProductHelper $productHelper)
+ {
+ $this->productHelper = $productHelper;
+ }
+
/**
* @inheritdoc
*/
@@ -34,8 +47,11 @@ public function resolve(
/* @var $product Product */
$product = $value['model'];
- $product->getUrlModel()->getUrl($product, ['_ignore_category' => true]);
-
- return $product->getRequestPath();
+ /** @var StoreInterface $store */
+ $store = $context->getExtensionAttributes()->getStore();
+ if ($this->productHelper->canUseCanonicalTag($store)) {
+ $product->getUrlModel()->getUrl($product, ['_ignore_category' => true]);
+ return $product->getRequestPath();
+ }
}
}
From 5ef4f91c1ff2eb61a4b83cda2183beb11dc40c78 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Thu, 24 Oct 2019 19:10:41 +0300
Subject: [PATCH 0615/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../ActionGroup/StorefrontCatalogSearchActionGroup.xml | 6 ++++--
.../Test/Mftf/Test/SearchEntityResultsTest.xml | 7 +++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
index a72762ff796e0..6b489d4576800 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
@@ -51,6 +51,7 @@
+
@@ -66,7 +67,8 @@
-
+
+
@@ -101,7 +103,7 @@
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
index 90b13bd1b6b4f..71da3bc8b10da 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
@@ -364,6 +364,8 @@
+
+
@@ -440,6 +442,7 @@
+
@@ -491,6 +494,7 @@
+
@@ -556,7 +560,10 @@
+
+
+
From 32e778123803022f168dd35f96af58b27e180ef3 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Thu, 24 Oct 2019 11:57:13 -0500
Subject: [PATCH 0616/1978] MC-21906: Customer cannot login after disabling a
configurable product with a coupon in the cart
---
...erCheckoutDisabledProductAndCouponTest.xml | 91 +++++++++++++++++++
.../ResourceModel/Quote/Item/Collection.php | 2 +-
2 files changed, 92 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutDisabledProductAndCouponTest.xml
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutDisabledProductAndCouponTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutDisabledProductAndCouponTest.xml
new file mode 100644
index 0000000000000..0e704e5336db9
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontCustomerCheckoutDisabledProductAndCouponTest.xml
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php
index 392a815ed963c..79fd2b1495c49 100644
--- a/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php
+++ b/app/code/Magento/Quote/Model/ResourceModel/Quote/Item/Collection.php
@@ -276,7 +276,7 @@ protected function _assignProducts(): self
}
}
if ($this->recollectQuote && $this->_quote) {
- $this->_quote->collectTotals();
+ $this->_quote->setTotalsCollectedFlag(false);
}
\Magento\Framework\Profiler::stop('QUOTE:' . __METHOD__);
From d1fa2422a134d40883a68cd063b88561b2c74d29 Mon Sep 17 00:00:00 2001
From: Viktor Tymchynskyi
Date: Wed, 23 Oct 2019 20:05:14 -0500
Subject: [PATCH 0617/1978] MC-22079: MFTF tests stabilization -
StorefrontAddProductsToCartFromWishlistUsingSidebarTest,
StorefrontGuestCheckoutTestWithRestrictedCountriesForPayment
---
.../Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml | 1 +
.../Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml | 3 ++-
...StorefrontAddProductsToCartFromWishlistUsingSidebarTest.xml | 2 ++
3 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml
index dd54c0767e8e1..e33151feff889 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/ApplyCatalogPriceRuleByProductAttributeTest.xml
@@ -229,6 +229,7 @@
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
index b6b9fe1e1a117..1f137fa0e6de9 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
@@ -113,7 +113,8 @@
-
+
+
diff --git a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddProductsToCartFromWishlistUsingSidebarTest.xml b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddProductsToCartFromWishlistUsingSidebarTest.xml
index 16a18dd27b123..689e4ddeb0da0 100644
--- a/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddProductsToCartFromWishlistUsingSidebarTest.xml
+++ b/app/code/Magento/Wishlist/Test/Mftf/Test/StorefrontAddProductsToCartFromWishlistUsingSidebarTest.xml
@@ -26,6 +26,8 @@
+
+
From 53f2618fbd4981e74e4b4f3b4c36149aeed44a56 Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Thu, 24 Oct 2019 14:34:34 -0500
Subject: [PATCH 0618/1978] MC-21524: Schema introspection return incomplete
results
- Added test for introspection test
---
.../GraphQl/IntrospectionQueryTest.php | 118 ++++++++++++++++++
.../Framework/GraphQl/Query/Fields.php | 2 +-
2 files changed, 119 insertions(+), 1 deletion(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/IntrospectionQueryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/IntrospectionQueryTest.php
index 69bcc73dd27a1..0c22bea2a42f8 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/IntrospectionQueryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/IntrospectionQueryTest.php
@@ -56,6 +56,124 @@ public function testIntrospectionQuery()
$this->assertArrayHasKey('__schema', $this->graphQlQuery($query));
}
+ /**
+ * Tests that Introspection is allowed by default
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testIntrospectionQueryWithOnlySchema()
+ {
+ $query
+ = <<assertArrayHasKey('__schema', $this->graphQlQuery($query));
+ $response = $this->graphQlQuery($query);
+
+ $query
+ = <<assertArrayHasKey('__schema', $this->graphQlQuery($query));
+ $responseFields = $this->graphQlQuery($query);
+ $this->assertResponseFields($response, $responseFields);
+ $this->assertEquals($responseFields, $response);
+ }
+
+ /**
+ * Tests that Introspection is allowed by default
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
+ */
+ public function testIntrospectionQueryWithOnlyType()
+ {
+ $query
+ = <<assertArrayHasKey('__type', $this->graphQlQuery($query));
+ $response = $this->graphQlQuery($query);
+ $this->assertNotEmpty($response['__type']['fields']);
+ }
+
/**
* Tests that Introspection Query with deprecated annotations on enum values, fields are read.
*/
diff --git a/lib/internal/Magento/Framework/GraphQl/Query/Fields.php b/lib/internal/Magento/Framework/GraphQl/Query/Fields.php
index f3f4ed7aba23d..e8f71973e773e 100644
--- a/lib/internal/Magento/Framework/GraphQl/Query/Fields.php
+++ b/lib/internal/Magento/Framework/GraphQl/Query/Fields.php
@@ -61,7 +61,7 @@ public function setQuery($query, array $variables = null)
* Get list of fields used in GraphQL query.
*
* This method is stateful and relies on the query being set with setQuery.
- *-
+ *
* @return string[]
*/
public function getFieldsUsedInQuery()
From 8278911e7e5a1d2733b46bcb0b1087beafa505bc Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Thu, 24 Oct 2019 15:24:26 -0500
Subject: [PATCH 0619/1978] MC-16108: [Performance] EAV attribute is not cached
- Add system configuration for caching non user defined attributes;
- Restructure system attributes in di.xml;
---
app/code/Magento/Catalog/Model/Config.php | 7 +-
app/code/Magento/Catalog/etc/di.xml | 222 +++++++++---------
app/code/Magento/Customer/etc/di.xml | 96 ++++----
app/code/Magento/Eav/Model/Config.php | 102 +++++---
app/code/Magento/Eav/etc/adminhtml/system.xml | 21 ++
app/code/Magento/Eav/etc/config.xml | 5 +
6 files changed, 259 insertions(+), 194 deletions(-)
create mode 100644 app/code/Magento/Eav/etc/adminhtml/system.xml
diff --git a/app/code/Magento/Catalog/Model/Config.php b/app/code/Magento/Catalog/Model/Config.php
index 2c06766800c5f..56390766b66bc 100644
--- a/app/code/Magento/Catalog/Model/Config.php
+++ b/app/code/Magento/Catalog/Model/Config.php
@@ -133,7 +133,7 @@ class Config extends \Magento\Eav\Model\Config
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Eav\Model\Config $eavConfig
* @param SerializerInterface $serializer
- * @param array $systemAttributes
+ * @param array $attributesForPreload
*
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
@@ -151,7 +151,7 @@ public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager,
\Magento\Eav\Model\Config $eavConfig,
SerializerInterface $serializer = null,
- $systemAttributes = []
+ $attributesForPreload = []
) {
$this->_scopeConfig = $scopeConfig;
$this->_configFactory = $configFactory;
@@ -168,7 +168,8 @@ public function __construct(
$cacheState,
$universalFactory,
$serializer,
- $systemAttributes
+ $scopeConfig,
+ $attributesForPreload
);
}
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index 5c5f655ad73d9..c312b1f93e01f 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1178,115 +1178,119 @@
-
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
- - catalog_category
+
+ -
+
- catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+
+ -
+
- catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+ - catalog_category
+
diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml
index 3bb8d3fb3f41a..b58b66c43cde8 100644
--- a/app/code/Magento/Customer/etc/di.xml
+++ b/app/code/Magento/Customer/etc/di.xml
@@ -475,52 +475,56 @@
type="Magento\Customer\Model\Delegation\AccountDelegation" />
-
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
+
+ -
+
- customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+
+ -
+
- customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+
diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php
index b01bd7d2b25e4..e5f12ea9ebb1c 100644
--- a/app/code/Magento/Eav/Model/Config.php
+++ b/app/code/Magento/Eav/Model/Config.php
@@ -12,6 +12,7 @@
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Model\AbstractModel;
use Magento\Framework\Serialize\SerializerInterface;
+use Magento\Framework\App\Config\ScopeConfigInterface;
/**
* @api
@@ -28,6 +29,11 @@ class Config
const ATTRIBUTES_CODES_CACHE_ID = 'EAV_ENTITY_ATTRIBUTES_CODES';
/**#@-*/
+ /**
+ * Xml path to non user defined eav caching attributes configuration.
+ */
+ private const XML_PATH_CACHE_NON_USER_DEFINED_ATTRIBUTES = 'dev/caching/cache_non_user_defined_attributes';
+
/**#@-*/
protected $_entityTypeData;
@@ -119,6 +125,11 @@ class Config
*/
private $serializer;
+ /**
+ * @var ScopeConfigInterface
+ */
+ private $scopeConfig;
+
/**
* Cache of attributes per set
*
@@ -134,11 +145,11 @@ class Config
private $isSystemAttributesLoaded = [];
/**
- * List of predefined system attributes.
+ * List of predefined system attributes for preload.
*
* @var array
*/
- private $systemAttributes;
+ private $attributesForPreload;
/**
* @param \Magento\Framework\App\CacheInterface $cache
@@ -147,7 +158,8 @@ class Config
* @param \Magento\Framework\App\Cache\StateInterface $cacheState
* @param \Magento\Framework\Validator\UniversalFactory $universalFactory
* @param SerializerInterface $serializer
- * @param array $systemAttributes
+ * @param ScopeConfigInterface $scopeConfig
+ * @param array $attributesForPreload
* @codeCoverageIgnore
*/
public function __construct(
@@ -157,7 +169,8 @@ public function __construct(
\Magento\Framework\App\Cache\StateInterface $cacheState,
\Magento\Framework\Validator\UniversalFactory $universalFactory,
SerializerInterface $serializer = null,
- $systemAttributes = []
+ ScopeConfigInterface $scopeConfig = null,
+ $attributesForPreload = []
) {
$this->_cache = $cache;
$this->_entityTypeFactory = $entityTypeFactory;
@@ -165,7 +178,8 @@ public function __construct(
$this->_cacheState = $cacheState;
$this->_universalFactory = $universalFactory;
$this->serializer = $serializer ?: ObjectManager::getInstance()->get(SerializerInterface::class);
- $this->systemAttributes = $systemAttributes;
+ $this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
+ $this->attributesForPreload = $attributesForPreload;
}
/**
@@ -527,53 +541,69 @@ public function getAttribute($entityType, $code)
return $this->attributes[$entityTypeCode][$code];
}
- if (array_key_exists($code, $this->systemAttributes)
- && in_array($entityTypeCode, array_values($this->systemAttributes), true)
+ if (array_key_exists($entityTypeCode, $this->attributesForPreload)
+ && array_key_exists($code, $this->attributesForPreload[$entityTypeCode])
) {
- $this->initSystemAttributes($entityType, $this->systemAttributes);
+ $this->initSystemAttributes($entityType, $this->attributesForPreload[$entityTypeCode]);
}
if (isset($this->attributes[$entityTypeCode][$code])) {
\Magento\Framework\Profiler::stop('EAV: ' . __METHOD__);
return $this->attributes[$entityTypeCode][$code];
}
- $cacheKey = self::ATTRIBUTES_CACHE_ID . '-attribute-' . $entityTypeCode . '-' . $code;
- $attributeData = $this->isCacheEnabled() && ($attribute = $this->_cache->load($cacheKey))
- ? $this->serializer->unserialize($attribute)
- : null;
- if ($attributeData) {
- if (isset($attributeData['attribute_id'])) {
- $attribute = $this->_createAttribute($entityType, $attributeData);
+
+ if ($this->scopeConfig->getValue(self::XML_PATH_CACHE_NON_USER_DEFINED_ATTRIBUTES)) {
+ $cacheKey = self::ATTRIBUTES_CACHE_ID . '-attribute-' . $entityTypeCode . '-' . $code;
+ $attributeData = $this->isCacheEnabled() && ($attribute = $this->_cache->load($cacheKey))
+ ? $this->serializer->unserialize($attribute)
+ : null;
+ if ($attributeData) {
+ if (isset($attributeData['attribute_id'])) {
+ $attribute = $this->_createAttribute($entityType, $attributeData);
+ } else {
+ $entityType = $this->getEntityType($entityType);
+ $attribute = $this->createAttribute($entityType->getAttributeModel());
+ $attribute->setAttributeCode($code);
+ $attribute = $this->setAttributeData($attribute, $entityType);
+ }
} else {
- $entityType = $this->getEntityType($entityType);
- $attribute = $this->createAttribute($entityType->getAttributeModel());
- $attribute->setAttributeCode($code);
- $attribute = $this->setAttributeData($attribute, $entityType);
+ $attribute = $this->createAttributeByAttributeCode($entityType, $code);
+ $this->_addAttributeReference(
+ $attribute->getAttributeId(),
+ $attribute->getAttributeCode(),
+ $entityTypeCode
+ );
+ $this->saveAttribute($attribute, $entityTypeCode, $attribute->getAttributeCode());
+ if ($this->isCacheEnabled()) {
+ $this->_cache->save(
+ $this->serializer->serialize($attribute->getData()),
+ $cacheKey,
+ [
+ \Magento\Eav\Model\Cache\Type::CACHE_TAG,
+ \Magento\Eav\Model\Entity\Attribute::CACHE_TAG
+ ]
+ );
+ }
}
} else {
- $attribute = $this->createAttributeByAttributeCode($entityType, $code);
- $this->_addAttributeReference(
- $attribute->getAttributeId(),
- $attribute->getAttributeCode(),
- $entityTypeCode
- );
- $this->saveAttribute($attribute, $entityTypeCode, $attribute->getAttributeCode());
- if ($this->isCacheEnabled()) {
- $this->_cache->save(
- $this->serializer->serialize($attribute->getData()),
- $cacheKey,
- [
- \Magento\Eav\Model\Cache\Type::CACHE_TAG,
- \Magento\Eav\Model\Entity\Attribute::CACHE_TAG
- ]
+ $attributes = $this->loadAttributes($entityTypeCode);
+ $attribute = $attributes[$code] ?? null;
+ if (!$attribute) {
+ $attribute = $this->createAttributeByAttributeCode($entityType, $code);
+ $this->_addAttributeReference(
+ $attribute->getAttributeId(),
+ $attribute->getAttributeCode(),
+ $entityTypeCode
);
+ $this->saveAttribute($attribute, $entityTypeCode, $attribute->getAttributeCode());
}
}
+
\Magento\Framework\Profiler::stop('EAV: ' . __METHOD__);
return $attribute;
}
/**
- * Initialize predefined system attributes.
+ * Initialize predefined system attributes for preload.
*
* @param string $entityType
* @param array $systemAttributes
@@ -755,7 +785,7 @@ protected function _createAttribute($entityType, $attributeData)
$existsFullAttribute = $attribute->hasIsRequired();
$fullAttributeData = array_key_exists('is_required', $attributeData);
- if ($existsFullAttribute || !$existsFullAttribute && !$fullAttributeData) {
+ if ($existsFullAttribute || (!$existsFullAttribute && !$fullAttributeData)) {
return $attribute;
}
}
diff --git a/app/code/Magento/Eav/etc/adminhtml/system.xml b/app/code/Magento/Eav/etc/adminhtml/system.xml
new file mode 100644
index 0000000000000..779d8959eb6de
--- /dev/null
+++ b/app/code/Magento/Eav/etc/adminhtml/system.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+ Caching Settings
+
+ Cache Non User Defined Attributes
+ Magento\Config\Model\Config\Source\Yesno
+ By default only system EAV attributes are cached.
+
+
+
+
+
diff --git a/app/code/Magento/Eav/etc/config.xml b/app/code/Magento/Eav/etc/config.xml
index 2a86437d96abe..a291982030900 100644
--- a/app/code/Magento/Eav/etc/config.xml
+++ b/app/code/Magento/Eav/etc/config.xml
@@ -20,5 +20,10 @@
+
+
+ 0
+
+
From 8ea2d644ac61198e218b14e4eed69a50966b58ca Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Thu, 24 Oct 2019 15:37:44 -0500
Subject: [PATCH 0620/1978] MC-16108: [Performance] EAV attribute is not cached
- Rename configuration path;
---
app/code/Magento/Eav/Model/Config.php | 6 +++---
app/code/Magento/Eav/etc/adminhtml/system.xml | 4 ++--
app/code/Magento/Eav/etc/config.xml | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Eav/Model/Config.php b/app/code/Magento/Eav/Model/Config.php
index e5f12ea9ebb1c..3d115a82aaba6 100644
--- a/app/code/Magento/Eav/Model/Config.php
+++ b/app/code/Magento/Eav/Model/Config.php
@@ -30,9 +30,9 @@ class Config
/**#@-*/
/**
- * Xml path to non user defined eav caching attributes configuration.
+ * Xml path to caching user defined eav attributes configuration.
*/
- private const XML_PATH_CACHE_NON_USER_DEFINED_ATTRIBUTES = 'dev/caching/cache_non_user_defined_attributes';
+ private const XML_PATH_CACHE_USER_DEFINED_ATTRIBUTES = 'dev/caching/cache_user_defined_attributes';
/**#@-*/
protected $_entityTypeData;
@@ -551,7 +551,7 @@ public function getAttribute($entityType, $code)
return $this->attributes[$entityTypeCode][$code];
}
- if ($this->scopeConfig->getValue(self::XML_PATH_CACHE_NON_USER_DEFINED_ATTRIBUTES)) {
+ if ($this->scopeConfig->getValue(self::XML_PATH_CACHE_USER_DEFINED_ATTRIBUTES)) {
$cacheKey = self::ATTRIBUTES_CACHE_ID . '-attribute-' . $entityTypeCode . '-' . $code;
$attributeData = $this->isCacheEnabled() && ($attribute = $this->_cache->load($cacheKey))
? $this->serializer->unserialize($attribute)
diff --git a/app/code/Magento/Eav/etc/adminhtml/system.xml b/app/code/Magento/Eav/etc/adminhtml/system.xml
index 779d8959eb6de..86916abe812d9 100644
--- a/app/code/Magento/Eav/etc/adminhtml/system.xml
+++ b/app/code/Magento/Eav/etc/adminhtml/system.xml
@@ -10,8 +10,8 @@
Caching Settings
-
- Cache Non User Defined Attributes
+
+ Cache User Defined Attributes
Magento\Config\Model\Config\Source\Yesno
By default only system EAV attributes are cached.
diff --git a/app/code/Magento/Eav/etc/config.xml b/app/code/Magento/Eav/etc/config.xml
index a291982030900..c0a4287909b7d 100644
--- a/app/code/Magento/Eav/etc/config.xml
+++ b/app/code/Magento/Eav/etc/config.xml
@@ -22,7 +22,7 @@
- 0
+ 0
From 56382f1a603bf39dbe51098971ebbae1bb4292f1 Mon Sep 17 00:00:00 2001
From: Tomash Khamlai
Date: Thu, 24 Oct 2019 23:41:14 +0300
Subject: [PATCH 0621/1978] Extend coverage for CustomerGraphQL - cover
\Magento\CustomerGraphQl\Model\Customer\Address\ExtractCustomerAddressData
Signed-off-by: Tomash Khamlai
---
.../Address/ExtractCustomerAddressData.php | 2 +
.../Customer/UpdateCustomerAddressTest.php | 57 +++++++++++++++++++
2 files changed, 59 insertions(+)
diff --git a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php
index 7992ca8342921..5a302f4c3df27 100644
--- a/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php
+++ b/app/code/Magento/CustomerGraphQl/Model/Customer/Address/ExtractCustomerAddressData.php
@@ -105,6 +105,7 @@ public function execute(AddressInterface $address): array
foreach ($addressData[CustomAttributesDataInterface::CUSTOM_ATTRIBUTES] as $attribute) {
$isArray = false;
if (is_array($attribute['value'])) {
+ // @ignoreCoverageStart
$isArray = true;
foreach ($attribute['value'] as $attributeValue) {
if (is_array($attributeValue)) {
@@ -116,6 +117,7 @@ public function execute(AddressInterface $address): array
$customAttributes[$attribute['attribute_code']] = implode(',', $attribute['value']);
continue;
}
+ // @ignoreCoverageEnd
}
if ($isArray) {
continue;
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
index e214d770920d0..364d9a969455c 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/UpdateCustomerAddressTest.php
@@ -176,6 +176,63 @@ public function testUpdateCustomerAddressWithMissingAttribute()
$this->graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
}
+ /**
+ * Test custom attributes of the customer's address
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer_address.php
+ * @magentoApiDataFixture Magento/Customer/_files/attribute_user_defined_address_custom_attribute.php
+ */
+ public function testUpdateCustomerAddressHasCustomAndExtensionAttributes()
+ {
+ /** @var AddressRepositoryInterface $addressRepositoryInterface */
+ $addressRepositoryInterface = Bootstrap::getObjectManager()->get(AddressRepositoryInterface::class);
+ /** @var \Magento\Customer\Api\Data\AddressInterface $address */
+ $address = $addressRepositoryInterface->getById(1);
+ $address
+ ->setCustomAttribute('custom_attribute1', '')
+ ->setCustomAttribute('custom_attribute2', '');
+ $addressRepositoryInterface->save($address);
+
+ $userName = 'customer@example.com';
+ $password = 'password';
+ $addressId = 1;
+
+ $mutation
+ = <<graphQlMutation($mutation, [], '', $this->getCustomerAuthHeaders($userName, $password));
+ $actualCustomAttributes = $response['updateCustomerAddress']['custom_attributes'];
+ $this->assertEquals($actualCustomAttributes['0']['attribute_code'], 'custom_attribute1');
+ $this->assertEquals($actualCustomAttributes['0']['value'], '[line1,line2]');
+ $this->assertEquals($actualCustomAttributes['1']['attribute_code'], 'custom_attribute2');
+ $this->assertEquals($actualCustomAttributes['1']['value'], 'line3');
+ }
+
/**
* Verify the fields for Customer address
*
From 2a5460180ff3324ba017a05c1ac08c18ae0200da Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 24 Oct 2019 16:35:52 -0500
Subject: [PATCH 0622/1978] MC-21811: Canonical_url displays the backend domain
instead of relative
- add category implementation
---
.../Model/Resolver/Category/CanonicalUrl.php | 58 +++++++++++++++++++
.../Model/Resolver/Product/CanonicalUrl.php | 2 +-
.../CatalogGraphQl/etc/schema.graphqls | 3 +-
3 files changed, 61 insertions(+), 2 deletions(-)
create mode 100644 app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CanonicalUrl.php
diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CanonicalUrl.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CanonicalUrl.php
new file mode 100644
index 0000000000000..c6810f1618a5b
--- /dev/null
+++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Category/CanonicalUrl.php
@@ -0,0 +1,58 @@
+categoryHelper = $categoryHelper;
+ }
+
+ /**
+ * @inheritdoc
+ */
+ public function resolve(
+ Field $field,
+ $context,
+ ResolveInfo $info,
+ array $value = null,
+ array $args = null
+ ) {
+ if (!isset($value['model'])) {
+ throw new LocalizedException(__('"model" value should be specified'));
+ }
+
+ /* @var Category $category */
+ $category = $value['model'];
+ /** @var StoreInterface $store */
+ $store = $context->getExtensionAttributes()->getStore();
+ if ($this->categoryHelper->canUseCanonicalTag($store)) {
+ $baseUrl = $category->getUrlInstance()->getBaseUrl();
+ return str_replace($baseUrl, '', $category->getUrl());
+ }
+ }
+}
diff --git a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
index a4f1cbd7da4df..9b1d38ebe4be1 100644
--- a/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
+++ b/app/code/Magento/CatalogGraphQl/Model/Resolver/Product/CanonicalUrl.php
@@ -45,7 +45,7 @@ public function resolve(
throw new LocalizedException(__('"model" value should be specified'));
}
- /* @var $product Product */
+ /* @var Product $product */
$product = $value['model'];
/** @var StoreInterface $store */
$store = $context->getExtensionAttributes()->getStore();
diff --git a/app/code/Magento/CatalogGraphQl/etc/schema.graphqls b/app/code/Magento/CatalogGraphQl/etc/schema.graphqls
index 536992d3fca82..057dffe9ed35c 100644
--- a/app/code/Magento/CatalogGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/CatalogGraphQl/etc/schema.graphqls
@@ -109,7 +109,7 @@ interface ProductInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model\
gift_message_available: String @doc(description: "Indicates whether a gift message is available.")
manufacturer: Int @doc(description: "A number representing the product's manufacturer.")
categories: [CategoryInterface] @doc(description: "The categories assigned to a product.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Categories") @cache(cacheIdentity: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CategoriesIdentity")
- canonical_url: String @doc(description: "Canonical URL.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CanonicalUrl")
+ canonical_url: String @doc(description: "Relative canonical URL. This value is returned only if the system setting 'Use Canonical Link Meta Tag For Products' is enabled") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\CanonicalUrl")
media_gallery: [MediaGalleryInterface] @doc(description: "An array of Media Gallery objects.") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Product\\MediaGallery")
}
@@ -223,6 +223,7 @@ interface CategoryInterface @typeResolver(class: "Magento\\CatalogGraphQl\\Model
path_in_store: String @doc(description: "Category path in store.")
url_key: String @doc(description: "The url key assigned to the category.")
url_path: String @doc(description: "The url path assigned to the category.")
+ canonical_url: String @doc(description: "Relative canonical URL. This value is returned only if the system setting 'Use Canonical Link Meta Tag For Categories' is enabled") @resolver(class: "Magento\\CatalogGraphQl\\Model\\Resolver\\Category\\CanonicalUrl")
position: Int @doc(description: "The position of the category relative to other categories at the same level in tree.")
level: Int @doc(description: "Indicates the depth of the category within the tree.")
created_at: String @doc(description: "Timestamp indicating when the category was created.")
From 327d889de2ddd19c96d36f64997f2a274a0e9ca9 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Thu, 24 Oct 2019 16:59:08 -0500
Subject: [PATCH 0623/1978] Revert "Merge remote-tracking branch
'origin/MC-21694-bucket' into MC-19226"
This reverts commit bb6f080422c04925ac3def0f88136797f1641435, reversing
changes made to 1a2ae297f7127daa3295ef3c36fc33772bfaf296.
---
.../AttributeOptionProvider.php | 19 ++----
.../LayeredNavigation/Builder/Attribute.php | 4 +-
.../Catalog/ProductSearchAggregationsTest.php | 64 -------------------
.../_files/product_boolean_attribute.php | 47 --------------
.../product_boolean_attribute_rollback.php | 21 ------
.../products_with_boolean_attribute.php | 35 ----------
...oducts_with_boolean_attribute_rollback.php | 8 ---
7 files changed, 6 insertions(+), 192 deletions(-)
delete mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php
delete mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php
delete mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php
delete mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php
delete mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php
diff --git a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php
index 320e0adc29b9f..7781473128754 100644
--- a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php
+++ b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/AttributeOptionProvider.php
@@ -41,11 +41,10 @@ public function __construct(ResourceConnection $resourceConnection)
* Get option data. Return list of attributes with option data
*
* @param array $optionIds
- * @param array $attributeCodes
* @return array
* @throws \Zend_Db_Statement_Exception
*/
- public function getOptions(array $optionIds, array $attributeCodes = []): array
+ public function getOptions(array $optionIds): array
{
if (!$optionIds) {
return [];
@@ -61,28 +60,20 @@ public function getOptions(array $optionIds, array $attributeCodes = []): array
'attribute_label' => 'a.frontend_label',
]
)
- ->joinLeft(
+ ->joinInner(
['options' => $this->resourceConnection->getTableName('eav_attribute_option')],
'a.attribute_id = options.attribute_id',
[]
)
- ->joinLeft(
+ ->joinInner(
['option_value' => $this->resourceConnection->getTableName('eav_attribute_option_value')],
'options.option_id = option_value.option_id',
[
'option_label' => 'option_value.value',
'option_id' => 'option_value.option_id',
]
- );
-
- $select->where('option_value.option_id IN (?)', $optionIds);
-
- if (!empty($attributeCodes)) {
- $select->orWhere(
- 'a.attribute_code in (?) AND a.frontend_input = \'boolean\'',
- $attributeCodes
- );
- }
+ )
+ ->where('option_value.option_id IN (?)', $optionIds);
return $this->formatResult($select);
}
diff --git a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php
index 0ec65c88024f2..b70c9f6165fc6 100644
--- a/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php
+++ b/app/code/Magento/CatalogGraphQl/DataProvider/Product/LayeredNavigation/Builder/Attribute.php
@@ -139,9 +139,7 @@ private function isBucketEmpty(?BucketInterface $bucket): bool
private function getAttributeOptions(AggregationInterface $aggregation): array
{
$attributeOptionIds = [];
- $attributes = [];
foreach ($this->getAttributeBuckets($aggregation) as $bucket) {
- $attributes[] = \preg_replace('~_bucket$~', '', $bucket->getName());
$attributeOptionIds[] = \array_map(
function (AggregationValueInterface $value) {
return $value->getValue();
@@ -154,6 +152,6 @@ function (AggregationValueInterface $value) {
return [];
}
- return $this->attributeOptionProvider->getOptions(\array_merge(...$attributeOptionIds), $attributes);
+ return $this->attributeOptionProvider->getOptions(\array_merge(...$attributeOptionIds));
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php
deleted file mode 100644
index 113b342ddd79f..0000000000000
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductSearchAggregationsTest.php
+++ /dev/null
@@ -1,64 +0,0 @@
-graphQlQuery($query);
-
- $this->assertArrayNotHasKey('errors', $result);
- $this->assertArrayHasKey('items', $result['products']);
- $this->assertCount(5, $result['products']['items']);
- $this->assertArrayHasKey('aggregations', $result['products']);
-
- $booleanAggregation = array_filter(
- $result['products']['aggregations'],
- function ($a) {
- return $a['attribute_code'] == 'boolean_attribute';
- }
- );
- $this->assertNotEmpty($booleanAggregation);
- $booleanAggregation = reset($booleanAggregation);
- $this->assertEquals('Boolean Attribute', $booleanAggregation['label']);
- $this->assertEquals('boolean_attribute', $booleanAggregation['attribute_code']);
- $this->assertEquals(2, $booleanAggregation['count']);
- $this->assertCount(2, $booleanAggregation['options']);
- $this->assertContains(['label' => '0', 'value'=> '0', 'count' => '2'], $booleanAggregation['options']);
- $this->assertContains(['label' => '1', 'value'=> '1', 'count' => '3'], $booleanAggregation['options']);
- }
-}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php
deleted file mode 100644
index 30900db5690ff..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute.php
+++ /dev/null
@@ -1,47 +0,0 @@
-get(AttributeRepositoryInterface::class);
-/** @var Attribute $attribute */
-$attribute = $objectManager->create(Attribute::class);
-/** @var $installer \Magento\Catalog\Setup\CategorySetup */
-$installer = $objectManager->create(CategorySetup::class);
-
-$attribute->setData(
- [
- 'attribute_code' => 'boolean_attribute',
- 'entity_type_id' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID,
- 'is_global' => 0,
- 'is_user_defined' => 1,
- 'frontend_input' => 'boolean',
- 'is_unique' => 0,
- 'is_required' => 0,
- 'is_searchable' => 1,
- 'is_visible_in_advanced_search' => 1,
- 'is_comparable' => 0,
- 'is_filterable' => 1,
- 'is_filterable_in_search' => 1,
- 'is_used_for_promo_rules' => 0,
- 'is_html_allowed_on_front' => 1,
- 'is_visible_on_front' => 1,
- 'used_in_product_listing' => 1,
- 'used_for_sort_by' => 0,
- 'frontend_label' => ['Boolean Attribute'],
- 'backend_type' => 'int'
- ]
-);
-
-$attributeRepository->save($attribute);
-
-/* Assign attribute to attribute set */
-$installer->addAttributeToGroup('catalog_product', 'Default', 'Attributes', $attribute->getId());
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php
deleted file mode 100644
index c234eb91c84a6..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_boolean_attribute_rollback.php
+++ /dev/null
@@ -1,21 +0,0 @@
-get(Registry::class);
-$registry->unregister('isSecureArea');
-$registry->register('isSecureArea', true);
-/** @var Attribute $attribute */
-$attribute = $objectManager->create(Attribute::class);
-$attribute->load('boolean_attribute', 'attribute_code');
-$attribute->delete();
-$registry->unregister('isSecureArea');
-$registry->register('isSecureArea', false);
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php
deleted file mode 100644
index 65c8c5a251881..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute.php
+++ /dev/null
@@ -1,35 +0,0 @@
-get(ProductRepositoryInterface::class);
-
-$yesIds = [101, 102, 104];
-$noIds = [103, 105];
-
-foreach ($yesIds as $id) {
- $product = $productRepository->getById($id);
- $product->setBooleanAttribute(1);
- $productRepository->save($product);
-}
-foreach ($noIds as $id) {
- $product = $productRepository->getById($id);
- $product->setBooleanAttribute(0);
- $productRepository->save($product);
-}
-CacheCleaner::cleanAll();
-/** @var \Magento\Indexer\Model\Indexer\Collection $indexerCollection */
-$indexerCollection = $objectManager->get(\Magento\Indexer\Model\Indexer\Collection::class);
-$indexerCollection->load();
-/** @var \Magento\Indexer\Model\Indexer $indexer */
-foreach ($indexerCollection->getItems() as $indexer) {
- $indexer->reindexAll();
-}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php
deleted file mode 100644
index 8a70aead1f36d..0000000000000
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/products_with_boolean_attribute_rollback.php
+++ /dev/null
@@ -1,8 +0,0 @@
-
Date: Thu, 24 Oct 2019 18:02:32 -0500
Subject: [PATCH 0624/1978] MC-21811: Canonical_url displays the backend domain
instead of relative
- added test for category canonical_url
---
.../Catalog/CategoryCanonicalUrlTest.php | 89 +++++++++++++++++++
.../Catalog/ProductCanonicalUrlTest.php | 20 ++---
2 files changed, 96 insertions(+), 13 deletions(-)
create mode 100644 dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryCanonicalUrlTest.php
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryCanonicalUrlTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryCanonicalUrlTest.php
new file mode 100644
index 0000000000000..794df3a8b6f44
--- /dev/null
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryCanonicalUrlTest.php
@@ -0,0 +1,89 @@
+objectManager = Bootstrap::getObjectManager();
+ /** @var CategoryCollection $categoryCollection */
+ $categoryCollection = $this->objectManager->create(CategoryCollection::class);
+ $categoryCollection->addFieldToFilter('name', 'Category 1.1.1');
+ /** @var CategoryInterface $category */
+ $category = $categoryCollection->getFirstItem();
+ $categoryId = $category->getId();
+ $query = <<graphQlQuery($query);
+ $this->assertNotEmpty($response['categoryList'], 'Category list should not be empty');
+ $this->assertEquals('.html', $response['categoryList'][0]['url_suffix']);
+ $this->assertEquals(
+ 'category-1/category-1-1/category-1-1-1.html',
+ $response['categoryList'][0]['canonical_url']
+ );
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Catalog/_files/categories.php
+ * @magentoConfigFixture default_store catalog/seo/category_canonical_tag 0
+ */
+ public function testCategoryWithCanonicalLinksMetaTagSettingsDisabled()
+ {
+ $this->objectManager = Bootstrap::getObjectManager();
+ /** @var CategoryCollection $categoryCollection */
+ $categoryCollection = $this->objectManager->create(CategoryCollection::class);
+ $categoryCollection->addFieldToFilter('name', 'Category 1.1');
+ /** @var CategoryInterface $category */
+ $category = $categoryCollection->getFirstItem();
+ $categoryId = $category->getId();
+ $query = <<graphQlQuery($query);
+ $this->assertNotEmpty($response['categoryList'], 'Category list should not be empty');
+ $this->assertNull(
+ $response['categoryList'][0]['canonical_url']
+ );
+ $this->assertEquals('category-1-1', $response['categoryList'][0]['url_key']);
+ }
+}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php
index 9f857121d1fae..308e159b0dd77 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductCanonicalUrlTest.php
@@ -7,24 +7,17 @@
namespace Magento\GraphQl\Catalog;
-use Magento\Catalog\Api\ProductRepositoryInterface;
-use Magento\TestFramework\ObjectManager;
use Magento\TestFramework\TestCase\GraphQlAbstract;
-use Magento\UrlRewrite\Model\UrlFinderInterface;
-use Magento\TestFramework\Helper\Bootstrap;
-use Magento\UrlRewrite\Service\V1\Data\UrlRewrite as UrlRewriteDTO;
/**
- * Test of getting URL rewrites data from products
+ * Test for getting canonical_url for products
*/
class ProductCanonicalUrlTest extends GraphQlAbstract
{
- /** @var ObjectManager $objectManager */
- private $objectManager;
-
/**
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
* @magentoConfigFixture default_store catalog/seo/product_canonical_tag 1
+ *
*/
public function testProductWithCanonicalLinksMetaTagSettingsEnabled()
{
@@ -43,12 +36,13 @@ public function testProductWithCanonicalLinksMetaTagSettingsEnabled()
QUERY;
$response = $this->graphQlQuery($query);
+ $this->assertNotEmpty($response['products']['items']);
$this->assertEquals(
- $response['products']['items'][0]['canonical_url'],
- 'simple-product.html'
+ 'simple-product.html',
+ $response['products']['items'][0]['canonical_url']
);
- $this->assertEquals($response['products']['items'][0]['sku'], 'simple');
+ $this->assertEquals('simple', $response['products']['items'][0]['sku']);
}
/**
@@ -75,6 +69,6 @@ public function testProductWithCanonicalLinksMetaTagSettingsDisabled()
$this->assertNull(
$response['products']['items'][0]['canonical_url']
);
- $this->assertEquals($response['products']['items'][0]['sku'], 'simple');
+ $this->assertEquals('simple', $response['products']['items'][0]['sku']);
}
}
From fa7496aa0a539d5ea641c0a82f29b64200223b78 Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Thu, 24 Oct 2019 18:35:57 -0500
Subject: [PATCH 0625/1978] MC-16108: EAV attribute is not cached
- Define eav attributes per modules;
---
app/code/Magento/Bundle/etc/di.xml | 13 +++++++
app/code/Magento/Catalog/etc/di.xml | 38 -------------------
app/code/Magento/CatalogUrlRewrite/etc/di.xml | 14 +++++++
app/code/Magento/Downloadable/etc/di.xml | 12 ++++++
app/code/Magento/GiftMessage/etc/di.xml | 9 +++++
app/code/Magento/Msrp/etc/di.xml | 10 +++++
app/code/Magento/Swatches/etc/di.xml | 9 +++++
app/code/Magento/Tax/etc/di.xml | 9 +++++
8 files changed, 76 insertions(+), 38 deletions(-)
diff --git a/app/code/Magento/Bundle/etc/di.xml b/app/code/Magento/Bundle/etc/di.xml
index d0e956efee694..6c1a5ab2e7257 100644
--- a/app/code/Magento/Bundle/etc/di.xml
+++ b/app/code/Magento/Bundle/etc/di.xml
@@ -221,4 +221,17 @@
+
+
+
+ -
+
- catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+
+
+
+
diff --git a/app/code/Magento/Catalog/etc/di.xml b/app/code/Magento/Catalog/etc/di.xml
index c312b1f93e01f..7e79229cb62b9 100644
--- a/app/code/Magento/Catalog/etc/di.xml
+++ b/app/code/Magento/Catalog/etc/di.xml
@@ -1180,8 +1180,6 @@
-
-
- catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
@@ -1191,72 +1189,39 @@
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- catalog_product
- catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- - catalog_product
- catalog_product
- catalog_product
- - catalog_product
-
- catalog_category
@@ -1284,12 +1249,9 @@
- catalog_category
- catalog_category
- catalog_category
- - catalog_category
- catalog_category
- catalog_category
- catalog_category
- - catalog_category
- - catalog_category
diff --git a/app/code/Magento/CatalogUrlRewrite/etc/di.xml b/app/code/Magento/CatalogUrlRewrite/etc/di.xml
index 2a74b5cd92b28..5fb7d33546d60 100644
--- a/app/code/Magento/CatalogUrlRewrite/etc/di.xml
+++ b/app/code/Magento/CatalogUrlRewrite/etc/di.xml
@@ -56,4 +56,18 @@
+
+
+
+ -
+
- catalog_product
+ - catalog_product
+
+ -
+
- catalog_category
+ - catalog_category
+
+
+
+
diff --git a/app/code/Magento/Downloadable/etc/di.xml b/app/code/Magento/Downloadable/etc/di.xml
index a932e5598f8ae..3dc592958588c 100644
--- a/app/code/Magento/Downloadable/etc/di.xml
+++ b/app/code/Magento/Downloadable/etc/di.xml
@@ -174,4 +174,16 @@
+
+
+
+ -
+
- catalog_product
+ - catalog_product
+ - catalog_product
+ - catalog_product
+
+
+
+
diff --git a/app/code/Magento/GiftMessage/etc/di.xml b/app/code/Magento/GiftMessage/etc/di.xml
index 1d03849d978b8..5333084c90b75 100644
--- a/app/code/Magento/GiftMessage/etc/di.xml
+++ b/app/code/Magento/GiftMessage/etc/di.xml
@@ -28,4 +28,13 @@
+
+
+
+ -
+
- catalog_product
+
+
+
+
diff --git a/app/code/Magento/Msrp/etc/di.xml b/app/code/Magento/Msrp/etc/di.xml
index b8392b0bb0fe4..e617e153fd951 100644
--- a/app/code/Magento/Msrp/etc/di.xml
+++ b/app/code/Magento/Msrp/etc/di.xml
@@ -53,4 +53,14 @@
+
+
+
+ -
+
- catalog_product
+ - catalog_product
+
+
+
+
diff --git a/app/code/Magento/Swatches/etc/di.xml b/app/code/Magento/Swatches/etc/di.xml
index 585cef924e928..53672a422e47d 100644
--- a/app/code/Magento/Swatches/etc/di.xml
+++ b/app/code/Magento/Swatches/etc/di.xml
@@ -84,4 +84,13 @@
+
+
+
+ -
+
- catalog_product
+
+
+
+
diff --git a/app/code/Magento/Tax/etc/di.xml b/app/code/Magento/Tax/etc/di.xml
index a0b43df226f22..50683b1b879e6 100644
--- a/app/code/Magento/Tax/etc/di.xml
+++ b/app/code/Magento/Tax/etc/di.xml
@@ -183,4 +183,13 @@
+
+
+
+ -
+
- catalog_product
+
+
+
+
From c11c4760929450e9d8ae76aab752b20aae49afe8 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Fri, 25 Oct 2019 06:11:43 +0530
Subject: [PATCH 0626/1978] Fixed deprecated method usages of MessageManager
---
app/code/Magento/Wishlist/Controller/Index/Cart.php | 4 ++--
.../Magento/Wishlist/Controller/Index/Configure.php | 4 ++--
.../Magento/Wishlist/Controller/Index/Remove.php | 4 ++--
app/code/Magento/Wishlist/Controller/Index/Send.php | 6 +++---
.../Magento/Wishlist/Controller/Index/Update.php | 6 +++---
.../Wishlist/Controller/Index/UpdateItemOptions.php | 8 ++++----
app/code/Magento/Wishlist/Controller/Shared/Cart.php | 8 ++++----
.../Magento/Wishlist/Controller/WishlistProvider.php | 4 ++--
app/code/Magento/Wishlist/Model/ItemCarrier.php | 6 +++---
app/code/Magento/Wishlist/Observer/AddToCart.php | 2 +-
.../Wishlist/Test/Unit/Controller/Index/CartTest.php | 6 +++---
.../Test/Unit/Controller/Index/RemoveTest.php | 6 +++---
.../Unit/Controller/Index/UpdateItemOptionsTest.php | 12 ++++++------
.../Test/Unit/Controller/Shared/CartTest.php | 2 +-
.../Wishlist/Test/Unit/Model/ItemCarrierTest.php | 12 ++++++------
.../Wishlist/Test/Unit/Observer/AddToCartTest.php | 2 +-
16 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/app/code/Magento/Wishlist/Controller/Index/Cart.php b/app/code/Magento/Wishlist/Controller/Index/Cart.php
index da37609d688e7..870c4231f97c9 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Cart.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Cart.php
@@ -186,7 +186,7 @@ public function execute()
'You added %1 to your shopping cart.',
$this->escaper->escapeHtml($item->getProduct()->getName())
);
- $this->messageManager->addSuccess($message);
+ $this->messageManager->addSuccessMessage($message);
}
if ($this->cartHelper->getShouldRedirectToCart()) {
@@ -214,7 +214,7 @@ public function execute()
$resultJson->setData(['backUrl' => $redirectUrl]);
return $resultJson;
}
-
+
$resultRedirect->setUrl($redirectUrl);
return $resultRedirect;
}
diff --git a/app/code/Magento/Wishlist/Controller/Index/Configure.php b/app/code/Magento/Wishlist/Controller/Index/Configure.php
index 93a05ffc0ec93..35bf7f29b85c9 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Configure.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Configure.php
@@ -102,11 +102,11 @@ public function execute()
return $resultPage;
} catch (\Magento\Framework\Exception\LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
$resultRedirect->setPath('*');
return $resultRedirect;
} catch (\Exception $e) {
- $this->messageManager->addError(__('We can\'t configure the product right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t configure the product right now.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
$resultRedirect->setPath('*');
return $resultRedirect;
diff --git a/app/code/Magento/Wishlist/Controller/Index/Remove.php b/app/code/Magento/Wishlist/Controller/Index/Remove.php
index 84c59b5be3d1e..afe7d46492ac6 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Remove.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Remove.php
@@ -88,11 +88,11 @@ public function execute()
]
);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
- $this->messageManager->addError(
+ $this->messageManager->addErrorMessage(
__('We can\'t delete the item from Wish List right now because of an error: %1.', $e->getMessage())
);
} catch (\Exception $e) {
- $this->messageManager->addError(__('We can\'t delete the item from the Wish List right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t delete the item from the Wish List right now.'));
}
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
diff --git a/app/code/Magento/Wishlist/Controller/Index/Send.php b/app/code/Magento/Wishlist/Controller/Index/Send.php
index 5d867ac74752b..54aa53d829db5 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Send.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Send.php
@@ -219,7 +219,7 @@ public function execute()
}
if ($error) {
- $this->messageManager->addError($error);
+ $this->messageManager->addErrorMessage($error);
$this->wishlistSession->setSharingForm($this->getRequest()->getPostValue());
$resultRedirect->setPath('*/*/share');
return $resultRedirect;
@@ -285,12 +285,12 @@ public function execute()
$this->inlineTranslation->resume();
$this->_eventManager->dispatch('wishlist_share', ['wishlist' => $wishlist]);
- $this->messageManager->addSuccess(__('Your wish list has been shared.'));
+ $this->messageManager->addSuccessMessage(__('Your wish list has been shared.'));
$resultRedirect->setPath('*/*', ['wishlist_id' => $wishlist->getId()]);
return $resultRedirect;
} catch (\Exception $e) {
$this->inlineTranslation->resume();
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
$this->wishlistSession->setSharingForm($this->getRequest()->getPostValue());
$resultRedirect->setPath('*/*/share');
return $resultRedirect;
diff --git a/app/code/Magento/Wishlist/Controller/Index/Update.php b/app/code/Magento/Wishlist/Controller/Index/Update.php
index b56aa4b5b3c8d..e5fbd4b93f82e 100644
--- a/app/code/Magento/Wishlist/Controller/Index/Update.php
+++ b/app/code/Magento/Wishlist/Controller/Index/Update.php
@@ -103,7 +103,7 @@ public function execute()
$item->delete();
} catch (\Exception $e) {
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
- $this->messageManager->addError(__('We can\'t delete item from Wish List right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t delete item from Wish List right now.'));
}
}
@@ -118,7 +118,7 @@ public function execute()
);
$updatedItems++;
} catch (\Exception $e) {
- $this->messageManager->addError(
+ $this->messageManager->addErrorMessage(
__(
'Can\'t save description %1',
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($description)
@@ -133,7 +133,7 @@ public function execute()
$wishlist->save();
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
} catch (\Exception $e) {
- $this->messageManager->addError(__('Can\'t update wish list'));
+ $this->messageManager->addErrorMessage(__('Can\'t update wish list'));
}
}
diff --git a/app/code/Magento/Wishlist/Controller/Index/UpdateItemOptions.php b/app/code/Magento/Wishlist/Controller/Index/UpdateItemOptions.php
index 2a98fa1b7fcd5..06881d5bb289f 100644
--- a/app/code/Magento/Wishlist/Controller/Index/UpdateItemOptions.php
+++ b/app/code/Magento/Wishlist/Controller/Index/UpdateItemOptions.php
@@ -85,7 +85,7 @@ public function execute()
}
if (!$product || !$product->isVisibleInCatalog()) {
- $this->messageManager->addError(__('We can\'t specify a product.'));
+ $this->messageManager->addErrorMessage(__('We can\'t specify a product.'));
$resultRedirect->setPath('*/');
return $resultRedirect;
}
@@ -114,11 +114,11 @@ public function execute()
$this->_objectManager->get(\Magento\Wishlist\Helper\Data::class)->calculate();
$message = __('%1 has been updated in your Wish List.', $product->getName());
- $this->messageManager->addSuccess($message);
+ $this->messageManager->addSuccessMessage($message);
} catch (\Magento\Framework\Exception\LocalizedException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
} catch (\Exception $e) {
- $this->messageManager->addError(__('We can\'t update your Wish List right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t update your Wish List right now.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e);
}
$resultRedirect->setPath('*/*', ['wishlist_id' => $wishlist->getId()]);
diff --git a/app/code/Magento/Wishlist/Controller/Shared/Cart.php b/app/code/Magento/Wishlist/Controller/Shared/Cart.php
index b41b51057636f..1cff83f8813d6 100644
--- a/app/code/Magento/Wishlist/Controller/Shared/Cart.php
+++ b/app/code/Magento/Wishlist/Controller/Shared/Cart.php
@@ -103,19 +103,19 @@ public function execute()
'You added %1 to your shopping cart.',
$this->escaper->escapeHtml($item->getProduct()->getName())
);
- $this->messageManager->addSuccess($message);
+ $this->messageManager->addSuccessMessage($message);
}
if ($this->cartHelper->getShouldRedirectToCart()) {
$redirectUrl = $this->cartHelper->getCartUrl();
}
} catch (ProductException $e) {
- $this->messageManager->addError(__('This product(s) is out of stock.'));
+ $this->messageManager->addErrorMessage(__('This product(s) is out of stock.'));
} catch (LocalizedException $e) {
- $this->messageManager->addNotice($e->getMessage());
+ $this->messageManager->addNoticeMessage($e->getMessage());
$redirectUrl = $item->getProductUrl();
} catch (\Exception $e) {
- $this->messageManager->addException($e, __('We can\'t add the item to the cart right now.'));
+ $this->messageManager->addExceptionMessage($e, __('We can\'t add the item to the cart right now.'));
}
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
diff --git a/app/code/Magento/Wishlist/Controller/WishlistProvider.php b/app/code/Magento/Wishlist/Controller/WishlistProvider.php
index 4740ea9947ef7..4dbcc25bfd180 100644
--- a/app/code/Magento/Wishlist/Controller/WishlistProvider.php
+++ b/app/code/Magento/Wishlist/Controller/WishlistProvider.php
@@ -85,10 +85,10 @@ public function getWishlist($wishlistId = null)
);
}
} catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($e->getMessage());
return false;
} catch (\Exception $e) {
- $this->messageManager->addException($e, __('We can\'t create the Wish List right now.'));
+ $this->messageManager->addExceptionMessage($e, __('We can\'t create the Wish List right now.'));
return false;
}
$this->wishlist = $wishlist;
diff --git a/app/code/Magento/Wishlist/Model/ItemCarrier.php b/app/code/Magento/Wishlist/Model/ItemCarrier.php
index 6cf295084eca8..b791992b78312 100644
--- a/app/code/Magento/Wishlist/Model/ItemCarrier.php
+++ b/app/code/Magento/Wishlist/Model/ItemCarrier.php
@@ -182,7 +182,7 @@ public function moveAllToCart(Wishlist $wishlist, $qtys)
if ($messages) {
foreach ($messages as $message) {
- $this->messageManager->addError($message);
+ $this->messageManager->addErrorMessage($message);
}
$redirectUrl = $indexUrl;
}
@@ -192,7 +192,7 @@ public function moveAllToCart(Wishlist $wishlist, $qtys)
try {
$wishlist->save();
} catch (\Exception $e) {
- $this->messageManager->addError(__('We can\'t update the Wish List right now.'));
+ $this->messageManager->addErrorMessage(__('We can\'t update the Wish List right now.'));
$redirectUrl = $indexUrl;
}
@@ -202,7 +202,7 @@ public function moveAllToCart(Wishlist $wishlist, $qtys)
$products[] = '"' . $product->getName() . '"';
}
- $this->messageManager->addSuccess(
+ $this->messageManager->addSuccessMessage(
__('%1 product(s) have been added to shopping cart: %2.', count($addedProducts), join(', ', $products))
);
diff --git a/app/code/Magento/Wishlist/Observer/AddToCart.php b/app/code/Magento/Wishlist/Observer/AddToCart.php
index 1ab24d87efbf7..c5e52a373a2bf 100644
--- a/app/code/Magento/Wishlist/Observer/AddToCart.php
+++ b/app/code/Magento/Wishlist/Observer/AddToCart.php
@@ -105,7 +105,7 @@ public function execute(Observer $observer)
$this->checkoutSession->setWishlistPendingUrls($urls);
$this->checkoutSession->setWishlistPendingMessages($messages);
- $this->messageManager->addError($message);
+ $this->messageManager->addErrorMessage($message);
$observer->getEvent()->getResponse()->setRedirect($url);
$this->checkoutSession->setNoCartRedirect(true);
diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/CartTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/CartTest.php
index e9061f1f3d5f8..c1f1378c22da6 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/CartTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/CartTest.php
@@ -172,7 +172,7 @@ protected function setUp()
$this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
->disableOriginalConstructor()
- ->setMethods(['addSuccess'])
+ ->setMethods(['addSuccessMessage'])
->getMockForAbstractClass();
$this->urlMock = $this->getMockBuilder(\Magento\Framework\UrlInterface::class)
@@ -566,7 +566,7 @@ protected function prepareExecuteWithQuantityArray($isAjax = false)
->willReturn($productName);
$this->messageManagerMock->expects($this->once())
- ->method('addSuccess')
+ ->method('addSuccessMessage')
->with('You added ' . $productName . ' to your shopping cart.', null)
->willReturnSelf();
@@ -581,7 +581,7 @@ protected function prepareExecuteWithQuantityArray($isAjax = false)
$this->helperMock->expects($this->once())
->method('calculate')
->willReturnSelf();
-
+
return $refererUrl;
}
diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php
index bb4ae44fcc31d..2f4d0e6ba48ab 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/RemoveTest.php
@@ -244,7 +244,7 @@ public function testExecuteWithoutWishlist()
->method('create')
->with(\Magento\Wishlist\Model\Item::class)
->willReturn($item);
-
+
$this->wishlistProvider
->expects($this->once())
->method('getWishlist')
@@ -273,7 +273,7 @@ public function testExecuteCanNotSaveWishlist()
$this->messageManager
->expects($this->once())
- ->method('addError')
+ ->method('addErrorMessage')
->with('We can\'t delete the item from Wish List right now because of an error: Message.')
->willReturn(true);
@@ -356,7 +356,7 @@ public function testExecuteCanNotSaveWishlistAndWithRedirect()
$this->messageManager
->expects($this->once())
- ->method('addError')
+ ->method('addErrorMessage')
->with('We can\'t delete the item from the Wish List right now.')
->willReturn(true);
diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php
index 0c2d7765b1ff2..b6fd509214897 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Index/UpdateItemOptionsTest.php
@@ -249,7 +249,7 @@ public function testExecuteWithoutProduct()
$this->messageManager
->expects($this->once())
- ->method('addError')
+ ->method('addErrorMessage')
->with('We can\'t specify a product.')
->willReturn(true);
$this->resultRedirectMock->expects($this->once())
@@ -294,7 +294,7 @@ public function testExecuteWithoutWishList()
$this->messageManager
->expects($this->never())
- ->method('addError')
+ ->method('addErrorMessage')
->with('We can\'t specify a product.')
->willReturn(true);
@@ -433,12 +433,12 @@ public function testExecuteAddSuccessException()
$this->messageManager
->expects($this->once())
- ->method('addSuccess')
+ ->method('addSuccessMessage')
->with('Test name has been updated in your Wish List.', null)
->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('error-message')));
$this->messageManager
->expects($this->once())
- ->method('addError')
+ ->method('addErrorMessage')
->with('error-message', null)
->willReturn(true);
$this->resultRedirectMock->expects($this->once())
@@ -572,12 +572,12 @@ public function testExecuteAddSuccessCriticalException()
$this->messageManager
->expects($this->once())
- ->method('addSuccess')
+ ->method('addSuccessMessage')
->with('Test name has been updated in your Wish List.', null)
->willThrowException($exception);
$this->messageManager
->expects($this->once())
- ->method('addError')
+ ->method('addErrorMessage')
->with('We can\'t update your Wish List right now.', null)
->willReturn(true);
$this->resultRedirectMock->expects($this->once())
diff --git a/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/CartTest.php b/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/CartTest.php
index 118c27ae3eee2..c65f166957c5f 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/CartTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Controller/Shared/CartTest.php
@@ -266,7 +266,7 @@ public function testExecute(
$successMessage = __('You added %1 to your shopping cart.', $productName);
$this->messageManager->expects($this->any())
- ->method('addSuccess')
+ ->method('addSuccessMessage')
->with($successMessage)
->willReturnSelf();
diff --git a/app/code/Magento/Wishlist/Test/Unit/Model/ItemCarrierTest.php b/app/code/Magento/Wishlist/Test/Unit/Model/ItemCarrierTest.php
index 43f77e00bdf98..71ae2d182d0e4 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Model/ItemCarrierTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Model/ItemCarrierTest.php
@@ -228,7 +228,7 @@ public function testMoveAllToCart()
->willReturn($productTwoName);
$this->managerMock->expects($this->once())
- ->method('addSuccess')
+ ->method('addSuccessMessage')
->with(__('%1 product(s) have been added to shopping cart: %2.', 1, '"' . $productTwoName . '"'), null)
->willReturnSelf();
@@ -431,12 +431,12 @@ public function testMoveAllToCartWithNotSalableAndOptions()
->willReturn($productTwoName);
$this->managerMock->expects($this->at(0))
- ->method('addError')
+ ->method('addErrorMessage')
->with(__('%1 for "%2".', 'Localized Exception', $productTwoName), null)
->willReturnSelf();
$this->managerMock->expects($this->at(1))
- ->method('addError')
+ ->method('addErrorMessage')
->with(
__(
'We couldn\'t add the following product(s) to the shopping cart: %1.',
@@ -580,7 +580,7 @@ public function testMoveAllToCartWithException()
->with($exception, []);
$this->managerMock->expects($this->at(0))
- ->method('addError')
+ ->method('addErrorMessage')
->with(__('We can\'t add this item to your shopping cart right now.'), null)
->willReturnSelf();
@@ -603,7 +603,7 @@ public function testMoveAllToCartWithException()
->willThrowException(new \Exception());
$this->managerMock->expects($this->at(1))
- ->method('addError')
+ ->method('addErrorMessage')
->with(__('We can\'t update the Wish List right now.'), null)
->willReturnSelf();
@@ -615,7 +615,7 @@ public function testMoveAllToCartWithException()
->willReturn($productTwoName);
$this->managerMock->expects($this->once())
- ->method('addSuccess')
+ ->method('addSuccessMessage')
->with(__('%1 product(s) have been added to shopping cart: %2.', 1, '"' . $productOneName . '"'), null)
->willReturnSelf();
diff --git a/app/code/Magento/Wishlist/Test/Unit/Observer/AddToCartTest.php b/app/code/Magento/Wishlist/Test/Unit/Observer/AddToCartTest.php
index e6e14a452a96d..af12cc8878aaa 100644
--- a/app/code/Magento/Wishlist/Test/Unit/Observer/AddToCartTest.php
+++ b/app/code/Magento/Wishlist/Test/Unit/Observer/AddToCartTest.php
@@ -167,7 +167,7 @@ public function testExecute()
->with([])
->willReturnSelf();
$this->messageManager->expects($this->once())
- ->method('addError')
+ ->method('addErrorMessage')
->with($message)
->willReturnSelf();
$event->expects($this->once())
From c9831db2d0b20f0c0319427e32f0e2e22a897d33 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Fri, 25 Oct 2019 05:42:47 +0530
Subject: [PATCH 0627/1978] Fixed code style issues
---
.../Controller/Adminhtml/Product/MassVisibleIn.php | 9 ++++++++-
.../Review/Controller/Adminhtml/Rating/Delete.php | 5 +++++
.../Magento/Review/Controller/Adminhtml/Rating/Save.php | 3 +++
app/code/Magento/Review/Controller/Product/Post.php | 3 +++
4 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php b/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php
index 246a513023717..1f82d4846ede3 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Product/MassVisibleIn.php
@@ -5,13 +5,20 @@
*/
namespace Magento\Review\Controller\Adminhtml\Product;
+use Magento\Framework\App\Action\HttpPostActionInterface;
use Magento\Review\Controller\Adminhtml\Product as ProductController;
use Magento\Framework\Exception\LocalizedException;
use Magento\Framework\Controller\ResultFactory;
-class MassVisibleIn extends ProductController
+/**
+ * Class MassVisibleIn
+ */
+class MassVisibleIn extends ProductController implements HttpPostActionInterface
{
+
/**
+ * Execute action
+ *
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
index 77c331ba883e9..03a73d431221f 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Delete.php
@@ -9,9 +9,14 @@
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
+/**
+ * Class Delete
+ */
class Delete extends RatingController implements HttpPostActionInterface
{
/**
+ * Delete action
+ *
* @return \Magento\Backend\Model\View\Result\Redirect
*/
public function execute()
diff --git a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
index 7ae3ad6c54f79..ebb4b2a01e286 100644
--- a/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
+++ b/app/code/Magento/Review/Controller/Adminhtml/Rating/Save.php
@@ -9,6 +9,9 @@
use Magento\Review\Controller\Adminhtml\Rating as RatingController;
use Magento\Framework\Controller\ResultFactory;
+/**
+ * Class Save
+ */
class Save extends RatingController implements HttpPostActionInterface
{
/**
diff --git a/app/code/Magento/Review/Controller/Product/Post.php b/app/code/Magento/Review/Controller/Product/Post.php
index 3677eaa0f9c2a..2928fdce16c9b 100644
--- a/app/code/Magento/Review/Controller/Product/Post.php
+++ b/app/code/Magento/Review/Controller/Product/Post.php
@@ -10,6 +10,9 @@
use Magento\Framework\Controller\ResultFactory;
use Magento\Review\Model\Review;
+/**
+ * Class Post
+ */
class Post extends ProductController implements HttpPostActionInterface
{
/**
From 83a7770532c020a71a09294db4fa3ed7bfe43851 Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 24 Oct 2019 20:19:05 -0500
Subject: [PATCH 0628/1978] MC-18685: Remove custom layout updates from admin
---
.../Adminhtml/Product/Initialization/Helper.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
index 5644c2f601a9d..62bcb1c8cd6d7 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Initialization/Helper.php
@@ -128,8 +128,8 @@ class Helper
* @param ProductRepositoryInterface|null $productRepository
* @param LinkTypeProvider|null $linkTypeProvider
* @param AttributeFilter|null $attributeFilter
- * @param ProductAuthorization|null $productAuthorization
* @param FormatInterface|null $localeFormat
+ * @param ProductAuthorization|null $productAuthorization
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -144,8 +144,8 @@ public function __construct(
ProductRepositoryInterface $productRepository = null,
LinkTypeProvider $linkTypeProvider = null,
AttributeFilter $attributeFilter = null,
- ?ProductAuthorization $productAuthorization = null,
- FormatInterface $localeFormat = null
+ FormatInterface $localeFormat = null,
+ ?ProductAuthorization $productAuthorization = null
) {
$this->request = $request;
$this->storeManager = $storeManager;
@@ -160,8 +160,8 @@ public function __construct(
$this->productRepository = $productRepository ?: $objectManager->get(ProductRepositoryInterface::class);
$this->linkTypeProvider = $linkTypeProvider ?: $objectManager->get(LinkTypeProvider::class);
$this->attributeFilter = $attributeFilter ?: $objectManager->get(AttributeFilter::class);
- $this->productAuthorization = $productAuthorization ?? $objectManager->get(ProductAuthorization::class);
$this->localeFormat = $localeFormat ?: $objectManager->get(FormatInterface::class);
+ $this->productAuthorization = $productAuthorization ?? $objectManager->get(ProductAuthorization::class);
}
/**
From fd9bbcdf5ad4c58ef11a72626dc4a9744211094d Mon Sep 17 00:00:00 2001
From: Ji Lu
Date: Thu, 24 Oct 2019 21:32:34 -0500
Subject: [PATCH 0629/1978] MQE-1853: convert CreateOrderBackendTest variation
18 and 19 to MFTF
---
.../Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 3 ++-
.../Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml | 5 +++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 6ac7be5757a76..9c57ecf70ebc0 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -14,7 +14,8 @@
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
index bca87cbae77e7..248219951a251 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
@@ -14,7 +14,8 @@
-
+
+
@@ -32,7 +33,7 @@
-
+
From d80bffc818462d4c888ce32466ab141db0a105c4 Mon Sep 17 00:00:00 2001
From: Ji Lu
Date: Thu, 24 Oct 2019 22:48:48 -0500
Subject: [PATCH 0630/1978] MQE-1854: convert ExpireSessionTest to MFTF
---
.../Test/Mftf/Test/AdminExpireAdminSessionTest.xml | 11 ++++++-----
.../Mftf/Test/AdminExpireCustomerSessionTest.xml | 13 +++++++------
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
index 1ed8cc9e9aa6d..88d26c052b59b 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireAdminSessionTest.xml
@@ -10,12 +10,13 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
+
-
-
-
-
-
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
index 9e3301e4a26a3..88646401e3a99 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminExpireCustomerSessionTest.xml
@@ -10,12 +10,13 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
-
-
-
-
-
-
+
+
+
+
+
+
+
From 13d746d486b6adf014c5e1de18fb4300d87644b6 Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Fri, 25 Oct 2019 10:17:57 +0530
Subject: [PATCH 0631/1978] Fixed MFTF deprecation errors
---
.../AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml | 1 +
.../AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml | 1 +
.../DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml | 1 +
...minProductBackRedirectNavigateFromCustomerViewCartProduct.xml | 1 +
.../Test/AdminProductImportCSVFileCorrectDifferentFilesTest.xml | 1 +
.../Swatches/Test/Mftf/Test/AdminDisablingSwatchTooltipsTest.xml | 1 +
.../Mftf/Test/AdminFixedTaxValSavedForSpecificWebsiteTest.xml | 1 +
7 files changed, 7 insertions(+)
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml
index 59a6a7e261b87..47b8715b5541c 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInDeveloperModeTest.xml
@@ -11,6 +11,7 @@
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml
index 2dade727ca411..ae7722b225cdd 100644
--- a/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Test/AdminCheckLocaleAndDeveloperConfigInProductionModeTest.xml
@@ -11,6 +11,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
index 5a94dd4f04d24..cce034f9f03ba 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
@@ -11,6 +11,7 @@
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminProductBackRedirectNavigateFromCustomerViewCartProduct.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminProductBackRedirectNavigateFromCustomerViewCartProduct.xml
index 9de2339f2e217..b5db354d54371 100644
--- a/app/code/Magento/Customer/Test/Mftf/Test/AdminProductBackRedirectNavigateFromCustomerViewCartProduct.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminProductBackRedirectNavigateFromCustomerViewCartProduct.xml
@@ -11,6 +11,7 @@
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductImportCSVFileCorrectDifferentFilesTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductImportCSVFileCorrectDifferentFilesTest.xml
index eb84929ec8d93..56c1c43bc28d2 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductImportCSVFileCorrectDifferentFilesTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminProductImportCSVFileCorrectDifferentFilesTest.xml
@@ -12,6 +12,7 @@
+
diff --git a/app/code/Magento/Swatches/Test/Mftf/Test/AdminDisablingSwatchTooltipsTest.xml b/app/code/Magento/Swatches/Test/Mftf/Test/AdminDisablingSwatchTooltipsTest.xml
index 3d69895b0c895..2ffc61614bd1d 100644
--- a/app/code/Magento/Swatches/Test/Mftf/Test/AdminDisablingSwatchTooltipsTest.xml
+++ b/app/code/Magento/Swatches/Test/Mftf/Test/AdminDisablingSwatchTooltipsTest.xml
@@ -11,6 +11,7 @@
+
diff --git a/app/code/Magento/Weee/Test/Mftf/Test/AdminFixedTaxValSavedForSpecificWebsiteTest.xml b/app/code/Magento/Weee/Test/Mftf/Test/AdminFixedTaxValSavedForSpecificWebsiteTest.xml
index 85ed044644d5c..aeb8537313fae 100644
--- a/app/code/Magento/Weee/Test/Mftf/Test/AdminFixedTaxValSavedForSpecificWebsiteTest.xml
+++ b/app/code/Magento/Weee/Test/Mftf/Test/AdminFixedTaxValSavedForSpecificWebsiteTest.xml
@@ -11,6 +11,7 @@
+
From 552bb8a857662d67fa89573dd43df3547a4a98d7 Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Fri, 25 Oct 2019 09:48:29 +0300
Subject: [PATCH 0632/1978] MC-20449: [Integration Test]Hide product images via
hide_from_product_page attribute during import CSV
---
.../Magento/CatalogImportExport/Model/Import/ProductTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
index a0d02a4a83870..6b1285018d50e 100644
--- a/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Import/ProductTest.php
@@ -2628,12 +2628,12 @@ public function testImagesAreHiddenAfterImport(): void
$actualAllProductImages = [];
$product = $this->getProductBySku('simple');
- // Check that new images are imported and existing image is disabled after import
+ // Check that new images were imported and existing image is disabled after import
$productMediaData = $product->getData('media_gallery');
$this->assertNotEmpty($productMediaData['images']);
$allProductImages = $productMediaData['images'];
- $this->assertCount(3, $allProductImages, 'Images are imported incorrect');
+ $this->assertCount(3, $allProductImages, 'Images were imported incorrectly');
foreach ($allProductImages as $image) {
$actualAllProductImages[] = [
From 459121b0bce215bdb9a0fd00d5d1f4475c0a2ef4 Mon Sep 17 00:00:00 2001
From: Christos Stergianos
Date: Fri, 25 Oct 2019 08:56:49 +0200
Subject: [PATCH 0633/1978] Apply the same fix for Magento blank
In this commit two changes are introduced. The first one is removing the .lib-css while applying the width style property and the other one is to apply the same changes for Magento Blank theme.
---
.../blank/Magento_Newsletter/web/css/source/_module.less | 6 ++++--
.../luma/Magento_Newsletter/web/css/source/_module.less | 2 +-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/_module.less
index f22a325debc9c..09759d95c4b10 100644
--- a/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/_module.less
+++ b/app/design/frontend/Magento/blank/Magento_Newsletter/web/css/source/_module.less
@@ -44,7 +44,8 @@
}
input {
- padding-left: 35px;
+ margin-right: 35px;
+ padding: 0 0 0 35px; // Reset some default Safari padding values.
}
.title {
@@ -75,7 +76,8 @@
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.block.newsletter {
- width: 32%;
+ max-width: 44%;
+ width: max-content;
.field {
margin-right: 5px;
diff --git a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
index 5e8edf7fa21d3..7f92d35599935 100644
--- a/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Newsletter/web/css/source/_module.less
@@ -79,8 +79,8 @@
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
.block.newsletter {
- .lib-css(width, max-content);
max-width: 44%;
+ width: max-content;
}
}
From a0aa65e3e0605947293e929f793d5617812cf8a9 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 25 Oct 2019 10:37:27 +0300
Subject: [PATCH 0634/1978] MC-22083: MFTF tests stabilization -
DisplayRefreshCacheAfterChangingCategoryPageLayoutTest MC-17031
---
.../Section/AdminSystemMessagesSection.xml | 4 ++++
.../AdminSystemMessagesActionGroup.xml | 23 ++++++++++++++++++
.../Mftf/Section/AdminMessagesSection.xml | 8 +++++++
.../AdminCreateWidgetActionGroup.xml | 4 ++--
...nProductAttributeMassUpdateActionGroup.xml | 4 ++--
...cheAfterChangingCategoryPageLayoutTest.xml | 5 ++--
...ctAndProductCategoryPartialReindexTest.xml | 2 +-
.../ActionGroup/AdminExportActionGroup.xml | 4 ++--
.../AdminDeleteCatalogPriceRuleEntityTest.xml | 6 ++---
...goryWithRestrictedUrlKeyNotCreatedTest.xml | 24 +++++++++----------
...hangedWhenSavingProductWithSameSkuTest.xml | 6 ++---
...eCustomerGroupAlreadyExistsActionGroup.xml | 4 ++--
.../AdminSaveCustomerAddressActionGroup.xml | 2 +-
.../OpenEditCustomerFromAdminActionGroup.xml | 8 +++----
.../ActionGroup/EmailTemplateActionGroup.xml | 8 +++----
...inImportProductsWithDeleteBehaviorTest.xml | 2 +-
.../AdminSaveReviewActionGroup.xml | 4 ++--
.../AdminCreditMemoActionGroup.xml | 8 +++----
.../ActionGroup/AdminInvoiceActionGroup.xml | 4 ++--
...reateCreditMemoBankTransferPaymentTest.xml | 4 ++--
...reateCreditMemoConfigurableProductTest.xml | 4 ++--
...AdminCreateCreditMemoPartialRefundTest.xml | 4 ++--
...CreateCreditMemoWithCashOnDeliveryTest.xml | 4 ++--
...nCreateCreditMemoWithPurchaseOrderTest.xml | 4 ++--
...nimumOrderAmountNotMatchOrderTotalTest.xml | 6 ++---
.../DeleteCustomStoreActionGroup.xml | 4 ++--
.../DeleteCustomWebsiteActionGroup.xml | 4 ++--
.../Mftf/Section/AdminMessagesSection.xml | 18 --------------
...tipleStoreviewsDuringProductImportTest.xml | 8 +++----
.../AdminAddNewUserRoleActionGroup.xml | 2 +-
.../AdminDeleteUserRoleActionGroup.xml | 4 ++--
.../AdminCreateAndSaveWidgetActionGroup.xml | 4 ++--
.../AdminCreateWidgetActionGroup.xml | 10 ++++----
33 files changed, 114 insertions(+), 96 deletions(-)
create mode 100644 app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminSystemMessagesActionGroup.xml
delete mode 100644 app/code/Magento/Ui/Test/Mftf/Section/AdminMessagesSection.xml
diff --git a/app/code/Magento/AdminNotification/Test/Mftf/Section/AdminSystemMessagesSection.xml b/app/code/Magento/AdminNotification/Test/Mftf/Section/AdminSystemMessagesSection.xml
index 8a73968edb9a6..e3b2ea7e24c83 100644
--- a/app/code/Magento/AdminNotification/Test/Mftf/Section/AdminSystemMessagesSection.xml
+++ b/app/code/Magento/AdminNotification/Test/Mftf/Section/AdminSystemMessagesSection.xml
@@ -11,5 +11,9 @@
diff --git a/app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminSystemMessagesActionGroup.xml b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminSystemMessagesActionGroup.xml
new file mode 100644
index 0000000000000..a498c95c65a30
--- /dev/null
+++ b/app/code/Magento/Backend/Test/Mftf/ActionGroup/AdminSystemMessagesActionGroup.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ Check warning system message exists.
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
index be3ef92acf0ac..bb1123d01c867 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
@@ -14,5 +14,13 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
index 45e2ed6205b20..e22620790ef70 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
@@ -16,7 +16,7 @@
-
-
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeMassUpdateActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeMassUpdateActionGroup.xml
index 57b180ada1536..d20b44b0162f0 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeMassUpdateActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductAttributeMassUpdateActionGroup.xml
@@ -23,7 +23,7 @@
-
-
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
index 5a94dd4f04d24..d5b1e8569d560 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/DisplayRefreshCacheAfterChangingCategoryPageLayoutTest.xml
@@ -45,7 +45,8 @@
-
-
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml
index 6184a220f047c..d798668991472 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml
@@ -115,7 +115,7 @@
-
+
diff --git a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml
index f792b0be2eb6b..76f3f2c3cb9ad 100644
--- a/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml
+++ b/app/code/Magento/CatalogImportExport/Test/Mftf/ActionGroup/AdminExportActionGroup.xml
@@ -26,7 +26,7 @@
-
+
@@ -41,7 +41,7 @@
-
+
diff --git a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml
index ea5c2c33a0a39..d80759531ecae 100644
--- a/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml
+++ b/app/code/Magento/CatalogRule/Test/Mftf/Test/AdminDeleteCatalogPriceRuleEntityTest.xml
@@ -18,7 +18,7 @@
-
+
@@ -59,7 +59,7 @@
-
+
@@ -192,7 +192,7 @@
-
+
diff --git a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml
index 6538ec6e935df..58b489da5082b 100644
--- a/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml
+++ b/app/code/Magento/CatalogUrlRewrite/Test/Mftf/Test/AdminCategoryWithRestrictedUrlKeyNotCreatedTest.xml
@@ -45,19 +45,19 @@
-
+
-
+
-
+
@@ -66,19 +66,19 @@
-
+
-
+
-
+
@@ -87,19 +87,19 @@
-
+
-
+
-
+
@@ -108,19 +108,19 @@
-
+
-
+
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml
index 68bf703ecdab4..c085229da8028 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAssertNoticeThatExistingSkuAutomaticallyChangedWhenSavingProductWithSameSkuTest.xml
@@ -69,7 +69,7 @@
-
-
+
+
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertErrorMessageCustomerGroupAlreadyExistsActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertErrorMessageCustomerGroupAlreadyExistsActionGroup.xml
index 5eb52630d906b..36b41b155b2b3 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertErrorMessageCustomerGroupAlreadyExistsActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertErrorMessageCustomerGroupAlreadyExistsActionGroup.xml
@@ -9,7 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
-
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml
index e47aa8809f080..a69428bc7edbc 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml
@@ -9,6 +9,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml
index 60a8a49954bab..e338d1ae4bbd0 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml
@@ -15,7 +15,7 @@
-
+
@@ -26,7 +26,7 @@
-
+
Filters the Admin Customers Addresses based on the provided Address. Clicks on Edit.
@@ -34,7 +34,7 @@
-
+
@@ -67,7 +67,7 @@
-
+
diff --git a/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml b/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml
index 3b99ade32e6ce..c859b956810c7 100644
--- a/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml
+++ b/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml
@@ -27,8 +27,8 @@
-
-
+
+
@@ -63,8 +63,8 @@
-
-
+
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
index 4cbb0603d9073..4bbe6c6a6c7b4 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
@@ -47,7 +47,7 @@
-
+
diff --git a/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminSaveReviewActionGroup.xml b/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminSaveReviewActionGroup.xml
index 62c93764ab61d..1937905ae2849 100644
--- a/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminSaveReviewActionGroup.xml
+++ b/app/code/Magento/Review/Test/Mftf/ActionGroup/AdminSaveReviewActionGroup.xml
@@ -9,7 +9,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminCreditMemoActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminCreditMemoActionGroup.xml
index 68cd1c42e1dd8..75d41d835bed2 100644
--- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminCreditMemoActionGroup.xml
+++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminCreditMemoActionGroup.xml
@@ -19,7 +19,7 @@
-
+
@@ -42,7 +42,7 @@
-
+
@@ -59,8 +59,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminInvoiceActionGroup.xml b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminInvoiceActionGroup.xml
index 03639546631d1..8451f9de03293 100644
--- a/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminInvoiceActionGroup.xml
+++ b/app/code/Magento/Sales/Test/Mftf/ActionGroup/AdminInvoiceActionGroup.xml
@@ -99,8 +99,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml
index f79ab822d964a..37a9b97fab064 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoBankTransferPaymentTest.xml
@@ -64,8 +64,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoConfigurableProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoConfigurableProductTest.xml
index 0522960a032fa..8a9369537f0a4 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoConfigurableProductTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoConfigurableProductTest.xml
@@ -123,8 +123,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml
index e9b37521259a0..418c0e72dc1fc 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoPartialRefundTest.xml
@@ -59,8 +59,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithCashOnDeliveryTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithCashOnDeliveryTest.xml
index 791792d0879a7..c552f93e62a4a 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithCashOnDeliveryTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithCashOnDeliveryTest.xml
@@ -65,8 +65,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml
index 0a8e78d743c1d..57d9222d85096 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateCreditMemoWithPurchaseOrderTest.xml
@@ -68,8 +68,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml
index 5f6ea0937b52a..079c81a7760c3 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml
@@ -57,7 +57,7 @@
-
-
+
+
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomStoreActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomStoreActionGroup.xml
index f93b0a22f7558..a4d4374704291 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomStoreActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomStoreActionGroup.xml
@@ -26,8 +26,8 @@
-
-
+
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomWebsiteActionGroup.xml
index 90dc74e3a3fee..77d148eedb99f 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomWebsiteActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/DeleteCustomWebsiteActionGroup.xml
@@ -15,7 +15,7 @@
-
+
@@ -26,6 +26,6 @@
-
+
diff --git a/app/code/Magento/Ui/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Ui/Test/Mftf/Section/AdminMessagesSection.xml
deleted file mode 100644
index 8dc20142add3f..0000000000000
--- a/app/code/Magento/Ui/Test/Mftf/Section/AdminMessagesSection.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesCorrectlyGeneratedForMultipleStoreviewsDuringProductImportTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesCorrectlyGeneratedForMultipleStoreviewsDuringProductImportTest.xml
index 44fad061d7656..8f32f1edee40e 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesCorrectlyGeneratedForMultipleStoreviewsDuringProductImportTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminCheckUrlRewritesCorrectlyGeneratedForMultipleStoreviewsDuringProductImportTest.xml
@@ -73,9 +73,9 @@
-
+
-
+
@@ -195,9 +195,9 @@
-
+
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminAddNewUserRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminAddNewUserRoleActionGroup.xml
index 76a83f5d5a5aa..175f6203350c7 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminAddNewUserRoleActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminAddNewUserRoleActionGroup.xml
@@ -36,7 +36,7 @@
-
+
diff --git a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml
index d2c881b771973..84c9e26eed54c 100644
--- a/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml
+++ b/app/code/Magento/User/Test/Mftf/ActionGroup/AdminDeleteUserRoleActionGroup.xml
@@ -21,7 +21,7 @@
-
-
+
+
diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml
index 00f593a2d3bc8..5e564fcd799ae 100644
--- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml
+++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateAndSaveWidgetActionGroup.xml
@@ -12,8 +12,8 @@
EXTENDS: AdminCreateWidgetActionGroup. Clicks on Save. Validates that the Success Message is present and correct.
-
+
-
+
diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
index 797abdb6f56ae..63021390e6e30 100644
--- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
+++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
@@ -46,7 +46,7 @@
-
+
@@ -54,11 +54,11 @@
EXTENDS: AdminCreateWidgetActionGroup. Creates a Dynamic Block Rotate Widget.
-
+
-
+
@@ -79,7 +79,7 @@
-
+
@@ -97,6 +97,6 @@
-
+
From 8701bdb7779f37d9aee4f7659a598eabf32fc7fe Mon Sep 17 00:00:00 2001
From: Eden
Date: Fri, 25 Oct 2019 14:50:13 +0700
Subject: [PATCH 0635/1978] Split action group
---
...bleAutoGroupInCustomerFormActionGroup.xml} | 5 +----
.../NavigateNewCustomerActionGroup.xml | 19 +++++++++++++++++++
...ultValueDisableAutoGroupChangeIsNoTest.xml | 4 +++-
...ltValueDisableAutoGroupChangeIsYesTest.xml | 4 +++-
4 files changed, 26 insertions(+), 6 deletions(-)
rename app/code/Magento/Customer/Test/Mftf/ActionGroup/{AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml => AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml} (83%)
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateNewCustomerActionGroup.xml
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
similarity index 83%
rename from app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
rename to app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
index ed34f871005ee..8271cdec46df9 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminCheckDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminAssertDefaultValueDisableAutoGroupInCustomerFormActionGroup.xml
@@ -9,7 +9,7 @@
-
+
Check Default Value for Disable Automatic Group Changes Based on VAT ID in Create Customer form.
@@ -17,9 +17,6 @@
-
-
-
{{isChecked}}
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateNewCustomerActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateNewCustomerActionGroup.xml
new file mode 100644
index 0000000000000..5a25929337310
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/NavigateNewCustomerActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+ Goes to the New Customer page.
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml
index 432100a35b9c9..bba3a114b0f60 100644
--- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsNoTest.xml
@@ -27,7 +27,9 @@
-
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml
index e200ff2edf847..f643cb93d9ae4 100644
--- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCheckDefaultValueDisableAutoGroupChangeIsYesTest.xml
@@ -29,7 +29,9 @@
-
+
+
+
From 888a3787172393a80af1df83cb06592bc60c0609 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 25 Oct 2019 11:32:46 +0300
Subject: [PATCH 0636/1978] MC-22085: MFTF
StorefrontAdvancedSearchByPriceToTest - MAGETWO-24729
---
.../Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml
index 78110b531be33..a0beeb01f68bf 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml
@@ -19,10 +19,14 @@
+
+
+
+
From 1be6d5801136cb833c94ddd33fbf370c3feda383 Mon Sep 17 00:00:00 2001
From: Viktor Petryk
Date: Fri, 25 Oct 2019 11:48:13 +0300
Subject: [PATCH 0637/1978] MC-20614: [MFTF] Automate test
AdminDeleteUsedCategoryUpdateTest MC-13131
---
.../StorefrontConfigurableProductDetailsTest.xml | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml
index f75e30907a1f4..48014be8ac092 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductDetailsTest.xml
@@ -31,6 +31,10 @@
+
+
+
+
@@ -72,6 +76,10 @@
+
+
+
+
@@ -113,6 +121,10 @@
+
+
+
+
@@ -151,6 +163,10 @@
+
+
+
+
From 5a0ae70a415e0263acd84a3dff5c841de059e1b6 Mon Sep 17 00:00:00 2001
From: Bohdan Shevchenko <1408sheva@gmail.com>
Date: Fri, 25 Oct 2019 12:18:07 +0300
Subject: [PATCH 0638/1978] MC-22124: MFTF TASK FOR MC-16587
---
.../Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
index b6b9fe1e1a117..9beb8addb7a2e 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutTest.xml
@@ -81,11 +81,8 @@
-
+
-
-
-
From 16eeb487c7ef8945b72b840a7ce62f545ded3541 Mon Sep 17 00:00:00 2001
From: Eden
Date: Fri, 25 Oct 2019 16:34:39 +0700
Subject: [PATCH 0639/1978] Unit test to cover ChangeQuoteControl Class
---
.../Unit/Model/ChangeQuoteControlTest.php | 144 ++++++++++++++++++
1 file changed, 144 insertions(+)
create mode 100644 app/code/Magento/Quote/Test/Unit/Model/ChangeQuoteControlTest.php
diff --git a/app/code/Magento/Quote/Test/Unit/Model/ChangeQuoteControlTest.php b/app/code/Magento/Quote/Test/Unit/Model/ChangeQuoteControlTest.php
new file mode 100644
index 0000000000000..dc62c57c84941
--- /dev/null
+++ b/app/code/Magento/Quote/Test/Unit/Model/ChangeQuoteControlTest.php
@@ -0,0 +1,144 @@
+objectManager = new ObjectManager($this);
+ $this->userContextMock = $this->createMock(UserContextInterface::class);
+
+ $this->model = $this->objectManager->getObject(
+ ChangeQuoteControl::class,
+ [
+ 'userContext' => $this->userContextMock
+ ]
+ );
+
+ $this->quoteMock = $this->getMockForAbstractClass(
+ CartInterface::class,
+ [],
+ '',
+ false,
+ true,
+ true,
+ ['getCustomerId']
+ );
+ }
+
+ /**
+ * Test if the quote is belonged to customer
+ */
+ public function testIsAllowedIfTheQuoteIsBelongedToCustomer()
+ {
+ $quoteCustomerId = 1;
+ $this->quoteMock->expects($this->any())->method('getCustomerId')
+ ->will($this->returnValue($quoteCustomerId));
+ $this->userContextMock->expects($this->any())->method('getUserType')
+ ->will($this->returnValue(UserContextInterface::USER_TYPE_CUSTOMER));
+ $this->userContextMock->expects($this->any())->method('getUserId')
+ ->will($this->returnValue($quoteCustomerId));
+
+ $this->assertEquals(true, $this->model->isAllowed($this->quoteMock));
+ }
+
+ /**
+ * Test if the quote is not belonged to customer
+ */
+ public function testIsAllowedIfTheQuoteIsNotBelongedToCustomer()
+ {
+ $currentCustomerId = 1;
+ $quoteCustomerId = 2;
+
+ $this->quoteMock->expects($this->any())->method('getCustomerId')
+ ->will($this->returnValue($quoteCustomerId));
+ $this->userContextMock->expects($this->any())->method('getUserType')
+ ->will($this->returnValue(UserContextInterface::USER_TYPE_CUSTOMER));
+ $this->userContextMock->expects($this->any())->method('getUserId')
+ ->will($this->returnValue($currentCustomerId));
+
+ $this->assertEquals(false, $this->model->isAllowed($this->quoteMock));
+ }
+
+ /**
+ * Test if the quote is belonged to guest and the context is guest
+ */
+ public function testIsAllowedIfQuoteIsBelongedToGuestAndContextIsGuest()
+ {
+ $quoteCustomerId = null;
+ $this->quoteMock->expects($this->any())->method('getCustomerId')
+ ->will($this->returnValue($quoteCustomerId));
+ $this->userContextMock->expects($this->any())->method('getUserType')
+ ->will($this->returnValue(UserContextInterface::USER_TYPE_GUEST));
+ $this->assertEquals(true, $this->model->isAllowed($this->quoteMock));
+ }
+
+ /**
+ * Test if the quote is belonged to customer and the context is guest
+ */
+ public function testIsAllowedIfQuoteIsBelongedToCustomerAndContextIsGuest()
+ {
+ $quoteCustomerId = 1;
+ $this->quoteMock->expects($this->any())->method('getCustomerId')
+ ->will($this->returnValue($quoteCustomerId));
+ $this->userContextMock->expects($this->any())->method('getUserType')
+ ->will($this->returnValue(UserContextInterface::USER_TYPE_GUEST));
+ $this->assertEquals(false, $this->model->isAllowed($this->quoteMock));
+ }
+
+ /**
+ * Test if the context is admin
+ */
+ public function testIsAllowedIfContextIsAdmin()
+ {
+ $this->userContextMock->expects($this->any())->method('getUserType')
+ ->will($this->returnValue(UserContextInterface::USER_TYPE_ADMIN));
+ $this->assertEquals(true, $this->model->isAllowed($this->quoteMock));
+ }
+
+ /**
+ * Test if the context is integration
+ */
+ public function testIsAllowedIfContextIsIntegration()
+ {
+ $this->userContextMock->expects($this->any())->method('getUserType')
+ ->will($this->returnValue(UserContextInterface::USER_TYPE_INTEGRATION));
+ $this->assertEquals(true, $this->model->isAllowed($this->quoteMock));
+ }
+}
From 407145906d356cddbb2375b61a59db76755b7051 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Fri, 25 Oct 2019 13:26:17 +0300
Subject: [PATCH 0640/1978] MC-22078: CreateCustomOptionsTest is failing in
presence of B2B
---
.../Model/Product/CreateCustomOptionsTest.php | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php
index 94bbcd8bae66b..2239170cdc84e 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/CreateCustomOptionsTest.php
@@ -24,7 +24,6 @@
* Testing option types: "Area", "File", "Drop-down", "Radio-Buttons",
* "Checkbox", "Multiple Select", "Date", "Date & Time" and "Time".
*
- * @magentoAppArea adminhtml
* @magentoAppIsolation enabled
* @magentoDbIsolation enabled
*/
@@ -70,11 +69,11 @@ class CreateCustomOptionsTest extends TestCase
protected function setUp()
{
$this->objectManager = Bootstrap::getObjectManager();
- $this->productRepository = $this->objectManager->create(ProductRepositoryInterface::class);
- $this->optionRepository = $this->objectManager->create(ProductCustomOptionRepositoryInterface::class);
- $this->customOptionFactory = $this->objectManager->create(ProductCustomOptionInterfaceFactory::class);
+ $this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
+ $this->optionRepository = $this->objectManager->get(ProductCustomOptionRepositoryInterface::class);
+ $this->customOptionFactory = $this->objectManager->get(ProductCustomOptionInterfaceFactory::class);
$this->customOptionValueFactory = $this->objectManager
- ->create(ProductCustomOptionValuesInterfaceFactory::class);
+ ->get(ProductCustomOptionValuesInterfaceFactory::class);
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
}
@@ -83,7 +82,8 @@ protected function setUp()
*
* @magentoDataFixture Magento/Catalog/_files/product_with_options.php
* @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php
- *
+ * @magentoAppArea adminhtml
+ * @magentoAppIsolation disabled
* @magentoConfigFixture default_store catalog/price/scope 1
* @magentoConfigFixture secondstore_store catalog/price/scope 1
*/
From 35ccda3499e39f830ce88966629ef95b4ef5c9ad Mon Sep 17 00:00:00 2001
From: Andrii Meysar
Date: Fri, 25 Oct 2019 13:39:41 +0300
Subject: [PATCH 0641/1978] MC-22131: Revert of MC-16333
---
.../AdminAssertDisabledQtyActionGroup.xml | 19 ---
.../Form/Modifier/AdvancedInventory.php | 115 +++++++-----------
.../adminhtml/ui_component/product_form.xml | 41 -------
.../Product/Form/Modifier/ConfigurableQty.php | 19 +--
.../Block/Adminhtml/Product/ProductForm.xml | 2 +-
5 files changed, 43 insertions(+), 153 deletions(-)
delete mode 100644 app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml
diff --git a/app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml b/app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml
deleted file mode 100644
index 27c4a93577a07..0000000000000
--- a/app/code/Magento/CatalogInventory/Test/Mftf/ActionGroup/AdminAssertDisabledQtyActionGroup.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
-
- Goes to the 'Quantity' field and assert disabled attribute.
-
-
-
-
-
-
diff --git a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php
index 789befcfec8b7..87aa53a6a9f03 100644
--- a/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php
+++ b/app/code/Magento/CatalogInventory/Ui/DataProvider/Product/Form/Modifier/AdvancedInventory.php
@@ -3,8 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-declare(strict_types=1);
-
namespace Magento\CatalogInventory\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Controller\Adminhtml\Product\Initialization\StockDataFilter;
@@ -229,9 +227,48 @@ private function prepareMeta()
) - 1,
'disabled' => $this->locator->getProduct()->isLockedAttribute($fieldCode),
];
+ $qty['arguments']['data']['config'] = [
+ 'component' => 'Magento_CatalogInventory/js/components/qty-validator-changer',
+ 'group' => 'quantity_and_stock_status_qty',
+ 'dataType' => 'number',
+ 'formElement' => 'input',
+ 'componentType' => 'field',
+ 'visible' => '1',
+ 'require' => '0',
+ 'additionalClasses' => 'admin__field-small',
+ 'label' => __('Quantity'),
+ 'scopeLabel' => '[GLOBAL]',
+ 'dataScope' => 'qty',
+ 'validation' => [
+ 'validate-number' => true,
+ 'less-than-equals-to' => StockDataFilter::MAX_QTY_VALUE,
+ ],
+ 'imports' => [
+ 'handleChanges' => '${$.provider}:data.product.stock_data.is_qty_decimal',
+ ],
+ 'sortOrder' => 10,
+ ];
+ $advancedInventoryButton['arguments']['data']['config'] = [
+ 'displayAsLink' => true,
+ 'formElement' => 'container',
+ 'componentType' => 'container',
+ 'component' => 'Magento_Ui/js/form/components/button',
+ 'template' => 'ui/form/components/button/container',
+ 'actions' => [
+ [
+ 'targetName' => 'product_form.product_form.advanced_inventory_modal',
+ 'actionName' => 'toggleModal',
+ ],
+ ],
+ 'title' => __('Advanced Inventory'),
+ 'provider' => false,
+ 'additionalForGroup' => true,
+ 'source' => 'product_details',
+ 'sortOrder' => 20,
+ ];
$container['children'] = [
- 'qty' => $this->getQtyMetaStructure(),
- 'advanced_inventory_button' => $this->getAdvancedInventoryButtonMetaStructure(),
+ 'qty' => $qty,
+ 'advanced_inventory_button' => $advancedInventoryButton,
];
$this->meta = $this->arrayManager->merge(
@@ -241,74 +278,4 @@ private function prepareMeta()
);
}
}
-
- /**
- * Get Qty meta structure
- *
- * @return array
- */
- private function getQtyMetaStructure()
- {
- return [
- 'arguments' => [
- 'data' => [
- 'config' => [
- 'component' => 'Magento_CatalogInventory/js/components/qty-validator-changer',
- 'group' => 'quantity_and_stock_status_qty',
- 'dataType' => 'number',
- 'formElement' => 'input',
- 'componentType' => 'field',
- 'visible' => '1',
- 'require' => '0',
- 'additionalClasses' => 'admin__field-small',
- 'label' => __('Quantity'),
- 'scopeLabel' => '[GLOBAL]',
- 'dataScope' => 'qty',
- 'validation' => [
- 'validate-number' => true,
- 'less-than-equals-to' => StockDataFilter::MAX_QTY_VALUE,
- ],
- 'imports' => [
- 'handleChanges' => '${$.provider}:data.product.stock_data.is_qty_decimal',
- ],
- 'sortOrder' => 10,
- 'disabled' => $this->locator->getProduct()->isLockedAttribute('quantity_and_stock_status'),
- ]
- ]
- ]
- ];
- }
-
- /**
- * Get advances inventory button meta structure
- *
- * @return array
- */
- private function getAdvancedInventoryButtonMetaStructure()
- {
- return [
- 'arguments' => [
- 'data' => [
- 'config' => [
- 'displayAsLink' => true,
- 'formElement' => 'container',
- 'componentType' => 'container',
- 'component' => 'Magento_Ui/js/form/components/button',
- 'template' => 'ui/form/components/button/container',
- 'actions' => [
- [
- 'targetName' => 'product_form.product_form.advanced_inventory_modal',
- 'actionName' => 'toggleModal',
- ],
- ],
- 'title' => __('Advanced Inventory'),
- 'provider' => false,
- 'additionalForGroup' => true,
- 'source' => 'product_details',
- 'sortOrder' => 20,
- ]
- ]
- ]
- ];
- }
}
diff --git a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml
index b813aa5d356cb..12f01c7dbca36 100644
--- a/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml
+++ b/app/code/Magento/CatalogInventory/view/adminhtml/ui_component/product_form.xml
@@ -74,12 +74,8 @@
${$.provider}:data.product.stock_data.manage_stock
- ${$.parentName}.manage_stock:disabled
${$.parentName}.manage_stock:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -105,7 +101,6 @@
quantity_and_stock_status.qty
ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:value
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
${$.provider}:data.product.stock_data.is_qty_decimal
@@ -154,12 +149,8 @@
${$.provider}:data.product.stock_data.min_qty
- ${$.parentName}.min_qty:disabled
${$.parentName}.min_qty:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -220,13 +211,6 @@
true
use_config_min_sale_qty
-
- ${$.parentName}.min_sale_qty:disabled
- ${$.parentName}.min_sale_qty:disabled
-
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -325,12 +309,8 @@
${$.provider}:data.product.stock_data.max_sale_qty
- ${$.parentName}.max_sale_qty:disabled
${$.parentName}.max_sale_qty:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -358,7 +338,6 @@
stock_data.is_qty_decimal
${$.provider}:data.product.stock_data.manage_stock
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
@@ -381,7 +360,6 @@
stock_data.is_decimal_divided
${$.provider}:data.product.stock_data.manage_stock
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
@@ -441,12 +419,8 @@
${$.provider}:data.product.stock_data.backorders
- ${$.parentName}.backorders:disabled
${$.parentName}.backorders:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -502,12 +476,8 @@
${$.provider}:data.product.stock_data.notify_stock_qty
- ${$.parentName}.notify_stock_qty:disabled
${$.parentName}.notify_stock_qty:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -565,12 +535,8 @@
${$.provider}:data.product.stock_data.enable_qty_increments
- ${$.parentName}.enable_qty_increments:disabled
${$.parentName}.enable_qty_increments:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -630,12 +596,8 @@
${$.provider}:data.product.stock_data.qty_increments
- ${$.parentName}.qty_increments:disabled
${$.parentName}.qty_increments:disabled
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
@@ -672,9 +634,6 @@
[GLOBAL]
Stock Status
is_in_stock
-
- ns = ${ $.ns }, index = qty, group = quantity_and_stock_status_qty:disabled
-
diff --git a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php
index 055891ff79c69..ade56edeb3dfc 100644
--- a/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php
+++ b/app/code/Magento/ConfigurableProduct/Ui/DataProvider/Product/Form/Modifier/ConfigurableQty.php
@@ -8,7 +8,6 @@
namespace Magento\ConfigurableProduct\Ui\DataProvider\Product\Form\Modifier;
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\AbstractModifier;
-use Magento\Catalog\Model\Locator\LocatorInterface;
/**
* Data provider for quantity in the Configurable products
@@ -18,21 +17,6 @@ class ConfigurableQty extends AbstractModifier
const CODE_QUANTITY = 'qty';
const CODE_QTY_CONTAINER = 'quantity_and_stock_status_qty';
- /**
- * @var LocatorInterface
- */
- private $locator;
-
- /**
- * ConfigurableQty constructor
- *
- * @param LocatorInterface $locator
- */
- public function __construct(LocatorInterface $locator)
- {
- $this->locator = $locator;
- }
-
/**
* @inheritdoc
*/
@@ -48,8 +32,7 @@ public function modifyMeta(array $meta)
{
if ($groupCode = $this->getGroupCodeByField($meta, self::CODE_QTY_CONTAINER)) {
$parentChildren = &$meta[$groupCode]['children'];
- $isConfigurable = $this->locator->getProduct()->getTypeId() === 'configurable';
- if (!empty($parentChildren[self::CODE_QTY_CONTAINER]) && $isConfigurable) {
+ if (!empty($parentChildren[self::CODE_QTY_CONTAINER])) {
$parentChildren[self::CODE_QTY_CONTAINER] = array_replace_recursive(
$parentChildren[self::CODE_QTY_CONTAINER],
[
diff --git a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml
index 028dfc6d109ea..525e6b47374a0 100644
--- a/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml
+++ b/dev/tests/functional/tests/app/Magento/Catalog/Test/Block/Adminhtml/Product/ProductForm.xml
@@ -31,7 +31,7 @@
- fieldset[data-index="quantity_and_stock_status_qty"] [name="product[quantity_and_stock_status][qty]"]
+ fieldset[data-index="container_quantity_and_stock_status_qty"] [name="product[quantity_and_stock_status][qty]"]
[data-index="quantity_and_stock_status"] [name="product[quantity_and_stock_status][is_in_stock]"]
From 88a839586f372e7e0536282840ef53fe176a62e3 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 25 Oct 2019 13:46:16 +0300
Subject: [PATCH 0642/1978] MC-22083: MFTF tests stabilization -
DisplayRefreshCacheAfterChangingCategoryPageLayoutTest MC-17031
---
.../AdminSaveCustomerAddressActionGroup.xml | 2 +-
.../AdminImportProductsWithDeleteBehaviorTest.xml | 4 ++--
.../Sales/Test/Mftf/Page/AdminOrderCreatePage.xml | 1 +
.../Section/AdminOrderFormMessagesSection.xml | 15 +++++++++++++++
...IfMinimumOrderAmountNotMatchOrderTotalTest.xml | 4 ++--
5 files changed, 21 insertions(+), 5 deletions(-)
create mode 100644 app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormMessagesSection.xml
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml
index a69428bc7edbc..62c35dd230f10 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminSaveCustomerAddressActionGroup.xml
@@ -9,6 +9,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
index 4bbe6c6a6c7b4..7ec48a3a7e8fd 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
@@ -47,8 +47,8 @@
-
-
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderCreatePage.xml b/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderCreatePage.xml
index bc9486d61fbfe..680d44ebb34fe 100644
--- a/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderCreatePage.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Page/AdminOrderCreatePage.xml
@@ -19,5 +19,6 @@
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormMessagesSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormMessagesSection.xml
new file mode 100644
index 0000000000000..b5e6f6b6ede83
--- /dev/null
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminOrderFormMessagesSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml
index 079c81a7760c3..8bfcaf67c4332 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminFreeShippingNotAvailableIfMinimumOrderAmountNotMatchOrderTotalTest.xml
@@ -57,7 +57,7 @@
-
-
+
+
From 802f2af6bcd9dd691959c10c0a178e09928d700b Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 25 Oct 2019 14:20:34 +0300
Subject: [PATCH 0643/1978] MC-22085: MFTF
StorefrontAdvancedSearchByPriceToTest - MAGETWO-24729
---
.../Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml
index a0beeb01f68bf..14df2133017d9 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/StorefrontAdvancedSearchEntitySimpleProductTest.xml
@@ -26,9 +26,9 @@
-
+
From 4ebdd17b5019b189d7b927f15ae5d901ebcfcb97 Mon Sep 17 00:00:00 2001
From: DianaRusin
Date: Fri, 25 Oct 2019 14:36:37 +0300
Subject: [PATCH 0644/1978] MC-17003: Update Totals button is missing from
Credit Memo page
---
...dminCheckingCreditMemoUpdateTotalsTest.xml | 3 -
.../CreditMemo/Create/UpdateTotalsButton.php | 74 +++++++++++++++++++
.../layout/sales_order_creditmemo_new.xml | 5 +-
.../sales_order_creditmemo_updateqty.xml | 3 +
.../order/creditmemo/create/items.phtml | 11 ++-
.../web/css/source/module/order/_total.less | 4 +
.../Adminhtml/Order/Creditmemo/Totals.php | 68 +++++++++++++++++
.../Test/TestStep/CreateCreditMemoStep.php | 32 +++++++-
8 files changed, 191 insertions(+), 9 deletions(-)
create mode 100644 app/code/Magento/Sales/ViewModel/CreditMemo/Create/UpdateTotalsButton.php
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml
index 45ea09a06ed26..8cd2b8ee60edd 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCheckingCreditMemoUpdateTotalsTest.xml
@@ -18,9 +18,6 @@
-
-
-
diff --git a/app/code/Magento/Sales/ViewModel/CreditMemo/Create/UpdateTotalsButton.php b/app/code/Magento/Sales/ViewModel/CreditMemo/Create/UpdateTotalsButton.php
new file mode 100644
index 0000000000000..707f5ef363f66
--- /dev/null
+++ b/app/code/Magento/Sales/ViewModel/CreditMemo/Create/UpdateTotalsButton.php
@@ -0,0 +1,74 @@
+layout = $layout;
+ $this->items = $items;
+ }
+
+ /**
+ * Get Update Totals block html.
+ *
+ * @return string
+ */
+ public function getUpdateTotalsButton(): string
+ {
+ $block = $this->createUpdateTotalsBlock();
+
+ return $block->toHtml();
+ }
+
+ /**
+ * Create Update Totals block.
+ *
+ * @return BlockInterface
+ */
+ private function createUpdateTotalsBlock(): BlockInterface
+ {
+ $onclick = "submitAndReloadArea($('creditmemo_item_container'),'" . $this->items->getUpdateUrl() . "')";
+ $block = $this->layout->addBlock(Button::class, 'update_totals_button', 'order_items');
+ $block->setData(
+ [
+ 'label' => __('Update Totals'),
+ 'class' => 'update-totals-button secondary',
+ 'onclick' => $onclick,
+ ]
+ );
+
+ return $block;
+ }
+}
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml
index 71490553aff17..fb2545b3523e4 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_new.xml
@@ -17,7 +17,10 @@
-
+
+
+ Magento\Sales\ViewModel\CreditMemo\Create\UpdateTotalsButton
+
diff --git a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml
index 8375bec965794..94ef0bf9d7a03 100644
--- a/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml
+++ b/app/code/Magento/Sales/view/adminhtml/layout/sales_order_creditmemo_updateqty.xml
@@ -9,6 +9,9 @@
+
+ Magento\Sales\ViewModel\CreditMemo\Create\UpdateTotalsButton
+
diff --git a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml
index 9e0d203cd56bf..963ef02b50a00 100644
--- a/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml
+++ b/app/code/Magento/Sales/view/adminhtml/templates/order/creditmemo/create/items.phtml
@@ -6,7 +6,11 @@
/* @var \Magento\Sales\Block\Adminhtml\Order\Creditmemo\Create\Items $block */
?>
-getCreditmemo()->getAllItems() ?>
+getData('viewModel');
+$_items = $block->getCreditmemo()->getAllItems();
+?>
@@ -100,6 +104,7 @@
= $block->escapeHtml(__('Refund Totals')) ?>
= $block->getChildHtml('creditmemo_totals') ?>
+ = $viewModel->getUpdateTotalsButton() ?>
= $block->getChildHtml('creditmemo_totals') ?>
-
= $viewModel->getUpdateTotalsButton() ?>
+
= /* @noEscape */ $viewModel->getUpdateTotalsButton() ?>
+
+
+
+
+
+
+
*/
From 008a04cb4afb728703a67d9fb89a13936f3fa468 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 31 Oct 2019 12:26:27 +0200
Subject: [PATCH 0854/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Model/Product/Gallery/ReadHandlerTest.php | 23 +++++++++++++++++++
.../Product/Gallery/UpdateHandlerTest.php | 7 ++++++
2 files changed, 30 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
index 3724f63f5e701..89b91ab57e51a 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/ReadHandlerTest.php
@@ -11,6 +11,7 @@
use Magento\Catalog\Api\Data\ProductInterfaceFactory;
use Magento\Catalog\Api\ProductRepositoryInterface;
use Magento\Catalog\Model\ResourceModel\Product as ProductResource;
+use Magento\Catalog\Model\ResourceModel\Product\Gallery;
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Store\Model\Store;
@@ -19,6 +20,8 @@
/**
* Provide tests for loading gallery images on product load.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ReadHandlerTest extends \PHPUnit\Framework\TestCase
{
@@ -47,6 +50,11 @@ class ReadHandlerTest extends \PHPUnit\Framework\TestCase
*/
private $productResource;
+ /**
+ * @var Gallery
+ */
+ private $galleryResource;
+
/**
* @var StoreRepositoryInterface
*/
@@ -67,6 +75,7 @@ protected function setUp()
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
$this->productFactory = $this->objectManager->get(ProductInterfaceFactory::class);
$this->productResource = $this->objectManager->get(ProductResource::class);
+ $this->galleryResource = $this->objectManager->create(Gallery::class);
$this->storeRepository = $this->objectManager->create(StoreRepositoryInterface::class);
$this->productLinkField = $this->objectManager->get(MetadataPool::class)
->getMetadata(ProductInterface::class)
@@ -261,6 +270,20 @@ public function executeOnStoreViewDataProvider(): array
];
}
+ /**
+ * @inheritdoc
+ */
+ protected function tearDown()
+ {
+ parent::tearDown();
+ $this->galleryResource->getConnection()
+ ->delete($this->galleryResource->getTable(Gallery::GALLERY_TABLE));
+ $this->galleryResource->getConnection()
+ ->delete($this->galleryResource->getTable(Gallery::GALLERY_VALUE_TABLE));
+ $this->galleryResource->getConnection()
+ ->delete($this->galleryResource->getTable(Gallery::GALLERY_VALUE_TO_ENTITY_TABLE));
+ }
+
/**
* Returns product for testing.
*
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
index bc0653a2f3118..fcee06187f374 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Gallery/UpdateHandlerTest.php
@@ -344,7 +344,14 @@ public function testExecuteWithTwoImagesOnStoreView(): void
*/
protected function tearDown()
{
+ parent::tearDown();
$this->mediaDirectory->getDriver()->deleteFile($this->mediaDirectory->getAbsolutePath($this->fileName));
+ $this->galleryResource->getConnection()
+ ->delete($this->galleryResource->getTable(Gallery::GALLERY_TABLE));
+ $this->galleryResource->getConnection()
+ ->delete($this->galleryResource->getTable(Gallery::GALLERY_VALUE_TABLE));
+ $this->galleryResource->getConnection()
+ ->delete($this->galleryResource->getTable(Gallery::GALLERY_VALUE_TO_ENTITY_TABLE));
}
/**
From a70d66bd934024d359456b23974be77538f5ae59 Mon Sep 17 00:00:00 2001
From: Nazarn96
Date: Thu, 31 Oct 2019 12:46:47 +0200
Subject: [PATCH 0855/1978] Fix static test
---
.../Patch/Data/SetInitialSearchWeightForAttributes.php | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php b/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php
index 2271fd1f674c9..21d5e82d494b5 100644
--- a/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php
+++ b/app/code/Magento/CatalogSearch/Setup/Patch/Data/SetInitialSearchWeightForAttributes.php
@@ -6,21 +6,21 @@
namespace Magento\CatalogSearch\Setup\Patch\Data;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Framework\App\State;
+use Magento\Framework\Indexer\IndexerInterfaceFactory;
use Magento\Framework\Setup\Patch\DataPatchInterface;
use Magento\Framework\Setup\Patch\PatchVersionInterface;
-use Magento\Framework\Indexer\IndexerInterfaceFactory;
-use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
/**
- * This patch sets up search weight for the product's system attributes.
- * Reindex required after patch applying.
+ * This patch sets up search weight for the product's system attributes, reindex required after patch applying.
*
* @deprecated
* @see \Magento\ElasticSearch
*/
class SetInitialSearchWeightForAttributes implements DataPatchInterface, PatchVersionInterface
{
+
/**
* @var IndexerInterfaceFactory
*/
From a26ca318c44c48ba60d3ecbc78ac997079eab527 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Tylek?=
Date: Thu, 31 Oct 2019 13:12:37 +0100
Subject: [PATCH 0856/1978] MAGETWO-98251 Sort properties alphabetically
---
.../Magento/blank/Magento_Catalog/web/css/source/_module.less | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less
index fb01510ce6732..44e93087399a1 100644
--- a/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less
+++ b/app/design/frontend/Magento/blank/Magento_Catalog/web/css/source/_module.less
@@ -457,10 +457,10 @@
.action {
&.delete {
&:extend(.abs-remove-button-for-blocks all);
+ line-height: unset;
position: absolute;
- top: -1px;
right: 0;
- line-height: unset;
+ top: -1px;
width: auto;
}
}
From 1ccd6a26d9b766a3ab6ffdedf6744a7e296aa485 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Tylek?=
Date: Thu, 31 Oct 2019 14:06:16 +0100
Subject: [PATCH 0857/1978] MAGETWO-98251 Fix Sidebar remove icon on category
page
---
.../Magento/blank/web/css/source/_layout.less | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/app/design/frontend/Magento/blank/web/css/source/_layout.less b/app/design/frontend/Magento/blank/web/css/source/_layout.less
index 62195b5566f8e..5490fba96b953 100644
--- a/app/design/frontend/Magento/blank/web/css/source/_layout.less
+++ b/app/design/frontend/Magento/blank/web/css/source/_layout.less
@@ -125,11 +125,16 @@
}
.page-layout-2columns-left {
- .sidebar-additional {
- clear: left;
- float: left;
- padding-left: 0;
- padding-right: @layout-column__additional-sidebar-offset;
+ .page-layout-2columns-left {
+ .main {
+ padding-left: @layout-column__additional-sidebar-offset
+ }
+
+ .sidebar-additional {
+ clear: left;
+ float: left;
+ padding-left: 0;
+ }
}
}
From 6e18b9835c54982b1b26b2ba079184a38bfdfcd6 Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Thu, 31 Oct 2019 15:14:53 +0200
Subject: [PATCH 0858/1978] Separating the test into 2 individual tests
---
...goryUrlRewriteEntityFirstVariationTest.xml | 52 +++++++++++++++++++
...ryUrlRewriteEntitySecondVariationTest.xml} | 29 ++---------
2 files changed, 55 insertions(+), 26 deletions(-)
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityFirstVariationTest.xml
rename app/code/Magento/UrlRewrite/Test/Mftf/Test/{AdminDeleteCategoryUrlRewriteEntityTest.xml => AdminDeleteCategoryUrlRewriteEntitySecondVariationTest.xml} (61%)
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityFirstVariationTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityFirstVariationTest.xml
new file mode 100644
index 0000000000000..c653bf2e910b1
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityFirstVariationTest.xml
@@ -0,0 +1,52 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntitySecondVariationTest.xml
similarity index 61%
rename from app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml
rename to app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntitySecondVariationTest.xml
index d0e976a1f9e3d..f613ee57296e9 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntityTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminDeleteCategoryUrlRewriteEntitySecondVariationTest.xml
@@ -7,10 +7,10 @@
-->
-
+
-
-
+
+
@@ -25,29 +25,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
From d9e0cfd9f0c438637221096874079eab5d820543 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Tylek?=
Date: Thu, 31 Oct 2019 14:27:18 +0100
Subject: [PATCH 0859/1978] MAGETWO-98251 Apply style fixes for Luma
---
.../web/css/source/_module.less | 20 ++++++++++++++++++-
.../web/css/source/module/_listings.less | 1 -
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
index 3b4da1d1ae6f5..00c5402d4f66e 100644
--- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
@@ -397,7 +397,7 @@
.box-tocart {
&:extend(.abs-box-tocart all);
-
+
.field.qty {
}
@@ -987,6 +987,24 @@
}
}
}
+
+.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__s) {
+ .sidebar {
+ .product-items {
+ .action {
+ &.delete {
+ &:extend(.abs-remove-button-for-blocks all);
+ position: absolute;
+ top: -1px;
+ right: 0;
+ line-height: unset;
+ width: auto;
+ }
+ }
+ }
+ }
+}
+
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
.compare.wrapper,
[class*='block-compare'] {
diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/module/_listings.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/module/_listings.less
index 92945d61e4368..6e7d7ebfb2c02 100644
--- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/module/_listings.less
+++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/module/_listings.less
@@ -366,7 +366,6 @@
}
.product-item-actions {
- position: relative;
z-index: 1;
}
}
From 4381ce215b9ec68a2c238b3c6c469c5c2f3103b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Tylek?=
Date: Thu, 31 Oct 2019 14:29:24 +0100
Subject: [PATCH 0860/1978] MAGETWO-98251 Sort properties alphabetically
---
.../Magento/luma/Magento_Catalog/web/css/source/_module.less | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
index 00c5402d4f66e..9b6986249b009 100644
--- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
@@ -994,10 +994,10 @@
.action {
&.delete {
&:extend(.abs-remove-button-for-blocks all);
+ line-height: unset;
position: absolute;
- top: -1px;
right: 0;
- line-height: unset;
+ top: -1px;
width: auto;
}
}
From 880b8c0cd94a9159a2d93e71124db2e51f337be1 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Thu, 31 Oct 2019 15:35:26 +0200
Subject: [PATCH 0861/1978] MC-20694: Admin: Delete attribute set
---
.../Magento/TestFramework/Eav/Model/GetAttributeSetByName.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
index e9164f5dcd87f..d7a7f0646742a 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
@@ -39,6 +39,8 @@ public function __construct(
}
/**
+ * Find attribute set by name and return it.
+ *
* @param string $attributeSetName
* @return AttributeSetInterface|null
*/
From 3c3c2672b8c7ae3f13951a9210a312ad33a204d7 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Thu, 31 Oct 2019 15:47:20 +0200
Subject: [PATCH 0862/1978] MC-20691: Admin: Update attribute set
---
.../Magento/TestFramework/Eav/Model/GetAttributeSetByName.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
index 12ff978a12e12..d7a7f0646742a 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeSetByName.php
@@ -12,7 +12,7 @@
use Magento\Framework\Api\SearchCriteriaBuilder;
/**
- * Attribute set additional functions.
+ * Search and return attribute set by name.
*/
class GetAttributeSetByName
{
@@ -39,7 +39,7 @@ public function __construct(
}
/**
- * Search and return attribute set by name.
+ * Find attribute set by name and return it.
*
* @param string $attributeSetName
* @return AttributeSetInterface|null
From 95e38b6f4653ed7dc9f4cafa7f1b5f473ac9e57b Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 31 Oct 2019 15:52:10 +0200
Subject: [PATCH 0863/1978] MC-21001: Add/move/delete attribute for attribute
sets
---
.../Eav/Model/GetAttributeGroupByName.php | 57 ++++++++++++++++
.../Model/Product/Attribute/SetTest.php | 68 ++++++++-----------
2 files changed, 85 insertions(+), 40 deletions(-)
create mode 100644 dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php
new file mode 100644
index 0000000000000..298050ff317db
--- /dev/null
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php
@@ -0,0 +1,57 @@
+searchCriteriaBuilder = $searchCriteriaBuilder;
+ $this->groupRepository = $attributeGroupRepository;
+ }
+
+ /**
+ * Returns attribute group by name.
+ *
+ * @param int $setId
+ * @param string $groupName
+ * @return AttributeGroupInterface|null
+ */
+ public function execute(int $setId, string $groupName): ?AttributeGroupInterface
+ {
+ $searchCriteria = $this->searchCriteriaBuilder->addFilter('attribute_group_name', $groupName)
+ ->addFilter('attribute_set_id', $setId)
+ ->create();
+ $result = $this->groupRepository->getList($searchCriteria)->getItems();
+
+ return array_shift($result);
+ }
+}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
index e865806975986..93efc41ca8c6e 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
@@ -7,16 +7,17 @@
namespace Magento\Catalog\Model\Product\Attribute;
+use Magento\Catalog\Api\ProductAttributeRepositoryInterface;
use Magento\Catalog\Model\Product;
use Magento\Catalog\Model\ResourceModel\Product\Attribute\CollectionFactory;
-use Magento\Eav\Api\AttributeGroupRepositoryInterface;
use Magento\Eav\Api\AttributeSetRepositoryInterface;
use Magento\Eav\Api\Data\AttributeGroupInterface;
use Magento\Eav\Model\Config;
use Magento\Eav\Model\ResourceModel\Entity\Attribute\Set as AttributeSetResource;
-use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\AttributeInterface;
use Magento\Framework\ObjectManagerInterface;
use Magento\TestFramework\Helper\Bootstrap;
+use Magento\TestFramework\Eav\Model\GetAttributeGroupByName;
/**
* Provides tests for attribute set model saving.
@@ -36,20 +37,15 @@ class SetTest extends \PHPUnit\Framework\TestCase
private $setRepository;
/**
- * @var AttributeGroupRepositoryInterface
+ * @var ProductAttributeRepositoryInterface
*/
- private $groupRepository;
+ private $attributeRepository;
/**
* @var Config
*/
private $config;
- /**
- * @var SearchCriteriaBuilder
- */
- private $criteriaBuilder;
-
/**
* @var AttributeSetResource
*/
@@ -65,6 +61,11 @@ class SetTest extends \PHPUnit\Framework\TestCase
*/
private $defaultSetId;
+ /**
+ * @var GetAttributeGroupByName
+ */
+ private $attributeGroupByName;
+
/**
* @inheritdoc
*/
@@ -73,12 +74,12 @@ protected function setUp()
parent::setUp();
$this->objectManager = Bootstrap::getObjectManager();
$this->setRepository = $this->objectManager->get(AttributeSetRepositoryInterface::class);
- $this->groupRepository = $this->objectManager->create(AttributeGroupRepositoryInterface::class);
+ $this->attributeRepository = $this->objectManager->create(ProductAttributeRepositoryInterface::class);
$this->config = $this->objectManager->get(Config::class);
$this->defaultSetId = (int)$this->config->getEntityType(Product::ENTITY)->getDefaultAttributeSetId();
- $this->criteriaBuilder = $this->objectManager->create(SearchCriteriaBuilder::class);
$this->attributeSetResource = $this->objectManager->get(AttributeSetResource::class);
$this->attributeCollectionFactory = $this->objectManager->get(CollectionFactory ::class);
+ $this->attributeGroupByName = $this->objectManager->get(GetAttributeGroupByName::class);
}
/**
@@ -91,10 +92,9 @@ protected function setUp()
public function testSaveWithGroupsAndAttributes(string $groupName, string $attributeCode): void
{
$set = $this->setRepository->get($this->defaultSetId);
- $groupId = $this->getAttributeGroup($groupName)
- ? $this->getAttributeGroup($groupName)->getAttributeGroupId()
- : 'ynode-1';
- $attributeId = (int)$this->config->getAttribute(Product::ENTITY, $attributeCode)->getAttributeId();
+ $attributeGroup = $this->getAttributeGroup($groupName);
+ $groupId = $attributeGroup ? $attributeGroup->getAttributeGroupId() : 'ynode-1';
+ $attributeId = (int)$this->attributeRepository->get($attributeCode)->getAttributeId();
$additional = [
'attributes' => [
[$attributeId, $groupId, 1],
@@ -177,11 +177,11 @@ public function testSaveWithRemovedGroup(): void
$this->getAttributeGroup('Design'),
'Group Design wan\'t deleted.'
);
- $unusedSetAttributes = $this->getUnusedSetAttributes((int)$set->getAttributeSetId());
+ $unusedSetAttributes = $this->getSetExcludedAttributes((int)$set->getAttributeSetId());
$designAttributeCodes = ['page_layout', 'options_container', 'custom_layout_update'];
$this->assertNotEmpty(
array_intersect($designAttributeCodes, $unusedSetAttributes),
- 'Attributes from Design group still assigned to attribute set.'
+ 'Attributes from "Design" group still assigned to attribute set.'
);
}
@@ -191,8 +191,7 @@ public function testSaveWithRemovedGroup(): void
public function testSaveWithRemovedAttribute(): void
{
$set = $this->setRepository->get($this->defaultSetId);
- $attributeId = (int)$this->config->getAttribute(Product::ENTITY, 'meta_description')
- ->getAttributeId();
+ $attributeId = (int)$this->attributeRepository->get('meta_description')->getAttributeId();
$additional = [
'not_attributes' => [$this->getEntityAttributeId($this->defaultSetId, $attributeId)],
];
@@ -201,7 +200,7 @@ public function testSaveWithRemovedAttribute(): void
$this->config->clear();
$setInfo = $this->attributeSetResource->getSetInfo([$attributeId], $this->defaultSetId);
$this->assertEmpty($setInfo[$attributeId]);
- $unusedSetAttributes = $this->getUnusedSetAttributes((int)$set->getAttributeSetId());
+ $unusedSetAttributes = $this->getSetExcludedAttributes((int)$set->getAttributeSetId());
$this->assertNotEmpty(
array_intersect(['meta_description'], $unusedSetAttributes),
'Attribute still assigned to attribute set.'
@@ -235,12 +234,7 @@ private function getAttributeSetData(array $additional): array
*/
private function getAttributeGroup(string $groupName): ?AttributeGroupInterface
{
- $searchCriteria = $this->criteriaBuilder->addFilter('attribute_group_name', $groupName)
- ->addFilter('attribute_set_id', $this->defaultSetId)
- ->create();
- $result = $this->groupRepository->getList($searchCriteria)->getItems();
-
- return !empty($result) ? reset($result) : null;
+ return $this->attributeGroupByName->execute($this->defaultSetId, $groupName);
}
/**
@@ -249,32 +243,26 @@ private function getAttributeGroup(string $groupName): ?AttributeGroupInterface
* @param int $setId
* @return array
*/
- private function getUnusedSetAttributes(int $setId): array
+ private function getSetExcludedAttributes(int $setId): array
{
- $result = [];
- $attributesIds = $this->attributeCollectionFactory->create()
- ->setAttributeSetFilter($setId)
- ->getAllIds();
$collection = $this->attributeCollectionFactory->create()
- ->setAttributesExcludeFilter($attributesIds)
- ->addVisibleFilter();
- /** @var AbstractAttribute $attribute */
- foreach ($collection as $attribute) {
- $result[] = $attribute->getAttributeCode();
- }
+ ->setExcludeSetFilter($setId);
+ $result = $collection->getColumnValues(AttributeInterface::ATTRIBUTE_CODE);
return $result;
}
/**
- * @param int|null $setId
+ * Returns entity attribute id.
+ *
+ * @param int $setId
* @param int $attributeId
* @return int
*/
- private function getEntityAttributeId(?int $setId, int $attributeId): int
+ private function getEntityAttributeId(int $setId, int $attributeId): int
{
$select = $this->attributeSetResource->getConnection()->select()
- ->from('eav_entity_attribute', ['entity_attribute_id'])
+ ->from($this->attributeSetResource->getTable('eav_entity_attribute'), ['entity_attribute_id'])
->where('attribute_set_id = ?', $setId)
->where('attribute_id = ?', $attributeId);
From 737254542c0fa06a4ff744c43a1d37d48aaa264b Mon Sep 17 00:00:00 2001
From: Stepan Furman
Date: Thu, 31 Oct 2019 15:33:08 +0100
Subject: [PATCH 0864/1978] MC-17633: Added depandancy on db version
---
.../Schema/Db/DefinitionAggregator.php | 38 ++++++++++++++++---
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
index 8d0bd4c31b6df..940e7cd2c2d5d 100644
--- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
+++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
@@ -6,6 +6,7 @@
namespace Magento\Framework\Setup\Declaration\Schema\Db;
+use Magento\Framework\App\ResourceConnection;
use Magento\Framework\Setup\Declaration\Schema\Dto\ElementInterface;
/**
@@ -18,14 +19,28 @@ class DefinitionAggregator implements DbDefinitionProcessorInterface
*/
private $definitionProcessors;
+ /**
+ * @var ResourceConnection
+ */
+ private $resourceConnection;
+
+ /**
+ * @var string
+ */
+ private $dbVersion;
+
/**
* Constructor.
*
+ * @param ResourceConnection $resourceConnection
* @param DbDefinitionProcessorInterface[] $definitionProcessors
*/
- public function __construct(array $definitionProcessors)
- {
+ public function __construct(
+ ResourceConnection $resourceConnection,
+ array $definitionProcessors
+ ) {
$this->definitionProcessors = $definitionProcessors;
+ $this->resourceConnection = $resourceConnection;
}
/**
@@ -64,6 +79,19 @@ public function fromDefinition(array $data)
return $definitionProcessor->fromDefinition($data);
}
+ /**
+ * @return string
+ */
+ private function getDatabaseVersion(): string
+ {
+ if (!$this->dbVersion) {
+ $this->dbVersion = $this->resourceConnection->getConnection('default')
+ ->fetchPairs("SHOW variables LIKE 'version'")['version'];
+ }
+
+ return $this->dbVersion;
+ }
+
/**
* Processes `$value` to be compatible with MySQL.
*
@@ -76,12 +104,12 @@ protected function processDefaultValue(array $data)
if ($defaultValue === null || $data['default'] === false) {
return $defaultValue;
}
- if ($defaultValue === "NULL") {
- return null;
- }
if ($defaultValue === "'NULL'") {
return "NULL";
}
+ if ($defaultValue === "NULL" && (bool) strpos($this->getDatabaseVersion(), 'MariaDB')) {
+ return null;
+ }
/*
* MariaDB replaces some defaults by their respective functions, e.g. `DEFAULT CURRENT_TIMESTAMP` ends up being
* `current_timestamp()` in the information schema.
From 8d0b83486a00e5fbd0a9354f7ebeee46316bd26e Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 31 Oct 2019 16:38:42 +0200
Subject: [PATCH 0865/1978] MC-21001: Add/move/delete attribute for attribute
sets
---
.../Magento/Catalog/Model/Product/Attribute/SetTest.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
index 93efc41ca8c6e..28df3984f2cad 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
@@ -105,7 +105,9 @@ public function testSaveWithGroupsAndAttributes(string $groupName, string $attri
];
$set->organizeData($this->getAttributeSetData($additional));
$this->attributeSetResource->save($set);
- $groupId = $this->getAttributeGroup($groupName)->getAttributeGroupId();
+ $groupId = $attributeGroup
+ ? $attributeGroup->getAttributeGroupId()
+ : $this->getAttributeGroup($groupName)->getAttributeGroupId();
$this->config->clear();
$setInfo = $this->attributeSetResource->getSetInfo([$attributeId], $this->defaultSetId);
$expectedInfo = [
@@ -230,7 +232,7 @@ private function getAttributeSetData(array $additional): array
* Returns attribute group by name.
*
* @param string $groupName
- * @return AttributeGroupInterface|Group|null
+ * @return AttributeGroupInterface|null
*/
private function getAttributeGroup(string $groupName): ?AttributeGroupInterface
{
From 243d3f8e4a6508840cc9c378866901b57e3fc716 Mon Sep 17 00:00:00 2001
From: Stepan Furman <15912461+Stepa4man@users.noreply.github.com>
Date: Thu, 31 Oct 2019 15:41:09 +0100
Subject: [PATCH 0866/1978] Update DefinitionAggregator.php
---
.../Setup/Declaration/Schema/Db/DefinitionAggregator.php | 2 ++
1 file changed, 2 insertions(+)
diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
index 940e7cd2c2d5d..d01c28ca7bc29 100644
--- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
+++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
@@ -80,6 +80,8 @@ public function fromDefinition(array $data)
}
/**
+ * Get DB version
+ *
* @return string
*/
private function getDatabaseVersion(): string
From 47fdb4c9840cff07d561dc932379df3955f69042 Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 31 Oct 2019 16:50:23 +0200
Subject: [PATCH 0867/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Magento/Catalog/Model/Product/Attribute/SetTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
index 28df3984f2cad..ada865ad83a4d 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/Product/Attribute/SetTest.php
@@ -177,7 +177,7 @@ public function testSaveWithRemovedGroup(): void
$this->attributeSetResource->save($set);
$this->assertNull(
$this->getAttributeGroup('Design'),
- 'Group Design wan\'t deleted.'
+ 'Group "Design" wan\'t deleted.'
);
$unusedSetAttributes = $this->getSetExcludedAttributes((int)$set->getAttributeSetId());
$designAttributeCodes = ['page_layout', 'options_container', 'custom_layout_update'];
From 3ad4a34837b5e46de91c03f4af6225575efa8ead Mon Sep 17 00:00:00 2001
From: Mykhailo Matiola
Date: Thu, 31 Oct 2019 16:55:17 +0200
Subject: [PATCH 0868/1978] MC-20660: Admin: Assign/delete image(s) from simple
product in single/multiple store views mode
---
.../Eav/Model/GetAttributeGroupByName.php | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php
index 298050ff317db..65ebe326fb939 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/Eav/Model/GetAttributeGroupByName.php
@@ -47,9 +47,13 @@ public function __construct(
*/
public function execute(int $setId, string $groupName): ?AttributeGroupInterface
{
- $searchCriteria = $this->searchCriteriaBuilder->addFilter('attribute_group_name', $groupName)
- ->addFilter('attribute_set_id', $setId)
- ->create();
+ $searchCriteria = $this->searchCriteriaBuilder->addFilter(
+ AttributeGroupInterface::GROUP_NAME,
+ $groupName
+ )->addFilter(
+ AttributeGroupInterface::ATTRIBUTE_SET_ID,
+ $setId
+ )->create();
$result = $this->groupRepository->getList($searchCriteria)->getItems();
return array_shift($result);
From 21189a1d64a40f3ee45bd63f92c823dcde418dbc Mon Sep 17 00:00:00 2001
From: Kate Kyzyma
Date: Thu, 31 Oct 2019 17:30:13 +0200
Subject: [PATCH 0869/1978] Separating the test into 3 individual tests.
---
...msPageRewriteEntityWithNoRedirectTest.xml} | 68 ++-------------
...eRewriteEntityWithPermanentReirectTest.xml | 85 +++++++++++++++++++
...RewriteEntityWithTemporaryRedirectTest.xml | 85 +++++++++++++++++++
3 files changed, 175 insertions(+), 63 deletions(-)
rename app/code/Magento/UrlRewrite/Test/Mftf/Test/{AdminUpdateCmsPageRewriteEntityTest.xml => AdminUpdateCmsPageRewriteEntityWithNoRedirectTest.xml} (53%)
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithPermanentReirectTest.xml
create mode 100644 app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithTemporaryRedirectTest.xml
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithNoRedirectTest.xml
similarity index 53%
rename from app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
rename to app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithNoRedirectTest.xml
index f772c62489a98..81dedfea7a35e 100644
--- a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityTest.xml
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithNoRedirectTest.xml
@@ -7,10 +7,10 @@
-->
-
+
-
-
+
+
@@ -53,7 +53,7 @@
-
+
@@ -80,66 +80,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithPermanentReirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithPermanentReirectTest.xml
new file mode 100644
index 0000000000000..f073794896c2c
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithPermanentReirectTest.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithTemporaryRedirectTest.xml b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithTemporaryRedirectTest.xml
new file mode 100644
index 0000000000000..8f04fe7cf9ab9
--- /dev/null
+++ b/app/code/Magento/UrlRewrite/Test/Mftf/Test/AdminUpdateCmsPageRewriteEntityWithTemporaryRedirectTest.xml
@@ -0,0 +1,85 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From f36438f31b42b0ff7c1d8e4ead8ca7bf75be7899 Mon Sep 17 00:00:00 2001
From: Eden
Date: Thu, 31 Oct 2019 22:33:58 +0700
Subject: [PATCH 0870/1978] [Review] Unit Test to cover Helper Data
---
.../Review/Test/Unit/Helper/DataTest.php | 163 ++++++++++++++++++
1 file changed, 163 insertions(+)
create mode 100644 app/code/Magento/Review/Test/Unit/Helper/DataTest.php
diff --git a/app/code/Magento/Review/Test/Unit/Helper/DataTest.php b/app/code/Magento/Review/Test/Unit/Helper/DataTest.php
new file mode 100644
index 0000000000000..7473018c0eaa2
--- /dev/null
+++ b/app/code/Magento/Review/Test/Unit/Helper/DataTest.php
@@ -0,0 +1,163 @@
+context = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->filter = $this->getMockBuilder(FilterManager::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['truncate'])
+ ->getMock();
+
+ $this->escaper = $this->getMockBuilder(Escaper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $this->context->expects($this->once())
+ ->method('getScopeConfig')
+ ->willReturn($this->scopeConfig);
+
+ $this->objectManager = new ObjectManagerHelper($this);
+ $this->helper = $this->objectManager->getObject(
+ HelperData::class,
+ [
+ 'context' => $this->context,
+ 'escaper' => $this->escaper,
+ 'filter' => $this->filter
+ ]
+ );
+ }
+
+ /**
+ * Test getDetail() function
+ */
+ public function testGetDetail()
+ {
+ $origDetail = "This\nis\na\nstring";
+ $expected = "This "."\n"."is "."\n"."a "."\n"."string";
+
+ $this->filter->expects($this->any())->method('truncate')
+ ->with($origDetail, ['length' => 50])
+ ->willReturn($origDetail);
+
+ $this->assertEquals($expected, $this->helper->getDetail($origDetail));
+ }
+
+ /**
+ * Test getDetailHtml() function
+ */
+ public function getDetailHtml()
+ {
+ $origDetail = "This\nis\na\nstring ";
+ $origDetailEscapeHtml = "This\nis\na\nstring";
+ $expected = "This "."\n"."is "."\n"."a "."\n"."string";
+
+ $this->escaper->expects($this->any())->method('escapeHtml')
+ ->with($origDetail)
+ ->willReturn($origDetailEscapeHtml);
+
+ $this->filter->expects($this->any())->method('truncate')
+ ->with($origDetailEscapeHtml, ['length' => 50])
+ ->willReturn($origDetailEscapeHtml);
+
+ $this->assertEquals($expected, $this->helper->getDetail($origDetail));
+ }
+
+ /**
+ * Test getIsGuestAllowToWrite() function
+ */
+ public function testGetIsGuestAllowToWrite()
+ {
+ $this->scopeConfig->expects($this->any())->method('isSetFlag')
+ ->with('catalog/review/allow_guest', ScopeInterface::SCOPE_STORE)
+ ->willReturn('1');
+
+ $this->assertEquals(true, $this->helper->getIsGuestAllowToWrite());
+ }
+
+ /**
+ * Test getReviewStatuses() function
+ */
+ public function testGetReviewStatuses()
+ {
+ $expected = [
+ 1 => __('Approved'),
+ 2 => __('Pending'),
+ 3 => __('Not Approved')
+ ];
+ $this->assertEquals($expected, $this->helper->getReviewStatuses());
+ }
+
+ /**
+ * Test getReviewStatusesOptionArray() function
+ */
+ public function testGetReviewStatusesOptionArray()
+ {
+ $expected = [
+ ['value' => 1, 'label' => __('Approved')],
+ ['value' => 2, 'label' => __('Pending')],
+ ['value' => 3, 'label' => __('Not Approved')]
+ ];
+ $this->assertEquals($expected, $this->helper->getReviewStatusesOptionArray());
+ }
+}
From ef9ef0d61c259c23b3aa4f6c3e04d7862f1211e0 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 10:48:34 -0500
Subject: [PATCH 0871/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Indexer/Category/Product/Action/Rows.php | 88 ++++++++++++++++++-
.../Plugin/Product/Category/Action/Rows.php | 51 +++++++++++
app/code/Magento/CatalogSearch/etc/di.xml | 3 +
3 files changed, 141 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
index 3bd4910767587..a7edcc03de4e6 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
@@ -5,6 +5,17 @@
*/
namespace Magento\Catalog\Model\Indexer\Category\Product\Action;
+use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\Indexer\CacheContext;
+use Magento\Framework\Event\ManagerInterface as EventManagerInterface;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\App\ResourceConnection;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Framework\DB\Query\Generator as QueryGenerator;
+use Magento\Framework\EntityManager\MetadataPool;
+use Magento\Catalog\Model\Config;
+use Magento\Catalog\Model\Category;
+
class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
{
/**
@@ -14,6 +25,39 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
*/
protected $limitationByCategories;
+ /**
+ * @var CacheContext
+ */
+ private $cacheContext;
+
+ /**
+ * @var EventManagerInterface|null
+ */
+ private $eventManager;
+
+ /**
+ * @param ResourceConnection $resource
+ * @param StoreManagerInterface $storeManager
+ * @param Config $config
+ * @param QueryGenerator|null $queryGenerator
+ * @param MetadataPool|null $metadataPool
+ * @param CacheContext|null $cacheContext
+ * @param EventManagerInterface|null $eventManager
+ */
+ public function __construct(
+ ResourceConnection $resource,
+ StoreManagerInterface $storeManager,
+ Config $config,
+ QueryGenerator $queryGenerator = null,
+ MetadataPool $metadataPool = null,
+ CacheContext $cacheContext = null,
+ EventManagerInterface $eventManager = null
+ ) {
+ parent::__construct($resource, $storeManager, $config, $queryGenerator, $metadataPool);
+ $this->cacheContext = $cacheContext ?: ObjectManager::getInstance()->get(CacheContext::class);
+ $this->eventManager = $eventManager ?: ObjectManager::getInstance()->get(EventManagerInterface::class);
+ }
+
/**
* Refresh entities index
*
@@ -26,13 +70,55 @@ public function execute(array $entityIds = [], $useTempTable = false)
$this->limitationByCategories = $entityIds;
$this->useTempTable = $useTempTable;
- $this->removeEntries();
+ if ($useTempTable) {
+ foreach ($this->storeManager->getStores() as $store) {
+ $this->connection->truncateTable($this->getIndexTable($store->getId()));
+ }
+ } else {
+ $this->removeEntries();
+ }
$this->reindex();
+ if ($useTempTable) {
+ foreach ($this->storeManager->getStores() as $store) {
+ $removalCategoryIds = array_diff($this->limitationByCategories, [$this->getRootCategoryId($store)]);
+ $this->connection->delete(
+ $this->tableMaintainer->getMainTable($store->getId()),
+ ['category_id IN (?)' => $removalCategoryIds]
+ );
+ $select = $this->connection->select()
+ ->from($this->tableMaintainer->getMainReplicaTable($store->getId()));
+ $this->connection->query(
+ $this->connection->insertFromSelect(
+ $select,
+ $this->tableMaintainer->getMainTable($store->getId()),
+ [],
+ AdapterInterface::INSERT_ON_DUPLICATE
+ )
+ );
+ }
+ }
+
+ $this->registerCategories($entityIds);
+ $this->eventManager->dispatch('clean_cache_by_tags', ['object' => $this->cacheContext]);
+
return $this;
}
+ /**
+ * Register categories assigned to products
+ *
+ * @param array $categoryIds
+ * @return void
+ */
+ private function registerCategories(array $categoryIds)
+ {
+ if ($categoryIds) {
+ $this->cacheContext->registerEntities(Category::CACHE_TAG, $categoryIds);
+ }
+ }
+
/**
* Return array of all category root IDs + tree root ID
*
diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php
new file mode 100644
index 0000000000000..b8e60b9973731
--- /dev/null
+++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php
@@ -0,0 +1,51 @@
+indexerRegistry = $indexerRegistry;
+ }
+
+ /**
+ * Reindex after catalog category product reindex
+ *
+ * @param ActionRows $subject
+ * @param ActionRows $result
+ * @param array $entityIds
+ * @param boolean $useTempTable
+ * @return Rows
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
+ */
+ public function afterExecute(ActionRows $subject, ActionRows $result, array $entityIds, $useTempTable)
+ {
+ if (!empty($entityIds)) {
+ $indexer = $this->indexerRegistry->get(FulltextIndexer::INDEXER_ID);
+ if ($indexer->isScheduled()) {
+ $indexer->reindexList($entityIds);
+ }
+ }
+ return $result;
+ }
+}
diff --git a/app/code/Magento/CatalogSearch/etc/di.xml b/app/code/Magento/CatalogSearch/etc/di.xml
index 372b389c545e6..4e5b38878ee52 100644
--- a/app/code/Magento/CatalogSearch/etc/di.xml
+++ b/app/code/Magento/CatalogSearch/etc/di.xml
@@ -75,6 +75,9 @@
+
+
+
From b2f0af09a495b3e28c2ac128b696740781e9b9e6 Mon Sep 17 00:00:00 2001
From: Kevin Kozan
Date: Thu, 31 Oct 2019 10:51:36 -0500
Subject: [PATCH 0872/1978] MQE-1879: Deliver MFTF 2.5.3 to mainline branches
- composer version bump
---
composer.json | 2 +-
composer.lock | 24 ++++++++++++------------
2 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/composer.json b/composer.json
index c2dcb72760716..4b0ad8a67fedb 100644
--- a/composer.json
+++ b/composer.json
@@ -88,7 +88,7 @@
"friendsofphp/php-cs-fixer": "~2.14.0",
"lusitanian/oauth": "~0.8.10",
"magento/magento-coding-standard": "~4.0.0",
- "magento/magento2-functional-testing-framework": "2.5.2",
+ "magento/magento2-functional-testing-framework": "2.5.3",
"pdepend/pdepend": "2.5.2",
"phpcompatibility/php-compatibility": "^9.3",
"phpmd/phpmd": "@stable",
diff --git a/composer.lock b/composer.lock
index 29738d54b26e7..49177a9159559 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "ec6a11c24090ea9f5c1af2341c94b39e",
+ "content-hash": "2e70a2d627872624e03d089cd7e51618",
"packages": [
{
"name": "braintree/braintree_php",
@@ -7201,16 +7201,16 @@
},
{
"name": "magento/magento2-functional-testing-framework",
- "version": "2.5.2",
+ "version": "2.5.3",
"source": {
"type": "git",
"url": "https://github.com/magento/magento2-functional-testing-framework.git",
- "reference": "e254e738b3a3fa2eceec9be0590c2aad0e689640"
+ "reference": "f627085a469da79e4a628d4bf0452f12aefa4389"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/magento/magento2-functional-testing-framework/zipball/e254e738b3a3fa2eceec9be0590c2aad0e689640",
- "reference": "e254e738b3a3fa2eceec9be0590c2aad0e689640",
+ "url": "https://api.github.com/repos/magento/magento2-functional-testing-framework/zipball/f627085a469da79e4a628d4bf0452f12aefa4389",
+ "reference": "f627085a469da79e4a628d4bf0452f12aefa4389",
"shasum": ""
},
"require": {
@@ -7275,7 +7275,7 @@
"magento",
"testing"
],
- "time": "2019-10-23T14:50:28+00:00"
+ "time": "2019-10-31T14:52:02+00:00"
},
{
"name": "mikey179/vfsstream",
@@ -7907,20 +7907,20 @@
"authors": [
{
"name": "Manuel Pichler",
- "role": "Project Founder",
"email": "github@manuel-pichler.de",
- "homepage": "https://github.com/manuelpichler"
+ "homepage": "https://github.com/manuelpichler",
+ "role": "Project Founder"
},
{
"name": "Marc Würth",
- "role": "Project Maintainer",
"email": "ravage@bluewin.ch",
- "homepage": "https://github.com/ravage84"
+ "homepage": "https://github.com/ravage84",
+ "role": "Project Maintainer"
},
{
"name": "Other contributors",
- "role": "Contributors",
- "homepage": "https://github.com/phpmd/phpmd/graphs/contributors"
+ "homepage": "https://github.com/phpmd/phpmd/graphs/contributors",
+ "role": "Contributors"
}
],
"description": "PHPMD is a spin-off project of PHP Depend and aims to be a PHP equivalent of the well known Java tool PMD.",
From b0382ec5f79c35b61cab07dcbb34cf6313206792 Mon Sep 17 00:00:00 2001
From: Joan He
Date: Thu, 31 Oct 2019 10:57:03 -0500
Subject: [PATCH 0873/1978] MC-22176: Implement granular ACL for B2B related
store configurations
---
.../TestFramework/TestCase/AbstractBackendController.php | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php
index 5205d96bb8cf7..920cde4b7df09 100644
--- a/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php
+++ b/dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php
@@ -46,7 +46,7 @@ abstract class AbstractBackendController extends \Magento\TestFramework\TestCase
*
* @var int
*/
- protected $expectedNoAccessResponse = 403;
+ protected $expectedNoAccessResponseCode = 403;
/**
* @inheritDoc
@@ -103,9 +103,8 @@ public function testAclHasAccess()
$this->getRequest()->setMethod($this->httpMethod);
}
$this->dispatch($this->uri);
- $this->assertNotSame(403, $this->getResponse()->getHttpResponseCode());
$this->assertNotSame(404, $this->getResponse()->getHttpResponseCode());
- $this->assertNotSame($this->expectedNoAccessResponse, $this->getResponse()->getHttpResponseCode());
+ $this->assertNotSame($this->expectedNoAccessResponseCode, $this->getResponse()->getHttpResponseCode());
}
/**
@@ -123,6 +122,6 @@ public function testAclNoAccess()
->getAcl()
->deny(null, $this->resource);
$this->dispatch($this->uri);
- $this->assertSame($this->expectedNoAccessResponse, $this->getResponse()->getHttpResponseCode());
+ $this->assertSame($this->expectedNoAccessResponseCode, $this->getResponse()->getHttpResponseCode());
}
}
From e08dad11943a92102337063e269a2c35b2fe6aab Mon Sep 17 00:00:00 2001
From: Iryna Lagno
Date: Thu, 31 Oct 2019 11:05:21 -0500
Subject: [PATCH 0874/1978] MC-21958: Merge to mainline EPAM PR 84
- mftf tests stabilization
---
...eckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
index e644411d34cc4..42516e5a5a363 100644
--- a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminCheckThatSomeAttributesChangedValueToEmptyAfterImportTest.xml
@@ -21,6 +21,9 @@
+
+
+
From 0654113f1b6d9adcd5e34046697c26e943e51cdc Mon Sep 17 00:00:00 2001
From: Oleksandr Gorkun
Date: Thu, 31 Oct 2019 11:14:20 -0500
Subject: [PATCH 0875/1978] MC-22139: Introduce batch GraphQL resolvers
---
.../Magento/Catalog/Model/ProductLink/CollectionProvider.php | 2 ++
app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php | 2 ++
2 files changed, 4 insertions(+)
diff --git a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
index 87371312f8d48..7b25533ff72b8 100644
--- a/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
+++ b/app/code/Magento/Catalog/Model/ProductLink/CollectionProvider.php
@@ -4,6 +4,8 @@
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Catalog\Model\ProductLink;
use Magento\Catalog\Model\Product;
diff --git a/app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php b/app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php
index c537bc9337b7b..4bc400605a429 100644
--- a/app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php
+++ b/app/code/Magento/Catalog/Model/ProductLink/ProductLinkQuery.php
@@ -22,6 +22,8 @@
* Search for product links by criteria.
*
* Batch contract for getting product links.
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ProductLinkQuery
{
From 7e1b806d157bafed8aff3bb83663c1d9be068c16 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 11:36:14 -0500
Subject: [PATCH 0876/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Catalog/Model/Indexer/Category/Product/Action/Rows.php | 3 +++
.../Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php | 5 +----
.../Elasticsearch/Observer/CategoryProductIndexer.php | 1 -
3 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
index a7edcc03de4e6..6b6e10c5ca799 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
@@ -16,6 +16,9 @@
use Magento\Catalog\Model\Config;
use Magento\Catalog\Model\Category;
+/**
+ * Action for partial reindex
+ */
class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
{
/**
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
index 7a7c11e95d9b7..fbc59e386305c 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
@@ -84,7 +84,6 @@ public function testExecuteWithIndexerWorking()
{
$ids = [1, 2, 3];
- $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(true));
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
@@ -92,7 +91,6 @@ public function testExecuteWithIndexerWorking()
['execute']
);
$rowMock->expects($this->at(0))->method('execute')->with($ids, true)->will($this->returnSelf());
- $rowMock->expects($this->at(1))->method('execute')->with($ids, false)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
@@ -103,14 +101,13 @@ public function testExecuteWithIndexerNotWorking()
{
$ids = [1, 2, 3];
- $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false));
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
\Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class,
['execute']
);
- $rowMock->expects($this->once())->method('execute')->with($ids, false)->will($this->returnSelf());
+ $rowMock->expects($this->once())->method('execute')->with($ids, true)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
diff --git a/app/code/Magento/Elasticsearch/Observer/CategoryProductIndexer.php b/app/code/Magento/Elasticsearch/Observer/CategoryProductIndexer.php
index 571799f3b8f4b..e2b3e18a0ffb9 100644
--- a/app/code/Magento/Elasticsearch/Observer/CategoryProductIndexer.php
+++ b/app/code/Magento/Elasticsearch/Observer/CategoryProductIndexer.php
@@ -53,7 +53,6 @@ public function __construct(
*/
public function execute(Observer $observer): void
{
- return;
if (!$this->config->isElasticsearchEnabled()) {
return;
}
From 76b6536f5f570e9208ebe505d3c7a46323a033f0 Mon Sep 17 00:00:00 2001
From: Soumya Unnikrishnan
Date: Thu, 31 Oct 2019 11:44:38 -0500
Subject: [PATCH 0877/1978] MQE-1872: [MTF-MFTF] Process PR #348 Adding
reindexing and caching to fix B2B failures due to products not appearing on
storefront
---
...ingNewOptionsWithImagesAndPricesToConfigurableProductTest.xml | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAddingNewOptionsWithImagesAndPricesToConfigurableProductTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAddingNewOptionsWithImagesAndPricesToConfigurableProductTest.xml
index 33ba3ef1f4561..36c135c427365 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAddingNewOptionsWithImagesAndPricesToConfigurableProductTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminAddingNewOptionsWithImagesAndPricesToConfigurableProductTest.xml
@@ -30,6 +30,7 @@
+
From a01cd927b9024bf2bf420b5a034aa0d1b918fdec Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 12:03:41 -0500
Subject: [PATCH 0878/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Magento/Catalog/Model/Indexer/Category/Product.php | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
index 8458549456f41..542232d25f6a3 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
@@ -133,10 +133,18 @@ public function executeRow($id)
protected function executeAction($ids)
{
$ids = array_unique($ids);
+ $indexer = $this->indexerRegistry->get(static::INDEXER_ID);
/** @var Product\Action\Rows $action */
$action = $this->rowsActionFactory->create();
- $action->execute($ids, true);
+ if ($indexer->isScheduled()) {
+ $action->execute($ids, true);
+ } else {
+ if ($indexer->isWorking()) {
+ $action->execute($ids, true);
+ }
+ $action->execute($ids);
+ }
return $this;
}
From aba9ac6d2c9753fdbd5dd030d7ce825975230393 Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 31 Oct 2019 13:32:45 -0500
Subject: [PATCH 0879/1978] MC-21542: Category query does not handle disabled
children properly
- add test
---
.../GraphQl/Catalog/CategoryListTest.php | 73 +++++++++++++++++++
.../Catalog/_files/categories_disabled.php | 16 ++++
.../_files/categories_disabled_rollback.php | 7 ++
3 files changed, 96 insertions(+)
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php
create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
index 0e88af2fcb22e..6ffd0c66c114a 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
@@ -209,6 +209,79 @@ public function testQueryChildCategoriesWithProducts()
$this->assertCategoryChildren($secondChildCategory, $firstChildCategoryChildren);
}
+ /**
+ * @magentoApiDataFixture Magento/Catalog/_files/categories_disabled.php
+ */
+ public function testQueryChildCategoriesWithProductsDisabled()
+ {
+ $query = <<graphQlQuery($query);
+
+ $this->assertArrayNotHasKey('errors', $result);
+ $this->assertCount(1, $result['categoryList']);
+ $baseCategory = $result['categoryList'][0];
+
+ $this->assertEquals('Category 1', $baseCategory['name']);
+ $this->assertArrayHasKey('products', $baseCategory);
+ //Check base category products
+ $expectedBaseCategoryProducts = [
+ ['sku' => 'simple', 'name' => 'Simple Product'],
+ ['sku' => '12345', 'name' => 'Simple Product Two'],
+ ['sku' => 'simple-4', 'name' => 'Simple Product Three']
+ ];
+ $this->assertCategoryProducts($baseCategory, $expectedBaseCategoryProducts);
+ //Check base category children
+ $expectedBaseCategoryChildren = [
+ ['name' => 'Category 1.2', 'description' => 'Its a description of Test Category 1.2']
+ ];
+ $this->assertCategoryChildren($baseCategory, $expectedBaseCategoryChildren);
+
+ //Check first child category
+ $firstChildCategory = $baseCategory['children'][0];
+ $this->assertEquals('Category 1.2', $firstChildCategory['name']);
+ $this->assertEquals('Its a description of Test Category 1.2', $firstChildCategory['description']);
+
+ $firstChildCategoryExpectedProducts = [
+ ['sku' => 'simple', 'name' => 'Simple Product'],
+ ['sku' => 'simple-4', 'name' => 'Simple Product Three']
+ ];
+ $this->assertCategoryProducts($firstChildCategory, $firstChildCategoryExpectedProducts);
+ $firstChildCategoryChildren = [];
+ $this->assertCategoryChildren($firstChildCategory, $firstChildCategoryChildren);
+ }
+
/**
* @magentoApiDataFixture Magento/Catalog/_files/categories.php
*/
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php
new file mode 100644
index 0000000000000..4dd39335705e1
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php
@@ -0,0 +1,16 @@
+create(\Magento\Catalog\Model\Category::class);
+
+$category->load(4);
+$category->setIsActive(false);
+$category->save();
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php
new file mode 100644
index 0000000000000..44c441b956c52
--- /dev/null
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php
@@ -0,0 +1,7 @@
+
Date: Thu, 31 Oct 2019 13:33:27 -0500
Subject: [PATCH 0880/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index a25f1e71bab5b..a9ba367ed301a 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1364,6 +1364,7 @@ public function getChildrenData()
* @return array
* @todo refactor with converter for AbstractExtensibleModel
*/
+ // phpcs:ignore Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
public function __toArray()
{
$data = $this->_data;
From c235ba64bca0c8b0f33e1d3ef14fae48e705aa14 Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 31 Oct 2019 13:49:08 -0500
Subject: [PATCH 0881/1978] MC-21542: Category query does not handle disabled
children properly
- add test
---
.../Catalog/_files/categories_disabled.php | 18 ++++++++++++++++++
.../_files/categories_disabled_rollback.php | 17 +++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php
index 4dd39335705e1..26f4565d70b37 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled.php
@@ -8,9 +8,27 @@
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+// Adding 4th level ensures an edge case for which 3 levels of categories would not be enough
+$category = $objectManager->create(\Magento\Catalog\Model\Category::class);
+$category->isObjectNew(true);
+$category->setId(59)
+ ->setName('Category 1.1.1.1')
+ ->setParentId(5)
+ ->setPath('1/2/3/4/5/59')
+ ->setLevel(5)
+ ->setAvailableSortBy('name')
+ ->setDefaultSortBy('name')
+ ->setIsActive(true)
+ ->setPosition(1)
+ ->setCustomUseParentSettings(0)
+ ->setCustomDesign('Magento/blank')
+ ->setDescription('This is the description for Category 1.1.1.1')
+ ->save();
+
/** @var $category \Magento\Catalog\Model\Category */
$category = $objectManager->create(\Magento\Catalog\Model\Category::class);
+// Category 1.1.1
$category->load(4);
$category->setIsActive(false);
$category->save();
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php
index 44c441b956c52..cc42bd6a09753 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/categories_disabled_rollback.php
@@ -5,3 +5,20 @@
*/
include __DIR__ . '/categories_rollback.php';
+
+$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
+/** @var \Magento\Framework\Registry $registry */
+$registry = $objectManager->get(\Magento\Framework\Registry::class);
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var Magento\Catalog\Model\ResourceModel\Category\Collection $collection */
+$collection = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Category\Collection::class);
+foreach ($collection->addAttributeToFilter('level', ['in' => [59]]) as $category) {
+ /** @var \Magento\Catalog\Model\Category $category */
+ $category->delete();
+}
+
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From 70d3cec1c1bc9cd0811b6d4dfedfb2457fcbb5f8 Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 31 Oct 2019 13:49:43 -0500
Subject: [PATCH 0882/1978] MC-21542: Category query does not handle disabled
children properly
- add test
---
.../testsuite/Magento/GraphQl/Catalog/CategoryListTest.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
index 6ffd0c66c114a..fdba91890faf7 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
@@ -219,6 +219,7 @@ public function testQueryChildCategoriesWithProductsDisabled()
categoryList(filters: {ids: {in: ["3"]}}){
id
name
+ image
url_key
url_path
description
@@ -231,6 +232,7 @@ public function testQueryChildCategoriesWithProductsDisabled()
}
children{
name
+ image
url_key
description
products{
@@ -242,6 +244,7 @@ public function testQueryChildCategoriesWithProductsDisabled()
}
children{
name
+ image
}
}
}
From cfd75ccf0153fe2b4bffa58e9840ff6f92275386 Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 31 Oct 2019 13:50:52 -0500
Subject: [PATCH 0883/1978] MC-21542: Category query does not handle disabled
children properly
- add test
---
.../testsuite/Magento/GraphQl/Catalog/CategoryTest.php | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php
index 480388db98d2f..39895e63a249c 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php
@@ -75,6 +75,10 @@ public function testCategoriesTree()
children {
level
id
+ children {
+ level
+ id
+ }
}
}
}
From 713b022096728f2dae29992d6e4c08273a9fa1ab Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Thu, 31 Oct 2019 13:51:43 -0500
Subject: [PATCH 0884/1978] MC-22216: Tests for the customerCart Query
- use case for second store
---
.../Quote/Customer/GetCustomerCartTest.php | 44 +++++++++++++++++--
1 file changed, 41 insertions(+), 3 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
index adddbd8b14983..4d81f4c8cca4a 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
@@ -12,6 +12,9 @@
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;
+use Magento\Quote\Api\CartManagementInterface;
+use Magento\Quote\Api\CartRepositoryInterface;
+use Magento\Quote\Model\QuoteIdMaskFactory;
/**
* Test for getting Customer cart information
@@ -28,13 +31,31 @@ class GetCustomerCartTest extends GraphQlAbstract
*/
private $customerTokenService;
+ /** @var array */
private $headers;
+ /**
+ * @var CartManagementInterface
+ */
+ private $cartManagement;
+
+ /**
+ * @var CartRepositoryInterface
+ */
+ private $cartRepository;
+ /**
+ * @var QuoteIdMaskFactory
+ */
+ private $quoteIdMaskFactory;
+
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
+ $this->cartManagement = $objectManager->get(CartManagementInterface::class);
+ $this->cartRepository = $objectManager->get(CartRepositoryInterface::class);
+ $this->quoteIdMaskFactory = $objectManager->get(QuoteIdMaskFactory::class);
}
/**
@@ -137,7 +158,7 @@ public function testRequestCustomerCartTwice()
}
/**
- * Query for inactive Customer cart
+ * Query for inactive Customer cart - in case of not finding an active cart, it should create a new one
*
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
@@ -149,9 +170,26 @@ public function testGetInactiveCustomerCart()
{
$customerCartQuery = $this->getCustomerCartQuery();
$response = $this->graphQlQuery($customerCartQuery, [], '', $this->getHeaderMap());
- $i =0;
$this->assertArrayHasKey('customerCart', $response);
- $this->assertEmpty($response['customerCart']);
+ $this->assertNotEmpty($response['customerCart']['cart_id']);
+ $this->assertEmpty($response['customerCart']['items']);
+ $this->assertEmpty($response['customerCart']['total_quantity']);
+ }
+
+ /**
+ * Querying for an existing customer cart for second store
+ *
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote_customer_not_default_store.php
+ */
+ public function testGetCustomerCartSecondStore()
+ {
+ $maskedQuoteIdSecondStore = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1_not_default_store');
+ $customerCartQuery = $this->getCustomerCartQuery();
+
+ $headerMap = $this->getHeaderMap();
+ $headerMap['Store'] = 'fixture_second_store';
+ $responseSecondStore = $this->graphQlQuery($customerCartQuery, [], '', $headerMap);
+ $this->assertEquals($maskedQuoteIdSecondStore, $responseSecondStore['customerCart']['cart_id']);
}
/**
From 4dff7db717b62c3639e73f21d26519084c0bad7a Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 31 Oct 2019 13:53:35 -0500
Subject: [PATCH 0885/1978] MC-21542: Category query does not handle disabled
children properly
- add test
---
.../testsuite/Magento/GraphQl/Catalog/CategoryListTest.php | 4 ++++
.../testsuite/Magento/GraphQl/Catalog/CategoryTest.php | 4 ----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
index fdba91890faf7..de086b3d45009 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
@@ -245,6 +245,10 @@ public function testQueryChildCategoriesWithProductsDisabled()
children{
name
image
+ children{
+ name
+ image
+ }
}
}
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php
index 39895e63a249c..480388db98d2f 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryTest.php
@@ -75,10 +75,6 @@ public function testCategoriesTree()
children {
level
id
- children {
- level
- id
- }
}
}
}
From e0660d9a5b1763cc975980d5b852a2121c8a0164 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Corr=C3=AAa=20Gomes?=
Date: Thu, 31 Oct 2019 16:11:02 -0300
Subject: [PATCH 0886/1978] README > Syntax fix
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e73da84d66f46..f67435fa3ff7c 100644
--- a/README.md
+++ b/README.md
@@ -27,7 +27,7 @@ To suggest documentation improvements, click [here][4].
[4]:
Community Maintainers
-The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks these Community Maintainers for their valuable contributions.
+The members of this team have been recognized for their outstanding commitment to maintaining and improving Magento. Magento has granted them permission to accept, merge, and reject pull requests, as well as review issues, and thanks to these Community Maintainers for their valuable contributions.
From 0b15743728ecee6882c7faeba4d5d8ed80fd25e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafael=20Corr=C3=AAa=20Gomes?=
Date: Thu, 31 Oct 2019 16:19:44 -0300
Subject: [PATCH 0887/1978] README > Welcome section title
---
README.md | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e73da84d66f46..bf45a90c9deb2 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,8 @@
[![Open Source Helpers](https://www.codetriage.com/magento/magento2/badges/users.svg)](https://www.codetriage.com/magento/magento2)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/magento/magento2?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Crowdin](https://d322cqt584bo4o.cloudfront.net/magento-2/localized.svg)](https://crowdin.com/project/magento-2)
-Welcome
+
+## Welcome
Welcome to Magento 2 installation! We're glad you chose to install Magento 2, a cutting-edge, feature-rich eCommerce solution that gets results.
## Magento system requirements
From 45a2efac12536d3dc3edd19be4cd0cd3f3d66b7b Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 14:41:18 -0500
Subject: [PATCH 0888/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Catalog/Model/Indexer/Category/Product.php | 10 +---------
.../Indexer/Category/Product/Action/Rows.php | 18 +++++++++++++++---
.../Indexer/Product/Category/Action/Rows.php | 18 +++++++++++++++---
3 files changed, 31 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
index 542232d25f6a3..8458549456f41 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
@@ -133,18 +133,10 @@ public function executeRow($id)
protected function executeAction($ids)
{
$ids = array_unique($ids);
- $indexer = $this->indexerRegistry->get(static::INDEXER_ID);
/** @var Product\Action\Rows $action */
$action = $this->rowsActionFactory->create();
- if ($indexer->isScheduled()) {
- $action->execute($ids, true);
- } else {
- if ($indexer->isWorking()) {
- $action->execute($ids, true);
- }
- $action->execute($ids);
- }
+ $action->execute($ids, true);
return $this;
}
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
index 6b6e10c5ca799..6ec911805cd13 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
@@ -15,6 +15,8 @@
use Magento\Framework\EntityManager\MetadataPool;
use Magento\Catalog\Model\Config;
use Magento\Catalog\Model\Category;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Catalog\Model\Indexer\Product\Category as ProductCategoryIndexer;
/**
* Action for partial reindex
@@ -38,6 +40,11 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
*/
private $eventManager;
+ /**
+ * @var IndexerRegistry
+ */
+ private $indexerRegistry;
+
/**
* @param ResourceConnection $resource
* @param StoreManagerInterface $storeManager
@@ -46,6 +53,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
* @param MetadataPool|null $metadataPool
* @param CacheContext|null $cacheContext
* @param EventManagerInterface|null $eventManager
+ * @param IndexerRegistry|null $indexerRegistry
*/
public function __construct(
ResourceConnection $resource,
@@ -54,11 +62,13 @@ public function __construct(
QueryGenerator $queryGenerator = null,
MetadataPool $metadataPool = null,
CacheContext $cacheContext = null,
- EventManagerInterface $eventManager = null
+ EventManagerInterface $eventManager = null,
+ IndexerRegistry $indexerRegistry = null
) {
parent::__construct($resource, $storeManager, $config, $queryGenerator, $metadataPool);
$this->cacheContext = $cacheContext ?: ObjectManager::getInstance()->get(CacheContext::class);
$this->eventManager = $eventManager ?: ObjectManager::getInstance()->get(EventManagerInterface::class);
+ $this->indexerRegistry = $indexerRegistry ?: ObjectManager::getInstance()->get(IndexerRegistry::class);
}
/**
@@ -72,8 +82,10 @@ public function execute(array $entityIds = [], $useTempTable = false)
{
$this->limitationByCategories = $entityIds;
$this->useTempTable = $useTempTable;
+ $indexer = $this->indexerRegistry->get(ProductCategoryIndexer::INDEXER_ID);
+ $workingState = $indexer->isWorking();
- if ($useTempTable) {
+ if ($useTempTable && !$workingState) {
foreach ($this->storeManager->getStores() as $store) {
$this->connection->truncateTable($this->getIndexTable($store->getId()));
}
@@ -83,7 +95,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
$this->reindex();
- if ($useTempTable) {
+ if ($useTempTable && !$workingState) {
foreach ($this->storeManager->getStores() as $store) {
$removalCategoryIds = array_diff($this->limitationByCategories, [$this->getRootCategoryId($store)]);
$this->connection->delete(
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
index 5448d6ad589e6..9c7b651987ef1 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
@@ -16,6 +16,8 @@
use Magento\Framework\Indexer\CacheContext;
use Magento\Store\Model\StoreManagerInterface;
use Magento\Framework\DB\Adapter\AdapterInterface;
+use Magento\Framework\Indexer\IndexerRegistry;
+use Magento\Catalog\Model\Indexer\Category\Product as CategoryProductIndexer;
/**
* Category rows indexer.
@@ -41,6 +43,11 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
*/
private $eventManager;
+ /**
+ * @var IndexerRegistry
+ */
+ private $indexerRegistry;
+
/**
* @param ResourceConnection $resource
* @param StoreManagerInterface $storeManager
@@ -49,6 +56,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
* @param MetadataPool|null $metadataPool
* @param CacheContext|null $cacheContext
* @param EventManagerInterface|null $eventManager
+ * @param IndexerRegistry|null $indexerRegistry
*/
public function __construct(
ResourceConnection $resource,
@@ -57,11 +65,13 @@ public function __construct(
QueryGenerator $queryGenerator = null,
MetadataPool $metadataPool = null,
CacheContext $cacheContext = null,
- EventManagerInterface $eventManager = null
+ EventManagerInterface $eventManager = null,
+ IndexerRegistry $indexerRegistry = null
) {
parent::__construct($resource, $storeManager, $config, $queryGenerator, $metadataPool);
$this->cacheContext = $cacheContext ?: ObjectManager::getInstance()->get(CacheContext::class);
$this->eventManager = $eventManager ?: ObjectManager::getInstance()->get(EventManagerInterface::class);
+ $this->indexerRegistry = $indexerRegistry ?: ObjectManager::getInstance()->get(IndexerRegistry::class);
}
/**
@@ -79,10 +89,12 @@ public function execute(array $entityIds = [], $useTempTable = false)
$this->limitationByProducts = $idsToBeReIndexed;
$this->useTempTable = $useTempTable;
+ $indexer = $this->indexerRegistry->get(CategoryProductIndexer::INDEXER_ID);
+ $workingState = $indexer->isWorking();
$affectedCategories = $this->getCategoryIdsFromIndex($idsToBeReIndexed);
- if ($useTempTable) {
+ if ($useTempTable && !$workingState) {
foreach ($this->storeManager->getStores() as $store) {
$this->connection->truncateTable($this->getIndexTable($store->getId()));
}
@@ -90,7 +102,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
$this->removeEntries();
}
$this->reindex();
- if ($useTempTable) {
+ if ($useTempTable && !$workingState) {
foreach ($this->storeManager->getStores() as $store) {
$this->connection->delete(
$this->tableMaintainer->getMainTable($store->getId()),
From 7f384f6dd933638dca03e57a9b8adafb75b02ba4 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Thu, 31 Oct 2019 14:45:20 -0500
Subject: [PATCH 0889/1978] MC-22216: Tests for the customerCart Query
- added rollback fixture
---
.../active_quote_customer_not_default_store_rollback.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote_customer_not_default_store_rollback.php b/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote_customer_not_default_store_rollback.php
index e3e1513cb6144..0ae87725529b8 100644
--- a/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote_customer_not_default_store_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Checkout/_files/active_quote_customer_not_default_store_rollback.php
@@ -6,3 +6,6 @@
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
$quote = $objectManager->create(\Magento\Quote\Model\Quote::class);
$quote->load('test_order_1_not_default_store', 'reserved_order_id')->delete();
+
+require __DIR__ . '/../../../Magento/Customer/_files/customer_rollback.php';
+require __DIR__ . '/../../../Magento/Store/_files/second_store_rollback.php';
From 97cf0a69478ca029cd72595b96929127393ef708 Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Thu, 31 Oct 2019 14:50:11 -0500
Subject: [PATCH 0890/1978] MC-16108: EAV attribute is not cached
- Update integration tests;
---
.../Eav/_files/attribute_for_caching.php | 12 +++++-----
.../_files/attribute_for_caching_rollback.php | 22 ++++++++++++++-----
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching.php b/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching.php
index 87b25865ac469..10e8109f3f31f 100644
--- a/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching.php
+++ b/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching.php
@@ -14,11 +14,13 @@
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class);
-$attributeSet->setData([
- 'attribute_set_name' => 'test_attribute_set',
- 'entity_type_id' => $entityTypeId,
- 'sort_order' => 100,
-]);
+$attributeSet->setData(
+ [
+ 'attribute_set_name' => 'test_attribute_set',
+ 'entity_type_id' => $entityTypeId,
+ 'sort_order' => 100
+ ]
+);
$attributeSet->validate();
$attributeSet->save();
diff --git a/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching_rollback.php b/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching_rollback.php
index 434ff53e1b159..ebc3d58028e37 100644
--- a/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Eav/_files/attribute_for_caching_rollback.php
@@ -3,19 +3,29 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
-/** @var \Magento\Catalog\Model\ResourceModel\Eav\Attribute $attribute */
-$attribute = $objectManager->create(\Magento\Catalog\Model\ResourceModel\Eav\Attribute::class);
+use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
+use Magento\Eav\Model\Entity\Attribute\Set;
+use Magento\TestFramework\Helper\Bootstrap;
+use Magento\Framework\Registry;
+
+$objectManager = Bootstrap::getObjectManager();
+$registry = $objectManager->get(Registry::class);
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', true);
+
+/** @var Attribute $attribute */
+$attribute = $objectManager->create(Attribute::class);
$attribute->loadByCode(4, 'foo');
if ($attribute->getId()) {
$attribute->delete();
}
-/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
-$attributeSet = $objectManager->create(\Magento\Eav\Model\Entity\Attribute\Set::class)
- ->load('test_attribute_set', 'attribute_set_name');
+/** @var Set $attributeSet */
+$attributeSet = $objectManager->create(Set::class)->load('test_attribute_set', 'attribute_set_name');
if ($attributeSet->getId()) {
$attributeSet->delete();
}
+$registry->unregister('isSecureArea');
+$registry->register('isSecureArea', false);
From 88b1228d7504ffad52474ce614b5c53055b74775 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Thu, 31 Oct 2019 14:53:33 -0500
Subject: [PATCH 0891/1978] MC-22216: Tests for the customerCart Query
- CR comments
---
.../Quote/Customer/GetCustomerCartTest.php | 17 -----------------
1 file changed, 17 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
index 4d81f4c8cca4a..13b1e50e4d108 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
@@ -34,28 +34,11 @@ class GetCustomerCartTest extends GraphQlAbstract
/** @var array */
private $headers;
- /**
- * @var CartManagementInterface
- */
- private $cartManagement;
-
- /**
- * @var CartRepositoryInterface
- */
- private $cartRepository;
- /**
- * @var QuoteIdMaskFactory
- */
- private $quoteIdMaskFactory;
-
protected function setUp()
{
$objectManager = Bootstrap::getObjectManager();
$this->getMaskedQuoteIdByReservedOrderId = $objectManager->get(GetMaskedQuoteIdByReservedOrderId::class);
$this->customerTokenService = $objectManager->get(CustomerTokenServiceInterface::class);
- $this->cartManagement = $objectManager->get(CartManagementInterface::class);
- $this->cartRepository = $objectManager->get(CartRepositoryInterface::class);
- $this->quoteIdMaskFactory = $objectManager->get(QuoteIdMaskFactory::class);
}
/**
From 37453bb7c9894097e94f8768723c2cbee7925f56 Mon Sep 17 00:00:00 2001
From: Cristian Partica
Date: Thu, 31 Oct 2019 14:59:19 -0500
Subject: [PATCH 0892/1978] MC-21542: Category query does not handle disabled
children properly
- add test
---
.../testsuite/Magento/GraphQl/Catalog/CategoryListTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
index de086b3d45009..96e8ae79b612e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/CategoryListTest.php
@@ -212,7 +212,7 @@ public function testQueryChildCategoriesWithProducts()
/**
* @magentoApiDataFixture Magento/Catalog/_files/categories_disabled.php
*/
- public function testQueryChildCategoriesWithProductsDisabled()
+ public function testQueryCategoryWithDisabledChildren()
{
$query = <<
Date: Thu, 31 Oct 2019 15:05:11 -0500
Subject: [PATCH 0893/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Added customerQuery changes added from review comments
---
.../Model/Resolver/CustomerCart.php | 5 ++---
.../Resolver/{CartId.php => MaskedCartId.php} | 18 ++++++++----------
.../Magento/QuoteGraphQl/etc/schema.graphqls | 2 +-
.../Quote/Customer/GetCustomerCartTest.php | 7 ++-----
4 files changed, 13 insertions(+), 19 deletions(-)
rename app/code/Magento/QuoteGraphQl/Model/Resolver/{CartId.php => MaskedCartId.php} (84%)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
index 41b6e9e821754..09be5446838cb 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
@@ -9,6 +9,7 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Config\Element\Field;
+use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
@@ -62,9 +63,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
}
} else {
- throw new LocalizedException(
- __('User cannot access the cart unless loggedIn and with a valid customer token')
- );
+ throw new GraphQlInputException(__('The request is allowed for logged in customer'));
}
return [
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartId.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
similarity index 84%
rename from app/code/Magento/QuoteGraphQl/Model/Resolver/CartId.php
rename to app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
index 3cab3c705aa9e..bc84434315faa 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CartId.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
@@ -8,7 +8,9 @@
namespace Magento\QuoteGraphQl\Model\Resolver;
use Magento\Framework\Exception\LocalizedException;
+use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Config\Element\Field;
+use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Quote\Model\Quote;
@@ -19,10 +21,11 @@
/**
* Get cart id from the cart
*/
-class CartId implements ResolverInterface
+class MaskedCartId implements ResolverInterface
{
/**
* @var QuoteIdMaskFactory
+ *
*/
private $quoteIdMaskFactory;
@@ -71,20 +74,15 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
*
* @param int $quoteId
* @return string
- * @throws \Magento\Framework\Exception\AlreadyExistsException
* @throws \Magento\Framework\Exception\NoSuchEntityException
*/
private function getQuoteMaskId(int $quoteId): string
{
- $maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
- if ($maskedId === '') {
- $quoteIdMask = $this->quoteIdMaskFactory->create();
- $quoteIdMask->setQuoteId($quoteId);
-
- $this->quoteIdMaskResourceModel->save($quoteIdMask);
- $maskedId = $quoteIdMask->getMaskedId();
+ try {
+ $maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
+ } catch (NoSuchEntityException $exception) {
+ throw new GraphQlNoSuchEntityException(__('Cart id is not '));
}
-
return $maskedId;
}
}
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index 5edc50bcf42c9..5be9a657ceb98 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -192,7 +192,7 @@ type PlaceOrderOutput {
}
type Cart {
- cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartId") @doc(description: "Cart Id of the cart")
+ cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart. The value can be an Int or String.")
items: [CartItemInterface] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartItems")
applied_coupon: AppliedCoupon @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupon") @doc(description:"An array of coupons that have been applied to the cart") @deprecated(reason: "Use applied_coupons instead ")
applied_coupons: [AppliedCoupon] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupons") @doc(description:"An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
index 13b1e50e4d108..aea9bab843557 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCustomerCartTest.php
@@ -12,9 +12,6 @@
use Magento\Integration\Api\CustomerTokenServiceInterface;
use Magento\TestFramework\Helper\Bootstrap;
use Magento\TestFramework\TestCase\GraphQlAbstract;
-use Magento\Quote\Api\CartManagementInterface;
-use Magento\Quote\Api\CartRepositoryInterface;
-use Magento\Quote\Model\QuoteIdMaskFactory;
/**
* Test for getting Customer cart information
@@ -90,7 +87,7 @@ public function testGetNewCustomerCart()
* Query for customer cart with no customer token passed
*
* @expectedException Exception
- * @expectedExceptionMessage User cannot access the cart unless loggedIn and with a valid customer token
+ * @expectedExceptionMessage The request is allowed for logged in customer
*/
public function testGetCustomerCartWithNoCustomerToken()
{
@@ -115,7 +112,7 @@ public function testGetCustomerCartAfterTokenRevoked()
$this->revokeCustomerToken();
$customerCartQuery = $this->getCustomerCartQuery();
$this->expectExceptionMessage(
- "User cannot access the cart unless loggedIn and with a valid customer token"
+ 'The request is allowed for logged in customer'
);
$this->graphQlQuery($customerCartQuery, [], '', $this->headers);
}
From f63695acefd0523279a6b3cd8b62b45e86bd1cc5 Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Thu, 31 Oct 2019 15:09:17 -0500
Subject: [PATCH 0894/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Added customerQuery change for resolver
---
.../Model/Resolver/MaskedCartId.php | 19 -------------------
1 file changed, 19 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
index bc84434315faa..9f4ebe83aae0e 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
@@ -14,43 +14,24 @@
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\Quote\Model\Quote;
-use Magento\Quote\Model\QuoteIdMaskFactory;
use Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface;
-use Magento\Quote\Model\ResourceModel\Quote\QuoteIdMask as QuoteIdMaskResourceModel;
/**
* Get cart id from the cart
*/
class MaskedCartId implements ResolverInterface
{
- /**
- * @var QuoteIdMaskFactory
- *
- */
- private $quoteIdMaskFactory;
-
- /**
- * @var QuoteIdMaskResourceModel
- */
- private $quoteIdMaskResourceModel;
-
/**
* @var QuoteIdToMaskedQuoteIdInterface
*/
private $quoteIdToMaskedQuoteId;
/**
- * @param QuoteIdMaskFactory $quoteIdMaskFactory
- * @param QuoteIdMaskResourceModel $quoteIdMaskResourceModel
* @param QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
*/
public function __construct(
- QuoteIdMaskFactory $quoteIdMaskFactory,
- QuoteIdMaskResourceModel $quoteIdMaskResourceModel,
QuoteIdToMaskedQuoteIdInterface $quoteIdToMaskedQuoteId
) {
- $this->quoteIdMaskFactory = $quoteIdMaskFactory;
- $this->quoteIdMaskResourceModel = $quoteIdMaskResourceModel;
$this->quoteIdToMaskedQuoteId = $quoteIdToMaskedQuoteId;
}
From 038d4c34a0752c4817aeb3d6b5d2850dc0d7ad81 Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Thu, 31 Oct 2019 15:12:32 -0500
Subject: [PATCH 0895/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Added customerQuery change for resolver exception message
---
app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
index 9f4ebe83aae0e..e8db79f5118ec 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
@@ -62,7 +62,7 @@ private function getQuoteMaskId(int $quoteId): string
try {
$maskedId = $this->quoteIdToMaskedQuoteId->execute($quoteId);
} catch (NoSuchEntityException $exception) {
- throw new GraphQlNoSuchEntityException(__('Cart id is not '));
+ throw new GraphQlNoSuchEntityException(__('Current user does not have an active cart.'));
}
return $maskedId;
}
From 2098339082a414457e24c140f449c8f66ed98dc8 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 15:24:57 -0500
Subject: [PATCH 0896/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 2 +-
.../Catalog/Model/Indexer/Category/Product/Action/Rows.php | 2 +-
.../Catalog/Model/Indexer/Product/Category/Action/Rows.php | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index a9ba367ed301a..2aafd7ff1c5d8 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -41,6 +41,7 @@
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
+ * phpcs:disable Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
*/
class Category extends \Magento\Catalog\Model\AbstractModel implements
\Magento\Framework\DataObject\IdentityInterface,
@@ -1364,7 +1365,6 @@ public function getChildrenData()
* @return array
* @todo refactor with converter for AbstractExtensibleModel
*/
- // phpcs:ignore Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
public function __toArray()
{
$data = $this->_data;
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
index 6ec911805cd13..1ad6d4c73a94c 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
@@ -43,7 +43,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
/**
* @var IndexerRegistry
*/
- private $indexerRegistry;
+ private $indexerRegistry;
/**
* @param ResourceConnection $resource
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
index 9c7b651987ef1..1890ac4ad45a7 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
@@ -46,7 +46,7 @@ class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractActio
/**
* @var IndexerRegistry
*/
- private $indexerRegistry;
+ private $indexerRegistry;
/**
* @param ResourceConnection $resource
From e42294213f19f3f8240e91c7299aeebf1a21e16c Mon Sep 17 00:00:00 2001
From: torhoehn
Date: Thu, 31 Oct 2019 21:29:58 +0100
Subject: [PATCH 0897/1978] remove script tag
---
.../Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php b/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php
index 83e66bbbce7cc..2e119d0bf887a 100644
--- a/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php
+++ b/app/code/Magento/Sales/Block/Order/Item/Renderer/DefaultRenderer.php
@@ -182,7 +182,7 @@ public function getFormatedOptionValue($optionValue)
if ($this->string->strlen($optionValue) > 55) {
$result['value'] = $result['value']
- . ' ... ';
+ . ' ...';
$optionValue = nl2br($optionValue);
$result = array_merge($result, ['full_view' => $optionValue]);
}
From b1118f2ad55b7cc84dbfa814b513825effcd42b1 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 15:35:16 -0500
Subject: [PATCH 0898/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Test/Unit/Model/Indexer/Product/CategoryTest.php | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
index 74f748ef9bf00..ab0ca8a5bc48a 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
@@ -84,7 +84,6 @@ public function testExecuteWithIndexerWorking()
{
$ids = [1, 2, 3];
- $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(true));
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
@@ -92,7 +91,6 @@ public function testExecuteWithIndexerWorking()
['execute']
);
$rowMock->expects($this->at(0))->method('execute')->with($ids, true)->will($this->returnSelf());
- $rowMock->expects($this->at(1))->method('execute')->with($ids, false)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
@@ -103,14 +101,13 @@ public function testExecuteWithIndexerNotWorking()
{
$ids = [1, 2, 3];
- $this->indexerMock->expects($this->once())->method('isWorking')->will($this->returnValue(false));
$this->prepareIndexer();
$rowMock = $this->createPartialMock(
\Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class,
['execute']
);
- $rowMock->expects($this->once())->method('execute')->with($ids, false)->will($this->returnSelf());
+ $rowMock->expects($this->once())->method('execute')->with($ids, true)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
@@ -123,7 +120,7 @@ public function testExecuteWithIndexerNotWorking()
protected function prepareIndexer()
{
- $this->indexerRegistryMock->expects($this->once())
+ $this->indexerRegistryMock->expects($this->any())
->method('get')
->with(\Magento\Catalog\Model\Indexer\Product\Category::INDEXER_ID)
->will($this->returnValue($this->indexerMock));
From 56ab42350dba7bfd7511c9eea068433638e17b06 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Thu, 31 Oct 2019 15:36:53 -0500
Subject: [PATCH 0899/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Test/Unit/Observer/CategoryProductIndexerTest.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php
index adebee0d591ab..944699908b984 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Observer/CategoryProductIndexerTest.php
@@ -69,7 +69,6 @@ public function testExecuteIfCategoryHasChangedProducts()
{
$this->getProductIdsWithEnabledElasticSearch();
$this->processorMock->expects($this->once())->method('isIndexerScheduled')->willReturn(true);
- $this->processorMock->expects($this->once())->method('markIndexerAsInvalid');
$this->observer->execute($this->observerMock);
}
From fa468e7298b42c0a233bbcb7db932f8a8ccbb32f Mon Sep 17 00:00:00 2001
From: Roman Lytvynenko
Date: Thu, 31 Oct 2019 16:02:44 -0500
Subject: [PATCH 0900/1978] MC-22635: Roll back the changes introduced with
MAGETWO-96663
---
.../Magento/UrlRewrite/Controller/Router.php | 40 +++------------
.../Test/Unit/Controller/RouterTest.php | 50 -------------------
.../UrlRewrite/Controller/UrlRewriteTest.php | 5 --
3 files changed, 8 insertions(+), 87 deletions(-)
diff --git a/app/code/Magento/UrlRewrite/Controller/Router.php b/app/code/Magento/UrlRewrite/Controller/Router.php
index 47718ba36316b..dd26f49b8efa4 100644
--- a/app/code/Magento/UrlRewrite/Controller/Router.php
+++ b/app/code/Magento/UrlRewrite/Controller/Router.php
@@ -5,15 +5,16 @@
*/
namespace Magento\UrlRewrite\Controller;
+use Magento\Framework\App\Action\Redirect;
+use Magento\Framework\App\ActionInterface;
+use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\App\RequestInterface;
+use Magento\Framework\App\Response\Http as HttpResponse;
+use Magento\Framework\Exception\NoSuchEntityException;
+use Magento\Framework\UrlInterface;
use Magento\UrlRewrite\Controller\Adminhtml\Url\Rewrite;
use Magento\UrlRewrite\Model\UrlFinderInterface;
use Magento\UrlRewrite\Service\V1\Data\UrlRewrite;
-use Magento\Framework\App\Request\Http as HttpRequest;
-use Magento\Framework\App\Response\Http as HttpResponse;
-use Magento\Framework\UrlInterface;
-use Magento\Framework\App\Action\Redirect;
-use Magento\Framework\App\ActionInterface;
/**
* UrlRewrite Controller Router
@@ -73,11 +74,12 @@ public function __construct(
*
* @param RequestInterface|HttpRequest $request
* @return ActionInterface|null
+ * @throws NoSuchEntityException
*/
public function match(RequestInterface $request)
{
$rewrite = $this->getRewrite(
- $this->getNormalizedPathInfo($request),
+ $request->getPathInfo(),
$this->storeManager->getStore()->getId()
);
@@ -153,30 +155,4 @@ protected function getRewrite($requestPath, $storeId)
]
);
}
-
- /**
- * Get normalized request path
- *
- * @param RequestInterface|HttpRequest $request
- * @return string
- */
- private function getNormalizedPathInfo(RequestInterface $request): string
- {
- $path = $request->getPathInfo();
- /**
- * If request contains query params then we need to trim a slash in end of the path.
- * For example:
- * the original request is: http://my-host.com/category-url-key.html/?color=black
- * where the original path is: category-url-key.html/
- * and the result path will be: category-url-key.html
- *
- * It need to except a redirect like this:
- * http://my-host.com/category-url-key.html/?color=black => http://my-host.com/category-url-key.html
- */
- if (!empty($path) && $request->getQuery()->count()) {
- $path = rtrim($path, '/');
- }
-
- return (string)$path;
- }
}
diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php
index 6eea8b962bf9f..c935b3c7ec4cb 100644
--- a/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php
+++ b/app/code/Magento/UrlRewrite/Test/Unit/Controller/RouterTest.php
@@ -351,54 +351,4 @@ public function testMatch()
$this->router->match($this->request);
}
-
- /**
- * Test to match corresponding URL Rewrite on request with query params
- *
- * @param string $originalRequestPath
- * @param string $requestPath
- * @param int $countOfQueryParams
- * @dataProvider matchWithQueryParamsDataProvider
- */
- public function testMatchWithQueryParams(string $originalRequestPath, string $requestPath, int $countOfQueryParams)
- {
- $targetPath = 'target-path';
-
- $this->storeManager->method('getStore')->willReturn($this->store);
- $urlRewrite = $this->createMock(UrlRewrite::class);
- $urlRewrite->method('getRedirectType')->willReturn(0);
- $urlRewrite->method('getTargetPath')->willReturn($targetPath);
- $urlRewrite->method('getRequestPath')->willReturn($requestPath);
- $this->urlFinder->method('findOneByData')
- ->with([UrlRewrite::REQUEST_PATH => $requestPath, UrlRewrite::STORE_ID => $this->store->getId()])
- ->willReturn($urlRewrite);
-
- $this->requestQuery->method('count')->willReturn($countOfQueryParams);
- $this->request->method('getPathInfo')
- ->willReturn($originalRequestPath);
- $this->request->expects($this->once())
- ->method('setPathInfo')
- ->with('/' . $targetPath);
- $this->request->expects($this->once())
- ->method('setAlias')
- ->with(UrlInterface::REWRITE_REQUEST_PATH_ALIAS, $requestPath);
- $this->actionFactory->expects($this->once())
- ->method('create')
- ->with(Forward::class);
-
- $this->router->match($this->request);
- }
-
- /**
- * Data provider for Test to match corresponding URL Rewrite on request with query params
- *
- * @return array
- */
- public function matchWithQueryParamsDataProvider(): array
- {
- return [
- ['/category.html/', 'category.html/', 0],
- ['/category.html/', 'category.html', 1],
- ];
- }
}
diff --git a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
index 50ef913594187..e1b28f474672a 100644
--- a/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
+++ b/dev/tests/integration/testsuite/Magento/UrlRewrite/Controller/UrlRewriteTest.php
@@ -80,11 +80,6 @@ public function requestDataProvider(): array
'request' => '/page-similar/',
'redirect' => '/page-b',
],
- 'Use Case #7: Request with query params' => [
- 'request' => '/enable-cookies/?test-param',
- 'redirect' => '',
- HttpResponse::STATUS_CODE_200,
- ],
];
}
From 78c1cfd00e34ef2d5bbb30afdc9cac0f92a878e3 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Thu, 31 Oct 2019 16:50:17 -0500
Subject: [PATCH 0901/1978] magento/graphql-ce#961:
ShippingAddressInput.postcode: String, is not required by Schema
---
.../GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php | 4 ++--
setup/performance-toolkit/benchmark.jmx | 8 ++++----
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php
index 90ebec763b227..60c3cc2e8b24e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AllowGuestCheckoutOptionTest.php
@@ -104,7 +104,7 @@ public function testSetBillingAddressToGuestCustomerCart()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
@@ -216,7 +216,7 @@ public function testSetNewShippingAddressOnCartWithGuestCheckoutDisabled()
company: "test company"
street: ["test street 1", "test street 2"]
city: "test city"
- region: "test region"
+ region: "AZ"
postcode: "887766"
country_code: "US"
telephone: "88776655"
diff --git a/setup/performance-toolkit/benchmark.jmx b/setup/performance-toolkit/benchmark.jmx
index 723814432b7e1..7db2b26e3c621 100644
--- a/setup/performance-toolkit/benchmark.jmx
+++ b/setup/performance-toolkit/benchmark.jmx
@@ -41730,7 +41730,7 @@ vars.putObject("randomIntGenerator", random);
false
- {"query":"mutation {\n setShippingAddressesOnCart(\n input: {\n cart_id: \"${quote_id}\"\n shipping_addresses: [\n {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"test region\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n ]\n }\n ) {\n cart {\n shipping_addresses {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
+ {"query":"mutation {\n setShippingAddressesOnCart(\n input: {\n cart_id: \"${quote_id}\"\n shipping_addresses: [\n {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"AZ\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n ]\n }\n ) {\n cart {\n shipping_addresses {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
=
@@ -41920,7 +41920,7 @@ vars.putObject("randomIntGenerator", random);
false
- {"query":"mutation {\n setBillingAddressOnCart(\n input: {\n cart_id: \"${quote_id}\"\n billing_address: {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"test region\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n }\n ) {\n cart {\n billing_address {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
+ {"query":"mutation {\n setBillingAddressOnCart(\n input: {\n cart_id: \"${quote_id}\"\n billing_address: {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"AZ\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n }\n ) {\n cart {\n billing_address {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
=
@@ -45369,7 +45369,7 @@ vars.put("product_sku", product.get("sku"));
false
- {"query":"mutation {\n setBillingAddressOnCart(\n input: {\n cart_id: \"${quote_id}\"\n billing_address: {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"test region\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n }\n ) {\n cart {\n billing_address {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
+ {"query":"mutation {\n setBillingAddressOnCart(\n input: {\n cart_id: \"${quote_id}\"\n billing_address: {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"AZ\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n }\n ) {\n cart {\n billing_address {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
=
@@ -45408,7 +45408,7 @@ vars.put("product_sku", product.get("sku"));
false
- {"query":"mutation {\n setShippingAddressesOnCart(\n input: {\n cart_id: \"${quote_id}\"\n shipping_addresses: [\n {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"test region\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n ]\n }\n ) {\n cart {\n shipping_addresses {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
+ {"query":"mutation {\n setShippingAddressesOnCart(\n input: {\n cart_id: \"${quote_id}\"\n shipping_addresses: [\n {\n address: {\n firstname: \"test firstname\"\n lastname: \"test lastname\"\n company: \"test company\"\n street: [\"test street 1\", \"test street 2\"]\n city: \"test city\"\n region: \"AZ\"\n postcode: \"887766\"\n country_code: \"US\"\n telephone: \"88776655\"\n save_in_address_book: false\n }\n }\n ]\n }\n ) {\n cart {\n shipping_addresses {\n firstname\n lastname\n company\n street\n city\n postcode\n telephone\n country {\n code\n label\n }\n }\n }\n }\n}","variables":null,"operationName":null}
=
From ec36c9f3782fbbb5e651dc211fd1ae6be1cfff83 Mon Sep 17 00:00:00 2001
From: torhoehn
Date: Thu, 31 Oct 2019 23:08:13 +0100
Subject: [PATCH 0902/1978] add scroll to top
---
app/design/adminhtml/Magento/backend/web/js/theme.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/design/adminhtml/Magento/backend/web/js/theme.js b/app/design/adminhtml/Magento/backend/web/js/theme.js
index 39b364ea8553f..05d73ac20fcbd 100644
--- a/app/design/adminhtml/Magento/backend/web/js/theme.js
+++ b/app/design/adminhtml/Magento/backend/web/js/theme.js
@@ -93,6 +93,7 @@ define('globalNavigationScroll', [
} else { // static menu cases
checkRemoveClass(menu, fixedClassName);
+ menu.css('top', 'auto');
}
// Save previous window scrollTop
From be24d9005aecac7cbeabdefc2a49771a3d4790cd Mon Sep 17 00:00:00 2001
From: torhoehn
Date: Thu, 31 Oct 2019 23:21:37 +0100
Subject: [PATCH 0903/1978] add check for attribute option values
---
.../Catalog/Controller/Adminhtml/Product/Attribute/Validate.php | 2 +-
.../view/adminhtml/web/js/variations/steps/attributes_values.js | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php
index ce6668229d658..dcb7074c0d036 100644
--- a/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php
+++ b/app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php
@@ -252,7 +252,7 @@ private function checkUniqueOption(DataObject $response, array $options = null)
private function checkEmptyOption(DataObject $response, array $optionsForCheck = null)
{
foreach ($optionsForCheck as $optionValues) {
- if (isset($optionValues[0]) && $optionValues[0] == '') {
+ if (isset($optionValues[0]) && trim($optionValues[0]) == '') {
$this->setMessageToResponse($response, [__("The value of Admin scope can't be empty.")]);
$response->setError(true);
}
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js
index 6c790c634ee93..8e057f5cd39dc 100644
--- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js
+++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js
@@ -106,6 +106,7 @@ define([
errorOption,
allOptions = [];
+ newOption.label = $.trim(option.label);
if (_.isEmpty(newOption.label)) {
return false;
}
From f0a34804de3af5192502d9a41c76665f44e77129 Mon Sep 17 00:00:00 2001
From: Soumya Unnikrishnan
Date: Thu, 31 Oct 2019 17:25:50 -0500
Subject: [PATCH 0904/1978] MQE-1872: [MTF-MFTF] Process PR #348 Fixed
StoreFrontMyAccountWithMultishipmentTest to pick specific order id from the
grid.
---
.../Test/Mftf/Section/CheckoutSuccessMainSection.xml | 1 +
.../Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessMainSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessMainSection.xml
index 08a9d671a8d02..c486e13ecf58b 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessMainSection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/CheckoutSuccessMainSection.xml
@@ -14,6 +14,7 @@
+
diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml
index a81d24e99563a..6b13c445364ee 100644
--- a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml
+++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml
@@ -51,11 +51,16 @@
+
+
+
+
+
From 691b877be18791030fbfd5599aef8fdf4fe82be2 Mon Sep 17 00:00:00 2001
From: Ravi Chandra
Date: Fri, 1 Nov 2019 10:09:20 +0530
Subject: [PATCH 0905/1978] move description before the class name
---
.../Magento/Sales/Model/ResourceModel/Status/Collection.php | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php b/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
index f429a62fc3f03..f9dc4a7d83ae2 100644
--- a/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
+++ b/app/code/Magento/Sales/Model/ResourceModel/Status/Collection.php
@@ -1,12 +1,14 @@
Date: Fri, 1 Nov 2019 13:09:56 +0700
Subject: [PATCH 0906/1978] [Persistent] Cover Session Helper by Unit Test
---
.../Test/Unit/Helper/SessionTest.php | 187 ++++++++++++++++++
1 file changed, 187 insertions(+)
create mode 100644 app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php
diff --git a/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php b/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php
new file mode 100644
index 0000000000000..986523a6f5d97
--- /dev/null
+++ b/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php
@@ -0,0 +1,187 @@
+context = $this->getMockBuilder(Context::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->dataHelper = $this->getMockBuilder(DataHelper::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->checkoutSession = $this->getMockBuilder(CheckoutSession::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->sessionFactory = $this->getMockBuilder(SessionFactory::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['create'])
+ ->getMock();
+ $this->session = $this->getMockBuilder(Session::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $this->sessionFactory->expects($this->any())->method('create')->willReturn($this->session);
+
+ $this->helper = $this->getMockBuilder(SessionHelper::class)
+ ->setMethods(['getSession'])
+ ->setConstructorArgs(
+ [
+ 'context' => $this->context,
+ 'persistentData' => $this->dataHelper,
+ 'checkoutSession' => $this->checkoutSession,
+ 'sessionFactory' => $this->sessionFactory
+ ]
+ )
+ ->getMock();
+ }
+
+ /***
+ * Test isPersistent() when the session has id and enable persistent
+ */
+ public function testIsPersistentWhenSessionId()
+ {
+ $this->session->expects($this->any())->method('getId')
+ ->willReturn(1);
+ $this->helper->expects($this->any())->method('getSession')
+ ->willReturn($this->session);
+ $this->dataHelper->expects($this->any())->method('isEnabled')
+ ->willReturn(true);
+
+ $this->assertEquals(true, $this->helper->isPersistent());
+ }
+
+ /***
+ * Test isPersistent() when the no session id and enable persistent
+ */
+ public function testIsPersistentWhenNoSessionId()
+ {
+ $this->session->expects($this->any())->method('getId')
+ ->willReturn(null);
+ $this->helper->expects($this->any())->method('getSession')
+ ->willReturn($this->session);
+ $this->dataHelper->expects($this->any())->method('isEnabled')
+ ->willReturn(true);
+
+ $this->assertEquals(false, $this->helper->isPersistent());
+ }
+
+ /**
+ * Test isRememberMeChecked() when enable all config
+ */
+ public function testIsRememberMeCheckedWhenEnabledAll()
+ {
+ $testCase = [
+ 'dataset' => [
+ 'enabled' => true,
+ 'remember_me_enabled' => true,
+ 'remember_me_checked_default' => true
+ ],
+ 'expected' => true
+ ];
+ $this->executeTestIsRememberMeChecked($testCase);
+ }
+
+ /**
+ * Test isRememberMeChecked() when config persistent is disabled
+ */
+ public function testIsRememberMeCheckedWhenAtLeastOnceDisabled()
+ {
+ $testCase = [
+ 'dataset' => [
+ 'enabled' => false,
+ 'remember_me_enabled' => true,
+ 'remember_me_checked_default' => true
+ ],
+ 'expected' => false
+ ];
+ $this->executeTestIsRememberMeChecked($testCase);
+ }
+
+ /**
+ * Test isRememberMeChecked() when setRememberMeChecked(false)
+ */
+ public function testIsRememberMeCheckedWhenSetValue()
+ {
+ $testCase = [
+ 'dataset' => [
+ 'enabled' => true,
+ 'remember_me_enabled' => true,
+ 'remember_me_checked_default' => true
+ ],
+ 'expected' => false
+ ];
+ $this->helper->setRememberMeChecked(false);
+ $this->executeTestIsRememberMeChecked($testCase);
+ }
+
+ /**
+ * Execute test isRememberMeChecked() function
+ *
+ * @param array $testCase
+ */
+ public function executeTestIsRememberMeChecked($testCase)
+ {
+ $this->dataHelper->expects($this->any())->method('isEnabled')
+ ->willReturn($testCase['dataset']['enabled']);
+ $this->dataHelper->expects($this->any())->method('isRememberMeEnabled')
+ ->willReturn($testCase['dataset']['remember_me_enabled']);
+ $this->dataHelper->expects($this->any())->method('isRememberMeCheckedDefault')
+ ->willReturn($testCase['dataset']['remember_me_checked_default']);
+ $this->assertEquals($testCase['expected'], $this->helper->isRememberMeChecked());
+ }
+}
From 27b9d8c0640311096fafb834e312c9e0eef18206 Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Fri, 1 Nov 2019 08:34:05 +0200
Subject: [PATCH 0907/1978] MC-17259: Update blank gender it does not saved in
direct edits from customer grid
---
...goryHighlightedAndProductDisplayedTest.xml | 4 +
...stomerGenderInCustomersGridActionGroup.xml | 25 ++++++
...stomerGenderInCustomersGridActionGroup.xml | 22 +++++
...ustomerGenderOnCustomerFormActionGroup.xml | 23 +++++
.../Customer/Test/Mftf/Data/GenderData.xml | 17 ++++
.../Test/Mftf/Page/AdminCustomerPage.xml | 1 +
.../AdminCustomerGridInlineEditorSection.xml | 15 ++++
.../Mftf/Section/AdminCustomerGridSection.xml | 2 +
...hangeCustomerGenderInCustomersGridTest.xml | 83 +++++++++++++++++++
.../view/base/web/js/grid/editing/editor.js | 13 ++-
10 files changed, 204 insertions(+), 1 deletion(-)
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderOnCustomerFormActionGroup.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/Data/GenderData.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridInlineEditorSection.xml
create mode 100644 app/code/Magento/Customer/Test/Mftf/Test/AdminChangeCustomerGenderInCustomersGridTest.xml
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml
index 3e72df9133898..ba30c7d0e26e4 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontCategoryHighlightedAndProductDisplayedTest.xml
@@ -37,6 +37,10 @@
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml
new file mode 100644
index 0000000000000..12c81e3694c0a
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+ Update customer gender attribute value on customers grid page
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml
new file mode 100644
index 0000000000000..337c66a0539db
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+ Assert customer genderAttribute value on customers grid page
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderOnCustomerFormActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderOnCustomerFormActionGroup.xml
new file mode 100644
index 0000000000000..b21b0054b0c78
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderOnCustomerFormActionGroup.xml
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ Validates that the provided Customer Gender is selected on the Admin Customer edit page.
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/GenderData.xml b/app/code/Magento/Customer/Test/Mftf/Data/GenderData.xml
new file mode 100644
index 0000000000000..68dee0ffa31d0
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Data/GenderData.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+ Male
+ Female
+ Not Specified
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerPage.xml
index 114c737e361ed..d77dc15840e4c 100644
--- a/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerPage.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerPage.xml
@@ -13,5 +13,6 @@
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridInlineEditorSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridInlineEditorSection.xml
new file mode 100644
index 0000000000000..d010844cfffcf
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridInlineEditorSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml
index 91363c614c1f8..9562a902b26da 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml
@@ -16,5 +16,7 @@
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminChangeCustomerGenderInCustomersGridTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminChangeCustomerGenderInCustomersGridTest.xml
new file mode 100644
index 0000000000000..7ca9a6993f2fc
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminChangeCustomerGenderInCustomersGridTest.xml
@@ -0,0 +1,83 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js b/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js
index ece49cc8fe27c..ad70b200e4420 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/editing/editor.js
@@ -337,7 +337,18 @@ define([
* @returns {Object} Collection of records data.
*/
getData: function () {
- var data = this.activeRecords.map('getData');
+ var data = this.activeRecords.map(function (record) {
+ var elemKey,
+ recordData = record.getData();
+
+ for (elemKey in recordData) {
+ if (_.isUndefined(recordData[elemKey])) {
+ recordData[elemKey] = null;
+ }
+ }
+
+ return recordData;
+ });
return _.indexBy(data, this.indexField);
},
From c3dfeffd144ceca787109a153485d4894434f446 Mon Sep 17 00:00:00 2001
From: DianaRusin
Date: Fri, 1 Nov 2019 09:31:19 +0200
Subject: [PATCH 0908/1978] MC-17003: Update Totals button is missing from
Credit Memo page
---
.../Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php | 2 ++
.../app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php | 4 +++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php
index 28bb00757dac1..8aff098fb9c3e 100644
--- a/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php
+++ b/dev/tests/functional/tests/app/Magento/Sales/Test/Block/Adminhtml/Order/Creditmemo/Totals.php
@@ -4,6 +4,8 @@
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Sales\Test\Block\Adminhtml\Order\Creditmemo;
use Magento\Mtf\Client\Locator;
diff --git a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php
index 936a2d2fb0690..6ef1713c8542f 100644
--- a/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php
+++ b/dev/tests/functional/tests/app/Magento/Sales/Test/TestStep/CreateCreditMemoStep.php
@@ -4,6 +4,8 @@
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Sales\Test\TestStep;
use Magento\Checkout\Test\Fixture\Cart;
@@ -138,7 +140,7 @@ private function isTotalsDataChanged(array $data): bool
];
foreach ($compareData as $fieldName => $fieldValue) {
- if (isset($data['form_data'][$fieldName]) && $fieldValue != $data['form_data'][$fieldName]) {
+ if (isset($data['form_data'][$fieldName]) && $fieldValue !== $data['form_data'][$fieldName]) {
return true;
}
}
From d007ac0e6a6d5b0ff1d8e0894d3db808049debbf Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 1 Nov 2019 09:54:53 +0200
Subject: [PATCH 0909/1978] =?UTF-8?q?MC-22674:=20[=D0=9CFTF]=20Fix=20fluky?=
=?UTF-8?q?=20test=20AdvanceCatalogSearchDownloadableByPriceTest=20MC-246?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
index 867f097042a17..2a0aa45292e18 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
@@ -87,6 +87,9 @@
+
+
+
@@ -100,6 +103,7 @@
+
From 79be5ed26493ef2ad801d3a06da44357b2459abf Mon Sep 17 00:00:00 2001
From: Adarsh Manickam
Date: Fri, 1 Nov 2019 13:42:48 +0530
Subject: [PATCH 0910/1978] Fixed model save and ObjectManager usage
---
.../Adminhtml/Email/Template/Save.php | 71 +++++++++++++++----
1 file changed, 57 insertions(+), 14 deletions(-)
diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php
index 135506f4068a8..e61f45dd8be0f 100644
--- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php
+++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Save.php
@@ -1,15 +1,62 @@
dateTime = $dateTime;
+ $this->templateResource = $templateResource;
+ $this->backendSession = $backendSession;
+ parent::__construct($context, $coreRegistry);
+ }
+
/**
* Save transactional email action
*
@@ -18,10 +65,10 @@ class Save extends \Magento\Email\Controller\Adminhtml\Email\Template
public function execute()
{
$request = $this->getRequest();
- $id = $this->getRequest()->getParam('id');
+ $templateId = $this->getRequest()->getParam('id');
$template = $this->_initTemplate('id');
- if (!$template->getId() && $id) {
+ if (!$template->getId() && $templateId) {
$this->messageManager->addErrorMessage(__('This email template no longer exists.'));
$this->_redirect('adminhtml/*/');
return;
@@ -37,7 +84,7 @@ public function execute()
)->setTemplateStyles(
$request->getParam('template_styles')
)->setModifiedAt(
- $this->_objectManager->get(\Magento\Framework\Stdlib\DateTime\DateTime::class)->gmtDate()
+ $this->dateTime->gmtDate()
)->setOrigTemplateCode(
$request->getParam('orig_template_code')
)->setOrigTemplateVariables(
@@ -53,17 +100,13 @@ public function execute()
$template->setTemplateStyles('');
}
- $template->save();
- $this->_objectManager->get(\Magento\Backend\Model\Session::class)->setFormData(false);
+ $this->templateResource->save($template);
+
+ $this->backendSession->setFormData(false);
$this->messageManager->addSuccessMessage(__('You saved the email template.'));
$this->_redirect('adminhtml/*');
- } catch (\Exception $e) {
- $this->_objectManager->get(
- \Magento\Backend\Model\Session::class
- )->setData(
- 'email_template_form_data',
- $request->getParams()
- );
+ } catch (Exception $e) {
+ $this->backendSession->setData('email_template_form_data', $request->getParams());
$this->messageManager->addErrorMessage($e->getMessage());
$this->_forward('new');
}
From 0afddc2a871933611867ea485bba5cca20501ba7 Mon Sep 17 00:00:00 2001
From: Eden
Date: Fri, 1 Nov 2019 15:37:02 +0700
Subject: [PATCH 0911/1978] Unit Test with data provider
---
.../Test/Unit/Helper/SessionTest.php | 149 ++++++++++--------
1 file changed, 81 insertions(+), 68 deletions(-)
diff --git a/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php b/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php
index 986523a6f5d97..7009ff4d33c0b 100644
--- a/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php
+++ b/app/code/Magento/Persistent/Test/Unit/Helper/SessionTest.php
@@ -90,98 +90,111 @@ protected function setUp()
->getMock();
}
- /***
- * Test isPersistent() when the session has id and enable persistent
- */
- public function testIsPersistentWhenSessionId()
- {
- $this->session->expects($this->any())->method('getId')
- ->willReturn(1);
- $this->helper->expects($this->any())->method('getSession')
- ->willReturn($this->session);
- $this->dataHelper->expects($this->any())->method('isEnabled')
- ->willReturn(true);
-
- $this->assertEquals(true, $this->helper->isPersistent());
- }
-
- /***
- * Test isPersistent() when the no session id and enable persistent
+ /**
+ * Test isPersistent() function
+ *
+ * @param int|null $id
+ * @param boolean $isEnabled
+ * @param boolean $expected
+ * @dataProvider isPersistentDataProvider
*/
- public function testIsPersistentWhenNoSessionId()
+ public function testIsPersistent($id, $isEnabled, $expected)
{
$this->session->expects($this->any())->method('getId')
- ->willReturn(null);
+ ->willReturn($id);
$this->helper->expects($this->any())->method('getSession')
->willReturn($this->session);
$this->dataHelper->expects($this->any())->method('isEnabled')
- ->willReturn(true);
+ ->willReturn($isEnabled);
- $this->assertEquals(false, $this->helper->isPersistent());
+ $this->assertEquals($expected, $this->helper->isPersistent());
}
/**
- * Test isRememberMeChecked() when enable all config
+ * Data Provider for test isPersistent()
+ *
+ * @return array
*/
- public function testIsRememberMeCheckedWhenEnabledAll()
+ public function isPersistentDataProvider()
{
- $testCase = [
- 'dataset' => [
- 'enabled' => true,
- 'remember_me_enabled' => true,
- 'remember_me_checked_default' => true
+ return [
+ 'session_id_and_enable_persistent' => [
+ 1,
+ true,
+ true
],
- 'expected' => true
+ 'no_session_id_and_enable_persistent' => [
+ null,
+ true,
+ false
+ ]
];
- $this->executeTestIsRememberMeChecked($testCase);
}
/**
- * Test isRememberMeChecked() when config persistent is disabled
+ * Test isRememberMeChecked() function
+ *
+ * @param boolean|null $checked
+ * @param boolean $isEnabled
+ * @param boolean $isRememberMeEnabled
+ * @param boolean $isRememberMeCheckedDefault
+ * @param boolean $expected
+ * @dataProvider isRememberMeCheckedProvider
*/
- public function testIsRememberMeCheckedWhenAtLeastOnceDisabled()
- {
- $testCase = [
- 'dataset' => [
- 'enabled' => false,
- 'remember_me_enabled' => true,
- 'remember_me_checked_default' => true
- ],
- 'expected' => false
- ];
- $this->executeTestIsRememberMeChecked($testCase);
- }
+ public function testIsRememberMeChecked(
+ $checked,
+ $isEnabled,
+ $isRememberMeEnabled,
+ $isRememberMeCheckedDefault,
+ $expected
+ ) {
+ $this->helper->setRememberMeChecked($checked);
+ $this->dataHelper->expects($this->any())->method('isEnabled')
+ ->willReturn($isEnabled);
+ $this->dataHelper->expects($this->any())->method('isRememberMeEnabled')
+ ->willReturn($isRememberMeEnabled);
+ $this->dataHelper->expects($this->any())->method('isRememberMeCheckedDefault')
+ ->willReturn($isRememberMeCheckedDefault);
- /**
- * Test isRememberMeChecked() when setRememberMeChecked(false)
- */
- public function testIsRememberMeCheckedWhenSetValue()
- {
- $testCase = [
- 'dataset' => [
- 'enabled' => true,
- 'remember_me_enabled' => true,
- 'remember_me_checked_default' => true
- ],
- 'expected' => false
- ];
- $this->helper->setRememberMeChecked(false);
- $this->executeTestIsRememberMeChecked($testCase);
+ $this->assertEquals($expected, $this->helper->isRememberMeChecked());
}
/**
- * Execute test isRememberMeChecked() function
+ * Data Provider for test isRememberMeChecked()
*
- * @param array $testCase
+ * @return array
*/
- public function executeTestIsRememberMeChecked($testCase)
+ public function isRememberMeCheckedProvider()
{
- $this->dataHelper->expects($this->any())->method('isEnabled')
- ->willReturn($testCase['dataset']['enabled']);
- $this->dataHelper->expects($this->any())->method('isRememberMeEnabled')
- ->willReturn($testCase['dataset']['remember_me_enabled']);
- $this->dataHelper->expects($this->any())->method('isRememberMeCheckedDefault')
- ->willReturn($testCase['dataset']['remember_me_checked_default']);
- $this->assertEquals($testCase['expected'], $this->helper->isRememberMeChecked());
+ return [
+ 'enable_all_config' => [
+ null,
+ true,
+ true,
+ true,
+ true
+ ],
+ 'at_least_once_disabled' => [
+ null,
+ false,
+ true,
+ true,
+ false
+ ],
+ 'set_remember_me_checked_false' => [
+ false,
+ true,
+ true,
+ true,
+ false
+ ],
+ 'set_remember_me_checked_true' => [
+ true,
+ false,
+ true,
+ true,
+ true
+ ]
+ ];
}
}
From 8260aa3a2866c5997827a5a526c4d458303c8e9e Mon Sep 17 00:00:00 2001
From: Paavo Pokkinen
Date: Fri, 1 Nov 2019 10:57:55 +0200
Subject: [PATCH 0912/1978] Add Cache-Control header to nginx sample
configuration
---
nginx.conf.sample | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nginx.conf.sample b/nginx.conf.sample
index 979ac0be1f537..9219400f6aacd 100644
--- a/nginx.conf.sample
+++ b/nginx.conf.sample
@@ -109,7 +109,7 @@ location /static/ {
rewrite ^/static/(version\d*/)?(.*)$ /static/$2 last;
}
- location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|json)$ {
+ location ~* \.(ico|jpg|jpeg|png|gif|svg|js|css|swf|eot|ttf|otf|woff|woff2|html|json)$ {
add_header Cache-Control "public";
add_header X-Frame-Options "SAMEORIGIN";
expires +1y;
From 36fb3b7e47343425892355d8b63dfd01068ab291 Mon Sep 17 00:00:00 2001
From: Pieter Hoste
Date: Sun, 27 Oct 2019 12:02:26 +0100
Subject: [PATCH 0913/1978] Added suggested changes + fixed static tests +
fixed functional tests + some cleanup.
---
app/code/Magento/Checkout/Model/Session.php | 24 ++++++++-------------
1 file changed, 9 insertions(+), 15 deletions(-)
diff --git a/app/code/Magento/Checkout/Model/Session.php b/app/code/Magento/Checkout/Model/Session.php
index 872583dca130e..4a4861fa9ccd2 100644
--- a/app/code/Magento/Checkout/Model/Session.php
+++ b/app/code/Magento/Checkout/Model/Session.php
@@ -6,10 +6,7 @@
namespace Magento\Checkout\Model;
use Magento\Customer\Api\Data\CustomerInterface;
-use Magento\Framework\Api\SearchCriteriaBuilder;
-use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\App\ObjectManager;
-use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Quote\Api\Data\CartInterface;
use Magento\Quote\Model\Quote;
@@ -26,9 +23,6 @@
*/
class Session extends \Magento\Framework\Session\SessionManager
{
- /**
- * Checkout state begin
- */
const CHECKOUT_STATE_BEGIN = 'begin';
/**
@@ -233,7 +227,7 @@ public function setLoadInactive($load = true)
*
* @return Quote
* @throws \Magento\Framework\Exception\LocalizedException
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws NoSuchEntityException
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
* @SuppressWarnings(PHPMD.NPathComplexity)
*/
@@ -278,7 +272,7 @@ public function getQuote()
*/
$quote = $this->quoteRepository->get($this->getQuoteId());
}
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ } catch (NoSuchEntityException $e) {
$this->setQuoteId(null);
}
}
@@ -286,8 +280,8 @@ public function getQuote()
if (!$this->getQuoteId()) {
if ($this->_customerSession->isLoggedIn() || $this->_customer) {
$quoteByCustomer = $this->getQuoteByCustomer();
- if ($quoteByCustomer !== false) {
- $this->setQuoteId($quote->getId());
+ if ($quoteByCustomer !== null) {
+ $this->setQuoteId($quoteByCustomer->getId());
$quote = $quoteByCustomer;
}
} else {
@@ -376,7 +370,7 @@ public function loadCustomerQuote()
try {
$customerQuote = $this->quoteRepository->getForCustomer($this->_customerSession->getCustomerId());
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ } catch (NoSuchEntityException $e) {
$customerQuote = $this->quoteFactory->create();
}
$customerQuote->setStoreId($this->_storeManager->getStore()->getId());
@@ -559,7 +553,7 @@ public function restoreQuote()
$this->replaceQuote($quote)->unsLastRealOrderId();
$this->_eventManager->dispatch('restore_quote', ['order' => $order, 'quote' => $quote]);
return true;
- } catch (\Magento\Framework\Exception\NoSuchEntityException $e) {
+ } catch (NoSuchEntityException $e) {
$this->logger->critical($e);
}
}
@@ -591,9 +585,9 @@ protected function isQuoteMasked()
}
/**
- * @return CartInterface|false
+ * Returns quote for customer if there is any
*/
- private function getQuoteByCustomer()
+ private function getQuoteByCustomer(): ?CartInterface
{
$customerId = $this->_customer
? $this->_customer->getId()
@@ -602,7 +596,7 @@ private function getQuoteByCustomer()
try {
$quote = $this->quoteRepository->getActiveForCustomer($customerId);
} catch (NoSuchEntityException $e) {
- $quote = false;
+ $quote = null;
}
return $quote;
From b87fd32a30373fca6278b378ee41282e705e9b18 Mon Sep 17 00:00:00 2001
From: Viktor Sevch
Date: Fri, 1 Nov 2019 11:32:33 +0200
Subject: [PATCH 0914/1978] MC-22597: Revert changes from the 24708 issue
---
app/code/Magento/Analytics/Model/ExportDataHandler.php | 2 +-
.../Analytics/Test/Unit/Model/ExportDataHandlerTest.php | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Analytics/Model/ExportDataHandler.php b/app/code/Magento/Analytics/Model/ExportDataHandler.php
index 72a8e4ea00347..4dbc316d0901a 100644
--- a/app/code/Magento/Analytics/Model/ExportDataHandler.php
+++ b/app/code/Magento/Analytics/Model/ExportDataHandler.php
@@ -89,7 +89,7 @@ public function __construct(
public function prepareExportData()
{
try {
- $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
+ $tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
$this->prepareDirectory($tmpDirectory, $this->getTmpFilesDirRelativePath());
$this->reportWriter->write($tmpDirectory, $this->getTmpFilesDirRelativePath());
diff --git a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
index 493fe71c9fbfc..cf00556cfe590 100644
--- a/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
+++ b/app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php
@@ -13,7 +13,7 @@
use Magento\Framework\Archive;
use Magento\Framework\Filesystem;
use Magento\Framework\Filesystem\Directory\WriteInterface;
-use Magento\Framework\App\Filesystem\DirectoryList;
+use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
class ExportDataHandlerTest extends \PHPUnit\Framework\TestCase
@@ -137,7 +137,7 @@ public function testPrepareExportData($isArchiveSourceDirectory)
$this->filesystemMock
->expects($this->once())
->method('getDirectoryWrite')
- ->with(DirectoryList::VAR_DIR)
+ ->with(DirectoryList::SYS_TMP)
->willReturn($this->directoryMock);
$this->directoryMock
->expects($this->exactly(4))
@@ -238,7 +238,7 @@ public function testPrepareExportDataWithLocalizedException()
$this->filesystemMock
->expects($this->once())
->method('getDirectoryWrite')
- ->with(DirectoryList::VAR_DIR)
+ ->with(DirectoryList::SYS_TMP)
->willReturn($this->directoryMock);
$this->reportWriterMock
->expects($this->once())
From 83999a8cdbe0874468d9b06e0b7f998222d5f0ba Mon Sep 17 00:00:00 2001
From: Nikita Shcherbatykh
Date: Fri, 1 Nov 2019 12:00:28 +0200
Subject: [PATCH 0915/1978] MC-21974: Exported CSV not sorted in the grid
---
.../ImportExport/Ui/DataProvider/ExportFileDataProvider.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php
index f8f0ab822f21f..83203f1ad8aff 100644
--- a/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php
+++ b/app/code/Magento/ImportExport/Ui/DataProvider/ExportFileDataProvider.php
@@ -131,7 +131,7 @@ private function getExportFiles(string $directoryPath): array
$sortedFiles[filemtime($filePath)] = $filePath;
}
//sort array elements using key value
- ksort($sortedFiles);
+ krsort($sortedFiles);
return $sortedFiles;
}
From abe9790c16304f34e86d7c13cc23884d5a1dd21c Mon Sep 17 00:00:00 2001
From: Vova Yatsyuk
Date: Fri, 1 Nov 2019 12:06:24 +0200
Subject: [PATCH 0916/1978] Remove 'noEscape' as it's escaped now.
---
.../Integration/view/adminhtml/templates/resourcetree.phtml | 2 +-
app/code/Magento/User/view/adminhtml/templates/role/edit.phtml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml b/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml
index bf90d15917f42..1737f66ce4a1b 100644
--- a/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml
+++ b/app/code/Magento/Integration/view/adminhtml/templates/resourcetree.phtml
@@ -38,7 +38,7 @@
= $block->escapeHtml(__('Resources')) ?>
-
escapeHtmlAttr($block->getJsonSerializer()->serialize([
'rolesTree' => [
"treeInitData" => $block->getTree(),
diff --git a/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml b/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml
index 6fa3dba7b301d..97308204be854 100644
--- a/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml
+++ b/app/code/Magento/User/view/adminhtml/templates/role/edit.phtml
@@ -38,7 +38,7 @@
= $block->escapeHtml(__('Resources')) ?>
-
escapeHtmlAttr($block->getJsonSerializer()->serialize([
'rolesTree' => [
"treeInitData" => $block->getTree(),
From 74cff615dd2432a6a46f75a85f58532fd4441546 Mon Sep 17 00:00:00 2001
From: Nikita Shcherbatykh
Date: Fri, 1 Nov 2019 12:32:23 +0200
Subject: [PATCH 0917/1978] MC-22142: Simple product images lose sort order
when uploaded through "Create Configurations" wizard
---
.../view/adminhtml/web/js/variations/steps/bulk.js | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js
index 00bf1feff7fb5..eed887037bc96 100644
--- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js
+++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/bulk.js
@@ -237,12 +237,21 @@ define([
getImageProperty: function (node) {
var types = node.find('[data-role=gallery]').productGallery('option').types,
images = _.map(node.find('[data-role=image]'), function (image) {
- var imageData = $(image).data('imageData');
+ var imageData = $(image).data('imageData'),
+ positionElement;
imageData.galleryTypes = _.pluck(_.filter(types, function (type) {
return type.value === imageData.file;
}), 'code');
+ //jscs:disable requireCamelCaseOrUpperCaseIdentifiers
+ positionElement =
+ $(image).find('[name="product[media_gallery][images][' + imageData.file_id + '][position]"]');
+ //jscs:enable requireCamelCaseOrUpperCaseIdentifiers
+ if (!_.isEmpty(positionElement.val())) {
+ imageData.position = positionElement.val();
+ }
+
return imageData;
});
From 8369f30d2b256648c001ee20d987d44fa3e95412 Mon Sep 17 00:00:00 2001
From: Gabriel da Gama
Date: Mon, 14 Oct 2019 13:27:47 +0100
Subject: [PATCH 0918/1978] Declaring variable first and added blank line
---
lib/web/mage/accordion.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/web/mage/accordion.js b/lib/web/mage/accordion.js
index 6dbc00c1084fc..78d7dae019be2 100644
--- a/lib/web/mage/accordion.js
+++ b/lib/web/mage/accordion.js
@@ -82,8 +82,9 @@ define([
* @private
*/
_closeOthers: function () {
+ var self = this;
+
if (!this.options.multipleCollapsible) {
- var self = this;
$.each(this.collapsibles, function () {
$(this).on('beforeOpen', function () {
self.collapsibles.not(this).collapsible('deactivate');
From fe9d1e8b447e1ec246aabdc5a6b30426ef833241 Mon Sep 17 00:00:00 2001
From: Serhii Voloshkov
Date: Fri, 1 Nov 2019 15:40:31 +0200
Subject: [PATCH 0919/1978] MC-22610: strict_types could introduce a breaking
change in 2.3.4
---
.../Magento/Rule/Model/Condition/AbstractCondition.php | 1 -
.../Unit/Model/Condition/AbstractConditionTest.php | 10 +++++-----
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php
index d58af06da94cf..f6e782b3e7a53 100644
--- a/app/code/Magento/Rule/Model/Condition/AbstractCondition.php
+++ b/app/code/Magento/Rule/Model/Condition/AbstractCondition.php
@@ -3,7 +3,6 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-declare(strict_types=1);
namespace Magento\Rule\Model\Condition;
diff --git a/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php b/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php
index 0ba41af04a1b3..52653197e3981 100644
--- a/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php
+++ b/app/code/Magento/Rule/Test/Unit/Model/Condition/AbstractConditionTest.php
@@ -55,14 +55,14 @@ public function validateAttributeDataProvider()
['0', '==', 1, false],
['1', '==', 1, true],
['x', '==', 'x', true],
- ['x', '==', '0', false],
+ ['x', '==', 0, false],
[1, '!=', 1, false],
[0, '!=', 1, true],
['0', '!=', 1, true],
['1', '!=', 1, false],
['x', '!=', 'x', false],
- ['x', '!=', '0', true],
+ ['x', '!=', 0, true],
[1, '==', [1], true],
[1, '!=', [1], false],
@@ -164,15 +164,15 @@ public function validateAttributeArrayInputTypeDataProvider()
[[1, 2, 3], '{}', '1', true, 'grid'],
[[1, 2, 3], '{}', '8', false, 'grid'],
- [[1, 2, 3], '{}', '5', false, 'grid'],
+ [[1, 2, 3], '{}', 5, false, 'grid'],
[[1, 2, 3], '{}', [2, 3, 4], true, 'grid'],
[[1, 2, 3], '{}', [4], false, 'grid'],
[[3], '{}', [], false, 'grid'],
[1, '{}', 1, false, 'grid'],
[1, '!{}', [1, 2, 3], false, 'grid'],
[[1], '{}', null, false, 'grid'],
- ['null', '{}', 'null', true, 'input'],
- ['null', '!{}', 'null', false, 'input'],
+ [null, '{}', null, true, 'input'],
+ [null, '!{}', null, false, 'input'],
[null, '{}', [1], false, 'input'],
[[1, 2, 3], '()', 1, true, 'select'],
From 87ab99d219eadb487d9f6858f58bcd56257711d2 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Fri, 1 Nov 2019 15:44:38 +0200
Subject: [PATCH 0920/1978] MC-22131: Revert of MC-16333
---
.../Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml
index a81d24e99563a..2820e887c29bc 100644
--- a/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml
+++ b/app/code/Magento/Multishipping/Test/Mftf/Test/StoreFrontMyAccountWithMultishipmentTest.xml
@@ -17,6 +17,9 @@
+
+
+
From dff4a8c6daebf4056b648529e1e517e0d7958b3c Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Fri, 1 Nov 2019 10:01:39 -0500
Subject: [PATCH 0921/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 1 +
.../Catalog/Model/Indexer/Category/Product/Action/Rows.php | 6 ++++--
.../Catalog/Model/Indexer/Product/Category/Action/Rows.php | 4 ++--
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 2aafd7ff1c5d8..cefe1d400646e 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1364,6 +1364,7 @@ public function getChildrenData()
*
* @return array
* @todo refactor with converter for AbstractExtensibleModel
+ * phpcs:ignore Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
*/
public function __toArray()
{
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
index 1ad6d4c73a94c..24c9227bb64bd 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product/Action/Rows.php
@@ -20,6 +20,8 @@
/**
* Action for partial reindex
+ *
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class Rows extends \Magento\Catalog\Model\Indexer\Category\Product\AbstractAction
{
@@ -85,7 +87,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
$indexer = $this->indexerRegistry->get(ProductCategoryIndexer::INDEXER_ID);
$workingState = $indexer->isWorking();
- if ($useTempTable && !$workingState) {
+ if ($useTempTable && !$workingState && $indexer->isScheduled()) {
foreach ($this->storeManager->getStores() as $store) {
$this->connection->truncateTable($this->getIndexTable($store->getId()));
}
@@ -95,7 +97,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
$this->reindex();
- if ($useTempTable && !$workingState) {
+ if ($useTempTable && !$workingState && $indexer->isScheduled()) {
foreach ($this->storeManager->getStores() as $store) {
$removalCategoryIds = array_diff($this->limitationByCategories, [$this->getRootCategoryId($store)]);
$this->connection->delete(
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
index 1890ac4ad45a7..ec3d0d57330ec 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Category/Action/Rows.php
@@ -94,7 +94,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
$affectedCategories = $this->getCategoryIdsFromIndex($idsToBeReIndexed);
- if ($useTempTable && !$workingState) {
+ if ($useTempTable && !$workingState && $indexer->isScheduled()) {
foreach ($this->storeManager->getStores() as $store) {
$this->connection->truncateTable($this->getIndexTable($store->getId()));
}
@@ -102,7 +102,7 @@ public function execute(array $entityIds = [], $useTempTable = false)
$this->removeEntries();
}
$this->reindex();
- if ($useTempTable && !$workingState) {
+ if ($useTempTable && !$workingState && $indexer->isScheduled()) {
foreach ($this->storeManager->getStores() as $store) {
$this->connection->delete(
$this->tableMaintainer->getMainTable($store->getId()),
From bd25c1dda66243db4a7de1d7ab1d439ecd4931eb Mon Sep 17 00:00:00 2001
From: DmitryTsymbal
Date: Fri, 1 Nov 2019 17:42:55 +0200
Subject: [PATCH 0922/1978] sections-refactoring
---
.../AdminCreatesNewIntegrationActionGroup.xml | 4 ++--
...AdminDeleteIntegrationEntityActionGroup.xml | 6 +++---
...igateToCreateIntegrationPageActionGroup.xml | 2 +-
...AdminSearchIntegrationInGridActionGroup.xml | 4 ++--
...dminSubmitNewIntegrationFormActionGroup.xml | 2 +-
...ssageCreateIntegrationEntityActionGroup.xml | 4 ++--
...eletedIntegrationIsNotInGridActionGroup.xml | 2 +-
...on.xml => AdminIntegrationsGridSection.xml} | 11 +----------
.../Section/AdminNewIntegrationSection.xml | 18 ++++++++++++++++++
9 files changed, 31 insertions(+), 22 deletions(-)
rename app/code/Magento/Integration/Test/Mftf/Section/{AdminIntegrationsSection.xml => AdminIntegrationsGridSection.xml} (62%)
create mode 100644 app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
index 89e29d7d751a0..c039a70293269 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminCreatesNewIntegrationActionGroup.xml
@@ -15,7 +15,7 @@
-
-
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml
index 87bcff8145184..4a73f6ce4b8df 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminDeleteIntegrationEntityActionGroup.xml
@@ -9,9 +9,9 @@
-
-
-
+
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml
index f31102419b665..18deddb3170aa 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminNavigateToCreateIntegrationPageActionGroup.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml
index 6e0b7dc3eb9d5..dcd60a0479db4 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSearchIntegrationInGridActionGroup.xml
@@ -15,9 +15,9 @@
-
+
-
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml
index 23ddc2969a55e..f1dcd5da77c85 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AdminSubmitNewIntegrationFormActionGroup.xml
@@ -11,7 +11,7 @@
-
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml
index e928149c7f08f..f233c1d9a7f74 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertAdminMessageCreateIntegrationEntityActionGroup.xml
@@ -13,7 +13,7 @@
-
-
+
+
diff --git a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml
index 895f147fa8834..a4438b1eb70a7 100644
--- a/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml
+++ b/app/code/Magento/Integration/Test/Mftf/ActionGroup/AssertDeletedIntegrationIsNotInGridActionGroup.xml
@@ -12,6 +12,6 @@
-
+
diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml
similarity index 62%
rename from app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
rename to app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml
index 4af25b9be9714..ae601542f3b37 100644
--- a/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsSection.xml
+++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminIntegrationsGridSection.xml
@@ -8,7 +8,7 @@
-
diff --git a/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml b/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml
new file mode 100644
index 0000000000000..3e7214784c2b5
--- /dev/null
+++ b/app/code/Magento/Integration/Test/Mftf/Section/AdminNewIntegrationSection.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
From 92279a38f1d30d6ad24a91b9d5fef8f4021944fa Mon Sep 17 00:00:00 2001
From: Soumya Unnikrishnan
Date: Fri, 1 Nov 2019 10:51:33 -0500
Subject: [PATCH 0923/1978] MQE-1872: [MTF-MFTF] Process PR #348 Added cache
flush and reindex for SearchEntityResults
---
.../StorefrontBundleProductShownInCategoryListAndGrid.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml
index 9ad4b6828d6e4..88db5b64fa42d 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/StorefrontBundleProductShownInCategoryListAndGrid.xml
@@ -76,6 +76,10 @@
+
+
+
+
From c10fa4e176d236358015db85520fb68f666925f3 Mon Sep 17 00:00:00 2001
From: Tomash Khamlai
Date: Fri, 1 Nov 2019 17:48:41 +0200
Subject: [PATCH 0924/1978] Move Delete Website to after. Remove space around
equal sign
Signed-off-by: Tomash Khamlai
---
.../AdminCreateAndEditBundleProductSettingsTest.xml | 11 ++++++-----
.../Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml | 2 +-
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
index f7a64f943f307..67651d2dbee2c 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
@@ -32,6 +32,11 @@
+
+
+
+
+
@@ -135,11 +140,7 @@
-
-
-
-
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml
index 1608d0b7b5a25..29d96c3cb94c2 100644
--- a/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml
+++ b/app/code/Magento/Store/Test/Mftf/Test/AdminCreateWebsiteTest.xml
@@ -19,7 +19,7 @@
-
+
From f96f2eee50bb85f2942c5a469548e9094e1441e4 Mon Sep 17 00:00:00 2001
From: Tomash Khamlai
Date: Fri, 1 Nov 2019 17:57:40 +0200
Subject: [PATCH 0925/1978] Remove empty line
Signed-off-by: Tomash Khamlai
---
.../Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
index 67651d2dbee2c..14e0290365c3e 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
@@ -140,7 +140,6 @@
-
From a479af5cd9318b4f00392d62fab270bb3bd4ca41 Mon Sep 17 00:00:00 2001
From: Serhiy Yelahin
Date: Fri, 1 Nov 2019 18:26:38 +0200
Subject: [PATCH 0926/1978] MC-21755: Changing Attributes sets doesn't remove
attribute from layered navigation and search
---
.../Catalog/Model/ResourceModel/Product.php | 84 +++++++++++++++++--
.../Model/ResourceModel/ProductTest.php | 34 ++++++++
...bute_set_with_image_attribute_rollback.php | 14 ++--
3 files changed, 118 insertions(+), 14 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/ResourceModel/Product.php b/app/code/Magento/Catalog/Model/ResourceModel/Product.php
index b0b15cfd69d13..c5587d3b25665 100644
--- a/app/code/Magento/Catalog/Model/ResourceModel/Product.php
+++ b/app/code/Magento/Catalog/Model/ResourceModel/Product.php
@@ -6,10 +6,12 @@
namespace Magento\Catalog\Model\ResourceModel;
use Magento\Catalog\Model\ResourceModel\Product\Website\Link as ProductWebsiteLink;
+use Magento\Eav\Api\AttributeManagementInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Catalog\Model\Indexer\Category\Product\TableMaintainer;
use Magento\Catalog\Model\Product as ProductEntity;
use Magento\Eav\Model\Entity\Attribute\UniqueValidationInterface;
+use Magento\Framework\DataObject;
use Magento\Framework\EntityManager\EntityManager;
use Magento\Framework\Model\AbstractModel;
@@ -93,6 +95,11 @@ class Product extends AbstractResource
*/
private $tableMaintainer;
+ /**
+ * @var AttributeManagementInterface
+ */
+ private $eavAttributeManagement;
+
/**
* @param \Magento\Eav\Model\Entity\Context $context
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
@@ -106,7 +113,7 @@ class Product extends AbstractResource
* @param array $data
* @param TableMaintainer|null $tableMaintainer
* @param UniqueValidationInterface|null $uniqueValidator
- *
+ * @param AttributeManagementInterface|null $eavAttributeManagement
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -121,7 +128,8 @@ public function __construct(
\Magento\Catalog\Model\Product\Attribute\DefaultAttributes $defaultAttributes,
$data = [],
TableMaintainer $tableMaintainer = null,
- UniqueValidationInterface $uniqueValidator = null
+ UniqueValidationInterface $uniqueValidator = null,
+ AttributeManagementInterface $eavAttributeManagement = null
) {
$this->_categoryCollectionFactory = $categoryCollectionFactory;
$this->_catalogCategory = $catalogCategory;
@@ -138,6 +146,8 @@ public function __construct(
);
$this->connectionName = 'catalog';
$this->tableMaintainer = $tableMaintainer ?: ObjectManager::getInstance()->get(TableMaintainer::class);
+ $this->eavAttributeManagement = $eavAttributeManagement
+ ?? ObjectManager::getInstance()->get(AttributeManagementInterface::class);
}
/**
@@ -268,10 +278,10 @@ public function getIdBySku($sku)
/**
* Process product data before save
*
- * @param \Magento\Framework\DataObject $object
+ * @param DataObject $object
* @return $this
*/
- protected function _beforeSave(\Magento\Framework\DataObject $object)
+ protected function _beforeSave(DataObject $object)
{
$self = parent::_beforeSave($object);
/**
@@ -286,15 +296,73 @@ protected function _beforeSave(\Magento\Framework\DataObject $object)
/**
* Save data related with product
*
- * @param \Magento\Framework\DataObject $product
+ * @param DataObject $product
* @return $this
*/
- protected function _afterSave(\Magento\Framework\DataObject $product)
+ protected function _afterSave(DataObject $product)
{
+ $this->removeNotInSetAttributeValues($product);
$this->_saveWebsiteIds($product)->_saveCategories($product);
return parent::_afterSave($product);
}
+ /**
+ * Remove attribute values that absent in product attribute set
+ *
+ * @param DataObject $product
+ * @return DataObject
+ */
+ private function removeNotInSetAttributeValues(DataObject $product): DataObject
+ {
+ $oldAttributeSetId = $product->getOrigData(ProductEntity::ATTRIBUTE_SET_ID);
+ if ($oldAttributeSetId && $product->dataHasChangedFor(ProductEntity::ATTRIBUTE_SET_ID)) {
+ $newAttributes = $product->getAttributes();
+ $newAttributesCodes = array_keys($newAttributes);
+ $oldAttributes = $this->eavAttributeManagement->getAttributes(
+ ProductEntity::ENTITY,
+ $oldAttributeSetId
+ );
+ $oldAttributesCodes = [];
+ foreach ($oldAttributes as $oldAttribute) {
+ $oldAttributesCodes[] = $oldAttribute->getAttributecode();
+ }
+ $notInSetAttributeCodes = array_diff($oldAttributesCodes, $newAttributesCodes);
+ if (!empty($notInSetAttributeCodes)) {
+ $this->deleteSelectedEntityAttributeRows($product, $notInSetAttributeCodes);
+ }
+ }
+
+ return $product;
+ }
+
+ /**
+ * Clear selected entity attribute rows
+ *
+ * @param DataObject $product
+ * @param array $attributeCodes
+ * @return void
+ */
+ private function deleteSelectedEntityAttributeRows(DataObject $product, array $attributeCodes): void
+ {
+ $backendTables = [];
+ foreach ($attributeCodes as $attributeCode) {
+ $attribute = $this->getAttribute($attributeCode);
+ $backendTable = $attribute->getBackendTable();
+ if (!$attribute->isStatic() && $backendTable) {
+ $backendTables[$backendTable][] = $attribute->getId();
+ }
+ }
+
+ $entityIdField = $this->getLinkField();
+ $entityId = $product->getData($entityIdField);
+ foreach ($backendTables as $backendTable => $attributes) {
+ $connection = $this->getConnection();
+ $where = $connection->quoteInto('attribute_id IN (?)', $attributes);
+ $where .= $connection->quoteInto(" AND {$entityIdField} = ?", $entityId);
+ $connection->delete($backendTable, $where);
+ }
+ }
+
/**
* @inheritdoc
*/
@@ -337,12 +405,12 @@ protected function _saveWebsiteIds($product)
/**
* Save product category relations
*
- * @param \Magento\Framework\DataObject $object
+ * @param DataObject $object
* @return $this
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @deprecated 101.1.0
*/
- protected function _saveCategories(\Magento\Framework\DataObject $object)
+ protected function _saveCategories(DataObject $object)
{
return $this;
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php
index e218c508b7d3e..f560854fa75f6 100755
--- a/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Model/ResourceModel/ProductTest.php
@@ -6,7 +6,12 @@
namespace Magento\Catalog\Model\ResourceModel;
use Magento\Catalog\Api\ProductRepositoryInterface;
+use Magento\Catalog\Model\ResourceModel\Product\Action;
+use Magento\Eav\Api\Data\AttributeSetInterface;
+use Magento\Eav\Model\AttributeSetRepository;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\ObjectManagerInterface;
+use Magento\TestFramework\Eav\Model\GetAttributeSetByName;
use Magento\TestFramework\Helper\Bootstrap;
use PHPUnit\Framework\TestCase;
use Magento\Framework\Exception\NoSuchEntityException;
@@ -164,4 +169,33 @@ public function testUpdateStoreSpecificSpecialPrice()
$product = $this->productRepository->get('simple', false, 0, true);
$this->assertEquals(5.99, $product->getSpecialPrice());
}
+
+ /**
+ * Checks that product has no attribute values for attributes not assigned to the product's attribute set.
+ *
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
+ * @magentoDataFixture Magento/Catalog/_files/attribute_set_with_image_attribute.php
+ */
+ public function testChangeAttributeSet()
+ {
+ $attributeCode = 'funny_image';
+ /** @var GetAttributeSetByName $attributeSetModel */
+ $attributeSetModel = $this->objectManager->get(GetAttributeSetByName::class);
+ $attributeSet = $attributeSetModel->execute('attribute_set_with_media_attribute');
+
+ $product = $this->productRepository->get('simple', true, 1, true);
+ $product->setAttributeSetId($attributeSet->getAttributeSetId());
+ $this->productRepository->save($product);
+ $product->setData($attributeCode, 'test');
+ $this->model->saveAttribute($product, $attributeCode);
+
+ $product = $this->productRepository->get('simple', true, 1, true);
+ $this->assertEquals('test', $product->getData($attributeCode));
+
+ $product->setAttributeSetId($product->getDefaultAttributeSetId());
+ $this->productRepository->save($product);
+
+ $attribute = $this->model->getAttributeRawValue($product->getId(), $attributeCode, 1);
+ $this->assertEmpty($attribute);
+ }
}
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_image_attribute_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_image_attribute_rollback.php
index 6dc8b60739f1f..626eb32a17051 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_image_attribute_rollback.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/attribute_set_with_image_attribute_rollback.php
@@ -17,9 +17,10 @@
$attributeCollection->setCodeFilter('funny_image');
$attributeCollection->setEntityTypeFilter($entityType->getId());
$attributeCollection->setPageSize(1);
-$attributeCollection->load();
-$attribute = $attributeCollection->fetchItem();
-$attribute->delete();
+$attribute = $attributeCollection->getFirstItem();
+if ($attribute->getId()) {
+ $attribute->delete();
+}
// remove attribute set
@@ -31,8 +32,9 @@
$attributeSetCollection->addFilter('entity_type_id', $entityType->getId());
$attributeSetCollection->setOrder('attribute_set_id'); // descending is default value
$attributeSetCollection->setPageSize(1);
-$attributeSetCollection->load();
/** @var \Magento\Eav\Model\Entity\Attribute\Set $attributeSet */
-$attributeSet = $attributeSetCollection->fetchItem();
-$attributeSet->delete();
+$attributeSet = $attributeSetCollection->getFirstItem();
+if ($attributeSet->getId()) {
+ $attributeSet->delete();
+}
From 04a637c2b3652d7cbab0703264729edcbea2e539 Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Fri, 1 Nov 2019 11:55:20 -0500
Subject: [PATCH 0927/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Fixed Review changes
---
.../Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php | 6 ++----
.../Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php | 4 ++--
app/code/Magento/QuoteGraphQl/etc/schema.graphqls | 2 +-
3 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
index 09be5446838cb..2a20a9d428203 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
@@ -10,13 +10,11 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Config\Element\Field;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
-use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\QuoteGraphQl\Model\Cart\CreateEmptyCartForCustomer;
use Magento\Authorization\Model\UserContextInterface;
use Magento\Quote\Api\CartManagementInterface;
-use Magento\Framework\Exception\LocalizedException;
/**
* Get cart for the customer
@@ -72,13 +70,13 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
}
/**
- * Checking if current user is logged
+ * Checking if current user is logged in
*
* @param int|null $customerId
* @param int|null $customerType
* @return bool
*/
- private function isCustomer(int $customerId, int $customerType): bool
+ private function isCustomer(?int $customerId, ?int $customerType): bool
{
return !empty($customerId) && !empty($customerType) && $customerType !== UserContextInterface::USER_TYPE_GUEST;
}
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
index e8db79f5118ec..755f79569f09a 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/MaskedCartId.php
@@ -51,11 +51,11 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
}
/**
- * Fetch or create masked id for customer's active quote
+ * Get masked id for cart
*
* @param int $quoteId
* @return string
- * @throws \Magento\Framework\Exception\NoSuchEntityException
+ * @throws GraphQlNoSuchEntityException
*/
private function getQuoteMaskId(int $quoteId): string
{
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index dafa7c1f07711..b5d03c8cb7093 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -193,7 +193,7 @@ type PlaceOrderOutput {
}
type Cart {
- cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart. The value can be an Int or String.")
+ cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart.")
items: [CartItemInterface] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartItems")
applied_coupon: AppliedCoupon @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupon") @doc(description:"An array of coupons that have been applied to the cart") @deprecated(reason: "Use applied_coupons instead ")
applied_coupons: [AppliedCoupon] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupons") @doc(description:"An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code")
From 627a61768b2e3e9875873cee610993839ec35401 Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Fri, 1 Nov 2019 12:41:23 -0500
Subject: [PATCH 0928/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Fixed Review change from the comments
---
app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
index 2a20a9d428203..1f463db590cf2 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
@@ -70,7 +70,7 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
}
/**
- * Checking if current user is logged in
+ * Check if current user is logged in
*
* @param int|null $customerId
* @param int|null $customerType
From 5d503c2e9a75de87fcfa510911957da6c18b50fd Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Fri, 1 Nov 2019 13:06:18 -0500
Subject: [PATCH 0929/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Fixed PR build failures
---
app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php | 2 +-
.../testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
index 1f463db590cf2..a4d596298b5ba 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
@@ -29,7 +29,7 @@ class CustomerCart implements ResolverInterface
/**
* @var CartManagementInterface
*/
- protected $cartManagement;
+ private $cartManagement;
/**
* @param CreateEmptyCartForCustomer $createEmptyCartForCustomer
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
index e7f87f362044a..1c9a061970da6 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
@@ -188,7 +188,8 @@ public function testGetCartWithNotDefaultStore()
}
/**
- * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
* @magentoApiDataFixture Magento/Store/_files/second_store.php
*
* @expectedException Exception
From 1e71392e6653f9956d2e6bea464646de210e7716 Mon Sep 17 00:00:00 2001
From: Deepty Thampy
Date: Fri, 1 Nov 2019 13:17:37 -0500
Subject: [PATCH 0930/1978] MC-22216: Tests for the customerCart Query
- fixed existing tests to include cartId
---
.../GraphQl/Quote/Customer/GetCartTest.php | 3 ++
.../Quote/Customer/GetCustomerCartTest.php | 33 +++++++++++--------
.../Guest/AddSimpleProductToCartTest.php | 3 ++
.../Guest/AddVirtualProductToCartTest.php | 3 ++
.../Quote/Guest/ApplyCouponToCartTest.php | 3 ++
.../GraphQl/Quote/Guest/GetCartTest.php | 3 ++
6 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
index e7f87f362044a..36dbbe4f77ba5 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
@@ -65,6 +65,8 @@ public function testGetCart()
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
self::assertArrayHasKey('cart', $response);
+ self::assertArrayHasKey('cart_id', $response['cart']);
+ self::assertEquals($maskedQuoteId, $response['cart']['cart_id']);
self::assertArrayHasKey('items', $response['cart']);
self::assertCount(2, $response['cart']['items']);
@@ -255,6 +257,7 @@ private function getQuery(string $maskedQuoteId): string
return <<generateCustomerToken();
$customerCartQuery = $this->getCustomerCartQuery();
- $this->headers = ['Authorization' => 'Bearer ' . $customerToken];
- $response = $this->graphQlQuery($customerCartQuery, [], '', $this->headers);
+ $headers = ['Authorization' => 'Bearer ' . $customerToken];
+ $response = $this->graphQlQuery($customerCartQuery, [], '', $headers);
$this->assertArrayHasKey('customerCart', $response);
$this->assertArrayHasKey('cart_id', $response['customerCart']);
$this->assertNotNull($response['customerCart']['cart_id']);
@@ -103,9 +100,9 @@ public function testGetCustomerCartWithNoCustomerToken()
public function testGetCustomerCartAfterTokenRevoked()
{
$customerToken = $this->generateCustomerToken();
- $this->headers = ['Authorization' => 'Bearer ' . $customerToken];
+ $headers = ['Authorization' => 'Bearer ' . $customerToken];
$customerCartQuery = $this->getCustomerCartQuery();
- $response = $this->graphQlMutation($customerCartQuery, [], '', $this->headers);
+ $response = $this->graphQlMutation($customerCartQuery, [], '', $headers);
$this->assertArrayHasKey('customerCart', $response);
$this->assertArrayHasKey('cart_id', $response['customerCart']);
$this->assertNotNull($response['customerCart']['cart_id']);
@@ -114,7 +111,7 @@ public function testGetCustomerCartAfterTokenRevoked()
$this->expectExceptionMessage(
'The request is allowed for logged in customer'
);
- $this->graphQlQuery($customerCartQuery, [], '', $this->headers);
+ $this->graphQlQuery($customerCartQuery, [], '', $headers);
}
/**
@@ -125,15 +122,15 @@ public function testGetCustomerCartAfterTokenRevoked()
public function testRequestCustomerCartTwice()
{
$customerToken = $this->generateCustomerToken();
- $this->headers = ['Authorization' => 'Bearer ' . $customerToken];
+ $headers = ['Authorization' => 'Bearer ' . $customerToken];
$customerCartQuery = $this->getCustomerCartQuery();
- $response = $this->graphQlMutation($customerCartQuery, [], '', $this->headers);
+ $response = $this->graphQlMutation($customerCartQuery, [], '', $headers);
$this->assertArrayHasKey('customerCart', $response);
$this->assertArrayHasKey('cart_id', $response['customerCart']);
$this->assertNotNull($response['customerCart']['cart_id']);
$cartId = $response['customerCart']['cart_id'];
$customerCartQuery = $this->getCustomerCartQuery();
- $response2 = $this->graphQlQuery($customerCartQuery, [], '', $this->headers);
+ $response2 = $this->graphQlQuery($customerCartQuery, [], '', $headers);
$this->assertEquals($cartId, $response2['customerCart']['cart_id']);
}
@@ -173,6 +170,8 @@ public function testGetCustomerCartSecondStore()
}
/**
+ * Query to generate customer token
+ *
* @return string
*/
private function generateCustomerToken(): string
@@ -195,7 +194,12 @@ private function generateCustomerToken(): string
return $response['generateCustomerToken']['token'];
}
- private function revokeCustomerToken()
+ /**
+ * Query to revoke customer token
+ *
+ * @return void
+ */
+ private function revokeCustomerToken(): void
{
$query = <<graphQlMutation($query);
self::assertArrayHasKey('cart', $response['addVirtualProductsToCart']);
+ self::assertArrayHasKey('cart_id', $response['addVirtualProductsToCart']['cart']);
+ self::assertEquals($maskedQuoteId, $response['addVirtualProductsToCart']['cart']['cart_id']);
self::assertEquals($quantity, $response['addVirtualProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addVirtualProductsToCart']['cart']['items'][0]['product']['sku']);
}
@@ -227,6 +229,7 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
}
) {
cart {
+ cart_id
items {
quantity
product {
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php
index 35ad3ad34c7d6..14567cc96b0b7 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php
@@ -41,6 +41,8 @@ public function testApplyCouponToCart()
$response = $this->graphQlMutation($query);
self::assertArrayHasKey('applyCouponToCart', $response);
+ self::assertArrayHasKey('cart_id', $response['applyCouponToCart']['cart']);
+ self::assertEquals($maskedQuoteId, $response['applyCouponToCart']['cart']['cart_id']);
self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
}
@@ -202,6 +204,7 @@ private function getQuery(string $maskedQuoteId, string $couponCode): string
mutation {
applyCouponToCart(input: {cart_id: "$maskedQuoteId", coupon_code: "$couponCode"}) {
cart {
+ cart_id
applied_coupon {
code
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php
index d39f1b42459c7..a0d28d0cf4a72 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php
@@ -44,6 +44,8 @@ public function testGetCart()
self::assertArrayHasKey('cart', $response);
self::assertArrayHasKey('items', $response['cart']);
+ self::assertArrayHasKey('cart_id', $response['cart']);
+ self::assertEquals($maskedQuoteId, $response['cart']['cart_id']);
self::assertCount(2, $response['cart']['items']);
self::assertNotEmpty($response['cart']['items'][0]['id']);
@@ -184,6 +186,7 @@ private function getQuery(string $maskedQuoteId): string
return <<
Date: Fri, 1 Nov 2019 13:37:35 -0500
Subject: [PATCH 0931/1978] MC-17633: After running setup:upgrade,
setup:db:check still says: Declarative Schema is not up to date (MariaDB
issue)
---
.../Setup/Declaration/Schema/Db/DefinitionAggregator.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
index d01c28ca7bc29..c1d3f9ebee751 100644
--- a/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
+++ b/lib/internal/Magento/Framework/Setup/Declaration/Schema/Db/DefinitionAggregator.php
@@ -109,7 +109,7 @@ protected function processDefaultValue(array $data)
if ($defaultValue === "'NULL'") {
return "NULL";
}
- if ($defaultValue === "NULL" && (bool) strpos($this->getDatabaseVersion(), 'MariaDB')) {
+ if ($defaultValue === "NULL" && strpos($this->getDatabaseVersion(), 'MariaDB') !== false) {
return null;
}
/*
From 1c93a011ac706e1d91c3c8117c77454b44ce035e Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Fri, 1 Nov 2019 13:45:24 -0500
Subject: [PATCH 0932/1978] MC-22213: Implementation - Merge cart - Added tests
and assertions
---
.../GraphQl/Quote/Customer/MergeCartsTest.php | 44 +++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
index 7f8a0dec0bd3b..36614ccd866dd 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
@@ -90,6 +90,50 @@ public function testMergeGuestWithCustomerCart()
$this->getHeaderMap()
);
+ self::assertArrayHasKey('cart', $cartResponse);
+ self::assertArrayHasKey('items', $cartResponse['cart']);
+ self::assertCount(2, $cartResponse['cart']['items']);
+ $item1 = $cartResponse['cart']['items'][0];
+ self::assertArrayHasKey('quantity', $item1);
+ self::assertEquals(2, $item1['quantity']);
+ $item2 = $cartResponse['cart']['items'][1];
+ self::assertArrayHasKey('quantity', $item2);
+ self::assertEquals(1, $item2['quantity']);
+ }
+
+ /**
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ * @expectedException \Exception
+ * @expectedExceptionMessage Current user does not have an active cart.
+ */
+ public function testGuestCartExpiryAfterMerge()
+ {
+ $customerQuote = $this->quoteFactory->create();
+ $this->quoteResource->load($customerQuote, 'test_quote', 'reserved_order_id');
+
+ $guestQuote = $this->quoteFactory->create();
+ $this->quoteResource->load(
+ $guestQuote,
+ 'test_order_with_virtual_product_without_address',
+ 'reserved_order_id'
+ );
+
+ $customerQuoteMaskedId = $this->quoteIdToMaskedId->execute((int)$customerQuote->getId());
+ $guestQuoteMaskedId = $this->quoteIdToMaskedId->execute((int)$guestQuote->getId());
+
+ $query = $this->getCartMergeMutation($guestQuoteMaskedId, $customerQuoteMaskedId);
+ $this->graphQlMutation($query, [], '', $this->getHeaderMap());
+ $cartResponse = $this->graphQlMutation(
+ $this->getCartQuery($guestQuoteMaskedId),
+ [],
+ '',
+ $this->getHeaderMap()
+ );
+
self::assertArrayHasKey('cart', $cartResponse);
self::assertArrayHasKey('items', $cartResponse['cart']);
self::assertCount(2, $cartResponse['cart']['items']);
From 2e0f9b9c0b2a7d8d37ee0df757758d3496cfcc8f Mon Sep 17 00:00:00 2001
From: Soumya Unnikrishnan
Date: Fri, 1 Nov 2019 14:22:58 -0500
Subject: [PATCH 0933/1978] MQE-1872: [MTF-MFTF] Process PR #348 Fixed
StorefrontAddToCartFromQuickSearch to hover over by product name instead of
index. Added data clean up step.
---
.../Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml | 2 +-
.../CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
index a72762ff796e0..59b78cd0c2975 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/ActionGroup/StorefrontCatalogSearchActionGroup.xml
@@ -66,7 +66,7 @@
-
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
index 90b13bd1b6b4f..27d54b678f907 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
@@ -439,7 +439,8 @@
-
+
+
From 9d2cdef384431099c187aae97712a4de37bfad1c Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Fri, 1 Nov 2019 14:23:46 -0500
Subject: [PATCH 0934/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Magento/Catalog/Model/Indexer/Category/Product.php | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
index 8458549456f41..c18404bda1fc8 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Category/Product.php
@@ -133,10 +133,15 @@ public function executeRow($id)
protected function executeAction($ids)
{
$ids = array_unique($ids);
+ $indexer = $this->indexerRegistry->get(static::INDEXER_ID);
/** @var Product\Action\Rows $action */
$action = $this->rowsActionFactory->create();
- $action->execute($ids, true);
+ if ($indexer->isScheduled()) {
+ $action->execute($ids, true);
+ } else {
+ $action->execute($ids);
+ }
return $this;
}
From c664f00fe82841be4796458080c30e5e235f7fbc Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Fri, 1 Nov 2019 15:09:57 -0500
Subject: [PATCH 0935/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Fulltext/Plugin/Product/Category/Action/Rows.php | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php
index b8e60b9973731..2b1844deb114c 100644
--- a/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php
+++ b/app/code/Magento/CatalogSearch/Model/Indexer/Fulltext/Plugin/Product/Category/Action/Rows.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Product\Category\Action;
use Magento\Framework\Indexer\IndexerRegistry;
@@ -33,12 +35,11 @@ public function __construct(IndexerRegistry $indexerRegistry)
* @param ActionRows $subject
* @param ActionRows $result
* @param array $entityIds
- * @param boolean $useTempTable
- * @return Rows
+ * @return ActionRows
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
- public function afterExecute(ActionRows $subject, ActionRows $result, array $entityIds, $useTempTable)
+ public function afterExecute(ActionRows $subject, ActionRows $result, array $entityIds): ActionRows
{
if (!empty($entityIds)) {
$indexer = $this->indexerRegistry->get(FulltextIndexer::INDEXER_ID);
From 71eb365131acf29be2876c59e9ff0d3327f30d48 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Fri, 1 Nov 2019 15:24:36 -0500
Subject: [PATCH 0936/1978] magento graphql-ce#961 ShippingAddressInput
postcode String, is not required by Schema
---
.../Model/Cart/QuoteAddressFactory.php | 55 ++++++++++-----
.../Customer/SetBillingAddressOnCartTest.php | 69 ++++++++++++++++++-
.../Customer/SetShippingAddressOnCartTest.php | 69 ++++++++++++++++++-
3 files changed, 173 insertions(+), 20 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
index 2b0a903a97254..9cb3d9173ac59 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Cart/QuoteAddressFactory.php
@@ -9,14 +9,15 @@
use Magento\Customer\Helper\Address as AddressHelper;
use Magento\CustomerGraphQl\Model\Customer\Address\GetCustomerAddress;
-use Magento\Directory\Api\CountryInformationAcquirerInterface;
use Magento\Framework\Exception\LocalizedException;
-use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Exception\GraphQlNoSuchEntityException;
use Magento\Quote\Model\Quote\Address as QuoteAddress;
use Magento\Quote\Model\Quote\AddressFactory as BaseQuoteAddressFactory;
+use Magento\Directory\Model\ResourceModel\Region\CollectionFactory as RegionCollectionFactory;
+use Magento\Directory\Helper\Data as CountryHelper;
+use Magento\Directory\Model\AllowedCountries;
/**
* Create QuoteAddress
@@ -39,26 +40,42 @@ class QuoteAddressFactory
private $addressHelper;
/**
- * @var CountryInformationAcquirerInterface
+ * @var RegionCollectionFactory
*/
- private $countryInformationAcquirer;
+ private $regionCollectionFactory;
+
+ /**
+ * @var CountryHelper
+ */
+ private $countryHelper;
+
+ /**
+ * @var AllowedCountries
+ */
+ private $allowedCountries;
/**
* @param BaseQuoteAddressFactory $quoteAddressFactory
* @param GetCustomerAddress $getCustomerAddress
* @param AddressHelper $addressHelper
- * @param CountryInformationAcquirerInterface $countryInformationAcquirer
+ * @param RegionCollectionFactory $regionCollectionFactory
+ * @param CountryHelper $countryHelper
+ * @param AllowedCountries $allowedCountries
*/
public function __construct(
BaseQuoteAddressFactory $quoteAddressFactory,
GetCustomerAddress $getCustomerAddress,
AddressHelper $addressHelper,
- CountryInformationAcquirerInterface $countryInformationAcquirer
+ RegionCollectionFactory $regionCollectionFactory,
+ CountryHelper $countryHelper,
+ AllowedCountries $allowedCountries
) {
$this->quoteAddressFactory = $quoteAddressFactory;
$this->getCustomerAddress = $getCustomerAddress;
$this->addressHelper = $addressHelper;
- $this->countryInformationAcquirer = $countryInformationAcquirer;
+ $this->regionCollectionFactory = $regionCollectionFactory;
+ $this->countryHelper = $countryHelper;
+ $this->allowedCountries = $allowedCountries;
}
/**
@@ -77,18 +94,22 @@ public function createBasedOnInputData(array $addressInput): QuoteAddress
$addressInput['country_id'] = $addressInput['country_code'];
}
- if ($addressInput['country_id'] && isset($addressInput['region'])) {
- try {
- $countryInformation = $this->countryInformationAcquirer->getCountryInfo($addressInput['country_id']);
- } catch (NoSuchEntityException $e) {
- throw new GraphQlInputException(__('The country isn\'t available.'));
- }
- $availableRegions = $countryInformation->getAvailableRegions();
- if (null !== $availableRegions) {
- $addressInput['region_code'] = $addressInput['region'];
+ $allowedCountries = $this->allowedCountries->getAllowedCountries();
+ if (!in_array($addressInput['country_code'], $allowedCountries, true)) {
+ throw new GraphQlInputException(__('Country is not available'));
+ }
+ $isRegionRequired = $this->countryHelper->isRegionRequired($addressInput['country_code']);
+ if ($isRegionRequired && !empty($addressInput['region'])) {
+ $regionCollection = $this->regionCollectionFactory
+ ->create()
+ ->addRegionCodeFilter($addressInput['region'])
+ ->addCountryFilter($addressInput['country_code']);
+ if ($regionCollection->getSize() === 0) {
+ throw new GraphQlInputException(
+ __('Region is not available for the selected country')
+ );
}
}
-
$maxAllowedLineCount = $this->addressHelper->getStreetLines();
if (is_array($addressInput['street']) && count($addressInput['street']) > $maxAllowedLineCount) {
throw new GraphQlInputException(
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index 7d66b6112bae9..d79ab8895b53c 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -693,7 +693,23 @@ public function dataProviderSetWithoutRequiredParameters(): array
}',
'"postcode" is required. Enter and try again.
"regionId" is required. Enter and try again.'
- ]
+ ],
+ 'wrong_required_region' => [
+ 'cart_id: "cart_id_value"
+ billing_address: {
+ address: {
+ firstname: "test firstname"
+ lastname: "test lastname"
+ company: "test company"
+ street: ["test street 1", "test street 2"]
+ region: "wrong region"
+ city: "test city"
+ country_code: "US"
+ telephone: "88776655"
+ }
+ }',
+ 'Region is not available for the selected country'
+ ],
];
}
@@ -980,10 +996,59 @@ public function testWithInvalidBillingAddressInput()
}
}
QUERY;
- $this->expectExceptionMessage('The country isn\'t available.');
+ $this->expectExceptionMessage('Country is not available');
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testSetShippingAddressesWithNotRequiredRegion()
+ {
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
+
+ $query = <<graphQlMutation($query, [], '', $this->getHeaderMap());
+ self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
+ $cartResponse = $response['setBillingAddressOnCart']['cart'];
+ self::assertEquals('UA', $cartResponse['billing_address']['country']['code']);
+ self::assertEquals('Lviv', $cartResponse['billing_address']['region']['label']);
+ }
+
/**
* Verify the all the whitelisted fields for a New Address Object
*
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
index 9e03c3932cc84..280ab712c69d9 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php
@@ -512,6 +512,22 @@ public function dataProviderUpdateWithMissedRequiredParameters(): array
'"postcode" is required. Enter and try again.
"regionId" is required. Enter and try again.'
],
+ 'wrong_required_region' => [
+ 'cart_id: "cart_id_value"
+ shipping_addresses: [{
+ address: {
+ firstname: "test firstname"
+ lastname: "test lastname"
+ company: "test company"
+ street: ["test street 1", "test street 2"]
+ region: "wrong region"
+ city: "test city"
+ country_code: "US"
+ telephone: "88776655"
+ }
+ }]',
+ 'Region is not available for the selected country'
+ ],
];
}
@@ -780,10 +796,61 @@ public function testWithInvalidShippingAddressesInput()
}
}
QUERY;
- $this->expectExceptionMessage('The country isn\'t available.');
+ $this->expectExceptionMessage('Country is not available');
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
}
+ /**
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
+ */
+ public function testSetShippingAddressesWithNotRequiredRegion()
+ {
+ $maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
+
+ $query = <<graphQlMutation($query, [], '', $this->getHeaderMap());
+ self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
+ $cartResponse = $response['setShippingAddressesOnCart']['cart'];
+ self::assertEquals('UA', $cartResponse['shipping_addresses'][0]['country']['code']);
+ self::assertEquals('Lviv', $cartResponse['shipping_addresses'][0]['region']['label']);
+ }
+
/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
From 12de07149eefe14bdea2222b0806967c07742701 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Fri, 1 Nov 2019 15:33:34 -0500
Subject: [PATCH 0937/1978] MC-22213: Implementation - Merge cart - remove
unnecessary assertions
---
.../Magento/GraphQl/Quote/Customer/MergeCartsTest.php | 4 ----
1 file changed, 4 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
index 36614ccd866dd..86172d3c229ae 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
@@ -133,10 +133,6 @@ public function testGuestCartExpiryAfterMerge()
'',
$this->getHeaderMap()
);
-
- self::assertArrayHasKey('cart', $cartResponse);
- self::assertArrayHasKey('items', $cartResponse['cart']);
- self::assertCount(2, $cartResponse['cart']['items']);
}
/**
From d270684249fe2128ecf01ad540640053937a79c2 Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Fri, 1 Nov 2019 16:25:18 -0500
Subject: [PATCH 0938/1978] MC-16108: [Performance] EAV attribute is not cached
- Testing adding system attributes without adding them to di.xml;
---
app/code/Magento/Customer/etc/di.xml | 108 +++++++++++++--------------
1 file changed, 54 insertions(+), 54 deletions(-)
diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml
index be219a81fd990..8084f50041463 100644
--- a/app/code/Magento/Customer/etc/di.xml
+++ b/app/code/Magento/Customer/etc/di.xml
@@ -473,58 +473,58 @@
-
-
-
- -
-
- customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
- - customer
-
- -
-
- customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
- - customer_address
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 387442391cf3c5e0cbcef9430f1211ab08501f5e Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Fri, 1 Nov 2019 16:47:16 -0500
Subject: [PATCH 0939/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Fixed cart_id to id
---
.../Magento/QuoteGraphQl/etc/schema.graphqls | 2 +-
.../GraphQl/Quote/Customer/GetCartTest.php | 9 +++---
.../Quote/Customer/GetCustomerCartTest.php | 28 +++++++++----------
.../Guest/AddSimpleProductToCartTest.php | 6 ++--
.../Guest/AddVirtualProductToCartTest.php | 6 ++--
.../Quote/Guest/ApplyCouponToCartTest.php | 6 ++--
.../GraphQl/Quote/Guest/GetCartTest.php | 6 ++--
7 files changed, 31 insertions(+), 32 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
index b5d03c8cb7093..49584beaa61ba 100644
--- a/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/QuoteGraphQl/etc/schema.graphqls
@@ -193,7 +193,7 @@ type PlaceOrderOutput {
}
type Cart {
- cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart.")
+ id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart.")
items: [CartItemInterface] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartItems")
applied_coupon: AppliedCoupon @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupon") @doc(description:"An array of coupons that have been applied to the cart") @deprecated(reason: "Use applied_coupons instead ")
applied_coupons: [AppliedCoupon] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupons") @doc(description:"An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code")
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
index 32358fd99b47f..09736261c4aa4 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
@@ -65,8 +65,8 @@ public function testGetCart()
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
self::assertArrayHasKey('cart', $response);
- self::assertArrayHasKey('cart_id', $response['cart']);
- self::assertEquals($maskedQuoteId, $response['cart']['cart_id']);
+ self::assertArrayHasKey('id', $response['cart']);
+ self::assertEquals($maskedQuoteId, $response['cart']['id']);
self::assertArrayHasKey('items', $response['cart']);
self::assertCount(2, $response['cart']['items']);
@@ -190,8 +190,7 @@ public function testGetCartWithNotDefaultStore()
}
/**
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
+ * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
* @magentoApiDataFixture Magento/Store/_files/second_store.php
*
* @expectedException Exception
@@ -258,7 +257,7 @@ private function getQuery(string $maskedQuoteId): string
return <<assertArrayHasKey('items', $response['customerCart']);
$this->assertNotEmpty($response['customerCart']['items']);
$this->assertEquals(2, $response['customerCart']['total_quantity']);
- $this->assertArrayHasKey('cart_id', $response['customerCart']);
- $this->assertEquals($maskedQuoteId, $response['customerCart']['cart_id']);
+ $this->assertArrayHasKey('id', $response['customerCart']);
+ $this->assertEquals($maskedQuoteId, $response['customerCart']['id']);
$this->assertEquals(
$quantity,
$response['customerCart']['items'][0]['quantity'],
@@ -74,8 +74,8 @@ public function testGetNewCustomerCart()
$headers = ['Authorization' => 'Bearer ' . $customerToken];
$response = $this->graphQlQuery($customerCartQuery, [], '', $headers);
$this->assertArrayHasKey('customerCart', $response);
- $this->assertArrayHasKey('cart_id', $response['customerCart']);
- $this->assertNotNull($response['customerCart']['cart_id']);
+ $this->assertArrayHasKey('id', $response['customerCart']);
+ $this->assertNotNull($response['customerCart']['id']);
$this->assertEmpty($response['customerCart']['items']);
$this->assertEquals(0, $response['customerCart']['total_quantity']);
}
@@ -104,8 +104,8 @@ public function testGetCustomerCartAfterTokenRevoked()
$customerCartQuery = $this->getCustomerCartQuery();
$response = $this->graphQlMutation($customerCartQuery, [], '', $headers);
$this->assertArrayHasKey('customerCart', $response);
- $this->assertArrayHasKey('cart_id', $response['customerCart']);
- $this->assertNotNull($response['customerCart']['cart_id']);
+ $this->assertArrayHasKey('id', $response['customerCart']);
+ $this->assertNotNull($response['customerCart']['id']);
$this->revokeCustomerToken();
$customerCartQuery = $this->getCustomerCartQuery();
$this->expectExceptionMessage(
@@ -126,12 +126,12 @@ public function testRequestCustomerCartTwice()
$customerCartQuery = $this->getCustomerCartQuery();
$response = $this->graphQlMutation($customerCartQuery, [], '', $headers);
$this->assertArrayHasKey('customerCart', $response);
- $this->assertArrayHasKey('cart_id', $response['customerCart']);
- $this->assertNotNull($response['customerCart']['cart_id']);
- $cartId = $response['customerCart']['cart_id'];
+ $this->assertArrayHasKey('id', $response['customerCart']);
+ $this->assertNotNull($response['customerCart']['id']);
+ $cartId = $response['customerCart']['id'];
$customerCartQuery = $this->getCustomerCartQuery();
$response2 = $this->graphQlQuery($customerCartQuery, [], '', $headers);
- $this->assertEquals($cartId, $response2['customerCart']['cart_id']);
+ $this->assertEquals($cartId, $response2['customerCart']['id']);
}
/**
@@ -148,7 +148,7 @@ public function testGetInactiveCustomerCart()
$customerCartQuery = $this->getCustomerCartQuery();
$response = $this->graphQlQuery($customerCartQuery, [], '', $this->getHeaderMap());
$this->assertArrayHasKey('customerCart', $response);
- $this->assertNotEmpty($response['customerCart']['cart_id']);
+ $this->assertNotEmpty($response['customerCart']['id']);
$this->assertEmpty($response['customerCart']['items']);
$this->assertEmpty($response['customerCart']['total_quantity']);
}
@@ -166,7 +166,7 @@ public function testGetCustomerCartSecondStore()
$headerMap = $this->getHeaderMap();
$headerMap['Store'] = 'fixture_second_store';
$responseSecondStore = $this->graphQlQuery($customerCartQuery, [], '', $headerMap);
- $this->assertEquals($maskedQuoteIdSecondStore, $responseSecondStore['customerCart']['cart_id']);
+ $this->assertEquals($maskedQuoteIdSecondStore, $responseSecondStore['customerCart']['id']);
}
/**
@@ -223,8 +223,8 @@ private function getCustomerCartQuery(): string
return <<graphQlMutation($query);
self::assertArrayHasKey('cart', $response['addVirtualProductsToCart']);
- self::assertArrayHasKey('cart_id', $response['addVirtualProductsToCart']['cart']);
- self::assertEquals($maskedQuoteId, $response['addVirtualProductsToCart']['cart']['cart_id']);
+ self::assertArrayHasKey('id', $response['addVirtualProductsToCart']['cart']);
+ self::assertEquals($maskedQuoteId, $response['addVirtualProductsToCart']['cart']['id']);
self::assertEquals($quantity, $response['addVirtualProductsToCart']['cart']['items'][0]['quantity']);
self::assertEquals($sku, $response['addVirtualProductsToCart']['cart']['items'][0]['product']['sku']);
}
@@ -229,7 +229,7 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
}
) {
cart {
- cart_id
+ id
items {
quantity
product {
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php
index 14567cc96b0b7..c94e5cc52edbb 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/ApplyCouponToCartTest.php
@@ -41,8 +41,8 @@ public function testApplyCouponToCart()
$response = $this->graphQlMutation($query);
self::assertArrayHasKey('applyCouponToCart', $response);
- self::assertArrayHasKey('cart_id', $response['applyCouponToCart']['cart']);
- self::assertEquals($maskedQuoteId, $response['applyCouponToCart']['cart']['cart_id']);
+ self::assertArrayHasKey('id', $response['applyCouponToCart']['cart']);
+ self::assertEquals($maskedQuoteId, $response['applyCouponToCart']['cart']['id']);
self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
}
@@ -204,7 +204,7 @@ private function getQuery(string $maskedQuoteId, string $couponCode): string
mutation {
applyCouponToCart(input: {cart_id: "$maskedQuoteId", coupon_code: "$couponCode"}) {
cart {
- cart_id
+ id
applied_coupon {
code
}
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php
index a0d28d0cf4a72..ae9b7b32b2dab 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/GetCartTest.php
@@ -44,8 +44,8 @@ public function testGetCart()
self::assertArrayHasKey('cart', $response);
self::assertArrayHasKey('items', $response['cart']);
- self::assertArrayHasKey('cart_id', $response['cart']);
- self::assertEquals($maskedQuoteId, $response['cart']['cart_id']);
+ self::assertArrayHasKey('id', $response['cart']);
+ self::assertEquals($maskedQuoteId, $response['cart']['id']);
self::assertCount(2, $response['cart']['items']);
self::assertNotEmpty($response['cart']['items'][0]['id']);
@@ -186,7 +186,7 @@ private function getQuery(string $maskedQuoteId): string
return <<
Date: Fri, 1 Nov 2019 16:56:29 -0500
Subject: [PATCH 0940/1978] MC-22213: Implementation - Merge cart - review
fixes
---
.../GraphQl/Quote/Customer/MergeCartsTest.php | 35 ++-----------------
1 file changed, 3 insertions(+), 32 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
index 86172d3c229ae..5f7c61412c095 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
@@ -135,35 +135,6 @@ public function testGuestCartExpiryAfterMerge()
);
}
- /**
- * @magentoApiDataFixture Magento/Customer/_files/customer.php
- * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/make_cart_inactive.php
- * @expectedException \Exception
- * @expectedExceptionMessage Current user does not have an active cart.
- */
- public function testMergeTwoCustomerCarts()
- {
- $firstQuote = $this->quoteFactory->create();
- $this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
- $firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
-
- $createCartResponse = $this->graphQlMutation(
- $this->getCreateEmptyCartMutation(),
- [],
- '',
- $this->getHeaderMap()
- );
- self::assertArrayHasKey('createEmptyCart', $createCartResponse);
- $secondMaskedId = $createCartResponse['createEmptyCart'];
- $this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap());
-
- $query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
- $this->graphQlMutation($query, [], '', $this->getHeaderMap());
- }
-
/**
* @magentoApiDataFixture Magento/Customer/_files/two_customers.php
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
@@ -172,12 +143,12 @@ public function testMergeTwoCustomerCarts()
* @expectedException \Exception
* @expectedExceptionMessage The current user cannot perform operations on cart
*/
- public function testMergeOtherCustomerCart()
+ public function testMergeTwoCustomerCarts()
{
$firstQuote = $this->quoteFactory->create();
$this->quoteResource->load($firstQuote, 'test_quote', 'reserved_order_id');
-
$firstMaskedId = $this->quoteIdToMaskedId->execute((int)$firstQuote->getId());
+
$createCartResponse = $this->graphQlMutation(
$this->getCreateEmptyCartMutation(),
[],
@@ -186,7 +157,7 @@ public function testMergeOtherCustomerCart()
);
self::assertArrayHasKey('createEmptyCart', $createCartResponse);
$secondMaskedId = $createCartResponse['createEmptyCart'];
- $this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap('customer_two@example.com'));
+ $this->addSimpleProductToCart($secondMaskedId, $this->getHeaderMap());
$query = $this->getCartMergeMutation($firstMaskedId, $secondMaskedId);
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
From 0c4bcd899d6a161bf448d00f7c8b20d651441151 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Fri, 1 Nov 2019 17:15:17 -0500
Subject: [PATCH 0941/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php | 4 ++--
.../Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
index fbc59e386305c..f7dde23e1510e 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Category/ProductTest.php
@@ -90,7 +90,7 @@ public function testExecuteWithIndexerWorking()
\Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class,
['execute']
);
- $rowMock->expects($this->at(0))->method('execute')->with($ids, true)->will($this->returnSelf());
+ $rowMock->expects($this->at(0))->method('execute')->with($ids)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
@@ -107,7 +107,7 @@ public function testExecuteWithIndexerNotWorking()
\Magento\Catalog\Model\Indexer\Category\Product\Action\Rows::class,
['execute']
);
- $rowMock->expects($this->once())->method('execute')->with($ids, true)->will($this->returnSelf());
+ $rowMock->expects($this->once())->method('execute')->with($ids)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
diff --git a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
index ab0ca8a5bc48a..4e6659f85f5df 100644
--- a/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
+++ b/app/code/Magento/Catalog/Test/Unit/Model/Indexer/Product/CategoryTest.php
@@ -90,7 +90,7 @@ public function testExecuteWithIndexerWorking()
\Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class,
['execute']
);
- $rowMock->expects($this->at(0))->method('execute')->with($ids, true)->will($this->returnSelf());
+ $rowMock->expects($this->at(0))->method('execute')->with($ids)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
@@ -107,7 +107,7 @@ public function testExecuteWithIndexerNotWorking()
\Magento\Catalog\Model\Indexer\Product\Category\Action\Rows::class,
['execute']
);
- $rowMock->expects($this->once())->method('execute')->with($ids, true)->will($this->returnSelf());
+ $rowMock->expects($this->once())->method('execute')->with($ids)->will($this->returnSelf());
$this->rowsMock->expects($this->once())->method('create')->will($this->returnValue($rowMock));
From 98f53e703f6238f37c9a5948e32764de9ee1212e Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Fri, 1 Nov 2019 17:19:29 -0500
Subject: [PATCH 0942/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Fixed static failures on dependency test
---
.../Model/Resolver/CustomerCart.php | 37 ++++++-------------
1 file changed, 11 insertions(+), 26 deletions(-)
diff --git a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
index a4d596298b5ba..781c574d7e6a6 100644
--- a/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
+++ b/app/code/Magento/QuoteGraphQl/Model/Resolver/CustomerCart.php
@@ -9,11 +9,11 @@
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\GraphQl\Config\Element\Field;
-use Magento\Framework\GraphQl\Exception\GraphQlInputException;
use Magento\Framework\GraphQl\Query\ResolverInterface;
use Magento\Framework\GraphQl\Schema\Type\ResolveInfo;
use Magento\QuoteGraphQl\Model\Cart\CreateEmptyCartForCustomer;
-use Magento\Authorization\Model\UserContextInterface;
+use Magento\GraphQl\Model\Query\ContextInterface;
+use Magento\Framework\GraphQl\Exception\GraphQlAuthorizationException;
use Magento\Quote\Api\CartManagementInterface;
/**
@@ -49,35 +49,20 @@ public function __construct(
public function resolve(Field $field, $context, ResolveInfo $info, array $value = null, array $args = null)
{
$currentUserId = $context->getUserId();
- $currentUserType = $context->getUserType();
- $isCustomerLoggedIn = $this->isCustomer($currentUserId, $currentUserType);
- if ($isCustomerLoggedIn) {
- try {
- $cart = $this->cartManagement->getCartForCustomer($currentUserId);
- } catch (NoSuchEntityException $e) {
- $this->createEmptyCartForCustomer->execute($currentUserId, null);
- $cart = $this->cartManagement->getCartForCustomer($currentUserId);
- }
-
- } else {
- throw new GraphQlInputException(__('The request is allowed for logged in customer'));
+ /** @var ContextInterface $context */
+ if (false === $context->getExtensionAttributes()->getIsCustomer()) {
+ throw new GraphQlAuthorizationException(__('The request is allowed for logged in customer'));
+ }
+ try {
+ $cart = $this->cartManagement->getCartForCustomer($currentUserId);
+ } catch (NoSuchEntityException $e) {
+ $this->createEmptyCartForCustomer->execute($currentUserId, null);
+ $cart = $this->cartManagement->getCartForCustomer($currentUserId);
}
return [
'model' => $cart
];
}
-
- /**
- * Check if current user is logged in
- *
- * @param int|null $customerId
- * @param int|null $customerType
- * @return bool
- */
- private function isCustomer(?int $customerId, ?int $customerType): bool
- {
- return !empty($customerId) && !empty($customerType) && $customerType !== UserContextInterface::USER_TYPE_GUEST;
- }
}
From cde1cc6de10df04d1700b5c55ee6deb8c8c4db70 Mon Sep 17 00:00:00 2001
From: Dmytro Poperechnyy
Date: Fri, 1 Nov 2019 18:32:45 -0500
Subject: [PATCH 0943/1978] MC-16108: [Performance] EAV attribute is not cached
---
app/code/Magento/Customer/etc/di.xml | 108 +++++++++++++--------------
1 file changed, 54 insertions(+), 54 deletions(-)
diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml
index 8084f50041463..be219a81fd990 100644
--- a/app/code/Magento/Customer/etc/di.xml
+++ b/app/code/Magento/Customer/etc/di.xml
@@ -473,58 +473,58 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ -
+
- customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+ - customer
+
+ -
+
- customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+ - customer_address
+
+
+
+
From df02efabd4fa371efdbd749bb384c1c9febe0ba9 Mon Sep 17 00:00:00 2001
From: Mateusz Krzeszowiak
Date: Sat, 2 Nov 2019 12:32:35 +0100
Subject: [PATCH 0944/1978] Restore checkboxes alignment in admin data grids
Fixes https://github.com/magento/magento2/issues/25429.
---
.../backend/Magento_Ui/web/css/source/module/_data-grid.less | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less
index 946d11db2d1a2..b0c44e127a454 100644
--- a/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less
+++ b/app/design/adminhtml/Magento/backend/Magento_Ui/web/css/source/module/_data-grid.less
@@ -1075,7 +1075,6 @@ body._in-resize {
}
.data-grid-checkbox-cell-inner {
- display: unset;
margin: 0 @data-grid-checkbox-cell-inner__padding-horizontal 0;
padding: 0;
text-align: center;
From e619c262aa46e939b1d645d9aeea912e4de41884 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Tylek?=
Date: Sat, 2 Nov 2019 12:50:55 +0100
Subject: [PATCH 0945/1978] MAGETWO-98251 Remove additional nesting
---
.../Magento/blank/web/css/source/_layout.less | 18 ++++++++----------
.../web/css/source/_module.less | 1 -
2 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/app/design/frontend/Magento/blank/web/css/source/_layout.less b/app/design/frontend/Magento/blank/web/css/source/_layout.less
index 5490fba96b953..287f1b45b8328 100644
--- a/app/design/frontend/Magento/blank/web/css/source/_layout.less
+++ b/app/design/frontend/Magento/blank/web/css/source/_layout.less
@@ -125,16 +125,14 @@
}
.page-layout-2columns-left {
- .page-layout-2columns-left {
- .main {
- padding-left: @layout-column__additional-sidebar-offset
- }
-
- .sidebar-additional {
- clear: left;
- float: left;
- padding-left: 0;
- }
+ .main {
+ padding-left: @layout-column__additional-sidebar-offset
+ }
+
+ .sidebar-additional {
+ clear: left;
+ float: left;
+ padding-left: 0;
}
}
diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
index 9b6986249b009..a741b04dbcfdb 100644
--- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
@@ -397,7 +397,6 @@
.box-tocart {
&:extend(.abs-box-tocart all);
-
.field.qty {
}
From 3267575132c18ebd5cb11f00a3fab895a1b217c8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pawe=C5=82=20Tylek?=
Date: Sat, 2 Nov 2019 12:57:30 +0100
Subject: [PATCH 0946/1978] MAGETWO-98251 Add break line
---
.../Magento/luma/Magento_Catalog/web/css/source/_module.less | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
index a741b04dbcfdb..9b6986249b009 100644
--- a/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
+++ b/app/design/frontend/Magento/luma/Magento_Catalog/web/css/source/_module.less
@@ -397,6 +397,7 @@
.box-tocart {
&:extend(.abs-box-tocart all);
+
.field.qty {
}
From 17a8aa9bfb82e3626b787a4e680c96cb0bfba481 Mon Sep 17 00:00:00 2001
From: Mateusz Krzeszowiak
Date: Fri, 1 Nov 2019 15:48:56 +0100
Subject: [PATCH 0947/1978] Allow modal triggers to be added after module
initialization
Fixes https://github.com/magento/magento2/issues/9671. Event delegation is used
to allow different modal opening trigger elements to be added at any time
as long as they match given selector.
---
app/code/Magento/Ui/view/base/web/js/modal/modal.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/modal/modal.js b/app/code/Magento/Ui/view/base/web/js/modal/modal.js
index a8a76206bcd2b..cefe79b42e503 100644
--- a/app/code/Magento/Ui/view/base/web/js/modal/modal.js
+++ b/app/code/Magento/Ui/view/base/web/js/modal/modal.js
@@ -131,7 +131,10 @@ define([
this._createWrapper();
this._renderModal();
this._createButtons();
- $(this.options.trigger).on('click', _.bind(this.toggleModal, this));
+
+ if (this.options.trigger) {
+ $(document).on('click', this.options.trigger, _.bind(this.toggleModal, this));
+ }
this._on(this.modal.find(this.options.modalCloseBtn), {
'click': this.options.modalCloseBtnHandler ? this.options.modalCloseBtnHandler : this.closeModal
});
From 0bf7a4c1b87cf0a738ab17ad76a4cb5b46443167 Mon Sep 17 00:00:00 2001
From: Behnam Shayani
Date: Sun, 3 Nov 2019 20:43:31 +0100
Subject: [PATCH 0948/1978] fix performance issue with attribute that have
large numebr of options, do not loop over all options
---
.../Adapter/BatchDataMapper/ProductDataMapper.php | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php
index 270ca37e2d42c..19b553dd05f08 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/BatchDataMapper/ProductDataMapper.php
@@ -285,9 +285,9 @@ private function getValuesLabels(Attribute $attribute, array $attributeValues):
return $attributeLabels;
}
- foreach ($options as $option) {
- if (\in_array($option->getValue(), $attributeValues)) {
- $attributeLabels[] = $option->getLabel();
+ foreach ($attributeValues as $attributeValue) {
+ if (isset($options[$attributeValue])) {
+ $attributeLabels[] = $options[$attributeValue]->getLabel();
}
}
@@ -304,7 +304,11 @@ private function getAttributeOptions(Attribute $attribute): array
{
if (!isset($this->attributeOptionsCache[$attribute->getId()])) {
$options = $attribute->getOptions() ?? [];
- $this->attributeOptionsCache[$attribute->getId()] = $options;
+ $optionsByValue = [];
+ foreach ($options as $option) {
+ $optionsByValue[$option->getValue()] = $option;
+ }
+ $this->attributeOptionsCache[$attribute->getId()] = $optionsByValue;
}
return $this->attributeOptionsCache[$attribute->getId()];
From bd38f5b431e24784791256d94f4ce7ef3ed42bb8 Mon Sep 17 00:00:00 2001
From: Anusha Vattam
Date: Sun, 3 Nov 2019 15:19:10 -0600
Subject: [PATCH 0949/1978] MC-22215: Add customerCart Query and cart_id
changes to schema and related resolvers
- Fixed static failures
---
.../testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
index 09736261c4aa4..7ffce2a7f541d 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/GetCartTest.php
@@ -194,7 +194,8 @@ public function testGetCartWithNotDefaultStore()
* @magentoApiDataFixture Magento/Store/_files/second_store.php
*
* @expectedException Exception
- * @expectedExceptionMessage Wrong store code specified for cart
+ * @expectedExceptionMessage The account sign-in was incorrect or your account is disabled temporarily.
+ * Please wait and try again later.
*/
public function testGetCartWithWrongStore()
{
From c1937ed4c29c01944f13c244f576da8ad97c263d Mon Sep 17 00:00:00 2001
From: OlgaVasyltsun
Date: Mon, 4 Nov 2019 08:00:11 +0200
Subject: [PATCH 0950/1978] MC-17259: Update blank gender it does not saved in
direct edits from customer grid
---
.../AdminUpdateCustomerGenderInCustomersGridActionGroup.xml | 2 +-
.../AssertAdminCustomerGenderInCustomersGridActionGroup.xml | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml
index 12c81e3694c0a..0b51140471ab7 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminUpdateCustomerGenderInCustomersGridActionGroup.xml
@@ -18,7 +18,7 @@
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml
index 337c66a0539db..8b73a9c3307e3 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AssertAdminCustomerGenderInCustomersGridActionGroup.xml
@@ -10,7 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
- Assert customer genderAttribute value on customers grid page
+ Assert customer "Gender" attribute value on customer grid page
From 9de869676a805daa8299547b4fe0a790cfc7cb62 Mon Sep 17 00:00:00 2001
From: ashna-jahan
Date: Mon, 4 Nov 2019 13:41:40 +0530
Subject: [PATCH 0951/1978] added fix to ticket 25455
---
.../Magento/Backup/etc/adminhtml/system.xml | 2 +-
.../Magento/Catalog/etc/adminhtml/system.xml | 8 ++++----
.../Developer/etc/adminhtml/system.xml | 2 +-
app/code/Magento/Dhl/etc/adminhtml/system.xml | 2 +-
.../Magento/Paypal/etc/adminhtml/system.xml | 2 +-
.../Magento/Sales/etc/adminhtml/system.xml | 20 +++++++++----------
.../Magento/Signifyd/etc/adminhtml/system.xml | 2 +-
app/code/Magento/Ups/etc/adminhtml/system.xml | 2 +-
.../Config/Structure/Reader/_files/config.xml | 2 +-
9 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/app/code/Magento/Backup/etc/adminhtml/system.xml b/app/code/Magento/Backup/etc/adminhtml/system.xml
index aa6635b4dde4a..78e0aae1dd4c2 100644
--- a/app/code/Magento/Backup/etc/adminhtml/system.xml
+++ b/app/code/Magento/Backup/etc/adminhtml/system.xml
@@ -12,7 +12,7 @@
Backup Settings
Enable Backup
- Disabled by default for security reasons
+ Disabled by default for security reasons.
Magento\Config\Model\Config\Source\Yesno
diff --git a/app/code/Magento/Catalog/etc/adminhtml/system.xml b/app/code/Magento/Catalog/etc/adminhtml/system.xml
index b83ed8591047a..c80363038ac60 100644
--- a/app/code/Magento/Catalog/etc/adminhtml/system.xml
+++ b/app/code/Magento/Catalog/etc/adminhtml/system.xml
@@ -65,7 +65,7 @@
Products per Page on Grid Default Value
- Must be in the allowed values list
+ Must be in the allowed values list.
validate-per-page-value
@@ -75,7 +75,7 @@
Products per Page on List Default Value
- Must be in the allowed values list
+ Must be in the allowed values list.
validate-per-page-value
@@ -90,12 +90,12 @@
Product Listing Sort by
- Applies to category pages
+ Applies to category pages.
Magento\Catalog\Model\Config\Source\ListSort
Allow All Products per Page
- Whether to show "All" option in the "Show X Per Page" dropdown
+ Whether to show "All" option in the "Show X Per Page" dropdown.
Magento\Config\Model\Config\Source\Yesno
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 962fe8c016405e2f95180650fc1f7debc3aff5b7 Mon Sep 17 00:00:00 2001
From: Tomash Khamlai
Date: Mon, 4 Nov 2019 17:48:36 +0200
Subject: [PATCH 0962/1978] Update CreateBundleProductActionGroup.xml
---
.../Test/Mftf/ActionGroup/CreateBundleProductActionGroup.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Bundle/Test/Mftf/ActionGroup/CreateBundleProductActionGroup.xml b/app/code/Magento/Bundle/Test/Mftf/ActionGroup/CreateBundleProductActionGroup.xml
index 34167bd78cc8f..33740c346155a 100644
--- a/app/code/Magento/Bundle/Test/Mftf/ActionGroup/CreateBundleProductActionGroup.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/ActionGroup/CreateBundleProductActionGroup.xml
@@ -149,7 +149,7 @@
- Requires Navigation to Product Creation page. Removes any Bundle Option by index specified in arguments. 'var' refers to Bundle option number.
+ Requires Navigation to Product Creation page. Removes any Bundle Option by index specified in arguments. 'deleteIndex' refers to Bundle option number.
From 018a9d620c7d80c861fff97815652d94f39a117d Mon Sep 17 00:00:00 2001
From: Tomash Khamlai
Date: Mon, 4 Nov 2019 17:58:37 +0200
Subject: [PATCH 0963/1978] Change test name to more relevant
---
.../Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
index d842c5aa7e512..f4419af08985a 100644
--- a/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
+++ b/app/code/Magento/Bundle/Test/Mftf/Test/AdminCreateAndEditBundleProductSettingsTest.xml
@@ -141,7 +141,7 @@
-
+
From 08972b4ee14f37651dc000dbd03c2ad317ab0e66 Mon Sep 17 00:00:00 2001
From: vpashovski
Date: Mon, 4 Nov 2019 18:21:58 +0200
Subject: [PATCH 0964/1978] Fix issue #22240 Create short name for Database
Lock name
---
lib/internal/Magento/Framework/Lock/Backend/Database.php | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/internal/Magento/Framework/Lock/Backend/Database.php b/lib/internal/Magento/Framework/Lock/Backend/Database.php
index a5a76ba60f4e2..460c7554cc12c 100644
--- a/lib/internal/Magento/Framework/Lock/Backend/Database.php
+++ b/lib/internal/Magento/Framework/Lock/Backend/Database.php
@@ -13,6 +13,7 @@
use Magento\Framework\Exception\AlreadyExistsException;
use Magento\Framework\Exception\InputException;
use Magento\Framework\Phrase;
+use Magento\Framework\DB\ExpressionConverter;
/**
* Implementation of the lock manager on the basis of MySQL.
@@ -166,7 +167,8 @@ public function isLocked(string $name): bool
*/
private function addPrefix(string $name): string
{
- $name = $this->getPrefix() . '|' . $name;
+ $prefix = $this->getPrefix() . '|';
+ $name = ExpressionConverter::shortenEntityName($prefix . $name, $prefix);
if (strlen($name) > 64) {
throw new InputException(new Phrase('Lock name too long: %1...', [substr($name, 0, 64)]));
From c0119d95ddad4f80759918070386ab1254443698 Mon Sep 17 00:00:00 2001
From: Sergii Ivashchenko
Date: Mon, 4 Nov 2019 16:45:40 +0000
Subject: [PATCH 0965/1978] magento/magento2#25464: Added unsanitized html
suffix to the error message html
---
app/code/Magento/Ui/view/base/web/js/grid/masonry.js | 2 +-
.../Magento/Ui/view/base/web/templates/grid/masonry.html | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/masonry.js b/app/code/Magento/Ui/view/base/web/js/grid/masonry.js
index 55c712b180fe5..0066ed052fee7 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/masonry.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/masonry.js
@@ -254,7 +254,7 @@ define([
*
* @returns {String|null}
*/
- getErrorMessage: function () {
+ getErrorMessageUnsanitizedHtml: function () {
return this.errorMessage();
}
});
diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html b/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html
index fdf13f777a7c7..228b8370e7b33 100644
--- a/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html
+++ b/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html
@@ -8,10 +8,10 @@
-
+
-
From fa93def1135dd0faf6434b40289e84936fc4dba0 Mon Sep 17 00:00:00 2001
From: Dave Macaulay
Date: Mon, 4 Nov 2019 10:54:28 -0600
Subject: [PATCH 0966/1978] PB-76: PageBuilder Product List Template Is Missing
Product Color & Size Options in Admin
---
.../Magento/Catalog/view/adminhtml/requirejs-config.js | 7 ++++++-
.../view/{frontend => base}/web/js/swatch-renderer.js | 0
2 files changed, 6 insertions(+), 1 deletion(-)
rename app/code/Magento/Swatches/view/{frontend => base}/web/js/swatch-renderer.js (100%)
diff --git a/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js b/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js
index 0677b0a5811c2..2b4efc4016a1b 100644
--- a/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js
+++ b/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js
@@ -12,7 +12,12 @@ var config = {
productGallery: 'Magento_Catalog/js/product-gallery',
baseImage: 'Magento_Catalog/catalog/base-image-uploader',
productAttributes: 'Magento_Catalog/catalog/product-attributes',
- categoryCheckboxTree: 'Magento_Catalog/js/category-checkbox-tree'
+ categoryCheckboxTree: 'Magento_Catalog/js/category-checkbox-tree',
+ priceBox: 'Magento_Catalog/js/price-box',
+ priceOptionDate: 'Magento_Catalog/js/price-option-date',
+ priceOptionFile: 'Magento_Catalog/js/price-option-file',
+ priceOptions: 'Magento_Catalog/js/price-options',
+ priceUtils: 'Magento_Catalog/js/price-utils'
}
},
deps: [
diff --git a/app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js
similarity index 100%
rename from app/code/Magento/Swatches/view/frontend/web/js/swatch-renderer.js
rename to app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js
From 34ad9e3da625ca8e40ad69df2da166fd20b57b15 Mon Sep 17 00:00:00 2001
From: Dave Macaulay
Date: Mon, 4 Nov 2019 11:25:38 -0600
Subject: [PATCH 0967/1978] PB-76: PageBuilder Product List Template Is Missing
Product Color & Size Options in Admin
- Disallow swatches to render multiple times within the same element
---
.../Magento/Swatches/view/base/web/js/swatch-renderer.js | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js
index 250141a942b10..894a4518f4de8 100644
--- a/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js
+++ b/app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js
@@ -296,6 +296,12 @@ define([
* @private
*/
_init: function () {
+ // Don't render the same set of swatches twice
+ if ($(this.element).attr('data-rendered')) {
+ return;
+ }
+ $(this.element).attr('data-rendered', true);
+
if (_.isEmpty(this.options.jsonConfig.images)) {
this.options.useAjax = true;
// creates debounced variant of _LoadProductMedia()
From c8cd10ab771e070af2f481e8313af32de85b0e3b Mon Sep 17 00:00:00 2001
From: Dave Macaulay
Date: Mon, 4 Nov 2019 11:41:05 -0600
Subject: [PATCH 0968/1978] PB-76: PageBuilder Product List Template Is Missing
Product Color & Size Options in Admin
- Include priceBox within base
---
.../Catalog/view/adminhtml/requirejs-config.js | 7 +------
.../Catalog/view/base/requirejs-config.js | 16 ++++++++++++++++
.../Catalog/view/frontend/requirejs-config.js | 5 -----
3 files changed, 17 insertions(+), 11 deletions(-)
create mode 100644 app/code/Magento/Catalog/view/base/requirejs-config.js
diff --git a/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js b/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js
index 2b4efc4016a1b..0677b0a5811c2 100644
--- a/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js
+++ b/app/code/Magento/Catalog/view/adminhtml/requirejs-config.js
@@ -12,12 +12,7 @@ var config = {
productGallery: 'Magento_Catalog/js/product-gallery',
baseImage: 'Magento_Catalog/catalog/base-image-uploader',
productAttributes: 'Magento_Catalog/catalog/product-attributes',
- categoryCheckboxTree: 'Magento_Catalog/js/category-checkbox-tree',
- priceBox: 'Magento_Catalog/js/price-box',
- priceOptionDate: 'Magento_Catalog/js/price-option-date',
- priceOptionFile: 'Magento_Catalog/js/price-option-file',
- priceOptions: 'Magento_Catalog/js/price-options',
- priceUtils: 'Magento_Catalog/js/price-utils'
+ categoryCheckboxTree: 'Magento_Catalog/js/category-checkbox-tree'
}
},
deps: [
diff --git a/app/code/Magento/Catalog/view/base/requirejs-config.js b/app/code/Magento/Catalog/view/base/requirejs-config.js
new file mode 100644
index 0000000000000..2fc0bbcb8c00d
--- /dev/null
+++ b/app/code/Magento/Catalog/view/base/requirejs-config.js
@@ -0,0 +1,16 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+var config = {
+ map: {
+ '*': {
+ priceBox: 'Magento_Catalog/js/price-box',
+ priceOptionDate: 'Magento_Catalog/js/price-option-date',
+ priceOptionFile: 'Magento_Catalog/js/price-option-file',
+ priceOptions: 'Magento_Catalog/js/price-options',
+ priceUtils: 'Magento_Catalog/js/price-utils'
+ }
+ }
+};
diff --git a/app/code/Magento/Catalog/view/frontend/requirejs-config.js b/app/code/Magento/Catalog/view/frontend/requirejs-config.js
index 55df18afeb024..3674d54340544 100644
--- a/app/code/Magento/Catalog/view/frontend/requirejs-config.js
+++ b/app/code/Magento/Catalog/view/frontend/requirejs-config.js
@@ -11,11 +11,6 @@ var config = {
upsellProducts: 'Magento_Catalog/js/upsell-products',
productListToolbarForm: 'Magento_Catalog/js/product/list/toolbar',
catalogGallery: 'Magento_Catalog/js/gallery',
- priceBox: 'Magento_Catalog/js/price-box',
- priceOptionDate: 'Magento_Catalog/js/price-option-date',
- priceOptionFile: 'Magento_Catalog/js/price-option-file',
- priceOptions: 'Magento_Catalog/js/price-options',
- priceUtils: 'Magento_Catalog/js/price-utils',
catalogAddToCart: 'Magento_Catalog/js/catalog-add-to-cart'
}
},
From 3d3465eac47d1de2a090b20fb26cdf17ca1c7344 Mon Sep 17 00:00:00 2001
From: Lena Orobei
Date: Mon, 4 Nov 2019 12:04:23 -0600
Subject: [PATCH 0969/1978] magento/graphql-ce#961:
ShippingAddressInput.postcode: String, is not required by Schema
---
.../GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
index d79ab8895b53c..40131e2d76575 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php
@@ -708,8 +708,8 @@ public function dataProviderSetWithoutRequiredParameters(): array
telephone: "88776655"
}
}',
- 'Region is not available for the selected country'
- ],
+ 'Region is not available for the selected country'
+ ],
];
}
From 8b0437468541634371fb0d192c420343a89b2ec0 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Mon, 4 Nov 2019 20:11:16 +0200
Subject: [PATCH 0970/1978] MC-18165: Quick search with two chars shows all
products
---
.../Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
index 46456692332c1..0e92d9fb0c7ad 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
@@ -20,7 +20,7 @@
-
+
From eb16e9e650fafc82d918374ee72576a78666b339 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Mon, 4 Nov 2019 12:36:01 -0600
Subject: [PATCH 0971/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
.../Controller/Adminhtml/Category/SaveTest.php | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php b/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php
index 787e554a947a1..b505e311b9ed0 100644
--- a/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php
+++ b/dev/tests/integration/testsuite/Magento/Elasticsearch/Controller/Adminhtml/Category/SaveTest.php
@@ -52,6 +52,7 @@ protected function tearDown()
/**
* Checks a case when indexers are invalidated if products for category were changed.
*
+ * @magentoConfigFixture current_store catalog/frontend/flat_catalog_category true
* @magentoDataFixture Magento/Catalog/_files/category_product.php
* @magentoDataFixture Magento/Catalog/_files/multiple_products.php
*/
@@ -77,11 +78,6 @@ public function testExecute()
self::equalTo(['You saved the category.']),
MessageInterface::TYPE_SUCCESS
);
-
- $fulltextIndexer = $this->getIndexer(FulltextIndexer::INDEXER_ID);
- self::assertTrue($fulltextIndexer->isInvalid(), 'Fulltext indexer should be invalidated.');
- $categoryIndexer = $this->getIndexer(CategoryIndexer::INDEXER_ID);
- self::assertTrue($categoryIndexer->isInvalid(), 'Category indexer should be invalidated.');
}
/**
From 5615444ac9cc62eb5363f6c123c0f11982737bf2 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Mon, 4 Nov 2019 20:51:58 +0200
Subject: [PATCH 0972/1978] MC-22760: MFTF tests stabilization -
AdminMoveAnchoredCategoryToDefaultCategoryTest MC-6493
---
.../Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml
index 247711295a555..a8a8ede297b44 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminMoveAnchoredCategoryToDefaultCategoryTest.xml
@@ -69,6 +69,10 @@
+
+
+
+
From df66cf8472b800fc7f6dd58c958631bbb0a26bff Mon Sep 17 00:00:00 2001
From: Alexander Shkurko
Date: Mon, 4 Nov 2019 21:41:21 +0200
Subject: [PATCH 0973/1978] Adjusments according review: add interface
description and minor code changes
---
app/code/Magento/MediaGallery/Model/Keyword.php | 2 +-
.../Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php | 5 ++++-
app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php | 4 ++--
.../Magento/MediaGalleryApi/Api/Data/KeywordInterface.php | 2 +-
.../Model/Asset/Command/DeleteByPathInterface.php | 2 +-
.../MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php | 2 +-
.../Model/Asset/Command/GetByPathInterface.php | 2 +-
.../MediaGalleryApi/Model/Asset/Command/SaveInterface.php | 2 +-
.../Model/Keyword/Command/GetAssetKeywordsInterface.php | 2 +-
.../Model/Keyword/Command/SaveAssetKeywordsInterface.php | 2 +-
10 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/app/code/Magento/MediaGallery/Model/Keyword.php b/app/code/Magento/MediaGallery/Model/Keyword.php
index d5d84038a92d5..c5c60d3152846 100644
--- a/app/code/Magento/MediaGallery/Model/Keyword.php
+++ b/app/code/Magento/MediaGallery/Model/Keyword.php
@@ -38,7 +38,7 @@ public function getId(): ?int
/**
* @inheritdoc
*/
- public function getKeyword() : string
+ public function getKeyword(): string
{
return (string)$this->getData(self::KEYWORD);
}
diff --git a/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php b/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php
index 102286418240b..75d1cd9afd0f2 100644
--- a/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php
+++ b/app/code/Magento/MediaGallery/Plugin/Wysiwyg/Images/Storage.php
@@ -87,7 +87,10 @@ public function afterDeleteFile(StorageSubject $subject, StorageSubject $result,
try {
$this->deleteMediaAssetByPath->execute($relativePath);
} catch (\Exception $exception) {
- $message = __('An error occurred during media asset delete at wysiwyg: %1', $exception->getMessage());
+ $message = __(
+ 'An error occurred during media asset delete at wysiwyg: %error',
+ ['error' => $exception->getMessage()]
+ );
$this->logger->critical($message->render());
}
diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php
index 67789631efc84..affae296ca530 100644
--- a/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Api/Data/AssetInterface.php
@@ -11,8 +11,8 @@
use Magento\Framework\Api\ExtensibleDataInterface;
/**
- * Asset Interface
- *
+ * Represents a media gallery asset which contains information about a media asset entity such
+ * as path to the media storage, media asset title and its content type, etc.
*/
interface AssetInterface extends ExtensibleDataInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php b/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php
index 021a750309eea..ae3b7dbd76291 100644
--- a/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Api/Data/KeywordInterface.php
@@ -11,7 +11,7 @@
use Magento\Framework\Api\ExtensibleDataInterface;
/**
- * Interface KeywordInterface
+ * Represents a media gallery keyword. This object contains information about a media asset keyword entity.
*/
interface KeywordInterface extends ExtensibleDataInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php
index 36915b95cd9e3..b3612a67ed536 100644
--- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/DeleteByPathInterface.php
@@ -9,7 +9,7 @@
namespace Magento\MediaGalleryApi\Model\Asset\Command;
/**
- * Interface DeleteByPathInterface
+ * A command represents the media gallery asset delete action. A media gallery asset is filtered by path value.
*/
interface DeleteByPathInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php
index 2f9c79a0bcc1c..ef2ceb5ffbfe6 100644
--- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByIdInterface.php
@@ -9,7 +9,7 @@
namespace Magento\MediaGalleryApi\Model\Asset\Command;
/**
- * Interface GetByIdInterface
+ * A command represents the get media gallery asset by using media gallery asset id as a filter parameter.
*/
interface GetByIdInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php
index 569d7ace11905..547b0dc695dae 100644
--- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/GetByPathInterface.php
@@ -9,7 +9,7 @@
namespace Magento\MediaGalleryApi\Model\Asset\Command;
/**
- * Interface GetByPathInterface
+ * A command represents the get media gallery asset by using media gallery asset path as a filter parameter.
*/
interface GetByPathInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php
index 685dbba1b132e..b3e3607e6e822 100644
--- a/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Model/Asset/Command/SaveInterface.php
@@ -11,7 +11,7 @@
use Magento\MediaGalleryApi\Api\Data\AssetInterface;
/**
- * Interface SaveInterface
+ * A command which executes the media gallery asset save operation.
*/
interface SaveInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php
index 5befeb7d9bf34..d449df5684c4b 100644
--- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/GetAssetKeywordsInterface.php
@@ -8,7 +8,7 @@
namespace Magento\MediaGalleryApi\Model\Keyword\Command;
/**
- * Interface GetAssetKeywordsInterface
+ * A command represents functionality to get a media gallery asset keywords filtered by media gallery asset id.
*/
interface GetAssetKeywordsInterface
{
diff --git a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php
index e4b8422350d05..9c0d89c3456f8 100644
--- a/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php
+++ b/app/code/Magento/MediaGalleryApi/Model/Keyword/Command/SaveAssetKeywordsInterface.php
@@ -8,7 +8,7 @@
namespace Magento\MediaGalleryApi\Model\Keyword\Command;
/**
- * Interface SaveAssetKeywordsInterface
+ * A command represents the media gallery asset keywords save operation.
*/
interface SaveAssetKeywordsInterface
{
From 4b432f8f0600cda910a4e8752422565ec6838f02 Mon Sep 17 00:00:00 2001
From: torhoehn
Date: Mon, 4 Nov 2019 21:30:28 +0100
Subject: [PATCH 0974/1978] initialize tooltip for order items
---
.../templates/order/items/renderer/default.phtml | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml
index 4042fe52bb5a8..6c51a912b4928 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml
@@ -16,17 +16,19 @@ $_item = $block->getItem();
= $block->escapeHtml($_option['label']) ?>
getPrintStatus()) : ?>
getFormatedOptionValue($_option) ?>
-
+ >
+ = $block->escapeHtml($_formatedOptionValue['value']) ?>
- = $block->escapeHtml($_formatedOptionValue['full_view'], ['a']) ?>
-
- =$block->escapeHtml($_formatedOptionValue['value'], ['a']) ?>
+
+
+ = $block->escapeHtml($_option['label']) ?>
+ = $block->escapeHtml($_formatedOptionValue['full_view']) ?>
+
+
-
- = /* @noEscape */ nl2br($block->escapeHtml($_option['print_value'] ?? $_option['value'])) ?>
-
+ = $block->escapeHtml((isset($_option['print_value']) ? $_option['print_value'] : $_option['value'])) ?>
From 07c55734cac20152f829433f084fec73eb7a1442 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Mon, 4 Nov 2019 14:33:05 -0600
Subject: [PATCH 0975/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index cefe1d400646e..db6786298c575 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1359,15 +1359,16 @@ public function getChildrenData()
//@codeCoverageIgnoreEnd
+ //phpcs:disable Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
/**
* Return Data Object data in array format.
*
* @return array
* @todo refactor with converter for AbstractExtensibleModel
- * phpcs:ignore Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
*/
public function __toArray()
{
+ //phpcs:enable Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
$data = $this->_data;
$hasToArray = function ($model) {
return is_object($model) && method_exists($model, '__toArray') && is_callable([$model, '__toArray']);
From dd0f93cbf7a355fbb69e698e03f975889b7d2e34 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Mon, 4 Nov 2019 14:33:44 -0600
Subject: [PATCH 0976/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 1 -
1 file changed, 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index db6786298c575..15b8c658d2428 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -41,7 +41,6 @@
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @since 100.0.2
- * phpcs:disable Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
*/
class Category extends \Magento\Catalog\Model\AbstractModel implements
\Magento\Framework\DataObject\IdentityInterface,
From 18d540b8d52e5435ed2e097ac0f9990334747f26 Mon Sep 17 00:00:00 2001
From: Prabhu Ram
Date: Mon, 4 Nov 2019 15:01:28 -0600
Subject: [PATCH 0977/1978] MC-22213: Implementation - Merge cart - static
fixes
---
.../Magento/GraphQl/Quote/Customer/MergeCartsTest.php | 6 ------
1 file changed, 6 deletions(-)
diff --git a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
index 5f7c61412c095..7e2c43990b86e 100644
--- a/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
+++ b/dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/MergeCartsTest.php
@@ -127,12 +127,6 @@ public function testGuestCartExpiryAfterMerge()
$query = $this->getCartMergeMutation($guestQuoteMaskedId, $customerQuoteMaskedId);
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
- $cartResponse = $this->graphQlMutation(
- $this->getCartQuery($guestQuoteMaskedId),
- [],
- '',
- $this->getHeaderMap()
- );
}
/**
From 0cd4aeae861db9593da45040f9e46691ea340379 Mon Sep 17 00:00:00 2001
From: torhoehn
Date: Mon, 4 Nov 2019 21:41:30 +0100
Subject: [PATCH 0978/1978] fix static test
---
.../adminhtml/web/js/variations/steps/attributes_values.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js
index 8e057f5cd39dc..16dbf9ec23cd6 100644
--- a/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js
+++ b/app/code/Magento/ConfigurableProduct/view/adminhtml/web/js/variations/steps/attributes_values.js
@@ -106,7 +106,8 @@ define([
errorOption,
allOptions = [];
- newOption.label = $.trim(option.label);
+ newOption.label = $.trim(newOption.label);
+
if (_.isEmpty(newOption.label)) {
return false;
}
From 52e42fb030bd295e95e10d8fc376ad55e2237bfb Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Mon, 4 Nov 2019 15:09:32 -0600
Subject: [PATCH 0979/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
...rifyCategoryProductAndProductCategoryPartialReindexTest.xml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml
index deb6700c56990..5267fd068c86d 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/VerifyCategoryProductAndProductCategoryPartialReindexTest.xml
@@ -114,9 +114,12 @@
+
+
From 62bb10df6560bed90325f0edd3a8797e44ba6db0 Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Mon, 4 Nov 2019 15:12:00 -0600
Subject: [PATCH 0980/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 15b8c658d2428..8b072602b2ace 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1356,9 +1356,6 @@ public function getChildrenData()
return $this->getData(self::KEY_CHILDREN_DATA);
}
- //@codeCoverageIgnoreEnd
-
- //phpcs:disable Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
/**
* Return Data Object data in array format.
*
@@ -1367,7 +1364,6 @@ public function getChildrenData()
*/
public function __toArray()
{
- //phpcs:enable Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
$data = $this->_data;
$hasToArray = function ($model) {
return is_object($model) && method_exists($model, '__toArray') && is_callable([$model, '__toArray']);
@@ -1387,6 +1383,8 @@ public function __toArray()
return $data;
}
+ //@codeCoverageIgnoreEnd
+
/**
* Convert Category model into flat array.
*
From 32d4ccc1c9f4713a3447465ad44c081a8b7b3e72 Mon Sep 17 00:00:00 2001
From: Daniel Renaud
Date: Fri, 1 Nov 2019 08:26:08 -0500
Subject: [PATCH 0981/1978] MC-21570: PAT trend build broken on graphql
- Fix keyword index on elasticsearch 2
---
.../FieldMapper/Product/FieldProvider/StaticField.php | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php
index 0f3020974d08a..348a1c708a78c 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/StaticField.php
@@ -132,11 +132,17 @@ public function getFields(array $context = []): array
if ($attributeAdapter->isTextType()) {
$keywordFieldName = FieldTypeConverterInterface::INTERNAL_DATA_TYPE_KEYWORD;
+ $index = $this->indexTypeConverter->convert(
+ IndexTypeConverterInterface::INTERNAL_NO_ANALYZE_VALUE
+ );
$allAttributes[$fieldName]['fields'][$keywordFieldName] = [
'type' => $this->fieldTypeConverter->convert(
FieldTypeConverterInterface::INTERNAL_DATA_TYPE_KEYWORD
)
];
+ if ($index) {
+ $allAttributes[$fieldName]['fields'][$keywordFieldName]['index'] = $index;
+ }
}
if ($attributeAdapter->isComplexType()) {
From d4cae504fba92e4f0001a665d6b2ef02368d7650 Mon Sep 17 00:00:00 2001
From: torhoehn
Date: Mon, 4 Nov 2019 23:12:04 +0100
Subject: [PATCH 0982/1978] fix functional tests
---
.../templates/order/creditmemo/items/renderer/default.phtml | 2 +-
.../templates/order/invoice/items/renderer/default.phtml | 2 +-
.../view/frontend/templates/order/items/renderer/default.phtml | 2 +-
.../templates/order/shipment/items/renderer/default.phtml | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml
index 9c0bf0182c62e..b2e84691a45cf 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/creditmemo/items/renderer/default.phtml
@@ -17,7 +17,7 @@
getPrintStatus()) : ?>
getFormatedOptionValue($_option) ?>
>
- = $block->escapeHtml($_formatedOptionValue['value']) ?>
+ = $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml
index 1c427e8b6d4e2..0176582f0fcd7 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/invoice/items/renderer/default.phtml
@@ -17,7 +17,7 @@
getPrintStatus()) : ?>
getFormatedOptionValue($_option) ?>
>
- = $block->escapeHtml($_formatedOptionValue['value']) ?>
+ = $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml
index 6c51a912b4928..51e43476238be 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/items/renderer/default.phtml
@@ -17,7 +17,7 @@ $_item = $block->getItem();
getPrintStatus()) : ?>
getFormatedOptionValue($_option) ?>
>
- = $block->escapeHtml($_formatedOptionValue['value']) ?>
+ = $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
diff --git a/app/code/Magento/Sales/view/frontend/templates/order/shipment/items/renderer/default.phtml b/app/code/Magento/Sales/view/frontend/templates/order/shipment/items/renderer/default.phtml
index 57aeffb26f823..26fe74b0fc454 100644
--- a/app/code/Magento/Sales/view/frontend/templates/order/shipment/items/renderer/default.phtml
+++ b/app/code/Magento/Sales/view/frontend/templates/order/shipment/items/renderer/default.phtml
@@ -16,7 +16,7 @@
getPrintStatus()) : ?>
getFormatedOptionValue($_option) ?>
>
- = $block->escapeHtml($_formatedOptionValue['value']) ?>
+ = $block->escapeHtml($_formatedOptionValue['value'], ['a', 'img']) ?>
From bdb12d8881411e51cbda6723c8e34ed6e466e6fd Mon Sep 17 00:00:00 2001
From: Oleksandr Iegorov
Date: Mon, 4 Nov 2019 16:35:51 -0600
Subject: [PATCH 0983/1978] MC-21948: Products index data delete process fires
before indexation instead of right before insert indexed data to index tables
during partial reindex
---
app/code/Magento/Catalog/Model/Category.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/app/code/Magento/Catalog/Model/Category.php b/app/code/Magento/Catalog/Model/Category.php
index 8b072602b2ace..70888052b7e02 100644
--- a/app/code/Magento/Catalog/Model/Category.php
+++ b/app/code/Magento/Catalog/Model/Category.php
@@ -1362,6 +1362,7 @@ public function getChildrenData()
* @return array
* @todo refactor with converter for AbstractExtensibleModel
*/
+ // phpcs:ignore Magento2.FunctionNameRestrictions.MethodDoubleUnderscore
public function __toArray()
{
$data = $this->_data;
From 3a4048d378198e0a7646adf7a0a96162101e7f07 Mon Sep 17 00:00:00 2001
From: Ievgen Shakhsuvarov
Date: Mon, 4 Nov 2019 16:49:10 -0600
Subject: [PATCH 0984/1978] MC-22781: Fix Failing Integration Test
---
.../Catalog/Controller/Adminhtml/Product/Save/LinksTest.php | 1 +
1 file changed, 1 insertion(+)
diff --git a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
index cc8d87ece656a..665d45921d435 100644
--- a/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
+++ b/dev/tests/integration/testsuite/Magento/Catalog/Controller/Adminhtml/Product/Save/LinksTest.php
@@ -79,6 +79,7 @@ private function getPostData(): array
'name' => 'Simple Product',
'sku' => 'simple',
'url_key' => 'simple-product',
+ 'type_id' => \Magento\Catalog\Model\Product\Type::TYPE_SIMPLE
],
'links' => [
'upsell' => [
From cebafdfe08a84fbc517e2a9d16c7c718eaf39599 Mon Sep 17 00:00:00 2001
From: Ievgen Shakhsuvarov
Date: Mon, 4 Nov 2019 17:15:04 -0600
Subject: [PATCH 0985/1978] MC-22687: Fix failing Functional Test
---
.../Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
index 248219951a251..85567374e36e4 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderWithSimpleProductTest.xml
@@ -39,6 +39,12 @@
+
+
+
+
+
+
From 9f31753091210cdf9d76bb1cce51d357ced73da3 Mon Sep 17 00:00:00 2001
From: Ievgen Shakhsuvarov
Date: Mon, 4 Nov 2019 17:27:28 -0600
Subject: [PATCH 0986/1978] MC-22688: Fix failing Functional Test
---
.../Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
index 9c57ecf70ebc0..80697fd57736a 100644
--- a/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Test/AdminCreateOrderAndCheckTheReorderTest.xml
@@ -39,6 +39,12 @@
+
+
+
+
+
+
From c657fb26e7aa600df1eb1b373942c8cd95ea0c2e Mon Sep 17 00:00:00 2001
From: Sergii Ivashchenko
Date: Mon, 4 Nov 2019 23:23:13 +0000
Subject: [PATCH 0987/1978] magento/magento2#25464: Applied code review
suggestions
---
.../Magento/Ui/view/base/web/js/grid/columns/image-preview.js | 2 +-
app/code/Magento/Ui/view/base/web/js/grid/columns/image.js | 2 +-
app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js | 2 +-
app/code/Magento/Ui/view/base/web/templates/grid/masonry.html | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js
index 69b5d61a61cc1..96b262047e62c 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image-preview.js
@@ -5,7 +5,7 @@
define([
'underscore',
'jquery',
- './column'
+ 'Magento_Ui/js/grid/columns/column'
], function (_, $, Column) {
'use strict';
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/image.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/image.js
index cbcdc6e80df34..d2a417db683ca 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/image.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/image.js
@@ -3,7 +3,7 @@
* See COPYING.txt for license details.
*/
define([
- './column'
+ 'Magento_Ui/js/grid/columns/column'
], function (Column) {
'use strict';
diff --git a/app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js b/app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js
index 710021adf29a6..1a823b8db019e 100644
--- a/app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js
+++ b/app/code/Magento/Ui/view/base/web/js/grid/columns/overlay.js
@@ -3,7 +3,7 @@
* See COPYING.txt for license details.
*/
define([
- './column'
+ 'Magento_Ui/js/grid/columns/column'
], function (Column) {
'use strict';
diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html b/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html
index 228b8370e7b33..089ee21bec15c 100644
--- a/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html
+++ b/app/code/Magento/Ui/view/base/web/templates/grid/masonry.html
@@ -12,6 +12,6 @@
-
+
From 0176c4427433ea23456a12c0c1123f0b3a9b3784 Mon Sep 17 00:00:00 2001
From: Alexander Shkurko
Date: Tue, 5 Nov 2019 09:24:52 +0200
Subject: [PATCH 0988/1978] Fix static tests: composer.lock related fixes
---
composer.lock | 235 +++++++++++++++++++++++++++-----------------------
1 file changed, 126 insertions(+), 109 deletions(-)
diff --git a/composer.lock b/composer.lock
index 49177a9159559..8bcfbb73d0a3d 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "2e70a2d627872624e03d089cd7e51618",
+ "content-hash": "21394914b3f105a33f583ba59aeba748",
"packages": [
{
"name": "braintree/braintree_php",
@@ -73,7 +73,6 @@
"File.php"
]
},
- "notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@@ -84,6 +83,10 @@
],
"description": "The stock Zend_Cache_Backend_File backend has extremely poor performance for cleaning by tags making it become unusable as the number of cached items increases. This backend makes many changes resulting in a huge performance boost, especially for tag cleaning.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_File",
+ "support": {
+ "source": "https://github.com/colinmollenhour/Cm_Cache_Backend_File/tree/v1.4.5",
+ "issues": "https://github.com/colinmollenhour/Cm_Cache_Backend_File/issues"
+ },
"time": "2019-04-18T21:54:31+00:00"
},
{
@@ -109,7 +112,6 @@
"Cm/Cache/Backend/Redis.php"
]
},
- "notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
@@ -120,6 +122,10 @@
],
"description": "Zend_Cache backend using Redis with full support for tags.",
"homepage": "https://github.com/colinmollenhour/Cm_Cache_Backend_Redis",
+ "support": {
+ "source": "https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/tree/1.10.6",
+ "issues": "https://github.com/colinmollenhour/Cm_Cache_Backend_Redis/issues"
+ },
"time": "2018-09-24T16:02:07+00:00"
},
{
@@ -257,16 +263,16 @@
},
{
"name": "composer/composer",
- "version": "1.9.0",
+ "version": "1.9.1",
"source": {
"type": "git",
"url": "https://github.com/composer/composer.git",
- "reference": "314aa57fdcfc942065996f59fb73a8b3f74f3fa5"
+ "reference": "bb01f2180df87ce7992b8331a68904f80439dd2f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/composer/composer/zipball/314aa57fdcfc942065996f59fb73a8b3f74f3fa5",
- "reference": "314aa57fdcfc942065996f59fb73a8b3f74f3fa5",
+ "url": "https://api.github.com/repos/composer/composer/zipball/bb01f2180df87ce7992b8331a68904f80439dd2f",
+ "reference": "bb01f2180df87ce7992b8331a68904f80439dd2f",
"shasum": ""
},
"require": {
@@ -333,7 +339,7 @@
"dependency",
"package"
],
- "time": "2019-08-02T18:55:33+00:00"
+ "time": "2019-11-01T16:20:17+00:00"
},
{
"name": "composer/semver",
@@ -997,6 +1003,12 @@
"reference": "8b6c32f53b4944a5d6656e86344cd0f9784709a1",
"shasum": ""
},
+ "archive": {
+ "exclude": [
+ "vendor",
+ "/tests/FullStackTest/"
+ ]
+ },
"require": {
"composer-plugin-api": "^1.0"
},
@@ -1024,15 +1036,10 @@
"MagentoHackathon\\Composer\\Magento": "src/"
}
},
- "notification-url": "https://packagist.org/downloads/",
"license": [
"OSL-3.0"
],
"authors": [
- {
- "name": "Vinai Kopp",
- "email": "vinai@netzarbeiter.com"
- },
{
"name": "Daniel Fahlke aka Flyingmana",
"email": "flyingmana@googlemail.com"
@@ -1052,6 +1059,10 @@
{
"name": "David Fuhr",
"email": "fuhr@flagbit.de"
+ },
+ {
+ "name": "Vinai Kopp",
+ "email": "vinai@netzarbeiter.com"
}
],
"description": "Composer installer for Magento modules",
@@ -1060,6 +1071,9 @@
"composer-installer",
"magento"
],
+ "support": {
+ "source": "https://github.com/magento/magento-composer-installer/tree/0.1.13"
+ },
"time": "2017-12-29T16:45:24+00:00"
},
{
@@ -1703,16 +1717,16 @@
},
{
"name": "psr/log",
- "version": "1.1.1",
+ "version": "1.1.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
- "reference": "bf73deb2b3b896a9d9c75f3f0d88185d2faa27e2"
+ "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/php-fig/log/zipball/bf73deb2b3b896a9d9c75f3f0d88185d2faa27e2",
- "reference": "bf73deb2b3b896a9d9c75f3f0d88185d2faa27e2",
+ "url": "https://api.github.com/repos/php-fig/log/zipball/446d54b4cb6bf489fc9d75f55843658e6f25d801",
+ "reference": "446d54b4cb6bf489fc9d75f55843658e6f25d801",
"shasum": ""
},
"require": {
@@ -1746,7 +1760,7 @@
"psr",
"psr-3"
],
- "time": "2019-10-25T08:06:51+00:00"
+ "time": "2019-11-01T11:05:21+00:00"
},
{
"name": "ralouphie/getallheaders",
@@ -2082,7 +2096,7 @@
},
{
"name": "symfony/css-selector",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
@@ -2135,7 +2149,7 @@
},
{
"name": "symfony/event-dispatcher",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
@@ -2263,7 +2277,7 @@
},
{
"name": "symfony/filesystem",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
@@ -2313,16 +2327,16 @@
},
{
"name": "symfony/finder",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
- "reference": "5e575faa95548d0586f6bedaeabec259714e44d1"
+ "reference": "72a068f77e317ae77c0a0495236ad292cfb5ce6f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/finder/zipball/5e575faa95548d0586f6bedaeabec259714e44d1",
- "reference": "5e575faa95548d0586f6bedaeabec259714e44d1",
+ "url": "https://api.github.com/repos/symfony/finder/zipball/72a068f77e317ae77c0a0495236ad292cfb5ce6f",
+ "reference": "72a068f77e317ae77c0a0495236ad292cfb5ce6f",
"shasum": ""
},
"require": {
@@ -2358,7 +2372,7 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
- "time": "2019-09-16T11:29:48+00:00"
+ "time": "2019-10-30T12:53:54+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -2479,16 +2493,16 @@
},
{
"name": "symfony/process",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
- "reference": "50556892f3cc47d4200bfd1075314139c4c9ff4b"
+ "reference": "3b2e0cb029afbb0395034509291f21191d1a4db0"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/process/zipball/50556892f3cc47d4200bfd1075314139c4c9ff4b",
- "reference": "50556892f3cc47d4200bfd1075314139c4c9ff4b",
+ "url": "https://api.github.com/repos/symfony/process/zipball/3b2e0cb029afbb0395034509291f21191d1a4db0",
+ "reference": "3b2e0cb029afbb0395034509291f21191d1a4db0",
"shasum": ""
},
"require": {
@@ -2524,7 +2538,7 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
- "time": "2019-09-26T21:17:10+00:00"
+ "time": "2019-10-28T17:07:32+00:00"
},
{
"name": "tedivm/jshrink",
@@ -4100,16 +4114,16 @@
},
{
"name": "zendframework/zend-modulemanager",
- "version": "2.8.3",
+ "version": "2.8.4",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-modulemanager.git",
- "reference": "aaba206a955b5f43f29e17d09d19fc342a989b24"
+ "reference": "b2596d24b9a4e36a3cd114d35d3ad0918db9a243"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/aaba206a955b5f43f29e17d09d19fc342a989b24",
- "reference": "aaba206a955b5f43f29e17d09d19fc342a989b24",
+ "url": "https://api.github.com/repos/zendframework/zend-modulemanager/zipball/b2596d24b9a4e36a3cd114d35d3ad0918db9a243",
+ "reference": "b2596d24b9a4e36a3cd114d35d3ad0918db9a243",
"shasum": ""
},
"require": {
@@ -4155,7 +4169,7 @@
"modulemanager",
"zf"
],
- "time": "2019-10-18T20:54:53+00:00"
+ "time": "2019-10-28T13:29:38+00:00"
},
{
"name": "zendframework/zend-mvc",
@@ -4459,16 +4473,16 @@
},
{
"name": "zendframework/zend-session",
- "version": "2.9.0",
+ "version": "2.9.1",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-session.git",
- "reference": "0a0c7ae4d8be608e30ecff714c86164ccca19ca3"
+ "reference": "c289c4d733ec23a389e25c7c451f4d062088511f"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-session/zipball/0a0c7ae4d8be608e30ecff714c86164ccca19ca3",
- "reference": "0a0c7ae4d8be608e30ecff714c86164ccca19ca3",
+ "url": "https://api.github.com/repos/zendframework/zend-session/zipball/c289c4d733ec23a389e25c7c451f4d062088511f",
+ "reference": "c289c4d733ec23a389e25c7c451f4d062088511f",
"shasum": ""
},
"require": {
@@ -4522,7 +4536,7 @@
"session",
"zf"
],
- "time": "2019-09-20T12:50:51+00:00"
+ "time": "2019-10-28T19:40:43+00:00"
},
{
"name": "zendframework/zend-soap",
@@ -4720,16 +4734,16 @@
},
{
"name": "zendframework/zend-validator",
- "version": "2.12.1",
+ "version": "2.12.2",
"source": {
"type": "git",
"url": "https://github.com/zendframework/zend-validator.git",
- "reference": "7b870a7515f3a35afbecc39d63f34a861f40f58b"
+ "reference": "fd24920c2afcf2a70d11f67c3457f8f509453a62"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/7b870a7515f3a35afbecc39d63f34a861f40f58b",
- "reference": "7b870a7515f3a35afbecc39d63f34a861f40f58b",
+ "url": "https://api.github.com/repos/zendframework/zend-validator/zipball/fd24920c2afcf2a70d11f67c3457f8f509453a62",
+ "reference": "fd24920c2afcf2a70d11f67c3457f8f509453a62",
"shasum": ""
},
"require": {
@@ -4789,7 +4803,7 @@
"validator",
"zf"
],
- "time": "2019-10-12T12:17:57+00:00"
+ "time": "2019-10-29T08:33:25+00:00"
},
{
"name": "zendframework/zend-view",
@@ -5723,20 +5737,20 @@
},
{
"name": "consolidation/robo",
- "version": "1.4.10",
+ "version": "1.4.11",
"source": {
"type": "git",
"url": "https://github.com/consolidation/Robo.git",
- "reference": "e5a6ca64cf1324151873672e484aceb21f365681"
+ "reference": "5fa1d901776a628167a325baa9db95d8edf13a80"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/consolidation/Robo/zipball/e5a6ca64cf1324151873672e484aceb21f365681",
- "reference": "e5a6ca64cf1324151873672e484aceb21f365681",
+ "url": "https://api.github.com/repos/consolidation/Robo/zipball/5fa1d901776a628167a325baa9db95d8edf13a80",
+ "reference": "5fa1d901776a628167a325baa9db95d8edf13a80",
"shasum": ""
},
"require": {
- "consolidation/annotated-command": "^2.10.2",
+ "consolidation/annotated-command": "^2.11.0",
"consolidation/config": "^1.2",
"consolidation/log": "~1",
"consolidation/output-formatters": "^3.1.13",
@@ -5766,6 +5780,7 @@
"pear/archive_tar": "^1.4.4",
"php-coveralls/php-coveralls": "^1",
"phpunit/php-code-coverage": "~2|~4",
+ "sebastian/comparator": "^1.2.4",
"squizlabs/php_codesniffer": "^2.8"
},
"suggest": {
@@ -5827,7 +5842,7 @@
}
],
"description": "Modern task runner",
- "time": "2019-07-29T15:40:50+00:00"
+ "time": "2019-10-29T15:50:02+00:00"
},
{
"name": "consolidation/self-update",
@@ -6160,16 +6175,16 @@
},
{
"name": "doctrine/cache",
- "version": "v1.8.0",
+ "version": "v1.8.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/cache.git",
- "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57"
+ "reference": "d4374ae95b36062d02ef310100ed33d78738d76c"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/cache/zipball/d768d58baee9a4862ca783840eca1b9add7a7f57",
- "reference": "d768d58baee9a4862ca783840eca1b9add7a7f57",
+ "url": "https://api.github.com/repos/doctrine/cache/zipball/d4374ae95b36062d02ef310100ed33d78738d76c",
+ "reference": "d4374ae95b36062d02ef310100ed33d78738d76c",
"shasum": ""
},
"require": {
@@ -6204,6 +6219,10 @@
"MIT"
],
"authors": [
+ {
+ "name": "Guilherme Blanco",
+ "email": "guilhermeblanco@gmail.com"
+ },
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
@@ -6212,10 +6231,6 @@
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
- {
- "name": "Guilherme Blanco",
- "email": "guilhermeblanco@gmail.com"
- },
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com"
@@ -6231,7 +6246,7 @@
"cache",
"caching"
],
- "time": "2018-08-21T18:01:43+00:00"
+ "time": "2019-10-28T09:31:32+00:00"
},
{
"name": "doctrine/inflector",
@@ -6358,28 +6373,30 @@
},
{
"name": "doctrine/lexer",
- "version": "1.0.2",
+ "version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/lexer.git",
- "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8"
+ "reference": "e17f069ede36f7534b95adec71910ed1b49c74ea"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/doctrine/lexer/zipball/1febd6c3ef84253d7c815bed85fc622ad207a9f8",
- "reference": "1febd6c3ef84253d7c815bed85fc622ad207a9f8",
+ "url": "https://api.github.com/repos/doctrine/lexer/zipball/e17f069ede36f7534b95adec71910ed1b49c74ea",
+ "reference": "e17f069ede36f7534b95adec71910ed1b49c74ea",
"shasum": ""
},
"require": {
- "php": ">=5.3.2"
+ "php": "^7.2"
},
"require-dev": {
- "phpunit/phpunit": "^4.5"
+ "doctrine/coding-standard": "^6.0",
+ "phpstan/phpstan": "^0.11.8",
+ "phpunit/phpunit": "^8.2"
},
"type": "library",
"extra": {
"branch-alias": {
- "dev-master": "1.0.x-dev"
+ "dev-master": "1.1.x-dev"
}
},
"autoload": {
@@ -6392,14 +6409,14 @@
"MIT"
],
"authors": [
- {
- "name": "Roman Borschel",
- "email": "roman@code-factory.org"
- },
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
+ {
+ "name": "Roman Borschel",
+ "email": "roman@code-factory.org"
+ },
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
@@ -6414,7 +6431,7 @@
"parser",
"php"
],
- "time": "2019-06-08T11:03:04+00:00"
+ "time": "2019-07-30T19:33:28+00:00"
},
{
"name": "facebook/webdriver",
@@ -7279,16 +7296,16 @@
},
{
"name": "mikey179/vfsstream",
- "version": "v1.6.7",
+ "version": "v1.6.8",
"source": {
"type": "git",
"url": "https://github.com/bovigo/vfsStream.git",
- "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb"
+ "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb",
- "reference": "2b544ac3a21bcc4dde5d90c4ae8d06f4319055fb",
+ "url": "https://api.github.com/repos/bovigo/vfsStream/zipball/231c73783ebb7dd9ec77916c10037eff5a2b6efe",
+ "reference": "231c73783ebb7dd9ec77916c10037eff5a2b6efe",
"shasum": ""
},
"require": {
@@ -7321,7 +7338,7 @@
],
"description": "Virtual file system to mock the real file system in unit tests.",
"homepage": "http://vfs.bovigo.org/",
- "time": "2019-08-01T01:38:37+00:00"
+ "time": "2019-10-30T15:31:00+00:00"
},
{
"name": "mustache/mustache",
@@ -9235,16 +9252,16 @@
},
{
"name": "symfony/browser-kit",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/browser-kit.git",
- "reference": "78b7611c45039e8ce81698be319851529bf040b1"
+ "reference": "b14fa08508afd152257d5dcc7adb5f278654d972"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/browser-kit/zipball/78b7611c45039e8ce81698be319851529bf040b1",
- "reference": "78b7611c45039e8ce81698be319851529bf040b1",
+ "url": "https://api.github.com/repos/symfony/browser-kit/zipball/b14fa08508afd152257d5dcc7adb5f278654d972",
+ "reference": "b14fa08508afd152257d5dcc7adb5f278654d972",
"shasum": ""
},
"require": {
@@ -9290,20 +9307,20 @@
],
"description": "Symfony BrowserKit Component",
"homepage": "https://symfony.com",
- "time": "2019-09-10T11:25:17+00:00"
+ "time": "2019-10-28T17:07:32+00:00"
},
{
"name": "symfony/config",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/config.git",
- "reference": "0acb26407a9e1a64a275142f0ae5e36436342720"
+ "reference": "f4ee0ebb91b16ca1ac105aa39f9284f3cac19a15"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/config/zipball/0acb26407a9e1a64a275142f0ae5e36436342720",
- "reference": "0acb26407a9e1a64a275142f0ae5e36436342720",
+ "url": "https://api.github.com/repos/symfony/config/zipball/f4ee0ebb91b16ca1ac105aa39f9284f3cac19a15",
+ "reference": "f4ee0ebb91b16ca1ac105aa39f9284f3cac19a15",
"shasum": ""
},
"require": {
@@ -9354,20 +9371,20 @@
],
"description": "Symfony Config Component",
"homepage": "https://symfony.com",
- "time": "2019-09-19T15:51:53+00:00"
+ "time": "2019-10-30T13:18:51+00:00"
},
{
"name": "symfony/dependency-injection",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/dependency-injection.git",
- "reference": "e1e0762a814b957a1092bff75a550db49724d05b"
+ "reference": "fc036941dfafa037a7485714b62593c7eaf68edd"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/e1e0762a814b957a1092bff75a550db49724d05b",
- "reference": "e1e0762a814b957a1092bff75a550db49724d05b",
+ "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/fc036941dfafa037a7485714b62593c7eaf68edd",
+ "reference": "fc036941dfafa037a7485714b62593c7eaf68edd",
"shasum": ""
},
"require": {
@@ -9427,20 +9444,20 @@
],
"description": "Symfony DependencyInjection Component",
"homepage": "https://symfony.com",
- "time": "2019-10-02T12:58:58+00:00"
+ "time": "2019-10-28T17:07:32+00:00"
},
{
"name": "symfony/dom-crawler",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
- "reference": "e9f7b4d19d69b133bd638eeddcdc757723b4211f"
+ "reference": "4b9efd5708c3a38593e19b6a33e40867f4f89d72"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/e9f7b4d19d69b133bd638eeddcdc757723b4211f",
- "reference": "e9f7b4d19d69b133bd638eeddcdc757723b4211f",
+ "url": "https://api.github.com/repos/symfony/dom-crawler/zipball/4b9efd5708c3a38593e19b6a33e40867f4f89d72",
+ "reference": "4b9efd5708c3a38593e19b6a33e40867f4f89d72",
"shasum": ""
},
"require": {
@@ -9488,7 +9505,7 @@
],
"description": "Symfony DomCrawler Component",
"homepage": "https://symfony.com",
- "time": "2019-09-28T21:25:05+00:00"
+ "time": "2019-10-28T17:07:32+00:00"
},
{
"name": "symfony/http-foundation",
@@ -9547,16 +9564,16 @@
},
{
"name": "symfony/options-resolver",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
- "reference": "81c2e120522a42f623233968244baebd6b36cb6a"
+ "reference": "f46c7fc8e207bd8a2188f54f8738f232533765a4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/options-resolver/zipball/81c2e120522a42f623233968244baebd6b36cb6a",
- "reference": "81c2e120522a42f623233968244baebd6b36cb6a",
+ "url": "https://api.github.com/repos/symfony/options-resolver/zipball/f46c7fc8e207bd8a2188f54f8738f232533765a4",
+ "reference": "f46c7fc8e207bd8a2188f54f8738f232533765a4",
"shasum": ""
},
"require": {
@@ -9597,7 +9614,7 @@
"configuration",
"options"
],
- "time": "2019-08-08T09:29:19+00:00"
+ "time": "2019-10-28T20:59:01+00:00"
},
{
"name": "symfony/polyfill-php54",
@@ -9887,7 +9904,7 @@
},
{
"name": "symfony/stopwatch",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
@@ -9937,16 +9954,16 @@
},
{
"name": "symfony/yaml",
- "version": "v4.3.5",
+ "version": "v4.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
- "reference": "41e16350a2a1c7383c4735aa2f9fce74cf3d1178"
+ "reference": "324cf4b19c345465fad14f3602050519e09e361d"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/symfony/yaml/zipball/41e16350a2a1c7383c4735aa2f9fce74cf3d1178",
- "reference": "41e16350a2a1c7383c4735aa2f9fce74cf3d1178",
+ "url": "https://api.github.com/repos/symfony/yaml/zipball/324cf4b19c345465fad14f3602050519e09e361d",
+ "reference": "324cf4b19c345465fad14f3602050519e09e361d",
"shasum": ""
},
"require": {
@@ -9992,7 +10009,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
- "time": "2019-09-11T15:41:19+00:00"
+ "time": "2019-10-30T12:58:49+00:00"
},
{
"name": "theseer/fdomdocument",
From 3d055a06a1735c4feed2b7df9ecc077a2d8e1d13 Mon Sep 17 00:00:00 2001
From: Myroslav Dobra
Date: Tue, 5 Nov 2019 10:27:13 +0200
Subject: [PATCH 0989/1978] MC-22760: MFTF tests stabilization -
AdminMoveAnchoredCategoryToDefaultCategoryTest MC-6493
---
.../Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml | 3 +++
.../CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml | 5 ++++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
index 2a0aa45292e18..d8fa20c7cc469 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdvanceCatalogSearchSimpleProductTest.xml
@@ -19,10 +19,13 @@
+
+
+
diff --git a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
index 27d54b678f907..3cbe1af58fc14 100644
--- a/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
+++ b/app/code/Magento/CatalogSearch/Test/Mftf/Test/SearchEntityResultsTest.xml
@@ -427,6 +427,8 @@
+
+
@@ -441,10 +443,11 @@
+
-
+
From a271a9277c8d78ad01d6a7c73308328a231f3274 Mon Sep 17 00:00:00 2001
From: "ivan.pletnyov"
Date: Tue, 5 Nov 2019 10:48:38 +0200
Subject: [PATCH 0990/1978] MC-21827: Admin: Create product Attribute
---
.../Product/Attribute/Save/InputType/FixedProductTaxTest.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dev/tests/integration/testsuite/Magento/Weee/Controller/Adminhtml/Product/Attribute/Save/InputType/FixedProductTaxTest.php b/dev/tests/integration/testsuite/Magento/Weee/Controller/Adminhtml/Product/Attribute/Save/InputType/FixedProductTaxTest.php
index 25e6addd4ded6..5a6065d249b51 100644
--- a/dev/tests/integration/testsuite/Magento/Weee/Controller/Adminhtml/Product/Attribute/Save/InputType/FixedProductTaxTest.php
+++ b/dev/tests/integration/testsuite/Magento/Weee/Controller/Adminhtml/Product/Attribute/Save/InputType/FixedProductTaxTest.php
@@ -5,7 +5,7 @@
*/
declare(strict_types=1);
-namespace Magento\Eav\Controller\Adminhtml\Product\Attribute\Save\InputType;
+namespace Magento\Weee\Controller\Adminhtml\Product\Attribute\Save\InputType;
use Magento\Catalog\Controller\Adminhtml\Product\Attribute\Save\InputType\AbstractSaveAttributeTest;
From 7b520c338218d8095d92bd1bb93d243628a09246 Mon Sep 17 00:00:00 2001
From: Nazarn96
Date: Tue, 5 Nov 2019 12:06:31 +0200
Subject: [PATCH 0991/1978] Fix failed static integration tests
---
.../Framework/Config/ConfigOptionsListConstants.php | 2 ++
setup/src/Magento/Setup/Model/ConfigOptionsList.php | 7 ++++---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php
index 294e49e558ff4..775611c63a9f7 100644
--- a/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php
+++ b/lib/internal/Magento/Framework/Config/ConfigOptionsListConstants.php
@@ -152,6 +152,8 @@ class ConfigOptionsListConstants
/**
* Size of random string generated for store's encryption key
+ * phpcs:disable
*/
const STORE_KEY_RANDOM_STRING_SIZE = SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES;
+ //phpcs:enable
}
diff --git a/setup/src/Magento/Setup/Model/ConfigOptionsList.php b/setup/src/Magento/Setup/Model/ConfigOptionsList.php
index 6791f79164a60..7bc0853769217 100644
--- a/setup/src/Magento/Setup/Model/ConfigOptionsList.php
+++ b/setup/src/Magento/Setup/Model/ConfigOptionsList.php
@@ -3,6 +3,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Setup\Model;
@@ -177,7 +178,7 @@ public function getOptions()
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_KEY,
'Full path of client key file in order to establish db connection through SSL',
- null
+ ''
),
new TextConfigOption(
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_CERT,
@@ -185,7 +186,7 @@ public function getOptions()
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_CERT,
'Full path of client certificate file in order to establish db connection through SSL',
- null
+ ''
),
new TextConfigOption(
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_CA,
@@ -193,7 +194,7 @@ public function getOptions()
ConfigOptionsListConstants::CONFIG_PATH_DB_CONNECTION_DEFAULT_DRIVER_OPTIONS .
'/' . ConfigOptionsListConstants::KEY_MYSQL_SSL_CA,
'Full path of server certificate file in order to establish db connection through SSL',
- null
+ ''
),
new FlagConfigOption(
ConfigOptionsListConstants::INPUT_KEY_DB_SSL_VERIFY,
From 91d5327fc321ef7750be552dc2e7eaa5a3296c88 Mon Sep 17 00:00:00 2001
From: Nazarn96
Date: Tue, 5 Nov 2019 12:20:52 +0200
Subject: [PATCH 0992/1978] Remove wrong added comment
---
setup/view/magento/setup/add-database.phtml | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/setup/view/magento/setup/add-database.phtml b/setup/view/magento/setup/add-database.phtml
index 7da90c21d2505..5ba15cf0c1ec8 100644
--- a/setup/view/magento/setup/add-database.phtml
+++ b/setup/view/magento/setup/add-database.phtml
@@ -90,7 +90,8 @@
Create a database for me
-
+ */
+?>