Skip to content

Commit 0c0c30e

Browse files
[Magento Community Engineering] Community Contributions - 2.3-develop
- merged latest code from mainline branch
2 parents cd29d80 + 44648f0 commit 0c0c30e

File tree

12 files changed

+168
-60
lines changed

12 files changed

+168
-60
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="ChangedCookieDomainForMainWebsiteConfigData">
12+
<data key="path">web/cookie/cookie_domain</data>
13+
<data key="scope">website</data>
14+
<data key="scope_code">base</data>
15+
<data key="value">testDomain.com</data>
16+
</entity>
17+
<entity name="EmptyCookieDomainForMainWebsiteConfigData">
18+
<data key="path">web/cookie/cookie_domain</data>
19+
<data key="scope">website</data>
20+
<data key="scope_code">base</data>
21+
<data key="value">''</data>
22+
</entity>
23+
</entities>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminLoginAfterChangeCookieDomainTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Login on the Admin Backend"/>
15+
<title value="Admin user can login after changing cookie domain on main website scope without changing cookie domain on default scope"/>
16+
<description value="Admin user can login after changing cookie domain on main website scope without changing cookie domain on default scope"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MC-17847"/>
19+
<useCaseId value="MC-17275"/>
20+
<group value="backend"/>
21+
</annotations>
22+
<before>
23+
<magentoCLI command="config:set {{ChangedCookieDomainForMainWebsiteConfigData.path}} --scope={{ChangedCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{ChangedCookieDomainForMainWebsiteConfigData.scope_code}} {{ChangedCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteBeforeTestRun"/>
24+
<magentoCLI command="cache:flush config" stepKey="flushCacheBeforeTestRun"/>
25+
</before>
26+
<after>
27+
<magentoCLI command="config:set {{EmptyCookieDomainForMainWebsiteConfigData.path}} --scope={{EmptyCookieDomainForMainWebsiteConfigData.scope}} --scope-code={{EmptyCookieDomainForMainWebsiteConfigData.scope_code}} {{EmptyCookieDomainForMainWebsiteConfigData.value}}" stepKey="changeDomainForMainWebsiteAfterTestComplete"/>
28+
<magentoCLI command="cache:flush config" stepKey="flushCacheAfterTestComplete"/>
29+
</after>
30+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
31+
<actionGroup ref="AssertAdminDashboardPageIsVisibleActionGroup" stepKey="seeDashboardPage"/>
32+
<actionGroup ref="logout" stepKey="logoutFromAdmin"/>
33+
</test>
34+
</tests>

app/code/Magento/Backend/etc/adminhtml/di.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
<arguments>
8787
<argument name="lifetimePath" xsi:type="const">Magento\Backend\Model\Auth\Session::XML_PATH_SESSION_LIFETIME</argument>
8888
<argument name="sessionName" xsi:type="const">Magento\Backend\Model\Session\AdminConfig::SESSION_NAME_ADMIN</argument>
89+
<argument name="scopeType" xsi:type="const">Magento\Framework\App\Config\ScopeConfigInterface::SCOPE_TYPE_DEFAULT</argument>
8990
</arguments>
9091
</type>
9192
<type name="Magento\Framework\View\Result\PageFactory">

