Skip to content

Commit b631f9d

Browse files
committed
Merge remote-tracking branch 'upstream/2.3-develop' into project_pepe
2 parents 47a9ed7 + 5588999 commit b631f9d

File tree

13 files changed

+243
-74
lines changed

13 files changed

+243
-74
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/OfflineShipping/Test/Unit/Model/Quote/Address/FreeShippingTest.php

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
use Magento\Store\Model\StoreManagerInterface;
1717
use PHPUnit_Framework_MockObject_MockObject as MockObject;
1818

19+
/**
20+
* Test for Magento\OfflineShipping\Model\Quote\Address\FreeShipping class.
21+
*/
1922
class FreeShippingTest extends \PHPUnit\Framework\TestCase
2023
{
2124
private static $websiteId = 1;
@@ -77,12 +80,14 @@ public function testIsFreeShipping(int $addressFree, int $fItemFree, int $sItemF
7780
[$fItem],
7881
[$sItem]
7982
)
80-
->willReturnCallback(function () use ($fItem, $sItem, $addressFree, $fItemFree, $sItemFree) {
81-
// emulate behavior of cart rule calculator
82-
$fItem->getAddress()->setFreeShipping($addressFree);
83-
$fItem->setFreeShipping($fItemFree);
84-
$sItem->setFreeShipping($sItemFree);
85-
});
83+
->willReturnCallback(
84+
function () use ($fItem, $sItem, $addressFree, $fItemFree, $sItemFree) {
85+
// emulate behavior of cart rule calculator
86+
$fItem->getAddress()->setFreeShipping($addressFree);
87+
$fItem->setFreeShipping($fItemFree);
88+
$sItem->setFreeShipping($sItemFree);
89+
}
90+
);
8691

8792
$actual = $this->model->isFreeShipping($quote, $items);
8893
self::assertEquals($expected, $actual);
@@ -133,8 +138,11 @@ private function getQuote(Address $address): Quote
133138
->disableOriginalConstructor()
134139
->setMethods(
135140
[
136-
'getCouponCode', 'getCustomerGroupId', 'getShippingAddress', 'getStoreId', 'getItemsQty',
137-
'getVirtualItemsQty'
141+
'getCouponCode',
142+
'getCustomerGroupId',
143+
'getShippingAddress',
144+
'getStoreId',
145+
'isVirtual'
138146
]
139147
)
140148
->getMock();
@@ -147,10 +155,8 @@ private function getQuote(Address $address): Quote
147155
->willReturn(self::$couponCode);
148156
$quote->method('getShippingAddress')
149157
->willReturn($address);
150-
$quote->method('getItemsQty')
151-
->willReturn(2);
152-
$quote->method('getVirtualItemsQty')
153-
->willReturn(0);
158+
$quote->method('isVirtual')
159+
->willReturn(false);
154160

155161
return $quote;
156162
}

