Skip to content

Commit b3bd86b

Browse files
authored
Merge pull request magento#4952 from magento-mpi/MPI-PR-2019-10-31
MPI-PR-2019-10-31
2 parents d5104d5 + 2aaa6c2 commit b3bd86b

24 files changed

+335
-187
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Uploader.php

+20-11
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ class Uploader extends \Magento\MediaStorage\Model\File\Uploader
3636
*/
3737
protected $_tmpDir = '';
3838

39-
/**
40-
* Download directory for url-based resources.
41-
*
42-
* @var string
43-
*/
44-
private $downloadDir;
45-
4639
/**
4740
* Destination directory.
4841
*
@@ -151,7 +144,6 @@ public function __construct(
151144
$this->_setUploadFile($filePath);
152145
}
153146
$this->random = $random ?: ObjectManager::getInstance()->get(\Magento\Framework\Math\Random::class);
154-
$this->downloadDir = DirectoryList::getDefaultConfig()[DirectoryList::TMP][DirectoryList::PATH];
155147
}
156148

157149
/**
@@ -187,8 +179,7 @@ public function move($fileName, $renameFileOff = false)
187179
$driver = ($matches[0] === $this->httpScheme) ? DriverPool::HTTP : DriverPool::HTTPS;
188180
$tmpFilePath = $this->downloadFileFromUrl($url, $driver);
189181
} else {
190-
$tmpDir = $this->getTmpDir() ? ($this->getTmpDir() . '/') : '';
191-
$tmpFilePath = $this->_directory->getRelativePath($tmpDir . $fileName);
182+
$tmpFilePath = $this->_directory->getRelativePath($this->getTempFilePath($fileName));
192183
}
193184

194185
$this->_setUploadFile($tmpFilePath);
@@ -225,8 +216,13 @@ private function downloadFileFromUrl($url, $driver)
225216
$tmpFileName = str_replace(".$fileExtension", '', $fileName);
226217
$tmpFileName .= '_' . $this->random->getRandomString(16);
227218
$tmpFileName .= $fileExtension ? ".$fileExtension" : '';
228-
$tmpFilePath = $this->_directory->getRelativePath($this->downloadDir . '/' . $tmpFileName);
219+
$tmpFilePath = $this->_directory->getRelativePath($this->getTempFilePath($tmpFileName));
229220

221+
if (!$this->_directory->isWritable($this->getTmpDir())) {
222+
throw new \Magento\Framework\Exception\LocalizedException(
223+
__('Import images directory must be writable in order to process remote images.')
224+
);
225+
}
230226
$this->_directory->writeFile(
231227
$tmpFilePath,
232228
$this->_readFactory->create($url, $driver)->readAll()
@@ -402,6 +398,19 @@ protected function _moveFile($tmpPath, $destPath)
402398
}
403399
}
404400

401+
/**
402+
* Append temp path to filename
403+
*
404+
* @param string $filename
405+
* @return string
406+
*/
407+
private function getTempFilePath(string $filename): string
408+
{
409+
return $this->getTmpDir()
410+
? rtrim($this->getTmpDir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . $filename
411+
: $filename;
412+
}
413+
405414
/**
406415
* @inheritdoc
407416
*/

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/UploaderTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName, $che
128128
{
129129
$tmpDir = 'var/tmp';
130130
$destDir = 'var/dest/dir';
131+
$this->uploader->method('getTmpDir')->willReturn($tmpDir);
131132

132133
// Expected invocation to validate file extension
133134
$this->uploader->expects($this->exactly($checkAllowedExtension))->method('checkAllowedExtension')
@@ -159,9 +160,11 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName, $che
159160
$this->directoryMock->expects($this->any())->method('writeFile')
160161
->will($this->returnValue($expectedFileName));
161162

162-
// Expected invocations to move the temp file to the destination directory
163-
$this->directoryMock->expects($this->once())->method('isWritable')
164-
->with($destDir)
163+
// Expected invocations save the downloaded file to temp file
164+
// and move the temp file to the destination directory
165+
$this->directoryMock->expects($this->exactly(2))
166+
->method('isWritable')
167+
->withConsecutive([$destDir], [$tmpDir])
165168
->willReturn(true);
166169
$this->directoryMock->expects($this->once())->method('getAbsolutePath')
167170
->with($destDir)
@@ -172,9 +175,6 @@ public function testMoveFileUrl($fileUrl, $expectedHost, $expectedFileName, $che
172175
->with($destDir . '/' . $expectedFileName)
173176
->willReturn(['name' => $expectedFileName, 'path' => 'absPath']);
174177

175-
// Do not use configured temp directory
176-
$this->uploader->expects($this->never())->method('getTmpDir');
177-
178178
$this->uploader->setDestDir($destDir);
179179
$result = $this->uploader->move($fileUrl);
180180

app/code/Magento/Checkout/view/frontend/web/js/view/form/element/email.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,19 @@ define([
145145
var loginFormSelector = 'form[data-role=email-with-possible-login]',
146146
usernameSelector = loginFormSelector + ' input[name=username]',
147147
loginForm = $(loginFormSelector),
148-
validator;
148+
validator,
149+
valid;
149150

150151
loginForm.validation();
151152

152153
if (focused === false && !!this.email()) {
153-
return !!$(usernameSelector).valid();
154+
valid = !!$(usernameSelector).valid();
155+
156+
if (valid) {
157+
$(usernameSelector).removeAttr('aria-invalid aria-describedby');
158+
}
159+
160+
return valid;
154161
}
155162

156163
validator = loginForm.validate();

app/code/Magento/Multishipping/Test/Mftf/ActionGroup/AdminSalesOrderActionGroup.xml

+13-14
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,21 @@
88
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
99
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1010
<actionGroup name="AdminSalesOrderActionGroup">
11-
<waitForPageLoad stepKey="waitForAdminSalesPageToLoad"/>
12-
<click selector="{{AdminOrdersGridSection.firstRow}}" stepKey="clickOrderRowLink"/>
13-
<waitForPageLoad stepKey="waitForOrderPageToLoad"/>
14-
<waitForPageLoad stepKey="waitForCheckTotalActionGroup"/>
1511
<scrollTo selector="{{AdminOrderTotalSection.subTotal}}" stepKey="scrollToOrderTotalSection"/>
16-
<grabTextFrom selector="{{AdminOrderTotalSection.subTotal}}" stepKey="grabvalueForSubtotal"/>
17-
<grabTextFrom selector="{{AdminOrderTotalSection.shippingAndHandling}}" stepKey="grabvalueForShippingHandling"/>
18-
<grabTextFrom selector="{{AdminOrderTotalSection.grandTotal}}" stepKey="grabvalueForGrandTotal"/>
19-
<executeJS stepKey="sum_TotalValue" function="
20-
var subtotal = '{$grabvalueForSubtotal}'.substr(1);
21-
var handling = '{$grabvalueForShippingHandling}'.substr(1);
22-
var subtotal_handling = (parseFloat(subtotal) + parseFloat(handling)).toFixed(2);
23-
return ('$' + subtotal_handling);"/>
12+
<grabTextFrom selector="{{AdminOrderTotalSection.subTotal}}" stepKey="grabValueForSubtotal"/>
13+
<grabTextFrom selector="{{AdminOrderTotalSection.shippingAndHandling}}" stepKey="grabValueForShippingHandling"/>
14+
<grabTextFrom selector="{{AdminOrderTotalSection.grandTotal}}" stepKey="grabValueForGrandTotal"/>
15+
<executeJS function="
16+
var grandTotal = '{$grabValueForGrandTotal}'.substr(1);
17+
return (grandTotal);" stepKey="grandTotalValue"/>
18+
<executeJS function="
19+
var subtotal = '{$grabValueForSubtotal}'.substr(1);
20+
var handling = '{$grabValueForShippingHandling}'.substr(1);
21+
var subtotalHandling = (parseFloat(subtotal) + parseFloat(handling)).toFixed(2);
22+
return (subtotalHandling);" stepKey="sumTotalValue"/>
2423
<assertEquals stepKey="assertSubTotalPrice">
25-
<expectedResult type="string">$sum_TotalValue</expectedResult>
26-
<actualResult type="string">$grabvalueForGrandTotal</actualResult>
24+
<expectedResult type="variable">$sumTotalValue</expectedResult>
25+
<actualResult type="variable">$grandTotalValue</actualResult>
2726
</assertEquals>
2827
</actionGroup>
2928
</actionGroups>
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+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<actionGroup name="AssertStorefrontSalesOrderMatchesGrandTotalActionGroup">
12+
<arguments>
13+
<argument name="dataHref" type="string"/>
14+
</arguments>
15+
<!--Click on View Order Link-->
16+
<click selector="{{StorefrontSalesOrderSection.viewOrderLink(dataHref)}}" stepKey="viewOrderAction"/>
17+
<waitForPageLoad stepKey="waitForViewOrderPageToLoad"/>
18+
<grabTextFrom selector="{{StorefrontSalesOrderSection.salesOrderPrice('subtotal')}}" stepKey="grabValueForSubtotal"/>
19+
<grabTextFrom selector="{{StorefrontSalesOrderSection.salesOrderPrice('shipping')}}" stepKey="grabValueForShippingHandling"/>
20+
<grabTextFrom selector="{{StorefrontSalesOrderSection.salesOrderPrice('grand_total')}}" stepKey="grabValueForGrandTotal"/>
21+
<executeJS function="
22+
var grandTotal = '{$grabValueForGrandTotal}'.substr(1);
23+
return (grandTotal);" stepKey="grandTotalValue"/>
24+
<executeJS function="
25+
var subtotal = '{$grabValueForSubtotal}'.substr(1);
26+
var handling = '{$grabValueForShippingHandling}'.substr(1);
27+
var subtotalHandling = (parseFloat(subtotal) + parseFloat(handling)).toFixed(2);
28+
return (subtotalHandling);" stepKey="sumTotalValue"/>
29+
<assertEquals stepKey="assertSubTotalPrice">
30+
<expectedResult type="variable">$sumTotalValue</expectedResult>
31+
<actualResult type="variable">$grandTotalValue</actualResult>
32+
</assertEquals>
33+
</actionGroup>
34+
</actionGroups>

app/code/Magento/Multishipping/Test/Mftf/ActionGroup/CheckingWithMinicartActionGroup.xml

+2-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1111
<actionGroup name="CheckingWithMinicartActionGroup">
12-
<waitForPageLoad stepKey="waitForCheckoutCartPageLoad"/>
13-
<click stepKey="clickOnCollapsibleDiv" selector="{{MinicartSection.clickOnCollapsibleDiv}}"/>
14-
<click stepKey="clickOnShippingMethodRadioButton" selector="{{MinicartSection.shippingMethodRadioButton}}"/>
12+
<click selector="{{MinicartSection.clickOnCollapsibleDiv}}" stepKey="clickOnCollapsibleDiv"/>
13+
<click selector="{{MinicartSection.shippingMethodRadioButton}}" stepKey="clickOnShippingMethodRadioButton"/>
1514
<waitForPageLoad stepKey="waitForShippingPriceToBeChanged"/>
1615
<grabTextFrom selector="{{MinicartSection.shippingMethodRadioText}}" stepKey="shippingMethodRadioText"/>
1716
<grabTextFrom selector="{{MinicartSection.shippingMethodSubtotalPrice}}" stepKey="shippingMethodSubtotalPrice"/>

app/code/Magento/Multishipping/Test/Mftf/ActionGroup/CheckingWithMultipleAddressesActionGroup.xml

+16-12
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,23 @@
99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1111
<actionGroup name="CheckingWithSingleAddressActionGroup">
12-
<click stepKey="clickOnCheckoutWithMultipleAddresses" selector="{{SingleShippingSection.checkoutWithMultipleAddresses}}"/>
12+
<click selector="{{SingleShippingSection.checkoutWithMultipleAddresses}}" stepKey="clickOnCheckoutWithMultipleAddresses"/>
1313
<waitForPageLoad stepKey="waitForMultipleAddressPageLoad"/>
14-
<click stepKey="goToShippingInformation" selector="{{SingleShippingSection.goToShippingInfo}}"/>
14+
<click selector="{{SingleShippingSection.goToShippingInfo}}" stepKey="goToShippingInformation"/>
1515
<waitForPageLoad stepKey="waitForShippingPageLoad"/>
1616
</actionGroup>
1717
<actionGroup name="CheckingWithMultipleAddressesActionGroup" extends="CheckingWithSingleAddressActionGroup">
18-
<grabTextFrom stepKey="firstShippingAddressValue" selector="{{MultishippingSection.firstShippingAddressValue}}" after="waitForMultipleAddressPageLoad" />
19-
<selectOption selector="{{MultishippingSection.firstShippingAddressOption}}" userInput="{$firstShippingAddressValue}" stepKey="selectFirstShippingMethod" after="firstShippingAddressValue" />
20-
<waitForPageLoad stepKey="waitForSecondShippingAddresses" after="selectFirstShippingMethod" />
21-
<grabTextFrom stepKey="secondShippingAddressValue" selector="{{MultishippingSection.secondShippingAddressValue}}" after="waitForSecondShippingAddresses" />
22-
<selectOption selector="{{MultishippingSection.secondShippingAddressOption}}" userInput="{$secondShippingAddressValue}" stepKey="selectSecondShippingMethod" after="secondShippingAddressValue" />
23-
<click stepKey="clickOnUpdateAddress" selector="{{SingleShippingSection.updateAddress}}" after="selectSecondShippingMethod" />
24-
<waitForPageLoad stepKey="waitForShippingInformation" after="clickOnUpdateAddress" />
18+
<arguments>
19+
<argument name="addressOption1" type="string" defaultValue="1"/>
20+
<argument name="addressOption2" type="string" defaultValue="2"/>
21+
</arguments>
22+
<grabTextFrom selector="{{MultishippingSection.shippingAddressOptions(addressOption1,addressOption1)}}" after="waitForMultipleAddressPageLoad" stepKey="firstShippingAddressValue"/>
23+
<selectOption selector="{{MultishippingSection.shippingAddressSelector(addressOption1)}}" userInput="{$firstShippingAddressValue}" after="firstShippingAddressValue" stepKey="selectFirstShippingMethod"/>
24+
<waitForPageLoad after="selectFirstShippingMethod" stepKey="waitForSecondShippingAddresses"/>
25+
<grabTextFrom selector="{{MultishippingSection.shippingAddressOptions(addressOption2,addressOption2)}}" after="waitForSecondShippingAddresses" stepKey="secondShippingAddressValue"/>
26+
<selectOption selector="{{MultishippingSection.shippingAddressSelector(addressOption2)}}" userInput="{$secondShippingAddressValue}" after="secondShippingAddressValue" stepKey="selectSecondShippingMethod"/>
27+
<click selector="{{SingleShippingSection.updateAddress}}" after="selectSecondShippingMethod" stepKey="clickOnUpdateAddress"/>
28+
<waitForPageLoad after="clickOnUpdateAddress" stepKey="waitForShippingInformation"/>
2529
</actionGroup>
2630
<actionGroup name="StorefrontCheckoutWithMultipleAddressesActionGroup">
2731
<click selector="{{SingleShippingSection.checkoutWithMultipleAddresses}}" stepKey="clickOnCheckoutWithMultipleAddresses"/>
@@ -35,9 +39,9 @@
3539
<selectOption selector="{{MultishippingSection.selectShippingAddress(sequenceNumber)}}" userInput="{{option}}" stepKey="selectShippingAddress"/>
3640
</actionGroup>
3741
<actionGroup name="StorefrontSaveAddressActionGroup">
38-
<click stepKey="clickOnUpdateAddress" selector="{{SingleShippingSection.updateAddress}}"/>
39-
<waitForPageLoad stepKey="waitForShippingInformationAfterUpdated" time="90"/>
40-
<click stepKey="goToShippingInformation" selector="{{SingleShippingSection.goToShippingInfo}}"/>
42+
<click selector="{{SingleShippingSection.updateAddress}}" stepKey="clickOnUpdateAddress"/>
43+
<waitForPageLoad time="90" stepKey="waitForShippingInformationAfterUpdated"/>
44+
<click selector="{{SingleShippingSection.goToShippingInfo}}" stepKey="goToShippingInformation"/>
4145
<waitForPageLoad stepKey="waitForShippingPageLoad"/>
4246
</actionGroup>
4347
</actionGroups>

app/code/Magento/Multishipping/Test/Mftf/ActionGroup/PlaceOrderActionGroup.xml

+12-5
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@
99
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
1010
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
1111
<actionGroup name="PlaceOrderActionGroup">
12-
<waitForPageLoad stepKey="waitForPlaceOrderPageLoad"/>
13-
<!-- place order and check the order number-->
14-
<click stepKey="checkoutMultishipmentPlaceOrder" selector="{{SingleShippingSection.placeOrder}}" />
12+
<click selector="{{SingleShippingSection.placeOrder}}" stepKey="checkoutMultiShipmentPlaceOrder"/>
1513
<waitForPageLoad stepKey="waitForSuccessfullyPlacedOrder"/>
1614
<see selector="{{CheckoutSuccessMainSection.successTitle}}" userInput="Thank you for your purchase!" stepKey="waitForLoadSuccessPage"/>
17-
1815
</actionGroup>
19-
</actionGroups>
16+
<actionGroup name="StorefrontPlaceOrderForMultipleAddressesActionGroup" extends="PlaceOrderActionGroup">
17+
<arguments>
18+
<argument name="firstOrderPosition" type="string" defaultValue="1"/>
19+
<argument name="secondOrderPosition" type="string" defaultValue="2"/>
20+
</arguments>
21+
<grabTextFrom selector="{{StorefrontSalesOrderSection.orderLinkByPosition(firstOrderPosition)}}" after="waitForLoadSuccessPage" stepKey="getFirstOrderId"/>
22+
<grabAttributeFrom selector="{{StorefrontSalesOrderSection.orderLinkByPosition(firstOrderPosition)}}" userInput="href" after="getFirstOrderId" stepKey="dataHrefForFirstOrder"/>
23+
<grabTextFrom selector="{{StorefrontSalesOrderSection.orderLinkByPosition(secondOrderPosition)}}" after="dataHrefForFirstOrder" stepKey="getSecondOrderId"/>
24+
<grabAttributeFrom selector="{{StorefrontSalesOrderSection.orderLinkByPosition(secondOrderPosition)}}" userInput="href" after="getSecondOrderId" stepKey="dataHrefForSecondOrder"/>
25+
</actionGroup>
26+
</actionGroups>

0 commit comments

Comments
 (0)