app/code/Magento/Catalog/Model/Product/Visibility.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function __construct(
5555
/**
5656
* Retrieve visible in catalog ids array
5757
*
58-
* @return string[]
58+
* @return int[]
5959
*/
6060
public function getVisibleInCatalogIds()
6161
{
@@ -65,7 +65,7 @@ public function getVisibleInCatalogIds()
6565
/**
6666
* Retrieve visible in search ids array
6767
*
68-
* @return string[]
68+
* @return int[]
6969
*/
7070
public function getVisibleInSearchIds()
7171
{
@@ -75,7 +75,7 @@ public function getVisibleInSearchIds()
7575
/**
7676
* Retrieve visible in site ids array
7777
*
78-
* @return string[]
78+
* @return int[]
7979
*/
8080
public function getVisibleInSiteIds()
8181
{
@@ -86,6 +86,7 @@ public function getVisibleInSiteIds()
8686
* Retrieve option array
8787
*
8888
* @return array
89+
* phpcs:disable Magento2.Functions.StaticFunction
8990
*/
9091
public static function getOptionArray()
9192
{
@@ -134,6 +135,7 @@ public static function getOptionText($optionId)
134135
$options = self::getOptionArray();
135136
return isset($options[$optionId]) ? $options[$optionId] : null;
136137
}
138+
//phpcs:enable Magento2.Functions.StaticFunction
137139

138140
/**
139141
* Retrieve flat column definition
@@ -251,7 +253,7 @@ public function addValueSortToCollection($collection, $dir = 'asc')
251253
}
252254

253255
/**
254-
* {@inheritdoc}
256+
* @inheritdoc
255257
*/
256258
public function toOptionArray()
257259
{

app/code/Magento/Ui/view/base/web/js/form/element/date.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,26 @@ define([
114114
* @param {String} value
115115
*/
116116
onValueChange: function (value) {
117-
var dateFormat,
118-
shiftedValue;
117+
var shiftedValue;
119118

120119
if (value) {
121120
if (this.options.showsTime) {
122121
shiftedValue = moment.tz(value, 'UTC').tz(this.storeTimeZone);
123122
} else {
124-
dateFormat = this.shiftedValue() ? this.outputDateFormat : this.inputDateFormat;
125-
shiftedValue = moment(value, dateFormat);
123+
shiftedValue = moment(value, this.outputDateFormat);
126124
}
127125

128-
shiftedValue = shiftedValue.format(this.pickerDateTimeFormat);
129-
130-
if (shiftedValue !== this.shiftedValue()) {
131-
this.shiftedValue(shiftedValue);
126+
if (!shiftedValue.isValid()) {
127+
shiftedValue = moment(value, this.inputDateFormat);
132128
}
129+
shiftedValue = shiftedValue.format(this.pickerDateTimeFormat);
130+
} else {
131+
shiftedValue = '';
133132
}
134133

134+
if (shiftedValue !== this.shiftedValue()) {
135+
this.shiftedValue(shiftedValue);
136+
}
135137
},
136138

137139
/**

app/code/Magento/Ui/view/base/web/js/lib/knockout/bindings/datepicker.js

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,29 +41,60 @@ define([
4141

4242
if (typeof config === 'object') {
4343
observable = config.storage;
44-
4544
_.extend(options, config.options);
4645
} else {
4746
observable = config;
4847
}
4948

5049
$(el).calendar(options);
5150

52-
observable() && $(el).datepicker(
53-
'setDate',
54-
moment(
51+
ko.utils.registerEventHandler(el, 'change', function () {
52+
observable(this.value);
53+
});
54+
},
55+
56+
/**
57+
* Update calendar widget on element and stores it's value to observable property.
58+
* Datepicker binding takes either observable property or object
59+
* { storage: {ko.observable}, options: {Object} }.
60+
* @param {HTMLElement} element - Element, that binding is applied to
61+
* @param {Function} valueAccessor - Function that returns value, passed to binding
62+
*/
63+
update: function (element, valueAccessor) {
64+
var config = valueAccessor(),
65+
observable,
66+
options = {},
67+
newVal;
68+
69+
_.extend(options, defaults);
70+
71+
if (typeof config === 'object') {
72+
observable = config.storage;
73+
_.extend(options, config.options);
74+
} else {
75+
observable = config;
76+
}
77+
78+
if (_.isEmpty(observable())) {
79+
if ($(element).datepicker('getDate')) {
80+
$(element).datepicker('setDate', null);
81+
$(element).blur();
82+
}
83+
} else {
84+
newVal = moment(
5585
observable(),
5686
utils.convertToMomentFormat(
5787
options.dateFormat + (options.showsTime ? ' ' + options.timeFormat : '')
5888
)
59-
).toDate()
60-
);
89+
).toDate();
6190

62-
$(el).blur();
63-
64-
ko.utils.registerEventHandler(el, 'change', function () {
65-
observable(this.value);
66-
});
91+
if ($(element).datepicker('getDate') == null ||
92+
newVal.valueOf() !== $(element).datepicker('getDate').valueOf()
93+
) {
94+
$(element).datepicker('setDate', newVal);
95+
$(element).blur();
96+
}
97+
}
6798
}
6899
};
69100
});

app/code/Magento/Ups/Model/Carrier.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1380,7 +1380,7 @@ protected function _formShipmentRequest(\Magento\Framework\DataObject $request)
13801380
$shipperPart->addChild('PhoneNumber', $request->getShipperContactPhoneNumber());
13811381

13821382
$addressPart = $shipperPart->addChild('Address');
1383-
$addressPart->addChild('AddressLine1', $request->getShipperAddressStreet());
1383+
$addressPart->addChild('AddressLine1', $request->getShipperAddressStreet1());
13841384
$addressPart->addChild('AddressLine2', $request->getShipperAddressStreet2());
13851385
$addressPart->addChild('City', $request->getShipperAddressCity());
13861386
$addressPart->addChild('CountryCode', $request->getShipperAddressCountryCode());

dev/tests/js/jasmine/tests/app/code/Magento/Ui/base/js/lib/ko/bind/datepicker.test.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,23 @@ define([
5353

5454
expect(todayDate).toEqual(result);
5555
});
56+
57+
it('update picked date\'s value after update observable value', function () {
58+
var date = '06/21/2019',
59+
inputFormat = 'M/d/yy',
60+
expectedDate;
61+
62+
expectedDate = moment(date, utils.convertToMomentFormat(inputFormat)).toDate();
63+
observable(date);
64+
65+
expect(expectedDate.valueOf()).toEqual(element.datepicker('getDate').valueOf());
66+
});
67+
68+
it('clear picked date\'s value after clear observable value', function () {
69+
element.datepicker('setTimezoneDate').blur().trigger('change');
70+
observable('');
71+
72+
expect(null).toEqual(element.datepicker('getDate'));
73+
});
5674
});
5775
});

