Skip to content

Commit 62cd3a1

Browse files
Merge pull request magento#4944 from magento-engcom/2.3-develop-expedited-prs
[Magento Community Engineering] Community Contributions - 2.3-develop expedited
2 parents 3f336e8 + 1a7ae45 commit 62cd3a1

File tree

41 files changed

+508
-103
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+508
-103
lines changed

app/code/Magento/Catalog/Test/Mftf/Section/AdminProductFormSection.xml

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@
158158
<element name="FolderName" type="button" selector="input[data-role='promptField']" />
159159
<element name="AcceptFolderName" type="button" selector=".action-primary.action-accept" timeout="30"/>
160160
<element name="StorageRootArrow" type="button" selector="#root > .jstree-icon" />
161+
<element name="FolderContainer" type="button" selector="div[data-role='tree']" />
161162
<element name="checkIfArrowExpand" type="button" selector="//li[@id='root' and contains(@class,'jstree-closed')]" />
162163
<element name="WysiwygArrow" type="button" selector="#d3lzaXd5Zw-- > .jstree-icon" />
163164
<element name="checkIfWysiwygArrowExpand" type="button" selector="//li[@id='d3lzaXd5Zw--' and contains(@class,'jstree-closed')]" />

app/code/Magento/Catalog/Test/Mftf/Test/AdminAddImageToWYSIWYGProductTest.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,12 @@
7070
<scrollTo selector="{{ProductDescriptionWYSIWYGToolbarSection.TinyMCE4}}" stepKey="scrollToTinyMCE4" />
7171
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertImageIcon}}" stepKey="clickInsertImageIcon2" />
7272
<click selector="{{ProductShortDescriptionWYSIWYGToolbarSection.Browse}}" stepKey="clickBrowse2" />
73+
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
7374
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CancelBtn}}" stepKey="waitForCancelButton2"/>
7475
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CancelBtn}}" userInput="Cancel" stepKey="seeCancelBtn2" />
75-
<waitForLoadingMaskToDisappear stepKey="waitForLoading13"/>
76+
<waitForElementVisible selector="{{ProductDescriptionWYSIWYGToolbarSection.CreateFolder}}" stepKey="waitForCreateFolderBtn2"/>
7677
<see selector="{{ProductShortDescriptionWYSIWYGToolbarSection.CreateFolder}}" userInput="Create Folder" stepKey="seeCreateFolderBtn2" />
77-
<waitForLoadingMaskToDisappear stepKey="waitForLoading14"/>
78+
<see selector="{{ProductDescriptionWYSIWYGToolbarSection.FolderContainer}}" userInput="Storage Root" stepKey="seeFolderContainer" />
7879
<click userInput="Storage Root" stepKey="clickOnRootFolder" />
7980
<waitForLoadingMaskToDisappear stepKey="waitForLoading15"/>
8081
<dontSeeElement selector="{{ProductShortDescriptionWYSIWYGToolbarSection.InsertFile}}" stepKey="dontSeeAddSelectedBtn3" />

app/code/Magento/Cookie/Block/RequireCookie.php

+11-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,22 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
6+
declare(strict_types=1);
77
/**
88
* Frontend form key content block
99
*/
1010
namespace Magento\Cookie\Block;
1111

