@@ -59,7 +60,7 @@ $createDateStore = $block->getStoreCreateDate();
= $block->escapeHtml(__('Default Billing Address')) ?>
- = $block->getBillingAddressHtml() ?>
+ = $block->escapeHtml($block->getBillingAddressHtml(), $allowedAddressHtmlTags) ?>
diff --git a/app/code/Magento/Customer/view/adminhtml/web/js/grid/columns/actions.js b/app/code/Magento/Customer/view/adminhtml/web/js/grid/columns/actions.js
index 66ef89c9413c7..42f427cf8a094 100644
--- a/app/code/Magento/Customer/view/adminhtml/web/js/grid/columns/actions.js
+++ b/app/code/Magento/Customer/view/adminhtml/web/js/grid/columns/actions.js
@@ -20,6 +20,11 @@ define([
},
listens: {
action: 'onAction'
+ },
+ ignoreTmpls: {
+ fieldAction: true,
+ options: true,
+ action: true
}
},
diff --git a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
index 1238184075057..bf7527c855e57 100644
--- a/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/CustomerGraphQl/etc/schema.graphqls
@@ -126,8 +126,8 @@ type CustomerAddressRegion @doc(description: "CustomerAddressRegion defines the
}
type CustomerAddressAttribute {
- attribute_code: String @doc(description: "Attribute code")
- value: String @doc(description: "Attribute value")
+ attribute_code: String @doc(description: "Attribute code")
+ value: String @doc(description: "Attribute value")
}
type IsEmailAvailableOutput {
diff --git a/app/code/Magento/Dhl/Model/Carrier.php b/app/code/Magento/Dhl/Model/Carrier.php
index e765a81554670..5959294fe6dc7 100644
--- a/app/code/Magento/Dhl/Model/Carrier.php
+++ b/app/code/Magento/Dhl/Model/Carrier.php
@@ -1088,7 +1088,7 @@ function () use ($deferredResponses, $responseBodies) {
protected function _getQuotesFromServer($request)
{
$client = $this->_httpClientFactory->create();
- $client->setUri((string)$this->getConfigData('gateway_url'));
+ $client->setUri($this->getGatewayURL());
$client->setConfig(['maxredirects' => 0, 'timeout' => 30]);
$client->setRawData(utf8_encode($request));
@@ -1410,7 +1410,7 @@ public function proccessAdditionalValidation(\Magento\Framework\DataObject $requ
public function processAdditionalValidation(\Magento\Framework\DataObject $request)
{
//Skip by item validation if there is no items in request
- if (!count($this->getAllItems($request))) {
+ if (empty($this->getAllItems($request))) {
$this->_errors[] = __('There is no items in this order');
}
@@ -1681,7 +1681,7 @@ protected function _doRequest()
try {
$response = $this->httpClient->request(
new Request(
- (string)$this->getConfigData('gateway_url'),
+ $this->getGatewayURL(),
Request::METHOD_POST,
['Content-Type' => 'application/xml'],
$request
@@ -1850,7 +1850,7 @@ protected function _getXMLTracking($trackings)
try {
$response = $this->httpClient->request(
new Request(
- (string)$this->getConfigData('gateway_url'),
+ $this->getGatewayURL(),
Request::METHOD_POST,
['Content-Type' => 'application/xml'],
$request
@@ -1883,7 +1883,7 @@ protected function _parseXmlTrackingResponse($trackings, $response)
$errorTitle = __('Unable to retrieve tracking');
$resultArr = [];
- if (strlen(trim($response)) > 0) {
+ if (!empty(trim($response))) {
$xml = $this->parseXml($response, \Magento\Shipping\Model\Simplexml\Element::class);
if (!is_object($xml)) {
$errorTitle = __('Response is in the wrong format');
@@ -2131,4 +2131,18 @@ private function buildSoftwareVersion(): string
{
return substr($this->productMetadata->getVersion(), 0, 10);
}
+
+ /**
+ * Get the gateway URL
+ *
+ * @return string
+ */
+ private function getGatewayURL(): string
+ {
+ if ($this->getConfigData('sandbox_mode')) {
+ return (string)$this->getConfigData('sandbox_url');
+ } else {
+ return (string)$this->getConfigData('gateway_url');
+ }
+ }
}
diff --git a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php
index 0fde6fa8e9d13..d1b35c8e2b77f 100644
--- a/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php
+++ b/app/code/Magento/Dhl/Test/Unit/Model/CarrierTest.php
@@ -446,6 +446,50 @@ public function buildSoftwareVersionProvider()
];
}
+ /**
+ * Tests if the DHL client returns the appropriate API URL.
+ *
+ * @dataProvider getGatewayURLProvider
+ * @param $sandboxMode
+ * @param $expectedURL
+ * @throws \ReflectionException
+ */
+ public function testGetGatewayURL($sandboxMode, $expectedURL)
+ {
+ $scopeConfigValueMap = [
+ ['carriers/dhl/gateway_url', 'store', null, 'https://xmlpi-ea.dhl.com/XMLShippingServlet'],
+ ['carriers/dhl/sandbox_url', 'store', null, 'https://xmlpitest-ea.dhl.com/XMLShippingServlet'],
+ ['carriers/dhl/sandbox_mode', 'store', null, $sandboxMode]
+ ];
+
+ $this->scope->method('getValue')
+ ->willReturnMap($scopeConfigValueMap);
+
+ $this->model = $this->objectManager->getObject(
+ Carrier::class,
+ [
+ 'scopeConfig' => $this->scope
+ ]
+ );
+
+ $method = new \ReflectionMethod($this->model, 'getGatewayURL');
+ $method->setAccessible(true);
+ $this->assertEquals($expectedURL, $method->invoke($this->model));
+ }
+
+ /**
+ * Data provider for testGetGatewayURL
+ *
+ * @return array
+ */
+ public function getGatewayURLProvider()
+ {
+ return [
+ 'standard_url' => [0, 'https://xmlpi-ea.dhl.com/XMLShippingServlet'],
+ 'sandbox_url' => [1, 'https://xmlpitest-ea.dhl.com/XMLShippingServlet']
+ ];
+ }
+
/**
* Creates mock for XML factory.
*
diff --git a/app/code/Magento/Dhl/etc/adminhtml/system.xml b/app/code/Magento/Dhl/etc/adminhtml/system.xml
index 7ab37de2f3658..597f33b579282 100644
--- a/app/code/Magento/Dhl/etc/adminhtml/system.xml
+++ b/app/code/Magento/Dhl/etc/adminhtml/system.xml
@@ -14,9 +14,6 @@
Magento\Config\Model\Config\Source\Yesno
-
-
-
@@ -145,6 +142,10 @@
Magento\Config\Model\Config\Source\Yesno
+
+
+ Magento\Config\Model\Config\Source\Yesno
+
diff --git a/app/code/Magento/Dhl/etc/config.xml b/app/code/Magento/Dhl/etc/config.xml
index 79addefb34a16..b46152fb0ecad 100644
--- a/app/code/Magento/Dhl/etc/config.xml
+++ b/app/code/Magento/Dhl/etc/config.xml
@@ -25,6 +25,7 @@
2,5,6,7,9,B,C,D,U,K,L,G,W,I,N,O,R,S,T,X
G
https://xmlpi-ea.dhl.com/XMLShippingServlet
+
https://xmlpitest-ea.dhl.com/XMLShippingServlet
N
diff --git a/app/code/Magento/Downloadable/Controller/Download/LinkSample.php b/app/code/Magento/Downloadable/Controller/Download/LinkSample.php
index f40df744dd3ea..c0bc825a8285b 100644
--- a/app/code/Magento/Downloadable/Controller/Download/LinkSample.php
+++ b/app/code/Magento/Downloadable/Controller/Download/LinkSample.php
@@ -7,7 +7,9 @@
namespace Magento\Downloadable\Controller\Download;
+use Magento\Catalog\Model\Product\SalabilityChecker;
use Magento\Downloadable\Helper\Download as DownloadHelper;
+use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
/**
@@ -18,7 +20,24 @@
class LinkSample extends \Magento\Downloadable\Controller\Download
{
/**
- * Download link's sample action
+ * @var SalabilityChecker
+ */
+ private $salabilityChecker;
+
+ /**
+ * @param Context $context
+ * @param SalabilityChecker|null $salabilityChecker
+ */
+ public function __construct(
+ Context $context,
+ SalabilityChecker $salabilityChecker = null
+ ) {
+ parent::__construct($context);
+ $this->salabilityChecker = $salabilityChecker ?: $this->_objectManager->get(SalabilityChecker::class);
+ }
+
+ /**
+ * Download link's sample action.
*
* @return ResponseInterface
*/
@@ -27,7 +46,7 @@ public function execute()
$linkId = $this->getRequest()->getParam('link_id', 0);
/** @var \Magento\Downloadable\Model\Link $link */
$link = $this->_objectManager->create(\Magento\Downloadable\Model\Link::class)->load($linkId);
- if ($link->getId()) {
+ if ($link->getId() && $this->salabilityChecker->isSalable($link->getProductId())) {
$resource = '';
$resourceType = '';
if ($link->getSampleType() == DownloadHelper::LINK_TYPE_URL) {
@@ -52,6 +71,7 @@ public function execute()
);
}
}
+
return $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
}
}
diff --git a/app/code/Magento/Downloadable/Controller/Download/Sample.php b/app/code/Magento/Downloadable/Controller/Download/Sample.php
index ac9eeac678f8d..b95ec510fdd9b 100644
--- a/app/code/Magento/Downloadable/Controller/Download/Sample.php
+++ b/app/code/Magento/Downloadable/Controller/Download/Sample.php
@@ -7,7 +7,9 @@
namespace Magento\Downloadable\Controller\Download;
+use Magento\Catalog\Model\Product\SalabilityChecker;
use Magento\Downloadable\Helper\Download as DownloadHelper;
+use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
/**
@@ -18,7 +20,24 @@
class Sample extends \Magento\Downloadable\Controller\Download
{
/**
- * Download sample action
+ * @var SalabilityChecker
+ */
+ private $salabilityChecker;
+
+ /**
+ * @param Context $context
+ * @param SalabilityChecker|null $salabilityChecker
+ */
+ public function __construct(
+ Context $context,
+ SalabilityChecker $salabilityChecker = null
+ ) {
+ parent::__construct($context);
+ $this->salabilityChecker = $salabilityChecker ?: $this->_objectManager->get(SalabilityChecker::class);
+ }
+
+ /**
+ * Download sample action.
*
* @return ResponseInterface
*/
@@ -27,7 +46,7 @@ public function execute()
$sampleId = $this->getRequest()->getParam('sample_id', 0);
/** @var \Magento\Downloadable\Model\Sample $sample */
$sample = $this->_objectManager->create(\Magento\Downloadable\Model\Sample::class)->load($sampleId);
- if ($sample->getId()) {
+ if ($sample->getId() && $this->salabilityChecker->isSalable($sample->getProductId())) {
$resource = '';
$resourceType = '';
if ($sample->getSampleType() == DownloadHelper::LINK_TYPE_URL) {
@@ -49,6 +68,7 @@ public function execute()
);
}
}
+
return $this->getResponse()->setRedirect($this->_redirect->getRedirectUrl());
}
}
diff --git a/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontVerifySecureURLRedirectDownloadableTest.xml b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontVerifySecureURLRedirectDownloadableTest.xml
new file mode 100644
index 0000000000000..6e039ca413a08
--- /dev/null
+++ b/app/code/Magento/Downloadable/Test/Mftf/Test/StorefrontVerifySecureURLRedirectDownloadableTest.xml
@@ -0,0 +1,44 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php
index ce01b449d3388..fa989c9e94991 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/LinkSampleTest.php
@@ -8,6 +8,8 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
/**
+ * Unit tests for \Magento\Downloadable\Controller\Download\LinkSample.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class LinkSampleTest extends \PHPUnit\Framework\TestCase
@@ -63,6 +65,11 @@ class LinkSampleTest extends \PHPUnit\Framework\TestCase
*/
protected $urlInterface;
+ /**
+ * @var \Magento\Catalog\Model\Product\SalabilityChecker|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $salabilityCheckerMock;
+
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
@@ -83,31 +90,39 @@ protected function setUp()
]
);
- $this->helperData = $this->createPartialMock(\Magento\Downloadable\Helper\Data::class, [
- 'getIsShareable'
- ]);
- $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [
+ $this->helperData = $this->createPartialMock(
+ \Magento\Downloadable\Helper\Data::class,
+ ['getIsShareable']
+ );
+ $this->downloadHelper = $this->createPartialMock(
+ \Magento\Downloadable\Helper\Download::class,
+ [
'setResource',
'getFilename',
'getContentType',
'getFileSize',
'getContentDisposition',
'output'
- ]);
- $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [
+ ]
+ );
+ $this->product = $this->createPartialMock(
+ \Magento\Catalog\Model\Product::class,
+ [
'_wakeup',
'load',
'getId',
'getProductUrl',
'getName'
- ]);
+ ]
+ );
$this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class);
$this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class);
$this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class);
- $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [
- 'create',
- 'get'
- ]);
+ $this->salabilityCheckerMock = $this->createMock(\Magento\Catalog\Model\Product\SalabilityChecker::class);
+ $this->objectManager = $this->createPartialMock(
+ \Magento\Framework\ObjectManager\ObjectManager::class,
+ ['create', 'get']
+ );
$this->linkSample = $this->objectManagerHelper->getObject(
\Magento\Downloadable\Controller\Download\LinkSample::class,
[
@@ -115,11 +130,17 @@ protected function setUp()
'request' => $this->request,
'response' => $this->response,
'messageManager' => $this->messageManager,
- 'redirect' => $this->redirect
+ 'redirect' => $this->redirect,
+ 'salabilityChecker' => $this->salabilityCheckerMock,
]
);
}
+ /**
+ * Execute Download link's sample action with Url link.
+ *
+ * @return void
+ */
public function testExecuteLinkTypeUrl()
{
$linkMock = $this->getMockBuilder(\Magento\Downloadable\Model\Link::class)
@@ -134,6 +155,7 @@ public function testExecuteLinkTypeUrl()
->willReturn($linkMock);
$linkMock->expects($this->once())->method('load')->with('some_link_id')->willReturnSelf();
$linkMock->expects($this->once())->method('getId')->willReturn('some_link_id');
+ $this->salabilityCheckerMock->expects($this->once())->method('isSalable')->willReturn(true);
$linkMock->expects($this->once())->method('getSampleType')->willReturn(
\Magento\Downloadable\Helper\Download::LINK_TYPE_URL
);
@@ -155,6 +177,11 @@ public function testExecuteLinkTypeUrl()
$this->assertEquals($this->response, $this->linkSample->execute());
}
+ /**
+ * Execute Download link's sample action with File link.
+ *
+ * @return void
+ */
public function testExecuteLinkTypeFile()
{
$linkMock = $this->getMockBuilder(\Magento\Downloadable\Model\Link::class)
@@ -173,6 +200,7 @@ public function testExecuteLinkTypeFile()
->willReturn($linkMock);
$linkMock->expects($this->once())->method('load')->with('some_link_id')->willReturnSelf();
$linkMock->expects($this->once())->method('getId')->willReturn('some_link_id');
+ $this->salabilityCheckerMock->expects($this->once())->method('isSalable')->willReturn(true);
$linkMock->expects($this->any())->method('getSampleType')->willReturn(
\Magento\Downloadable\Helper\Download::LINK_TYPE_FILE
);
diff --git a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php
index 2545e15317ebb..5e711b61e6a5a 100644
--- a/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php
+++ b/app/code/Magento/Downloadable/Test/Unit/Controller/Download/SampleTest.php
@@ -8,6 +8,8 @@
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
/**
+ * Unit tests for \Magento\Downloadable\Controller\Download\Sample.
+ *
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class SampleTest extends \PHPUnit\Framework\TestCase
@@ -63,6 +65,11 @@ class SampleTest extends \PHPUnit\Framework\TestCase
*/
protected $urlInterface;
+ /**
+ * @var \Magento\Catalog\Model\Product\SalabilityChecker|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private $salabilityCheckerMock;
+
/**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
@@ -83,31 +90,39 @@ protected function setUp()
]
);
- $this->helperData = $this->createPartialMock(\Magento\Downloadable\Helper\Data::class, [
- 'getIsShareable'
- ]);
- $this->downloadHelper = $this->createPartialMock(\Magento\Downloadable\Helper\Download::class, [
+ $this->helperData = $this->createPartialMock(
+ \Magento\Downloadable\Helper\Data::class,
+ ['getIsShareable']
+ );
+ $this->downloadHelper = $this->createPartialMock(
+ \Magento\Downloadable\Helper\Download::class,
+ [
'setResource',
'getFilename',
'getContentType',
'getFileSize',
'getContentDisposition',
'output'
- ]);
- $this->product = $this->createPartialMock(\Magento\Catalog\Model\Product::class, [
+ ]
+ );
+ $this->product = $this->createPartialMock(
+ \Magento\Catalog\Model\Product::class,
+ [
'_wakeup',
'load',
'getId',
'getProductUrl',
'getName'
- ]);
+ ]
+ );
$this->messageManager = $this->createMock(\Magento\Framework\Message\ManagerInterface::class);
$this->redirect = $this->createMock(\Magento\Framework\App\Response\RedirectInterface::class);
$this->urlInterface = $this->createMock(\Magento\Framework\UrlInterface::class);
- $this->objectManager = $this->createPartialMock(\Magento\Framework\ObjectManager\ObjectManager::class, [
- 'create',
- 'get'
- ]);
+ $this->salabilityCheckerMock = $this->createMock(\Magento\Catalog\Model\Product\SalabilityChecker::class);
+ $this->objectManager = $this->createPartialMock(
+ \Magento\Framework\ObjectManager\ObjectManager::class,
+ ['create', 'get']
+ );
$this->sample = $this->objectManagerHelper->getObject(
\Magento\Downloadable\Controller\Download\Sample::class,
[
@@ -115,12 +130,18 @@ protected function setUp()
'request' => $this->request,
'response' => $this->response,
'messageManager' => $this->messageManager,
- 'redirect' => $this->redirect
+ 'redirect' => $this->redirect,
+ 'salabilityChecker' => $this->salabilityCheckerMock,
]
);
}
- public function testExecuteLinkTypeUrl()
+ /**
+ * Execute Download sample action with Sample Url.
+ *
+ * @return void
+ */
+ public function testExecuteSampleWithUrlType()
{
$sampleMock = $this->getMockBuilder(\Magento\Downloadable\Model\Sample::class)
->disableOriginalConstructor()
@@ -134,6 +155,7 @@ public function testExecuteLinkTypeUrl()
->willReturn($sampleMock);
$sampleMock->expects($this->once())->method('load')->with('some_sample_id')->willReturnSelf();
$sampleMock->expects($this->once())->method('getId')->willReturn('some_link_id');
+ $this->salabilityCheckerMock->expects($this->once())->method('isSalable')->willReturn(true);
$sampleMock->expects($this->once())->method('getSampleType')->willReturn(
\Magento\Downloadable\Helper\Download::LINK_TYPE_URL
);
@@ -155,7 +177,12 @@ public function testExecuteLinkTypeUrl()
$this->assertEquals($this->response, $this->sample->execute());
}
- public function testExecuteLinkTypeFile()
+ /**
+ * Execute Download sample action with Sample File.
+ *
+ * @return void
+ */
+ public function testExecuteSampleWithFileType()
{
$sampleMock = $this->getMockBuilder(\Magento\Downloadable\Model\Sample::class)
->disableOriginalConstructor()
@@ -173,6 +200,7 @@ public function testExecuteLinkTypeFile()
->willReturn($sampleMock);
$sampleMock->expects($this->once())->method('load')->with('some_sample_id')->willReturnSelf();
$sampleMock->expects($this->once())->method('getId')->willReturn('some_sample_id');
+ $this->salabilityCheckerMock->expects($this->once())->method('isSalable')->willReturn(true);
$sampleMock->expects($this->any())->method('getSampleType')->willReturn(
\Magento\Downloadable\Helper\Download::LINK_TYPE_FILE
);
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute.php b/app/code/Magento/Eav/Model/Entity/Attribute.php
index e23f81607a0c0..bb2477d4df827 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute.php
@@ -203,6 +203,7 @@ protected function _getDefaultSourceModel()
* Delete entity
*
* @return \Magento\Eav\Model\ResourceModel\Entity\Attribute
+ * @throws LocalizedException
* @codeCoverageIgnore
*/
public function deleteEntity()
@@ -310,9 +311,10 @@ public function beforeSave()
}
/**
- * @inheritdoc
+ * Save additional data
*
- * Save additional data.
+ * @return $this
+ * @throws LocalizedException
*/
public function afterSave()
{
@@ -320,15 +322,6 @@ public function afterSave()
return parent::afterSave();
}
- /**
- * @inheritdoc
- * @since 100.0.7
- */
- public function afterDelete()
- {
- return parent::afterDelete();
- }
-
/**
* Detect backend storage type using frontend input type
*
@@ -496,14 +489,9 @@ public function getIdentities()
/**
* @inheritdoc
* @since 100.0.7
- *
- * @SuppressWarnings(PHPMD.SerializationAware)
- * @deprecated Do not use PHP serialization.
*/
public function __sleep()
{
- trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
-
$this->unsetData('attribute_set_info');
return array_diff(
parent::__sleep(),
@@ -514,14 +502,9 @@ public function __sleep()
/**
* @inheritdoc
* @since 100.0.7
- *
- * @SuppressWarnings(PHPMD.SerializationAware)
- * @deprecated Do not use PHP serialization.
*/
public function __wakeup()
{
- trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
-
parent::__wakeup();
$objectManager = ObjectManager::getInstance();
$this->_localeDate = $objectManager->get(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::class);
diff --git a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
index 9ed4ac5293681..3857118ae67ca 100644
--- a/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
+++ b/app/code/Magento/Eav/Model/Entity/Attribute/AbstractAttribute.php
@@ -13,6 +13,7 @@
/**
* Entity/Attribute/Model - attribute abstract
+ * phpcs:disable Magento2.Classes.AbstractApi
* @api
* @SuppressWarnings(PHPMD.ExcessivePublicCount)
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
@@ -1404,14 +1405,9 @@ public function setExtensionAttributes(\Magento\Eav\Api\Data\AttributeExtensionI
/**
* @inheritdoc
* @since 100.0.7
- *
- * @SuppressWarnings(PHPMD.SerializationAware)
- * @deprecated Do not use PHP serialization.
*/
public function __sleep()
{
- trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
-
return array_diff(
parent::__sleep(),
[
@@ -1434,14 +1430,9 @@ public function __sleep()
/**
* @inheritdoc
* @since 100.0.7
- *
- * @SuppressWarnings(PHPMD.SerializationAware)
- * @deprecated Do not use PHP serialization.
*/
public function __wakeup()
{
- trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
-
parent::__wakeup();
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$this->_eavConfig = $objectManager->get(\Magento\Eav\Model\Config::class);
diff --git a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
index 5e7226e7a36dd..0e7a46125d872 100644
--- a/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
+++ b/app/code/Magento/Eav/Model/ResourceModel/Entity/Attribute.php
@@ -725,14 +725,9 @@ public function getValidAttributeIds($attributeIds)
*
* @return array
* @since 100.0.7
- *
- * @SuppressWarnings(PHPMD.SerializationAware)
- * @deprecated Do not use PHP serialization.
*/
public function __sleep()
{
- trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
-
$properties = parent::__sleep();
$properties = array_diff($properties, ['_storeManager']);
return $properties;
@@ -743,14 +738,9 @@ public function __sleep()
*
* @return void
* @since 100.0.7
- *
- * @SuppressWarnings(PHPMD.SerializationAware)
- * @deprecated Do not use PHP serialization.
*/
public function __wakeup()
{
- trigger_error('Using PHP serialization is deprecated', E_USER_DEPRECATED);
-
parent::__wakeup();
$this->_storeManager = \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Store\Model\StoreManagerInterface::class);
diff --git a/app/code/Magento/EavGraphQl/etc/schema.graphqls b/app/code/Magento/EavGraphQl/etc/schema.graphqls
index 0299067bd0523..0b174fbc4d84d 100644
--- a/app/code/Magento/EavGraphQl/etc/schema.graphqls
+++ b/app/code/Magento/EavGraphQl/etc/schema.graphqls
@@ -2,7 +2,7 @@
# See COPYING.txt for license details.
type Query {
- customAttributeMetadata(attributes: [AttributeInput!]!): CustomAttributeMetadata @resolver(class: "Magento\\EavGraphQl\\Model\\Resolver\\CustomAttributeMetadata") @doc(description: "The customAttributeMetadata query returns the attribute type, given an attribute code and entity type") @cache(cacheable: false)
+ customAttributeMetadata(attributes: [AttributeInput!]!): CustomAttributeMetadata @resolver(class: "Magento\\EavGraphQl\\Model\\Resolver\\CustomAttributeMetadata") @doc(description: "The customAttributeMetadata query returns the attribute type, given an attribute code and entity type") @cache(cacheable: false)
}
type CustomAttributeMetadata @doc(description: "CustomAttributeMetadata defines an array of attribute_codes and entity_types") {
diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php
index e5c8dd48c7af3..bbfcce6aa695b 100644
--- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php
+++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php
@@ -45,8 +45,7 @@ public function __construct(ConverterInterface $fieldTypeConverter, $integerType
public function getFieldType(AttributeAdapter $attribute): ?string
{
if (in_array($attribute->getAttributeCode(), $this->integerTypeAttributes, true)
- || (($attribute->isIntegerType() || $attribute->isBooleanType())
- && !$attribute->isUserDefined())
+ || ($attribute->isIntegerType() || $attribute->isBooleanType())
) {
return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_INT);
}
diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php
index e522d4ae5e070..7ac6588b87866 100644
--- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php
+++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordType.php
@@ -37,8 +37,9 @@ public function __construct(ConverterInterface $fieldTypeConverter)
*/
public function getFieldType(AttributeAdapter $attribute): ?string
{
- if ($attribute->isComplexType()
- || (!$attribute->isSearchable() && !$attribute->isAlwaysIndexable() && $attribute->isFilterable())
+ if (($attribute->isComplexType()
+ || (!$attribute->isSearchable() && !$attribute->isAlwaysIndexable() && $attribute->isFilterable()))
+ && !$attribute->isBooleanType()
) {
return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_KEYWORD);
}
diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php
index c05e8a441604d..93f4caa10adf9 100644
--- a/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch/Elasticsearch5/Model/Client/Elasticsearch.php
@@ -91,7 +91,7 @@ public function ping()
}
/**
- * Validate connection params
+ * Validate connection params.
*
* @return bool
*/
@@ -109,7 +109,9 @@ public function testConnection()
private function buildConfig($options = [])
{
$host = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
+ // @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
+ // @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
@@ -144,10 +146,12 @@ public function bulkQuery($query)
*/
public function createIndex($index, $settings)
{
- $this->getClient()->indices()->create([
- 'index' => $index,
- 'body' => $settings,
- ]);
+ $this->getClient()->indices()->create(
+ [
+ 'index' => $index,
+ 'body' => $settings,
+ ]
+ );
}
/**
@@ -250,10 +254,12 @@ public function addFieldsMapping(array $fields, $index, $entityType)
'type' => $entityType,
'body' => [
$entityType => [
- '_all' => $this->prepareFieldInfo([
- 'enabled' => true,
- 'type' => 'text',
- ]),
+ '_all' => $this->prepareFieldInfo(
+ [
+ 'enabled' => true,
+ 'type' => 'text',
+ ]
+ ),
'properties' => [],
'dynamic_templates' => [
[
@@ -266,25 +272,28 @@ public function addFieldsMapping(array $fields, $index, $entityType)
],
],
],
- [
- 'string_mapping' => [
- 'match' => '*',
- 'match_mapping_type' => 'string',
- 'mapping' => $this->prepareFieldInfo([
- 'type' => 'text',
- 'index' => false,
- ]),
- ],
- ],
[
'position_mapping' => [
'match' => 'position_*',
'match_mapping_type' => 'string',
'mapping' => [
- 'type' => 'int',
+ 'type' => 'integer',
+ 'index' => false,
],
],
],
+ [
+ 'string_mapping' => [
+ 'match' => '*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => $this->prepareFieldInfo(
+ [
+ 'type' => 'text',
+ 'index' => false,
+ ]
+ ),
+ ],
+ ]
],
],
],
@@ -329,10 +338,9 @@ private function prepareFieldInfo($fieldInfo)
*/
public function deleteMapping($index, $entityType)
{
- $this->getClient()->indices()->deleteMapping([
- 'index' => $index,
- 'type' => $entityType,
- ]);
+ $this->getClient()->indices()->deleteMapping(
+ ['index' => $index, 'type' => $entityType]
+ );
}
/**
diff --git a/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php b/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php
index 09968db00aa25..75c675663f03f 100644
--- a/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php
+++ b/app/code/Magento/Elasticsearch/Elasticsearch5/SearchAdapter/Query/Builder.php
@@ -49,27 +49,24 @@ class Builder
/**
* @var Sort
*/
- protected $sortBuilder;
+ private $sortBuilder;
/**
* @param Config $clientConfig
* @param SearchIndexNameResolver $searchIndexNameResolver
* @param AggregationBuilder $aggregationBuilder
* @param ScopeResolverInterface $scopeResolver
- * @param Sort|null $sortBuilder
*/
public function __construct(
Config $clientConfig,
SearchIndexNameResolver $searchIndexNameResolver,
AggregationBuilder $aggregationBuilder,
- ScopeResolverInterface $scopeResolver,
- Sort $sortBuilder = null
+ ScopeResolverInterface $scopeResolver
) {
$this->clientConfig = $clientConfig;
$this->searchIndexNameResolver = $searchIndexNameResolver;
$this->aggregationBuilder = $aggregationBuilder;
$this->scopeResolver = $scopeResolver;
- $this->sortBuilder = $sortBuilder ?: ObjectManager::getInstance()->get(Sort::class);
}
/**
@@ -91,7 +88,7 @@ public function initQuery(RequestInterface $request)
'from' => $request->getFrom(),
'size' => $request->getSize(),
'stored_fields' => ['_id', '_score'],
- 'sort' => $this->sortBuilder->getSort($request),
+ 'sort' => $this->getSortBuilder()->getSort($request),
'query' => [],
],
];
@@ -112,4 +109,17 @@ public function initAggregations(
) {
return $this->aggregationBuilder->build($request, $searchQuery);
}
+
+ /**
+ * Get sort builder instance.
+ *
+ * @return Sort
+ */
+ private function getSortBuilder()
+ {
+ if (null === $this->sortBuilder) {
+ $this->sortBuilder = ObjectManager::getInstance()->get(Sort::class);
+ }
+ return $this->sortBuilder;
+ }
}
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php
index 54586fa357ff0..165f7e78eb65f 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/AttributeAdapter.php
@@ -159,9 +159,9 @@ public function isSortable(): bool
/**
* Check if attribute is defined by user.
*
- * @return string
+ * @return bool|null
*/
- public function isUserDefined(): string
+ public function isUserDefined()
{
return $this->getAttribute()->getIsUserDefined();
}
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php
index 268fe00e4c41e..76bc7a15e47a7 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicField.php
@@ -125,7 +125,7 @@ public function getFields(array $context = []): array
['categoryId' => $categoryId]
);
$allAttributes[$categoryPositionKey] = [
- 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_STRING),
+ 'type' => $this->fieldTypeConverter->convert(FieldTypeConverterInterface::INTERNAL_DATA_TYPE_INT),
'index' => $this->indexTypeConverter->convert(IndexTypeConverterInterface::INTERNAL_NO_INDEX_VALUE)
];
$allAttributes[$categoryNameKey] = [
diff --git a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php
index 7793f60cd1efc..f1e6c8abeb439 100644
--- a/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php
+++ b/app/code/Magento/Elasticsearch/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerType.php
@@ -37,9 +37,7 @@ public function __construct(ConverterInterface $fieldTypeConverter)
*/
public function getFieldType(AttributeAdapter $attribute): ?string
{
- if (($attribute->isIntegerType() || $attribute->isBooleanType())
- && !$attribute->isUserDefined()
- ) {
+ if ($attribute->isIntegerType() || $attribute->isBooleanType()) {
return $this->fieldTypeConverter->convert(ConverterInterface::INTERNAL_DATA_TYPE_INT);
}
diff --git a/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php b/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php
index 44ab0dbc4d46c..f9b827304446d 100644
--- a/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch/Model/Client/Elasticsearch.php
@@ -96,13 +96,17 @@ public function testConnection()
}
/**
+ * Build config.
+ *
* @param array $options
* @return array
*/
private function buildConfig($options = [])
{
$host = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
+ // @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
+ // @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
@@ -137,10 +141,12 @@ public function bulkQuery($query)
*/
public function createIndex($index, $settings)
{
- $this->getClient()->indices()->create([
- 'index' => $index,
- 'body' => $settings,
- ]);
+ $this->getClient()->indices()->create(
+ [
+ 'index' => $index,
+ 'body' => $settings,
+ ]
+ );
}
/**
@@ -202,9 +208,10 @@ public function indexExists($index)
}
/**
+ * Check if alias exists.
+ *
* @param string $alias
* @param string $index
- *
* @return bool
*/
public function existsAlias($alias, $index = '')
@@ -217,8 +224,9 @@ public function existsAlias($alias, $index = '')
}
/**
- * @param string $alias
+ * Get alias.
*
+ * @param string $alias
* @return array
*/
public function getAlias($alias)
@@ -252,29 +260,31 @@ public function addFieldsMapping(array $fields, $index, $entityType)
'match' => 'price_*',
'match_mapping' => 'string',
'mapping' => [
- 'type' => 'float'
+ 'type' => 'float',
+ 'store' => true
],
],
],
[
- 'string_mapping' => [
- 'match' => '*',
+ 'position_mapping' => [
+ 'match' => 'position_*',
'match_mapping' => 'string',
'mapping' => [
- 'type' => 'string',
+ 'type' => 'integer',
'index' => 'no'
],
],
],
[
- 'position_mapping' => [
- 'match' => 'position_*',
+ 'string_mapping' => [
+ 'match' => '*',
'match_mapping' => 'string',
'mapping' => [
- 'type' => 'int'
+ 'type' => 'string',
+ 'index' => 'no'
],
],
- ],
+ ]
],
],
],
@@ -294,10 +304,12 @@ public function addFieldsMapping(array $fields, $index, $entityType)
*/
public function deleteMapping($index, $entityType)
{
- $this->getClient()->indices()->deleteMapping([
- 'index' => $index,
- 'type' => $entityType,
- ]);
+ $this->getClient()->indices()->deleteMapping(
+ [
+ 'index' => $index,
+ 'type' => $entityType,
+ ]
+ );
}
/**
diff --git a/app/code/Magento/Elasticsearch/Model/Config.php b/app/code/Magento/Elasticsearch/Model/Config.php
index 387db07c62f90..0bf23f318c3bd 100644
--- a/app/code/Magento/Elasticsearch/Model/Config.php
+++ b/app/code/Magento/Elasticsearch/Model/Config.php
@@ -106,7 +106,15 @@ public function prepareClientOptions($options = [])
'timeout' => $this->getElasticsearchConfigData('server_timeout') ? : self::ELASTICSEARCH_DEFAULT_TIMEOUT,
];
$options = array_merge($defaultOptions, $options);
- return $options;
+ $allowedOptions = array_merge(array_keys($defaultOptions), ['engine']);
+
+ return array_filter(
+ $options,
+ function (string $key) use ($allowedOptions) {
+ return in_array($key, $allowedOptions);
+ },
+ ARRAY_FILTER_USE_KEY
+ );
}
/**
diff --git a/app/code/Magento/Elasticsearch/Model/Indexer/Plugin/StockedProductsFilterPlugin.php b/app/code/Magento/Elasticsearch/Model/Indexer/Plugin/StockedProductsFilterPlugin.php
deleted file mode 100644
index ec18b955a2917..0000000000000
--- a/app/code/Magento/Elasticsearch/Model/Indexer/Plugin/StockedProductsFilterPlugin.php
+++ /dev/null
@@ -1,94 +0,0 @@
-config = $config;
- $this->stockConfiguration = $stockConfiguration;
- $this->stockStatusRepository = $stockStatusRepository;
- $this->stockStatusCriteriaFactory = $stockStatusCriteriaFactory;
- }
-
- /**
- * Filter out of stock options for configurable product.
- *
- * @param DataProvider $dataProvider
- * @param array $indexData
- * @param array $productData
- * @param int $storeId
- * @return array
- * @SuppressWarnings(PHPMD.UnusedFormalParameter)
- */
- public function beforePrepareProductIndex(
- DataProvider $dataProvider,
- array $indexData,
- array $productData,
- int $storeId
- ): array {
- if ($this->config->isElasticsearchEnabled() && !$this->stockConfiguration->isShowOutOfStock($storeId)) {
- $productIds = array_keys($indexData);
- $stockStatusCriteria = $this->stockStatusCriteriaFactory->create();
- $stockStatusCriteria->setProductsFilter($productIds);
- $stockStatusCollection = $this->stockStatusRepository->getList($stockStatusCriteria);
- $stockStatuses = $stockStatusCollection->getItems();
- $stockStatuses = array_filter($stockStatuses, function (StockStatusInterface $stockStatus) {
- return StockStatusInterface::STATUS_IN_STOCK == $stockStatus->getStockStatus();
- });
- $indexData = array_intersect_key($indexData, $stockStatuses);
- }
-
- return [
- $indexData,
- $productData,
- $storeId,
- ];
- }
-}
diff --git a/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/DefaultFilterStrategyApplyChecker.php b/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/DefaultFilterStrategyApplyChecker.php
new file mode 100644
index 0000000000000..21ff9a53e4f96
--- /dev/null
+++ b/app/code/Magento/Elasticsearch/Model/ResourceModel/Fulltext/Collection/DefaultFilterStrategyApplyChecker.php
@@ -0,0 +1,26 @@
+builder->setPageSize($this->size);
$searchCriteria = $this->builder->create();
$searchCriteria->setRequestName($this->searchRequestName);
- $searchCriteria->setSortOrders(array_merge(['relevance' => 'DESC'], $this->orders));
+ $searchCriteria->setSortOrders($this->orders);
$searchCriteria->setCurrentPage($this->currentPage - 1);
return $searchCriteria;
diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php
index d0aaa4b3dd572..0bea8683692f2 100644
--- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php
+++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder.php
@@ -6,6 +6,8 @@
namespace Magento\Elasticsearch\SearchAdapter\Query;
+use Magento\Elasticsearch\SearchAdapter\Query\Builder\Sort;
+use Magento\Framework\App\ObjectManager;
use Magento\Framework\Search\RequestInterface;
use Magento\Elasticsearch\Elasticsearch5\SearchAdapter\Query\Builder as Elasticsearch5Builder;
@@ -18,7 +20,12 @@
class Builder extends Elasticsearch5Builder
{
/**
- * Set initial settings for query
+ * @var Sort
+ */
+ private $sortBuilder;
+
+ /**
+ * Set initial settings for query.
*
* @param RequestInterface $request
* @return array
@@ -35,10 +42,23 @@ public function initQuery(RequestInterface $request)
'from' => $request->getFrom(),
'size' => $request->getSize(),
'fields' => ['_id', '_score'],
- 'sort' => $this->sortBuilder->getSort($request),
+ 'sort' => $this->getSortBuilder()->getSort($request),
'query' => [],
],
];
return $searchQuery;
}
+
+ /**
+ * Get sort builder instance.
+ *
+ * @return Sort
+ */
+ private function getSortBuilder()
+ {
+ if (null === $this->sortBuilder) {
+ $this->sortBuilder = ObjectManager::getInstance()->get(Sort::class);
+ }
+ return $this->sortBuilder;
+ }
}
diff --git a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Sort.php b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Sort.php
index 5ccf202e3812b..e8085787f2b44 100644
--- a/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Sort.php
+++ b/app/code/Magento/Elasticsearch/SearchAdapter/Query/Builder/Sort.php
@@ -78,6 +78,13 @@ public function __construct(
public function getSort(RequestInterface $request)
{
$sorts = [];
+ /**
+ * Temporary solution for an existing interface of a fulltext search request in Backward compatibility purposes.
+ * Scope to split Search request interface on two different 'Search' and 'Fulltext Search' contains in MC-16461.
+ */
+ if (!method_exists($request, 'getSort')) {
+ return $sorts;
+ }
foreach ($request->getSort() as $item) {
if (in_array($item['field'], $this->skippedFields)) {
continue;
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php
index 39155e4f4fe02..c5eea2f897ea6 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php
@@ -53,15 +53,18 @@ protected function setUp()
/**
* @dataProvider getFieldTypeProvider
- * @param $attributeCode
- * @param $isIntegerType
- * @param $isBooleanType
- * @param $isUserDefined
- * @param $expected
+ * @param string $attributeCode
+ * @param bool $isIntegerType
+ * @param bool $isBooleanType
+ * @param string $expected
* @return void
*/
- public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType, $isUserDefined, $expected)
- {
+ public function testGetFieldType(
+ string $attributeCode,
+ bool $isIntegerType,
+ bool $isBooleanType,
+ string $expected
+ ): void {
$attributeMock = $this->getMockBuilder(AttributeAdapter::class)
->disableOriginalConstructor()
->setMethods(['getAttributeCode', 'isIntegerType', 'isBooleanType', 'isUserDefined'])
@@ -75,9 +78,6 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
$attributeMock->expects($this->any())
->method('isBooleanType')
->willReturn($isBooleanType);
- $attributeMock->expects($this->any())
- ->method('isUserDefined')
- ->willReturn($isUserDefined);
$this->fieldTypeConverter->expects($this->any())
->method('convert')
->willReturn('something');
@@ -94,12 +94,12 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
public function getFieldTypeProvider()
{
return [
- ['category_ids', true, true, true, 'something'],
- ['category_ids', false, false, false, 'something'],
- ['type', true, false, false, 'something'],
- ['type', false, true, false, 'something'],
- ['type', true, true, true, ''],
- ['type', false, false, true, ''],
+ ['category_ids', true, true, 'something'],
+ ['category_ids', false, false, 'something'],
+ ['type', true, false, 'something'],
+ ['type', false, true, 'something'],
+ ['type', true, true, 'something'],
+ ['type', false, false, ''],
];
}
}
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php
index 0e33498a16fba..92d523e6c2346 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/KeywordTypeTest.php
@@ -53,18 +53,25 @@ protected function setUp()
/**
* @dataProvider getFieldTypeProvider
- * @param $isComplexType
- * @param $isSearchable
- * @param $isAlwaysIndexable
- * @param $isFilterable
- * @param $expected
+ * @param bool $isComplexType
+ * @param bool $isSearchable
+ * @param bool $isAlwaysIndexable
+ * @param bool $isFilterable
+ * @param bool $isBoolean
+ * @param string $expected
* @return void
*/
- public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexable, $isFilterable, $expected)
- {
+ public function testGetFieldType(
+ bool $isComplexType,
+ bool $isSearchable,
+ bool $isAlwaysIndexable,
+ bool $isFilterable,
+ bool $isBoolean,
+ string $expected
+ ): void {
$attributeMock = $this->getMockBuilder(AttributeAdapter::class)
->disableOriginalConstructor()
- ->setMethods(['isComplexType', 'isSearchable', 'isAlwaysIndexable', 'isFilterable'])
+ ->setMethods(['isComplexType', 'isSearchable', 'isAlwaysIndexable', 'isFilterable', 'isBooleanType'])
->getMock();
$attributeMock->expects($this->any())
->method('isComplexType')
@@ -78,6 +85,9 @@ public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexab
$attributeMock->expects($this->any())
->method('isFilterable')
->willReturn($isFilterable);
+ $attributeMock->expects($this->any())
+ ->method('isBooleanType')
+ ->willReturn($isBoolean);
$this->fieldTypeConverter->expects($this->any())
->method('convert')
->willReturn('something');
@@ -94,13 +104,14 @@ public function testGetFieldType($isComplexType, $isSearchable, $isAlwaysIndexab
public function getFieldTypeProvider()
{
return [
- [true, true, true, true, 'something'],
- [true, false, false, false, 'something'],
- [true, false, false, true, 'something'],
- [false, false, false, true, 'something'],
- [false, false, false, false, ''],
- [false, false, true, false, ''],
- [false, true, false, false, ''],
+ [true, true, true, true, false, 'something'],
+ [true, false, false, false, false, 'something'],
+ [true, false, false, true, false, 'something'],
+ [false, false, false, true, false, 'something'],
+ [false, false, false, false, false, ''],
+ [false, false, true, false, false, ''],
+ [false, true, false, false, false, ''],
+ [true, true, true, true, true, ''],
];
}
}
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Client/ElasticsearchTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Client/ElasticsearchTest.php
index 8fbd183441b6d..5f5807e212961 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Client/ElasticsearchTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Elasticsearch5/Model/Client/ElasticsearchTest.php
@@ -8,6 +8,9 @@
use Magento\Elasticsearch\Model\Client\Elasticsearch as ElasticsearchClient;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+/**
+ * Class ElasticsearchTest
+ */
class ElasticsearchTest extends \PHPUnit\Framework\TestCase
{
/**
@@ -38,30 +41,34 @@ class ElasticsearchTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->elasticsearchClientMock = $this->getMockBuilder(\Elasticsearch\Client::class)
- ->setMethods([
- 'indices',
- 'ping',
- 'bulk',
- 'search',
- 'scroll',
- 'suggest',
- 'info',
- ])
+ ->setMethods(
+ [
+ 'indices',
+ 'ping',
+ 'bulk',
+ 'search',
+ 'scroll',
+ 'suggest',
+ 'info',
+ ]
+ )
->disableOriginalConstructor()
->getMock();
$this->indicesMock = $this->getMockBuilder(\Elasticsearch\Namespaces\IndicesNamespace::class)
- ->setMethods([
- 'exists',
- 'getSettings',
- 'create',
- 'delete',
- 'putMapping',
- 'deleteMapping',
- 'stats',
- 'updateAliases',
- 'existsAlias',
- 'getAlias',
- ])
+ ->setMethods(
+ [
+ 'exists',
+ 'getSettings',
+ 'create',
+ 'delete',
+ 'putMapping',
+ 'deleteMapping',
+ 'stats',
+ 'updateAliases',
+ 'existsAlias',
+ 'getAlias',
+ ]
+ )
->disableOriginalConstructor()
->getMock();
$this->elasticsearchClientMock->expects($this->any())
@@ -174,10 +181,12 @@ public function testCreateIndexExists()
{
$this->indicesMock->expects($this->once())
->method('create')
- ->with([
- 'index' => 'indexName',
- 'body' => [],
- ]);
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'body' => [],
+ ]
+ );
$this->model->createIndex('indexName', []);
}
@@ -263,9 +272,7 @@ public function testIndexExists()
{
$this->indicesMock->expects($this->once())
->method('exists')
- ->with([
- 'index' => 'indexName',
- ])
+ ->with(['index' => 'indexName'])
->willReturn(true);
$this->model->indexExists('indexName');
}
@@ -321,10 +328,12 @@ public function testCreateIndexFailure()
{
$this->indicesMock->expects($this->once())
->method('create')
- ->with([
- 'index' => 'indexName',
- 'body' => [],
- ])
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'body' => [],
+ ]
+ )
->willThrowException(new \Exception('Something went wrong'));
$this->model->createIndex('indexName', []);
}
@@ -336,54 +345,57 @@ public function testAddFieldsMapping()
{
$this->indicesMock->expects($this->once())
->method('putMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- 'body' => [
- 'product' => [
- '_all' => [
- 'enabled' => true,
- 'type' => 'text',
- ],
- 'properties' => [
- 'name' => [
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ 'body' => [
+ 'product' => [
+ '_all' => [
+ 'enabled' => true,
'type' => 'text',
],
- ],
- 'dynamic_templates' => [
- [
- 'price_mapping' => [
- 'match' => 'price_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'float',
- 'store' => true,
- ],
+ 'properties' => [
+ 'name' => [
+ 'type' => 'text',
],
],
- [
- 'string_mapping' => [
- 'match' => '*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'text',
- 'index' => false,
+ 'dynamic_templates' => [
+ [
+ 'price_mapping' => [
+ 'match' => 'price_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'float',
+ 'store' => true,
+ ],
],
],
- ],
- [
- 'position_mapping' => [
- 'match' => 'position_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'int',
+ [
+ 'position_mapping' => [
+ 'match' => 'position_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'integer',
+ 'index' => false
+ ],
+ ],
+ ],
+ [
+ 'string_mapping' => [
+ 'match' => '*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'text',
+ 'index' => false,
+ ],
],
],
],
],
],
- ],
- ]);
+ ]
+ );
$this->model->addFieldsMapping(
[
'name' => [
@@ -403,54 +415,57 @@ public function testAddFieldsMappingFailure()
{
$this->indicesMock->expects($this->once())
->method('putMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- 'body' => [
- 'product' => [
- '_all' => [
- 'enabled' => true,
- 'type' => 'text',
- ],
- 'properties' => [
- 'name' => [
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ 'body' => [
+ 'product' => [
+ '_all' => [
+ 'enabled' => true,
'type' => 'text',
],
- ],
- 'dynamic_templates' => [
- [
- 'price_mapping' => [
- 'match' => 'price_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'float',
- 'store' => true,
- ],
+ 'properties' => [
+ 'name' => [
+ 'type' => 'text',
],
],
- [
- 'string_mapping' => [
- 'match' => '*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'text',
- 'index' => false,
+ 'dynamic_templates' => [
+ [
+ 'price_mapping' => [
+ 'match' => 'price_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'float',
+ 'store' => true,
+ ],
],
],
- ],
- [
- 'position_mapping' => [
- 'match' => 'position_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'int',
+ [
+ 'position_mapping' => [
+ 'match' => 'position_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'integer',
+ 'index' => false
+ ],
],
],
+ [
+ 'string_mapping' => [
+ 'match' => '*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'text',
+ 'index' => false,
+ ],
+ ],
+ ]
],
],
],
- ],
- ])
+ ]
+ )
->willThrowException(new \Exception('Something went wrong'));
$this->model->addFieldsMapping(
[
@@ -470,10 +485,12 @@ public function testDeleteMapping()
{
$this->indicesMock->expects($this->once())
->method('deleteMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- ]);
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ ]
+ );
$this->model->deleteMapping(
'indexName',
'product'
@@ -488,10 +505,12 @@ public function testDeleteMappingFailure()
{
$this->indicesMock->expects($this->once())
->method('deleteMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- ])
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ ]
+ )
->willThrowException(new \Exception('Something went wrong'));
$this->model->deleteMapping(
'indexName',
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php
index 7c2a33c05aa08..cdb4ea4021f79 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/DynamicFieldTest.php
@@ -184,21 +184,25 @@ public function testGetAllAttributesTypes(
$this->fieldNameResolver->expects($this->any())
->method('getFieldName')
- ->will($this->returnCallback(
- function ($attribute) use ($categoryId) {
- static $callCount = [];
- $attributeCode = $attribute->getAttributeCode();
- $callCount[$attributeCode] = !isset($callCount[$attributeCode]) ? 1 : ++$callCount[$attributeCode];
+ ->will(
+ $this->returnCallback(
+ function ($attribute) use ($categoryId) {
+ static $callCount = [];
+ $attributeCode = $attribute->getAttributeCode();
+ $callCount[$attributeCode] = !isset($callCount[$attributeCode])
+ ? 1
+ : ++$callCount[$attributeCode];
- if ($attributeCode === 'category') {
- return 'category_name_' . $categoryId;
- } elseif ($attributeCode === 'position') {
- return 'position_' . $categoryId;
- } elseif ($attributeCode === 'price') {
- return 'price_' . $categoryId . '_1';
+ if ($attributeCode === 'category') {
+ return 'category_name_' . $categoryId;
+ } elseif ($attributeCode === 'position') {
+ return 'position_' . $categoryId;
+ } elseif ($attributeCode === 'price') {
+ return 'price_' . $categoryId . '_1';
+ }
}
- }
- ));
+ )
+ );
$priceAttributeMock = $this->getMockBuilder(AttributeAdapter::class)
->disableOriginalConstructor()
->setMethods(['getAttributeCode'])
@@ -215,44 +219,47 @@ function ($attribute) use ($categoryId) {
$this->attributeAdapterProvider->expects($this->any())
->method('getByAttributeCode')
->with($this->anything())
- ->will($this->returnCallback(
- function ($code) use (
- $categoryAttributeMock,
- $positionAttributeMock,
- $priceAttributeMock
- ) {
- static $callCount = [];
- $callCount[$code] = !isset($callCount[$code]) ? 1 : ++$callCount[$code];
+ ->will(
+ $this->returnCallback(
+ function ($code) use (
+ $categoryAttributeMock,
+ $positionAttributeMock,
+ $priceAttributeMock
+ ) {
+ static $callCount = [];
+ $callCount[$code] = !isset($callCount[$code]) ? 1 : ++$callCount[$code];
- if ($code === 'position') {
- return $positionAttributeMock;
- } elseif ($code === 'category_name') {
- return $categoryAttributeMock;
- } elseif ($code === 'price') {
- return $priceAttributeMock;
+ if ($code === 'position') {
+ return $positionAttributeMock;
+ } elseif ($code === 'category_name') {
+ return $categoryAttributeMock;
+ } elseif ($code === 'price') {
+ return $priceAttributeMock;
+ }
}
- }
- ));
+ )
+ );
$this->fieldTypeConverter->expects($this->any())
->method('convert')
->with($this->anything())
- ->will($this->returnCallback(
- function ($type) use ($complexType) {
- static $callCount = [];
- $callCount[$type] = !isset($callCount[$type]) ? 1 : ++$callCount[$type];
+ ->will(
+ $this->returnCallback(
+ function ($type) use ($complexType) {
+ static $callCount = [];
+ $callCount[$type] = !isset($callCount[$type]) ? 1 : ++$callCount[$type];
- if ($type === 'string') {
- return 'string';
+ if ($type === 'string') {
+ return 'string';
+ } elseif ($type === 'float') {
+ return 'float';
+ } elseif ($type === 'integer') {
+ return 'integer';
+ } else {
+ return $complexType;
+ }
}
- if ($type === 'string') {
- return 'string';
- } elseif ($type === 'float') {
- return 'float';
- } else {
- return $complexType;
- }
- }
- ));
+ )
+ );
$this->assertEquals(
$expected,
@@ -276,7 +283,7 @@ public function attributeProvider()
'index' => 'no_index'
],
'position_1' => [
- 'type' => 'string',
+ 'type' => 'integer',
'index' => 'no_index'
],
'price_1_1' => [
@@ -295,7 +302,7 @@ public function attributeProvider()
'index' => 'no_index'
],
'position_1' => [
- 'type' => 'string',
+ 'type' => 'integer',
'index' => 'no_index'
],
'price_1_1' => [
@@ -314,7 +321,7 @@ public function attributeProvider()
'index' => 'no_index'
],
'position_1' => [
- 'type' => 'string',
+ 'type' => 'integer',
'index' => 'no_index'
],
'price_1_1' => [
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php
index 7570c8971b27b..c45ebe20b6be6 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/Adapter/FieldMapper/Product/FieldProvider/FieldType/Resolver/IntegerTypeTest.php
@@ -52,15 +52,18 @@ protected function setUp()
/**
* @dataProvider getFieldTypeProvider
- * @param $attributeCode
- * @param $isIntegerType
- * @param $isBooleanType
- * @param $isUserDefined
- * @param $expected
+ * @param string $attributeCode
+ * @param bool $isIntegerType
+ * @param bool $isBooleanType
+ * @param string|null $expected
* @return void
*/
- public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType, $isUserDefined, $expected)
- {
+ public function testGetFieldType(
+ string $attributeCode,
+ bool $isIntegerType,
+ bool $isBooleanType,
+ $expected
+ ): void {
$attributeMock = $this->getMockBuilder(AttributeAdapter::class)
->disableOriginalConstructor()
->setMethods(['getAttributeCode', 'isIntegerType', 'isBooleanType', 'isUserDefined'])
@@ -74,9 +77,6 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
$attributeMock->expects($this->any())
->method('isBooleanType')
->willReturn($isBooleanType);
- $attributeMock->expects($this->any())
- ->method('isUserDefined')
- ->willReturn($isUserDefined);
$this->fieldTypeConverter->expects($this->any())
->method('convert')
->willReturn('something');
@@ -93,12 +93,12 @@ public function testGetFieldType($attributeCode, $isIntegerType, $isBooleanType,
public function getFieldTypeProvider()
{
return [
- ['category_ids', true, true, true, null],
- ['category_ids', false, false, false, null],
- ['type', true, false, false, 'something'],
- ['type', false, true, false, 'something'],
- ['type', true, true, true, ''],
- ['type', false, false, true, ''],
+ ['category_ids', true, true, 'something'],
+ ['category_ids', false, false, null],
+ ['type', true, false, 'something'],
+ ['type', false, true, 'something'],
+ ['type', true, true, 'something'],
+ ['type', false, false, ''],
];
}
}
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/ConfigTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/ConfigTest.php
index 3829a2f9280c1..dfe6deb23c22f 100644
--- a/app/code/Magento/Elasticsearch/Test/Unit/Model/ConfigTest.php
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/ConfigTest.php
@@ -61,7 +61,7 @@ public function testPrepareClientOptions()
'password' => 'pass',
'timeout' => 1,
];
- $this->assertEquals($options, $this->model->prepareClientOptions($options));
+ $this->assertEquals($options, $this->model->prepareClientOptions(array_merge($options, ['test' => 'test'])));
}
/**
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/Indexer/Plugin/StockedProductsFilterPluginTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/Indexer/Plugin/StockedProductsFilterPluginTest.php
deleted file mode 100644
index f66d2532b32ae..0000000000000
--- a/app/code/Magento/Elasticsearch/Test/Unit/Model/Indexer/Plugin/StockedProductsFilterPluginTest.php
+++ /dev/null
@@ -1,134 +0,0 @@
-configMock = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
- $this->stockConfigurationMock = $this->getMockBuilder(StockConfigurationInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->stockStatusRepositoryMock = $this->getMockBuilder(StockStatusRepositoryInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
- $this->stockStatusCriteriaFactoryMock = $this->getMockBuilder(StockStatusCriteriaInterfaceFactory::class)
- ->disableOriginalConstructor()
- ->getMock();
-
- $this->plugin = new StockedProductsFilterPlugin(
- $this->configMock,
- $this->stockConfigurationMock,
- $this->stockStatusRepositoryMock,
- $this->stockStatusCriteriaFactoryMock
- );
- }
-
- /**
- * @return void
- */
- public function testBeforePrepareProductIndex(): void
- {
- /** @var DataProvider|\PHPUnit_Framework_MockObject_MockObject $dataProviderMock */
- $dataProviderMock = $this->getMockBuilder(DataProvider::class)->disableOriginalConstructor()->getMock();
- $indexData = [
- 1 => [],
- 2 => [],
- ];
- $productData = [];
- $storeId = 1;
-
- $this->configMock
- ->expects($this->once())
- ->method('isElasticsearchEnabled')
- ->willReturn(true);
- $this->stockConfigurationMock
- ->expects($this->once())
- ->method('isShowOutOfStock')
- ->willReturn(false);
-
- $stockStatusCriteriaMock = $this->getMockBuilder(StockStatusCriteriaInterface::class)->getMock();
- $stockStatusCriteriaMock
- ->expects($this->once())
- ->method('setProductsFilter')
- ->willReturn(true);
- $this->stockStatusCriteriaFactoryMock
- ->expects($this->once())
- ->method('create')
- ->willReturn($stockStatusCriteriaMock);
-
- $stockStatusMock = $this->getMockBuilder(StockStatusInterface::class)->getMock();
- $stockStatusMock->expects($this->atLeastOnce())
- ->method('getStockStatus')
- ->willReturnOnConsecutiveCalls(Stock::STOCK_IN_STOCK, Stock::STOCK_OUT_OF_STOCK);
- $stockStatusCollectionMock = $this->getMockBuilder(StockStatusCollectionInterface::class)->getMock();
- $stockStatusCollectionMock
- ->expects($this->once())
- ->method('getItems')
- ->willReturn([
- 1 => $stockStatusMock,
- 2 => $stockStatusMock,
- ]);
- $this->stockStatusRepositoryMock
- ->expects($this->once())
- ->method('getList')
- ->willReturn($stockStatusCollectionMock);
-
- list ($indexData, $productData, $storeId) = $this->plugin->beforePrepareProductIndex(
- $dataProviderMock,
- $indexData,
- $productData,
- $storeId
- );
-
- $this->assertEquals([1], array_keys($indexData));
- }
-}
diff --git a/app/code/Magento/Elasticsearch/Test/Unit/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolverTest.php b/app/code/Magento/Elasticsearch/Test/Unit/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolverTest.php
new file mode 100644
index 0000000000000..30a1642378b71
--- /dev/null
+++ b/app/code/Magento/Elasticsearch/Test/Unit/Model/ResourceModel/Fulltext/Collection/SearchCriteriaResolverTest.php
@@ -0,0 +1,104 @@
+searchCriteriaBuilder = $this->getMockBuilder(SearchCriteriaBuilder::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setPageSize', 'create'])
+ ->getMock();
+ }
+
+ /**
+ * @param array|null $orders
+ * @param array|null $expected
+ * @dataProvider resolveSortOrderDataProvider
+ */
+ public function testResolve($orders, $expected)
+ {
+ $searchRequestName = 'test';
+ $currentPage = 1;
+ $size = 10;
+
+ $searchCriteria = $this->getMockBuilder(SearchCriteria::class)
+ ->disableOriginalConstructor()
+ ->setMethods(['setRequestName', 'setSortOrders', 'setCurrentPage'])
+ ->getMock();
+ $searchCriteria->expects($this->once())
+ ->method('setRequestName')
+ ->with($searchRequestName)
+ ->willReturn($searchCriteria);
+ $searchCriteria->expects($this->once())
+ ->method('setSortOrders')
+ ->with($expected)
+ ->willReturn($searchCriteria);
+ $searchCriteria->expects($this->once())
+ ->method('setCurrentPage')
+ ->with($currentPage - 1)
+ ->willReturn($searchCriteria);
+
+ $this->searchCriteriaBuilder->expects($this->once())
+ ->method('create')
+ ->willReturn($searchCriteria);
+ $this->searchCriteriaBuilder->expects($this->once())
+ ->method('setPageSize')
+ ->with($size)
+ ->willReturn($this->searchCriteriaBuilder);
+
+ $objectManager = new ObjectManagerHelper($this);
+ /** @var SearchCriteriaResolver $model */
+ $model = $objectManager->getObject(
+ SearchCriteriaResolver::class,
+ [
+ 'builder' => $this->searchCriteriaBuilder,
+ 'searchRequestName' => $searchRequestName,
+ 'currentPage' => $currentPage,
+ 'size' => $size,
+ 'orders' => $orders,
+ ]
+ );
+
+ $model->resolve();
+ }
+
+ /**
+ * @return array
+ */
+ public function resolveSortOrderDataProvider()
+ {
+ return [
+ [
+ null,
+ null,
+ ],
+ [
+ ['test' => 'ASC'],
+ ['test' => 'ASC'],
+ ],
+ ];
+ }
+}
diff --git a/app/code/Magento/Elasticsearch/etc/di.xml b/app/code/Magento/Elasticsearch/etc/di.xml
index 9732ae8226431..55df6a5a37f46 100644
--- a/app/code/Magento/Elasticsearch/etc/di.xml
+++ b/app/code/Magento/Elasticsearch/etc/di.xml
@@ -49,6 +49,7 @@
elasticsearchSearchCriteriaResolverFactory
elasticsearchSearchResultApplier\Factory
elasticsearchTotalRecordsResolver\Factory
+
Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyChecker
@@ -71,6 +72,7 @@
elasticsearchSearchCriteriaResolverFactory
elasticsearchSearchResultApplier\Factory
elasticsearchTotalRecordsResolver\Factory
+ Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyChecker
@@ -93,6 +95,7 @@
elasticsearchSearchCriteriaResolverFactory
elasticsearchSearchResultApplier\Factory
elasticsearchTotalRecordsResolver\Factory
+ Magento\Elasticsearch\Model\ResourceModel\Fulltext\Collection\DefaultFilterStrategyApplyChecker
@@ -313,9 +316,6 @@
-
-
-
@@ -478,7 +478,7 @@
Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\Converter
Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldIndex\IndexResolver
\Magento\Elasticsearch\Elasticsearch5\Model\Adapter\FieldMapper\Product\FieldProvider\FieldType\Resolver\CompositeResolver
- \Magento\Elasticsearch\Model\Adapter\FieldMapper\Product\FieldProvider\FieldName\ResolverInterface
+ elasticsearch5FieldNameResolver
diff --git a/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php b/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php
index af39b24acda56..34129a5af0012 100644
--- a/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php
+++ b/app/code/Magento/Elasticsearch6/Model/Client/Elasticsearch.php
@@ -104,7 +104,9 @@ public function testConnection()
private function buildConfig($options = [])
{
$host = preg_replace('/http[s]?:\/\//i', '', $options['hostname']);
+ // @codingStandardsIgnoreStart
$protocol = parse_url($options['hostname'], PHP_URL_SCHEME);
+ // @codingStandardsIgnoreEnd
if (!$protocol) {
$protocol = 'http';
}
@@ -139,10 +141,12 @@ public function bulkQuery($query)
*/
public function createIndex($index, $settings)
{
- $this->getClient()->indices()->create([
- 'index' => $index,
- 'body' => $settings,
- ]);
+ $this->getClient()->indices()->create(
+ [
+ 'index' => $index,
+ 'body' => $settings,
+ ]
+ );
}
/**
@@ -262,22 +266,23 @@ public function addFieldsMapping(array $fields, $index, $entityType)
],
],
[
- 'string_mapping' => [
- 'match' => '*',
+ 'position_mapping' => [
+ 'match' => 'position_*',
'match_mapping_type' => 'string',
'mapping' => [
- 'type' => 'text',
+ 'type' => 'integer',
'index' => false,
- 'copy_to' => '_search'
],
],
],
[
- 'position_mapping' => [
- 'match' => 'position_*',
+ 'string_mapping' => [
+ 'match' => '*',
'match_mapping_type' => 'string',
'mapping' => [
- 'type' => 'int',
+ 'type' => 'text',
+ 'index' => false,
+ 'copy_to' => '_search'
],
],
],
@@ -302,10 +307,12 @@ public function addFieldsMapping(array $fields, $index, $entityType)
*/
public function deleteMapping($index, $entityType)
{
- $this->getClient()->indices()->deleteMapping([
- 'index' => $index,
- 'type' => $entityType,
- ]);
+ $this->getClient()->indices()->deleteMapping(
+ [
+ 'index' => $index,
+ 'type' => $entityType,
+ ]
+ );
}
/**
diff --git a/app/code/Magento/Elasticsearch6/Test/Unit/Model/Client/ElasticsearchTest.php b/app/code/Magento/Elasticsearch6/Test/Unit/Model/Client/ElasticsearchTest.php
index 8276d0dd8dbe8..487a5a886f951 100644
--- a/app/code/Magento/Elasticsearch6/Test/Unit/Model/Client/ElasticsearchTest.php
+++ b/app/code/Magento/Elasticsearch6/Test/Unit/Model/Client/ElasticsearchTest.php
@@ -8,6 +8,9 @@
use Magento\Elasticsearch\Model\Client\Elasticsearch as ElasticsearchClient;
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
+/**
+ * Class ElasticsearchTest
+ */
class ElasticsearchTest extends \PHPUnit\Framework\TestCase
{
/**
@@ -38,30 +41,34 @@ class ElasticsearchTest extends \PHPUnit\Framework\TestCase
protected function setUp()
{
$this->elasticsearchClientMock = $this->getMockBuilder(\Elasticsearch\Client::class)
- ->setMethods([
- 'indices',
- 'ping',
- 'bulk',
- 'search',
- 'scroll',
- 'suggest',
- 'info',
- ])
+ ->setMethods(
+ [
+ 'indices',
+ 'ping',
+ 'bulk',
+ 'search',
+ 'scroll',
+ 'suggest',
+ 'info',
+ ]
+ )
->disableOriginalConstructor()
->getMock();
$this->indicesMock = $this->getMockBuilder(\Elasticsearch\Namespaces\IndicesNamespace::class)
- ->setMethods([
- 'exists',
- 'getSettings',
- 'create',
- 'delete',
- 'putMapping',
- 'deleteMapping',
- 'stats',
- 'updateAliases',
- 'existsAlias',
- 'getAlias',
- ])
+ ->setMethods(
+ [
+ 'exists',
+ 'getSettings',
+ 'create',
+ 'delete',
+ 'putMapping',
+ 'deleteMapping',
+ 'stats',
+ 'updateAliases',
+ 'existsAlias',
+ 'getAlias',
+ ]
+ )
->disableOriginalConstructor()
->getMock();
$this->elasticsearchClientMock->expects($this->any())
@@ -174,10 +181,12 @@ public function testCreateIndexExists()
{
$this->indicesMock->expects($this->once())
->method('create')
- ->with([
- 'index' => 'indexName',
- 'body' => [],
- ]);
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'body' => [],
+ ]
+ );
$this->model->createIndex('indexName', []);
}
@@ -263,9 +272,7 @@ public function testIndexExists()
{
$this->indicesMock->expects($this->once())
->method('exists')
- ->with([
- 'index' => 'indexName',
- ])
+ ->with(['index' => 'indexName'])
->willReturn(true);
$this->model->indexExists('indexName');
}
@@ -321,10 +328,12 @@ public function testCreateIndexFailure()
{
$this->indicesMock->expects($this->once())
->method('create')
- ->with([
- 'index' => 'indexName',
- 'body' => [],
- ])
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'body' => [],
+ ]
+ )
->willThrowException(new \Exception('Something went wrong'));
$this->model->createIndex('indexName', []);
}
@@ -336,54 +345,57 @@ public function testAddFieldsMapping()
{
$this->indicesMock->expects($this->once())
->method('putMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- 'body' => [
- 'product' => [
- 'properties' => [
- '_search' => [
- 'type' => 'text',
- ],
- 'name' => [
- 'type' => 'text',
- ],
- ],
- 'dynamic_templates' => [
- [
- 'price_mapping' => [
- 'match' => 'price_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'float',
- 'store' => true,
- ],
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ 'body' => [
+ 'product' => [
+ 'properties' => [
+ '_search' => [
+ 'type' => 'text',
+ ],
+ 'name' => [
+ 'type' => 'text',
],
],
- [
- 'string_mapping' => [
- 'match' => '*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'text',
- 'index' => false,
- 'copy_to' => '_search'
+ 'dynamic_templates' => [
+ [
+ 'price_mapping' => [
+ 'match' => 'price_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'float',
+ 'store' => true,
+ ],
],
],
- ],
- [
- 'position_mapping' => [
- 'match' => 'position_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'int',
+ [
+ 'position_mapping' => [
+ 'match' => 'position_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'integer',
+ 'index' => false
+ ],
],
],
+ [
+ 'string_mapping' => [
+ 'match' => '*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'text',
+ 'index' => false,
+ 'copy_to' => '_search'
+ ],
+ ],
+ ]
],
],
],
- ],
- ]);
+ ]
+ );
$this->model->addFieldsMapping(
[
'name' => [
@@ -403,54 +415,57 @@ public function testAddFieldsMappingFailure()
{
$this->indicesMock->expects($this->once())
->method('putMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- 'body' => [
- 'product' => [
- 'properties' => [
- '_search' => [
- 'type' => 'text',
- ],
- 'name' => [
- 'type' => 'text',
- ],
- ],
- 'dynamic_templates' => [
- [
- 'price_mapping' => [
- 'match' => 'price_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'float',
- 'store' => true,
- ],
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ 'body' => [
+ 'product' => [
+ 'properties' => [
+ '_search' => [
+ 'type' => 'text',
+ ],
+ 'name' => [
+ 'type' => 'text',
],
],
- [
- 'string_mapping' => [
- 'match' => '*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'text',
- 'index' => false,
- 'copy_to' => '_search'
+ 'dynamic_templates' => [
+ [
+ 'price_mapping' => [
+ 'match' => 'price_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'float',
+ 'store' => true,
+ ],
],
],
- ],
- [
- 'position_mapping' => [
- 'match' => 'position_*',
- 'match_mapping_type' => 'string',
- 'mapping' => [
- 'type' => 'int',
+ [
+ 'position_mapping' => [
+ 'match' => 'position_*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'integer',
+ 'index' => false
+ ],
],
],
+ [
+ 'string_mapping' => [
+ 'match' => '*',
+ 'match_mapping_type' => 'string',
+ 'mapping' => [
+ 'type' => 'text',
+ 'index' => false,
+ 'copy_to' => '_search'
+ ],
+ ],
+ ]
],
],
],
- ],
- ])
+ ]
+ )
->willThrowException(new \Exception('Something went wrong'));
$this->model->addFieldsMapping(
[
@@ -470,10 +485,12 @@ public function testDeleteMapping()
{
$this->indicesMock->expects($this->once())
->method('deleteMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- ]);
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ ]
+ );
$this->model->deleteMapping(
'indexName',
'product'
@@ -488,10 +505,12 @@ public function testDeleteMappingFailure()
{
$this->indicesMock->expects($this->once())
->method('deleteMapping')
- ->with([
- 'index' => 'indexName',
- 'type' => 'product',
- ])
+ ->with(
+ [
+ 'index' => 'indexName',
+ 'type' => 'product',
+ ]
+ )
->willThrowException(new \Exception('Something went wrong'));
$this->model->deleteMapping(
'indexName',
diff --git a/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php b/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php
index 1ea6e3f921bc6..0ca6615b075b2 100644
--- a/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php
+++ b/app/code/Magento/Email/Block/Adminhtml/Template/Preview.php
@@ -12,7 +12,7 @@
namespace Magento\Email\Block\Adminhtml\Template;
/**
- * Template Preview Block
+ * Email template preview block.
*
* @api
* @since 100.0.2
@@ -70,8 +70,6 @@ protected function _toHtml()
$template->setTemplateStyles($this->getRequest()->getParam('styles'));
}
- $template->setTemplateText($this->_maliciousCode->filter($template->getTemplateText()));
-
\Magento\Framework\Profiler::start($this->profilerName);
$template->emulateDesign($storeId);
@@ -80,6 +78,7 @@ protected function _toHtml()
[$template, 'getProcessedTemplate']
);
$template->revertDesign();
+ $templateProcessed = $this->_maliciousCode->filter($templateProcessed);
if ($template->isPlain()) {
$templateProcessed = "" . $this->escapeHtml($templateProcessed) . "
";
diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php
new file mode 100644
index 0000000000000..31d172935da7f
--- /dev/null
+++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Popup.php
@@ -0,0 +1,53 @@
+resultPageFactory = $resultPageFactory;
+ }
+
+ /**
+ * Load the page.
+ *
+ * Load the page defined in view/adminhtml/layout/adminhtml_email_template_popup.xml
+ *
+ * @return \Magento\Framework\View\Result\Page
+ */
+ public function execute()
+ {
+ return $this->resultPageFactory->create();
+ }
+
+ /**
+ * @inheritdoc
+ */
+ protected function _isAllowed()
+ {
+ return $this->_authorization->isAllowed('Magento_Email::template');
+ }
+}
diff --git a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php
index 404f97c937167..c1a8eec07e461 100644
--- a/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php
+++ b/app/code/Magento/Email/Controller/Adminhtml/Email/Template/Preview.php
@@ -6,10 +6,15 @@
*/
namespace Magento\Email\Controller\Adminhtml\Email\Template;
-class Preview extends \Magento\Email\Controller\Adminhtml\Email\Template
+use Magento\Framework\App\Action\HttpGetActionInterface;
+
+/**
+ * Rendering email template preview.
+ */
+class Preview extends \Magento\Email\Controller\Adminhtml\Email\Template implements HttpGetActionInterface
{
/**
- * Preview transactional email action
+ * Preview transactional email action.
*
* @return void
*/
@@ -19,7 +24,7 @@ public function execute()
$this->_view->loadLayout();
$this->_view->getPage()->getConfig()->getTitle()->prepend(__('Email Preview'));
$this->_view->renderLayout();
- $this->getResponse()->setHeader('Content-Security-Policy', "script-src 'none'");
+ $this->getResponse()->setHeader('Content-Security-Policy', "script-src 'self'");
} catch (\Exception $e) {
$this->messageManager->addErrorMessage(
__('An error occurred. The email template can not be opened for preview.')
diff --git a/app/code/Magento/Email/Model/Template/Filter.php b/app/code/Magento/Email/Model/Template/Filter.php
index aa018d6fd44d6..0e27b2d4c418b 100644
--- a/app/code/Magento/Email/Model/Template/Filter.php
+++ b/app/code/Magento/Email/Model/Template/Filter.php
@@ -321,7 +321,7 @@ public function setDesignParams(array $designParams)
}
/**
- * Retrieve CSS processor
+ * Get CSS processor
*
* @deprecated 100.1.2
* @return Css\Processor
@@ -335,7 +335,7 @@ private function getCssProcessor()
}
/**
- * Retrieve pub directory
+ * Get pub directory
*
* @deprecated 100.1.2
* @param string $dirType
@@ -855,7 +855,7 @@ public function cssDirective($construction)
return $css;
} else {
// Return CSS comment for debugging purposes
- return '/* ' . sprintf(__('Contents of %s could not be loaded or is empty'), $file) . ' */';
+ return '/* ' . __('Contents of the specified CSS file could not be loaded or is empty') . ' */';
}
}
diff --git a/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml b/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml
index d299acd28fc1c..4285f6dbdbb08 100644
--- a/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml
+++ b/app/code/Magento/Email/Test/Mftf/ActionGroup/EmailTemplateActionGroup.xml
@@ -11,29 +11,70 @@
+
+
+
+
+
+
-
-
+
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Data/EmailTemplateData.xml b/app/code/Magento/Email/Test/Mftf/Data/EmailTemplateData.xml
index 04e597244833a..7f28e2241761b 100644
--- a/app/code/Magento/Email/Test/Mftf/Data/EmailTemplateData.xml
+++ b/app/code/Magento/Email/Test/Mftf/Data/EmailTemplateData.xml
@@ -10,5 +10,7 @@
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
Template
+ Template Subject_
+ Template Text_
diff --git a/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplateEditPage.xml b/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplateEditPage.xml
new file mode 100644
index 0000000000000..f369e84abf374
--- /dev/null
+++ b/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplateEditPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplatePage.xml b/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplateIndexPage.xml
similarity index 65%
rename from app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplatePage.xml
rename to app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplateIndexPage.xml
index 9636986dda8fa..c4ba7aa006203 100644
--- a/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplatePage.xml
+++ b/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplateIndexPage.xml
@@ -8,7 +8,7 @@
-
-
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplatePreviewPage.xml b/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplatePreviewPage.xml
new file mode 100644
index 0000000000000..aae010be27fd8
--- /dev/null
+++ b/app/code/Magento/Email/Test/Mftf/Page/AdminEmailTemplatePreviewPage.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateEditSection.xml b/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateEditSection.xml
new file mode 100644
index 0000000000000..4dd4ac14cc040
--- /dev/null
+++ b/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateEditSection.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateIndexSection.xml b/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateIndexSection.xml
new file mode 100644
index 0000000000000..54d5c54627047
--- /dev/null
+++ b/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplateIndexSection.xml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplatePreviewSection.xml b/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplatePreviewSection.xml
new file mode 100644
index 0000000000000..5510800edc06e
--- /dev/null
+++ b/app/code/Magento/Email/Test/Mftf/Section/AdminEmailTemplatePreviewSection.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Section/EmailTemplateSection.xml b/app/code/Magento/Email/Test/Mftf/Section/EmailTemplateSection.xml
deleted file mode 100644
index 4e877bd24239e..0000000000000
--- a/app/code/Magento/Email/Test/Mftf/Section/EmailTemplateSection.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
diff --git a/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml b/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml
new file mode 100644
index 0000000000000..459e3c0f9290f
--- /dev/null
+++ b/app/code/Magento/Email/Test/Mftf/Test/AdminEmailTemplatePreviewTest.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/Test/Mftf/Test/TransactionalEmailsLogoUploadTest.xml b/app/code/Magento/Email/Test/Mftf/Test/TransactionalEmailsLogoUploadTest.xml
index c3870417fa5e0..9e1d9c5c3cdbb 100644
--- a/app/code/Magento/Email/Test/Mftf/Test/TransactionalEmailsLogoUploadTest.xml
+++ b/app/code/Magento/Email/Test/Mftf/Test/TransactionalEmailsLogoUploadTest.xml
@@ -17,6 +17,9 @@
+
+
+
diff --git a/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php b/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
index e11d7fc4db534..286e9a989d4d8 100644
--- a/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
+++ b/app/code/Magento/Email/Test/Unit/Block/Adminhtml/Template/PreviewTest.php
@@ -38,14 +38,16 @@ public function testToHtml($requestParamMap)
{
$storeId = 1;
$template = $this->getMockBuilder(\Magento\Email\Model\Template::class)
- ->setMethods([
- 'setDesignConfig',
- 'getDesignConfig',
- '__wakeup',
- 'getProcessedTemplate',
- 'getAppState',
- 'revertDesign'
- ])
+ ->setMethods(
+ [
+ 'setDesignConfig',
+ 'getDesignConfig',
+ '__wakeup',
+ 'getProcessedTemplate',
+ 'getAppState',
+ 'revertDesign'
+ ]
+ )
->disableOriginalConstructor()
->getMock();
$template->expects($this->once())
@@ -55,9 +57,7 @@ public function testToHtml($requestParamMap)
$designConfigData = [];
$template->expects($this->atLeastOnce())
->method('getDesignConfig')
- ->willReturn(new \Magento\Framework\DataObject(
- $designConfigData
- ));
+ ->willReturn(new \Magento\Framework\DataObject($designConfigData));
$emailFactory = $this->createPartialMock(\Magento\Email\Model\TemplateFactory::class, ['create']);
$emailFactory->expects($this->any())
->method('create')
@@ -79,9 +79,7 @@ public function testToHtml($requestParamMap)
$storeManager->expects($this->any())->method('getDefaultStoreView')->willReturn(null);
$storeManager->expects($this->any())->method('getStores')->willReturn([$store]);
$appState = $this->getMockBuilder(\Magento\Framework\App\State::class)
- ->setConstructorArgs([
- $scopeConfig
- ])
+ ->setConstructorArgs([$scopeConfig])
->setMethods(['emulateAreaCode'])
->disableOriginalConstructor()
->getMock();
@@ -128,16 +126,6 @@ public function toHtmlDataProvider()
{
return [
['data 1' => [
- ['type', null, ''],
- ['text', null, sprintf('%s', self::MALICIOUS_TEXT)],
- ['styles', null, ''],
- ]],
- ['data 2' => [
- ['type', null, ''],
- ['text', null, sprintf('', self::MALICIOUS_TEXT)],
- ['styles', null, ''],
- ]],
- ['data 3' => [
['type', null, ''],
['text', null, self::MALICIOUS_TEXT],
['styles', null, ''],
diff --git a/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php b/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php
index 0ba717a461718..9a67bf59dd4bf 100644
--- a/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php
+++ b/app/code/Magento/Email/Test/Unit/Controller/Adminhtml/Email/Template/PreviewTest.php
@@ -15,9 +15,7 @@
use Magento\Framework\View\Result\Page;
/**
- * Preview Test
- *
- * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ * Preview Test.
*/
class PreviewTest extends \PHPUnit\Framework\TestCase
{
@@ -122,7 +120,7 @@ public function testExecute()
->willReturnSelf();
$this->responseMock->expects($this->once())
->method('setHeader')
- ->with('Content-Security-Policy', "script-src 'none'");
+ ->with('Content-Security-Policy', "script-src 'self'");
$this->assertNull($this->object->execute());
}
diff --git a/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_popup.xml b/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_popup.xml
new file mode 100644
index 0000000000000..d633ac8ccf9e1
--- /dev/null
+++ b/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_popup.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml b/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml
index b308ad7d3dfcd..97f31c618f9b7 100644
--- a/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml
+++ b/app/code/Magento/Email/view/adminhtml/layout/adminhtml_email_template_preview.xml
@@ -6,12 +6,13 @@
*/
-->
-
+
+
+
+
-
-
-
+
diff --git a/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml b/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml
new file mode 100644
index 0000000000000..4d26b59b093e2
--- /dev/null
+++ b/app/code/Magento/Email/view/adminhtml/templates/preview/iframeswitcher.phtml
@@ -0,0 +1,19 @@
+
+
+
+
diff --git a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml
index 8b1f50095d984..9653156e85e80 100644
--- a/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml
+++ b/app/code/Magento/Email/view/adminhtml/templates/template/edit.phtml
@@ -48,7 +48,7 @@ use Magento\Framework\App\TemplateTypesInterface;
= /* @noEscape */ $block->getFormHtml() ?>
-
getOrder()->getIsVirtual()) : ?>