lib/internal/Magento/Framework/Mail/Message.php

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Message implements MailMessageInterface
2323
*
2424
* @var string
2525
*/
26-
private $messageType = self::TYPE_TEXT;
26+
private $messageType = Mime::TYPE_TEXT;
2727

2828
/**
2929
* Initialize dependencies.
@@ -58,8 +58,8 @@ public function setMessageType($type)
5858
*/
5959
public function setBody($body)
6060
{
61-
if (is_string($body) && $this->messageType === MailMessageInterface::TYPE_HTML) {
62-
$body = self::createHtmlMimeFromString($body);
61+
if (is_string($body)) {
62+
$body = self::createMimeFromString($body, $this->messageType);
6363
}
6464
$this->zendMessage->setBody($body);
6565
return $this;
@@ -157,18 +157,19 @@ public function getRawMessage()
157157
}
158158

159159
/**
160-
* Create HTML mime message from the string.
160+
* Create mime message from the string.
161161
*
162-
* @param string $htmlBody
162+
* @param string $body
163+
* @param string $messageType
163164
* @return \Zend\Mime\Message
164165
*/
165-
private function createHtmlMimeFromString($htmlBody)
166+
private function createMimeFromString($body, $messageType)
166167
{
167-
$htmlPart = new Part($htmlBody);
168-
$htmlPart->setCharset($this->zendMessage->getEncoding());
169-
$htmlPart->setType(Mime::TYPE_HTML);
168+
$part = new Part($body);
169+
$part->setCharset($this->zendMessage->getEncoding());
170+
$part->setType($messageType);
170171
$mimeMessage = new \Zend\Mime\Message();
171-
$mimeMessage->addPart($htmlPart);
172+
$mimeMessage->addPart($part);
172173
return $mimeMessage;
173174
}
174175

@@ -177,7 +178,7 @@ private function createHtmlMimeFromString($htmlBody)
177178
*/
178179
public function setBodyHtml($html)
179180
{
180-
$this->setMessageType(self::TYPE_HTML);
181+
$this->setMessageType(Mime::TYPE_HTML);
181182
return $this->setBody($html);
182183
}
183184

@@ -186,7 +187,7 @@ public function setBodyHtml($html)
186187
*/
187188
public function setBodyText($text)
188189
{
189-
$this->setMessageType(self::TYPE_TEXT);
190+
$this->setMessageType(Mime::TYPE_TEXT);
190191
return $this->setBody($text);
191192
}
192193
}

lib/internal/Magento/Framework/Mail/Test/Unit/MessageTest.php

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,44 +5,40 @@
55
*/
66
namespace Magento\Framework\Mail\Test\Unit;
77

8+
/**
9+
* test Magento\Framework\Mail\Message
10+
*/
811
class MessageTest extends \PHPUnit\Framework\TestCase
912
{
1013
/**
11-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\Mail\Message
14+
* @var \Magento\Framework\Mail\Message
1215
*/
13-
protected $_messageMock;
16+
protected $message;
1417

1518
protected function setUp()
1619
{
17-
$this->_messageMock = $this->createPartialMock(
18-
\Magento\Framework\Mail\Message::class,
19-
['setBody', 'setMessageType']
20-
);
20+
$this->message = new \Magento\Framework\Mail\Message();
2121
}
2222

2323
public function testSetBodyHtml()
2424
{
25-
$this->_messageMock->expects($this->once())
26-
->method('setMessageType')
27-
->with('text/html');
25+
$this->message->setBodyHtml('body');
2826

29-
$this->_messageMock->expects($this->once())
30-
->method('setBody')
31-
->with('body');
32-
33-
$this->_messageMock->setBodyHtml('body');
27+
$part = $this->message->getBody()->getParts()[0];
28+
$this->assertEquals('text/html', $part->getType());
29+
$this->assertEquals('8bit', $part->getEncoding());
30+
$this->assertEquals('utf-8', $part->getCharset());
31+
$this->assertEquals('body', $part->getContent());
3432
}
3533

3634
public function testSetBodyText()
3735
{
38-
$this->_messageMock->expects($this->once())
39-
->method('setMessageType')
40-
->with('text/plain');
41-
42-
$this->_messageMock->expects($this->once())
43-
->method('setBody')
44-
->with('body');
36+
$this->message->setBodyText('body');
4537

46-
$this->_messageMock->setBodyText('body');
38+
$part = $this->message->getBody()->getParts()[0];
39+
$this->assertEquals('text/plain', $part->getType());
40+
$this->assertEquals('8bit', $part->getEncoding());
41+
$this->assertEquals('utf-8', $part->getCharset());
42+
$this->assertEquals('body', $part->getContent());
4743
}
4844
}

0 commit comments

Comments
 (0)