-
+ |
= /* @escapeNotVerified */ $block->getActions($_item) ?>
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js
index 76e3d911e7d3f..54e496131972e 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/model/cart/estimate-service.js
@@ -14,55 +14,71 @@ define([
'use strict';
var rateProcessors = [],
- totalsProcessors = [];
+ totalsProcessors = [],
- quote.shippingAddress.subscribe(function () {
- var type = quote.shippingAddress().getType();
+ /**
+ * Estimate totals for shipping address and update shipping rates.
+ */
+ estimateTotalsAndUpdateRates = function () {
+ var type = quote.shippingAddress().getType();
- if (
- quote.isVirtual() ||
- window.checkoutConfig.activeCarriers && window.checkoutConfig.activeCarriers.length === 0
- ) {
- // update totals block when estimated address was set
- totalsProcessors['default'] = totalsDefaultProvider;
- totalsProcessors[type] ?
- totalsProcessors[type].estimateTotals(quote.shippingAddress()) :
- totalsProcessors['default'].estimateTotals(quote.shippingAddress());
- } else {
- // check if user data not changed -> load rates from cache
- if (!cartCache.isChanged('address', quote.shippingAddress()) &&
- !cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
- cartCache.get('rates')
+ if (
+ quote.isVirtual() ||
+ window.checkoutConfig.activeCarriers && window.checkoutConfig.activeCarriers.length === 0
) {
- shippingService.setShippingRates(cartCache.get('rates'));
+ // update totals block when estimated address was set
+ totalsProcessors['default'] = totalsDefaultProvider;
+ totalsProcessors[type] ?
+ totalsProcessors[type].estimateTotals(quote.shippingAddress()) :
+ totalsProcessors['default'].estimateTotals(quote.shippingAddress());
+ } else {
+ // check if user data not changed -> load rates from cache
+ if (!cartCache.isChanged('address', quote.shippingAddress()) &&
+ !cartCache.isChanged('cartVersion', customerData.get('cart')()['data_id']) &&
+ cartCache.get('rates')
+ ) {
+ shippingService.setShippingRates(cartCache.get('rates'));
- return;
+ return;
+ }
+
+ // update rates list when estimated address was set
+ rateProcessors['default'] = defaultProcessor;
+ rateProcessors[type] ?
+ rateProcessors[type].getRates(quote.shippingAddress()) :
+ rateProcessors['default'].getRates(quote.shippingAddress());
+
+ // save rates to cache after load
+ shippingService.getShippingRates().subscribe(function (rates) {
+ cartCache.set('rates', rates);
+ });
}
+ },
- // update rates list when estimated address was set
- rateProcessors['default'] = defaultProcessor;
- rateProcessors[type] ?
- rateProcessors[type].getRates(quote.shippingAddress()) :
- rateProcessors['default'].getRates(quote.shippingAddress());
+ /**
+ * Estimate totals for shipping address.
+ */
+ estimateTotalsShipping = function () {
+ totalsDefaultProvider.estimateTotals(quote.shippingAddress());
+ },
- // save rates to cache after load
- shippingService.getShippingRates().subscribe(function (rates) {
- cartCache.set('rates', rates);
- });
- }
- });
- quote.shippingMethod.subscribe(function () {
- totalsDefaultProvider.estimateTotals(quote.shippingAddress());
- });
- quote.billingAddress.subscribe(function () {
- var type = quote.billingAddress().getType();
+ /**
+ * Estimate totals for billing address.
+ */
+ estimateTotalsBilling = function () {
+ var type = quote.billingAddress().getType();
+
+ if (quote.isVirtual()) {
+ // update totals block when estimated address was set
+ totalsProcessors['default'] = totalsDefaultProvider;
+ totalsProcessors[type] ?
+ totalsProcessors[type].estimateTotals(quote.billingAddress()) :
+ totalsProcessors['default'].estimateTotals(quote.billingAddress());
+ }
+ };
- if (quote.isVirtual()) {
- // update totals block when estimated address was set
- totalsProcessors['default'] = totalsDefaultProvider;
- totalsProcessors[type] ?
- totalsProcessors[type].estimateTotals(quote.billingAddress()) :
- totalsProcessors['default'].estimateTotals(quote.billingAddress());
- }
- });
+ quote.shippingAddress.subscribe(estimateTotalsAndUpdateRates);
+ quote.shippingMethod.subscribe(estimateTotalsShipping);
+ quote.billingAddress.subscribe(estimateTotalsBilling);
+ customerData.get('cart').subscribe(estimateTotalsShipping);
});
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js b/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js
index 73f4df567903c..28e04699f8daf 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/model/checkout-data-resolver.js
@@ -218,16 +218,31 @@ define([
* Apply resolved billing address to quote
*/
applyBillingAddress: function () {
- var shippingAddress;
+ var shippingAddress,
+ isBillingAddressInitialized;
if (quote.billingAddress()) {
selectBillingAddress(quote.billingAddress());
return;
}
+
+ if (quote.isVirtual()) {
+ isBillingAddressInitialized = addressList.some(function (addrs) {
+ if (addrs.isDefaultBilling()) {
+ selectBillingAddress(addrs);
+
+ return true;
+ }
+
+ return false;
+ });
+ }
+
shippingAddress = quote.shippingAddress();
- if (shippingAddress &&
+ if (!isBillingAddressInitialized &&
+ shippingAddress &&
shippingAddress.canUseForBilling() &&
(shippingAddress.isDefaultShipping() || !quote.isVirtual())
) {
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js b/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js
index 848a7daf71e1b..16fc459729bbc 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/model/error-processor.js
@@ -8,8 +8,9 @@
*/
define([
'mage/url',
- 'Magento_Ui/js/model/messageList'
-], function (url, globalMessageList) {
+ 'Magento_Ui/js/model/messageList',
+ 'consoleLogger'
+], function (url, globalMessageList, consoleLogger) {
'use strict';
return {
@@ -25,8 +26,12 @@ define([
if (response.status == 401) { //eslint-disable-line eqeqeq
window.location.replace(url.build('customer/account/login/'));
} else {
- error = JSON.parse(response.responseText);
- messageContainer.addErrorMessage(error);
+ try {
+ error = JSON.parse(response.responseText);
+ messageContainer.addErrorMessage(error);
+ } catch (e) {
+ consoleLogger.error(e);
+ }
}
}
};
diff --git a/app/code/Magento/Checkout/view/frontend/web/js/view/progress-bar.js b/app/code/Magento/Checkout/view/frontend/web/js/view/progress-bar.js
index e4b1e464348b9..db49683129f2b 100644
--- a/app/code/Magento/Checkout/view/frontend/web/js/view/progress-bar.js
+++ b/app/code/Magento/Checkout/view/frontend/web/js/view/progress-bar.js
@@ -24,11 +24,17 @@ define([
/** @inheritdoc */
initialize: function () {
+ var stepsValue;
+
this._super();
$(window).hashchange(_.bind(stepNavigator.handleHash, stepNavigator));
if (!window.location.hash) {
- stepNavigator.setHash(stepNavigator.steps().sort(stepNavigator.sortItems)[0].code);
+ stepsValue = stepNavigator.steps();
+
+ if (stepsValue.length) {
+ stepNavigator.setHash(stepsValue.sort(stepNavigator.sortItems)[0].code);
+ }
}
stepNavigator.handleHash();
diff --git a/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html b/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html
index fd994a4e8a955..ea521b3a8afd4 100644
--- a/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html
+++ b/app/code/Magento/Checkout/view/frontend/web/template/billing-address/details.html
@@ -4,28 +4,37 @@
* See COPYING.txt for license details.
*/
-->
-
-
-
-
- ,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html
index 2e268461d1eea..2a5dc27328a43 100644
--- a/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html
+++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-address/address-renderer/default.html
@@ -4,33 +4,38 @@
* See COPYING.txt for license details.
*/
-->
-
-
-
-
- ,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ ,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+ click="editAddress">
+
-
-
-
+
+
diff --git a/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html b/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html
index b66526f660af7..541413955cb47 100644
--- a/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html
+++ b/app/code/Magento/Checkout/view/frontend/web/template/shipping-information/address-renderer/default.html
@@ -4,23 +4,29 @@
* See COPYING.txt for license details.
*/
-->
-
-
-
-
- ,
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ ,
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/CheckoutAgreements/Test/Mftf/composer.json b/app/code/Magento/CheckoutAgreements/Test/Mftf/composer.json
deleted file mode 100644
index c4b8e1fe51c75..0000000000000
--- a/app/code/Magento/CheckoutAgreements/Test/Mftf/composer.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "magento/functional-test-module-checkout-agreements",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-checkout": "100.0.0-dev",
- "magento/functional-test-module-quote": "100.0.0-dev",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-backend": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/CheckoutAgreements/composer.json b/app/code/Magento/CheckoutAgreements/composer.json
index d54b90d823386..a53558981e2f8 100644
--- a/app/code/Magento/CheckoutAgreements/composer.json
+++ b/app/code/Magento/CheckoutAgreements/composer.json
@@ -10,7 +10,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
- "version": "100.2.1",
+ "version": "100.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php
index 4b8a0f3494dd9..2cd1647a1bf22 100644
--- a/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php
+++ b/app/code/Magento/Cms/Model/Wysiwyg/Images/Storage.php
@@ -500,14 +500,6 @@ public function uploadFile($targetPath, $type = null)
// create thumbnail
$this->resizeFile($targetPath . '/' . $uploader->getUploadedFileName(), true);
- $result['cookie'] = [
- 'name' => $this->getSession()->getName(),
- 'value' => $this->getSession()->getSessionId(),
- 'lifetime' => $this->getSession()->getCookieLifetime(),
- 'path' => $this->getSession()->getCookiePath(),
- 'domain' => $this->getSession()->getCookieDomain(),
- ];
-
return $result;
}
diff --git a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml
index d0f72da39c482..39face57e5c86 100644
--- a/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml
+++ b/app/code/Magento/Cms/Test/Mftf/Test/AdminCreateCmsPageTest.xml
@@ -17,8 +17,9 @@
-
-
+
+
+
diff --git a/app/code/Magento/Cms/Test/Mftf/composer.json b/app/code/Magento/Cms/Test/Mftf/composer.json
deleted file mode 100644
index 2d0c6274fd0d1..0000000000000
--- a/app/code/Magento/Cms/Test/Mftf/composer.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "name": "magento/functional-test-module-cms",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-theme": "100.0.0-dev",
- "magento/functional-test-module-widget": "100.0.0-dev",
- "magento/functional-test-module-backend": "100.0.0-dev",
- "magento/functional-test-module-catalog": "100.0.0-dev",
- "magento/functional-test-module-email": "100.0.0-dev",
- "magento/functional-test-module-ui": "100.0.0-dev",
- "magento/functional-test-module-variable": "100.0.0-dev",
- "magento/functional-test-module-media-storage": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "suggest": {
- "magento/functional-test-module-cms-sample-data": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php
index 634a51272b39b..906a7d4fbc605 100644
--- a/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php
+++ b/app/code/Magento/Cms/Test/Unit/Model/Wysiwyg/Images/StorageTest.php
@@ -437,14 +437,7 @@ public function testUploadFile()
$thumbnailDestination = $thumbnailTargetPath . '/' . $fileName;
$type = 'image';
$result = [
- 'result',
- 'cookie' => [
- 'name' => 'session_name',
- 'value' => '1',
- 'lifetime' => '50',
- 'path' => 'cookie/path',
- 'domain' => 'cookie_domain',
- ]
+ 'result'
];
$uploader = $this->getMockBuilder(\Magento\MediaStorage\Model\File\Uploader::class)
->disableOriginalConstructor()
@@ -504,17 +497,6 @@ public function testUploadFile()
$this->adapterFactoryMock->expects($this->atLeastOnce())->method('create')->willReturn($image);
- $this->sessionMock->expects($this->atLeastOnce())->method('getName')
- ->willReturn($result['cookie']['name']);
- $this->sessionMock->expects($this->atLeastOnce())->method('getSessionId')
- ->willReturn($result['cookie']['value']);
- $this->sessionMock->expects($this->atLeastOnce())->method('getCookieLifetime')
- ->willReturn($result['cookie']['lifetime']);
- $this->sessionMock->expects($this->atLeastOnce())->method('getCookiePath')
- ->willReturn($result['cookie']['path']);
- $this->sessionMock->expects($this->atLeastOnce())->method('getCookieDomain')
- ->willReturn($result['cookie']['domain']);
-
$this->assertEquals($result, $this->imagesStorage->uploadFile($targetPath, $type));
}
}
diff --git a/app/code/Magento/Cms/composer.json b/app/code/Magento/Cms/composer.json
index ea31f1bda59b2..64e97e0a38e18 100644
--- a/app/code/Magento/Cms/composer.json
+++ b/app/code/Magento/Cms/composer.json
@@ -18,7 +18,7 @@
"magento/module-cms-sample-data": "Sample Data version:100.2.*"
},
"type": "magento2-module",
- "version": "102.0.5",
+ "version": "102.0.6",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml b/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml
index 1bc8828ef6c8e..5bf66ef302f04 100644
--- a/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml
+++ b/app/code/Magento/Cms/view/adminhtml/layout/cms_wysiwyg_images_index.xml
@@ -9,7 +9,11 @@
-
+
+
+ Magento\Backend\Block\DataProviders\UploadConfig
+
+
diff --git a/app/code/Magento/Cms/view/adminhtml/templates/browser/content/uploader.phtml b/app/code/Magento/Cms/view/adminhtml/templates/browser/content/uploader.phtml
index f87dc07dc04f4..27f14434b5fcf 100644
--- a/app/code/Magento/Cms/view/adminhtml/templates/browser/content/uploader.phtml
+++ b/app/code/Magento/Cms/view/adminhtml/templates/browser/content/uploader.phtml
@@ -7,6 +7,14 @@
// @codingStandardsIgnoreFile
/** @var $block \Magento\Cms\Block\Adminhtml\Wysiwyg\Images\Content\Uploader */
+
+$resizeConfig = $block->getImageUploadConfigData()->getIsResizeEnabled()
+ ? "{action: 'resize', maxWidth: "
+ . $block->getImageUploadMaxWidth()
+ . ", maxHeight: "
+ . $block->getImageUploadMaxHeight()
+ . "}"
+ : "{action: 'resize'}";
?>
@@ -99,11 +107,9 @@ require([
action: 'load',
fileTypes: /^image\/(gif|jpeg|png)$/,
maxFileSize: = (int) $block->getFileSizeService()->getMaxFileSize() ?> * 10
- }, {
- action: 'resize',
- maxWidth: = (int) $block->getImageUploadMaxWidth() ?> ,
- maxHeight: = (int) $block->getImageUploadMaxHeight() ?>
- }, {
+ },
+ = $block->escapeHtml($resizeConfig) ?>,
+ {
action: 'save'
}]
});
diff --git a/app/code/Magento/CmsUrlRewrite/Test/Mftf/composer.json b/app/code/Magento/CmsUrlRewrite/Test/Mftf/composer.json
deleted file mode 100644
index ba91c4d901431..0000000000000
--- a/app/code/Magento/CmsUrlRewrite/Test/Mftf/composer.json
+++ /dev/null
@@ -1,19 +0,0 @@
-{
- "name": "magento/functional-test-module-cms-url-rewrite",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-cms": "100.0.0-dev",
- "magento/functional-test-module-url-rewrite": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/CmsUrlRewrite/composer.json b/app/code/Magento/CmsUrlRewrite/composer.json
index e86f4c073db74..414dcdf54921d 100644
--- a/app/code/Magento/CmsUrlRewrite/composer.json
+++ b/app/code/Magento/CmsUrlRewrite/composer.json
@@ -9,7 +9,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
- "version": "100.2.1",
+ "version": "100.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Config/App/Config/Type/System.php b/app/code/Magento/Config/App/Config/Type/System.php
index f5d109b198d5a..83c61f90f789a 100644
--- a/app/code/Magento/Config/App/Config/Type/System.php
+++ b/app/code/Magento/Config/App/Config/Type/System.php
@@ -11,6 +11,8 @@
use Magento\Framework\App\Config\Spi\PreProcessorInterface;
use Magento\Framework\App\ObjectManager;
use Magento\Config\App\Config\Type\System\Reader;
+use Magento\Framework\Serialize\Serializer\Sensitive as SensitiveSerializer;
+use Magento\Framework\Serialize\Serializer\SensitiveFactory as SensitiveSerializerFactory;
use Magento\Framework\App\ScopeInterface;
use Magento\Framework\Cache\FrontendInterface;
use Magento\Framework\Serialize\SerializerInterface;
@@ -44,7 +46,7 @@ class System implements ConfigTypeInterface
private $cache;
/**
- * @var SerializerInterface
+ * @var SensitiveSerializer
*/
private $serializer;
@@ -79,7 +81,9 @@ class System implements ConfigTypeInterface
* @param int $cachingNestedLevel
* @param string $configType
* @param Reader $reader
+ * @param SensitiveSerializerFactory|null $sensitiveFactory
*
+ * @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
@@ -91,13 +95,21 @@ public function __construct(
PreProcessorInterface $preProcessor,
$cachingNestedLevel = 1,
$configType = self::CONFIG_TYPE,
- Reader $reader = null
+ Reader $reader = null,
+ SensitiveSerializerFactory $sensitiveFactory = null
) {
$this->postProcessor = $postProcessor;
$this->cache = $cache;
- $this->serializer = $serializer;
$this->configType = $configType;
- $this->reader = $reader ?: ObjectManager::getInstance()->get(Reader::class);
+ $this->reader = $reader ?: ObjectManager::getInstance()
+ ->get(Reader::class);
+ $sensitiveFactory = $sensitiveFactory ?? ObjectManager::getInstance()
+ ->get(SensitiveSerializerFactory::class);
+ //Using sensitive serializer because any kind of information may
+ //be stored in configs.
+ $this->serializer = $sensitiveFactory->create(
+ ['serializer' => $serializer]
+ );
}
/**
diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field/Datetime.php b/app/code/Magento/Config/Block/System/Config/Form/Field/Datetime.php
index 63dbb2b80e334..acf830f363ce6 100644
--- a/app/code/Magento/Config/Block/System/Config/Form/Field/Datetime.php
+++ b/app/code/Magento/Config/Block/System/Config/Form/Field/Datetime.php
@@ -40,7 +40,7 @@ public function __construct(
protected function _getElementHtml(AbstractElement $element)
{
return $this->dateTimeFormatter->formatObject(
- $this->_localeDate->date(intval($element->getValue())),
+ $this->_localeDate->date((int) $element->getValue()),
$this->_localeDate->getDateTimeFormat(\IntlDateFormatter::MEDIUM)
);
}
diff --git a/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php b/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php
index 7f21bf4b92bf4..40ff76ee0e885 100644
--- a/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php
+++ b/app/code/Magento/Config/Block/System/Config/Form/Field/Notification.php
@@ -44,6 +44,6 @@ protected function _getElementHtml(AbstractElement $element)
$format = $this->_localeDate->getDateTimeFormat(
\IntlDateFormatter::MEDIUM
);
- return $this->dateTimeFormatter->formatObject($this->_localeDate->date(intval($element->getValue())), $format);
+ return $this->dateTimeFormatter->formatObject($this->_localeDate->date((int)$element->getValue()), $format);
}
}
diff --git a/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php b/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php
index 582f87508089f..aeb57010e4969 100644
--- a/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php
+++ b/app/code/Magento/Config/Console/Command/ConfigShow/ValueProcessor.php
@@ -97,7 +97,7 @@ public function process($scope, $scopeCode, $value, $path)
$field = $configStructure->getElementByConfigPath($path);
/** @var Value $backendModel */
- $backendModel = $field && $field->hasBackendModel()
+ $backendModel = $field instanceof Field && $field->hasBackendModel()
? $field->getBackendModel()
: $this->configValueFactory->create();
diff --git a/app/code/Magento/Config/Model/Config.php b/app/code/Magento/Config/Model/Config.php
index c6e2412f7e58f..0472c5daa276f 100644
--- a/app/code/Magento/Config/Model/Config.php
+++ b/app/code/Magento/Config/Model/Config.php
@@ -237,13 +237,14 @@ private function getField(string $sectionId, string $groupId, string $fieldId):
* Get field path
*
* @param Field $field
+ * @param string $fieldId Need for support of clone_field feature
* @param array &$oldConfig Need for compatibility with _processGroup()
* @param array &$extraOldGroups Need for compatibility with _processGroup()
* @return string
*/
- private function getFieldPath(Field $field, array &$oldConfig, array &$extraOldGroups): string
+ private function getFieldPath(Field $field, string $fieldId, array &$oldConfig, array &$extraOldGroups): string
{
- $path = $field->getGroupPath() . '/' . $field->getId();
+ $path = $field->getGroupPath() . '/' . $fieldId;
/**
* Look for custom defined field path
@@ -303,7 +304,7 @@ private function getChangedPaths(
if (isset($groupData['fields'])) {
foreach ($groupData['fields'] as $fieldId => $fieldData) {
$field = $this->getField($sectionId, $groupId, $fieldId);
- $path = $this->getFieldPath($field, $oldConfig, $extraOldGroups);
+ $path = $this->getFieldPath($field, $fieldId, $oldConfig, $extraOldGroups);
if ($this->isValueChanged($oldConfig, $path, $fieldData)) {
$changedPaths[] = $path;
}
@@ -398,7 +399,7 @@ protected function _processGroup(
$backendModel->addData($data);
$this->_checkSingleStoreMode($field, $backendModel);
- $path = $this->getFieldPath($field, $extraOldGroups, $oldConfig);
+ $path = $this->getFieldPath($field, $fieldId, $extraOldGroups, $oldConfig);
$backendModel->setPath($path)->setValue($fieldData['value']);
$inherit = !empty($fieldData['inherit']);
diff --git a/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php b/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php
index 3f80e01802b8d..e0e1525fd04cc 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Currency/Cron.php
@@ -59,14 +59,14 @@ public function afterSave()
$frequencyMonthly = \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY;
$cronExprArray = [
- intval($time[1]), # Minute
- intval($time[0]), # Hour
+ (int)$time[1], # Minute
+ (int)$time[0], # Hour
$frequency == $frequencyMonthly ? '1' : '*', # Day of the Month
'*', # Month of the Year
$frequency == $frequencyWeekly ? '1' : '*', # Day of the Week
];
- $cronExprString = join(' ', $cronExprArray);
+ $cronExprString = implode(' ', $cronExprArray);
try {
/** @var $configValue \Magento\Framework\App\Config\ValueInterface */
diff --git a/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php b/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php
index 3c36baf6f31f4..163124eae1204 100644
--- a/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php
+++ b/app/code/Magento/Config/Model/Config/Backend/Log/Cron.php
@@ -73,13 +73,13 @@ public function afterSave()
if ($enabled) {
$cronExprArray = [
- intval($time[1]), # Minute
- intval($time[0]), # Hour
+ (int)$time[1], # Minute
+ (int)$time[0], # Hour
$frequency == $frequencyMonthly ? '1' : '*', # Day of the Month
'*', # Month of the Year
$frequency == $frequencyWeekly ? '1' : '*', # Day of the Week
];
- $cronExprString = join(' ', $cronExprArray);
+ $cronExprString = implode(' ', $cronExprArray);
} else {
$cronExprString = '';
}
diff --git a/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php b/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php
index 2733847bab1d0..e615678550108 100644
--- a/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php
+++ b/app/code/Magento/Config/Model/Config/Structure/Mapper/Sorting.php
@@ -62,10 +62,6 @@ protected function _cmp($elementA, $elementB)
$sortIndexB = (float)$elementB['sortOrder'];
}
- if ($sortIndexA == $sortIndexB) {
- return 0;
- }
-
- return $sortIndexA < $sortIndexB ? -1 : 1;
+ return $sortIndexA <=> $sortIndexB;
}
}
diff --git a/app/code/Magento/Config/Test/Mftf/Section/GeneralSection.xml b/app/code/Magento/Config/Test/Mftf/Section/GeneralSection.xml
index d67f0c3f243d8..18a124ac669ec 100644
--- a/app/code/Magento/Config/Test/Mftf/Section/GeneralSection.xml
+++ b/app/code/Magento/Config/Test/Mftf/Section/GeneralSection.xml
@@ -15,7 +15,7 @@
-
+
diff --git a/app/code/Magento/Config/Test/Mftf/composer.json b/app/code/Magento/Config/Test/Mftf/composer.json
deleted file mode 100644
index a464a84b98d85..0000000000000
--- a/app/code/Magento/Config/Test/Mftf/composer.json
+++ /dev/null
@@ -1,23 +0,0 @@
-{
- "name": "magento/functional-test-module-config",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/magento2-functional-testing-framework": "2.2.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-cron": "100.0.0-dev",
- "magento/functional-test-module-email": "100.0.0-dev",
- "magento/functional-test-module-directory": "100.0.0-dev",
- "magento/functional-test-module-backend": "100.0.0-dev",
- "magento/functional-test-module-media-storage": "100.0.0-dev",
- "magento/functional-test-module-deploy": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php
index 40aa110382ede..9ca4e6138babe 100644
--- a/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php
+++ b/app/code/Magento/Config/Test/Unit/App/Config/Type/SystemTest.php
@@ -11,6 +11,8 @@
use Magento\Framework\App\Config\Spi\PostProcessorInterface;
use Magento\Framework\App\Config\Spi\PreProcessorInterface;
use Magento\Framework\Cache\FrontendInterface;
+use Magento\Framework\Serialize\Serializer\Sensitive;
+use Magento\Framework\Serialize\Serializer\SensitiveFactory;
use Magento\Framework\Serialize\SerializerInterface;
use Magento\Store\Model\Config\Processor\Fallback;
use Magento\Config\App\Config\Type\System\Reader;
@@ -74,22 +76,34 @@ public function setUp()
->getMockForAbstractClass();
$this->preProcessor = $this->getMockBuilder(PreProcessorInterface::class)
->getMockForAbstractClass();
- $this->serializer = $this->getMockBuilder(SerializerInterface::class)
+ $this->serializer = $this->getMockBuilder(Sensitive::class)
+ ->disableOriginalConstructor()
->getMock();
$this->reader = $this->getMockBuilder(Reader::class)
->disableOriginalConstructor()
->getMock();
+ $sensitiveFactory = $this->getMockBuilder(SensitiveFactory::class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ $sensitiveFactory->expects($this->any())
+ ->method('create')
+ ->willReturn($this->serializer);
+ /** @var SerializerInterface|\PHPUnit_Framework_MockObject_MockObject $serializerMock */
+ $serializerMock = $this->getMockBuilder(SerializerInterface::class)
+ ->disableOriginalConstructor()
+ ->getMock();
$this->configType = new System(
$this->source,
$this->postProcessor,
$this->fallback,
$this->cache,
- $this->serializer,
+ $serializerMock,
$this->preProcessor,
1,
'system',
- $this->reader
+ $this->reader,
+ $sensitiveFactory
);
}
@@ -133,49 +147,4 @@ public function testGetCachedWithLoadAllData()
->willReturn($data);
$this->assertEquals($data, $this->configType->get(''));
}
-
- public function testGetNotCached()
- {
- $path = 'stores/default/dev/unsecure/url';
- $url = 'http://magento.test/';
-
- $dataToCache = [
- 'unsecure' => [
- 'url' => $url
- ]
- ];
- $data = [
- 'default' => [],
- 'websites' => [],
- 'stores' => [
- 'default' => [
- 'dev' => [
- 'unsecure' => [
- 'url' => $url
- ]
- ]
- ]
- ]
- ];
- $this->cache->expects($this->any())
- ->method('load')
- ->willReturnOnConsecutiveCalls(false, false);
-
- $this->serializer->expects($this->atLeastOnce())
- ->method('serialize')
- ->willReturn(serialize($dataToCache));
- $this->cache->expects($this->atLeastOnce())
- ->method('save')
- ->willReturnSelf();
- $this->reader->expects($this->once())
- ->method('read')
- ->willReturn($data);
- $this->postProcessor->expects($this->once())
- ->method('process')
- ->with($data)
- ->willReturn($data);
-
- $this->assertEquals($url, $this->configType->get($path));
- $this->assertEquals($url, $this->configType->get($path));
- }
}
diff --git a/app/code/Magento/Config/composer.json b/app/code/Magento/Config/composer.json
index 1201c5942b558..e43c9b0382e25 100644
--- a/app/code/Magento/Config/composer.json
+++ b/app/code/Magento/Config/composer.json
@@ -13,7 +13,7 @@
"magento/module-deploy": "100.2.*"
},
"type": "magento2-module",
- "version": "101.0.5",
+ "version": "101.0.6",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/ConfigurableImportExport/Test/Mftf/composer.json b/app/code/Magento/ConfigurableImportExport/Test/Mftf/composer.json
deleted file mode 100644
index 0ee8e8ad235c5..0000000000000
--- a/app/code/Magento/ConfigurableImportExport/Test/Mftf/composer.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "magento/functional-test-module-configurable-import-export",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-catalog": "100.0.0-dev",
- "magento/functional-test-module-catalog-import-export": "100.0.0-dev",
- "magento/functional-test-module-eav": "100.0.0-dev",
- "magento/functional-test-module-import-export": "100.0.0-dev",
- "magento/functional-test-module-configurable-product": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/ConfigurableImportExport/composer.json b/app/code/Magento/ConfigurableImportExport/composer.json
index 10e6637e7558a..b2070fe7ebc44 100644
--- a/app/code/Magento/ConfigurableImportExport/composer.json
+++ b/app/code/Magento/ConfigurableImportExport/composer.json
@@ -11,7 +11,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
- "version": "100.2.2",
+ "version": "100.2.3",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php
index a6bec4ac6274f..c4cbed58f1587 100644
--- a/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php
+++ b/app/code/Magento/ConfigurableProduct/Model/Product/Type/Configurable/Attribute.php
@@ -18,7 +18,7 @@
class Attribute extends \Magento\Framework\Model\AbstractExtensibleModel implements
\Magento\ConfigurableProduct\Api\Data\OptionInterface
{
- /**#@+
+ /**
* Constants for field names
*/
const KEY_ATTRIBUTE_ID = 'attribute_id';
@@ -27,9 +27,10 @@ class Attribute extends \Magento\Framework\Model\AbstractExtensibleModel impleme
const KEY_IS_USE_DEFAULT = 'is_use_default';
const KEY_VALUES = 'values';
const KEY_PRODUCT_ID = 'product_id';
- /**#@-*/
- /**#@-*/
+ /**
+ * @var MetadataPool|\Magento\Framework\EntityManager\MetadataPool
+ */
private $metadataPool;
/**
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml
new file mode 100644
index 0000000000000..75686d23a11b9
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/AdminCreateApiConfigurableProductActionGroup.xml
@@ -0,0 +1,65 @@
+
+
+
+
+
+
+
+
+
+
+
+ {{productName}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
index 83e0aa1deaedf..a2f824dd8864e 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductData.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
configurable
configurable
@@ -38,4 +38,15 @@
EavStockItem
CustomAttributeCategoryIds
+
+ api-configurable-product-with-out-category
+ configurable
+ 4
+ 4
+ API Configurable Product
+ api-configurable-product
+ 1
+ 100
+ EavStockItem
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductOptionData.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductOptionData.xml
index 21dcf998a6399..e98175bc8d40b 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductOptionData.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ConfigurableProductOptionData.xml
@@ -7,11 +7,18 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
option
ValueIndex1
ValueIndex2
+
+
+ option
+ ValueIndex1
+ ValueIndex2
+ ValueIndex3
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ValueIndexData.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ValueIndexData.xml
index 54d489a446fd7..e1cd70790a6b2 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ValueIndexData.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Data/ValueIndexData.xml
@@ -7,11 +7,14 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml
index 5dcbfbaf44037..a1e3e0b83e722 100644
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontConfigurableProductWithFileCustomOptionTest.xml
@@ -12,7 +12,7 @@
-
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontSortingByPriceForConfigurableWithCatalogRuleAppliedTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontSortingByPriceForConfigurableWithCatalogRuleAppliedTest.xml
new file mode 100644
index 0000000000000..c8ca2ced0d60f
--- /dev/null
+++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/StorefrontSortingByPriceForConfigurableWithCatalogRuleAppliedTest.xml
@@ -0,0 +1,156 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 5.00
+
+
+
+ 10.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 15.00
+
+
+
+
+ 20.00
+
+
+
+
+ 25.00
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/composer.json b/app/code/Magento/ConfigurableProduct/Test/Mftf/composer.json
deleted file mode 100644
index d8da8e39013a1..0000000000000
--- a/app/code/Magento/ConfigurableProduct/Test/Mftf/composer.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "name": "magento/functional-test-module-configurable-product",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-catalog": "100.0.0-dev",
- "magento/functional-test-module-catalog-inventory": "100.0.0-dev",
- "magento/functional-test-module-checkout": "100.0.0-dev",
- "magento/functional-test-module-msrp": "100.0.0-dev",
- "magento/functional-test-module-backend": "100.0.0-dev",
- "magento/functional-test-module-eav": "100.0.0-dev",
- "magento/functional-test-module-customer": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0",
- "magento/functional-test-module-media-storage": "100.0.0-dev",
- "magento/functional-test-module-quote": "100.0.0-dev",
- "magento/functional-test-module-ui": "100.0.0-dev"
- },
- "suggest": {
- "magento/functional-test-module-webapi": "100.0.0-dev",
- "magento/functional-test-module-sales": "100.0.0-dev",
- "magento/functional-test-module-product-video": "100.0.0-dev",
- "magento/functional-test-module-configurable-sample-data": "100.0.0-dev",
- "magento/functional-test-module-product-links-sample-data": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/ConfigurableProduct/composer.json b/app/code/Magento/ConfigurableProduct/composer.json
index 4c583d79ce418..eae9dac046b23 100644
--- a/app/code/Magento/ConfigurableProduct/composer.json
+++ b/app/code/Magento/ConfigurableProduct/composer.json
@@ -19,12 +19,13 @@
"suggest": {
"magento/module-webapi": "100.2.*",
"magento/module-sales": "101.0.*",
+ "magento/module-sales-rule": "101.0.*",
"magento/module-product-video": "100.2.*",
"magento/module-configurable-sample-data": "Sample Data version:100.2.*",
"magento/module-product-links-sample-data": "Sample Data version:100.2.*"
},
"type": "magento2-module",
- "version": "100.2.5",
+ "version": "100.2.6",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/ConfigurableProduct/etc/di.xml b/app/code/Magento/ConfigurableProduct/etc/di.xml
index dfbad0dd5a764..1dbb0969687d5 100644
--- a/app/code/Magento/ConfigurableProduct/etc/di.xml
+++ b/app/code/Magento/ConfigurableProduct/etc/di.xml
@@ -228,4 +228,11 @@
+
+
+
+ - false
+
+
+
diff --git a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
index 8cabe71c17504..6b6c1762fadd9 100644
--- a/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
+++ b/app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js
@@ -360,7 +360,11 @@ define([
index = 1,
allowedProducts,
i,
- j;
+ j,
+ basePrice = parseFloat(this.options.spConfig.prices.basePrice.amount),
+ optionFinalPrice,
+ optionPriceDiff,
+ optionPrices = this.options.spConfig.optionPrices;
this._clearSelect(element);
element.options[0] = new Option('', '');
@@ -374,6 +378,7 @@ define([
if (options) {
for (i = 0; i < options.length; i++) {
allowedProducts = [];
+ optionPriceDiff = 0;
/* eslint-disable max-depth */
if (prevConfig) {
@@ -387,6 +392,20 @@ define([
}
} else {
allowedProducts = options[i].products.slice(0);
+
+ if (typeof allowedProducts[0] !== 'undefined' &&
+ typeof optionPrices[allowedProducts[0]] !== 'undefined') {
+
+ optionFinalPrice = parseFloat(optionPrices[allowedProducts[0]].finalPrice.amount);
+ optionPriceDiff = optionFinalPrice - basePrice;
+
+ if (optionPriceDiff !== 0) {
+ options[i].label = options[i].label + ' ' + priceUtils.formatPrice(
+ optionPriceDiff,
+ this.options.priceFormat,
+ true);
+ }
+ }
}
if (allowedProducts.length > 0) {
@@ -394,7 +413,7 @@ define([
element.options[index] = new Option(this._getOptionLabel(options[i]), options[i].id);
if (typeof options[i].price !== 'undefined') {
- element.options[index].setAttribute('price', options[i].prices);
+ element.options[index].setAttribute('price', options[i].price);
}
element.options[index].config = options[i];
diff --git a/app/code/Magento/ConfigurableProductSales/Test/Mftf/composer.json b/app/code/Magento/ConfigurableProductSales/Test/Mftf/composer.json
deleted file mode 100644
index 21dbce122386f..0000000000000
--- a/app/code/Magento/ConfigurableProductSales/Test/Mftf/composer.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
- "name": "magento/functional-test-module-configurable-product-sales",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-catalog": "100.0.0-dev",
- "magento/functional-test-module-sales": "100.0.0-dev",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "suggest": {
- "magento/functional-test-module-configurable-product": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/ConfigurableProductSales/composer.json b/app/code/Magento/ConfigurableProductSales/composer.json
index d1fbc142b627f..ca6638924b8c6 100644
--- a/app/code/Magento/ConfigurableProductSales/composer.json
+++ b/app/code/Magento/ConfigurableProductSales/composer.json
@@ -12,7 +12,7 @@
"magento/module-configurable-product": "100.2.*"
},
"type": "magento2-module",
- "version": "100.2.2",
+ "version": "100.2.3",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Contact/Test/Mftf/composer.json b/app/code/Magento/Contact/Test/Mftf/composer.json
deleted file mode 100644
index bdfb3265948ac..0000000000000
--- a/app/code/Magento/Contact/Test/Mftf/composer.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "magento/functional-test-module-contact",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-config": "100.0.0-dev",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-customer": "100.0.0-dev",
- "magento/functional-test-module-cms": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/Contact/composer.json b/app/code/Magento/Contact/composer.json
index 9ceca3bdfa80b..49ac8ec40dbc4 100644
--- a/app/code/Magento/Contact/composer.json
+++ b/app/code/Magento/Contact/composer.json
@@ -10,7 +10,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
- "version": "100.2.2",
+ "version": "100.2.3",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Cookie/Test/Mftf/composer.json b/app/code/Magento/Cookie/Test/Mftf/composer.json
deleted file mode 100644
index d65a11f025000..0000000000000
--- a/app/code/Magento/Cookie/Test/Mftf/composer.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "magento/functional-test-module-cookie",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "suggest": {
- "magento/functional-test-module-backend": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/Cookie/composer.json b/app/code/Magento/Cookie/composer.json
index 23bd37234f939..cc04b0ccd5d7d 100644
--- a/app/code/Magento/Cookie/composer.json
+++ b/app/code/Magento/Cookie/composer.json
@@ -10,7 +10,7 @@
"magento/module-backend": "100.2.*"
},
"type": "magento2-module",
- "version": "100.2.1",
+ "version": "100.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php
index 2fc0f0ab4c1a0..87618785adb1d 100644
--- a/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php
+++ b/app/code/Magento/Cron/Model/Config/Backend/Product/Alert.php
@@ -72,14 +72,14 @@ public function afterSave()
$frequency = $this->getData('groups/productalert_cron/fields/frequency/value');
$cronExprArray = [
- intval($time[1]), //Minute
- intval($time[0]), //Hour
+ (int)$time[1], //Minute
+ (int)$time[0], //Hour
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', //Day of the Month
'*', //Month of the Year
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*', //Day of the Week
];
- $cronExprString = join(' ', $cronExprArray);
+ $cronExprString = implode(' ', $cronExprArray);
try {
$this->_configValueFactory->create()->load(
diff --git a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php
index 681129916647d..31d8ba59ee42d 100644
--- a/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php
+++ b/app/code/Magento/Cron/Model/Config/Backend/Sitemap.php
@@ -70,8 +70,8 @@ public function afterSave()
$frequency = $this->getData('groups/generate/fields/frequency/value');
$cronExprArray = [
- intval($time[1]), //Minute
- intval($time[0]), //Hour
+ (int)$time[1], //Minute
+ (int)$time[0], //Hour
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_MONTHLY ? '1' : '*', //Day of the Month
'*', //Month of the Year
$frequency == \Magento\Cron\Model\Config\Source\Frequency::CRON_WEEKLY ? '1' : '*', //# Day of the Week
diff --git a/app/code/Magento/Cron/Test/Mftf/composer.json b/app/code/Magento/Cron/Test/Mftf/composer.json
deleted file mode 100644
index cdee4efef8a24..0000000000000
--- a/app/code/Magento/Cron/Test/Mftf/composer.json
+++ /dev/null
@@ -1,20 +0,0 @@
-{
- "name": "magento/functional-test-module-cron",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "suggest": {
- "magento/functional-test-module-config": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/Cron/Test/Unit/Model/System/Config/Initial/ConverterTest.php b/app/code/Magento/Cron/Test/Unit/Model/System/Config/Initial/ConverterTest.php
new file mode 100644
index 0000000000000..703926b4c0116
--- /dev/null
+++ b/app/code/Magento/Cron/Test/Unit/Model/System/Config/Initial/ConverterTest.php
@@ -0,0 +1,89 @@
+groupsConfigMock = $this->getMockBuilder(
+ GroupsConfigModel::class
+ )->disableOriginalConstructor()->getMock();
+ $this->converterMock = $this->getMockBuilder(Converter::class)->getMock();
+ $this->converterPlugin = new ConverterPlugin($this->groupsConfigMock);
+ }
+
+ /**
+ * Tests afterConvert method with no $result['data']['default']['system'] set
+ */
+ public function testAfterConvertWithNoData()
+ {
+ $expectedResult = ['test'];
+ $this->groupsConfigMock->expects($this->never())
+ ->method('get');
+
+ $result = $this->converterPlugin->afterConvert($this->converterMock, $expectedResult);
+
+ self::assertSame($expectedResult, $result);
+ }
+
+ /**
+ * Tests afterConvert method with $result['data']['default']['system'] set
+ */
+ public function testAfterConvertWithData()
+ {
+ $groups = [
+ 'group1' => ['val1' => ['value' => '1']],
+ 'group2' => ['val2' => ['value' => '2']]
+ ];
+ $expectedResult['data']['default']['system']['cron'] = [
+ 'group1' => [
+ 'val1' => '1'
+ ],
+ 'group2' => [
+ 'val2' => '2'
+ ]
+ ];
+ $result['data']['default']['system']['cron'] = '1';
+
+ $this->groupsConfigMock->expects($this->once())
+ ->method('get')
+ ->willReturn($groups);
+
+ $result = $this->converterPlugin->afterConvert($this->converterMock, $result);
+
+ self::assertEquals($expectedResult, $result);
+ }
+}
diff --git a/app/code/Magento/Cron/composer.json b/app/code/Magento/Cron/composer.json
index 5faf1d15e7782..a8c124dc57207 100644
--- a/app/code/Magento/Cron/composer.json
+++ b/app/code/Magento/Cron/composer.json
@@ -10,7 +10,7 @@
"magento/module-config": "101.0.*"
},
"type": "magento2-module",
- "version": "100.2.3",
+ "version": "100.2.4",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Cron/etc/di.xml b/app/code/Magento/Cron/etc/di.xml
index a37f3760b70a5..3e3bdc2053576 100644
--- a/app/code/Magento/Cron/etc/di.xml
+++ b/app/code/Magento/Cron/etc/di.xml
@@ -16,6 +16,18 @@
+
+
+ /var/log/cron.log
+
+
+
+
+
+ - Magento\Cron\Model\VirtualLoggerHandler
+
+
+
@@ -25,6 +37,7 @@
shellBackground
+ Magento\Cron\Model\VirtualLogger
diff --git a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php
index fcde688a1e145..518e7fcf4181f 100644
--- a/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php
+++ b/app/code/Magento/CurrencySymbol/Model/System/Currencysymbol.php
@@ -192,9 +192,11 @@ public function getCurrencySymbolsData()
*/
public function setCurrencySymbolsData($symbols = [])
{
- foreach ($this->getCurrencySymbolsData() as $code => $values) {
- if (isset($symbols[$code]) && ($symbols[$code] == $values['parentSymbol'] || empty($symbols[$code]))) {
- unset($symbols[$code]);
+ if (!$this->_storeManager->isSingleStoreMode()) {
+ foreach ($this->getCurrencySymbolsData() as $code => $values) {
+ if (isset($symbols[$code]) && ($symbols[$code] == $values['parentSymbol'] || empty($symbols[$code]))) {
+ unset($symbols[$code]);
+ }
}
}
$value = [];
diff --git a/app/code/Magento/CurrencySymbol/Test/Mftf/composer.json b/app/code/Magento/CurrencySymbol/Test/Mftf/composer.json
deleted file mode 100644
index e6815bb61a2d3..0000000000000
--- a/app/code/Magento/CurrencySymbol/Test/Mftf/composer.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "magento/functional-test-module-currency-symbol",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-config": "100.0.0-dev",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-page-cache": "100.0.0-dev",
- "magento/functional-test-module-directory": "100.0.0-dev",
- "magento/functional-test-module-backend": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/CurrencySymbol/composer.json b/app/code/Magento/CurrencySymbol/composer.json
index 3afa8c6338378..da76425436038 100644
--- a/app/code/Magento/CurrencySymbol/composer.json
+++ b/app/code/Magento/CurrencySymbol/composer.json
@@ -11,7 +11,7 @@
"magento/framework": "101.0.*"
},
"type": "magento2-module",
- "version": "100.2.1",
+ "version": "100.2.2",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml b/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml
index 0ba3c7ed2d7d6..6e9b9a396ec2f 100644
--- a/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml
+++ b/app/code/Magento/CurrencySymbol/view/adminhtml/templates/grid.phtml
@@ -23,10 +23,9 @@
name="custom_currency_symbol[= /* @escapeNotVerified */ $code ?>]">
diff --git a/app/code/Magento/Customer/Api/AccountManagementInterface.php b/app/code/Magento/Customer/Api/AccountManagementInterface.php
index d2f9fb7ebc420..0bda1fc4bb815 100644
--- a/app/code/Magento/Customer/Api/AccountManagementInterface.php
+++ b/app/code/Magento/Customer/Api/AccountManagementInterface.php
@@ -7,6 +7,8 @@
namespace Magento\Customer\Api;
+use Magento\Framework\Exception\InputException;
+
/**
* Interface for managing customers accounts.
* @api
@@ -144,19 +146,24 @@ public function initiatePasswordReset($email, $template, $websiteId = null);
/**
* Reset customer password.
*
- * @param string $email
+ * @param string $email If empty value given then the customer
+ * will be matched by the RP token.
* @param string $resetToken
* @param string $newPassword
+ *
* @return bool true on success
* @throws \Magento\Framework\Exception\LocalizedException
+ * @throws InputException
*/
public function resetPassword($email, $resetToken, $newPassword);
/**
* Check if password reset token is valid.
*
- * @param int $customerId
+ * @param int $customerId If 0 is given then a customer
+ * will be matched by the RP token.
* @param string $resetPasswordLinkToken
+ *
* @return bool True if the token is valid
* @throws \Magento\Framework\Exception\State\InputMismatchException If token is mismatched
* @throws \Magento\Framework\Exception\State\ExpiredException If token is expired
diff --git a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php
index 81b7b8b3f96b5..c7023d0404f75 100644
--- a/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php
+++ b/app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php
@@ -461,7 +461,7 @@ protected function getOnlineMinutesInterval()
'customer/online_customers/online_minutes_interval',
\Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
- return intval($configValue) > 0 ? intval($configValue) : self::DEFAULT_ONLINE_MINUTES_INTERVAL;
+ return (int)$configValue > 0 ? (int)$configValue : self::DEFAULT_ONLINE_MINUTES_INTERVAL;
}
/**
diff --git a/app/code/Magento/Customer/Controller/Account/CreatePassword.php b/app/code/Magento/Customer/Controller/Account/CreatePassword.php
index fb2e3dd42908b..a86f42c14a027 100644
--- a/app/code/Magento/Customer/Controller/Account/CreatePassword.php
+++ b/app/code/Magento/Customer/Controller/Account/CreatePassword.php
@@ -54,27 +54,30 @@ public function __construct(
public function execute()
{
$resetPasswordToken = (string)$this->getRequest()->getParam('token');
- $customerId = (int)$this->getRequest()->getParam('id');
- $isDirectLink = $resetPasswordToken != '' && $customerId != 0;
+ $isDirectLink = $resetPasswordToken != '';
if (!$isDirectLink) {
$resetPasswordToken = (string)$this->session->getRpToken();
- $customerId = (int)$this->session->getRpCustomerId();
}
try {
- $this->accountManagement->validateResetPasswordLinkToken($customerId, $resetPasswordToken);
+ $this->accountManagement->validateResetPasswordLinkToken(
+ 0,
+ $resetPasswordToken
+ );
if ($isDirectLink) {
$this->session->setRpToken($resetPasswordToken);
- $this->session->setRpCustomerId($customerId);
$resultRedirect = $this->resultRedirectFactory->create();
$resultRedirect->setPath('*/*/createpassword');
+
return $resultRedirect;
} else {
/** @var \Magento\Framework\View\Result\Page $resultPage */
$resultPage = $this->resultPageFactory->create();
- $resultPage->getLayout()->getBlock('resetPassword')->setCustomerId($customerId)
+ $resultPage->getLayout()
+ ->getBlock('resetPassword')
->setResetPasswordLinkToken($resetPasswordToken);
+
return $resultPage;
}
} catch (\Exception $exception) {
diff --git a/app/code/Magento/Customer/Controller/Account/EditPost.php b/app/code/Magento/Customer/Controller/Account/EditPost.php
index 3f895ad2f17ac..da0ad29c5c72f 100644
--- a/app/code/Magento/Customer/Controller/Account/EditPost.php
+++ b/app/code/Magento/Customer/Controller/Account/EditPost.php
@@ -20,6 +20,7 @@
use Magento\Framework\Exception\InputException;
use Magento\Framework\Exception\InvalidEmailOrPasswordException;
use Magento\Framework\Exception\State\UserLockedException;
+use Magento\Framework\Escaper;
/**
* Class EditPost
@@ -72,6 +73,9 @@ class EditPost extends \Magento\Customer\Controller\AbstractAccount
*/
private $customerMapper;
+ /** @var Escaper */
+ private $escaper;
+
/**
* @param Context $context
* @param Session $customerSession
@@ -79,6 +83,7 @@ class EditPost extends \Magento\Customer\Controller\AbstractAccount
* @param CustomerRepositoryInterface $customerRepository
* @param Validator $formKeyValidator
* @param CustomerExtractor $customerExtractor
+ * @param Escaper|null $escaper
*/
public function __construct(
Context $context,
@@ -86,7 +91,8 @@ public function __construct(
AccountManagementInterface $customerAccountManagement,
CustomerRepositoryInterface $customerRepository,
Validator $formKeyValidator,
- CustomerExtractor $customerExtractor
+ CustomerExtractor $customerExtractor,
+ Escaper $escaper = null
) {
parent::__construct($context);
$this->session = $customerSession;
@@ -94,6 +100,7 @@ public function __construct(
$this->customerRepository = $customerRepository;
$this->formKeyValidator = $formKeyValidator;
$this->customerExtractor = $customerExtractor;
+ $this->escaper = $escaper ?: ObjectManager::getInstance()->get(Escaper::class);
}
/**
@@ -175,9 +182,9 @@ public function execute()
$this->messageManager->addError($message);
return $resultRedirect->setPath('customer/account/login');
} catch (InputException $e) {
- $this->messageManager->addError($e->getMessage());
+ $this->messageManager->addErrorMessage($this->escaper->escapeHtml($e->getMessage()));
foreach ($e->getErrors() as $error) {
- $this->messageManager->addError($error->getMessage());
+ $this->messageManager->addErrorMessage($this->escaper->escapeHtml($error->getMessage()));
}
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addError($e->getMessage());
diff --git a/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php b/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php
index 3de44e35d2447..ab6944a995d84 100644
--- a/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php
+++ b/app/code/Magento/Customer/Controller/Account/ResetPasswordPost.php
@@ -12,7 +12,6 @@
use Magento\Framework\App\Action\Context;
use Magento\Framework\Exception\InputException;
use Magento\Customer\Model\Customer\CredentialsValidator;
-use Magento\Framework\App\ObjectManager;
class ResetPasswordPost extends \Magento\Customer\Controller\AbstractAccount
{
@@ -31,17 +30,14 @@ class ResetPasswordPost extends \Magento\Customer\Controller\AbstractAccount
*/
protected $session;
- /**
- * @var CredentialsValidator
- */
- private $credentialsValidator;
-
/**
* @param Context $context
* @param Session $customerSession
* @param AccountManagementInterface $accountManagement
* @param CustomerRepositoryInterface $customerRepository
* @param CredentialsValidator|null $credentialsValidator
+ *
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function __construct(
Context $context,
@@ -53,8 +49,6 @@ public function __construct(
$this->session = $customerSession;
$this->accountManagement = $accountManagement;
$this->customerRepository = $customerRepository;
- $this->credentialsValidator = $credentialsValidator ?: ObjectManager::getInstance()
- ->get(CredentialsValidator::class);
parent::__construct($context);
}
@@ -70,27 +64,33 @@ public function execute()
/** @var \Magento\Framework\Controller\Result\Redirect $resultRedirect */
$resultRedirect = $this->resultRedirectFactory->create();
$resetPasswordToken = (string)$this->getRequest()->getQuery('token');
- $customerId = (int)$this->getRequest()->getQuery('id');
$password = (string)$this->getRequest()->getPost('password');
$passwordConfirmation = (string)$this->getRequest()->getPost('password_confirmation');
if ($password !== $passwordConfirmation) {
$this->messageManager->addError(__("New Password and Confirm New Password values didn't match."));
- $resultRedirect->setPath('*/*/createPassword', ['id' => $customerId, 'token' => $resetPasswordToken]);
+ $resultRedirect->setPath(
+ '*/*/createPassword',
+ ['token' => $resetPasswordToken]
+ );
return $resultRedirect;
}
if (iconv_strlen($password) <= 0) {
$this->messageManager->addError(__('Please enter a new password.'));
- $resultRedirect->setPath('*/*/createPassword', ['id' => $customerId, 'token' => $resetPasswordToken]);
+ $resultRedirect->setPath(
+ '*/*/createPassword',
+ ['token' => $resetPasswordToken]
+ );
return $resultRedirect;
}
try {
- $customerEmail = $this->customerRepository->getById($customerId)->getEmail();
- $this->credentialsValidator->checkPasswordDifferentFromEmail($customerEmail, $password);
- $this->accountManagement->resetPassword($customerEmail, $resetPasswordToken, $password);
+ $this->accountManagement->resetPassword(
+ '',
+ $resetPasswordToken,
+ $password
+ );
$this->session->unsRpToken();
- $this->session->unsRpCustomerId();
$this->messageManager->addSuccess(__('You updated your password.'));
$resultRedirect->setPath('*/*/login');
return $resultRedirect;
@@ -102,7 +102,11 @@ public function execute()
} catch (\Exception $exception) {
$this->messageManager->addError(__('Something went wrong while saving the new password.'));
}
- $resultRedirect->setPath('*/*/createPassword', ['id' => $customerId, 'token' => $resetPasswordToken]);
+
+ $resultRedirect->setPath(
+ '*/*/createPassword',
+ ['token' => $resetPasswordToken]
+ );
return $resultRedirect;
}
}
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php
index e26b49aaebe7a..6b80cd5b3a6a5 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/AbstractMassAction.php
@@ -10,6 +10,7 @@
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\Controller\ResultInterface;
use Magento\Backend\App\Action\Context;
+use Magento\Framework\Exception\NotFoundException;
use Magento\Ui\Component\MassAction\Filter;
use Magento\Customer\Model\ResourceModel\Customer\CollectionFactory;
@@ -60,6 +61,10 @@ public function __construct(Context $context, Filter $filter, CollectionFactory
*/
public function execute()
{
+ if (!$this->getRequest()->isPost()) {
+ throw new NotFoundException(__('Page not found'));
+ }
+
try {
$collection = $this->filter->getCollection($this->collectionFactory->create());
return $this->massAction($collection);
diff --git a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php
index 2d0ee3ae13da4..6753a48d02d6a 100644
--- a/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php
+++ b/app/code/Magento/Customer/Controller/Adminhtml/Index/InlineEdit.php
@@ -6,13 +6,15 @@
namespace Magento\Customer\Controller\Adminhtml\Index;
use Magento\Backend\App\Action;
+use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\EmailNotificationInterface;
-use Magento\Customer\Test\Block\Form\Login;
use Magento\Customer\Ui\Component\Listing\AttributeRepository;
-use Magento\Customer\Api\Data\CustomerInterface;
-use Magento\Customer\Api\CustomerRepositoryInterface;
+use Magento\Framework\Message\MessageInterface;
/**
+ * Customer inline edit action
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class InlineEdit extends \Magento\Backend\App\Action
@@ -101,7 +103,11 @@ private function getEmailNotification()
}
/**
+ * Inline edit action execute
+ *
* @return \Magento\Framework\Controller\Result\Json
+ * @throws \Magento\Framework\Exception\LocalizedException
+ * @throws \Magento\Framework\Exception\NoSuchEntityException
*/
public function execute()
{
@@ -249,7 +255,7 @@ protected function processAddressData(array $data)
protected function getErrorMessages()
{
$messages = [];
- foreach ($this->getMessageManager()->getMessages()->getItems() as $error) {
+ foreach ($this->getMessageManager()->getMessages()->getErrors() as $error) {
$messages[] = $error->getText();
}
return $messages;
@@ -262,7 +268,7 @@ protected function getErrorMessages()
*/
protected function isErrorExists()
{
- return (bool)$this->getMessageManager()->getMessages(true)->getCount();
+ return (bool)$this->getMessageManager()->getMessages(true)->getCountByType(MessageInterface::TYPE_ERROR);
}
/**
diff --git a/app/code/Magento/Customer/Controller/Section/Load.php b/app/code/Magento/Customer/Controller/Section/Load.php
index 7a2345c91750c..e37461d20f5de 100644
--- a/app/code/Magento/Customer/Controller/Section/Load.php
+++ b/app/code/Magento/Customer/Controller/Section/Load.php
@@ -70,11 +70,11 @@ public function execute()
$sectionNames = $this->getRequest()->getParam('sections');
$sectionNames = $sectionNames ? array_unique(\explode(',', $sectionNames)) : null;
- $updateSectionId = $this->getRequest()->getParam('update_section_id');
- if ('false' === $updateSectionId) {
- $updateSectionId = false;
+ $forceNewSectionTimestamp = $this->getRequest()->getParam('force_new_section_timestamp');
+ if ('false' === $forceNewSectionTimestamp) {
+ $forceNewSectionTimestamp = false;
}
- $response = $this->sectionPool->getSectionsData($sectionNames, (bool)$updateSectionId);
+ $response = $this->sectionPool->getSectionsData($sectionNames, (bool)$forceNewSectionTimestamp);
} catch (\Exception $e) {
$resultJson->setStatusHeader(
\Zend\Http\Response::STATUS_CODE_400,
diff --git a/app/code/Magento/Customer/CustomerData/Section/Identifier.php b/app/code/Magento/Customer/CustomerData/Section/Identifier.php
index 2a770925d1c37..54d7cee2d90bd 100644
--- a/app/code/Magento/Customer/CustomerData/Section/Identifier.php
+++ b/app/code/Magento/Customer/CustomerData/Section/Identifier.php
@@ -43,12 +43,12 @@ public function __construct(
/**
* Init mark(identifier) for sections
*
- * @param bool $forceUpdate
+ * @param bool $forceNewTimestamp
* @return int
*/
- public function initMark($forceUpdate)
+ public function initMark($forceNewTimestamp)
{
- if ($forceUpdate) {
+ if ($forceNewTimestamp) {
$this->markId = time();
return $this->markId;
}
@@ -68,18 +68,18 @@ public function initMark($forceUpdate)
*
* @param array $sectionsData
* @param null $sectionNames
- * @param bool $updateIds
+ * @param bool $forceNewTimestamp
* @return array
*/
- public function markSections(array $sectionsData, $sectionNames = null, $updateIds = false)
+ public function markSections(array $sectionsData, $sectionNames = null, $forceNewTimestamp = false)
{
if (!$sectionNames) {
$sectionNames = array_keys($sectionsData);
}
- $markId = $this->initMark($updateIds);
+ $markId = $this->initMark($forceNewTimestamp);
foreach ($sectionNames as $name) {
- if ($updateIds || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
+ if ($forceNewTimestamp || !array_key_exists(self::SECTION_KEY, $sectionsData[$name])) {
$sectionsData[$name][self::SECTION_KEY] = $markId;
}
}
diff --git a/app/code/Magento/Customer/CustomerData/SectionPool.php b/app/code/Magento/Customer/CustomerData/SectionPool.php
index 26e9140c63df5..be5ea09c0db33 100644
--- a/app/code/Magento/Customer/CustomerData/SectionPool.php
+++ b/app/code/Magento/Customer/CustomerData/SectionPool.php
@@ -55,10 +55,10 @@ public function __construct(
/**
* {@inheritdoc}
*/
- public function getSectionsData(array $sectionNames = null, $updateIds = false)
+ public function getSectionsData(array $sectionNames = null, $forceNewTimestamp = false)
{
$sectionsData = $sectionNames ? $this->getSectionDataByNames($sectionNames) : $this->getAllSectionData();
- $sectionsData = $this->identifier->markSections($sectionsData, $sectionNames, $updateIds);
+ $sectionsData = $this->identifier->markSections($sectionsData, $sectionNames, $forceNewTimestamp);
return $sectionsData;
}
diff --git a/app/code/Magento/Customer/CustomerData/SectionPoolInterface.php b/app/code/Magento/Customer/CustomerData/SectionPoolInterface.php
index c308804fd0f8d..ad73b9722b133 100644
--- a/app/code/Magento/Customer/CustomerData/SectionPoolInterface.php
+++ b/app/code/Magento/Customer/CustomerData/SectionPoolInterface.php
@@ -14,8 +14,8 @@ interface SectionPoolInterface
* Get section data by section names. If $sectionNames is null then return all sections data
*
* @param array $sectionNames
- * @param bool $updateIds
+ * @param bool $forceNewTimestamp
* @return array
*/
- public function getSectionsData(array $sectionNames = null, $updateIds = false);
+ public function getSectionsData(array $sectionNames = null, $forceNewTimestamp = false);
}
diff --git a/app/code/Magento/Customer/Model/AccountManagement.php b/app/code/Magento/Customer/Model/AccountManagement.php
index 35684241faac1..8f2565189ef4c 100644
--- a/app/code/Magento/Customer/Model/AccountManagement.php
+++ b/app/code/Magento/Customer/Model/AccountManagement.php
@@ -19,6 +19,7 @@
use Magento\Customer\Model\Metadata\Validator;
use Magento\Eav\Model\Validator\Attribute\Backend;
use Magento\Framework\Api\ExtensibleDataObjectConverter;
+use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\App\Area;
use Magento\Framework\App\Config\ScopeConfigInterface;
use Magento\Framework\App\ObjectManager;
@@ -40,6 +41,7 @@
use Magento\Framework\Intl\DateTimeFactory;
use Magento\Framework\Mail\Template\TransportBuilder;
use Magento\Framework\Math\Random;
+use Magento\Framework\Phrase;
use Magento\Framework\Reflection\DataObjectProcessor;
use Magento\Framework\Registry;
use Magento\Framework\Stdlib\DateTime;
@@ -325,6 +327,11 @@ class AccountManagement implements AccountManagementInterface
*/
private $accountConfirmation;
+ /**
+ * @var SearchCriteriaBuilder
+ */
+ private $searchCriteriaBuilder;
+
/**
* @param CustomerFactory $customerFactory
* @param ManagerInterface $eventManager
@@ -356,6 +363,7 @@ class AccountManagement implements AccountManagementInterface
* @param SessionManagerInterface|null $sessionManager
* @param SaveHandlerInterface|null $saveHandler
* @param CollectionFactory|null $visitorCollectionFactory
+ * @param SearchCriteriaBuilder|null $searchCriteriaBuilder
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
*/
public function __construct(
@@ -387,7 +395,8 @@ public function __construct(
AccountConfirmation $accountConfirmation = null,
SessionManagerInterface $sessionManager = null,
SaveHandlerInterface $saveHandler = null,
- CollectionFactory $visitorCollectionFactory = null
+ CollectionFactory $visitorCollectionFactory = null,
+ SearchCriteriaBuilder $searchCriteriaBuilder = null
) {
$this->customerFactory = $customerFactory;
$this->eventManager = $eventManager;
@@ -423,6 +432,8 @@ public function __construct(
?: ObjectManager::getInstance()->get(SaveHandlerInterface::class);
$this->visitorCollectionFactory = $visitorCollectionFactory
?: ObjectManager::getInstance()->get(CollectionFactory::class);
+ $this->searchCriteriaBuilder = $searchCriteriaBuilder
+ ?: ObjectManager::getInstance()->get(SearchCriteriaBuilder::class);
}
/**
@@ -596,14 +607,62 @@ public function initiatePasswordReset($email, $template, $websiteId = null)
return false;
}
+ /**
+ * Match a customer by their RP token.
+ *
+ * @param string $rpToken
+ * @throws ExpiredException
+ * @throws NoSuchEntityException
+ *
+ * @return CustomerInterface
+ */
+ private function matchCustomerByRpToken(string $rpToken): CustomerInterface
+ {
+
+ $this->searchCriteriaBuilder->addFilter(
+ 'rp_token',
+ $rpToken
+ );
+ $this->searchCriteriaBuilder->setPageSize(1);
+ $found = $this->customerRepository->getList(
+ $this->searchCriteriaBuilder->create()
+ );
+
+ if ($found->getTotalCount() > 1) {
+ //Failed to generated unique RP token
+ throw new ExpiredException(
+ new Phrase('Reset password token expired.')
+ );
+ }
+ if ($found->getTotalCount() === 0) {
+ //Customer with such token not found.
+ throw NoSuchEntityException::singleField(
+ 'rp_token',
+ $rpToken
+ );
+ }
+
+ //Unique customer found.
+ return $found->getItems()[0];
+ }
+
/**
* {@inheritdoc}
*/
public function resetPassword($email, $resetToken, $newPassword)
{
- $customer = $this->customerRepository->get($email);
+ if (!$email) {
+ $customer = $this->matchCustomerByRpToken($resetToken);
+ $email = $customer->getEmail();
+ } else {
+ $customer = $this->customerRepository->get($email);
+ }
//Validate Token and new password strength
$this->validateResetPasswordToken($customer->getId(), $resetToken);
+ $this->credentialsValidator->checkPasswordDifferentFromEmail(
+ $email,
+ $newPassword
+ );
$this->checkPasswordStrength($newPassword);
//Update secure data
$customerSecure = $this->customerRegistry->retrieveSecureData($customer->getId());
@@ -1012,12 +1071,9 @@ public function isCustomerInStore($customerWebsiteId, $storeId)
private function validateResetPasswordToken($customerId, $resetPasswordLinkToken)
{
if (empty($customerId) || $customerId < 0) {
- throw new InputException(
- __(
- 'Invalid value of "%value" provided for the %fieldName field.',
- ['value' => $customerId, 'fieldName' => 'customerId']
- )
- );
+ //Looking for the customer.
+ $customerId = $this->matchCustomerByRpToken($resetPasswordLinkToken)
+ ->getId();
}
if (!is_string($resetPasswordLinkToken) || empty($resetPasswordLinkToken)) {
$params = ['fieldName' => 'resetPasswordLinkToken'];
diff --git a/app/code/Magento/Customer/Model/Address.php b/app/code/Magento/Customer/Model/Address.php
index 1dcd8516af69f..c39420542248e 100644
--- a/app/code/Magento/Customer/Model/Address.php
+++ b/app/code/Magento/Customer/Model/Address.php
@@ -154,9 +154,6 @@ public function updateData(AddressInterface $address)
// Need to explicitly set this due to discrepancy in the keys between model and data object
$this->setIsDefaultBilling($address->isDefaultBilling());
$this->setIsDefaultShipping($address->isDefaultShipping());
- if (!$this->getAttributeSetId()) {
- $this->setAttributeSetId(AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS);
- }
$customAttributes = $address->getCustomAttributes();
if ($customAttributes !== null) {
foreach ($customAttributes as $attribute) {
diff --git a/app/code/Magento/Customer/Model/Customer.php b/app/code/Magento/Customer/Model/Customer.php
index e0a7281776de9..e359b904347ef 100644
--- a/app/code/Magento/Customer/Model/Customer.php
+++ b/app/code/Magento/Customer/Model/Customer.php
@@ -358,13 +358,6 @@ public function updateData($customer)
$this->setId($customerId);
}
- // Need to use attribute set or future updates can cause data loss
- if (!$this->getAttributeSetId()) {
- $this->setAttributeSetId(
- CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER
- );
- }
-
return $this;
}
@@ -960,6 +953,16 @@ public function getSharedWebsiteIds()
return $ids;
}
+ /**
+ * Retrieve attribute set id for customer.
+ *
+ * @return int
+ */
+ public function getAttributeSetId()
+ {
+ return parent::getAttributeSetId() ?: CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER;
+ }
+
/**
* Set store to customer
*
diff --git a/app/code/Magento/Customer/Model/GroupManagement.php b/app/code/Magento/Customer/Model/GroupManagement.php
index 47d7d7ad1ac41..48cb5d55061c5 100644
--- a/app/code/Magento/Customer/Model/GroupManagement.php
+++ b/app/code/Magento/Customer/Model/GroupManagement.php
@@ -8,16 +8,19 @@
namespace Magento\Customer\Model;
use Magento\Customer\Api\Data\GroupInterface;
+use Magento\Customer\Api\Data\GroupInterfaceFactory;
+use Magento\Customer\Api\GroupRepositoryInterface;
+use Magento\Framework\Api\FilterBuilder;
use Magento\Framework\Api\SearchCriteriaBuilder;
+use Magento\Framework\Api\SortOrderBuilder;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Framework\Api\FilterBuilder;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Store\Model\StoreManagerInterface;
-use Magento\Customer\Api\GroupRepositoryInterface;
-use Magento\Customer\Api\Data\GroupInterfaceFactory;
-use Magento\Customer\Model\GroupFactory;
/**
+ * The class contains methods for getting information about a customer group
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
@@ -65,6 +68,11 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
*/
protected $filterBuilder;
+ /**
+ * @var SortOrderBuilder
+ */
+ private $sortOrderBuilder;
+
/**
* @param StoreManagerInterface $storeManager
* @param ScopeConfigInterface $scopeConfig
@@ -73,6 +81,7 @@ class GroupManagement implements \Magento\Customer\Api\GroupManagementInterface
* @param GroupInterfaceFactory $groupDataFactory
* @param SearchCriteriaBuilder $searchCriteriaBuilder
* @param FilterBuilder $filterBuilder
+ * @param SortOrderBuilder $sortOrderBuilder
*/
public function __construct(
StoreManagerInterface $storeManager,
@@ -81,7 +90,8 @@ public function __construct(
GroupRepositoryInterface $groupRepository,
GroupInterfaceFactory $groupDataFactory,
SearchCriteriaBuilder $searchCriteriaBuilder,
- FilterBuilder $filterBuilder
+ FilterBuilder $filterBuilder,
+ SortOrderBuilder $sortOrderBuilder = null
) {
$this->storeManager = $storeManager;
$this->scopeConfig = $scopeConfig;
@@ -90,10 +100,12 @@ public function __construct(
$this->groupDataFactory = $groupDataFactory;
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->filterBuilder = $filterBuilder;
+ $this->sortOrderBuilder = $sortOrderBuilder ?: ObjectManager::getInstance()
+ ->get(SortOrderBuilder::class);
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function isReadonly($groupId)
{
@@ -107,7 +119,7 @@ public function isReadonly($groupId)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getDefaultGroup($storeId = null)
{
@@ -133,7 +145,7 @@ public function getDefaultGroup($storeId = null)
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getNotLoggedInGroup()
{
@@ -141,7 +153,7 @@ public function getNotLoggedInGroup()
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getLoggedInGroups()
{
@@ -155,15 +167,20 @@ public function getLoggedInGroups()
->setConditionType('neq')
->setValue(self::CUST_GROUP_ALL)
->create();
+ $groupNameSortOrder = $this->sortOrderBuilder
+ ->setField('customer_group_code')
+ ->setAscendingDirection()
+ ->create();
$searchCriteria = $this->searchCriteriaBuilder
->addFilters($notLoggedInFilter)
->addFilters($groupAll)
+ ->addSortOrder($groupNameSortOrder)
->create();
return $this->groupRepository->getList($searchCriteria)->getItems();
}
/**
- * {@inheritdoc}
+ * @inheritdoc
*/
public function getAllCustomersGroup()
{
diff --git a/app/code/Magento/Customer/Model/Renderer/Region.php b/app/code/Magento/Customer/Model/Renderer/Region.php
index 5c7fcd38d6c52..ad620e4e4b3f2 100644
--- a/app/code/Magento/Customer/Model/Renderer/Region.php
+++ b/app/code/Magento/Customer/Model/Renderer/Region.php
@@ -80,7 +80,7 @@ public function render(AbstractElement $element)
$regionCollection = self::$_regionCollections[$countryId];
}
- $regionId = intval($element->getForm()->getElement('region_id')->getValue());
+ $regionId = (int)$element->getForm()->getElement('region_id')->getValue();
$htmlAttributes = $element->getHtmlAttributes();
foreach ($htmlAttributes as $key => $attribute) {
diff --git a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php
index 12d9dc9bcaa22..29f97d9f643a7 100644
--- a/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php
+++ b/app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php
@@ -205,12 +205,6 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
$customerModel->setStoreId($this->storeManager->getStore()->getId());
}
- // Need to use attribute set or future updates can cause data loss
- if (!$customerModel->getAttributeSetId()) {
- $customerModel->setAttributeSetId(
- \Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER
- );
- }
$this->populateCustomerWithSecureData($customerModel, $passwordHash);
// If customer email was changed, reset RpToken info
diff --git a/app/code/Magento/Customer/Model/Visitor.php b/app/code/Magento/Customer/Model/Visitor.php
index a0530389f902a..d144b7f6b70ec 100644
--- a/app/code/Magento/Customer/Model/Visitor.php
+++ b/app/code/Magento/Customer/Model/Visitor.php
@@ -320,11 +320,9 @@ public function clean()
*/
public function getOnlineInterval()
{
- $configValue = intval(
- $this->scopeConfig->getValue(
- static::XML_PATH_ONLINE_INTERVAL,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE
- )
+ $configValue = (int)$this->scopeConfig->getValue(
+ static::XML_PATH_ONLINE_INTERVAL,
+ \Magento\Store\Model\ScopeInterface::SCOPE_STORE
);
return $configValue ?: static::DEFAULT_ONLINE_MINUTES_INTERVAL;
}
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminConfigCustomerActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminConfigCustomerActionGroup.xml
new file mode 100644
index 0000000000000..3fc25ecf57faa
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/AdminConfigCustomerActionGroup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/ActionGroup/CustomerActionGroup.xml b/app/code/Magento/Customer/Test/Mftf/ActionGroup/CustomerActionGroup.xml
index 085c944cd3d3b..6a253a6053076 100644
--- a/app/code/Magento/Customer/Test/Mftf/ActionGroup/CustomerActionGroup.xml
+++ b/app/code/Magento/Customer/Test/Mftf/ActionGroup/CustomerActionGroup.xml
@@ -18,4 +18,9 @@
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml b/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml
index e4420f189900e..c8ba70c7f8b50 100644
--- a/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
0
12
@@ -89,4 +89,17 @@
Yes
RegionNY
+
+ Jane
+ Doe
+ Magento
+
+ - 172, Westminster Bridge Rd
+
+ London
+
+ SE1 7RW
+ GB
+ 444-44-444-44
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml b/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml
new file mode 100644
index 0000000000000..d7fc22f085344
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Data/CustomerGroupData.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+ ApiCustomerGroup
+ 0
+ Retail Customer
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml b/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml
index 99741a357109e..9f31e5994eaae 100644
--- a/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Data/RegionData.xml
@@ -15,7 +15,7 @@
Texas
TX
- 1
+ 57
California
diff --git a/app/code/Magento/Customer/Test/Mftf/Metadata/customer-group-meta.xml b/app/code/Magento/Customer/Test/Mftf/Metadata/customer-group-meta.xml
new file mode 100644
index 0000000000000..a45bf1645d088
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Metadata/customer-group-meta.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+ application/json
+
+
+
+ application/json
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerConfigPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerConfigPage.xml
new file mode 100644
index 0000000000000..3cf8490ec4af1
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerConfigPage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerAddressPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerAddressPage.xml
new file mode 100644
index 0000000000000..bdbbcab67da67
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerAddressPage.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerDashboardPage.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerDashboardPage.xml
index 941e247e18b8c..788a23fb539c5 100644
--- a/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerDashboardPage.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerDashboardPage.xml
@@ -10,5 +10,6 @@
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/PageObject.xsd">
+
diff --git a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SampleTemplates/Page/TemplatePageFile.xml b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerSignOutPage.xml
similarity index 76%
rename from dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SampleTemplates/Page/TemplatePageFile.xml
rename to app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerSignOutPage.xml
index 3c4d85019fe54..4e89e5476c3bc 100644
--- a/dev/tests/acceptance/tests/functional/Magento/FunctionalTest/SampleTemplates/Page/TemplatePageFile.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Page/StorefrontCustomerSignOutPage.xml
@@ -8,7 +8,5 @@
-
-
-
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml
new file mode 100644
index 0000000000000..7eef792f0f048
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerAccountInformationSection.xml
@@ -0,0 +1,20 @@
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerConfigSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerConfigSection.xml
new file mode 100644
index 0000000000000..33696fbd616e3
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerConfigSection.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAddressesSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAddressesSection.xml
new file mode 100644
index 0000000000000..88b46d245105f
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerAddressesSection.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml
index c39dfef5f74e7..7957fa0350fa5 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderSection.xml
@@ -9,6 +9,7 @@
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderViewSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderViewSection.xml
index 52aa077fff8db..f6a6cb2d457e1 100644
--- a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderViewSection.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerOrderViewSection.xml
@@ -7,11 +7,14 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
diff --git a/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml
new file mode 100644
index 0000000000000..7482193031091
--- /dev/null
+++ b/app/code/Magento/Customer/Test/Mftf/Section/StorefrontCustomerSidebarSection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml
index e5dc187e8ab7a..8e4d69e6a270d 100644
--- a/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml
+++ b/app/code/Magento/Customer/Test/Mftf/Test/AdminCreateCustomerTest.xml
@@ -7,7 +7,7 @@
-->
+ xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
@@ -19,6 +19,9 @@
+
+
+
diff --git a/app/code/Magento/Customer/Test/Mftf/composer.json b/app/code/Magento/Customer/Test/Mftf/composer.json
deleted file mode 100644
index 4290fbad458c6..0000000000000
--- a/app/code/Magento/Customer/Test/Mftf/composer.json
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- "name": "magento/functional-test-module-customer",
- "description": "N/A",
- "config": {
- "sort-packages": true
- },
- "require": {
- "php": "~7.0.13|~7.1.0",
- "magento/functional-test-module-store": "100.0.0-dev",
- "magento/functional-test-module-eav": "100.0.0-dev",
- "magento/functional-test-module-directory": "100.0.0-dev",
- "magento/functional-test-module-catalog": "100.0.0-dev",
- "magento/functional-test-module-newsletter": "100.0.0-dev",
- "magento/functional-test-module-sales": "100.0.0-dev",
- "magento/functional-test-module-checkout": "100.0.0-dev",
- "magento/functional-test-module-wishlist": "100.0.0-dev",
- "magento/functional-test-module-theme": "100.0.0-dev",
- "magento/functional-test-module-backend": "100.0.0-dev",
- "magento/functional-test-module-review": "100.0.0-dev",
- "magento/functional-test-module-tax": "100.0.0-dev",
- "magento/functional-test-module-page-cache": "100.0.0-dev",
- "magento/magento2-functional-testing-framework": "2.2.0",
- "magento/functional-test-module-authorization": "100.0.0-dev",
- "magento/functional-test-module-integration": "100.0.0-dev",
- "magento/functional-test-module-media-storage": "100.0.0-dev",
- "magento/functional-test-module-ui": "100.0.0-dev",
- "magento/functional-test-module-config": "100.0.0-dev",
- "magento/functional-test-module-quote": "100.0.0-dev"
- },
- "suggest": {
- "magento/functional-test-module-cookie": "100.0.0-dev",
- "magento/functional-test-module-customer-sample-data": "100.0.0-dev"
- },
- "type": "magento2-test",
- "license": [
- "OSL-3.0",
- "AFL-3.0"
- ]
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php
deleted file mode 100644
index 77f41024ba02f..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Controller/Account/CreatePasswordTest.php
+++ /dev/null
@@ -1,233 +0,0 @@
-sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class)
- ->disableOriginalConstructor()
- ->setMethods(['setRpToken', 'setRpCustomerId', 'getRpToken', 'getRpCustomerId'])
- ->getMock();
- $this->pageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->accountManagementMock = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class)
- ->getMockForAbstractClass();
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
- ->getMockForAbstractClass();
- $this->redirectFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RedirectFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
- ->getMockForAbstractClass();
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->model = $this->objectManagerHelper->getObject(
- \Magento\Customer\Controller\Account\CreatePassword::class,
- [
- 'customerSession' => $this->sessionMock,
- 'resultPageFactory' => $this->pageFactoryMock,
- 'accountManagement' => $this->accountManagementMock,
- 'request' => $this->requestMock,
- 'resultRedirectFactory' => $this->redirectFactoryMock,
- 'messageManager' => $this->messageManagerMock,
- ]
- );
- }
-
- public function testExecuteWithLink()
- {
- $token = 'token';
- $customerId = '11';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getParam')
- ->willReturnMap(
- [
- ['token', null, $token],
- ['id', null, $customerId],
- ]
- );
-
- $this->accountManagementMock->expects($this->once())
- ->method('validateResetPasswordLinkToken')
- ->with($customerId, $token)
- ->willReturn(true);
-
- $this->sessionMock->expects($this->once())
- ->method('setRpToken')
- ->with($token);
- $this->sessionMock->expects($this->once())
- ->method('setRpCustomerId')
- ->with($customerId);
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/createpassword', [])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-
- public function testExecuteWithSession()
- {
- $token = 'token';
- $customerId = '11';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getParam')
- ->willReturnMap(
- [
- ['token', null, null],
- ['id', null, $customerId],
- ]
- );
-
- $this->sessionMock->expects($this->once())
- ->method('getRpToken')
- ->willReturn($token);
- $this->sessionMock->expects($this->once())
- ->method('getRpCustomerId')
- ->willReturn($customerId);
-
- $this->accountManagementMock->expects($this->once())
- ->method('validateResetPasswordLinkToken')
- ->with($customerId, $token)
- ->willReturn(true);
-
- /** @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject $pageMock */
- $pageMock = $this->getMockBuilder(\Magento\Framework\View\Result\Page::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->pageFactoryMock->expects($this->once())
- ->method('create')
- ->with(false, [])
- ->willReturn($pageMock);
-
- /** @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject $layoutMock */
- $layoutMock = $this->getMockBuilder(\Magento\Framework\View\Layout::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $pageMock->expects($this->once())
- ->method('getLayout')
- ->willReturn($layoutMock);
-
- /** @var \Magento\Customer\Block\Account\Resetpassword|\PHPUnit_Framework_MockObject_MockObject $layoutMock */
- $blockMock = $this->getMockBuilder(\Magento\Customer\Block\Account\Resetpassword::class)
- ->disableOriginalConstructor()
- ->setMethods(['setCustomerId', 'setResetPasswordLinkToken'])
- ->getMock();
-
- $layoutMock->expects($this->once())
- ->method('getBlock')
- ->with('resetPassword')
- ->willReturn($blockMock);
-
- $blockMock->expects($this->once())
- ->method('setCustomerId')
- ->with($customerId)
- ->willReturnSelf();
- $blockMock->expects($this->once())
- ->method('setResetPasswordLinkToken')
- ->with($token)
- ->willReturnSelf();
-
- $this->assertEquals($pageMock, $this->model->execute());
- }
-
- public function testExecuteWithException()
- {
- $token = 'token';
- $customerId = '11';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getParam')
- ->willReturnMap(
- [
- ['token', null, $token],
- ['id', null, null],
- ]
- );
-
- $this->sessionMock->expects($this->once())
- ->method('getRpToken')
- ->willReturn($token);
- $this->sessionMock->expects($this->once())
- ->method('getRpCustomerId')
- ->willReturn($customerId);
-
- $this->accountManagementMock->expects($this->once())
- ->method('validateResetPasswordLinkToken')
- ->with($customerId, $token)
- ->willThrowException(new \Exception('Exception.'));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with(__('Your password reset link has expired.'))
- ->willReturnSelf();
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/forgotpassword', [])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php
deleted file mode 100644
index b79ad008e5e44..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Controller/Account/ResetPasswordPostTest.php
+++ /dev/null
@@ -1,379 +0,0 @@
-sessionMock = $this->getMockBuilder(\Magento\Customer\Model\Session::class)
- ->disableOriginalConstructor()
- ->setMethods(['unsRpToken', 'unsRpCustomerId'])
- ->getMock();
- $this->pageFactoryMock = $this->getMockBuilder(\Magento\Framework\View\Result\PageFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->accountManagementMock = $this->getMockBuilder(\Magento\Customer\Api\AccountManagementInterface::class)
- ->getMockForAbstractClass();
- $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class)
- ->getMockForAbstractClass();
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\RequestInterface::class)
- ->setMethods(['getQuery', 'getPost'])
- ->getMockForAbstractClass();
- $this->redirectFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\RedirectFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->messageManagerMock = $this->getMockBuilder(\Magento\Framework\Message\ManagerInterface::class)
- ->getMockForAbstractClass();
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->model = $this->objectManagerHelper->getObject(
- \Magento\Customer\Controller\Account\ResetPasswordPost::class,
- [
- 'customerSession' => $this->sessionMock,
- 'resultPageFactory' => $this->pageFactoryMock,
- 'accountManagement' => $this->accountManagementMock,
- 'customerRepository' => $this->customerRepositoryMock,
- 'request' => $this->requestMock,
- 'resultRedirectFactory' => $this->redirectFactoryMock,
- 'messageManager' => $this->messageManagerMock,
- ]
- );
- }
-
- public function testExecute()
- {
- $token = 'token';
- $customerId = '11';
- $password = 'password';
- $passwordConfirmation = 'password';
- $email = 'email@email.com';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getQuery')
- ->willReturnMap(
- [
- ['token', $token],
- ['id', $customerId],
- ]
- );
- $this->requestMock->expects($this->exactly(2))
- ->method('getPost')
- ->willReturnMap(
- [
- ['password', $password],
- ['password_confirmation', $passwordConfirmation],
- ]
- );
-
- /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */
- $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMockForAbstractClass();
-
- $this->customerRepositoryMock->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customerMock);
-
- $customerMock->expects($this->once())
- ->method('getEmail')
- ->willReturn($email);
-
- $this->accountManagementMock->expects($this->once())
- ->method('resetPassword')
- ->with($email, $token, $password)
- ->willReturn(true);
-
- $this->sessionMock->expects($this->once())
- ->method('unsRpToken');
- $this->sessionMock->expects($this->once())
- ->method('unsRpCustomerId');
-
- $this->messageManagerMock->expects($this->once())
- ->method('addSuccess')
- ->with(__('You updated your password.'))
- ->willReturnSelf();
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/login', [])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-
- public function testExecuteWithException()
- {
- $token = 'token';
- $customerId = '11';
- $password = 'password';
- $passwordConfirmation = 'password';
- $email = 'email@email.com';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getQuery')
- ->willReturnMap(
- [
- ['token', $token],
- ['id', $customerId],
- ]
- );
- $this->requestMock->expects($this->exactly(2))
- ->method('getPost')
- ->willReturnMap(
- [
- ['password', $password],
- ['password_confirmation', $passwordConfirmation],
- ]
- );
-
- /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */
- $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMockForAbstractClass();
-
- $this->customerRepositoryMock->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customerMock);
-
- $customerMock->expects($this->once())
- ->method('getEmail')
- ->willReturn($email);
-
- $this->accountManagementMock->expects($this->once())
- ->method('resetPassword')
- ->with($email, $token, $password)
- ->willThrowException(new \Exception('Exception.'));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with(__('Something went wrong while saving the new password.'))
- ->willReturnSelf();
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/createPassword', ['id' => $customerId, 'token' => $token])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-
- /**
- * Test for InputException
- */
- public function testExecuteWithInputException()
- {
- $token = 'token';
- $customerId = '11';
- $password = 'password';
- $passwordConfirmation = 'password';
- $email = 'email@email.com';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getQuery')
- ->willReturnMap(
- [
- ['token', $token],
- ['id', $customerId],
- ]
- );
- $this->requestMock->expects($this->exactly(2))
- ->method('getPost')
- ->willReturnMap(
- [
- ['password', $password],
- ['password_confirmation', $passwordConfirmation],
- ]
- );
-
- /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customerMock */
- $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMockForAbstractClass();
-
- $this->customerRepositoryMock->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customerMock);
-
- $customerMock->expects($this->once())
- ->method('getEmail')
- ->willReturn($email);
-
- $this->accountManagementMock->expects($this->once())
- ->method('resetPassword')
- ->with($email, $token, $password)
- ->willThrowException(new \Magento\Framework\Exception\InputException(__('InputException.')));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with(__('InputException.'))
- ->willReturnSelf();
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/createPassword', ['id' => $customerId, 'token' => $token])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-
- public function testExecuteWithWrongConfirmation()
- {
- $token = 'token';
- $customerId = '11';
- $password = 'password';
- $passwordConfirmation = 'wrong_password';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getQuery')
- ->willReturnMap(
- [
- ['token', $token],
- ['id', $customerId],
- ]
- );
- $this->requestMock->expects($this->exactly(2))
- ->method('getPost')
- ->willReturnMap(
- [
- ['password', $password],
- ['password_confirmation', $passwordConfirmation],
- ]
- );
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with(__('New Password and Confirm New Password values didn\'t match.'))
- ->willReturnSelf();
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/createPassword', ['id' => $customerId, 'token' => $token])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-
- public function testExecuteWithEmptyPassword()
- {
- $token = 'token';
- $customerId = '11';
- $password = '';
- $passwordConfirmation = '';
-
- $this->requestMock->expects($this->exactly(2))
- ->method('getQuery')
- ->willReturnMap(
- [
- ['token', $token],
- ['id', $customerId],
- ]
- );
- $this->requestMock->expects($this->exactly(2))
- ->method('getPost')
- ->willReturnMap(
- [
- ['password', $password],
- ['password_confirmation', $passwordConfirmation],
- ]
- );
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with(__('Please enter a new password.'))
- ->willReturnSelf();
-
- /** @var Redirect|\PHPUnit_Framework_MockObject_MockObject $redirectMock */
- $redirectMock = $this->getMockBuilder(\Magento\Framework\Controller\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->redirectFactoryMock->expects($this->once())
- ->method('create')
- ->with([])
- ->willReturn($redirectMock);
-
- $redirectMock->expects($this->once())
- ->method('setPath')
- ->with('*/*/createPassword', ['id' => $customerId, 'token' => $token])
- ->willReturnSelf();
-
- $this->assertEquals($redirectMock, $this->model->execute());
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php
index 913c41070856e..78d9dd7003522 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/InlineEditTest.php
@@ -6,6 +6,7 @@
namespace Magento\Customer\Test\Unit\Controller\Adminhtml\Index;
use Magento\Customer\Model\EmailNotificationInterface;
+use Magento\Framework\Message\MessageInterface;
/**
* @SuppressWarnings(PHPMD.TooManyFields)
@@ -242,10 +243,11 @@ protected function prepareMocksForErrorMessagesProcessing()
->method('getMessages')
->willReturn($this->messageCollection);
$this->messageCollection->expects($this->once())
- ->method('getItems')
+ ->method('getErrors')
->willReturn([$this->message]);
$this->messageCollection->expects($this->once())
- ->method('getCount')
+ ->method('getCountByType')
+ ->with(MessageInterface::TYPE_ERROR)
->willReturn(1);
$this->message->expects($this->once())
->method('getText')
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php
deleted file mode 100644
index 884aab711d168..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassAssignGroupTest.php
+++ /dev/null
@@ -1,189 +0,0 @@
-contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class);
- $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class);
- $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class);
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
- ->disableOriginalConstructor()->getMock();
- $this->objectManagerMock = $this->createPartialMock(
- \Magento\Framework\ObjectManager\ObjectManager::class,
- ['create']
- );
- $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class);
- $this->customerCollectionMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->customerCollectionFactoryMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
- $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $resultFactoryMock->expects($this->any())
- ->method('create')
- ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
- ->willReturn($redirectMock);
-
- $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
-
- $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
- $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
- $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
- $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
- $this->contextMock->expects($this->any())
- ->method('getResultRedirectFactory')
- ->willReturn($resultRedirectFactory);
- $this->contextMock->expects($this->any())
- ->method('getResultFactory')
- ->willReturn($resultFactoryMock);
-
- $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class);
- $this->filterMock->expects($this->once())
- ->method('getCollection')
- ->with($this->customerCollectionMock)
- ->willReturnArgument(0);
- $this->customerCollectionFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->customerCollectionMock);
- $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class)
- ->getMockForAbstractClass();
- $this->massAction = $objectManagerHelper->getObject(
- \Magento\Customer\Controller\Adminhtml\Index\MassAssignGroup::class,
- [
- 'context' => $this->contextMock,
- 'filter' => $this->filterMock,
- 'collectionFactory' => $this->customerCollectionFactoryMock,
- 'customerRepository' => $this->customerRepositoryMock,
- ]
- );
- }
-
- public function testExecute()
- {
- $customersIds = [10, 11, 12];
- $customerMock = $this->getMockBuilder(
- \Magento\Customer\Api\Data\CustomerInterface::class
- )->getMockForAbstractClass();
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('getById')
- ->willReturnMap([[10, $customerMock], [11, $customerMock], [12, $customerMock]]);
-
- $this->messageManagerMock->expects($this->once())
- ->method('addSuccess')
- ->with(__('A total of %1 record(s) were updated.', count($customersIds)));
-
- $this->resultRedirectMock->expects($this->any())
- ->method('setPath')
- ->with('customer/*/index')
- ->willReturnSelf();
-
- $this->massAction->execute();
- }
-
- public function testExecuteWithException()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('getById')
- ->willThrowException(new \Exception('Some message.'));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with('Some message.');
-
- $this->massAction->execute();
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php
deleted file mode 100644
index 190ff2c06618f..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassDeleteTest.php
+++ /dev/null
@@ -1,187 +0,0 @@
-contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class);
- $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class);
- $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class);
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
- ->disableOriginalConstructor()->getMock();
- $this->objectManagerMock = $this->createPartialMock(
- \Magento\Framework\ObjectManager\ObjectManager::class,
- ['create']
- );
- $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class);
- $this->customerCollectionMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->customerCollectionFactoryMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
- $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $resultFactoryMock->expects($this->any())
- ->method('create')
- ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
- ->willReturn($redirectMock);
-
- $this->resultRedirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
-
- $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
- $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
- $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
- $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
- $this->contextMock->expects($this->any())
- ->method('getResultRedirectFactory')
- ->willReturn($resultRedirectFactory);
- $this->contextMock->expects($this->any())
- ->method('getResultFactory')
- ->willReturn($resultFactoryMock);
-
- $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class);
- $this->filterMock->expects($this->once())
- ->method('getCollection')
- ->with($this->customerCollectionMock)
- ->willReturnArgument(0);
- $this->customerCollectionFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->customerCollectionMock);
- $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class)
- ->getMockForAbstractClass();
- $this->massAction = $objectManagerHelper->getObject(
- \Magento\Customer\Controller\Adminhtml\Index\MassDelete::class,
- [
- 'context' => $this->contextMock,
- 'filter' => $this->filterMock,
- 'collectionFactory' => $this->customerCollectionFactoryMock,
- 'customerRepository' => $this->customerRepositoryMock,
- ]
- );
- }
-
- public function testExecute()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('deleteById')
- ->willReturnMap([[10, true], [11, true], [12, true]]);
-
- $this->messageManagerMock->expects($this->once())
- ->method('addSuccess')
- ->with(__('A total of %1 record(s) were deleted.', count($customersIds)));
-
- $this->resultRedirectMock->expects($this->any())
- ->method('setPath')
- ->with('customer/*/index')
- ->willReturnSelf();
-
- $this->massAction->execute();
- }
-
- public function testExecuteWithException()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('deleteById')
- ->willThrowException(new \Exception('Some message.'));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with('Some message.');
-
- $this->massAction->execute();
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php
deleted file mode 100644
index daf9c64fe7b7b..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassSubscribeTest.php
+++ /dev/null
@@ -1,203 +0,0 @@
-contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class);
- $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class);
- $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class);
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
- ->disableOriginalConstructor()->getMock();
- $this->objectManagerMock = $this->createPartialMock(
- \Magento\Framework\ObjectManager\ObjectManager::class,
- ['create']
- );
- $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class);
- $this->customerCollectionMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->customerCollectionFactoryMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $resultFactoryMock->expects($this->any())
- ->method('create')
- ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
- ->willReturn($redirectMock);
- $this->subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class);
- $subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class)
- ->setMethods(['create'])
- ->disableOriginalConstructor()
- ->getMock();
- $subscriberFactoryMock->expects($this->any())
- ->method('create')
- ->willReturn($this->subscriberMock);
-
- $this->resultRedirectMock = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class);
- $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
-
- $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
- $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
- $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
- $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
- $this->contextMock->expects($this->any())
- ->method('getResultRedirectFactory')
- ->willReturn($resultRedirectFactory);
- $this->contextMock->expects($this->any())
- ->method('getResultFactory')
- ->willReturn($resultFactoryMock);
-
- $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class);
- $this->filterMock->expects($this->once())
- ->method('getCollection')
- ->with($this->customerCollectionMock)
- ->willReturnArgument(0);
- $this->customerCollectionFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->customerCollectionMock);
- $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class)
- ->getMockForAbstractClass();
- $this->massAction = $objectManagerHelper->getObject(
- \Magento\Customer\Controller\Adminhtml\Index\MassSubscribe::class,
- [
- 'context' => $this->contextMock,
- 'filter' => $this->filterMock,
- 'collectionFactory' => $this->customerCollectionFactoryMock,
- 'customerRepository' => $this->customerRepositoryMock,
- 'subscriberFactory' => $subscriberFactoryMock,
- ]
- );
- }
-
- public function testExecute()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('getById')
- ->willReturnMap([[10, true], [11, true], [12, true]]);
-
- $this->subscriberMock->expects($this->any())
- ->method('subscribeCustomerById')
- ->willReturnMap([[10, true], [11, true], [12, true]]);
-
- $this->messageManagerMock->expects($this->once())
- ->method('addSuccess')
- ->with(__('A total of %1 record(s) were updated.', count($customersIds)));
-
- $this->resultRedirectMock->expects($this->any())
- ->method('setPath')
- ->with('customer/*/index')
- ->willReturnSelf();
-
- $this->massAction->execute();
- }
-
- public function testExecuteWithException()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('getById')
- ->willThrowException(new \Exception('Some message.'));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with('Some message.');
-
- $this->massAction->execute();
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php
deleted file mode 100644
index 05624661a2de4..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/MassUnsubscribeTest.php
+++ /dev/null
@@ -1,203 +0,0 @@
-contextMock = $this->createMock(\Magento\Backend\App\Action\Context::class);
- $resultRedirectFactory = $this->createMock(\Magento\Backend\Model\View\Result\RedirectFactory::class);
- $this->responseMock = $this->createMock(\Magento\Framework\App\ResponseInterface::class);
- $this->requestMock = $this->getMockBuilder(\Magento\Framework\App\Request\Http::class)
- ->disableOriginalConstructor()->getMock();
- $this->objectManagerMock = $this->createPartialMock(
- \Magento\Framework\ObjectManager\ObjectManager::class,
- ['create']
- );
- $this->messageManagerMock = $this->createMock(\Magento\Framework\Message\Manager::class);
- $this->customerCollectionMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\Collection::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->customerCollectionFactoryMock =
- $this->getMockBuilder(\Magento\Customer\Model\ResourceModel\Customer\CollectionFactory::class)
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $redirectMock = $this->getMockBuilder(\Magento\Backend\Model\View\Result\Redirect::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $resultFactoryMock = $this->getMockBuilder(\Magento\Framework\Controller\ResultFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
- $resultFactoryMock->expects($this->any())
- ->method('create')
- ->with(\Magento\Framework\Controller\ResultFactory::TYPE_REDIRECT)
- ->willReturn($redirectMock);
- $this->subscriberMock = $this->createMock(\Magento\Newsletter\Model\Subscriber::class);
- $subscriberFactoryMock = $this->getMockBuilder(\Magento\Newsletter\Model\SubscriberFactory::class)
- ->setMethods(['create'])
- ->disableOriginalConstructor()
- ->getMock();
- $subscriberFactoryMock->expects($this->any())
- ->method('create')
- ->willReturn($this->subscriberMock);
-
- $this->resultRedirectMock = $this->createMock(\Magento\Backend\Model\View\Result\Redirect::class);
- $resultRedirectFactory->expects($this->any())->method('create')->willReturn($this->resultRedirectMock);
-
- $this->contextMock->expects($this->once())->method('getMessageManager')->willReturn($this->messageManagerMock);
- $this->contextMock->expects($this->once())->method('getRequest')->willReturn($this->requestMock);
- $this->contextMock->expects($this->once())->method('getResponse')->willReturn($this->responseMock);
- $this->contextMock->expects($this->once())->method('getObjectManager')->willReturn($this->objectManagerMock);
- $this->contextMock->expects($this->any())
- ->method('getResultRedirectFactory')
- ->willReturn($resultRedirectFactory);
- $this->contextMock->expects($this->any())
- ->method('getResultFactory')
- ->willReturn($resultFactoryMock);
-
- $this->filterMock = $this->createMock(\Magento\Ui\Component\MassAction\Filter::class);
- $this->filterMock->expects($this->once())
- ->method('getCollection')
- ->with($this->customerCollectionMock)
- ->willReturnArgument(0);
- $this->customerCollectionFactoryMock->expects($this->once())
- ->method('create')
- ->willReturn($this->customerCollectionMock);
- $this->customerRepositoryMock = $this->getMockBuilder(\Magento\Customer\Api\CustomerRepositoryInterface::class)
- ->getMockForAbstractClass();
- $this->massAction = $objectManagerHelper->getObject(
- \Magento\Customer\Controller\Adminhtml\Index\MassUnsubscribe::class,
- [
- 'context' => $this->contextMock,
- 'filter' => $this->filterMock,
- 'collectionFactory' => $this->customerCollectionFactoryMock,
- 'customerRepository' => $this->customerRepositoryMock,
- 'subscriberFactory' => $subscriberFactoryMock,
- ]
- );
- }
-
- public function testExecute()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('getById')
- ->willReturnMap([[10, true], [11, true], [12, true]]);
-
- $this->subscriberMock->expects($this->any())
- ->method('unsubscribeCustomerById')
- ->willReturnMap([[10, true], [11, true], [12, true]]);
-
- $this->messageManagerMock->expects($this->once())
- ->method('addSuccess')
- ->with(__('A total of %1 record(s) were updated.', count($customersIds)));
-
- $this->resultRedirectMock->expects($this->any())
- ->method('setPath')
- ->with('customer/*/index')
- ->willReturnSelf();
-
- $this->massAction->execute();
- }
-
- public function testExecuteWithException()
- {
- $customersIds = [10, 11, 12];
-
- $this->customerCollectionMock->expects($this->any())
- ->method('getAllIds')
- ->willReturn($customersIds);
-
- $this->customerRepositoryMock->expects($this->any())
- ->method('getById')
- ->willThrowException(new \Exception('Some message.'));
-
- $this->messageManagerMock->expects($this->once())
- ->method('addError')
- ->with('Some message.');
-
- $this->massAction->execute();
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php b/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php
index 8fc4df1515b94..04da8e77867d8 100644
--- a/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Controller/Section/LoadTest.php
@@ -81,13 +81,13 @@ protected function setUp()
}
/**
- * @param $sectionNames
- * @param $updateSectionID
- * @param $sectionNamesAsArray
- * @param $updateIds
+ * @param string $sectionNames
+ * @param bool $forceNewSectionTimestamp
+ * @param string[] $sectionNamesAsArray
+ * @param bool $forceNewTimestamp
* @dataProvider executeDataProvider
*/
- public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArray, $updateIds)
+ public function testExecute($sectionNames, $forceNewSectionTimestamp, $sectionNamesAsArray, $forceNewTimestamp)
{
$this->resultJsonFactoryMock->expects($this->once())
->method('create')
@@ -101,12 +101,12 @@ public function testExecute($sectionNames, $updateSectionID, $sectionNamesAsArra
$this->httpRequestMock->expects($this->exactly(2))
->method('getParam')
- ->withConsecutive(['sections'], ['update_section_id'])
- ->willReturnOnConsecutiveCalls($sectionNames, $updateSectionID);
+ ->withConsecutive(['sections'], ['force_new_section_timestamp'])
+ ->willReturnOnConsecutiveCalls($sectionNames, $forceNewSectionTimestamp);
$this->sectionPoolMock->expects($this->once())
->method('getSectionsData')
- ->with($sectionNamesAsArray, $updateIds)
+ ->with($sectionNamesAsArray, $forceNewTimestamp)
->willReturn([
'message' => 'some message',
'someKey' => 'someValue'
@@ -131,15 +131,15 @@ public function executeDataProvider()
return [
[
'sectionNames' => 'sectionName1,sectionName2,sectionName3',
- 'updateSectionID' => 'updateSectionID',
+ 'forceNewSectionTimestamp' => 'forceNewSectionTimestamp',
'sectionNamesAsArray' => ['sectionName1', 'sectionName2', 'sectionName3'],
- 'updateIds' => true
+ 'forceNewTimestamp' => true
],
[
'sectionNames' => null,
- 'updateSectionID' => null,
+ 'forceNewSectionTimestamp' => null,
'sectionNamesAsArray' => null,
- 'updateIds' => false
+ 'forceNewTimestamp' => false
],
];
}
diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php
index 98fee70e335f7..2b67df1aee292 100644
--- a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php
+++ b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionPoolTest.php
@@ -63,7 +63,7 @@ public function testGetSectionsDataAllSections()
$this->identifierMock->expects($this->once())
->method('markSections')
- //check also default value for $updateIds = false
+ //check also default value for $forceTimestamp = false
->with($allSectionsData, $sectionNames, false)
->willReturn($identifierResult);
$modelResult = $this->model->getSectionsData($sectionNames);
diff --git a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php b/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php
deleted file mode 100644
index 525cb91cbb966..0000000000000
--- a/app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php
+++ /dev/null
@@ -1,1978 +0,0 @@
-customerFactory = $this->createPartialMock(\Magento\Customer\Model\CustomerFactory::class, ['create']);
- $this->manager = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
- $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->storeManager = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
- $this->random = $this->createMock(\Magento\Framework\Math\Random::class);
- $this->validator = $this->createMock(\Magento\Customer\Model\Metadata\Validator::class);
- $this->validationResultsInterfaceFactory = $this->createMock(
- \Magento\Customer\Api\Data\ValidationResultsInterfaceFactory::class
- );
- $this->addressRepository = $this->createMock(\Magento\Customer\Api\AddressRepositoryInterface::class);
- $this->customerMetadata = $this->createMock(\Magento\Customer\Api\CustomerMetadataInterface::class);
- $this->customerRegistry = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class);
- $this->logger = $this->createMock(\Psr\Log\LoggerInterface::class);
- $this->encryptor = $this->getMockBuilder(\Magento\Framework\Encryption\EncryptorInterface::class)
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
- $this->share = $this->createMock(\Magento\Customer\Model\Config\Share::class);
- $this->string = $this->createMock(\Magento\Framework\Stdlib\StringUtils::class);
- $this->customerRepository = $this->createMock(\Magento\Customer\Api\CustomerRepositoryInterface::class);
- $this->scopeConfig = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->transportBuilder = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class);
- $this->dataObjectProcessor = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class);
- $this->registry = $this->createMock(\Magento\Framework\Registry::class);
- $this->customerViewHelper = $this->createMock(\Magento\Customer\Helper\View::class);
- $this->dateTime = $this->createMock(\Magento\Framework\Stdlib\DateTime::class);
- $this->customer = $this->createMock(\Magento\Customer\Model\Customer::class);
- $this->objectFactory = $this->createMock(\Magento\Framework\DataObjectFactory::class);
- $this->extensibleDataObjectConverter = $this->createMock(
- \Magento\Framework\Api\ExtensibleDataObjectConverter::class
- );
- $this->authenticationMock = $this->getMockBuilder(AuthenticationInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->emailNotificationMock = $this->getMockBuilder(EmailNotificationInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class)
- ->setMethods(['setRpToken', 'addData', 'setRpTokenCreatedAt', 'setData', 'getPasswordHash'])
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->visitorCollectionFactory = $this->getMockBuilder(
- \Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory::class
- )
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $this->sessionManager = $this->getMockBuilder(\Magento\Framework\Session\SessionManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->saveHandler = $this->getMockBuilder(\Magento\Framework\Session\SaveHandlerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->dateTimeFactory = $this->createMock(DateTimeFactory::class);
- $this->accountConfirmation = $this->createMock(AccountConfirmation::class);
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->accountManagement = $this->objectManagerHelper->getObject(
- \Magento\Customer\Model\AccountManagement::class,
- [
- 'customerFactory' => $this->customerFactory,
- 'eventManager' => $this->manager,
- 'storeManager' => $this->storeManager,
- 'mathRandom' => $this->random,
- 'validator' => $this->validator,
- 'validationResultsDataFactory' => $this->validationResultsInterfaceFactory,
- 'addressRepository' => $this->addressRepository,
- 'customerMetadataService' => $this->customerMetadata,
- 'customerRegistry' => $this->customerRegistry,
- 'logger' => $this->logger,
- 'encryptor' => $this->encryptor,
- 'configShare' => $this->share,
- 'stringHelper' => $this->string,
- 'customerRepository' => $this->customerRepository,
- 'scopeConfig' => $this->scopeConfig,
- 'transportBuilder' => $this->transportBuilder,
- 'dataProcessor' => $this->dataObjectProcessor,
- 'registry' => $this->registry,
- 'customerViewHelper' => $this->customerViewHelper,
- 'dateTime' => $this->dateTime,
- 'customerModel' => $this->customer,
- 'objectFactory' => $this->objectFactory,
- 'extensibleDataObjectConverter' => $this->extensibleDataObjectConverter,
- 'dateTimeFactory' => $this->dateTimeFactory,
- 'accountConfirmation' => $this->accountConfirmation,
- 'sessionManager' => $this->sessionManager,
- 'saveHandler' => $this->saveHandler,
- 'visitorCollectionFactory' => $this->visitorCollectionFactory,
- ]
- );
- $reflection = new \ReflectionClass(get_class($this->accountManagement));
- $reflectionProperty = $reflection->getProperty('authentication');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->accountManagement, $this->authenticationMock);
- $reflectionProperty = $reflection->getProperty('emailNotification');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->accountManagement, $this->emailNotificationMock);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- */
- public function testCreateAccountWithPasswordHashWithExistingCustomer()
- {
- $websiteId = 1;
- $storeId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock();
- $website->expects($this->once())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->once())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->once())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->once())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share
- ->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager
- ->expects($this->once())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $this->accountManagement->createAccountWithPasswordHash($customer, $hash);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\State\InputMismatchException
- */
- public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId()
- {
- $websiteId = 1;
- $storeId = null;
- $defaultStoreId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
- $store->expects($this->once())
- ->method('getId')
- ->willReturn($defaultStoreId);
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock();
- $website->expects($this->once())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $website->expects($this->once())
- ->method('getDefaultStore')
- ->willReturn($store);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->once())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer->expects($this->once())
- ->method('setStoreId')
- ->with($defaultStoreId);
- $customer
- ->expects($this->once())
- ->method('getAddresses')
- ->willReturn([$address]);
- $customer
- ->expects($this->once())
- ->method('setAddresses')
- ->with(null);
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share
- ->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager
- ->expects($this->atLeastOnce())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $exception = new \Magento\Framework\Exception\AlreadyExistsException(
- new \Magento\Framework\Phrase('Exception message')
- );
- $this->customerRepository
- ->expects($this->once())
- ->method('save')
- ->with($customer, $hash)
- ->willThrowException($exception);
-
- $this->accountManagement->createAccountWithPasswordHash($customer, $hash);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
- public function testCreateAccountWithPasswordHashWithLocalizedException()
- {
- $websiteId = 1;
- $storeId = null;
- $defaultStoreId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
- $store->expects($this->once())
- ->method('getId')
- ->willReturn($defaultStoreId);
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock();
- $website->expects($this->once())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $website->expects($this->once())
- ->method('getDefaultStore')
- ->willReturn($store);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->once())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer->expects($this->once())
- ->method('setStoreId')
- ->with($defaultStoreId);
- $customer
- ->expects($this->once())
- ->method('getAddresses')
- ->willReturn([$address]);
- $customer
- ->expects($this->once())
- ->method('setAddresses')
- ->with(null);
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share
- ->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager
- ->expects($this->atLeastOnce())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $exception = new \Magento\Framework\Exception\LocalizedException(
- new \Magento\Framework\Phrase('Exception message')
- );
- $this->customerRepository
- ->expects($this->once())
- ->method('save')
- ->with($customer, $hash)
- ->willThrowException($exception);
-
- $this->accountManagement->createAccountWithPasswordHash($customer, $hash);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
- public function testCreateAccountWithPasswordHashWithAddressException()
- {
- $websiteId = 1;
- $storeId = null;
- $defaultStoreId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $address->expects($this->once())
- ->method('setCustomerId')
- ->with($customerId);
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
- $store->expects($this->once())
- ->method('getId')
- ->willReturn($defaultStoreId);
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock();
- $website->expects($this->once())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $website->expects($this->once())
- ->method('getDefaultStore')
- ->willReturn($store);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->once())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer->expects($this->once())
- ->method('setStoreId')
- ->with($defaultStoreId);
- $customer
- ->expects($this->once())
- ->method('getAddresses')
- ->willReturn([$address]);
- $customer
- ->expects($this->once())
- ->method('setAddresses')
- ->with(null);
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share
- ->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager
- ->expects($this->atLeastOnce())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $this->customerRepository
- ->expects($this->once())
- ->method('save')
- ->with($customer, $hash)
- ->willReturn($customer);
- $exception = new \Magento\Framework\Exception\InputException(
- new \Magento\Framework\Phrase('Exception message')
- );
- $this->addressRepository
- ->expects($this->atLeastOnce())
- ->method('save')
- ->with($address)
- ->willThrowException($exception);
- $this->customerRepository
- ->expects($this->once())
- ->method('delete')
- ->with($customer);
-
- $this->accountManagement->createAccountWithPasswordHash($customer, $hash);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
- public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedException()
- {
- $storeId = 1;
- $storeName = 'store_name';
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMockForAbstractClass();
-
- $customerMock->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn(null);
- $customerMock->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customerMock->expects($this->once())
- ->method('setCreatedIn')
- ->with($storeName)
- ->willReturnSelf();
- $customerMock->expects($this->once())
- ->method('getAddresses')
- ->willReturn([]);
- $customerMock->expects($this->once())
- ->method('setAddresses')
- ->with(null)
- ->willReturnSelf();
-
- $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $storeMock->expects($this->once())
- ->method('getName')
- ->willReturn($storeName);
-
- $this->storeManager->expects($this->exactly(2))
- ->method('getStore')
- ->with($storeId)
- ->willReturn($storeMock);
- $exception = new \Magento\Framework\Exception\LocalizedException(
- new \Magento\Framework\Phrase('Exception message')
- );
- $this->customerRepository
- ->expects($this->once())
- ->method('save')
- ->with($customerMock, $hash)
- ->willThrowException($exception);
-
- $this->accountManagement->createAccountWithPasswordHash($customerMock, $hash);
- }
-
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
- public function testCreateAccountWithoutPassword()
- {
- $websiteId = 1;
- $storeId = null;
- $defaultStoreId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu';
-
- $datetime = $this->prepareDateTimeFactory();
-
- $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $address->expects($this->once())
- ->method('setCustomerId')
- ->with($customerId);
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
- $store->expects($this->once())
- ->method('getId')
- ->willReturn($defaultStoreId);
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock();
- $website->expects($this->atLeastOnce())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $website->expects($this->once())
- ->method('getDefaultStore')
- ->willReturn($store);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->atLeastOnce())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer->expects($this->once())
- ->method('setStoreId')
- ->with($defaultStoreId);
- $customer->expects($this->once())
- ->method('getAddresses')
- ->willReturn([$address]);
- $customer->expects($this->once())
- ->method('setAddresses')
- ->with(null);
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager->expects($this->atLeastOnce())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $this->customerRepository->expects($this->atLeastOnce())
- ->method('save')
- ->willReturn($customer);
- $this->addressRepository->expects($this->atLeastOnce())
- ->method('save')
- ->with($address);
- $this->customerRepository->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customer);
- $this->random->expects($this->once())
- ->method('getUniqueHash')
- ->willReturn($newLinkToken);
- $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class)
- ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash'])
- ->disableOriginalConstructor()
- ->getMock();
- $customerSecure->expects($this->any())
- ->method('setRpToken')
- ->with($newLinkToken);
- $customerSecure->expects($this->any())
- ->method('setRpTokenCreatedAt')
- ->with($datetime)
- ->willReturnSelf();
- $customerSecure->expects($this->any())
- ->method('getPasswordHash')
- ->willReturn(null);
- $this->customerRegistry->expects($this->atLeastOnce())
- ->method('retrieveSecureData')
- ->willReturn($customerSecure);
- $this->emailNotificationMock->expects($this->once())
- ->method('newAccount')
- ->willReturnSelf();
-
- $this->accountManagement->createAccount($customer);
- }
-
- /**
- * Data provider for testCreateAccountWithPasswordInputException test
- *
- * @return array
- */
- public function dataProviderCheckPasswordStrength()
- {
- return [
- [
- 'testNumber' => 1,
- 'password' => 'qwer',
- 'minPasswordLength' => 5,
- 'minCharacterSetsNum' => 1
- ],
- [
- 'testNumber' => 2,
- 'password' => 'wrfewqedf1',
- 'minPasswordLength' => 5,
- 'minCharacterSetsNum' => 3
- ]
- ];
- }
-
- /**
- * @param int $testNumber
- * @param string $password
- * @param int $minPasswordLength
- * @param int $minCharacterSetsNum
- * @dataProvider dataProviderCheckPasswordStrength
- */
- public function testCreateAccountWithPasswordInputException(
- $testNumber,
- $password,
- $minPasswordLength,
- $minCharacterSetsNum
- ) {
- $this->scopeConfig->expects($this->any())
- ->method('getValue')
- ->will(
- $this->returnValueMap(
- [
- [
- AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH,
- 'default',
- null,
- $minPasswordLength,
- ],
- [
- AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER,
- 'default',
- null,
- $minCharacterSetsNum],
- ]
- )
- );
-
- $this->string->expects($this->any())
- ->method('strlen')
- ->with($password)
- ->willReturn(iconv_strlen($password, 'UTF-8'));
-
- if ($testNumber == 1) {
- $this->expectException(
- \Magento\Framework\Exception\InputException::class,
- 'Please enter a password with at least ' . $minPasswordLength . ' characters.'
- );
- }
-
- if ($testNumber == 2) {
- $this->expectException(
- \Magento\Framework\Exception\InputException::class,
- 'Minimum of different classes of characters in password is ' . $minCharacterSetsNum .
- '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.'
- );
- }
-
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $this->accountManagement->createAccount($customer, $password);
- }
-
- public function testCreateAccountInputExceptionExtraLongPassword()
- {
- $password = '257*chars*************************************************************************************'
- . '****************************************************************************************************'
- . '***************************************************************';
-
- $this->string->expects($this->any())
- ->method('strlen')
- ->with($password)
- ->willReturn(iconv_strlen($password, 'UTF-8'));
-
- $this->expectException(
- \Magento\Framework\Exception\InputException::class,
- 'Please enter a password with at most 256 characters.'
- );
-
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $this->accountManagement->createAccount($customer, $password);
- }
-
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
- public function testCreateAccountWithPassword()
- {
- $websiteId = 1;
- $storeId = null;
- $defaultStoreId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
- $newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
- $password = 'wrfewqedf1';
- $minPasswordLength = 5;
- $minCharacterSetsNum = 2;
-
- $datetime = $this->prepareDateTimeFactory();
-
- $this->scopeConfig->expects($this->any())
- ->method('getValue')
- ->willReturnMap(
- [
- [
- AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH,
- 'default',
- null,
- $minPasswordLength,
- ],
- [
- AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER,
- 'default',
- null,
- $minCharacterSetsNum],
- [
- AccountManagement::XML_PATH_REGISTER_EMAIL_TEMPLATE,
- ScopeInterface::SCOPE_STORE,
- $defaultStoreId,
- $templateIdentifier,
- ],
- [
- AccountManagement::XML_PATH_REGISTER_EMAIL_IDENTITY,
- ScopeInterface::SCOPE_STORE,
- 1,
- $sender
- ]
- ]
- );
- $this->string->expects($this->any())
- ->method('strlen')
- ->with($password)
- ->willReturn(iconv_strlen($password, 'UTF-8'));
- $this->encryptor->expects($this->once())
- ->method('getHash')
- ->with($password, true)
- ->willReturn($hash);
- $address = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $address->expects($this->once())
- ->method('setCustomerId')
- ->with($customerId);
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
- $store->expects($this->once())
- ->method('getId')
- ->willReturn($defaultStoreId);
- $website = $this->getMockBuilder(\Magento\Store\Model\Website::class)->disableOriginalConstructor()->getMock();
- $website->expects($this->atLeastOnce())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $website->expects($this->once())
- ->method('getDefaultStore')
- ->willReturn($store);
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->atLeastOnce())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer->expects($this->once())
- ->method('setStoreId')
- ->with($defaultStoreId);
- $customer->expects($this->once())
- ->method('getAddresses')
- ->willReturn([$address]);
- $customer->expects($this->once())
- ->method('setAddresses')
- ->with(null);
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager->expects($this->atLeastOnce())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $this->customerRepository->expects($this->atLeastOnce())
- ->method('save')
- ->willReturn($customer);
- $this->addressRepository->expects($this->atLeastOnce())
- ->method('save')
- ->with($address);
- $this->customerRepository->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customer);
- $this->random->expects($this->once())
- ->method('getUniqueHash')
- ->willReturn($newLinkToken);
- $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class)
- ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash'])
- ->disableOriginalConstructor()
- ->getMock();
- $customerSecure->expects($this->any())
- ->method('setRpToken')
- ->with($newLinkToken);
- $customerSecure->expects($this->any())
- ->method('setRpTokenCreatedAt')
- ->with($datetime)
- ->willReturnSelf();
- $customerSecure->expects($this->any())
- ->method('getPasswordHash')
- ->willReturn($hash);
- $this->customerRegistry->expects($this->atLeastOnce())
- ->method('retrieveSecureData')
- ->willReturn($customerSecure);
- $this->emailNotificationMock->expects($this->once())
- ->method('newAccount')
- ->willReturnSelf();
-
- $this->accountManagement->createAccount($customer, $password);
- }
-
- /**
- * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
- */
- public function testSendPasswordReminderEmail()
- {
- $customerId = 1;
- $customerStoreId = 2;
- $customerEmail = 'email@email.com';
- $customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
-
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMock();
- $customer->expects($this->any())
- ->method('getStoreId')
- ->willReturn($customerStoreId);
- $customer->expects($this->any())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->any())
- ->method('getEmail')
- ->willReturn($customerEmail);
-
- $this->store->expects($this->any())
- ->method('getId')
- ->willReturn($customerStoreId);
-
- $this->storeManager->expects($this->at(0))
- ->method('getStore')
- ->willReturn($this->store);
-
- $this->storeManager->expects($this->at(1))
- ->method('getStore')
- ->with($customerStoreId)
- ->willReturn($this->store);
-
- $this->customerRegistry->expects($this->once())
- ->method('retrieveSecureData')
- ->with($customerId)
- ->willReturn($this->customerSecure);
-
- $this->dataObjectProcessor->expects($this->once())
- ->method('buildOutputDataArray')
- ->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)
- ->willReturn($customerData);
-
- $this->customerViewHelper->expects($this->any())
- ->method('getCustomerName')
- ->with($customer)
- ->willReturn($customerName);
-
- $this->customerSecure->expects($this->once())
- ->method('addData')
- ->with($customerData)
- ->willReturnSelf();
- $this->customerSecure->expects($this->once())
- ->method('setData')
- ->with('name', $customerName)
- ->willReturnSelf();
-
- $this->scopeConfig->expects($this->at(0))
- ->method('getValue')
- ->with(AccountManagement::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($templateIdentifier);
- $this->scopeConfig->expects($this->at(1))
- ->method('getValue')
- ->with(AccountManagement::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($sender);
-
- $transport = $this->getMockBuilder(\Magento\Framework\Mail\TransportInterface::class)
- ->getMock();
-
- $this->transportBuilder->expects($this->once())
- ->method('setTemplateIdentifier')
- ->with($templateIdentifier)
- ->willReturnSelf();
- $this->transportBuilder->expects($this->once())
- ->method('setTemplateOptions')
- ->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])
- ->willReturnSelf();
- $this->transportBuilder->expects($this->once())
- ->method('setTemplateVars')
- ->with(['customer' => $this->customerSecure, 'store' => $this->store])
- ->willReturnSelf();
- $this->transportBuilder->expects($this->once())
- ->method('setFrom')
- ->with($sender)
- ->willReturnSelf();
- $this->transportBuilder->expects($this->once())
- ->method('addTo')
- ->with($customerEmail, $customerName)
- ->willReturnSelf();
- $this->transportBuilder->expects($this->once())
- ->method('getTransport')
- ->willReturn($transport);
-
- $transport->expects($this->once())
- ->method('sendMessage');
-
- $this->assertEquals($this->accountManagement, $this->accountManagement->sendPasswordReminderEmail($customer));
- }
-
- /**
- * @param string $email
- * @param string $templateIdentifier
- * @param string $sender
- * @param int $storeId
- * @param int $customerId
- * @param string $hash
- */
- protected function prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash)
- {
- $websiteId = 1;
-
- $datetime = $this->prepareDateTimeFactory();
-
- $customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
-
- $this->store->expects($this->once())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $this->store->expects($this->any())
- ->method('getId')
- ->willReturn($storeId);
-
- $this->storeManager->expects($this->any())
- ->method('getStore')
- ->willReturn($this->store);
-
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMock();
- $customer->expects($this->any())
- ->method('getEmail')
- ->willReturn($email);
- $customer->expects($this->any())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->any())
- ->method('getStoreId')
- ->willReturn($storeId);
-
- $this->customerRepository->expects($this->once())
- ->method('get')
- ->with($email, $websiteId)
- ->willReturn($customer);
- $this->customerRepository->expects($this->once())
- ->method('save')
- ->with($customer)
- ->willReturnSelf();
-
- $this->random->expects($this->once())
- ->method('getUniqueHash')
- ->willReturn($hash);
-
- $this->customerViewHelper->expects($this->any())
- ->method('getCustomerName')
- ->with($customer)
- ->willReturn($customerName);
-
- $this->customerSecure->expects($this->any())
- ->method('setRpToken')
- ->with($hash)
- ->willReturnSelf();
- $this->customerSecure->expects($this->any())
- ->method('setRpTokenCreatedAt')
- ->with($datetime)
- ->willReturnSelf();
- $this->customerSecure->expects($this->any())
- ->method('addData')
- ->with($customerData)
- ->willReturnSelf();
- $this->customerSecure->expects($this->any())
- ->method('setData')
- ->with('name', $customerName)
- ->willReturnSelf();
-
- $this->customerRegistry->expects($this->any())
- ->method('retrieveSecureData')
- ->with($customerId)
- ->willReturn($this->customerSecure);
-
- $this->dataObjectProcessor->expects($this->any())
- ->method('buildOutputDataArray')
- ->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)
- ->willReturn($customerData);
-
- $this->prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName);
- }
-
- /**
- * @param $email
- * @param $templateIdentifier
- * @param $sender
- * @param $storeId
- * @param $customerName
- */
- protected function prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName)
- {
- $transport = $this->getMockBuilder(\Magento\Framework\Mail\TransportInterface::class)
- ->getMock();
-
- $this->transportBuilder->expects($this->any())
- ->method('setTemplateIdentifier')
- ->with($templateIdentifier)
- ->willReturnSelf();
- $this->transportBuilder->expects($this->any())
- ->method('setTemplateOptions')
- ->with(['area' => Area::AREA_FRONTEND, 'store' => $storeId])
- ->willReturnSelf();
- $this->transportBuilder->expects($this->any())
- ->method('setTemplateVars')
- ->with(['customer' => $this->customerSecure, 'store' => $this->store])
- ->willReturnSelf();
- $this->transportBuilder->expects($this->any())
- ->method('setFrom')
- ->with($sender)
- ->willReturnSelf();
- $this->transportBuilder->expects($this->any())
- ->method('addTo')
- ->with($email, $customerName)
- ->willReturnSelf();
- $this->transportBuilder->expects($this->any())
- ->method('getTransport')
- ->willReturn($transport);
-
- $transport->expects($this->any())
- ->method('sendMessage');
- }
-
- public function testInitiatePasswordResetEmailReminder()
- {
- $customerId = 1;
-
- $email = 'test@example.com';
- $template = AccountManagement::EMAIL_REMINDER;
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
-
- $storeId = 1;
-
- mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
- $hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
-
- $this->emailNotificationMock->expects($this->once())
- ->method('passwordReminder')
- ->willReturnSelf();
-
- $this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
-
- $this->assertTrue($this->accountManagement->initiatePasswordReset($email, $template));
- }
-
- public function testInitiatePasswordResetEmailReset()
- {
- $storeId = 1;
- $customerId = 1;
-
- $email = 'test@example.com';
- $template = AccountManagement::EMAIL_RESET;
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
-
- mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
- $hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
-
- $this->emailNotificationMock->expects($this->once())
- ->method('passwordResetConfirmation')
- ->willReturnSelf();
-
- $this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
-
- $this->assertTrue($this->accountManagement->initiatePasswordReset($email, $template));
- }
-
- public function testInitiatePasswordResetNoTemplate()
- {
- $storeId = 1;
- $customerId = 1;
-
- $email = 'test@example.com';
- $template = null;
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
-
- mt_srand(mt_rand() + (100000000 * (float)microtime()) % PHP_INT_MAX);
- $hash = md5(uniqid(microtime() . mt_rand(0, mt_getrandmax()), true));
-
- $this->prepareInitiatePasswordReset($email, $templateIdentifier, $sender, $storeId, $customerId, $hash);
-
- $this->expectException(\Magento\Framework\Exception\InputException::class);
- $this->expectExceptionMessage(
- 'Invalid value of "" provided for the template field. Possible values: email_reminder or email_reset.'
- );
- $this->accountManagement->initiatePasswordReset($email, $template);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage Invalid value of "" provided for the customerId field
- */
- public function testValidateResetPasswordTokenBadCustomerId()
- {
- $this->accountManagement->validateResetPasswordLinkToken(null, '');
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\InputException
- * @expectedExceptionMessage resetPasswordLinkToken is a required field
- */
- public function testValidateResetPasswordTokenBadResetPasswordLinkToken()
- {
- $this->accountManagement->validateResetPasswordLinkToken(22, null);
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\State\InputMismatchException
- * @expectedExceptionMessage Reset password token mismatch
- */
- public function testValidateResetPasswordTokenTokenMismatch()
- {
- $this->customerRegistry->expects($this->atLeastOnce())
- ->method('retrieveSecureData')
- ->willReturn($this->customerSecure);
-
- $this->accountManagement->validateResetPasswordLinkToken(22, 'newStringToken');
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\State\ExpiredException
- * @expectedExceptionMessage Reset password token expired
- */
- public function testValidateResetPasswordTokenTokenExpired()
- {
- $this->reInitModel();
- $this->customerRegistry->expects($this->atLeastOnce())
- ->method('retrieveSecureData')
- ->willReturn($this->customerSecure);
-
- $this->accountManagement->validateResetPasswordLinkToken(22, 'newStringToken');
- }
-
- /**
- * return bool
- */
- public function testValidateResetPasswordToken()
- {
- $this->reInitModel();
-
- $this->customer
- ->expects($this->once())
- ->method('getResetPasswordLinkExpirationPeriod')
- ->willReturn(100000);
-
- $this->customerRegistry->expects($this->atLeastOnce())
- ->method('retrieveSecureData')
- ->willReturn($this->customerSecure);
-
- $this->assertTrue($this->accountManagement->validateResetPasswordLinkToken(22, 'newStringToken'));
- }
-
- /**
- * reInit $this->accountManagement object
- */
- private function reInitModel()
- {
- $this->customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class)
- ->disableOriginalConstructor()
- ->setMethods(
- [
- 'getRpToken',
- 'getRpTokenCreatedAt',
- 'getPasswordHash',
- 'setPasswordHash',
- 'setRpToken',
- 'setRpTokenCreatedAt',
- ]
- )
- ->getMock();
-
- $this->customerSecure
- ->expects($this->any())
- ->method('getRpToken')
- ->willReturn('newStringToken');
-
- $pastDateTime = '2016-10-25 00:00:00';
-
- $this->customerSecure
- ->expects($this->any())
- ->method('getRpTokenCreatedAt')
- ->willReturn($pastDateTime);
-
- $this->customer = $this->getMockBuilder(\Magento\Customer\Model\Customer::class)
- ->disableOriginalConstructor()
- ->setMethods(['getResetPasswordLinkExpirationPeriod'])
- ->getMock();
-
- $this->prepareDateTimeFactory();
-
- $this->sessionManager = $this->getMockBuilder(\Magento\Framework\Session\SessionManagerInterface::class)
- ->disableOriginalConstructor()
- ->getMockForAbstractClass();
- $this->visitorCollectionFactory = $this->getMockBuilder(
- \Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory::class
- )
- ->disableOriginalConstructor()
- ->setMethods(['create'])
- ->getMock();
- $this->saveHandler = $this->getMockBuilder(\Magento\Framework\Session\SaveHandlerInterface::class)
- ->disableOriginalConstructor()
- ->setMethods(['destroy'])
- ->getMockForAbstractClass();
-
- $dateTime = '2017-10-25 18:57:08';
- $timestamp = '1508983028';
- $dateTimeMock = $this->createMock(\DateTime::class);
- $dateTimeMock->expects($this->any())
- ->method('format')
- ->with(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
- ->willReturn($dateTime);
-
- $dateTimeMock
- ->expects($this->any())
- ->method('getTimestamp')
- ->willReturn($timestamp);
-
- $dateTimeMock
- ->expects($this->any())
- ->method('setTimestamp')
- ->willReturnSelf();
-
- $dateTimeFactory = $this->createMock(DateTimeFactory::class);
- $dateTimeFactory->expects($this->any())->method('create')->willReturn($dateTimeMock);
-
- $this->objectManagerHelper = new ObjectManagerHelper($this);
- $this->accountManagement = $this->objectManagerHelper->getObject(
- \Magento\Customer\Model\AccountManagement::class,
- [
- 'customerFactory' => $this->customerFactory,
- 'customerRegistry' => $this->customerRegistry,
- 'customerRepository' => $this->customerRepository,
- 'customerModel' => $this->customer,
- 'dateTimeFactory' => $dateTimeFactory,
- 'stringHelper' => $this->string,
- 'scopeConfig' => $this->scopeConfig,
- 'sessionManager' => $this->sessionManager,
- 'visitorCollectionFactory' => $this->visitorCollectionFactory,
- 'saveHandler' => $this->saveHandler,
- 'encryptor' => $this->encryptor,
- 'dataProcessor' => $this->dataObjectProcessor,
- 'storeManager' => $this->storeManager,
- 'transportBuilder' => $this->transportBuilder,
- ]
- );
- $reflection = new \ReflectionClass(get_class($this->accountManagement));
- $reflectionProperty = $reflection->getProperty('authentication');
- $reflectionProperty->setAccessible(true);
- $reflectionProperty->setValue($this->accountManagement, $this->authenticationMock);
- }
-
- /**
- * @return void
- */
- public function testChangePassword()
- {
- $customerId = 7;
- $email = 'test@example.com';
- $currentPassword = '1234567';
- $newPassword = 'abcdefg';
- $passwordHash = '1a2b3f4c';
-
- $this->reInitModel();
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMock();
- $customer->expects($this->any())
- ->method('getId')
- ->willReturn($customerId);
-
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($email)
- ->willReturn($customer);
-
- $this->authenticationMock->expects($this->once())
- ->method('authenticate');
-
- $this->customerSecure->expects($this->once())
- ->method('setRpToken')
- ->with(null);
- $this->customerSecure->expects($this->once())
- ->method('setRpTokenCreatedAt')
- ->willReturnSelf();
- $this->customerSecure->expects($this->any())
- ->method('getPasswordHash')
- ->willReturn($passwordHash);
-
- $this->customerRegistry->expects($this->any())
- ->method('retrieveSecureData')
- ->with($customerId)
- ->willReturn($this->customerSecure);
-
- $this->scopeConfig->expects($this->any())
- ->method('getValue')
- ->willReturnMap(
- [
- [
- AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH,
- 'default',
- null,
- 7,
- ],
- [
- AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER,
- 'default',
- null,
- 1
- ],
- ]
- );
- $this->string->expects($this->any())
- ->method('strlen')
- ->with($newPassword)
- ->willReturn(7);
-
- $this->customerRepository
- ->expects($this->once())
- ->method('save')
- ->with($customer);
-
- $this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
-
- $visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
- ->disableOriginalConstructor()
- ->setMethods(['getSessionId'])
- ->getMock();
- $visitor->expects($this->at(0))->method('getSessionId')->willReturn('session_id_1');
- $visitor->expects($this->at(1))->method('getSessionId')->willReturn('session_id_2');
- $visitorCollection = $this->getMockBuilder(
- \Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory::class
- )
- ->disableOriginalConstructor()->setMethods(['addFieldToFilter', 'getItems'])->getMock();
- $visitorCollection->expects($this->atLeastOnce())->method('addFieldToFilter')->willReturnSelf();
- $visitorCollection->expects($this->atLeastOnce())->method('getItems')->willReturn([$visitor, $visitor]);
- $this->visitorCollectionFactory->expects($this->atLeastOnce())->method('create')
- ->willReturn($visitorCollection);
- $this->saveHandler->expects($this->at(0))->method('destroy')->with('session_id_1');
- $this->saveHandler->expects($this->at(1))->method('destroy')->with('session_id_2');
-
- $this->assertTrue($this->accountManagement->changePassword($email, $currentPassword, $newPassword));
- }
-
- public function testResetPassword()
- {
- $customerEmail = 'customer@example.com';
- $customerId = '1';
- $resetToken = 'newStringToken';
- $newPassword = 'new_password';
-
- $this->reInitModel();
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer->expects($this->any())->method('getId')->willReturn($customerId);
- $this->customerRepository->expects($this->atLeastOnce())->method('get')->with($customerEmail)
- ->willReturn($customer);
- $this->customer->expects($this->atLeastOnce())->method('getResetPasswordLinkExpirationPeriod')
- ->willReturn(100000);
- $this->string->expects($this->any())->method('strlen')->willReturnCallback(
- function ($string) {
- return strlen($string);
- }
- );
- $this->customerRegistry->expects($this->atLeastOnce())->method('retrieveSecureData')
- ->willReturn($this->customerSecure);
-
- $this->customerSecure->expects($this->once())
- ->method('setRpToken')
- ->with(null);
- $this->customerSecure->expects($this->once())
- ->method('setRpTokenCreatedAt')
- ->with(null);
- $this->customerSecure->expects($this->any())
- ->method('setPasswordHash')
- ->willReturn(null);
-
- $this->sessionManager->expects($this->atLeastOnce())->method('destroy');
- $this->sessionManager->expects($this->atLeastOnce())->method('getSessionId');
- $visitor = $this->getMockBuilder(\Magento\Customer\Model\Visitor::class)
- ->disableOriginalConstructor()
- ->setMethods(['getSessionId'])
- ->getMock();
- $visitor->expects($this->at(0))->method('getSessionId')->willReturn('session_id_1');
- $visitor->expects($this->at(1))->method('getSessionId')->willReturn('session_id_2');
- $visitorCollection = $this->getMockBuilder(
- \Magento\Customer\Model\ResourceModel\Visitor\CollectionFactory::class
- )
- ->disableOriginalConstructor()->setMethods(['addFieldToFilter', 'getItems'])->getMock();
- $visitorCollection->expects($this->atLeastOnce())->method('addFieldToFilter')->willReturnSelf();
- $visitorCollection->expects($this->atLeastOnce())->method('getItems')->willReturn([$visitor, $visitor]);
- $this->visitorCollectionFactory->expects($this->atLeastOnce())->method('create')
- ->willReturn($visitorCollection);
- $this->saveHandler->expects($this->at(0))->method('destroy')->with('session_id_1');
- $this->saveHandler->expects($this->at(1))->method('destroy')->with('session_id_2');
- $this->assertTrue($this->accountManagement->resetPassword($customerEmail, $resetToken, $newPassword));
- }
-
- /**
- * @return void
- */
- public function testChangePasswordException()
- {
- $email = 'test@example.com';
- $currentPassword = '1234567';
- $newPassword = 'abcdefg';
-
- $exception = new NoSuchEntityException(
- new \Magento\Framework\Phrase('Exception message')
- );
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($email)
- ->willThrowException($exception);
-
- $this->expectException(
- \Magento\Framework\Exception\InvalidEmailOrPasswordException::class,
- 'Invalid login or password.'
- );
-
- $this->accountManagement->changePassword($email, $currentPassword, $newPassword);
- }
-
- /**
- * @return void
- */
- public function testAuthenticate()
- {
- $username = 'login';
- $password = '1234567';
- $passwordHash = '1a2b3f4c';
-
- $customerData = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMock();
-
- $customerModel = $this->getMockBuilder(\Magento\Customer\Model\Customer::class)
- ->disableOriginalConstructor()
- ->getMock();
- $customerModel->expects($this->once())
- ->method('updateData')
- ->willReturn($customerModel);
-
- $this->customerRepository
- ->expects($this->once())
- ->method('get')
- ->with($username)
- ->willReturn($customerData);
-
- $this->authenticationMock->expects($this->once())
- ->method('authenticate');
-
- $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class)
- ->setMethods(['getPasswordHash'])
- ->disableOriginalConstructor()
- ->getMock();
- $customerSecure->expects($this->any())
- ->method('getPasswordHash')
- ->willReturn($passwordHash);
-
- $this->customerRegistry->expects($this->any())
- ->method('retrieveSecureData')
- ->willReturn($customerSecure);
-
- $this->customerFactory->expects($this->once())
- ->method('create')
- ->willReturn($customerModel);
-
- $this->manager->expects($this->exactly(2))
- ->method('dispatch')
- ->withConsecutive(
- [
- 'customer_customer_authenticated',
- ['model' => $customerModel, 'password' => $password]
- ],
- [
- 'customer_data_object_login', ['customer' => $customerData]
- ]
- );
-
- $this->assertEquals($customerData, $this->accountManagement->authenticate($username, $password));
- }
-
- /**
- * @param int $isConfirmationRequired
- * @param string|null $confirmation
- * @param string $expected
- * @dataProvider dataProviderGetConfirmationStatus
- */
- public function testGetConfirmationStatus(
- $isConfirmationRequired,
- $confirmation,
- $expected
- ) {
- $websiteId = 1;
- $customerId = 1;
- $customerEmail = 'test1@example.com';
-
- $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $customerMock->expects($this->once())
- ->method('getId')
- ->willReturn($customerId);
- $customerMock->expects($this->any())
- ->method('getConfirmation')
- ->willReturn($confirmation);
- $customerMock->expects($this->once())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customerMock->expects($this->once())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
-
- $this->accountConfirmation->expects($this->once())
- ->method('isConfirmationRequired')
- ->with($websiteId, $customerId, $customerEmail)
- ->willReturn($isConfirmationRequired);
-
- $this->customerRepository->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customerMock);
-
- $this->assertEquals($expected, $this->accountManagement->getConfirmationStatus($customerId));
- }
-
- /**
- * @return array
- */
- public function dataProviderGetConfirmationStatus()
- {
- return [
- [0, null, AccountManagement::ACCOUNT_CONFIRMATION_NOT_REQUIRED],
- [0, null, AccountManagement::ACCOUNT_CONFIRMATION_NOT_REQUIRED],
- [0, null, AccountManagement::ACCOUNT_CONFIRMATION_NOT_REQUIRED],
- [1, null, AccountManagement::ACCOUNT_CONFIRMED],
- [1, 'test', AccountManagement::ACCOUNT_CONFIRMATION_REQUIRED],
- ];
- }
-
- /**
- * @expectedException \Magento\Framework\Exception\LocalizedException
- */
- public function testCreateAccountWithPasswordHashForGuest()
- {
- $storeId = 1;
- $storeName = 'store_name';
- $websiteId = 1;
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $storeMock = $this->getMockBuilder(\Magento\Store\Model\Store::class)
- ->disableOriginalConstructor()
- ->getMock();
- $storeMock->expects($this->once())
- ->method('getId')
- ->willReturn($storeId);
- $storeMock->expects($this->once())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $storeMock->expects($this->once())
- ->method('getName')
- ->willReturn($storeName);
-
- $this->storeManager->expects($this->exactly(3))
- ->method('getStore')
- ->willReturn($storeMock);
-
- $customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
- ->getMockForAbstractClass();
- $customerMock->expects($this->exactly(2))
- ->method('getId')
- ->willReturn(null);
- $customerMock->expects($this->exactly(3))
- ->method('getStoreId')
- ->willReturn(null);
- $customerMock->expects($this->exactly(2))
- ->method('getWebsiteId')
- ->willReturn(null);
- $customerMock->expects($this->once())
- ->method('setStoreId')
- ->with($storeId)
- ->willReturnSelf();
- $customerMock->expects($this->once())
- ->method('setWebsiteId')
- ->with($websiteId)
- ->willReturnSelf();
- $customerMock->expects($this->once())
- ->method('setCreatedIn')
- ->with($storeName)
- ->willReturnSelf();
- $customerMock->expects($this->once())
- ->method('getAddresses')
- ->willReturn(null);
- $customerMock->expects($this->once())
- ->method('setAddresses')
- ->with(null)
- ->willReturnSelf();
-
- $this->customerRepository
- ->expects($this->once())
- ->method('save')
- ->with($customerMock, $hash)
- ->willThrowException(new \Magento\Framework\Exception\LocalizedException(__('Exception message')));
-
- $this->accountManagement->createAccountWithPasswordHash($customerMock, $hash);
- }
-
- public function testCreateAccountWithPasswordHashWithCustomerAddresses()
- {
- $websiteId = 1;
- $addressId = 2;
- $customerId = null;
- $storeId = 1;
- $hash = '4nj54lkj5jfi03j49f8bgujfgsd';
-
- $this->prepareDateTimeFactory();
-
- //Handle store
- $store = $this->getMockBuilder(\Magento\Store\Model\Store::class)->disableOriginalConstructor()->getMock();
- $store->expects($this->any())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- //Handle address - existing and non-existing. Non-Existing should return null when call getId method
- $existingAddress = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $nonExistingAddress = $this->getMockBuilder(\Magento\Customer\Api\Data\AddressInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- //Ensure that existing address is not in use
- $this->addressRepository
- ->expects($this->atLeastOnce())
- ->method("save")
- ->withConsecutive(
- [$this->logicalNot($this->identicalTo($existingAddress))],
- [$this->identicalTo($nonExistingAddress)]
- );
-
- $existingAddress
- ->expects($this->any())
- ->method("getId")
- ->willReturn($addressId);
- //Expects that id for existing address should be unset
- $existingAddress
- ->expects($this->once())
- ->method("setId")
- ->with(null);
- //Handle Customer calls
- $customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
- $customer
- ->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer
- ->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer
- ->expects($this->any())
- ->method("getId")
- ->willReturn($customerId);
- //Return Customer from customer repository
- $this->customerRepository
- ->expects($this->atLeastOnce())
- ->method('save')
- ->willReturn($customer);
- $this->customerRepository
- ->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customer);
- $customerSecure = $this->getMockBuilder(\Magento\Customer\Model\Data\CustomerSecure::class)
- ->setMethods(['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash'])
- ->disableOriginalConstructor()
- ->getMock();
- $customerSecure->expects($this->once())
- ->method('setRpToken')
- ->with($hash);
-
- $customerSecure->expects($this->any())
- ->method('getPasswordHash')
- ->willReturn($hash);
-
- $this->customerRegistry->expects($this->any())
- ->method('retrieveSecureData')
- ->with($customerId)
- ->willReturn($customerSecure);
-
- $this->random->expects($this->once())
- ->method('getUniqueHash')
- ->willReturn($hash);
-
- $customer
- ->expects($this->atLeastOnce())
- ->method('getAddresses')
- ->willReturn([$existingAddress, $nonExistingAddress]);
-
- $this->storeManager
- ->expects($this->atLeastOnce())
- ->method('getStore')
- ->willReturn($store);
-
- $this->assertSame($customer, $this->accountManagement->createAccountWithPasswordHash($customer, $hash));
- }
-
- /**
- * @return string
- */
- private function prepareDateTimeFactory()
- {
- $dateTime = '2017-10-25 18:57:08';
- $timestamp = '1508983028';
- $dateTimeMock = $this->createMock(\DateTime::class);
- $dateTimeMock->expects($this->any())
- ->method('format')
- ->with(\Magento\Framework\Stdlib\DateTime::DATETIME_PHP_FORMAT)
- ->willReturn($dateTime);
-
- $dateTimeMock
- ->expects($this->any())
- ->method('getTimestamp')
- ->willReturn($timestamp);
-
- $this->dateTimeFactory
- ->expects($this->any())
- ->method('create')
- ->willReturn($dateTimeMock);
-
- return $dateTime;
- }
-
- public function testCreateAccountUnexpectedValueException()
- {
- $websiteId = 1;
- $storeId = null;
- $defaultStoreId = 1;
- $customerId = 1;
- $customerEmail = 'email@email.com';
- $newLinkToken = '2jh43j5h2345jh23lh452h345hfuzasd96ofu';
- $exception = new \UnexpectedValueException('Template file was not found');
-
- $datetime = $this->prepareDateTimeFactory();
-
- $address = $this->createMock(\Magento\Customer\Api\Data\AddressInterface::class);
- $address->expects($this->once())
- ->method('setCustomerId')
- ->with($customerId);
- $store = $this->createMock(\Magento\Store\Model\Store::class);
- $store->expects($this->once())
- ->method('getId')
- ->willReturn($defaultStoreId);
- $website = $this->createMock(\Magento\Store\Model\Website::class);
- $website->expects($this->atLeastOnce())
- ->method('getStoreIds')
- ->willReturn([1, 2, 3]);
- $website->expects($this->once())
- ->method('getDefaultStore')
- ->willReturn($store);
- $customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
- $customer->expects($this->atLeastOnce())
- ->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->atLeastOnce())
- ->method('getEmail')
- ->willReturn($customerEmail);
- $customer->expects($this->atLeastOnce())
- ->method('getWebsiteId')
- ->willReturn($websiteId);
- $customer->expects($this->atLeastOnce())
- ->method('getStoreId')
- ->willReturn($storeId);
- $customer->expects($this->once())
- ->method('setStoreId')
- ->with($defaultStoreId);
- $customer->expects($this->once())
- ->method('getAddresses')
- ->willReturn([$address]);
- $customer->expects($this->once())
- ->method('setAddresses')
- ->with(null);
- $this->customerRepository->expects($this->once())
- ->method('get')
- ->with($customerEmail)
- ->willReturn($customer);
- $this->share->expects($this->once())
- ->method('isWebsiteScope')
- ->willReturn(true);
- $this->storeManager->expects($this->atLeastOnce())
- ->method('getWebsite')
- ->with($websiteId)
- ->willReturn($website);
- $this->customerRepository->expects($this->atLeastOnce())
- ->method('save')
- ->willReturn($customer);
- $this->addressRepository->expects($this->atLeastOnce())
- ->method('save')
- ->with($address);
- $this->customerRepository->expects($this->once())
- ->method('getById')
- ->with($customerId)
- ->willReturn($customer);
- $this->random->expects($this->once())
- ->method('getUniqueHash')
- ->willReturn($newLinkToken);
- $customerSecure = $this->createPartialMock(
- \Magento\Customer\Model\Data\CustomerSecure::class,
- ['setRpToken', 'setRpTokenCreatedAt', 'getPasswordHash']
- );
- $customerSecure->expects($this->any())
- ->method('setRpToken')
- ->with($newLinkToken);
- $customerSecure->expects($this->any())
- ->method('setRpTokenCreatedAt')
- ->with($datetime)
- ->willReturnSelf();
- $customerSecure->expects($this->any())
- ->method('getPasswordHash')
- ->willReturn(null);
- $this->customerRegistry->expects($this->atLeastOnce())
- ->method('retrieveSecureData')
- ->willReturn($customerSecure);
- $this->emailNotificationMock->expects($this->once())
- ->method('newAccount')
- ->willThrowException($exception);
- $this->logger->expects($this->once())->method('error')->with($exception);
-
- $this->accountManagement->createAccount($customer);
- }
-}
diff --git a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
index f5b7f08d2906d..b9e73a6613bab 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/CustomerTest.php
@@ -307,8 +307,6 @@ public function testUpdateData()
}
$expectedResult[$attribute->getAttributeCode()] = $attribute->getValue();
- $expectedResult['attribute_set_id'] =
- \Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER;
$this->assertEquals($this->_model->getData(), $expectedResult);
}
diff --git a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php
index 41816d26982d6..215cc32193b18 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php
@@ -334,12 +334,6 @@ public function testSave()
$customerModel->expects($this->once())
->method('setId')
->with($customerId);
- $customerModel->expects($this->once())
- ->method('getAttributeSetId')
- ->willReturn(null);
- $customerModel->expects($this->once())
- ->method('setAttributeSetId')
- ->with(\Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER);
$customerAttributesMetaData->expects($this->atLeastOnce())
->method('getId')
->willReturn($customerId);
@@ -616,12 +610,6 @@ public function testSaveWithPasswordHash()
$customerModel->expects($this->once())
->method('setId')
->with($customerId);
- $customerModel->expects($this->once())
- ->method('getAttributeSetId')
- ->willReturn(null);
- $customerModel->expects($this->once())
- ->method('setAttributeSetId')
- ->with(\Magento\Customer\Api\CustomerMetadataInterface::ATTRIBUTE_SET_ID_CUSTOMER);
$customerModel->expects($this->atLeastOnce())
->method('getId')
->willReturn($customerId);
diff --git a/app/code/Magento/Customer/composer.json b/app/code/Magento/Customer/composer.json
index 65cb1e257f5b6..e3d8f22088ef6 100644
--- a/app/code/Magento/Customer/composer.json
+++ b/app/code/Magento/Customer/composer.json
@@ -29,7 +29,7 @@
"magento/module-customer-sample-data": "Sample Data version:100.2.*"
},
"type": "magento2-module",
- "version": "101.0.5",
+ "version": "101.0.6",
"license": [
"OSL-3.0",
"AFL-3.0"
diff --git a/app/code/Magento/Customer/view/frontend/email/password_reset_confirmation.html b/app/code/Magento/Customer/view/frontend/email/password_reset_confirmation.html
index 6c17762a88227..59e7f16adfd51 100644
--- a/app/code/Magento/Customer/view/frontend/email/password_reset_confirmation.html
+++ b/app/code/Magento/Customer/view/frontend/email/password_reset_confirmation.html
@@ -21,7 +21,7 @@
diff --git a/app/code/Magento/Customer/view/frontend/templates/form/resetforgottenpassword.phtml b/app/code/Magento/Customer/view/frontend/templates/form/resetforgottenpassword.phtml
index 15e570da04beb..e79cea80ac838 100644
--- a/app/code/Magento/Customer/view/frontend/templates/form/resetforgottenpassword.phtml
+++ b/app/code/Magento/Customer/view/frontend/templates/form/resetforgottenpassword.phtml
@@ -8,7 +8,7 @@
/** @var \Magento\Customer\Block\Account\Resetpassword $block */
?>
- |