diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMainActionsSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMainActionsSection.xml
index bc576559e7a13..ef2e5f4216889 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMainActionsSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMainActionsSection.xml
@@ -10,6 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
index b1350d5dcc1d7..88e740d689cdd 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminMessagesSection.xml
@@ -12,5 +12,6 @@
+
diff --git a/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml b/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml
index a2645c9cbf96d..a01e025ba3dca 100644
--- a/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml
+++ b/app/code/Magento/Backend/Test/Mftf/Section/AdminSlideOutDialogSection.xml
@@ -1,11 +1,10 @@
-
+ /**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+ -->
diff --git a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php
index fbe0d4b550fa6..2252b3e3d5506 100644
--- a/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php
+++ b/app/code/Magento/Catalog/Model/Indexer/Product/Flat/FlatTableBuilder.php
@@ -10,7 +10,8 @@
use Magento\Framework\EntityManager\MetadataPool;
/**
- * Class FlatTableBuilder
+ * Class for building flat index
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class FlatTableBuilder
@@ -346,12 +347,21 @@ protected function _updateTemporaryTableByStoreValues(
}
//Update not simple attributes (eg. dropdown)
- if (isset($flatColumns[$attributeCode . $valueFieldSuffix])) {
- $select = $this->_connection->select()->joinInner(
- ['t' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
- 't.option_id = et.' . $attributeCode . ' AND t.store_id=' . $storeId,
- [$attributeCode . $valueFieldSuffix => 't.value']
- );
+ $columnName = $attributeCode . $valueFieldSuffix;
+ if (isset($flatColumns[$columnName])) {
+ $columnValue = $this->_connection->getIfNullSql('ts.value', 't0.value');
+ $select = $this->_connection->select();
+ $select->joinLeft(
+ ['t0' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
+ 't0.option_id = et.' . $attributeCode . ' AND t0.store_id = 0',
+ []
+ )->joinLeft(
+ ['ts' => $this->_productIndexerHelper->getTable('eav_attribute_option_value')],
+ 'ts.option_id = et.' . $attributeCode . ' AND ts.store_id = ' . $storeId,
+ []
+ )->columns(
+ [$columnName => $columnValue]
+ )->where($columnValue . ' IS NOT NULL');
if (!empty($changedIds)) {
$select->where($this->_connection->quoteInto('et.entity_id IN (?)', $changedIds));
}
@@ -374,6 +384,8 @@ protected function _getTemporaryTableName($tableName)
}
/**
+ * Get metadata pool
+ *
* @return \Magento\Framework\EntityManager\MetadataPool
*/
private function getMetadataPool()
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml
new file mode 100644
index 0000000000000..90ceb1e4a1f96
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminAssignImageRolesActionGroup.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
index 2b5fbfbe6a79b..28587e6405e49 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductActionGroup.xml
@@ -70,6 +70,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml
index 8d16d35ab0dde..817da18f5f2b7 100644
--- a/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/ActionGroup/AdminProductGridActionGroup.xml
@@ -243,6 +243,7 @@
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
index 23253ad6ad8f8..74492ed416206 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Data/ProductData.xml
@@ -497,4 +497,13 @@
Product With Long Name And Sku - But not too long
Product With Long Name And Sku - But not too long
+
+ Magento3
+ 1.00
+ Upload File
+ Yes
+ magento3.jpg
+ magento3
+ jpg
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml
index eca0cb6f02ea1..89eb1ed678cc9 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/AdminProductImagesSection.xml
@@ -16,6 +16,7 @@
+
@@ -32,4 +33,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml
index 83c3ca5348606..45e0b03e8d995 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Section/StorefrontProductMediaSection.xml
@@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml
index efceff6ffb177..e0e214342ad72 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminFilteringCategoryProductsUsingScopeSelectorTest.xml
@@ -19,19 +19,19 @@
-
-
-
-
+
+
+
+
-
-
-
-
+
+
+
+
-
-
-
+
+
+
@@ -60,9 +60,7 @@
-
-
+
@@ -72,12 +70,10 @@
-
+
-
-
+
@@ -87,15 +83,13 @@
-
+
-
-
+
-
+
@@ -107,7 +101,6 @@
-
@@ -126,17 +119,9 @@
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductImageAssignmentForMultipleStoresTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductImageAssignmentForMultipleStoresTest.xml
new file mode 100644
index 0000000000000..b9a5a31ad2168
--- /dev/null
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/AdminProductImageAssignmentForMultipleStoresTest.xml
@@ -0,0 +1,133 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 100
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml b/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml
index 170da829143a3..7da668df59022 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/CheckTierPricingOfProductsTest.xml
@@ -108,6 +108,10 @@
+
+
+
+
@@ -318,13 +322,17 @@
-
-
-
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptions.xml b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml
similarity index 93%
rename from app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptions.xml
rename to app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml
index 86755cb602ee2..d96399738c80a 100644
--- a/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptions.xml
+++ b/app/code/Magento/Catalog/Test/Mftf/Test/StorefrontPurchaseProductWithCustomOptionsTest.xml
@@ -8,7 +8,7 @@
-
+
@@ -55,6 +55,10 @@
+
+
+
+
@@ -66,10 +70,10 @@
-
+
-
+
@@ -102,8 +106,8 @@
-
-
+
+
@@ -140,8 +144,8 @@
-
-
+
+
@@ -158,8 +162,8 @@
-
-
+
+
@@ -176,8 +180,8 @@
-
-
+
+
diff --git a/app/code/Magento/CatalogImportExport/Model/Export/Product.php b/app/code/Magento/CatalogImportExport/Model/Export/Product.php
index 345d323e6e129..c047e9c9bef21 100644
--- a/app/code/Magento/CatalogImportExport/Model/Export/Product.php
+++ b/app/code/Magento/CatalogImportExport/Model/Export/Product.php
@@ -1158,7 +1158,7 @@ protected function collectMultiselectValues($item, $attrCode, $storeId)
}
/**
- * Check attribute is valid
+ * Check attribute is valid.
*
* @param string $code
* @param mixed $value
@@ -1175,6 +1175,10 @@ protected function isValidAttributeValue($code, $value)
$isValid = false;
}
+ if (is_array($value)) {
+ $isValid = false;
+ }
+
return $isValid;
}
diff --git a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php
index 7aac6e98fc044..7b239d84bf962 100644
--- a/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php
+++ b/app/code/Magento/CatalogSearch/Model/Layer/Filter/Attribute.php
@@ -91,12 +91,10 @@ protected function _getItemsData()
return $this->itemDataBuilder->build();
}
- $productSize = $productCollection->getSize();
-
$options = $attribute->getFrontend()
->getSelectOptions();
foreach ($options as $option) {
- $this->buildOptionData($option, $isAttributeFilterable, $optionsFacetedData, $productSize);
+ $this->buildOptionData($option, $isAttributeFilterable, $optionsFacetedData);
}
return $this->itemDataBuilder->build();
@@ -108,17 +106,16 @@ protected function _getItemsData()
* @param array $option
* @param boolean $isAttributeFilterable
* @param array $optionsFacetedData
- * @param int $productSize
* @return void
*/
- private function buildOptionData($option, $isAttributeFilterable, $optionsFacetedData, $productSize)
+ private function buildOptionData($option, $isAttributeFilterable, $optionsFacetedData)
{
$value = $this->getOptionValue($option);
if ($value === false) {
return;
}
$count = $this->getOptionCount($value, $optionsFacetedData);
- if ($isAttributeFilterable && (!$this->isOptionReducesResults($count, $productSize) || $count === 0)) {
+ if ($isAttributeFilterable && $count === 0) {
return;
}
diff --git a/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php b/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php
index abc0fdd1069fe..69e2c33d02d1a 100644
--- a/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php
+++ b/app/code/Magento/CatalogSearch/Test/Unit/Model/Layer/Filter/AttributeTest.php
@@ -321,10 +321,6 @@ public function testGetItemsWithoutApply()
->method('build')
->will($this->returnValue($builtData));
- $this->fulltextCollection->expects($this->once())
- ->method('getSize')
- ->will($this->returnValue(50));
-
$expectedFilterItems = [
$this->createFilterItem(0, $builtData[0]['label'], $builtData[0]['value'], $builtData[0]['count']),
$this->createFilterItem(1, $builtData[1]['label'], $builtData[1]['value'], $builtData[1]['count']),
@@ -383,9 +379,6 @@ public function testGetItemsOnlyWithResults()
$this->fulltextCollection->expects($this->once())
->method('getFacetedData')
->willReturn($facetedData);
- $this->fulltextCollection->expects($this->once())
- ->method('getSize')
- ->will($this->returnValue(50));
$this->itemDataBuilder->expects($this->once())
->method('addItemData')
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
index 54a4c6fd1b6d8..464ccc1913335 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/CheckoutActionGroup.xml
@@ -114,8 +114,8 @@
-
-
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/FillShippingZipFormActionGroup.xml b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/FillShippingZipFormActionGroup.xml
index 83f6b635bfee7..f12bf4344ab12 100644
--- a/app/code/Magento/Checkout/Test/Mftf/ActionGroup/FillShippingZipFormActionGroup.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/ActionGroup/FillShippingZipFormActionGroup.xml
@@ -13,6 +13,8 @@
+
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml
index 3f717943fe8f0..a894f2fbb1af9 100644
--- a/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml
+++ b/app/code/Magento/Checkout/Test/Mftf/Section/StorefrontMiniCartSection.xml
@@ -29,5 +29,6 @@
+
diff --git a/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutDataPersistTest.xml b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutDataPersistTest.xml
new file mode 100644
index 0000000000000..626f095604fa2
--- /dev/null
+++ b/app/code/Magento/Checkout/Test/Mftf/Test/StorefrontGuestCheckoutDataPersistTest.xml
@@ -0,0 +1,57 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Section/StorefrontCMSPageSection.xml b/app/code/Magento/Cms/Test/Mftf/Section/StorefrontCMSPageSection.xml
index 7a358c61263d6..280c7dfd8263e 100644
--- a/app/code/Magento/Cms/Test/Mftf/Section/StorefrontCMSPageSection.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Section/StorefrontCMSPageSection.xml
@@ -10,7 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
-
+
diff --git a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml
index c7ea85e441bb9..89431a0c7ce4d 100644
--- a/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Section/TinyMCESection.xml
@@ -57,6 +57,7 @@
+
diff --git a/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php b/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php
index d7d513bfad423..86ae1f96749df 100644
--- a/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php
+++ b/app/code/Magento/Config/Console/Command/ConfigSet/DefaultProcessor.php
@@ -7,17 +7,19 @@
use Magento\Config\App\Config\Type\System;
use Magento\Config\Console\Command\ConfigSetCommand;
+use Magento\Config\Model\Config\Factory as ConfigFactory;
use Magento\Framework\App\Config\ConfigPathResolver;
use Magento\Framework\App\DeploymentConfig;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\CouldNotSaveException;
use Magento\Config\Model\PreparedValueFactory;
-use Magento\Framework\App\Config\Value;
/**
* Processes default flow of config:set command.
+ *
* This processor saves the value of configuration into database.
*
- * {@inheritdoc}
+ * @inheritdoc
* @api
* @since 100.2.0
*/
@@ -44,26 +46,36 @@ class DefaultProcessor implements ConfigSetProcessorInterface
*/
private $preparedValueFactory;
+ /**
+ * @var ConfigFactory
+ */
+ private $configFactory;
+
/**
* @param PreparedValueFactory $preparedValueFactory The factory for prepared value
* @param DeploymentConfig $deploymentConfig The deployment configuration reader
* @param ConfigPathResolver $configPathResolver The resolver for configuration paths according to source type
+ * @param ConfigFactory|null $configFactory
*/
public function __construct(
PreparedValueFactory $preparedValueFactory,
DeploymentConfig $deploymentConfig,
- ConfigPathResolver $configPathResolver
+ ConfigPathResolver $configPathResolver,
+ ConfigFactory $configFactory = null
) {
$this->preparedValueFactory = $preparedValueFactory;
$this->deploymentConfig = $deploymentConfig;
$this->configPathResolver = $configPathResolver;
+
+ $this->configFactory = $configFactory ?? ObjectManager::getInstance()->get(ConfigFactory::class);
}
/**
* Processes database flow of config:set command.
+ *
* Requires installed application.
*
- * {@inheritdoc}
+ * @inheritdoc
* @since 100.2.0
*/
public function process($path, $value, $scope, $scopeCode)
@@ -78,12 +90,12 @@ public function process($path, $value, $scope, $scopeCode)
}
try {
- /** @var Value $backendModel */
- $backendModel = $this->preparedValueFactory->create($path, $value, $scope, $scopeCode);
- if ($backendModel instanceof Value) {
- $resourceModel = $backendModel->getResource();
- $resourceModel->save($backendModel);
- }
+ $config = $this->configFactory->create([
+ 'scope' => $scope,
+ 'scope_code' => $scopeCode,
+ ]);
+ $config->setDataByPath($path, $value);
+ $config->save();
} catch (\Exception $exception) {
throw new CouldNotSaveException(__('%1', $exception->getMessage()), $exception);
}
diff --git a/app/code/Magento/Config/Model/Config.php b/app/code/Magento/Config/Model/Config.php
index a9c400c46643d..b1074e92cc949 100644
--- a/app/code/Magento/Config/Model/Config.php
+++ b/app/code/Magento/Config/Model/Config.php
@@ -9,15 +9,32 @@
use Magento\Config\Model\Config\Structure\Element\Group;
use Magento\Config\Model\Config\Structure\Element\Field;
use Magento\Framework\App\ObjectManager;
+use Magento\Framework\App\ScopeInterface;
+use Magento\Framework\App\ScopeResolverPool;
+use Magento\Store\Model\ScopeInterface as StoreScopeInterface;
+use Magento\Store\Model\ScopeTypeNormalizer;
/**
* Backend config model
*
* Used to save configuration
+ *
* @author Magento Core Team
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @api
* @since 100.0.2
+ * @method string getSection()
+ * @method void setSection(string $section)
+ * @method string getWebsite()
+ * @method void setWebsite(string $website)
+ * @method string getStore()
+ * @method void setStore(string $store)
+ * @method string getScope()
+ * @method void setScope(string $scope)
+ * @method int getScopeId()
+ * @method void setScopeId(int $scopeId)
+ * @method string getScopeCode()
+ * @method void setScopeCode(string $scopeCode)
*/
class Config extends \Magento\Framework\DataObject
{
@@ -87,6 +104,16 @@ class Config extends \Magento\Framework\DataObject
*/
private $settingChecker;
+ /**
+ * @var ScopeResolverPool
+ */
+ private $scopeResolverPool;
+
+ /**
+ * @var ScopeTypeNormalizer
+ */
+ private $scopeTypeNormalizer;
+
/**
* @param \Magento\Framework\App\Config\ReinitableConfigInterface $config
* @param \Magento\Framework\Event\ManagerInterface $eventManager
@@ -97,6 +124,9 @@ class Config extends \Magento\Framework\DataObject
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param Config\Reader\Source\Deployed\SettingChecker|null $settingChecker
* @param array $data
+ * @param ScopeResolverPool|null $scopeResolverPool
+ * @param ScopeTypeNormalizer|null $scopeTypeNormalizer
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
\Magento\Framework\App\Config\ReinitableConfigInterface $config,
@@ -107,7 +137,9 @@ public function __construct(
\Magento\Framework\App\Config\ValueFactory $configValueFactory,
\Magento\Store\Model\StoreManagerInterface $storeManager,
SettingChecker $settingChecker = null,
- array $data = []
+ array $data = [],
+ ScopeResolverPool $scopeResolverPool = null,
+ ScopeTypeNormalizer $scopeTypeNormalizer = null
) {
parent::__construct($data);
$this->_eventManager = $eventManager;
@@ -117,7 +149,12 @@ public function __construct(
$this->_configLoader = $configLoader;
$this->_configValueFactory = $configValueFactory;
$this->_storeManager = $storeManager;
- $this->settingChecker = $settingChecker ?: ObjectManager::getInstance()->get(SettingChecker::class);
+ $this->settingChecker = $settingChecker
+ ?? ObjectManager::getInstance()->get(SettingChecker::class);
+ $this->scopeResolverPool = $scopeResolverPool
+ ?? ObjectManager::getInstance()->get(ScopeResolverPool::class);
+ $this->scopeTypeNormalizer = $scopeTypeNormalizer
+ ?? ObjectManager::getInstance()->get(ScopeTypeNormalizer::class);
}
/**
@@ -505,9 +542,8 @@ public function setDataByPath($path, $value)
}
/**
- * Get scope name and scopeId
+ * Set scope data
*
- * @todo refactor to scope resolver
* @return void
*/
private function initScope()
@@ -515,31 +551,66 @@ private function initScope()
if ($this->getSection() === null) {
$this->setSection('');
}
+
+ $scope = $this->retrieveScope();
+ $this->setScope($this->scopeTypeNormalizer->normalize($scope->getScopeType()));
+ $this->setScopeCode($scope->getCode());
+ $this->setScopeId($scope->getId());
+
if ($this->getWebsite() === null) {
- $this->setWebsite('');
+ $this->setWebsite(StoreScopeInterface::SCOPE_WEBSITES === $this->getScope() ? $scope->getId() : '');
}
if ($this->getStore() === null) {
- $this->setStore('');
+ $this->setStore(StoreScopeInterface::SCOPE_STORES === $this->getScope() ? $scope->getId() : '');
}
+ }
- if ($this->getStore()) {
- $scope = 'stores';
- $store = $this->_storeManager->getStore($this->getStore());
- $scopeId = (int)$store->getId();
- $scopeCode = $store->getCode();
- } elseif ($this->getWebsite()) {
- $scope = 'websites';
- $website = $this->_storeManager->getWebsite($this->getWebsite());
- $scopeId = (int)$website->getId();
- $scopeCode = $website->getCode();
+ /**
+ * Retrieve scope from initial data
+ *
+ * @return ScopeInterface
+ */
+ private function retrieveScope(): ScopeInterface
+ {
+ $scopeType = $this->getScope();
+ if (!$scopeType) {
+ switch (true) {
+ case $this->getStore():
+ $scopeType = StoreScopeInterface::SCOPE_STORES;
+ $scopeIdentifier = $this->getStore();
+ break;
+ case $this->getWebsite():
+ $scopeType = StoreScopeInterface::SCOPE_WEBSITES;
+ $scopeIdentifier = $this->getWebsite();
+ break;
+ default:
+ $scopeType = ScopeInterface::SCOPE_DEFAULT;
+ $scopeIdentifier = null;
+ break;
+ }
} else {
- $scope = 'default';
- $scopeId = 0;
- $scopeCode = '';
+ switch (true) {
+ case $this->getScopeId() !== null:
+ $scopeIdentifier = $this->getScopeId();
+ break;
+ case $this->getScopeCode() !== null:
+ $scopeIdentifier = $this->getScopeCode();
+ break;
+ case $this->getStore() !== null:
+ $scopeIdentifier = $this->getStore();
+ break;
+ case $this->getWebsite() !== null:
+ $scopeIdentifier = $this->getWebsite();
+ break;
+ default:
+ $scopeIdentifier = null;
+ break;
+ }
}
- $this->setScope($scope);
- $this->setScopeId($scopeId);
- $this->setScopeCode($scopeCode);
+ $scope = $this->scopeResolverPool->get($scopeType)
+ ->getScope($scopeIdentifier);
+
+ return $scope;
}
/**
diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php
index 4ae66bfd9692b..25303093ace5d 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Currency/AbstractCurrency.php
@@ -14,6 +14,8 @@
namespace Magento\Config\Model\Config\Backend\Currency;
/**
+ * Base currency class
+ *
* @api
* @since 100.0.2
*/
@@ -26,18 +28,19 @@ abstract class AbstractCurrency extends \Magento\Framework\App\Config\Value
*/
protected function _getAllowedCurrencies()
{
- if (!$this->isFormData() || $this->getData('groups/options/fields/allow/inherit')) {
- return explode(
+ $allowValue = $this->getData('groups/options/fields/allow/value');
+ $allowedCurrencies = $allowValue === null || $this->getData('groups/options/fields/allow/inherit')
+ ? explode(
',',
(string)$this->_config->getValue(
\Magento\Directory\Model\Currency::XML_PATH_CURRENCY_ALLOW,
$this->getScope(),
$this->getScopeId()
)
- );
- }
+ )
+ : (array) $allowValue;
- return (array)$this->getData('groups/options/fields/allow/value');
+ return $allowedCurrencies;
}
/**
diff --git a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php
index 984e0fe842687..edb76c067bf35 100644
--- a/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php
+++ b/app/code/Magento/Config/Test/Unit/Console/Command/ConfigSet/DefaultProcessorTest.php
@@ -7,13 +7,14 @@
use Magento\Config\App\Config\Type\System;
use Magento\Config\Console\Command\ConfigSet\DefaultProcessor;
+use Magento\Config\Model\Config;
+use Magento\Config\Model\Config\Factory as ConfigFactory;
use Magento\Framework\App\Config\ConfigPathResolver;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\DeploymentConfig;
use Magento\Store\Model\ScopeInterface;
use Magento\Config\Model\PreparedValueFactory;
use Magento\Framework\App\Config\Value;
-use Magento\Framework\App\Config\ValueInterface;
use Magento\Framework\Model\ResourceModel\Db\AbstractDb;
use PHPUnit_Framework_MockObject_MockObject as Mock;
@@ -55,17 +56,18 @@ class DefaultProcessorTest extends \PHPUnit\Framework\TestCase
*/
private $resourceModelMock;
+ /**
+ * @var ConfigFactory|Mock
+ */
+ private $configFactory;
+
/**
* @inheritdoc
*/
protected function setUp()
{
- $this->deploymentConfigMock = $this->getMockBuilder(DeploymentConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->configPathResolverMock = $this->getMockBuilder(ConfigPathResolver::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->deploymentConfigMock = $this->createMock(DeploymentConfig::class);
+ $this->configPathResolverMock = $this->createMock(ConfigPathResolver::class);
$this->resourceModelMock = $this->getMockBuilder(AbstractDb::class)
->disableOriginalConstructor()
->setMethods(['save'])
@@ -74,14 +76,14 @@ protected function setUp()
->disableOriginalConstructor()
->setMethods(['getResource'])
->getMock();
- $this->preparedValueFactoryMock = $this->getMockBuilder(PreparedValueFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->preparedValueFactoryMock = $this->createMock(PreparedValueFactory::class);
+ $this->configFactory = $this->createMock(ConfigFactory::class);
$this->model = new DefaultProcessor(
$this->preparedValueFactoryMock,
$this->deploymentConfigMock,
- $this->configPathResolverMock
+ $this->configPathResolverMock,
+ $this->configFactory
);
}
@@ -98,15 +100,16 @@ public function testProcess($path, $value, $scope, $scopeCode)
{
$this->configMockForProcessTest($path, $scope, $scopeCode);
- $this->preparedValueFactoryMock->expects($this->once())
+ $config = $this->createMock(Config::class);
+ $this->configFactory->expects($this->once())
->method('create')
- ->willReturn($this->valueMock);
- $this->valueMock->expects($this->once())
- ->method('getResource')
- ->willReturn($this->resourceModelMock);
- $this->resourceModelMock->expects($this->once())
+ ->with(['scope' => $scope, 'scope_code' => $scopeCode])
+ ->willReturn($config);
+ $config->expects($this->once())
+ ->method('setDataByPath')
+ ->with($path, $value);
+ $config->expects($this->once())
->method('save')
- ->with($this->valueMock)
->willReturnSelf();
$this->model->process($path, $value, $scope, $scopeCode);
@@ -124,28 +127,6 @@ public function processDataProvider()
];
}
- public function testProcessWithWrongValueInstance()
- {
- $path = 'test/test/test';
- $scope = ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
- $scopeCode = null;
- $value = 'value';
- $valueInterfaceMock = $this->getMockBuilder(ValueInterface::class)
- ->getMockForAbstractClass();
-
- $this->configMockForProcessTest($path, $scope, $scopeCode);
-
- $this->preparedValueFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($valueInterfaceMock);
- $this->valueMock->expects($this->never())
- ->method('getResource');
- $this->resourceModelMock->expects($this->never())
- ->method('save');
-
- $this->model->process($path, $value, $scope, $scopeCode);
- }
-
/**
* @param string $path
* @param string $scope
@@ -185,6 +166,9 @@ public function testProcessLockedValue()
->method('resolve')
->willReturn('system/default/test/test/test');
+ $this->configFactory->expects($this->never())
+ ->method('create');
+
$this->model->process($path, $value, ScopeConfigInterface::SCOPE_TYPE_DEFAULT, null);
}
}
diff --git a/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php
index d0568f48ded1e..bdcb44b756bb2 100644
--- a/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php
+++ b/app/code/Magento/Config/Test/Unit/Model/ConfigTest.php
@@ -5,6 +5,8 @@
*/
namespace Magento\Config\Test\Unit\Model;
+use PHPUnit\Framework\MockObject\MockObject;
+
/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
@@ -13,130 +15,158 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
/**
* @var \Magento\Config\Model\Config
*/
- protected $_model;
+ private $model;
+
+ /**
+ * @var \Magento\Framework\Event\ManagerInterface|MockObject
+ */
+ private $eventManagerMock;
+
+ /**
+ * @var \Magento\Config\Model\Config\Structure\Reader|MockObject
+ */
+ private $structureReaderMock;
+
+ /**
+ * @var \Magento\Framework\DB\TransactionFactory|MockObject
+ */
+ private $transFactoryMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\App\Config\ReinitableConfigInterface|MockObject
*/
- protected $_eventManagerMock;
+ private $appConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Config\Model\Config\Loader|MockObject
*/
- protected $_structureReaderMock;
+ private $configLoaderMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\App\Config\ValueFactory|MockObject
*/
- protected $_transFactoryMock;
+ private $dataFactoryMock;
/**
- * @var \Magento\Framework\App\Config\ReinitableConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Store\Model\StoreManagerInterface|MockObject
*/
- protected $_appConfigMock;
+ private $storeManager;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Config\Model\Config\Structure|MockObject
*/
- protected $_applicationMock;
+ private $configStructure;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker|MockObject
*/
- protected $_configLoaderMock;
+ private $settingsChecker;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\App\ScopeResolverPool|MockObject
*/
- protected $_dataFactoryMock;
+ private $scopeResolverPool;
/**
- * @var \Magento\Store\Model\StoreManagerInterface
+ * @var \Magento\Framework\App\ScopeResolverInterface|MockObject
*/
- protected $_storeManager;
+ private $scopeResolver;
/**
- * @var \Magento\Config\Model\Config\Structure
+ * @var \Magento\Framework\App\ScopeInterface|MockObject
*/
- protected $_configStructure;
+ private $scope;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Store\Model\ScopeTypeNormalizer|MockObject
*/
- private $_settingsChecker;
+ private $scopeTypeNormalizer;
protected function setUp()
{
- $this->_eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
- $this->_structureReaderMock = $this->createPartialMock(
+ $this->eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
+ $this->structureReaderMock = $this->createPartialMock(
\Magento\Config\Model\Config\Structure\Reader::class,
['getConfiguration']
);
- $this->_configStructure = $this->createMock(\Magento\Config\Model\Config\Structure::class);
+ $this->configStructure = $this->createMock(\Magento\Config\Model\Config\Structure::class);
- $this->_structureReaderMock->expects(
+ $this->structureReaderMock->expects(
$this->any()
)->method(
'getConfiguration'
)->will(
- $this->returnValue($this->_configStructure)
+ $this->returnValue($this->configStructure)
);
- $this->_transFactoryMock = $this->createPartialMock(
+ $this->transFactoryMock = $this->createPartialMock(
\Magento\Framework\DB\TransactionFactory::class,
['create', 'addObject']
);
- $this->_appConfigMock = $this->createMock(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
- $this->_configLoaderMock = $this->createPartialMock(
+ $this->appConfigMock = $this->createMock(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
+ $this->configLoaderMock = $this->createPartialMock(
\Magento\Config\Model\Config\Loader::class,
['getConfigByPath']
);
- $this->_dataFactoryMock = $this->createMock(\Magento\Framework\App\Config\ValueFactory::class);
+ $this->dataFactoryMock = $this->createMock(\Magento\Framework\App\Config\ValueFactory::class);
- $this->_storeManager = $this->getMockForAbstractClass(\Magento\Store\Model\StoreManagerInterface::class);
+ $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->_settingsChecker = $this
+ $this->settingsChecker = $this
->createMock(\Magento\Config\Model\Config\Reader\Source\Deployed\SettingChecker::class);
- $this->_model = new \Magento\Config\Model\Config(
- $this->_appConfigMock,
- $this->_eventManagerMock,
- $this->_configStructure,
- $this->_transFactoryMock,
- $this->_configLoaderMock,
- $this->_dataFactoryMock,
- $this->_storeManager,
- $this->_settingsChecker
+ $this->scopeResolverPool = $this->createMock(\Magento\Framework\App\ScopeResolverPool::class);
+ $this->scopeResolver = $this->createMock(\Magento\Framework\App\ScopeResolverInterface::class);
+ $this->scopeResolverPool->method('get')
+ ->willReturn($this->scopeResolver);
+ $this->scope = $this->createMock(\Magento\Framework\App\ScopeInterface::class);
+ $this->scopeResolver->method('getScope')
+ ->willReturn($this->scope);
+
+ $this->scopeTypeNormalizer = $this->createMock(\Magento\Store\Model\ScopeTypeNormalizer::class);
+
+ $this->model = new \Magento\Config\Model\Config(
+ $this->appConfigMock,
+ $this->eventManagerMock,
+ $this->configStructure,
+ $this->transFactoryMock,
+ $this->configLoaderMock,
+ $this->dataFactoryMock,
+ $this->storeManager,
+ $this->settingsChecker,
+ [],
+ $this->scopeResolverPool,
+ $this->scopeTypeNormalizer
);
}
public function testSaveDoesNotDoAnythingIfGroupsAreNotPassed()
{
- $this->_configLoaderMock->expects($this->never())->method('getConfigByPath');
- $this->_model->save();
+ $this->configLoaderMock->expects($this->never())->method('getConfigByPath');
+ $this->model->save();
}
public function testSaveEmptiesNonSetArguments()
{
- $this->_structureReaderMock->expects($this->never())->method('getConfiguration');
- $this->assertNull($this->_model->getSection());
- $this->assertNull($this->_model->getWebsite());
- $this->assertNull($this->_model->getStore());
- $this->_model->save();
- $this->assertSame('', $this->_model->getSection());
- $this->assertSame('', $this->_model->getWebsite());
- $this->assertSame('', $this->_model->getStore());
+ $this->structureReaderMock->expects($this->never())->method('getConfiguration');
+ $this->assertNull($this->model->getSection());
+ $this->assertNull($this->model->getWebsite());
+ $this->assertNull($this->model->getStore());
+ $this->model->save();
+ $this->assertSame('', $this->model->getSection());
+ $this->assertSame('', $this->model->getWebsite());
+ $this->assertSame('', $this->model->getStore());
}
public function testSaveToCheckAdminSystemConfigChangedSectionEvent()
{
$transactionMock = $this->createMock(\Magento\Framework\DB\Transaction::class);
- $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
+ $this->transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
- $this->_configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue([]));
+ $this->configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue([]));
- $this->_eventManagerMock->expects(
+ $this->eventManagerMock->expects(
$this->at(0)
)->method(
'dispatch'
@@ -145,7 +175,7 @@ public function testSaveToCheckAdminSystemConfigChangedSectionEvent()
$this->arrayHasKey('website')
);
- $this->_eventManagerMock->expects(
+ $this->eventManagerMock->expects(
$this->at(0)
)->method(
'dispatch'
@@ -154,20 +184,20 @@ public function testSaveToCheckAdminSystemConfigChangedSectionEvent()
$this->arrayHasKey('store')
);
- $this->_model->setGroups(['1' => ['data']]);
- $this->_model->save();
+ $this->model->setGroups(['1' => ['data']]);
+ $this->model->save();
}
public function testDoNotSaveReadOnlyFields()
{
$transactionMock = $this->createMock(\Magento\Framework\DB\Transaction::class);
- $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
+ $this->transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
- $this->_settingsChecker->expects($this->any())->method('isReadOnly')->will($this->returnValue(true));
- $this->_configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue([]));
+ $this->settingsChecker->expects($this->any())->method('isReadOnly')->will($this->returnValue(true));
+ $this->configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue([]));
- $this->_model->setGroups(['1' => ['fields' => ['key' => ['data']]]]);
- $this->_model->setSection('section');
+ $this->model->setGroups(['1' => ['fields' => ['key' => ['data']]]]);
+ $this->model->setSection('section');
$group = $this->createMock(\Magento\Config\Model\Config\Structure\Element\Group::class);
$group->method('getPath')->willReturn('section/1');
@@ -176,15 +206,15 @@ public function testDoNotSaveReadOnlyFields()
$field->method('getGroupPath')->willReturn('section/1');
$field->method('getId')->willReturn('key');
- $this->_configStructure->expects($this->at(0))
+ $this->configStructure->expects($this->at(0))
->method('getElement')
->with('section/1')
->will($this->returnValue($group));
- $this->_configStructure->expects($this->at(1))
+ $this->configStructure->expects($this->at(1))
->method('getElement')
->with('section/1')
->will($this->returnValue($group));
- $this->_configStructure->expects($this->at(2))
+ $this->configStructure->expects($this->at(2))
->method('getElement')
->with('section/1/key')
->will($this->returnValue($field));
@@ -193,28 +223,28 @@ public function testDoNotSaveReadOnlyFields()
\Magento\Framework\App\Config\Value::class,
['addData']
);
- $this->_dataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($backendModel));
+ $this->dataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($backendModel));
- $this->_transFactoryMock->expects($this->never())->method('addObject');
+ $this->transFactoryMock->expects($this->never())->method('addObject');
$backendModel->expects($this->never())->method('addData');
- $this->_model->save();
+ $this->model->save();
}
public function testSaveToCheckScopeDataSet()
{
$transactionMock = $this->createMock(\Magento\Framework\DB\Transaction::class);
- $this->_transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
+ $this->transFactoryMock->expects($this->any())->method('create')->will($this->returnValue($transactionMock));
- $this->_configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue([]));
+ $this->configLoaderMock->expects($this->any())->method('getConfigByPath')->will($this->returnValue([]));
- $this->_eventManagerMock->expects($this->at(0))
+ $this->eventManagerMock->expects($this->at(0))
->method('dispatch')
->with(
$this->equalTo('admin_system_config_changed_section_section'),
$this->arrayHasKey('website')
);
- $this->_eventManagerMock->expects($this->at(0))
+ $this->eventManagerMock->expects($this->at(0))
->method('dispatch')
->with(
$this->equalTo('admin_system_config_changed_section_section'),
@@ -228,36 +258,51 @@ public function testSaveToCheckScopeDataSet()
$field->method('getGroupPath')->willReturn('section/1');
$field->method('getId')->willReturn('key');
- $this->_configStructure->expects($this->at(0))
+ $this->configStructure->expects($this->at(0))
->method('getElement')
->with('section/1')
->will($this->returnValue($group));
- $this->_configStructure->expects($this->at(1))
+ $this->configStructure->expects($this->at(1))
->method('getElement')
->with('section/1')
->will($this->returnValue($group));
- $this->_configStructure->expects($this->at(2))
+ $this->configStructure->expects($this->at(2))
->method('getElement')
->with('section/1/key')
->will($this->returnValue($field));
- $this->_configStructure->expects($this->at(3))
+ $this->configStructure->expects($this->at(3))
->method('getElement')
->with('section/1')
->will($this->returnValue($group));
- $this->_configStructure->expects($this->at(4))
+ $this->configStructure->expects($this->at(4))
->method('getElement')
->with('section/1/key')
->will($this->returnValue($field));
+ $this->scopeResolver->expects($this->atLeastOnce())
+ ->method('getScope')
+ ->with('1')
+ ->willReturn($this->scope);
+ $this->scope->expects($this->atLeastOnce())
+ ->method('getScopeType')
+ ->willReturn('website');
+ $this->scope->expects($this->atLeastOnce())
+ ->method('getId')
+ ->willReturn(1);
+ $this->scope->expects($this->atLeastOnce())
+ ->method('getCode')
+ ->willReturn('website_code');
+ $this->scopeTypeNormalizer->expects($this->atLeastOnce())
+ ->method('normalize')
+ ->with('website')
+ ->willReturn('websites');
$website = $this->createMock(\Magento\Store\Model\Website::class);
- $website->expects($this->any())->method('getCode')->will($this->returnValue('website_code'));
- $this->_storeManager->expects($this->any())->method('getWebsite')->will($this->returnValue($website));
- $this->_storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue([$website]));
- $this->_storeManager->expects($this->any())->method('isSingleStoreMode')->will($this->returnValue(true));
+ $this->storeManager->expects($this->any())->method('getWebsites')->will($this->returnValue([$website]));
+ $this->storeManager->expects($this->any())->method('isSingleStoreMode')->will($this->returnValue(true));
- $this->_model->setWebsite('website');
- $this->_model->setSection('section');
- $this->_model->setGroups(['1' => ['fields' => ['key' => ['data']]]]);
+ $this->model->setWebsite('1');
+ $this->model->setSection('section');
+ $this->model->setGroups(['1' => ['fields' => ['key' => ['data']]]]);
$backendModel = $this->createPartialMock(
\Magento\Framework\App\Config\Value::class,
@@ -270,7 +315,7 @@ public function testSaveToCheckScopeDataSet()
'groups' => [1 => ['fields' => ['key' => ['data']]]],
'group_id' => null,
'scope' => 'websites',
- 'scope_id' => 0,
+ 'scope_id' => 1,
'scope_code' => 'website_code',
'field_config' => null,
'fieldset_data' => ['key' => null],
@@ -280,16 +325,16 @@ public function testSaveToCheckScopeDataSet()
->with('section/1/key')
->will($this->returnValue($backendModel));
- $this->_dataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($backendModel));
+ $this->dataFactoryMock->expects($this->any())->method('create')->will($this->returnValue($backendModel));
- $this->_model->save();
+ $this->model->save();
}
public function testSetDataByPath()
{
$value = 'value';
$path = '//';
- $this->_model->setDataByPath($path, $value);
+ $this->model->setDataByPath($path, $value);
$expected = [
'section' => '',
'groups' => [
@@ -300,7 +345,7 @@ public function testSetDataByPath()
],
],
];
- $this->assertSame($expected, $this->_model->getData());
+ $this->assertSame($expected, $this->model->getData());
}
/**
@@ -309,7 +354,7 @@ public function testSetDataByPath()
*/
public function testSetDataByPathEmpty()
{
- $this->_model->setDataByPath('', 'value');
+ $this->model->setDataByPath('', 'value');
}
/**
@@ -324,7 +369,7 @@ public function testSetDataByPathWrongDepth($path, $expectedException)
$this->expectException('\UnexpectedValueException');
$this->expectExceptionMessage($expectedException);
$value = 'value';
- $this->_model->setDataByPath($path, $value);
+ $this->model->setDataByPath($path, $value);
}
/**
diff --git a/app/code/Magento/ConfigurableProduct/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php b/app/code/Magento/ConfigurableProduct/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php
index df8782ae422b4..c828c0929b40c 100644
--- a/app/code/Magento/ConfigurableProduct/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php
+++ b/app/code/Magento/ConfigurableProduct/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolver.php
@@ -5,7 +5,7 @@
*/
namespace Magento\ConfigurableProduct\Plugin\Catalog\Model\Product\Pricing\Renderer;
-use Magento\ConfigurableProduct\Pricing\Price\LowestPriceOptionsProviderInterface;
+use Magento\ConfigurableProduct\Model\Product\Type\Configurable as TypeConfigurable;
/**
* A plugin for a salable resolver.
@@ -13,17 +13,16 @@
class SalableResolver
{
/**
- * @var LowestPriceOptionsProviderInterface
+ * @var TypeConfigurable
*/
- private $lowestPriceOptionsProvider;
+ private $typeConfigurable;
/**
- * @param LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
+ * @param TypeConfigurable $typeConfigurable
*/
- public function __construct(
- LowestPriceOptionsProviderInterface $lowestPriceOptionsProvider
- ) {
- $this->lowestPriceOptionsProvider = $lowestPriceOptionsProvider;
+ public function __construct(TypeConfigurable $typeConfigurable)
+ {
+ $this->typeConfigurable = $typeConfigurable;
}
/**
@@ -32,9 +31,7 @@ public function __construct(
* @param \Magento\Catalog\Model\Product\Pricing\Renderer\SalableResolver $subject
* @param bool $result
* @param \Magento\Framework\Pricing\SaleableInterface $salableItem
- *
* @return bool
- *
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function afterIsSalable(
@@ -42,8 +39,8 @@ public function afterIsSalable(
$result,
\Magento\Framework\Pricing\SaleableInterface $salableItem
) {
- if ($salableItem->getTypeId() == 'configurable' && $result) {
- $result = $salableItem->isSalable();
+ if ($salableItem->getTypeId() === TypeConfigurable::TYPE_CODE && $result) {
+ $result = $this->typeConfigurable->isSalable($salableItem);
}
return $result;
diff --git a/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php
new file mode 100644
index 0000000000000..7ec2ce370ac5d
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/Test/Unit/Plugin/Catalog/Model/Product/Pricing/Renderer/SalableResolverTest.php
@@ -0,0 +1,82 @@
+typeConfigurable = $this->createMock(TypeConfigurable::class);
+ $this->salableResolver = new SalableResolverPlugin($this->typeConfigurable);
+ }
+
+ /**
+ * @param SaleableInterface|MockObject $salableItem
+ * @param bool $isSalable
+ * @param bool $typeIsSalable
+ * @param bool $expectedResult
+ * @return void
+ * @dataProvider afterIsSalableDataProvider
+ */
+ public function testAfterIsSalable($salableItem, bool $isSalable, bool $typeIsSalable, bool $expectedResult): void
+ {
+ $salableResolver = $this->createMock(SalableResolver::class);
+
+ $this->typeConfigurable->method('isSalable')
+ ->willReturn($typeIsSalable);
+
+ $result = $this->salableResolver->afterIsSalable($salableResolver, $isSalable, $salableItem);
+ $this->assertEquals($expectedResult, $result);
+ }
+
+ /**
+ * @return array
+ */
+ public function afterIsSalableDataProvider(): array
+ {
+ $simpleSalableItem = $this->createMock(SaleableInterface::class);
+ $simpleSalableItem->expects($this->once())
+ ->method('getTypeId')
+ ->willReturn('simple');
+
+ $configurableSalableItem = $this->createMock(SaleableInterface::class);
+ $configurableSalableItem->expects($this->once())
+ ->method('getTypeId')
+ ->willReturn('configurable');
+
+ return [
+ [
+ $simpleSalableItem,
+ true,
+ false,
+ true,
+ ],
+ [
+ $configurableSalableItem,
+ true,
+ false,
+ false,
+ ],
+ ];
+ }
+}
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml
index 914cebe99ac5f..af918e8208566 100755
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/OpenEditCustomerFromAdminActionGroup.xml
@@ -39,10 +39,9 @@
-
+
-
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml
index 227085fce9de4..76acf6e865963 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/SignUpNewUserFromStorefrontActionGroup.xml
@@ -9,10 +9,9 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
+
-
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml
new file mode 100644
index 0000000000000..fc5c1b881752e
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerLogoutSuccessPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerLogoutSuccessPage.xml
new file mode 100644
index 0000000000000..9c1fc7aa8a88d
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerLogoutSuccessPage.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml
index a0c83f5bc491b..1955c6a417ba9 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontPanelHeaderSection.xml
@@ -12,5 +12,8 @@
+
+
+
diff --git a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js
index 39e3f8d95ee3b..66d37cb84e9cb 100644
--- a/app/code/Magento/Customer/view/frontend/web/js/customer-data.js
+++ b/app/code/Magento/Customer/view/frontend/web/js/customer-data.js
@@ -216,6 +216,9 @@ define([
$.cookieStorage.set(privateContentVersion, privateContent);
}
$.localStorage.set(privateContentVersion, privateContent);
+ _.each(dataProvider.getFromStorage(storage.keys()), function (sectionData, sectionName) {
+ buffer.notify(sectionName, sectionData);
+ });
this.reload([], false);
isLoading = true;
} else if (expiredSectionNames.length > 0) {
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Page/AdminImportIndexPage.xml b/app/code/Magento/ImportExport/Test/Mftf/Page/AdminImportIndexPage.xml
new file mode 100644
index 0000000000000..87807eb9b0e85
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Page/AdminImportIndexPage.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml
new file mode 100644
index 0000000000000..748580be09406
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportHeaderSection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportMainSection.xml b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportMainSection.xml
new file mode 100644
index 0000000000000..2ce6b1e35777f
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Section/AdminImportMainSection.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
new file mode 100644
index 0000000000000..4cbb0603d9073
--- /dev/null
+++ b/app/code/Magento/ImportExport/Test/Mftf/Test/AdminImportProductsWithDeleteBehaviorTest.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Simple Product for Test
+ Simple Product for Test
+
+
+
+ Virtual Product for Test
+ Virtual Product for Test
+
+
+
+ Api Downloadable Product for Test
+ Api Downloadable Product for Test
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/VerifySubscribedNewsletterDisplayedActionGroup.xml b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/VerifySubscribedNewsletterDisplayedActionGroup.xml
index 92d17e9d71e2f..059f157c407c9 100644
--- a/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/VerifySubscribedNewsletterDisplayedActionGroup.xml
+++ b/app/code/Magento/Newsletter/Test/Mftf/ActionGroup/VerifySubscribedNewsletterDisplayedActionGroup.xml
@@ -6,13 +6,10 @@
*/
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
-
-
-
@@ -28,4 +25,9 @@
+
+
+
+
+
diff --git a/app/code/Magento/Newsletter/Test/Mftf/Page/StorefrontNewsletterManagePage.xml b/app/code/Magento/Newsletter/Test/Mftf/Page/StorefrontNewsletterManagePage.xml
new file mode 100644
index 0000000000000..81fd3eb7c391c
--- /dev/null
+++ b/app/code/Magento/Newsletter/Test/Mftf/Page/StorefrontNewsletterManagePage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Newsletter/Test/Mftf/Section/StorefrontNewsletterManageSection.xml b/app/code/Magento/Newsletter/Test/Mftf/Section/StorefrontNewsletterManageSection.xml
new file mode 100644
index 0000000000000..96a944a4952ac
--- /dev/null
+++ b/app/code/Magento/Newsletter/Test/Mftf/Section/StorefrontNewsletterManageSection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Paypal/Model/Config/Structure/Element/FieldPlugin.php b/app/code/Magento/Paypal/Model/Config/Structure/Element/FieldPlugin.php
index c2056aea08c00..5d5db0128b1eb 100644
--- a/app/code/Magento/Paypal/Model/Config/Structure/Element/FieldPlugin.php
+++ b/app/code/Magento/Paypal/Model/Config/Structure/Element/FieldPlugin.php
@@ -5,7 +5,6 @@
*/
namespace Magento\Paypal\Model\Config\Structure\Element;
-use Magento\Framework\App\RequestInterface;
use Magento\Config\Model\Config\Structure\Element\Field as FieldConfigStructure;
use Magento\Paypal\Model\Config\StructurePlugin as ConfigStructurePlugin;
@@ -14,19 +13,6 @@
*/
class FieldPlugin
{
- /**
- * @var RequestInterface
- */
- private $request;
-
- /**
- * @param RequestInterface $request
- */
- public function __construct(RequestInterface $request)
- {
- $this->request = $request;
- }
-
/**
* Get original configPath (not changed by PayPal configuration inheritance)
*
@@ -36,7 +22,7 @@ public function __construct(RequestInterface $request)
*/
public function afterGetConfigPath(FieldConfigStructure $subject, $result)
{
- if (!$result && $this->request->getParam('section') == 'payment') {
+ if (!$result && strpos($subject->getPath(), 'payment_') === 0) {
$result = preg_replace(
'@^(' . implode('|', ConfigStructurePlugin::getPaypalConfigCountries(true)) . ')/@',
'payment/',
diff --git a/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php b/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php
index 8615b91383aaa..f0dda20b71c76 100644
--- a/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php
+++ b/app/code/Magento/Paypal/Test/Unit/Model/Config/Structure/Element/FieldPluginTest.php
@@ -7,7 +7,6 @@
use Magento\Paypal\Model\Config\Structure\Element\FieldPlugin as FieldConfigStructurePlugin;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
-use Magento\Framework\App\RequestInterface;
use Magento\Config\Model\Config\Structure\Element\Field as FieldConfigStructureMock;
class FieldPluginTest extends \PHPUnit\Framework\TestCase
@@ -22,11 +21,6 @@ class FieldPluginTest extends \PHPUnit\Framework\TestCase
*/
private $objectManagerHelper;
- /**
- * @var RequestInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- private $requestMock;
-
/**
* @var FieldConfigStructureMock|\PHPUnit_Framework_MockObject_MockObject
*/
@@ -34,16 +28,13 @@ class FieldPluginTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
- $this->requestMock = $this->getMockBuilder(RequestInterface::class)
- ->getMockForAbstractClass();
$this->subjectMock = $this->getMockBuilder(FieldConfigStructureMock::class)
->disableOriginalConstructor()
->getMock();
$this->objectManagerHelper = new ObjectManagerHelper($this);
$this->plugin = $this->objectManagerHelper->getObject(
- FieldConfigStructurePlugin::class,
- ['request' => $this->requestMock]
+ FieldConfigStructurePlugin::class
);
}
@@ -56,10 +47,9 @@ public function testAroundGetConfigPathHasResult()
public function testAroundGetConfigPathNonPaymentSection()
{
- $this->requestMock->expects(static::once())
- ->method('getParam')
- ->with('section')
- ->willReturn('non-payment');
+ $this->subjectMock->expects($this->once())
+ ->method('getPath')
+ ->willReturn('non-payment/group/field');
$this->assertNull($this->plugin->afterGetConfigPath($this->subjectMock, null));
}
@@ -72,11 +62,7 @@ public function testAroundGetConfigPathNonPaymentSection()
*/
public function testAroundGetConfigPath($subjectPath, $expectedConfigPath)
{
- $this->requestMock->expects(static::once())
- ->method('getParam')
- ->with('section')
- ->willReturn('payment');
- $this->subjectMock->expects(static::once())
+ $this->subjectMock->expects($this->exactly(2))
->method('getPath')
->willReturn($subjectPath);
diff --git a/app/code/Magento/Persistent/Block/Header/Additional.php b/app/code/Magento/Persistent/Block/Header/Additional.php
index c740f5a3469fb..dfde2adf1e6ab 100644
--- a/app/code/Magento/Persistent/Block/Header/Additional.php
+++ b/app/code/Magento/Persistent/Block/Header/Additional.php
@@ -5,6 +5,10 @@
*/
namespace Magento\Persistent\Block\Header;
+use Magento\Framework\App\ObjectManager;
+use Magento\Framework\Serialize\Serializer\Json;
+use Magento\Persistent\Helper\Data;
+
/**
* Remember Me block
*
@@ -30,20 +34,37 @@ class Additional extends \Magento\Framework\View\Element\Html\Link
protected $customerRepository;
/**
- * Constructor
- *
+ * @var string
+ */
+ protected $_template = 'Magento_Persistent::additional.phtml';
+
+ /**
+ * @var Json
+ */
+ private $jsonSerializer;
+
+ /**
+ * @var Data
+ */
+ private $persistentHelper;
+
+ /**
* @param \Magento\Framework\View\Element\Template\Context $context
* @param \Magento\Customer\Helper\View $customerViewHelper
* @param \Magento\Persistent\Helper\Session $persistentSessionHelper
* @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository
* @param array $data
+ * @param Json|null $jsonSerializer
+ * @param Data|null $persistentHelper
*/
public function __construct(
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Helper\View $customerViewHelper,
\Magento\Persistent\Helper\Session $persistentSessionHelper,
\Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
- array $data = []
+ array $data = [],
+ Json $jsonSerializer = null,
+ Data $persistentHelper = null
) {
$this->isScopePrivate = true;
$this->_customerViewHelper = $customerViewHelper;
@@ -51,6 +72,8 @@ public function __construct(
$this->customerRepository = $customerRepository;
parent::__construct($context, $data);
$this->_isScopePrivate = true;
+ $this->jsonSerializer = $jsonSerializer ?: ObjectManager::getInstance()->get(Json::class);
+ $this->persistentHelper = $persistentHelper ?: ObjectManager::getInstance()->get(Data::class);
}
/**
@@ -64,17 +87,26 @@ public function getHref()
}
/**
- * Render additional header html
+ * Get customer id.
*
- * @return string
+ * @return int
*/
- protected function _toHtml()
+ public function getCustomerId(): int
{
- if ($this->_persistentSessionHelper->getSession()->getCustomerId()) {
- return 'getLinkAttributes() . ' >' . __('Not you?')
- . '';
- }
+ return $this->_persistentSessionHelper->getSession()->getCustomerId();
+ }
- return '';
+ /**
+ * Get persistent config.
+ *
+ * @return string
+ */
+ public function getConfig(): string
+ {
+ return $this->jsonSerializer->serialize(
+ [
+ 'expirationLifetime' => $this->persistentHelper->getLifeTime(),
+ ]
+ );
}
}
diff --git a/app/code/Magento/Persistent/CustomerData/Persistent.php b/app/code/Magento/Persistent/CustomerData/Persistent.php
new file mode 100644
index 0000000000000..5800e4e7aeeb5
--- /dev/null
+++ b/app/code/Magento/Persistent/CustomerData/Persistent.php
@@ -0,0 +1,72 @@
+persistentSession = $persistentSession;
+ $this->customerViewHelper = $customerViewHelper;
+ $this->customerRepository = $customerRepository;
+ }
+
+ /**
+ * Get data.
+ *
+ * @return array
+ */
+ public function getSectionData(): array
+ {
+ if (!$this->persistentSession->isPersistent()) {
+ return [];
+ }
+
+ $customerId = $this->persistentSession->getSession()->getCustomerId();
+ if (!$customerId) {
+ return [];
+ }
+
+ $customer = $this->customerRepository->getById($customerId);
+
+ return [
+ 'fullname' => $this->customerViewHelper->getCustomerName($customer),
+ ];
+ }
+}
diff --git a/app/code/Magento/Persistent/Model/Observer.php b/app/code/Magento/Persistent/Model/Observer.php
index 53fe5f95531e1..81c2870071a2e 100644
--- a/app/code/Magento/Persistent/Model/Observer.php
+++ b/app/code/Magento/Persistent/Model/Observer.php
@@ -86,13 +86,8 @@ public function __construct(
*/
public function emulateWelcomeBlock($block)
{
- $customerName = $this->_customerViewHelper->getCustomerName(
- $this->customerRepository->getById($this->_persistentSession->getSession()->getCustomerId())
- );
+ $block->setWelcome(' ');
- $this->_applyAccountLinksPersistentData();
- $welcomeMessage = __('Welcome, %1!', $customerName);
- $block->setWelcome($welcomeMessage);
return $this;
}
diff --git a/app/code/Magento/Persistent/Model/Plugin/PersistentCustomerContext.php b/app/code/Magento/Persistent/Model/Plugin/PersistentCustomerContext.php
new file mode 100644
index 0000000000000..be8998bc9be14
--- /dev/null
+++ b/app/code/Magento/Persistent/Model/Plugin/PersistentCustomerContext.php
@@ -0,0 +1,43 @@
+persistentSession = $persistentSession;
+ }
+
+ /**
+ * Sets appropriate header if customer session is persistent.
+ *
+ * @param \Magento\Framework\App\Http\Context $subject
+ * @return mixed
+ */
+ public function beforeGetVaryString(\Magento\Framework\App\Http\Context $subject)
+ {
+ if ($this->persistentSession->isPersistent()) {
+ $subject->setValue('PERSISTENT', 1, 0);
+ }
+ }
+}
diff --git a/app/code/Magento/Persistent/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml b/app/code/Magento/Persistent/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml
new file mode 100644
index 0000000000000..293fa04d80462
--- /dev/null
+++ b/app/code/Magento/Persistent/Test/Mftf/ActionGroup/StorefrontCustomerActionGroup.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Persistent/Test/Mftf/Section/StorefrontCustomerSignInFormSection.xml b/app/code/Magento/Persistent/Test/Mftf/Section/StorefrontCustomerSignInFormSection.xml
new file mode 100644
index 0000000000000..c2220c33a6052
--- /dev/null
+++ b/app/code/Magento/Persistent/Test/Mftf/Section/StorefrontCustomerSignInFormSection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml
new file mode 100644
index 0000000000000..2b58e5c7bf62b
--- /dev/null
+++ b/app/code/Magento/Persistent/Test/Mftf/Test/StorefrontCorrectWelcomeMessageAfterCustomerIsLoggedOutTest.xml
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ John1
+ Doe1
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php b/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php
index b88b02ab4cfb5..407dad05c3baf 100644
--- a/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php
+++ b/app/code/Magento/Persistent/Test/Unit/Block/Header/AdditionalTest.php
@@ -34,44 +34,14 @@ class AdditionalTest extends \PHPUnit\Framework\TestCase
protected $contextMock;
/**
- * @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\Serialize\Serializer\Json|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $eventManagerMock;
+ private $jsonSerializerMock;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Persistent\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
*/
- protected $scopeConfigMock;
-
- /**
- * @var \Magento\Framework\App\Cache\StateInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $cacheStateMock;
-
- /**
- * @var \Magento\Framework\App\CacheInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $cacheMock;
-
- /**
- * @var \Magento\Framework\Session\SidResolverInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $sidResolverMock;
-
- /**
- * @var \Magento\Framework\Session\SessionManagerInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $sessionMock;
-
- /**
- * @var \Magento\Framework\Escaper|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $escaperMock;
-
- /**
- * @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject
- */
- protected $urlBuilderMock;
+ private $persistentHelperMock;
/**
* @var \Magento\Persistent\Block\Header\Additional
@@ -93,17 +63,7 @@ protected function setUp()
{
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
- $this->contextMock = $this->createPartialMock(\Magento\Framework\View\Element\Template\Context::class, [
- 'getEventManager',
- 'getScopeConfig',
- 'getCacheState',
- 'getCache',
- 'getInlineTranslation',
- 'getSidResolver',
- 'getSession',
- 'getEscaper',
- 'getUrlBuilder'
- ]);
+ $this->contextMock = $this->createPartialMock(\Magento\Framework\View\Element\Template\Context::class, []);
$this->customerViewHelperMock = $this->createMock(\Magento\Customer\Helper\View::class);
$this->persistentSessionHelperMock = $this->createPartialMock(
\Magento\Persistent\Helper\Session::class,
@@ -119,103 +79,14 @@ protected function setUp()
['getById']
);
- $this->eventManagerMock = $this->getMockForAbstractClass(
- \Magento\Framework\Event\ManagerInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['dispatch']
- );
- $this->scopeConfigMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\Config\ScopeConfigInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['getValue']
- );
- $this->cacheStateMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\Cache\StateInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['isEnabled']
+ $this->jsonSerializerMock = $this->createPartialMock(
+ \Magento\Framework\Serialize\Serializer\Json::class,
+ ['serialize']
);
- $this->cacheMock = $this->getMockForAbstractClass(
- \Magento\Framework\App\CacheInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['load']
+ $this->persistentHelperMock = $this->createPartialMock(
+ \Magento\Persistent\Helper\Data::class,
+ ['getLifeTime']
);
- $this->sidResolverMock = $this->getMockForAbstractClass(
- \Magento\Framework\Session\SidResolverInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['getSessionIdQueryParam']
- );
- $this->sessionMock = $this->getMockForAbstractClass(
- \Magento\Framework\Session\SessionManagerInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['getSessionId']
- );
- $this->escaperMock = $this->getMockForAbstractClass(
- \Magento\Framework\Escaper::class,
- [],
- '',
- false,
- true,
- true,
- ['escapeHtml']
- );
- $this->urlBuilderMock = $this->getMockForAbstractClass(
- \Magento\Framework\UrlInterface::class,
- [],
- '',
- false,
- true,
- true,
- ['getUrl']
- );
-
- $this->contextMock->expects($this->once())
- ->method('getEventManager')
- ->willReturn($this->eventManagerMock);
- $this->contextMock->expects($this->once())
- ->method('getScopeConfig')
- ->willReturn($this->scopeConfigMock);
- $this->contextMock->expects($this->once())
- ->method('getCacheState')
- ->willReturn($this->cacheStateMock);
- $this->contextMock->expects($this->once())
- ->method('getCache')
- ->willReturn($this->cacheMock);
- $this->contextMock->expects($this->once())
- ->method('getSidResolver')
- ->willReturn($this->sidResolverMock);
- $this->contextMock->expects($this->once())
- ->method('getSession')
- ->willReturn($this->sessionMock);
- $this->contextMock->expects($this->once())
- ->method('getEscaper')
- ->willReturn($this->escaperMock);
- $this->contextMock->expects($this->once())
- ->method('getUrlBuilder')
- ->willReturn($this->urlBuilderMock);
$this->additional = $this->objectManager->getObject(
\Magento\Persistent\Block\Header\Additional::class,
@@ -224,91 +95,48 @@ protected function setUp()
'customerViewHelper' => $this->customerViewHelperMock,
'persistentSessionHelper' => $this->persistentSessionHelperMock,
'customerRepository' => $this->customerRepositoryMock,
- 'data' => []
+ 'data' => [],
+ 'jsonSerializer' => $this->jsonSerializerMock,
+ 'persistentHelper' => $this->persistentHelperMock,
]
);
}
/**
- * Run test toHtml method
- *
- * @param bool $customerId
* @return void
- *
- * @dataProvider dataProviderToHtml
*/
- public function testToHtml($customerId)
+ public function testGetCustomerId(): void
{
- $cacheData = false;
- $idQueryParam = 'id-query-param';
- $sessionId = 'session-id';
-
- $this->additional->setData('cache_lifetime', 789);
- $this->additional->setData('cache_key', 'cache-key');
-
- $this->eventManagerMock->expects($this->at(0))
- ->method('dispatch')
- ->with('view_block_abstract_to_html_before', ['block' => $this->additional]);
- $this->eventManagerMock->expects($this->at(1))
- ->method('dispatch')
- ->with('view_block_abstract_to_html_after');
- $this->scopeConfigMock->expects($this->once())
- ->method('getValue')
- ->with(
- 'advanced/modules_disable_output/Magento_Persistent',
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
- )->willReturn(false);
-
- // get cache
- $this->cacheStateMock->expects($this->at(0))
- ->method('isEnabled')
- ->with(\Magento\Persistent\Block\Header\Additional::CACHE_GROUP)
- ->willReturn(true);
- // save cache
- $this->cacheStateMock->expects($this->at(1))
- ->method('isEnabled')
- ->with(\Magento\Persistent\Block\Header\Additional::CACHE_GROUP)
- ->willReturn(false);
-
- $this->cacheMock->expects($this->once())
- ->method('load')
- ->willReturn($cacheData);
- $this->sidResolverMock->expects($this->never())
- ->method('getSessionIdQueryParam')
- ->with($this->sessionMock)
- ->willReturn($idQueryParam);
- $this->sessionMock->expects($this->never())
- ->method('getSessionId')
- ->willReturn($sessionId);
-
- // call protected _toHtml method
+ $customerId = 1;
+ /** @var \Magento\Persistent\Model\Session|\PHPUnit_Framework_MockObject_MockObject $sessionMock */
$sessionMock = $this->createPartialMock(\Magento\Persistent\Model\Session::class, ['getCustomerId']);
-
- $this->persistentSessionHelperMock->expects($this->atLeastOnce())
- ->method('getSession')
- ->willReturn($sessionMock);
-
- $sessionMock->expects($this->atLeastOnce())
+ $sessionMock->expects($this->once())
->method('getCustomerId')
->willReturn($customerId);
+ $this->persistentSessionHelperMock->expects($this->once())
+ ->method('getSession')
+ ->willReturn($sessionMock);
- if ($customerId) {
- $this->assertEquals('Not you?', $this->additional->toHtml());
- } else {
- $this->assertEquals('', $this->additional->toHtml());
- }
+ $this->assertEquals($customerId, $this->additional->getCustomerId());
}
/**
- * Data provider for dataProviderToHtml method
- *
- * @return array
+ * @return void
*/
- public function dataProviderToHtml()
+ public function testGetConfig(): void
{
- return [
- ['customerId' => 2],
- ['customerId' => null],
- ];
+ $lifeTime = 500;
+ $arrayToSerialize = ['expirationLifetime' => $lifeTime];
+ $serializedArray = '{"expirationLifetime":' . $lifeTime . '}';
+
+ $this->persistentHelperMock->expects($this->once())
+ ->method('getLifeTime')
+ ->willReturn($lifeTime);
+ $this->jsonSerializerMock->expects($this->once())
+ ->method('serialize')
+ ->with($arrayToSerialize)
+ ->willReturn($serializedArray);
+
+ $this->assertEquals($serializedArray, $this->additional->getConfig());
}
}
diff --git a/app/code/Magento/Persistent/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Persistent/Test/Unit/Model/ObserverTest.php
index 7008a9eb25e5d..6d4db70adc642 100644
--- a/app/code/Magento/Persistent/Test/Unit/Model/ObserverTest.php
+++ b/app/code/Magento/Persistent/Test/Unit/Model/ObserverTest.php
@@ -80,31 +80,18 @@ protected function setUp()
);
}
- public function testEmulateWelcomeBlock()
+ /**
+ * @return void
+ */
+ public function testEmulateWelcomeBlock(): void
{
- $customerId = 1;
- $customerName = 'Test Customer Name';
- $welcomeMessage = __('Welcome, %1!', $customerName);
- $customerMock = $this->getMockForAbstractClass(\Magento\Customer\Api\Data\CustomerInterface::class);
+ $welcomeMessage = __(' ');
$block = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class)
->disableOriginalConstructor()
->setMethods(['setWelcome'])
->getMock();
- $headerAdditionalBlock = $this->getMockBuilder(\Magento\Framework\View\Element\AbstractBlock::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->persistentSessionMock->expects($this->once())->method('getSession')->willReturn($this->sessionMock);
- $this->sessionMock->expects($this->once())->method('getCustomerId')->willReturn($customerId);
- $this->customerRepositoryMock
- ->expects($this->once())
- ->method('getById')
- ->with($customerId)->willReturn($customerMock);
- $this->customerViewHelperMock->expects($this->once())->method('getCustomerName')->willReturn($customerName);
- $this->layoutMock->expects($this->once())
- ->method('getBlock')
- ->with('header.additional')
- ->willReturn($headerAdditionalBlock);
$block->expects($this->once())->method('setWelcome')->with($welcomeMessage);
+
$this->observer->emulateWelcomeBlock($block);
}
}
diff --git a/app/code/Magento/Persistent/etc/di.xml b/app/code/Magento/Persistent/etc/di.xml
index f49d4361acb52..c28426b4f25bf 100644
--- a/app/code/Magento/Persistent/etc/di.xml
+++ b/app/code/Magento/Persistent/etc/di.xml
@@ -12,4 +12,7 @@
+
+
+
diff --git a/app/code/Magento/Persistent/etc/frontend/di.xml b/app/code/Magento/Persistent/etc/frontend/di.xml
index f976f4de79c21..3c33f8a51c418 100644
--- a/app/code/Magento/Persistent/etc/frontend/di.xml
+++ b/app/code/Magento/Persistent/etc/frontend/di.xml
@@ -35,4 +35,18 @@
+
+
+
+ - Magento\Persistent\CustomerData\Persistent
+
+
+
+
+
+
+ - persistent
+
+
+
diff --git a/app/code/Magento/Persistent/etc/frontend/sections.xml b/app/code/Magento/Persistent/etc/frontend/sections.xml
new file mode 100644
index 0000000000000..16b44c502fc47
--- /dev/null
+++ b/app/code/Magento/Persistent/etc/frontend/sections.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Persistent/view/frontend/requirejs-config.js b/app/code/Magento/Persistent/view/frontend/requirejs-config.js
new file mode 100644
index 0000000000000..e30e07c454be5
--- /dev/null
+++ b/app/code/Magento/Persistent/view/frontend/requirejs-config.js
@@ -0,0 +1,14 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+var config = {
+ config: {
+ mixins: {
+ 'Magento_Customer/js/customer-data': {
+ 'Magento_Persistent/js/view/customer-data-mixin': true
+ }
+ }
+ }
+};
diff --git a/app/code/Magento/Persistent/view/frontend/templates/additional.phtml b/app/code/Magento/Persistent/view/frontend/templates/additional.phtml
new file mode 100644
index 0000000000000..28dce5dc23cc9
--- /dev/null
+++ b/app/code/Magento/Persistent/view/frontend/templates/additional.phtml
@@ -0,0 +1,21 @@
+
+getCustomerId()) :?>
+
+ getLinkAttributes()?>>= $block->escapeHtml(__('Not you?'));?>
+
+
+
+
diff --git a/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js b/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js
new file mode 100644
index 0000000000000..7ace6e60d1c39
--- /dev/null
+++ b/app/code/Magento/Persistent/view/frontend/web/js/view/additional-welcome.js
@@ -0,0 +1,55 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+
+define([
+ 'jquery',
+ 'mage/translate',
+ 'Magento_Customer/js/customer-data'
+], function ($, $t, customerData) {
+ 'use strict';
+
+ return {
+ /**
+ * Init.
+ */
+ init: function () {
+ var persistent = customerData.get('persistent');
+
+ if (persistent().fullname === undefined) {
+ customerData.get('persistent').subscribe(this.replacePersistentWelcome);
+ } else {
+ this.replacePersistentWelcome();
+ }
+ },
+
+ /**
+ * Replace welcome message for customer with persistent cookie.
+ */
+ replacePersistentWelcome: function () {
+ var persistent = customerData.get('persistent'),
+ welcomeElems;
+
+ if (persistent().fullname !== undefined) {
+ welcomeElems = $('li.greet.welcome > span.not-logged-in');
+
+ if (welcomeElems.length) {
+ $(welcomeElems).each(function () {
+ var html = $t('Welcome, %1!').replace('%1', persistent().fullname);
+
+ $(this).attr('data-bind', html);
+ $(this).html(html);
+ });
+ }
+ }
+ },
+
+ /**
+ * @constructor
+ */
+ 'Magento_Persistent/js/view/additional-welcome': function () {
+ this.init();
+ }
+ };
+});
diff --git a/app/code/Magento/Persistent/view/frontend/web/js/view/customer-data-mixin.js b/app/code/Magento/Persistent/view/frontend/web/js/view/customer-data-mixin.js
new file mode 100644
index 0000000000000..855404c6f6f32
--- /dev/null
+++ b/app/code/Magento/Persistent/view/frontend/web/js/view/customer-data-mixin.js
@@ -0,0 +1,51 @@
+/**
+ * Copyright © Magento, Inc. All rights reserved.
+ * See COPYING.txt for license details.
+ */
+define([
+ 'jquery',
+ 'mage/utils/wrapper'
+], function ($, wrapper) {
+ 'use strict';
+
+ var mixin = {
+
+ /**
+ * Check if persistent section is expired due to lifetime.
+ *
+ * @param {Function} originFn - Original method.
+ * @return {Array}
+ */
+ getExpiredSectionNames: function (originFn) {
+ var expiredSections = originFn(),
+ storage = $.initNamespaceStorage('mage-cache-storage').localStorage,
+ currentTimestamp = Math.floor(Date.now() / 1000),
+ persistentIndex = expiredSections.indexOf('persistent'),
+ persistentLifeTime = 0,
+ sectionData;
+
+ if (window.persistent !== undefined && window.persistent.expirationLifetime !== undefined) {
+ persistentLifeTime = window.persistent.expirationLifetime;
+ }
+
+ if (persistentIndex !== -1) {
+ sectionData = storage.get('persistent');
+
+ if (typeof sectionData === 'object' &&
+ sectionData['data_id'] + persistentLifeTime >= currentTimestamp
+ ) {
+ expiredSections.splice(persistentIndex, 1);
+ }
+ }
+
+ return expiredSections;
+ }
+ };
+
+ /**
+ * Override default customer-data.getExpiredSectionNames().
+ */
+ return function (target) {
+ return wrapper.extend(target, mixin);
+ };
+});
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml
index 84fcc8fc47dfb..d65074b3eb1e3 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminCreditMemoTotalSection.xml
@@ -22,4 +22,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoiceItemsSection.xml b/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoiceItemsSection.xml
index bc0d1cffd5d3e..92c01cf380746 100644
--- a/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoiceItemsSection.xml
+++ b/app/code/Magento/Sales/Test/Mftf/Section/AdminInvoiceItemsSection.xml
@@ -29,4 +29,4 @@
-
\ No newline at end of file
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCartPriceRuleActionGroup.xml b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCartPriceRuleActionGroup.xml
index a794c67e736fc..e5907e1e9c0f5 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCartPriceRuleActionGroup.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCartPriceRuleActionGroup.xml
@@ -16,4 +16,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml
index 224977e767cd3..b6a825766395d 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/ActionGroup/AdminCreateCartPriceRuleActionGroup.xml
@@ -48,4 +48,15 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleAddressConditionsData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleAddressConditionsData.xml
new file mode 100644
index 0000000000000..cc695b347c4fb
--- /dev/null
+++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleAddressConditionsData.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+ Magento\SalesRule\Model\Rule\Condition\Address|base_subtotal
+ Magento\SalesRule\Model\Rule\Condition\Address|total_qty
+ Magento\SalesRule\Model\Rule\Condition\Address|weight
+ Magento\SalesRule\Model\Rule\Condition\Address|shipping_method
+ Magento\SalesRule\Model\Rule\Condition\Address|postcode
+ Magento\SalesRule\Model\Rule\Condition\Address|region
+ Magento\SalesRule\Model\Rule\Condition\Address|region_id
+ Magento\SalesRule\Model\Rule\Condition\Address|country_id
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
index 3b2e9da9e7928..ded1d2806a684 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Data/SalesRuleData.xml
@@ -144,4 +144,31 @@
10
1
+
+
+ SimpleSalesRule
+ Sales Rule Description
+
+ - 1
+
+
+ - 1
+
+ 10
+ true
+ false
+ true
+ 1
+ by_percent
+ 10
+ 10
+ 0
+ false
+ 0
+ false
+ SPECIFIC_COUPON
+ false
+ 10
+ 1
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
index 070532500afe1..c3680e1c3ceaf 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesFormSection.xml
@@ -27,6 +27,12 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesSection.xml b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesSection.xml
index a32c50d9d8617..14d3a734408db 100644
--- a/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesSection.xml
+++ b/app/code/Magento/SalesRule/Test/Mftf/Section/AdminCartPriceRulesSection.xml
@@ -15,5 +15,8 @@
+
+
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchStoreViewActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchStoreViewActionGroup.xml
index 860f094a48ecc..ac8e9d717fdca 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchStoreViewActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchStoreViewActionGroup.xml
@@ -20,4 +20,8 @@
+
+
+
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchWebsiteActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchWebsiteActionGroup.xml
new file mode 100644
index 0000000000000..cfb2c7e6347c3
--- /dev/null
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/AdminSwitchWebsiteActionGroup.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Store/Test/Mftf/ActionGroup/StorefrontSwitchStoreViewActionGroup.xml b/app/code/Magento/Store/Test/Mftf/ActionGroup/StorefrontSwitchStoreViewActionGroup.xml
index cfcd25086e067..efd3a8c6b8cad 100644
--- a/app/code/Magento/Store/Test/Mftf/ActionGroup/StorefrontSwitchStoreViewActionGroup.xml
+++ b/app/code/Magento/Store/Test/Mftf/ActionGroup/StorefrontSwitchStoreViewActionGroup.xml
@@ -14,7 +14,7 @@
-
+
diff --git a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
index 9fae618020ff3..9c418e9ebd496 100644
--- a/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
+++ b/app/code/Magento/Store/Test/Mftf/Data/StoreData.xml
@@ -22,8 +22,8 @@
customStoreGroup
- EN
- en
+ EN
+ en
1
null
add
@@ -31,8 +31,8 @@
customStoreGroup
- FR
- fr
+ FR
+ fr
1
null
add
@@ -65,4 +65,13 @@
StoreView
StoreViewCode
+
+ Second Store View
+ second_store_view_
+ 1
+ null
+ add
+ store
+ SecondStoreGroup
+
diff --git a/app/code/Magento/Store/Test/Mftf/Data/StoreGroupData.xml b/app/code/Magento/Store/Test/Mftf/Data/StoreGroupData.xml
index e575ca3317ab6..2127b5f3c8b21 100644
--- a/app/code/Magento/Store/Test/Mftf/Data/StoreGroupData.xml
+++ b/app/code/Magento/Store/Test/Mftf/Data/StoreGroupData.xml
@@ -21,6 +21,22 @@
add
group
+
+ null
+ Second Store
+ second_store
+
+ add
+ group
+
+
+ null
+ Second Store
+ second_store_
+
+ add
+ group
+
NewStore
Base12
diff --git a/app/code/Magento/Store/Test/Mftf/Section/AdminMainActionsSection.xml b/app/code/Magento/Store/Test/Mftf/Section/AdminMainActionsSection.xml
index fda182246db4a..14160835af3e1 100644
--- a/app/code/Magento/Store/Test/Mftf/Section/AdminMainActionsSection.xml
+++ b/app/code/Magento/Store/Test/Mftf/Section/AdminMainActionsSection.xml
@@ -11,6 +11,8 @@
diff --git a/app/code/Magento/Store/etc/di.xml b/app/code/Magento/Store/etc/di.xml
index be005264b7bbf..defe0694d018d 100644
--- a/app/code/Magento/Store/etc/di.xml
+++ b/app/code/Magento/Store/etc/di.xml
@@ -236,6 +236,7 @@
+ - Magento\Framework\App\ScopeResolver
- Magento\Store\Model\Resolver\Store
- Magento\Store\Model\Resolver\Store
- Magento\Store\Model\Resolver\Group
diff --git a/app/code/Magento/Store/etc/frontend/di.xml b/app/code/Magento/Store/etc/frontend/di.xml
index c39d5df863939..917aedad3d960 100644
--- a/app/code/Magento/Store/etc/frontend/di.xml
+++ b/app/code/Magento/Store/etc/frontend/di.xml
@@ -9,7 +9,7 @@
-
+
diff --git a/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml b/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml
index 658f524a4a5db..72adf7b0dae1e 100644
--- a/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml
+++ b/app/code/Magento/Tax/Test/Mftf/Test/AdminDeleteTaxRuleTest.xml
@@ -68,7 +68,9 @@
+
+
diff --git a/app/code/Magento/Theme/Test/Mftf/Section/StorefrontHeaderSection.xml b/app/code/Magento/Theme/Test/Mftf/Section/StorefrontHeaderSection.xml
new file mode 100644
index 0000000000000..a4088c7a4a0b7
--- /dev/null
+++ b/app/code/Magento/Theme/Test/Mftf/Section/StorefrontHeaderSection.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/code/Magento/Theme/view/frontend/templates/html/header.phtml b/app/code/Magento/Theme/view/frontend/templates/html/header.phtml
index 4395cab651de1..1103ae28741c6 100644
--- a/app/code/Magento/Theme/view/frontend/templates/html/header.phtml
+++ b/app/code/Magento/Theme/view/frontend/templates/html/header.phtml
@@ -15,11 +15,11 @@ $welcomeMessage = $block->getWelcome();
case 'welcome': ?>
-
+
-
+
= $block->getBlockHtml('header.additional') ?>
diff --git a/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml b/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml
index edcc70a82396d..a2b7ba8c1ffd5 100644
--- a/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml
+++ b/app/code/Magento/Ui/Test/Mftf/Section/AdminDataGridTableSection.xml
@@ -18,5 +18,6 @@
+
diff --git a/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php b/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php
index f4aa61b145f62..d8ceb16d71fdc 100644
--- a/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php
+++ b/app/code/Magento/UrlRewrite/Model/Storage/DbStorage.php
@@ -87,7 +87,7 @@ protected function prepareSelect(array $data)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function doFindAllByData(array $data)
{
@@ -95,7 +95,7 @@ protected function doFindAllByData(array $data)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
protected function doFindOneByData(array $data)
{
@@ -161,26 +161,22 @@ private function deleteOldUrls(array $urls): void
$oldUrlsSelect->from(
$this->resource->getTableName(self::TABLE_NAME)
);
- /** @var UrlRewrite $url */
- foreach ($urls as $url) {
- $oldUrlsSelect->orWhere(
- $this->connection->quoteIdentifier(
- UrlRewrite::ENTITY_TYPE
- ) . ' = ?',
- $url->getEntityType()
- );
- $oldUrlsSelect->where(
- $this->connection->quoteIdentifier(
- UrlRewrite::ENTITY_ID
- ) . ' = ?',
- $url->getEntityId()
- );
- $oldUrlsSelect->where(
- $this->connection->quoteIdentifier(
- UrlRewrite::STORE_ID
- ) . ' = ?',
- $url->getStoreId()
- );
+
+ $uniqueEntities = $this->prepareUniqueEntities($urls);
+ foreach ($uniqueEntities as $storeId => $entityTypes) {
+ foreach ($entityTypes as $entityType => $entities) {
+ $oldUrlsSelect->orWhere(
+ $this->connection->quoteIdentifier(
+ UrlRewrite::STORE_ID
+ ) . ' = ' . $this->connection->quote($storeId, 'INTEGER') .
+ ' AND ' . $this->connection->quoteIdentifier(
+ UrlRewrite::ENTITY_ID
+ ) . ' IN (' . $this->connection->quote($entities, 'INTEGER') . ')' .
+ ' AND ' . $this->connection->quoteIdentifier(
+ UrlRewrite::ENTITY_TYPE
+ ) . ' = ' . $this->connection->quote($entityType)
+ );
+ }
}
// prevent query locking in a case when nothing to delete
@@ -198,6 +194,28 @@ private function deleteOldUrls(array $urls): void
}
}
+ /**
+ * Prepare array with unique entities
+ *
+ * @param UrlRewrite[] $urls
+ * @return array
+ */
+ private function prepareUniqueEntities(array $urls): array
+ {
+ $uniqueEntities = [];
+ /** @var UrlRewrite $url */
+ foreach ($urls as $url) {
+ $entityIds = (!empty($uniqueEntities[$url->getStoreId()][$url->getEntityType()])) ?
+ $uniqueEntities[$url->getStoreId()][$url->getEntityType()] : [];
+
+ if (!\in_array($url->getEntityId(), $entityIds)) {
+ $entityIds[] = $url->getEntityId();
+ }
+ $uniqueEntities[$url->getStoreId()][$url->getEntityType()] = $entityIds;
+ }
+ return $uniqueEntities;
+ }
+
/**
* @inheritDoc
*/
@@ -289,7 +307,7 @@ protected function createFilterDataBasedOnUrls($urls)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function deleteByData(array $data)
{
diff --git a/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php b/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php
index b96a8ef637404..697ce33be0fa7 100644
--- a/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php
+++ b/app/code/Magento/UrlRewrite/Test/Unit/Model/Storage/DbStorageTest.php
@@ -445,7 +445,6 @@ public function testReplace()
$urlSecond = $this->createMock(\Magento\UrlRewrite\Service\V1\Data\UrlRewrite::class);
// delete
-
$urlFirst->expects($this->any())
->method('getEntityType')
->willReturn('product');
@@ -479,10 +478,6 @@ public function testReplace()
->with(DbStorage::TABLE_NAME)
->will($this->returnValue('table_name'));
- $this->connectionMock->expects($this->any())
- ->method('query')
- ->with('sql delete query');
-
// insert
$urlFirst->expects($this->any())
@@ -497,10 +492,6 @@ public function testReplace()
->with(DbStorage::TABLE_NAME)
->will($this->returnValue('table_name'));
- $this->connectionMock->expects($this->once())
- ->method('insertMultiple')
- ->with('table_name', [['row1'], ['row2']]);
-
$this->storage->replace([$urlFirst, $urlSecond]);
}
diff --git a/app/code/Magento/Usps/Model/Carrier.php b/app/code/Magento/Usps/Model/Carrier.php
index e46257452b27f..6e69b9c317946 100644
--- a/app/code/Magento/Usps/Model/Carrier.php
+++ b/app/code/Magento/Usps/Model/Carrier.php
@@ -1248,7 +1248,7 @@ protected function _getCountryName($countryId)
'FO' => 'Faroe Islands',
'FR' => 'France',
'GA' => 'Gabon',
- 'GB' => 'Great Britain and Northern Ireland',
+ 'GB' => 'United Kingdom of Great Britain and Northern Ireland',
'GD' => 'Grenada',
'GE' => 'Georgia, Republic of',
'GF' => 'French Guiana',
@@ -1366,7 +1366,7 @@ protected function _getCountryName($countryId)
'ST' => 'Sao Tome and Principe',
'SV' => 'El Salvador',
'SY' => 'Syrian Arab Republic',
- 'SZ' => 'Swaziland',
+ 'SZ' => 'Eswatini',
'TC' => 'Turks and Caicos Islands',
'TD' => 'Chad',
'TG' => 'Togo',
diff --git a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
index 7955f4ec29e55..642ad6a268201 100644
--- a/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
+++ b/app/code/Magento/Widget/Test/Mftf/ActionGroup/AdminCreateWidgetActionGroup.xml
@@ -7,55 +7,62 @@
-->
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Widget/Test/Mftf/Data/WidgetsData.xml b/app/code/Magento/Widget/Test/Mftf/Data/WidgetsData.xml
index 26864c60b6494..27222298408de 100644
--- a/app/code/Magento/Widget/Test/Mftf/Data/WidgetsData.xml
+++ b/app/code/Magento/Widget/Test/Mftf/Data/WidgetsData.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
Catalog Products List
Magento Luma
@@ -19,4 +19,17 @@
All Pages
Main Content Area
+
+ Dynamic Blocks Rotator
+ Magento Luma
+ TestBannerWidget
+
+ - All Store Views
+
+ SKU
+ All Pages
+ Main Content Area
+ Cart Price Rule Related
+ Header
+
diff --git a/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml b/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml
index 8eb0a5f65318e..d495a36f68d0a 100644
--- a/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml
+++ b/app/code/Magento/Widget/Test/Mftf/Page/AdminNewWidgetPage.xml
@@ -7,8 +7,8 @@
-->
-
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd">
+
diff --git a/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml b/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml
index 38b4df335ea83..aea74b573ce11 100644
--- a/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml
+++ b/app/code/Magento/Widget/Test/Mftf/Section/AdminNewWidgetSection.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/etc/di.xml b/app/etc/di.xml
index ceccee04a8bc4..6cf169c1d2277 100755
--- a/app/etc/di.xml
+++ b/app/etc/di.xml
@@ -1749,4 +1749,11 @@
+
+
+
+ - Magento\Framework\App\ScopeResolver
+
+
+
diff --git a/dev/tests/acceptance/tests/_data/catalog_products.csv b/dev/tests/acceptance/tests/_data/catalog_products.csv
new file mode 100644
index 0000000000000..3b580172d6a05
--- /dev/null
+++ b/dev/tests/acceptance/tests/_data/catalog_products.csv
@@ -0,0 +1,4 @@
+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
+"Simple Product for Test",,Default,simple,,base,"Simple Product for Test",,,,1,"Taxable Goods","Catalog, Search",123.0000,,,,simple-product-for-test,,,,,,,,,,,,"12/18/18, 7:50 AM","12/18/18, 7:50 AM",,,"Block after Info Column",,,,,,,,,,,,,,1000.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,0,0,0,1,,,,,,,,,,,,,,,,,,,
+"Virtual Product for Test",,Default,virtual,,base,"Virtual Product for Test",,,0.0000,1,"Taxable Goods","Catalog, Search",99.9900,,,,virtual-product-for-test,,,,,,,,,,,,"12/18/18, 7:51 AM","12/18/18, 7:51 AM",,,"Block after Info Column",,,,,,,,,,,,,,1000.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,0,0,0,1,,,,,,,,,,,,,,,,,,,
+"Api Downloadable Product for Test",,Default,downloadable,,base,"Api Downloadable Product for Test","API Product Description5c18fb47982621","API Product Short Description5c18fb47982e21",,1,"Taxable Goods","Catalog, Search",123.0000,,,,api-downloadable-product-for-test,,,,,,,,,,,,"12/18/18, 7:51 AM","12/18/18, 7:51 AM",,,"Block after Info Column",,,,,,,,,,,,,,1000.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,0,1,1,0.0000,1,0,0,0,0,1,,,,,,,,,,,,,,,,,,,
diff --git a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.xml b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.xml
index dce1358a1ecf4..59c00683e3b1a 100644
--- a/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.xml
+++ b/dev/tests/functional/tests/app/Magento/GroupedProduct/Test/Fixture/GroupedProduct.xml
@@ -58,7 +58,7 @@
-
+
@@ -66,7 +66,7 @@
-
+
diff --git a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/AdvancedSearchWithAttributeTest.xml b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/AdvancedSearchWithAttributeTest.xml
index 13c7051d0c1ba..733b110ec5494 100644
--- a/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/AdvancedSearchWithAttributeTest.xml
+++ b/dev/tests/functional/tests/app/Magento/Search/Test/TestCase/AdvancedSearchWithAttributeTest.xml
@@ -8,8 +8,6 @@
- MAGETWO-65408: [FT] Magento\Search\Test\TestCase\AdvancedSearchWithAttributeTest fails on Jenkins
- to_maintain:yes
configurable
simple
bundle
diff --git a/dev/tests/integration/testsuite/Magento/Config/Console/Command/ConfigSetCommandTest.php b/dev/tests/integration/testsuite/Magento/Config/Console/Command/ConfigSetCommandTest.php
index f68f3cf37b079..73f1dd9e7b711 100644
--- a/dev/tests/integration/testsuite/Magento/Config/Console/Command/ConfigSetCommandTest.php
+++ b/dev/tests/integration/testsuite/Magento/Config/Console/Command/ConfigSetCommandTest.php
@@ -28,7 +28,7 @@
/**
* Tests the different flows of config:set command.
*
- * {@inheritdoc}
+ * @inheritdoc
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
* @magentoDbIsolation enabled
*/
@@ -292,8 +292,7 @@ public function runExtendedDataProvider()
* @param string $scope
* @param $scopeCode string|null
* @dataProvider configSetValidationErrorDataProvider
- *
- * @magentoDbIsolation enabled
+ * @magentoDbIsolation disabled
*/
public function testConfigSetValidationError(
$path,
@@ -307,6 +306,7 @@ public function testConfigSetValidationError(
/**
* Data provider for testConfigSetValidationError
+ *
* @return array
*/
public function configSetValidationErrorDataProvider()
@@ -399,7 +399,6 @@ public function testConfigSetCurrency()
* Saving values with successful validation
*
* @dataProvider configSetValidDataProvider
- *
* @magentoDbIsolation enabled
*/
public function testConfigSetValid()
diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Block/Header/AdditionalTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Block/Header/AdditionalTest.php
index fba5354b691d6..2e447e7854a7c 100644
--- a/dev/tests/integration/testsuite/Magento/Persistent/Block/Header/AdditionalTest.php
+++ b/dev/tests/integration/testsuite/Magento/Persistent/Block/Header/AdditionalTest.php
@@ -56,8 +56,8 @@ public function testToHtml()
$this->_customerSession->loginById(1);
$translation = __('Not you?');
- $this->assertStringMatchesFormat(
- '%A%A_block->getHref() . '"%A>' . $translation . '%A%A',
+ $this->assertContains(
+ '' . $translation . '',
$this->_block->toHtml()
);
$this->_customerSession->logout();
diff --git a/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php b/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php
index ecf2cd77a13ff..d0c253fc7a64b 100644
--- a/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php
+++ b/dev/tests/integration/testsuite/Magento/Persistent/Model/ObserverTest.php
@@ -9,7 +9,6 @@
use Magento\Customer\Model\Context;
/**
- * @magentoDataFixture Magento/Persistent/_files/persistent.php
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class ObserverTest extends \PHPUnit\Framework\TestCase
@@ -29,11 +28,6 @@ class ObserverTest extends \PHPUnit\Framework\TestCase
*/
protected $customerRepository;
- /**
- * @var \Magento\Persistent\Helper\Session
- */
- protected $_persistentSessionHelper;
-
/**
* @var \Magento\Framework\ObjectManagerInterface
*/
@@ -44,11 +38,6 @@ class ObserverTest extends \PHPUnit\Framework\TestCase
*/
protected $_observer;
- /**
- * @var \Magento\Customer\Model\Session
- */
- protected $_customerSession;
-
/**
* @var \Magento\Checkout\Model\Session | \PHPUnit_Framework_MockObject_MockObject
*/
@@ -58,8 +47,6 @@ public function setUp()
{
$this->_objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
- $this->_customerSession = $this->_objectManager->get(\Magento\Customer\Model\Session::class);
-
$this->_customerViewHelper = $this->_objectManager->create(
\Magento\Customer\Helper\View::class
);
@@ -75,8 +62,6 @@ public function setUp()
\Magento\Checkout\Model\Session::class
)->disableOriginalConstructor()->setMethods([])->getMock();
- $this->_persistentSessionHelper = $this->_objectManager->create(\Magento\Persistent\Helper\Session::class);
-
$this->_observer = $this->_objectManager->create(
\Magento\Persistent\Model\Observer::class,
[
@@ -89,16 +74,11 @@ public function setUp()
}
/**
- * @magentoConfigFixture current_store persistent/options/enabled 1
- * @magentoConfigFixture current_store persistent/options/remember_enabled 1
- * @magentoConfigFixture current_store persistent/options/remember_default 1
* @magentoAppArea frontend
* @magentoAppIsolation enabled
*/
public function testEmulateWelcomeBlock()
{
- $this->_customerSession->loginById(1);
-
$httpContext = new \Magento\Framework\App\Http\Context();
$httpContext->setValue(Context::CONTEXT_AUTH, 1, 1);
$block = $this->_objectManager->create(
@@ -108,15 +88,7 @@ public function testEmulateWelcomeBlock()
]
);
$this->_observer->emulateWelcomeBlock($block);
- $customerName = $this->_escaper->escapeHtml(
- $this->_customerViewHelper->getCustomerName(
- $this->customerRepository->getById(
- $this->_persistentSessionHelper->getSession()->getCustomerId()
- )
- )
- );
- $translation = __('Welcome, %1!', $customerName)->__toString();
- $this->assertStringMatchesFormat('%A' . $translation . '%A', $block->getWelcome()->__toString());
- $this->_customerSession->logout();
+
+ $this->assertEquals(' ', $block->getWelcome());
}
}
diff --git a/lib/internal/Magento/Framework/App/ScopeDefault.php b/lib/internal/Magento/Framework/App/ScopeDefault.php
index 2ea62387145bf..e62d19f9ffbb4 100644
--- a/lib/internal/Magento/Framework/App/ScopeDefault.php
+++ b/lib/internal/Magento/Framework/App/ScopeDefault.php
@@ -17,7 +17,7 @@ class ScopeDefault implements ScopeInterface
*/
public function getCode()
{
- return 'default';
+ return '';
}
/**
@@ -27,7 +27,7 @@ public function getCode()
*/
public function getId()
{
- return 1;
+ return 0;
}
/**
diff --git a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
index 9374bac405c46..9779be85133f8 100644
--- a/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
+++ b/lib/web/mage/adminhtml/wysiwyg/tiny_mce/tinymce4Adapter.js
@@ -350,7 +350,7 @@ define([
* @param {String} content
*/
setContent: function (content) {
- this.get(this.getId()).execCommand('mceSetContent', false, content);
+ this.get(this.getId()).setContent(content);
},
/**
@@ -559,10 +559,12 @@ define([
var selection = editor.selection,
dom = editor.dom,
rng = dom.createRng(),
+ doc = editor.getDoc(),
markerHtml,
marker;
- if (!selection.getContent().length) {
+ // Validate the range we're trying to fix is contained within the current editors document
+ if (!selection.getContent().length && jQuery.contains(doc, selection.getRng().startContainer)) {
markerHtml = '\uFEFF';
selection.setContent(markerHtml);
marker = dom.get('mce_marker');