diff --git a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml
deleted file mode 100644
index 2d580ab55075c..0000000000000
--- a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/AddingProductWithExpiredSessionTest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml
deleted file mode 100644
index 7c29e00b6a3a9..0000000000000
--- a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/StorefrontCustomerForgotPasswordTest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml b/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml
deleted file mode 100644
index 58e815b03126d..0000000000000
--- a/app/code/Magento/Customer/Test/Mftf/Test/_Deprecated_Test/VerifyDisabledCustomerGroupFieldTest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
diff --git a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php
index b78aa8609607e..44401ca5eb7bf 100644
--- a/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php
+++ b/app/code/Magento/Customer/Test/Unit/CustomerData/SectionConfigConverterTest.php
@@ -75,12 +75,12 @@ public function testConvert()
'sections' => [
'sales/guest/reorder' => ['account'],
'sales/order/reorder' => ['account', 'cart'],
- 'stores/store/switch' => ['*'],
+ 'stores/store/switch' => ['account', '*', 'cart'],
'directory/currency/switch' => ['*'],
'customer/account/logout' => ['account', 'cart'],
'customer/account/editpost' => ['account', 'acc', 'cart'],
- 'checkout/cart/delete' => ['*'],
- 'customer/account/createpost' => ['*'],
+ 'checkout/cart/delete' => ['account', 'acc', 'cart', '*'],
+ 'customer/account/createpost' => ['account','*'],
'catalog/product_compare/add' => ['*'],
'catalog/product_compare/remove' => ['account', 'acc'],
'catalog/product_compare/clear' => ['*'],
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php
index 8ad7363a1c310..f98759d3f067a 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/Customer/DataProviderTest.php
@@ -26,7 +26,7 @@
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\Form\Field;
use Magento\Ui\DataProvider\EavValidationRules;
-use PHPUnit_Framework_MockObject_MockObject as MockObject;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Unit tests for \Magento\Customer\Model\Customer\DataProvider class.
@@ -243,6 +243,7 @@ public function getAttributesMetaDataProvider()
'componentType' => Field::NAME,
'filterBy' => [
'target' => '${ $.provider }:data.customer.website_id',
+ '__disableTmpl' => ['target' => false],
'field' => 'website_ids',
],
],
@@ -1280,6 +1281,7 @@ private function getExpectationForVisibleAttributes()
'componentType' => Field::NAME,
'filterBy' => [
'target' => '${ $.provider }:data.customer.website_id',
+ '__disableTmpl' => ['target' => false],
'field' => 'website_ids',
],
],
diff --git a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php
index ff83ef62c6aa7..ab90eacbb6032 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/EmailNotificationTest.php
@@ -3,88 +3,132 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Customer\Test\Unit\Model;
use Magento\Customer\Api\Data\CustomerInterface;
+use Magento\Customer\Helper\View;
+use Magento\Customer\Model\CustomerRegistry;
+use Magento\Customer\Model\Data\CustomerSecure;
use Magento\Customer\Model\EmailNotification;
use Magento\Framework\App\Area;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Helper\Context;
use Magento\Framework\Mail\Template\SenderResolverInterface;
+use Magento\Framework\Mail\Template\TransportBuilder;
+use Magento\Framework\Mail\TransportInterface;
+use Magento\Framework\Reflection\DataObjectProcessor;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\Store;
+use Magento\Store\Model\StoreManagerInterface;
+use Magento\Store\Model\Website;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class EmailNotificationTest
+ * Unit test for \Magento\Customer\Model\EmailNotification
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class EmailNotificationTest extends \PHPUnit\Framework\TestCase
+class EmailNotificationTest extends TestCase
{
/**
- * @var \Magento\Customer\Model\CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject
+ * @var int
+ */
+ private const STUB_CUSTOMER_ID = 1;
+
+ /**
+ * @var int
+ */
+ private const STUB_CUSTOMER_WEBSITE_ID = 1;
+
+ /**
+ * @var string
+ */
+ private const STUB_CUSTOMER_EMAIL = 'email@email.com';
+
+ /**
+ * @var string
+ */
+ private const STUB_CUSTOMER_NAME = 'Customer Name';
+
+ /**
+ * @var string
+ */
+ private const STUB_EMAIL_IDENTIFIER = 'Template Identifier';
+
+ /**
+ * @var string
+ */
+ private const STUB_SENDER = 'Sender';
+
+ /**
+ * @var CustomerRegistry|MockObject
*/
private $customerRegistryMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
private $storeManagerMock;
/**
- * @var \Magento\Framework\Mail\Template\TransportBuilder|\PHPUnit_Framework_MockObject_MockObject
+ * @var TransportBuilder|MockObject
*/
private $transportBuilderMock;
/**
- * @var \Magento\Customer\Helper\View|\PHPUnit_Framework_MockObject_MockObject
+ * @var View|MockObject
*/
private $customerViewHelperMock;
/**
- * @var \Magento\Framework\Reflection\DataObjectProcessor|\PHPUnit_Framework_MockObject_MockObject
+ * @var DataObjectProcessor|MockObject
*/
private $dataProcessorMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Model\Data\CustomerSecure
+ * @var CustomerSecure|MockObject
*/
private $customerSecureMock;
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
/**
- * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store
+ * @var Store|MockObject
*/
private $storeMock;
/**
- * @var \Magento\Customer\Model\EmailNotification
+ * @var EmailNotification
*/
private $model;
/**
- * @var SenderResolverInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var SenderResolverInterface|MockObject
*/
private $senderResolverMock;
- public function setUp()
+ /**
+ * @inheritdoc
+ */
+ public function setUp():void
{
- $this->customerRegistryMock = $this->createMock(\Magento\Customer\Model\CustomerRegistry::class);
-
- $this->storeManagerMock = $this->createMock(\Magento\Store\Model\StoreManagerInterface::class);
-
- $this->transportBuilderMock = $this->createMock(\Magento\Framework\Mail\Template\TransportBuilder::class);
+ $this->customerRegistryMock = $this->createMock(CustomerRegistry::class);
+ $this->storeManagerMock = $this->createMock(StoreManagerInterface::class);
+ $this->transportBuilderMock = $this->createMock(TransportBuilder::class);
+ $this->customerViewHelperMock = $this->createMock(View::class);
+ $this->dataProcessorMock = $this->createMock(DataObjectProcessor::class);
- $this->customerViewHelperMock = $this->createMock(\Magento\Customer\Helper\View::class);
-
- $this->dataProcessorMock = $this->createMock(\Magento\Framework\Reflection\DataObjectProcessor::class);
-
- $contextMock = $this->createPartialMock(\Magento\Framework\App\Helper\Context::class, ['getScopeConfig']);
+ $contextMock = $this->createPartialMock(Context::class, ['getScopeConfig']);
$this->scopeConfigMock = $this->createPartialMock(
- \Magento\Framework\App\Config\ScopeConfigInterface::class,
+ ScopeConfigInterface::class,
['getValue', 'isSetFlag']
);
@@ -92,16 +136,16 @@ public function setUp()
->method('getScopeConfig')
->willReturn($this->scopeConfigMock);
- $this->customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class);
+ $this->customerSecureMock = $this->createMock(CustomerSecure::class);
- $this->storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $this->storeMock = $this->createMock(Store::class);
$this->senderResolverMock = $this->getMockBuilder(SenderResolverInterface::class)
->setMethods(['resolve'])
->disableOriginalConstructor()
->getMockForAbstractClass();
- $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
+ $objectManager = new ObjectManagerHelper($this);
$this->model = $objectManager->getObject(
EmailNotification::class,
@@ -118,24 +162,27 @@ public function setUp()
}
/**
+ * Test email notify when credentials changed
+ *
* @param int $testNumber
+ * @param int $customerStoreId
* @param string $oldEmail
* @param string $newEmail
* @param bool $isPasswordChanged
- *
* @dataProvider sendNotificationEmailsDataProvider
+ *
+ * @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPasswordChanged)
- {
- $customerId = 1;
- $customerStoreId = 2;
- $customerWebsiteId = 1;
+ public function testEmailNotifyWhenCredentialsChanged(
+ $testNumber,
+ $customerStoreId,
+ $oldEmail,
+ $newEmail,
+ $isPasswordChanged
+ ):void {
$customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
- $senderValues = ['name' => $sender, 'email' => $sender];
+ $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER];
$expects = $this->once();
$xmlPathTemplate = EmailNotification::XML_PATH_RESET_PASSWORD_TEMPLATE;
@@ -145,7 +192,7 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
$expects = $this->once();
break;
case 2:
- $xmlPathTemplate = \Magento\Customer\Model\EmailNotification::XML_PATH_CHANGE_EMAIL_TEMPLATE;
+ $xmlPathTemplate = EmailNotification::XML_PATH_CHANGE_EMAIL_TEMPLATE;
$expects = $this->exactly(2);
break;
case 3:
@@ -157,22 +204,23 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
$this->senderResolverMock
->expects($expects)
->method('resolve')
- ->with($sender, $customerStoreId)
+ ->with(self::STUB_SENDER, $customerStoreId)
->willReturn($senderValues);
- /** @var \PHPUnit_Framework_MockObject_MockObject $origCustomer */
- $origCustomer = $this->createMock(CustomerInterface::class);
- $origCustomer->expects($this->any())
+ /**
+ * @var MockObject $origCustomerMock
+ */
+ $origCustomerMock = $this->createMock(CustomerInterface::class);
+ $origCustomerMock->expects($this->any())
->method('getStoreId')
- ->willReturn(0);
- $origCustomer->expects($this->any())
+ ->willReturn($customerStoreId);
+ $origCustomerMock->expects($this->any())
->method('getId')
- ->willReturn($customerId);
- $origCustomer->expects($this->any())
- ->method('getWebsiteId')
- ->willReturn($customerWebsiteId);
+ ->willReturn(self::STUB_CUSTOMER_ID);
+ $origCustomerMock->expects($this->never())
+ ->method('getWebsiteId');
- $storeMock = $this->createMock(\Magento\Store\Model\Store::class);
+ $storeMock = $this->createMock(Store::class);
$storeMock->expects($this->any())
->method('getId')
->willReturn($customerStoreId);
@@ -181,31 +229,29 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
->method('getStore')
->willReturn($storeMock);
- $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']);
+ $websiteMock = $this->createPartialMock(Website::class, ['getStoreIds']);
$websiteMock->expects($this->any())
->method('getStoreIds')
->willReturn([$customerStoreId]);
- $this->storeManagerMock->expects(clone $expects)
- ->method('getWebsite')
- ->with($customerWebsiteId)
- ->willReturn($websiteMock);
+ $this->storeManagerMock->expects($this->never())
+ ->method('getWebsite');
- $customerSecureMock = $this->createMock(\Magento\Customer\Model\Data\CustomerSecure::class);
+ $customerSecureMock = $this->createMock(CustomerSecure::class);
$this->customerRegistryMock->expects(clone $expects)
->method('retrieveSecureData')
- ->with($customerId)
+ ->with(self::STUB_CUSTOMER_ID)
->willReturn($customerSecureMock);
$this->dataProcessorMock->expects(clone $expects)
->method('buildOutputDataArray')
- ->with($origCustomer, CustomerInterface::class)
+ ->with($origCustomerMock, CustomerInterface::class)
->willReturn($customerData);
$this->customerViewHelperMock->expects($this->any())
->method('getCustomerName')
- ->with($origCustomer)
- ->willReturn($customerName);
+ ->with($origCustomerMock)
+ ->willReturn(self::STUB_CUSTOMER_NAME);
$customerSecureMock->expects(clone $expects)
->method('addData')
@@ -213,13 +259,15 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
->willReturnSelf();
$customerSecureMock->expects(clone $expects)
->method('setData')
- ->with('name', $customerName)
+ ->with('name', self::STUB_CUSTOMER_NAME)
->willReturnSelf();
- /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $savedCustomer */
- $savedCustomer = clone $origCustomer;
+ /**
+ * @var CustomerInterface|MockObject $savedCustomer
+ */
+ $savedCustomer = clone $origCustomerMock;
- $origCustomer->expects($this->any())
+ $origCustomerMock->expects($this->any())
->method('getEmail')
->willReturn($oldEmail);
@@ -230,28 +278,40 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
$this->scopeConfigMock->expects($this->any())
->method('getValue')
->withConsecutive(
- [$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId],
[
- \Magento\Customer\Model\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ $xmlPathTemplate,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ ],
+ [
+ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ ],
+ [
+ $xmlPathTemplate,
+ ScopeInterface::SCOPE_STORE,
$customerStoreId
],
- [$xmlPathTemplate, \Magento\Store\Model\ScopeInterface::SCOPE_STORE, $customerStoreId],
[
- \Magento\Customer\Model\EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
- \Magento\Store\Model\ScopeInterface::SCOPE_STORE,
+ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
+ ScopeInterface::SCOPE_STORE,
$customerStoreId
]
- )
- ->willReturnOnConsecutiveCalls($templateIdentifier, $sender, $templateIdentifier, $sender);
+ )->willReturnOnConsecutiveCalls(
+ self::STUB_EMAIL_IDENTIFIER,
+ self::STUB_SENDER,
+ self::STUB_EMAIL_IDENTIFIER,
+ self::STUB_SENDER
+ );
$this->transportBuilderMock->expects(clone $expects)
->method('setTemplateIdentifier')
- ->with($templateIdentifier)
+ ->with(self::STUB_EMAIL_IDENTIFIER)
->willReturnSelf();
$this->transportBuilderMock->expects(clone $expects)
->method('setTemplateOptions')
- ->with(['area' => \Magento\Framework\App\Area::AREA_FRONTEND, 'store' => $customerStoreId])
+ ->with(['area' => Area::AREA_FRONTEND, 'store' => $customerStoreId])
->willReturnSelf();
$this->transportBuilderMock->expects(clone $expects)
->method('setTemplateVars')
@@ -264,10 +324,10 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
$this->transportBuilderMock->expects(clone $expects)
->method('addTo')
- ->withConsecutive([$oldEmail, $customerName], [$newEmail, $customerName])
+ ->withConsecutive([$oldEmail, self::STUB_CUSTOMER_NAME], [$newEmail, self::STUB_CUSTOMER_NAME])
->willReturnSelf();
- $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class);
+ $transport = $this->createMock(TransportInterface::class);
$this->transportBuilderMock->expects(clone $expects)
->method('getTransport')
@@ -280,25 +340,52 @@ public function testCredentialsChanged($testNumber, $oldEmail, $newEmail, $isPas
}
/**
+ * Provides Emails Data Provider
+ *
+ * @param void
* @return array
*/
- public function sendNotificationEmailsDataProvider()
+ public function sendNotificationEmailsDataProvider(): array
{
return [
[
'test_number' => 1,
+ 'customerStoreId' => 0,
'old_email' => 'test@example.com',
'new_email' => 'test@example.com',
'is_password_changed' => true
],
+ [
+ 'test_number' => 1,
+ 'customerStoreId' => 2,
+ 'old_email' => 'test@example.com',
+ 'new_email' => 'test@example.com',
+ 'is_password_changed' => true
+ ],
+ [
+ 'test_number' => 2,
+ 'customerStoreId' => 0,
+ 'old_email' => 'test1@example.com',
+ 'new_email' => 'test2@example.com',
+ 'is_password_changed' => false
+ ],
[
'test_number' => 2,
+ 'customerStoreId' => 2,
'old_email' => 'test1@example.com',
'new_email' => 'test2@example.com',
'is_password_changed' => false
],
[
'test_number' => 3,
+ 'customerStoreId' => 0,
+ 'old_email' => 'test1@example.com',
+ 'new_email' => 'test2@example.com',
+ 'is_password_changed' => true
+ ],
+ [
+ 'test_number' => 3,
+ 'customerStoreId' => 2,
'old_email' => 'test1@example.com',
'new_email' => 'test2@example.com',
'is_password_changed' => true
@@ -307,41 +394,43 @@ public function sendNotificationEmailsDataProvider()
}
/**
+ * Test Password Reminder Email Notify
+ *
+ * @param int $customerStoreId
+ * @dataProvider customerStoreIdDataProvider
+ * @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testPasswordReminder()
+ public function testPasswordReminder($customerStoreId):void
{
- $customerId = 1;
- $customerWebsiteId = 1;
- $customerStoreId = 2;
- $customerEmail = 'email@email.com';
$customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
- $senderValues = ['name' => $sender, 'email' => $sender];
+ $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER];
$storeIds = [1, 2];
$this->senderResolverMock
->expects($this->once())
->method('resolve')
- ->with($sender, $customerStoreId)
+ ->with(self::STUB_SENDER, $customerStoreId)
->willReturn($senderValues);
- /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
- $customer = $this->createMock(CustomerInterface::class);
- $customer->expects($this->any())
+ /**
+ * @var CustomerInterface|MockObject $customerMock
+ */
+ $customerMock = $this->createMock(CustomerInterface::class);
+ $customerMock->expects($this->never())
+ ->method('getWebsiteId');
+ $customerMock->expects($this->any())
->method('getWebsiteId')
- ->willReturn($customerWebsiteId);
- $customer->expects($this->any())
+ ->willReturn(self::STUB_CUSTOMER_WEBSITE_ID);
+ $customerMock->expects($this->any())
->method('getStoreId')
->willReturn($customerStoreId);
- $customer->expects($this->any())
+ $customerMock->expects($this->any())
->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->any())
+ ->willReturn(self::STUB_CUSTOMER_ID);
+ $customerMock->expects($this->any())
->method('getEmail')
- ->willReturn($customerEmail);
+ ->willReturn(self::STUB_CUSTOMER_EMAIL);
$this->storeMock->expects($this->any())
->method('getId')
@@ -351,30 +440,30 @@ public function testPasswordReminder()
->method('getStore')
->willReturn($this->storeMock);
- $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']);
+ $websiteMock = $this->createPartialMock(Website::class, ['getStoreIds']);
$websiteMock->expects($this->any())
->method('getStoreIds')
->willReturn($storeIds);
$this->storeManagerMock->expects($this->any())
->method('getWebsite')
- ->with($customerWebsiteId)
+ ->with(self::STUB_CUSTOMER_WEBSITE_ID)
->willReturn($websiteMock);
$this->customerRegistryMock->expects($this->once())
->method('retrieveSecureData')
- ->with($customerId)
+ ->with(self::STUB_CUSTOMER_ID)
->willReturn($this->customerSecureMock);
$this->dataProcessorMock->expects($this->once())
->method('buildOutputDataArray')
- ->with($customer, CustomerInterface::class)
+ ->with($customerMock, CustomerInterface::class)
->willReturn($customerData);
$this->customerViewHelperMock->expects($this->any())
->method('getCustomerName')
- ->with($customer)
- ->willReturn($customerName);
+ ->with($customerMock)
+ ->willReturn(self::STUB_CUSTOMER_NAME);
$this->customerSecureMock->expects($this->once())
->method('addData')
@@ -382,65 +471,69 @@ public function testPasswordReminder()
->willReturnSelf();
$this->customerSecureMock->expects($this->once())
->method('setData')
- ->with('name', $customerName)
+ ->with('name', self::STUB_CUSTOMER_NAME)
->willReturnSelf();
$this->scopeConfigMock->expects($this->at(0))
->method('getValue')
- ->with(EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($templateIdentifier);
+ ->with(
+ EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ )->willReturn(self::STUB_EMAIL_IDENTIFIER);
$this->scopeConfigMock->expects($this->at(1))
->method('getValue')
- ->with(EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($sender);
+ ->with(
+ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ )->willReturn(self::STUB_SENDER);
$this->mockDefaultTransportBuilder(
- $templateIdentifier,
+ self::STUB_EMAIL_IDENTIFIER,
$customerStoreId,
$senderValues,
- $customerEmail,
- $customerName,
+ self::STUB_CUSTOMER_EMAIL,
+ self::STUB_CUSTOMER_NAME,
['customer' => $this->customerSecureMock, 'store' => $this->storeMock]
);
- $this->model->passwordReminder($customer);
+ $this->model->passwordReminder($customerMock);
}
/**
+ * Test password reminder customer withouer store id info
+ *
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testPasswordReminderCustomerWithoutStoreId()
+ public function testPasswordReminderCustomerWithoutStoreId():void
{
- $customerId = 1;
- $customerWebsiteId = 1;
$customerStoreId = null;
- $customerEmail = 'email@email.com';
$customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
- $senderValues = ['name' => $sender, 'email' => $sender];
+ $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER];
$storeIds = [1, 2];
$defaultStoreId = reset($storeIds);
$this->senderResolverMock
->expects($this->once())
->method('resolve')
- ->with($sender, $defaultStoreId)
+ ->with(self::STUB_SENDER, $defaultStoreId)
->willReturn($senderValues);
- /** @var CustomerInterface | \PHPUnit_Framework_MockObject_MockObject $customer */
+ /**
+ * @var CustomerInterface|MockObject $customer
+ */
$customer = $this->createMock(CustomerInterface::class);
$customer->expects($this->any())
->method('getWebsiteId')
- ->willReturn($customerWebsiteId);
+ ->willReturn(self::STUB_CUSTOMER_WEBSITE_ID);
$customer->expects($this->any())
->method('getStoreId')
->willReturn($customerStoreId);
$customer->expects($this->any())
->method('getId')
- ->willReturn($customerId);
+ ->willReturn(self::STUB_CUSTOMER_ID);
$customer->expects($this->any())
->method('getEmail')
- ->willReturn($customerEmail);
+ ->willReturn(self::STUB_CUSTOMER_EMAIL);
$this->storeMock->expects($this->any())
->method('getId')
->willReturn($defaultStoreId);
@@ -451,18 +544,18 @@ public function testPasswordReminderCustomerWithoutStoreId()
->method('getStore')
->with($defaultStoreId)
->willReturn($this->storeMock);
- $websiteMock = $this->createPartialMock(\Magento\Store\Model\Website::class, ['getStoreIds']);
+ $websiteMock = $this->createPartialMock(Website::class, ['getStoreIds']);
$websiteMock->expects($this->any())
->method('getStoreIds')
->willReturn($storeIds);
$this->storeManagerMock->expects($this->any())
->method('getWebsite')
- ->with($customerWebsiteId)
+ ->with(self::STUB_CUSTOMER_WEBSITE_ID)
->willReturn($websiteMock);
$this->customerRegistryMock->expects($this->once())
->method('retrieveSecureData')
- ->with($customerId)
+ ->with(self::STUB_CUSTOMER_ID)
->willReturn($this->customerSecureMock);
$this->dataProcessorMock->expects($this->once())
->method('buildOutputDataArray')
@@ -471,65 +564,76 @@ public function testPasswordReminderCustomerWithoutStoreId()
$this->customerViewHelperMock->expects($this->any())
->method('getCustomerName')
->with($customer)
- ->willReturn($customerName);
+ ->willReturn(self::STUB_CUSTOMER_NAME);
$this->customerSecureMock->expects($this->once())
->method('addData')
->with($customerData)
->willReturnSelf();
$this->customerSecureMock->expects($this->once())
->method('setData')
- ->with('name', $customerName)
+ ->with('name', self::STUB_CUSTOMER_NAME)
->willReturnSelf();
$this->scopeConfigMock->expects($this->at(0))
->method('getValue')
- ->with(EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $defaultStoreId)
- ->willReturn($templateIdentifier);
+ ->with(
+ EmailNotification::XML_PATH_REMIND_EMAIL_TEMPLATE,
+ ScopeInterface::SCOPE_STORE,
+ $defaultStoreId
+ )->willReturn(self::STUB_EMAIL_IDENTIFIER);
$this->scopeConfigMock->expects($this->at(1))
->method('getValue')
- ->with(EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $defaultStoreId)
- ->willReturn($sender);
+ ->with(
+ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
+ ScopeInterface::SCOPE_STORE,
+ $defaultStoreId
+ )->willReturn(self::STUB_SENDER);
$this->mockDefaultTransportBuilder(
- $templateIdentifier,
+ self::STUB_EMAIL_IDENTIFIER,
$defaultStoreId,
$senderValues,
- $customerEmail,
- $customerName,
+ self::STUB_CUSTOMER_EMAIL,
+ self::STUB_CUSTOMER_NAME,
['customer' => $this->customerSecureMock, 'store' => $this->storeMock]
);
$this->model->passwordReminder($customer);
}
/**
+ * Test email notify for password reset confirm
+ *
+ * @dataProvider customerStoreIdDataProvider
+ * @param int $customerStoreId
+ * @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testPasswordResetConfirmation()
+ public function testPasswordResetConfirmation($customerStoreId):void
{
- $customerId = 1;
- $customerStoreId = 2;
- $customerEmail = 'email@email.com';
$customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
- $senderValues = ['name' => $sender, 'email' => $sender];
+ $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER];
$this->senderResolverMock
->expects($this->once())
->method('resolve')
- ->with($sender, $customerStoreId)
+ ->with(self::STUB_SENDER, $customerStoreId)
->willReturn($senderValues);
- /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
- $customer = $this->createMock(CustomerInterface::class);
- $customer->expects($this->once())
+ /**
+ * @var CustomerInterface|MockObject $customerMock
+ */
+ $customerMock = $this->createMock(CustomerInterface::class);
+
+ $customerMock->expects($this->never())
+ ->method('getWebsiteId');
+
+ $customerMock->expects($this->once())
->method('getStoreId')
->willReturn($customerStoreId);
- $customer->expects($this->any())
+ $customerMock->expects($this->any())
->method('getId')
- ->willReturn($customerId);
- $customer->expects($this->any())
+ ->willReturn(self::STUB_CUSTOMER_ID);
+ $customerMock->expects($this->any())
->method('getEmail')
- ->willReturn($customerEmail);
+ ->willReturn(self::STUB_CUSTOMER_EMAIL);
$this->storeMock->expects($this->any())
->method('getId')
@@ -541,18 +645,18 @@ public function testPasswordResetConfirmation()
$this->customerRegistryMock->expects($this->once())
->method('retrieveSecureData')
- ->with($customerId)
+ ->with(self::STUB_CUSTOMER_ID)
->willReturn($this->customerSecureMock);
$this->dataProcessorMock->expects($this->once())
->method('buildOutputDataArray')
- ->with($customer, CustomerInterface::class)
+ ->with($customerMock, CustomerInterface::class)
->willReturn($customerData);
$this->customerViewHelperMock->expects($this->any())
->method('getCustomerName')
- ->with($customer)
- ->willReturn($customerName);
+ ->with($customerMock)
+ ->willReturn(self::STUB_CUSTOMER_NAME);
$this->customerSecureMock->expects($this->once())
->method('addData')
@@ -560,61 +664,70 @@ public function testPasswordResetConfirmation()
->willReturnSelf();
$this->customerSecureMock->expects($this->once())
->method('setData')
- ->with('name', $customerName)
+ ->with('name', self::STUB_CUSTOMER_NAME)
->willReturnSelf();
$this->scopeConfigMock->expects($this->at(0))
->method('getValue')
- ->with(EmailNotification::XML_PATH_FORGOT_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($templateIdentifier);
+ ->with(
+ EmailNotification::XML_PATH_FORGOT_EMAIL_TEMPLATE,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ )->willReturn(self::STUB_EMAIL_IDENTIFIER);
$this->scopeConfigMock->expects($this->at(1))
->method('getValue')
- ->with(EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($sender);
+ ->with(
+ EmailNotification::XML_PATH_FORGOT_EMAIL_IDENTITY,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ )->willReturn(self::STUB_SENDER);
$this->mockDefaultTransportBuilder(
- $templateIdentifier,
+ self::STUB_EMAIL_IDENTIFIER,
$customerStoreId,
$senderValues,
- $customerEmail,
- $customerName,
+ self::STUB_CUSTOMER_EMAIL,
+ self::STUB_CUSTOMER_NAME,
['customer' => $this->customerSecureMock, 'store' => $this->storeMock]
);
- $this->model->passwordResetConfirmation($customer);
+ $this->model->passwordResetConfirmation($customerMock);
}
/**
+ * Test email notify with new account
+ *
+ * @dataProvider customerStoreIdDataProvider
+ * @param int $customerStoreId
+ * @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
- public function testNewAccount()
+ public function testNewAccount($customerStoreId):void
{
- $customerId = 1;
- $customerStoreId = 2;
- $customerEmail = 'email@email.com';
$customerData = ['key' => 'value'];
- $customerName = 'Customer Name';
- $templateIdentifier = 'Template Identifier';
- $sender = 'Sender';
- $senderValues = ['name' => $sender, 'email' => $sender];
+ $senderValues = ['name' => self::STUB_SENDER, 'email' => self::STUB_SENDER];
$this->senderResolverMock
->expects($this->once())
->method('resolve')
- ->with($sender, $customerStoreId)
+ ->with(self::STUB_SENDER, $customerStoreId)
->willReturn($senderValues);
- /** @var CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
+ /**
+ * @var CustomerInterface|MockObject $customer
+ */
$customer = $this->createMock(CustomerInterface::class);
+ $customer->expects($this->never())
+ ->method('getWebsiteId');
$customer->expects($this->any())
->method('getStoreId')
->willReturn($customerStoreId);
$customer->expects($this->any())
->method('getId')
- ->willReturn($customerId);
+ ->willReturn(self::STUB_CUSTOMER_ID);
$customer->expects($this->any())
->method('getEmail')
- ->willReturn($customerEmail);
+ ->willReturn(self::STUB_CUSTOMER_EMAIL);
$this->storeMock->expects($this->any())
->method('getId')
@@ -627,7 +740,7 @@ public function testNewAccount()
$this->customerRegistryMock->expects($this->once())
->method('retrieveSecureData')
- ->with($customerId)
+ ->with(self::STUB_CUSTOMER_ID)
->willReturn($this->customerSecureMock);
$this->dataProcessorMock->expects($this->once())
@@ -638,7 +751,7 @@ public function testNewAccount()
$this->customerViewHelperMock->expects($this->any())
->method('getCustomerName')
->with($customer)
- ->willReturn($customerName);
+ ->willReturn(self::STUB_CUSTOMER_NAME);
$this->customerSecureMock->expects($this->once())
->method('addData')
@@ -646,28 +759,52 @@ public function testNewAccount()
->willReturnSelf();
$this->customerSecureMock->expects($this->once())
->method('setData')
- ->with('name', $customerName)
+ ->with('name', self::STUB_CUSTOMER_NAME)
->willReturnSelf();
$this->scopeConfigMock->expects($this->at(0))
->method('getValue')
- ->with(EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($templateIdentifier);
+ ->with(
+ EmailNotification::XML_PATH_REGISTER_EMAIL_TEMPLATE,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ )->willReturn(self::STUB_EMAIL_IDENTIFIER);
$this->scopeConfigMock->expects($this->at(1))
->method('getValue')
- ->with(EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY, ScopeInterface::SCOPE_STORE, $customerStoreId)
- ->willReturn($sender);
+ ->with(
+ EmailNotification::XML_PATH_REGISTER_EMAIL_IDENTITY,
+ ScopeInterface::SCOPE_STORE,
+ $customerStoreId
+ )->willReturn(self::STUB_SENDER);
$this->mockDefaultTransportBuilder(
- $templateIdentifier,
+ self::STUB_EMAIL_IDENTIFIER,
$customerStoreId,
$senderValues,
- $customerEmail,
- $customerName,
+ self::STUB_CUSTOMER_EMAIL,
+ self::STUB_CUSTOMER_NAME,
['customer' => $this->customerSecureMock, 'back_url' => '', 'store' => $this->storeMock]
);
- $this->model->newAccount($customer, EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED, '', $customerStoreId);
+ $this->model->newAccount(
+ $customer,
+ EmailNotification::NEW_ACCOUNT_EMAIL_REGISTERED,
+ '',
+ $customerStoreId
+ );
+ }
+
+ /**
+ * DataProvider customer store
+ *
+ * @return array
+ */
+ public function customerStoreIdDataProvider():array
+ {
+ return [
+ ['customerStoreId' => 0],
+ ['customerStoreId' => 2]
+ ];
}
/**
@@ -689,8 +826,8 @@ private function mockDefaultTransportBuilder(
string $customerEmail,
string $customerName,
array $templateVars = []
- ): void {
- $transport = $this->createMock(\Magento\Framework\Mail\TransportInterface::class);
+ ):void {
+ $transportMock = $this->createMock(TransportInterface::class);
$this->transportBuilderMock->expects($this->once())
->method('setTemplateIdentifier')
@@ -714,9 +851,9 @@ private function mockDefaultTransportBuilder(
->willReturnSelf();
$this->transportBuilderMock->expects($this->once())
->method('getTransport')
- ->willReturn($transport);
+ ->willReturn($transportMock);
- $transport->expects($this->once())
+ $transportMock->expects($this->once())
->method('sendMessage');
}
}
diff --git a/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php b/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php
index 15337d8968305..095a83101322f 100644
--- a/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Model/Layout/DepersonalizePluginTest.php
@@ -3,143 +3,177 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Customer\Test\Unit\Model\Layout;
+use Magento\Customer\Model\Customer;
+use Magento\Customer\Model\CustomerFactory;
+use Magento\Customer\Model\Layout\DepersonalizePlugin;
+use Magento\Customer\Model\Session as CustomerSession;
+use Magento\Customer\Model\Visitor as VisitorModel;
+use Magento\Framework\Data\Form\FormKey;
+use Magento\Framework\Session\Generic as GenericSession;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+use Magento\Framework\View\LayoutInterface;
+use Magento\PageCache\Model\DepersonalizeChecker;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
+
/**
- * Class DepersonalizePluginTest
+ * Unit tests for \Magento\Customer\Model\Layout\DepersonalizePlugin class.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class DepersonalizePluginTest extends \PHPUnit\Framework\TestCase
+class DepersonalizePluginTest extends TestCase
{
/**
- * @var \Magento\Customer\Model\Layout\DepersonalizePlugin
+ * @var DepersonalizePlugin
*/
- protected $plugin;
+ private $plugin;
/**
- * @var \Magento\Framework\View\Layout|\PHPUnit_Framework_MockObject_MockObject
+ * @var LayoutInterface|MockObject
*/
- protected $layoutMock;
+ private $layoutMock;
/**
- * @var \Magento\Framework\Session\Generic|\PHPUnit_Framework_MockObject_MockObject
+ * @var GenericSession|MockObject
*/
- protected $sessionMock;
+ private $sessionMock;
/**
- * @var \Magento\Customer\Model\Session|\PHPUnit_Framework_MockObject_MockObject
+ * @var CustomerSession|MockObject
*/
- protected $customerSessionMock;
+ private $customerSessionMock;
/**
- * @var \Magento\Customer\Model\CustomerFactory|\PHPUnit_Framework_MockObject_MockObject
+ * @var CustomerFactory|MockObject
*/
- protected $customerFactoryMock;
+ private $customerFactoryMock;
/**
- * @var \Magento\Customer\Model\Customer|\PHPUnit_Framework_MockObject_MockObject
+ * @var Customer|MockObject
*/
- protected $customerMock;
+ private $customerMock;
/**
- * @var \Magento\Customer\Model\Visitor|\PHPUnit_Framework_MockObject_MockObject
+ * @var VisitorModel|MockObject
*/
- protected $visitorMock;
+ private $visitorMock;
/**
- * @var \Magento\PageCache\Model\DepersonalizeChecker|\PHPUnit_Framework_MockObject_MockObject
+ * @var DepersonalizeChecker|MockObject
*/
- protected $depersonalizeCheckerMock;
+ private $depersonalizeCheckerMock;
/**
- * SetUp
+ * @inheritdoc
*/
protected function setUp()
{
- $this->layoutMock = $this->createMock(\Magento\Framework\View\Layout::class);
+ $this->layoutMock = $this->getMockForAbstractClass(LayoutInterface::class);
$this->sessionMock = $this->createPartialMock(
- \Magento\Framework\Session\Generic::class,
+ GenericSession::class,
['clearStorage', 'setData', 'getData']
);
$this->customerSessionMock = $this->createPartialMock(
- \Magento\Customer\Model\Session::class,
+ CustomerSession::class,
['getCustomerGroupId', 'setCustomerGroupId', 'clearStorage', 'setCustomer']
);
- $this->customerFactoryMock = $this->createPartialMock(
- \Magento\Customer\Model\CustomerFactory::class,
- ['create']
- );
+ $this->customerFactoryMock = $this->createPartialMock(CustomerFactory::class, ['create']);
$this->customerMock = $this->createPartialMock(
- \Magento\Customer\Model\Customer::class,
+ Customer::class,
['setGroupId', '__wakeup']
);
- $this->visitorMock = $this->createMock(\Magento\Customer\Model\Visitor::class);
+ $this->visitorMock = $this->createMock(VisitorModel::class);
$this->customerFactoryMock->expects($this->any())
->method('create')
- ->will($this->returnValue($this->customerMock));
- $this->depersonalizeCheckerMock = $this->createMock(\Magento\PageCache\Model\DepersonalizeChecker::class);
-
- $this->plugin = new \Magento\Customer\Model\Layout\DepersonalizePlugin(
- $this->depersonalizeCheckerMock,
- $this->sessionMock,
- $this->customerSessionMock,
- $this->customerFactoryMock,
- $this->visitorMock
+ ->willReturn($this->customerMock);
+ $this->depersonalizeCheckerMock = $this->createMock(DepersonalizeChecker::class);
+
+ $this->plugin = (new ObjectManagerHelper($this))->getObject(
+ DepersonalizePlugin::class,
+ [
+ 'depersonalizeChecker' => $this->depersonalizeCheckerMock,
+ 'session' => $this->sessionMock,
+ 'customerSession' => $this->customerSessionMock,
+ 'customerFactory' => $this->customerFactoryMock,
+ 'visitor' => $this->visitorMock,
+ ]
);
}
- public function testBeforeGenerateXml()
+ /**
+ * Test beforeGenerateXml method when depersonalization is needed.
+ *
+ * @return void
+ */
+ public function testBeforeGenerateXml(): void
{
$this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(true);
$this->customerSessionMock->expects($this->once())->method('getCustomerGroupId');
$this->sessionMock
->expects($this->once())
->method('getData')
- ->with($this->equalTo(\Magento\Framework\Data\Form\FormKey::FORM_KEY));
- $output = $this->plugin->beforeGenerateXml($this->layoutMock);
- $this->assertEquals([], $output);
+ ->with($this->equalTo(FormKey::FORM_KEY));
+ $this->plugin->beforeGenerateXml($this->layoutMock);
}
- public function testBeforeGenerateXmlNoDepersonalize()
+ /**
+ * Test beforeGenerateXml method when depersonalization is not needed.
+ *
+ * @return void
+ */
+ public function testBeforeGenerateXmlNoDepersonalize(): void
{
$this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false);
$this->customerSessionMock->expects($this->never())->method('getCustomerGroupId');
$this->sessionMock
->expects($this->never())
->method('getData');
- $output = $this->plugin->beforeGenerateXml($this->layoutMock);
- $this->assertEquals([], $output);
+ $this->plugin->beforeGenerateXml($this->layoutMock);
}
- public function testAfterGenerateXml()
+ /**
+ * Test afterGenerateElements method when depersonalization is needed.
+ *
+ * @return void
+ */
+ public function testAfterGenerateElements(): void
{
- $expectedResult = $this->createMock(\Magento\Framework\View\Layout::class);
$this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(true);
$this->visitorMock->expects($this->once())->method('setSkipRequestLogging')->with($this->equalTo(true));
$this->visitorMock->expects($this->once())->method('unsetData');
$this->sessionMock->expects($this->once())->method('clearStorage');
$this->customerSessionMock->expects($this->once())->method('clearStorage');
$this->customerSessionMock->expects($this->once())->method('setCustomerGroupId')->with($this->equalTo(null));
- $this->customerMock->expects($this->once())->method('setGroupId')->with($this->equalTo(null))->willReturnSelf();
+ $this->customerMock
+ ->expects($this->once())
+ ->method('setGroupId')
+ ->with($this->equalTo(null))
+ ->willReturnSelf();
$this->sessionMock
->expects($this->once())
->method('setData')
->with(
- $this->equalTo(\Magento\Framework\Data\Form\FormKey::FORM_KEY),
+ $this->equalTo(FormKey::FORM_KEY),
$this->equalTo(null)
);
$this->customerSessionMock
->expects($this->once())
->method('setCustomer')
->with($this->equalTo($this->customerMock));
- $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult);
- $this->assertSame($expectedResult, $actualResult);
+ $this->assertEmpty($this->plugin->afterGenerateElements($this->layoutMock));
}
- public function testAfterGenerateXmlNoDepersonalize()
+ /**
+ * Test afterGenerateElements method when depersonalization is not needed.
+ *
+ * @return void
+ */
+ public function testAfterGenerateElementsNoDepersonalize(): void
{
- $expectedResult = $this->createMock(\Magento\Framework\View\Layout::class);
$this->depersonalizeCheckerMock->expects($this->once())->method('checkIfDepersonalize')->willReturn(false);
$this->visitorMock->expects($this->never())->method('setSkipRequestLogging');
$this->visitorMock->expects($this->never())->method('unsetData');
@@ -149,7 +183,6 @@ public function testAfterGenerateXmlNoDepersonalize()
$this->customerMock->expects($this->never())->method('setGroupId');
$this->sessionMock->expects($this->never())->method('setData');
$this->customerSessionMock->expects($this->never())->method('setCustomer');
- $actualResult = $this->plugin->afterGenerateXml($this->layoutMock, $expectedResult);
- $this->assertSame($expectedResult, $actualResult);
+ $this->assertEmpty($this->plugin->afterGenerateElements($this->layoutMock));
}
}
diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php
index d917cc4908ac8..8b926e8dfdec8 100644
--- a/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/ColumnFactoryTest.php
@@ -6,28 +6,29 @@
namespace Magento\Customer\Test\Unit\Ui\Component;
use Magento\Customer\Ui\Component\ColumnFactory;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Test ColumnFactory Class
*/
class ColumnFactoryTest extends \PHPUnit\Framework\TestCase
{
- /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Customer\Api\Data\OptionInterface|MockObject */
protected $attributeOption;
- /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */
protected $context;
- /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */
protected $componentFactory;
- /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|MockObject */
protected $attributeMetadata;
- /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|MockObject */
protected $column;
- /** @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Customer\Ui\Component\Listing\Column\InlineEditUpdater|MockObject */
protected $inlineEditUpdater;
/** @var ColumnFactory */
@@ -93,7 +94,6 @@ public function testCreate()
]
],
'component' => 'Magento_Ui/js/grid/columns/column',
- '__disableTmpl' => 'true'
],
],
'context' => $this->context,
diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php
index f3c0a56262622..3a23cf66faddc 100644
--- a/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/FilterFactoryTest.php
@@ -6,25 +6,26 @@
namespace Magento\Customer\Test\Unit\Ui\Component;
use Magento\Customer\Ui\Component\FilterFactory;
+use PHPUnit\Framework\MockObject\MockObject;
/**
* Test FilterFactory Class
*/
class FilterFactoryTest extends \PHPUnit\Framework\TestCase
{
- /** @var \Magento\Customer\Api\Data\OptionInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Customer\Api\Data\OptionInterface|MockObject */
protected $attributeOption;
- /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */
protected $context;
- /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */
protected $componentFactory;
- /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Customer\Api\Data\AttributeMetadataInterface|MockObject */
protected $attributeMetadata;
- /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Ui\Component\Listing\Columns\ColumnInterface|MockObject */
protected $filter;
/** @var FilterFactory */
@@ -72,7 +73,6 @@ public function testCreate()
'config' => [
'dataScope' => $filterName,
'label' => __('Label'),
- '__disableTmpl' => 'true',
'options' => [['value' => 'Value', 'label' => 'Label']],
'caption' => __('Select...'),
],
diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php
index 4a16acd98d827..3792f0d214537 100644
--- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/ActionsTest.php
@@ -6,22 +6,23 @@
namespace Magento\Customer\Test\Unit\Ui\Component\Listing\Column;
use Magento\Customer\Ui\Component\Listing\Column\Actions;
+use PHPUnit\Framework\MockObject\MockObject;
/**
- * Class ActionsTest
+ * Class Actions test for Listing Colummn
*/
class ActionsTest extends \PHPUnit\Framework\TestCase
{
/** @var Actions */
protected $component;
- /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\View\Element\UiComponent\ContextInterface|MockObject */
protected $context;
- /** @var \Magento\Framework\View\Element\UiComponentFactory|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\View\Element\UiComponentFactory|MockObject */
protected $uiComponentFactory;
- /** @var \Magento\Framework\UrlInterface|\PHPUnit_Framework_MockObject_MockObject */
+ /** @var \Magento\Framework\UrlInterface|MockObject */
protected $urlBuilder;
public function setup()
@@ -68,7 +69,6 @@ public function testPrepareDataSource()
'href' => 'http://magento.com/customer/index/edit',
'label' => new \Magento\Framework\Phrase('Edit'),
'hidden' => false,
- '__disableTmpl' => true,
]
]
],
diff --git a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php
index 02cacea5c2601..deec8ab7f7281 100644
--- a/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php
+++ b/app/code/Magento/Customer/Test/Unit/Ui/Component/Listing/Column/GroupActionsTest.php
@@ -202,7 +202,6 @@ public function testPrepareDataSourceWithDefaultGroup()
'edit' => [
'href' => static::STUB_GROUP_EDIT_URL,
'label' => __('Edit'),
- '__disableTmpl' => true,
]
]
],
@@ -213,7 +212,6 @@ public function testPrepareDataSourceWithDefaultGroup()
'edit' => [
'href' => static::STUB_GROUP_EDIT_URL,
'label' => __('Edit'),
- '__disableTmpl' => true,
]
]
]
@@ -289,13 +287,11 @@ public function customerGroupsDataProvider(): array
'edit' => [
'href' => static::STUB_GROUP_EDIT_URL,
'label' => __('Edit'),
- '__disableTmpl' => true,
],
'delete' => [
'href' => static::STUB_GROUP_DELETE_URL,
'label' => __('Delete'),
'post' => true,
- '__disableTmpl' => true,
'confirm' => [
'title' => __('Delete %1', 'General'),
'message' => __(
diff --git a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php
index a69e84ab41a2c..22f1a3315595b 100644
--- a/app/code/Magento/Customer/Ui/Component/ColumnFactory.php
+++ b/app/code/Magento/Customer/Ui/Component/ColumnFactory.php
@@ -77,7 +77,6 @@ public function create(array $attributeData, $columnName, $context, array $confi
'component' => $this->getJsComponent(
$this->getDataType($attributeData[AttributeMetadata::FRONTEND_INPUT])
),
- '__disableTmpl' => 'true'
],
$config
);
diff --git a/app/code/Magento/Customer/Ui/Component/FilterFactory.php b/app/code/Magento/Customer/Ui/Component/FilterFactory.php
index 3e57db06246d4..7575062dd23db 100644
--- a/app/code/Magento/Customer/Ui/Component/FilterFactory.php
+++ b/app/code/Magento/Customer/Ui/Component/FilterFactory.php
@@ -48,7 +48,6 @@ public function create(array $attributeData, $context)
$config = [
'dataScope' => $attributeData[AttributeMetadata::ATTRIBUTE_CODE],
'label' => __($attributeData[AttributeMetadata::FRONTEND_LABEL]),
- '__disableTmpl' => 'true'
];
if ($attributeData[AttributeMetadata::OPTIONS]) {
$config['options'] = $attributeData[AttributeMetadata::OPTIONS];
diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php
index 9441beeb7dc61..d6a4067ef3db6 100644
--- a/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php
+++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/Actions.php
@@ -60,7 +60,6 @@ public function prepareDataSource(array $dataSource)
),
'label' => __('Edit'),
'hidden' => false,
- '__disableTmpl' => true
];
}
}
diff --git a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php
index e5a536dc6ecd6..459ac3e29e993 100644
--- a/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php
+++ b/app/code/Magento/Customer/Ui/Component/Listing/Column/GroupActions.php
@@ -96,7 +96,6 @@ public function prepareDataSource(array $dataSource)
]
),
'label' => __('Edit'),
- '__disableTmpl' => true
],
];
@@ -117,7 +116,6 @@ public function prepareDataSource(array $dataSource)
)
],
'post' => true,
- '__disableTmpl' => true
];
}
}
diff --git a/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php b/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php
index e5739317bca8d..16caf346c808c 100644
--- a/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php
+++ b/app/code/Magento/Customer/Ui/Component/MassAction/Group/Options.php
@@ -10,7 +10,9 @@
use Magento\Customer\Model\ResourceModel\Group\CollectionFactory;
/**
- * Class Options
+ * Class Options for Mass Action Group
+ *
+ * Disable template needed for customers
*/
class Options implements \JsonSerializable
{
diff --git a/app/code/Magento/Customer/etc/di.xml b/app/code/Magento/Customer/etc/di.xml
index 60a2da9d6dfa7..ba0bb3bac6a98 100644
--- a/app/code/Magento/Customer/etc/di.xml
+++ b/app/code/Magento/Customer/etc/di.xml
@@ -357,6 +357,11 @@
+
+
+ Magento\Customer\Model\Session\Proxy
+
+
diff --git a/app/code/Magento/Customer/view/frontend/email/change_email.html b/app/code/Magento/Customer/view/frontend/email/change_email.html
index 4853adf638066..bd961ad99ec40 100644
--- a/app/code/Magento/Customer/view/frontend/email/change_email.html
+++ b/app/code/Magento/Customer/view/frontend/email/change_email.html
@@ -8,13 +8,12 @@
{{template config_path="design/email/header_template"}}
-{{trans "Hello,"}}
-
-
+{{trans "%name," name=$customer.name}}
{{trans "We have received a request to change the following information associated with your account at %store_name: email." store_name=$store.frontend_name}}
{{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}.
diff --git a/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html b/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html
index 49867bdedc9e0..4f5c85b2381f3 100644
--- a/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html
+++ b/app/code/Magento/Customer/view/frontend/email/change_email_and_password.html
@@ -8,13 +8,12 @@
{{template config_path="design/email/header_template"}}
-
{{trans "Hello,"}}
-
-
+{{trans "%name," name=$customer.name}}
{{trans "We have received a request to change the following information associated with your account at %store_name: email, password." store_name=$store.frontend_name}}
{{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}.
diff --git a/app/code/Magento/Customer/view/frontend/email/password_reset.html b/app/code/Magento/Customer/view/frontend/email/password_reset.html
index 79015117c2280..cab05a89227b6 100644
--- a/app/code/Magento/Customer/view/frontend/email/password_reset.html
+++ b/app/code/Magento/Customer/view/frontend/email/password_reset.html
@@ -9,13 +9,12 @@
"var customer.name":"Customer Name",
"var store.frontend_name":"Store Name",
"var store_email":"Store Email",
-"var store_phone":"Store Phone"
+"var store_phone":"Store Phone",
+"var customer.name":"Customer Name"
} @-->
{{template config_path="design/email/header_template"}}
-
{{trans "Hello,"}}
-
-
+{{trans "%name," name=$customer.name}}
{{trans "We have received a request to change the following information associated with your account at %store_name: password." store_name=$store.frontend_name}}
{{trans 'If you have not authorized this action, please contact us immediately at %store_email' store_email=$store_email |raw}}{{depend store_phone}} {{trans 'or call us at %store_phone' store_phone=$store_phone |raw}}{{/depend}}.
diff --git a/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php b/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
index 78531c7e6c22c..5800f7162b7f0 100644
--- a/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
+++ b/app/code/Magento/Developer/Console/Command/GeneratePatchCommand.php
@@ -7,13 +7,12 @@
namespace Magento\Developer\Console\Command;
-use Magento\Framework\App\ObjectManager;
use Magento\Framework\Component\ComponentRegistrar;
use Magento\Framework\Console\Cli;
use Magento\Framework\Exception\FileSystemException;
-use Magento\Framework\Filesystem\DirectoryList;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Filesystem\Directory\WriteFactory;
+use Magento\Framework\Filesystem\DirectoryList;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -58,20 +57,20 @@ class GeneratePatchCommand extends Command
* GeneratePatchCommand constructor.
*
* @param ComponentRegistrar $componentRegistrar
- * @param DirectoryList|null $directoryList
- * @param ReadFactory|null $readFactory
- * @param WriteFactory|null $writeFactory
+ * @param DirectoryList $directoryList
+ * @param ReadFactory $readFactory
+ * @param WriteFactory $writeFactory
*/
public function __construct(
ComponentRegistrar $componentRegistrar,
- DirectoryList $directoryList = null,
- ReadFactory $readFactory = null,
- WriteFactory $writeFactory = null
+ DirectoryList $directoryList,
+ ReadFactory $readFactory,
+ WriteFactory $writeFactory
) {
$this->componentRegistrar = $componentRegistrar;
- $this->directoryList = $directoryList ?: ObjectManager::getInstance()->get(DirectoryList::class);
- $this->readFactory = $readFactory ?: ObjectManager::getInstance()->get(ReadFactory::class);
- $this->writeFactory = $writeFactory ?: ObjectManager::getInstance()->get(WriteFactory::class);
+ $this->directoryList = $directoryList;
+ $this->readFactory = $readFactory;
+ $this->writeFactory = $writeFactory;
parent::__construct();
}
@@ -120,6 +119,7 @@ protected function configure()
*
* @param InputInterface $input
* @param OutputInterface $output
+ *
* @return int
* @throws FileSystemException
*/
@@ -194,8 +194,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
private function getPatchTemplate(): string
{
$read = $this->readFactory->create(__DIR__ . '/');
- $content = $read->readFile('patch_template.php.dist');
- return $content;
+ return $read->readFile('patch_template.php.dist');
}
/**
@@ -207,7 +206,6 @@ private function getPatchTemplate(): string
private function getRevertMethodTemplate(): string
{
$read = $this->readFactory->create(__DIR__ . '/');
- $content = $read->readFile('template_revert_function.php.dist');
- return $content;
+ return $read->readFile('template_revert_function.php.dist');
}
}
diff --git a/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php b/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php
index 1b2a0986fa0ad..10474d8455b1b 100644
--- a/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php
+++ b/app/code/Magento/Developer/Model/Css/PreProcessor/FileGenerator/PublicationDecorator.php
@@ -3,11 +3,12 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Developer\Model\Css\PreProcessor\FileGenerator;
use Magento\Developer\Model\Config\Source\WorkflowType;
use Magento\Framework\App\Config\ScopeConfigInterface;
-use Magento\Framework\App\ObjectManager;
use Magento\Framework\App\State;
use Magento\Framework\App\View\Asset\Publisher;
use Magento\Framework\Css\PreProcessor\File\Temporary;
@@ -31,22 +32,21 @@ class PublicationDecorator extends RelatedGenerator
private $scopeConfig;
/**
- * @var bool
+ * @var State
*/
- private $hasRelatedPublishing;
+ private $state;
/**
- * @var State
+ * @var bool
*/
- private $state;
+ private $hasRelatedPublishing;
/**
- * Constructor
- *
* @param Repository $assetRepository
* @param Temporary $temporaryFile
* @param Publisher $assetPublisher
* @param ScopeConfigInterface $scopeConfig
+ * @param State $state
* @param bool $hasRelatedPublishing
*/
public function __construct(
@@ -54,11 +54,13 @@ public function __construct(
Temporary $temporaryFile,
Publisher $assetPublisher,
ScopeConfigInterface $scopeConfig,
+ State $state,
$hasRelatedPublishing = false
) {
parent::__construct($assetRepository, $temporaryFile);
$this->assetPublisher = $assetPublisher;
$this->scopeConfig = $scopeConfig;
+ $this->state = $state;
$this->hasRelatedPublishing = $hasRelatedPublishing;
}
@@ -69,7 +71,7 @@ protected function generateRelatedFile($relatedFileId, LocalInterface $asset)
{
$relatedAsset = parent::generateRelatedFile($relatedFileId, $asset);
$isClientSideCompilation =
- $this->getState()->getMode() !== State::MODE_PRODUCTION
+ $this->state->getMode() !== State::MODE_PRODUCTION
&& WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH);
if ($this->hasRelatedPublishing || $isClientSideCompilation) {
@@ -78,17 +80,4 @@ protected function generateRelatedFile($relatedFileId, LocalInterface $asset)
return $relatedAsset;
}
-
- /**
- * @return State
- * @deprecated 100.2.0
- */
- private function getState()
- {
- if (null === $this->state) {
- $this->state = ObjectManager::getInstance()->get(State::class);
- }
-
- return $this->state;
- }
}
diff --git a/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php b/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php
index a10d7bca1b89e..07eb1257f9561 100644
--- a/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php
+++ b/app/code/Magento/Developer/Model/TemplateEngine/Plugin/DebugHints.php
@@ -1,7 +1,5 @@
storeManager = $storeManager;
$this->devHelper = $devHelper;
$this->debugHintsFactory = $debugHintsFactory;
+ $this->http = $http;
$this->debugHintsPath = $debugHintsPath;
- $this->http = $http ?: \Magento\Framework\App\ObjectManager::getInstance()->get(
- \Magento\Framework\App\Request\Http::class
- );
$this->debugHintsWithParam = $debugHintsWithParam;
$this->debugHintsParameter = $debugHintsParameter;
}
@@ -152,6 +156,7 @@ public function afterCreate(
]);
}
}
+
return $invocationResult;
}
}
diff --git a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php
index 6e230d351a25f..fac74a9e2d2bd 100644
--- a/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php
+++ b/app/code/Magento/Developer/Model/View/Asset/PreProcessor/PreprocessorStrategy.php
@@ -42,32 +42,34 @@ class PreprocessorStrategy implements PreProcessorInterface
private $state;
/**
- * Constructor
- *
* @param AlternativeSourceInterface $alternativeSource
* @param FrontendCompilation $frontendCompilation
* @param ScopeConfigInterface $scopeConfig
+ * @param State|null $state
*/
public function __construct(
AlternativeSourceInterface $alternativeSource,
FrontendCompilation $frontendCompilation,
- ScopeConfigInterface $scopeConfig
+ ScopeConfigInterface $scopeConfig,
+ ?State $state = null
) {
$this->frontendCompilation = $frontendCompilation;
$this->alternativeSource = $alternativeSource;
$this->scopeConfig = $scopeConfig;
+ $this->state = $state ?? ObjectManager::getInstance()->get(State::class);
}
/**
* Transform content and/or content type for the specified pre-processing chain object
*
* @param PreProcessor\Chain $chain
+ *
* @return void
*/
public function process(PreProcessor\Chain $chain)
{
$isClientSideCompilation =
- $this->getState()->getMode() !== State::MODE_PRODUCTION
+ $this->state->getMode() !== State::MODE_PRODUCTION
&& WorkflowType::CLIENT_SIDE_COMPILATION === $this->scopeConfig->getValue(WorkflowType::CONFIG_NAME_PATH);
if ($isClientSideCompilation) {
@@ -76,16 +78,4 @@ public function process(PreProcessor\Chain $chain)
$this->alternativeSource->process($chain);
}
}
-
- /**
- * @return State
- * @deprecated 100.2.0
- */
- private function getState()
- {
- if (null === $this->state) {
- $this->state = ObjectManager::getInstance()->get(State::class);
- }
- return $this->state;
- }
}
diff --git a/app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php b/app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php
index aef58a9a37e89..2e780d37bdf85 100644
--- a/app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php
+++ b/app/code/Magento/Developer/Model/XmlCatalog/Format/PhpStorm.php
@@ -3,14 +3,15 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
namespace Magento\Developer\Model\XmlCatalog\Format;
-use Magento\Framework\App\ObjectManager;
use Magento\Framework\DomDocument\DomDocumentFactory;
use Magento\Framework\Exception\FileSystemException;
use Magento\Framework\Filesystem\Directory\ReadFactory;
use Magento\Framework\Filesystem\Directory\ReadInterface;
+use Magento\Framework\Filesystem\DriverPool;
use Magento\Framework\Filesystem\File\WriteFactory;
/**
@@ -43,11 +44,11 @@ class PhpStorm implements FormatInterface
public function __construct(
ReadFactory $readFactory,
WriteFactory $fileWriteFactory,
- DomDocumentFactory $domDocumentFactory = null
+ DomDocumentFactory $domDocumentFactory
) {
$this->currentDirRead = $readFactory->create(getcwd());
$this->fileWriteFactory = $fileWriteFactory;
- $this->domDocumentFactory = $domDocumentFactory ?: ObjectManager::getInstance()->get(DomDocumentFactory::class);
+ $this->domDocumentFactory = $domDocumentFactory;
}
/**
@@ -55,6 +56,7 @@ public function __construct(
*
* @param string[] $dictionary
* @param string $configFilePath relative path to the PhpStorm misc.xml
+ *
* @return void
*/
public function generateCatalog(array $dictionary, $configFilePath)
@@ -65,7 +67,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
try {
$file = $this->fileWriteFactory->create(
$configFilePath,
- \Magento\Framework\Filesystem\DriverPool::FILE,
+ DriverPool::FILE,
'r'
);
$dom = $this->domDocumentFactory->create();
@@ -103,7 +105,7 @@ public function generateCatalog(array $dictionary, $configFilePath)
$dom->formatOutput = true;
$file = $this->fileWriteFactory->create(
$configFilePath,
- \Magento\Framework\Filesystem\DriverPool::FILE,
+ DriverPool::FILE,
'w'
);
$file->write($dom->saveXML());
diff --git a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php
index a918a562a926d..d7ab4fdea2c37 100644
--- a/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php
+++ b/app/code/Magento/Developer/Test/Unit/Model/TemplateEngine/Plugin/DebugHintsTest.php
@@ -3,60 +3,103 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Developer\Test\Unit\Model\TemplateEngine\Plugin;
+use Magento\Developer\Helper\Data;
+use Magento\Developer\Model\TemplateEngine\Decorator\DebugHints as DebugHintsDecorator;
use Magento\Developer\Model\TemplateEngine\Decorator\DebugHintsFactory;
use Magento\Developer\Model\TemplateEngine\Plugin\DebugHints;
+use Magento\Framework\App\Config\ScopeConfigInterface;
+use Magento\Framework\App\Request\Http;
+use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
+use Magento\Framework\View\TemplateEngineFactory;
+use Magento\Framework\View\TemplateEngineInterface;
+use Magento\Store\Api\Data\StoreInterface;
use Magento\Store\Model\ScopeInterface;
+use Magento\Store\Model\StoreManagerInterface;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
-class DebugHintsTest extends \PHPUnit\Framework\TestCase
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
+class DebugHintsTest extends TestCase
{
+ private const STORE_CODE = 'default';
+
+ /**
+ * @var ObjectManager
+ */
+ private $objectManager;
+
/**
- * @var \Magento\Framework\App\Config\ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
- protected $scopeConfigMock;
+ private $scopeConfigMock;
/**
- * @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var StoreManagerInterface|MockObject
*/
- protected $storeManager;
+ private $storeManagerMock;
/**
- * @var \Magento\Developer\Helper\Data|\PHPUnit_Framework_MockObject_MockObject
+ * @var Data|MockObject
*/
- protected $devHelperMock;
+ private $devHelperMock;
/**
- * @var DebugHintsFactory | \PHPUnit_Framework_MockObject_MockObject
+ * @var DebugHintsFactory|MockObject
*/
- protected $debugHintsFactory;
+ private $debugHintsFactoryMock;
+
+ /**
+ * @var Http|MockObject
+ */
+ private $httpMock;
/**
* @return void
*/
protected function setUp()
{
- $this->scopeConfigMock = $this->getMockBuilder(\Magento\Framework\App\Config\ScopeConfigInterface::class)
+ $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
->getMockForAbstractClass();
- $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
+ $this->storeManagerMock = $this->getMockBuilder(StoreManagerInterface::class)
->getMockForAbstractClass();
- $this->devHelperMock = $this->getMockBuilder(\Magento\Developer\Helper\Data::class)
+ $this->devHelperMock = $this->getMockBuilder(Data::class)
->disableOriginalConstructor()
->getMock();
- $this->debugHintsFactory = $this->getMockBuilder(
- \Magento\Developer\Model\TemplateEngine\Decorator\DebugHintsFactory::class
+ $this->debugHintsFactoryMock = $this->getMockBuilder(
+ DebugHintsFactory::class
)
->setMethods(['create'])
->disableOriginalConstructor()
->getMock();
+
+ $this->httpMock = $this->createMock(Http::class);
+
+ $storeMock = $this->createMock(StoreInterface::class);
+ $storeMock->expects($this->once())
+ ->method('getCode')
+ ->willReturn(static::STORE_CODE);
+ $this->storeManagerMock->expects($this->once())
+ ->method('getStore')
+ ->willReturn($storeMock);
+
+ $this->objectManager = new ObjectManager($this);
}
/**
* @param string $debugHintsPath
* @param bool $showBlockHints
+ * @param bool $debugHintsWithParam
+ * @param bool $debugHintsParameter
+ *
* @return void
* @dataProvider afterCreateActiveDataProvider
*/
@@ -72,40 +115,41 @@ public function testAfterCreateActive(
$this->setupConfigFixture($debugHintsPath, true, $showBlockHints);
- $engine = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class);
+ $engine = $this->createMock(TemplateEngineInterface::class);
- $debugHintsDecorator = $this->getMockBuilder(
- \Magento\Developer\Model\TemplateEngine\Decorator\DebugHints::class
+ $debugHintsDecoratorMock = $this->getMockBuilder(
+ DebugHintsDecorator::class
)
->disableOriginalConstructor()
->getMock();
- $this->debugHintsFactory->expects($this->once())
+ $this->debugHintsFactoryMock->expects($this->once())
->method('create')
->with([
'subject' => $engine,
'showBlockHints' => $showBlockHints,
])
- ->willReturn($debugHintsDecorator);
+ ->willReturn($debugHintsDecoratorMock);
- $subjectMock = $this->getMockBuilder(\Magento\Framework\View\TemplateEngineFactory::class)
+ $subjectMock = $this->getMockBuilder(TemplateEngineFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->httpMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
-
- $debugHints = new DebugHints(
- $this->scopeConfigMock,
- $this->storeManager,
- $this->devHelperMock,
- $this->debugHintsFactory,
- $debugHintsPath,
- $this->httpMock,
- $debugHintsWithParam,
- $debugHintsParameter
+ $debugHints = $this->objectManager->getObject(
+ DebugHints::class,
+ [
+ 'scopeConfig' => $this->scopeConfigMock,
+ 'storeManager' => $this->storeManagerMock,
+ 'devHelper' => $this->devHelperMock,
+ 'debugHintsFactory' => $this->debugHintsFactoryMock,
+ 'http' => $this->httpMock,
+ 'debugHintsPath' => $debugHintsPath,
+ 'debugHintsWithParam' => $debugHintsWithParam,
+ 'debugHintsParameter' => $debugHintsParameter
+ ]
);
- $this->assertEquals($debugHintsDecorator, $debugHints->afterCreate($subjectMock, $engine));
+ $this->assertEquals($debugHintsDecoratorMock, $debugHints->afterCreate($subjectMock, $engine));
}
/**
@@ -125,6 +169,9 @@ public function afterCreateActiveDataProvider()
* @param string $debugHintsPath
* @param bool $isDevAllowed
* @param bool $showTemplateHints
+ * @param bool $debugHintsWithParam
+ * @param bool $debugHintsParameter
+ *
* @return void
* @dataProvider afterCreateInactiveDataProvider
*/
@@ -135,29 +182,30 @@ public function testAfterCreateInactive(
$debugHintsWithParam,
$debugHintsParameter
) {
- $this->devHelperMock->expects($this->any())
+ $this->devHelperMock
->method('isDevAllowed')
->willReturn($isDevAllowed);
$this->setupConfigFixture($debugHintsPath, $showTemplateHints, true);
- $engine = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class);
+ $engine = $this->createMock(TemplateEngineInterface::class);
- $subjectMock = $this->getMockBuilder(\Magento\Framework\View\TemplateEngineFactory::class)
+ $subjectMock = $this->getMockBuilder(TemplateEngineFactory::class)
->disableOriginalConstructor()
->getMock();
- $this->httpMock = $this->createMock(\Magento\Framework\App\Request\Http::class);
-
- $debugHints = new DebugHints(
- $this->scopeConfigMock,
- $this->storeManager,
- $this->devHelperMock,
- $this->debugHintsFactory,
- $debugHintsPath,
- $this->httpMock,
- $debugHintsWithParam,
- $debugHintsParameter
+ $debugHints = $this->objectManager->getObject(
+ DebugHints::class,
+ [
+ 'scopeConfig' => $this->scopeConfigMock,
+ 'storeManager' => $this->storeManagerMock,
+ 'devHelper' => $this->devHelperMock,
+ 'debugHintsFactory' => $this->debugHintsFactoryMock,
+ 'http' => $this->httpMock,
+ 'debugHintsPath' => $debugHintsPath,
+ 'debugHintsWithParam' => $debugHintsWithParam,
+ 'debugHintsParameter' => $debugHintsParameter
+ ]
);
$this->assertSame($engine, $debugHints->afterCreate($subjectMock, $engine));
@@ -184,32 +232,24 @@ public function afterCreateInactiveDataProvider()
* @param string $debugHintsPath
* @param bool $showTemplateHints
* @param bool $showBlockHints
+ *
* @return void
*/
- protected function setupConfigFixture($debugHintsPath, $showTemplateHints, $showBlockHints)
+ private function setupConfigFixture($debugHintsPath, $showTemplateHints, $showBlockHints): void
{
- $storeCode = 'default';
- $storeMock = $this->createMock(\Magento\Store\Api\Data\StoreInterface::class);
- $storeMock->expects($this->once())
- ->method('getCode')
- ->willReturn($storeCode);
- $this->storeManager->expects($this->once())
- ->method('getStore')
- ->willReturn($storeMock);
-
$this->scopeConfigMock->expects($this->atLeastOnce())
->method('getValue')
->willReturnMap([
[
$debugHintsPath,
ScopeInterface::SCOPE_STORE,
- $storeCode,
+ static::STORE_CODE,
$showTemplateHints,
],
[
DebugHints::XML_PATH_DEBUG_TEMPLATE_HINTS_BLOCKS,
ScopeInterface::SCOPE_STORE,
- $storeCode,
+ static::STORE_CODE,
$showBlockHints
]
]);
diff --git a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php
index 8372092c0e763..4b1b3110b4b9b 100644
--- a/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php
+++ b/app/code/Magento/Developer/Test/Unit/Model/View/Asset/PreProcessor/PreprocessorStrategyTest.php
@@ -3,6 +3,8 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
+declare(strict_types=1);
+
namespace Magento\Developer\Test\Unit\Model\View\Asset\PreProcessor;
use Magento\Developer\Model\Config\Source\WorkflowType;
@@ -13,14 +15,14 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
use Magento\Framework\View\Asset\PreProcessor\AlternativeSourceInterface;
use Magento\Framework\View\Asset\PreProcessor\Chain;
+use PHPUnit\Framework\MockObject\MockObject;
+use PHPUnit\Framework\TestCase;
/**
- * Class PreprocessorStrategyTest
- *
* @see \Magento\Developer\Model\View\Asset\PreProcessor\PreprocessorStrategy
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
-class PreprocessorStrategyTest extends \PHPUnit\Framework\TestCase
+class PreprocessorStrategyTest extends TestCase
{
/**
* @var PreprocessorStrategy
@@ -28,27 +30,27 @@ class PreprocessorStrategyTest extends \PHPUnit\Framework\TestCase
private $preprocessorStrategy;
/**
- * @var FrontendCompilation|\PHPUnit_Framework_MockObject_MockObject
+ * @var FrontendCompilation|MockObject
*/
private $frontendCompilationMock;
/**
- * @var AlternativeSourceInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var AlternativeSourceInterface|MockObject
*/
private $alternativeSourceMock;
/**
- * @var ScopeConfigInterface|\PHPUnit_Framework_MockObject_MockObject
+ * @var ScopeConfigInterface|MockObject
*/
private $scopeConfigMock;
/**
- * @var State|\PHPUnit_Framework_MockObject_MockObject
+ * @var State|MockObject
*/
private $stateMock;
/**
- * @var \Magento\Framework\App\ObjectManager|\PHPUnit_Framework_MockObject_MockObject
+ * @var \Magento\Framework\App\ObjectManager|MockObject
*/
private $objectMangerMock;
@@ -71,12 +73,15 @@ protected function setUp()
->disableOriginalConstructor()
->getMock();
- $this->preprocessorStrategy = (new ObjectManager($this))->getObject(PreprocessorStrategy::class, [
- 'alternativeSource' => $this->alternativeSourceMock,
- 'frontendCompilation' => $this->frontendCompilationMock,
- 'scopeConfig' => $this->scopeConfigMock,
- 'state' => $this->stateMock,
- ]);
+ $this->preprocessorStrategy = (new ObjectManager($this))->getObject(
+ PreprocessorStrategy::class,
+ [
+ 'alternativeSource' => $this->alternativeSourceMock,
+ 'frontendCompilation' => $this->frontendCompilationMock,
+ 'scopeConfig' => $this->scopeConfigMock,
+ 'state' => $this->stateMock,
+ ]
+ );
}
/**
@@ -148,14 +153,12 @@ public function testProcessAlternativeSource()
}
/**
- * @return Chain|\PHPUnit_Framework_MockObject_MockObject
+ * @return Chain|MockObject
*/
private function getChainMock()
{
- $chainMock = $this->getMockBuilder(Chain::class)
+ return $this->getMockBuilder(Chain::class)
->disableOriginalConstructor()
->getMock();
-
- return $chainMock;
}
}
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml
index 9ae046210181b..317f2abdf2f23 100644
--- a/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml
+++ b/app/code/Magento/Downloadable/Test/Mftf/Test/AdminCreateDownloadableProductWithLinkTest.xml
@@ -97,8 +97,7 @@