12+
use Magento\Framework\App\ObjectManager;
13+
use Magento\Framework\App\Config\ScopeConfigInterface;
14+
1215
/**
16+
* Block Require Cookie
17+
*
1318
* @api
1419
* @since 100.0.2
20+
*
21+
* Class \Magento\Cookie\Block\RequireCookie
1522
*/
1623
class RequireCookie extends \Magento\Framework\View\Element\Template
1724
{
@@ -22,9 +29,11 @@ class RequireCookie extends \Magento\Framework\View\Element\Template
2229
*/
2330
public function getScriptOptions()
2431
{
32+
$isRedirectCmsPage = (boolean)$this->_scopeConfig->getValue('web/browser_capabilities/cookies');
2533
$params = [
2634
'noCookieUrl' => $this->escapeUrl($this->getUrl('cookie/index/noCookies/')),
27-
'triggers' => $this->escapeHtml($this->getTriggers())
35+
'triggers' => $this->escapeHtml($this->getTriggers()),
36+
'isRedirectCmsPage' => $isRedirectCmsPage
2837
];
2938
return json_encode($params);
3039
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Cookie\Test\Unit\Block;
10+
11+
use Magento\Cookie\Block\RequireCookie;
12+
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\View\Element\Template\Context;
14+
15+
/**
16+
* Class \Magento\Cookie\Test\Unit\Block\RequireCookieTest
17+
*/
18+
class RequireCookieTest extends \PHPUnit\Framework\TestCase
19+
{
20+
/**
21+
* @var \PHPUnit_Framework_MockObject_MockObject|RequireCookie
22+
*/
23+
private $block;
24+
25+
/**
26+
* @var \PHPUnit_Framework_MockObject_MockObject|ScopeConfigInterface
27+
*/
28+
private $scopeConfig;
29+
30+
/**
31+
* @var \PHPUnit_Framework_MockObject_MockObject|Context
32+
*/
33+
private $context;
34+
35+
/**
36+
* Setup Environment
37+
*/
38+
protected function setUp()
39+
{
40+
$this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
41+
->disableOriginalConstructor()
42+
->setMethods(['getValue'])
43+
->getMockForAbstractClass();
44+
$this->context = $this->getMockBuilder(Context::class)
45+
->disableOriginalConstructor()
46+
->getMock();
47+
$this->context->expects($this->any())->method('getScopeConfig')
48+
->willReturn($this->scopeConfig);
49+
$this->block = $this->getMockBuilder(RequireCookie::class)
50+
->setMethods(['escapeHtml', 'escapeUrl', 'getUrl', 'getTriggers'])
51+
->setConstructorArgs(
52+
[
53+
'context' => $this->context
54+
]
55+
)->getMock();
56+
}
57+
58+
/**
59+
* Test getScriptOptions() when the settings "Redirect to CMS-page if Cookies are Disabled" is "Yes"
60+
*/
61+
public function testGetScriptOptionsWhenRedirectToCmsIsYes()
62+
{
63+
$this->scopeConfig->expects($this->any())->method('getValue')
64+
->with('web/browser_capabilities/cookies')
65+
->willReturn('1');
66+
67+
$this->block->expects($this->any())->method('getUrl')
68+
->with('cookie/index/noCookies/')
69+
->willReturn('http://magento.com/cookie/index/noCookies/');
70+
$this->block->expects($this->any())->method('getTriggers')
71+
->willReturn('test');
72+
$this->block->expects($this->any())->method('escapeUrl')
73+
->with('http://magento.com/cookie/index/noCookies/')
74+
->willReturn('http://magento.com/cookie/index/noCookies/');
75+
$this->block->expects($this->any())->method('escapeHtml')
76+
->with('test')
77+
->willReturn('test');
78+
79+
$this->assertEquals(
80+
'{"noCookieUrl":"http:\/\/magento.com\/cookie\/index\/noCookies\/",' .
81+
'"triggers":"test","isRedirectCmsPage":true}',
82+
$this->block->getScriptOptions()
83+
);
84+
}
85+
86+
/**
87+
* Test getScriptOptions() when the settings "Redirect to CMS-page if Cookies are Disabled" is "No"
88+
*/
89+
public function testGetScriptOptionsWhenRedirectToCmsIsNo()
90+
{
91+
$this->scopeConfig->expects($this->any())->method('getValue')
92+
->with('web/browser_capabilities/cookies')
93+
->willReturn('0');
94+
95+
$this->block->expects($this->any())->method('getUrl')
96+
->with('cookie/index/noCookies/')
97+
->willReturn('http://magento.com/cookie/index/noCookies/');
98+
$this->block->expects($this->any())->method('getTriggers')
99+
->willReturn('test');
100+
$this->block->expects($this->any())->method('escapeUrl')
101+
->with('http://magento.com/cookie/index/noCookies/')
102+
->willReturn('http://magento.com/cookie/index/noCookies/');
103+
$this->block->expects($this->any())->method('escapeHtml')
104+
->with('test')
105+
->willReturn('test');
106+
107+
$this->assertEquals(
108+
'{"noCookieUrl":"http:\/\/magento.com\/cookie\/index\/noCookies\/",' .
109+
'"triggers":"test","isRedirectCmsPage":false}',
110+
$this->block->getScriptOptions()
111+
);
112+
}
113+
}

app/code/Magento/Cookie/i18n/en_US.csv

+2
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@
1111
"Cookie Domain","Cookie Domain"
1212
"Use HTTP Only","Use HTTP Only"
1313
"Cookie Restriction Mode","Cookie Restriction Mode"
14+
"Cookies are disabled in your browser.","Cookies are disabled in your browser."
15+

app/code/Magento/Cookie/view/frontend/web/js/require-cookie.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,19 @@
88
*/
99
define([
1010
'jquery',
11-
'jquery-ui-modules/widget'
12-
], function ($) {
11+
'Magento_Ui/js/modal/alert',
12+
'jquery-ui-modules/widget',
13+
'mage/mage',
14+
'mage/translate'
15+
], function ($, alert) {
1316
'use strict';
1417

1518
$.widget('mage.requireCookie', {
1619
options: {
1720
event: 'click',
1821
noCookieUrl: 'enable-cookies',
19-
triggers: ['.action.login', '.action.submit']
22+
triggers: ['.action.login', '.action.submit'],
23+
isRedirectCmsPage: true
2024
},
2125

2226
/**
@@ -49,8 +53,16 @@ define([
4953
if (navigator.cookieEnabled) {
5054
return;
5155
}
56+
5257
event.preventDefault();
53-
window.location = this.options.noCookieUrl;
58+
59+
if (this.options.isRedirectCmsPage) {
60+
window.location = this.options.noCookieUrl;
61+
} else {
62+
alert({
63+
content: $.mage.__('Cookies are disabled in your browser.')
64+
});
65+
}
5466
}
5567
});
5668

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Email\Test\Unit\Block\Adminhtml\Template\Render;
10+
11+
use Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Sender;
12+
use Magento\Framework\DataObject;
13+
14+
/**
15+
* Class \Magento\Email\Test\Unit\Block\Adminhtml\Template\Render\SenderTest
16+
*/
17+
class SenderTest extends \PHPUnit\Framework\TestCase
18+
{
19+
/**
20+
* @var \PHPUnit_Framework_MockObject_MockObject|Sender
21+
*/
22+
protected $block;
23+
24+
/**
25+
* Setup environment
26+
*/
27+
protected function setUp()
28+
{
29+
$this->block = $this->getMockBuilder(Sender::class)
30+
->disableOriginalConstructor()
31+
->setMethods(['escapeHtml'])
32+
->getMock();
33+
}
34+
35+
/**
36+
* Test render() with sender name and sender email are not empty
37+
*/
38+
public function testRenderWithSenderNameAndEmail()
39+
{
40+
$templateSenderEmail = 'test';
41+
$this->block->expects($this->any())->method('escapeHtml')->with($templateSenderEmail)
42+
->willReturn('test');
43+
$actualResult = $this->block->render(
44+
new DataObject(
45+
[
46+
'template_sender_name' => 'test',
47+
'template_sender_email' => '[email protected]'
48+
]
49+
)
50+
);
51+
$this->assertEquals('test [[email protected]]', $actualResult);
52+
}
53+
54+
/**
55+
* Test render() with sender name and sender email are empty
56+
*/
57+
public function testRenderWithNoSenderNameAndEmail()
58+
{
59+
$templateSenderEmail = '';
60+
$this->block->expects($this->any())->method('escapeHtml')->with($templateSenderEmail)
61+
->willReturn('');
62+
$actualResult = $this->block->render(
63+
new DataObject(
64+
[
65+
'template_sender_name' => '',
66+
'template_sender_email' => ''
67+
]
68+
)
69+
);
70+
$this->assertEquals('---', $actualResult);
71+
}
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Email\Test\Unit\Block\Adminhtml\Template\Render;
10+
11+
use Magento\Email\Block\Adminhtml\Template\Grid\Renderer\Type;
12+
use Magento\Framework\DataObject;
13+
use Magento\Framework\Phrase;
14+
15+
/**
16+
* Class \Magento\Email\Test\Unit\Block\Adminhtml\Template\Render\TypeTest
17+
*/
18+
class TypeTest extends \PHPUnit\Framework\TestCase
19+
{
20+
/**
21+
* @var \PHPUnit_Framework_MockObject_MockObject|Type
22+
*/
23+
protected $block;
24+
25+
/**
26+
* Setup environment
27+
*/
28+
protected function setUp()
29+
{
30+
$this->block = $this->getMockBuilder(Type::class)
31+
->disableOriginalConstructor()
32+
->setMethods(['__'])
33+
->getMock();
34+
}
35+
36+
/**
37+
* Test render() with supported template Text type
38+
*/
39+
public function testRenderWithSupportedTemplateTextType()
40+
{
41+
$testCase = [
42+
'dataset' => [
43+
'template_type' => '1'
44+
],
45+
'expectedResult' => 'Text'
46+
];
47+
$this->executeTestCase($testCase);
48+
}
49+
50+
/**
51+
* Test render() with supported template HTML type
52+
*/
53+
public function testRenderWithSupportedTemplateHtmlType()
54+
{
55+
$testCase = [
56+
'dataset' => [
57+
'template_type' => '2'
58+
],
59+
'expectedResult' => 'HTML'
60+
];
61+
$this->executeTestCase($testCase);
62+
}
63+
64+
/**
65+
* Test render() with unsupported template type
66+
*/
67+
public function testRenderWithUnsupportedTemplateType()
68+
{
69+
$testCase = [
70+
'dataset' => [
71+
'template_type' => '5'
72+
],
73+
'expectedResult' => 'Unknown'
74+
];
75+
$this->executeTestCase($testCase);
76+
}
77+
78+
/**
79+
* Execute Test case
80+
*
81+
* @param array $testCase
82+
*/
83+
public function executeTestCase($testCase)
84+
{
85+
$actualResult = $this->block->render(
86+
new DataObject(
87+
[
88+
'template_type' => $testCase['dataset']['template_type'],
89+
]
90+
)
91+
);
92+
$this->assertEquals(new Phrase($testCase['expectedResult']), $actualResult);
93+
}
94+
}

0 commit comments

Comments
 (0)