app/code/Magento/Quote/Model/Quote/Item.php

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ public function beforeSave()
270270
*/
271271
public function getAddress()
272272
{
273-
if ($this->getQuote()->getItemsQty() == $this->getQuote()->getVirtualItemsQty()) {
273+
if ($this->getQuote()->isVirtual()) {
274274
$address = $this->getQuote()->getBillingAddress();
275275
} else {
276276
$address = $this->getQuote()->getShippingAddress();
@@ -282,7 +282,7 @@ public function getAddress()
282282
/**
283283
* Declare quote model object
284284
*
285-
* @param \Magento\Quote\Model\Quote $quote
285+
* @param \Magento\Quote\Model\Quote $quote
286286
* @return $this
287287
*/
288288
public function setQuote(\Magento\Quote\Model\Quote $quote)
@@ -719,6 +719,7 @@ public function getOptionByCode($code)
719719

720720
/**
721721
* Checks that item model has data changes.
722+
*
722723
* Call save item options if model isn't need to save in DB
723724
*
724725
* @return boolean
@@ -813,8 +814,9 @@ public function __clone()
813814
}
814815

815816
/**
816-
* Returns formatted buy request - object, holding request received from
817-
* product view page with keys and options for configured product
817+
* Get formatted buy request.
818+
*
819+
* Returns object, holding request received from product view page with keys and options for configured product.
818820
*
819821
* @return \Magento\Framework\DataObject
820822
*/
@@ -863,6 +865,7 @@ public function setHasError($flag)
863865

864866
/**
865867
* Clears list of errors, associated with this quote item.
868+
*
866869
* Also automatically removes error-flag from oneself.
867870
*
868871
* @return $this
@@ -876,6 +879,7 @@ protected function _clearErrorInfo()
876879

877880
/**
878881
* Adds error information to the quote item.
882+
*
879883
* Automatically sets error flag.
880884
*
881885
* @param string|null $origin Usually a name of module, that embeds error
@@ -930,97 +934,96 @@ public function removeErrorInfosByParams($params)
930934
}
931935

932936
/**
937+
* @inheritdoc
933938
* @codeCoverageIgnoreStart
934-
*
935-
* {@inheritdoc}
936939
*/
937940
public function getItemId()
938941
{
939942
return $this->getData(self::KEY_ITEM_ID);
940943
}
941944

942945
/**
943-
* {@inheritdoc}
946+
* @inheritdoc
944947
*/
945948
public function setItemId($itemID)
946949
{
947950
return $this->setData(self::KEY_ITEM_ID, $itemID);
948951
}
949952

950953
/**
951-
* {@inheritdoc}
954+
* @inheritdoc
952955
*/
953956
public function getSku()
954957
{
955958
return $this->getData(self::KEY_SKU);
956959
}
957960

958961
/**
959-
* {@inheritdoc}
962+
* @inheritdoc
960963
*/
961964
public function setSku($sku)
962965
{
963966
return $this->setData(self::KEY_SKU, $sku);
964967
}
965968

966969
/**
967-
* {@inheritdoc}
970+
* @inheritdoc
968971
*/
969972
public function getQty()
970973
{
971974
return $this->getData(self::KEY_QTY);
972975
}
973976

974977
/**
975-
* {@inheritdoc}
978+
* @inheritdoc
976979
*/
977980
public function getName()
978981
{
979982
return $this->getData(self::KEY_NAME);
980983
}
981984

982985
/**
983-
* {@inheritdoc}
986+
* @inheritdoc
984987
*/
985988
public function setName($name)
986989
{
987990
return $this->setData(self::KEY_NAME, $name);
988991
}
989992

990993
/**
991-
* {@inheritdoc}
994+
* @inheritdoc
992995
*/
993996
public function getPrice()
994997
{
995998
return $this->getData(self::KEY_PRICE);
996999
}
9971000

9981001
/**
999-
* {@inheritdoc}
1002+
* @inheritdoc
10001003
*/
10011004
public function setPrice($price)
10021005
{
10031006
return $this->setData(self::KEY_PRICE, $price);
10041007
}
10051008

10061009
/**
1007-
* {@inheritdoc}
1010+
* @inheritdoc
10081011
*/
10091012
public function setProductType($productType)
10101013
{
10111014
return $this->setData(self::KEY_PRODUCT_TYPE, $productType);
10121015
}
10131016

10141017
/**
1015-
* {@inheritdoc}
1018+
* @inheritdoc
10161019
*/
10171020
public function getQuoteId()
10181021
{
10191022
return $this->getData(self::KEY_QUOTE_ID);
10201023
}
10211024

10221025
/**
1023-
* {@inheritdoc}
1026+
* @inheritdoc
10241027
*/
10251028
public function setQuoteId($quoteId)
10261029
{
@@ -1051,7 +1054,7 @@ public function setProductOption(\Magento\Quote\Api\Data\ProductOptionInterface
10511054
//@codeCoverageIgnoreEnd
10521055

10531056
/**
1054-
* {@inheritdoc}
1057+
* @inheritdoc
10551058
*
10561059
* @return \Magento\Quote\Api\Data\CartItemExtensionInterface|null
10571060
*/
@@ -1061,7 +1064,7 @@ public function getExtensionAttributes()
10611064
}
10621065

10631066
/**
1064-
* {@inheritdoc}
1067+
* @inheritdoc
10651068
*
10661069
* @param \Magento\Quote\Api\Data\CartItemExtensionInterface $extensionAttributes
10671070
* @return $this

app/code/Magento/Quote/Test/Unit/Model/Quote/ItemTest.php

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -135,27 +135,24 @@ protected function setUp()
135135
public function testGetAddress()
136136
{
137137
$quote = $this->getMockBuilder(\Magento\Quote\Model\Quote::class)
138-
->setMethods(['getShippingAddress', 'getBillingAddress', 'getStoreId', '__wakeup'])
138+
->setMethods(['getShippingAddress', 'getBillingAddress', 'getStoreId', '__wakeup', 'isVirtual'])
139139
->disableOriginalConstructor()
140140
->getMock();
141141
$quote->expects($this->once())
142142
->method('getShippingAddress')
143-
->will($this->returnValue('shipping'));
143+
->willReturn('shipping');
144144
$quote->expects($this->once())
145145
->method('getBillingAddress')
146-
->will($this->returnValue('billing'));
146+
->willReturn('billing');
147147
$quote->expects($this->any())
148148
->method('getStoreId')
149-
->will($this->returnValue(1));
149+
->willReturn(1);
150+
$quote->expects($this->exactly(2))
151+
->method('isVirtual')
152+
->willReturnOnConsecutiveCalls(false, true);
150153

151154
$this->model->setQuote($quote);
152-
153-
$quote->setItemsQty(2);
154-
$quote->setVirtualItemsQty(1);
155155
$this->assertEquals('shipping', $this->model->getAddress(), 'Wrong shipping address');
156-
157-
$quote->setItemsQty(2);
158-
$quote->setVirtualItemsQty(2);
159156
$this->assertEquals('billing', $this->model->getAddress(), 'Wrong billing address');
160157
}
161158

@@ -855,18 +852,20 @@ public function testSetOptionsWithNull()
855852
private function createOptionMock($optionCode, $optionData = [])
856853
{
857854
$optionMock = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item\Option::class)
858-
->setMethods([
859-
'setData',
860-
'setItem',
861-
'getItem',
862-
'getCode',
863-
'__wakeup',
864-
'isDeleted',
865-
'delete',
866-
'getValue',
867-
'getProduct',
868-
'save'
869-
])
855+
->setMethods(
856+
[
857+
'setData',
858+
'setItem',
859+
'getItem',
860+
'getCode',
861+
'__wakeup',
862+
'isDeleted',
863+
'delete',
864+
'getValue',
865+
'getProduct',
866+
'save'
867+
]
868+
)
870869
->disableOriginalConstructor()
871870
->getMock();
872871
$optionMock->expects($this->any())

app/code/Magento/Sales/Model/Order/Address.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,5 +730,16 @@ public function setExtensionAttributes(\Magento\Sales\Api\Data\OrderAddressExten
730730
return $this->_setExtensionAttributes($extensionAttributes);
731731
}
732732

733+
/**
734+
* @inheritdoc
735+
*/
736+
public function beforeSave()
737+
{
738+
if ($this->getEmail() === null) {
739+
$this->setEmail($this->getOrder()->getCustomerEmail());
740+
}
741+
return parent::beforeSave();
742+
}
743+
733744
//@codeCoverageIgnoreEnd
734745
}

0 commit comments

Comments
 (0)