Skip to content

Commit 0f27eba

Browse files
committed
MAGETWO-60958: [Backport] Incorrect province code sent on Checkout to UPS #6564 - for 2.1
- MAGETWO-70727: [GitHub] Shipping method randomly dissapear when page refreshed for 2.1 #7497
1 parent 3758d4c commit 0f27eba

File tree

3 files changed

+82
-83
lines changed

3 files changed

+82
-83
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © 2013-2017 Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Checkout\Test\Constraint;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Mtf\Client\BrowserInterface;
11+
use Magento\Mtf\Constraint\AbstractConstraint;
12+
13+
/**
14+
* Asserts shipping methods estimation on checkout page.
15+
*/
16+
abstract class AssertShippingMethodsEstimate extends AbstractConstraint
17+
{
18+
/**
19+
* Asserts shipping methods estimation on checkout page.
20+
*
21+
* @param CheckoutOnepage $checkoutOnepage
22+
* @param BrowserInterface $browser
23+
* @return void
24+
*/
25+
protected function assert(
26+
CheckoutOnepage $checkoutOnepage,
27+
BrowserInterface $browser
28+
) {
29+
if ($this->shouldOpenCheckout($checkoutOnepage, $browser)) {
30+
$checkoutOnepage->open();
31+
}
32+
33+
\PHPUnit_Framework_Assert::assertFalse(
34+
$checkoutOnepage->getShippingMethodBlock()->isErrorPresent(),
35+
'Shipping estimation error is present.'
36+
);
37+
38+
$methods = $checkoutOnepage->getShippingMethodBlock()->getAvailableMethods();
39+
\PHPUnit_Framework_Assert::assertNotEmpty(
40+
$methods,
41+
'No shipping methods are present.'
42+
);
43+
}
44+
45+
/**
46+
* Should open checkout page or not.
47+
*
48+
* @param CheckoutOnepage $checkoutOnepage
49+
* @param BrowserInterface $browser
50+
* @return bool
51+
*/
52+
private function shouldOpenCheckout(CheckoutOnepage $checkoutOnepage, BrowserInterface $browser)
53+
{
54+
$result = true;
55+
56+
foreach (['checkout/', $checkoutOnepage::MCA] as $path) {
57+
$length = strlen($path);
58+
if (substr($browser->getUrl(), -$length) === $path) {
59+
$result = false;
60+
break;
61+
}
62+
}
63+
64+
return $result;
65+
}
66+
67+
/**
68+
* Returns a string representation of the object.
69+
*
70+
* @return string
71+
*/
72+
public function toString()
73+
{
74+
return "Shipping methods estimation on checkout page.";
75+
}
76+
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertShippingMethodsSuccessEstimate.php

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@
77
namespace Magento\Checkout\Test\Constraint;
88

99
use Magento\Checkout\Test\Page\CheckoutOnepage;
10-
use Magento\Checkout\Test\TestStep\FillShippingAddressStep;
1110
use Magento\Mtf\Client\BrowserInterface;
12-
use Magento\Mtf\Constraint\AbstractConstraint;
13-
use Magento\Mtf\Fixture\FixtureFactory;
14-
use Magento\Mtf\TestStep\TestStepFactory;
1511

1612
/**
1713
* Asserts that shipping methods are present on checkout page.
1814
*/
19-
class AssertShippingMethodsSuccessEstimate extends AbstractConstraint
15+
class AssertShippingMethodsSuccessEstimate extends AssertShippingMethodsEstimate
2016
{
2117
/**
2218
* Asserts that shipping methods are present on checkout page.
@@ -25,46 +21,9 @@ class AssertShippingMethodsSuccessEstimate extends AbstractConstraint
2521
* @param BrowserInterface $browser
2622
* @return void
2723
*/
28-
public function processAssert(
29-
CheckoutOnepage $checkoutOnepage,
30-
BrowserInterface $browser
31-
) {
32-
if ($this->shouldOpenCheckout($checkoutOnepage, $browser)) {
33-
$checkoutOnepage->open();
34-
}
35-
36-
\PHPUnit_Framework_Assert::assertFalse(
37-
$checkoutOnepage->getShippingMethodBlock()->isErrorPresent(),
38-
'Shipping estimation error is present.'
39-
);
40-
41-
$methods = $checkoutOnepage->getShippingMethodBlock()->getAvailableMethods();
42-
\PHPUnit_Framework_Assert::assertNotEmpty(
43-
$methods,
44-
'No shipping methods are present.'
45-
);
46-
}
47-
48-
/**
49-
* Should open checkout page or not.
50-
*
51-
* @param CheckoutOnepage $checkoutOnepage
52-
* @param BrowserInterface $browser
53-
* @return bool
54-
*/
55-
private function shouldOpenCheckout(CheckoutOnepage $checkoutOnepage, BrowserInterface $browser)
24+
public function processAssert(CheckoutOnepage $checkoutOnepage, BrowserInterface $browser)
5625
{
57-
$result = true;
58-
59-
foreach (['checkout/', $checkoutOnepage::MCA] as $path) {
60-
$length = strlen($path);
61-
if (substr($browser->getUrl(), -$length) === $path) {
62-
$result = false;
63-
break;
64-
}
65-
}
66-
67-
return $result;
26+
$this->assert($checkoutOnepage, $browser);
6827
}
6928

7029
/**

dev/tests/functional/tests/app/Magento/Checkout/Test/Constraint/AssertShippingMethodsSuccessEstimateAfterAddressEdit.php

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,13 @@
99
use Magento\Checkout\Test\Page\CheckoutOnepage;
1010
use Magento\Checkout\Test\TestStep\FillShippingAddressStep;
1111
use Magento\Mtf\Client\BrowserInterface;
12-
use Magento\Mtf\Constraint\AbstractConstraint;
1312
use Magento\Mtf\Fixture\FixtureFactory;
1413
use Magento\Mtf\TestStep\TestStepFactory;
1514

1615
/**
1716
* Asserts that shipping methods are present on checkout page after address modification.
1817
*/
19-
class AssertShippingMethodsSuccessEstimateAfterAddressEdit extends AbstractConstraint
18+
class AssertShippingMethodsSuccessEstimateAfterAddressEdit extends AssertShippingMethodsEstimate
2019
{
2120
/**
2221
* Asserts that shipping methods are present on checkout page after address modification.
@@ -35,53 +34,18 @@ public function processAssert(
3534
BrowserInterface $browser,
3635
array $editAddressData = []
3736
) {
38-
if ($this->shouldOpenCheckout($checkoutOnepage, $browser)) {
39-
$checkoutOnepage->open();
40-
}
41-
4237
if (!empty ($editAddressData)) {
4338
$address = $fixtureFactory->createByCode('address', ['data' => $editAddressData]);
4439
$testStepFactory->create(
4540
FillShippingAddressStep::class,
4641
[
4742
'checkoutOnepage' => $checkoutOnepage,
48-
'shippingAddress' => $address
43+
'shippingAddress' => $address,
4944
]
5045
)->run();
5146

52-
\PHPUnit_Framework_Assert::assertFalse(
53-
$checkoutOnepage->getShippingMethodBlock()->isErrorPresent(),
54-
'Shipping estimation error is present.'
55-
);
56-
57-
$methods = $checkoutOnepage->getShippingMethodBlock()->getAvailableMethods();
58-
\PHPUnit_Framework_Assert::assertNotEmpty(
59-
$methods,
60-
'No shipping methods are present.'
61-
);
62-
}
63-
}
64-
65-
/**
66-
* Should open checkout page or not.
67-
*
68-
* @param CheckoutOnepage $checkoutOnepage
69-
* @param BrowserInterface $browser
70-
* @return bool
71-
*/
72-
private function shouldOpenCheckout(CheckoutOnepage $checkoutOnepage, BrowserInterface $browser)
73-
{
74-
$result = true;
75-
76-
foreach (['checkout/', $checkoutOnepage::MCA] as $path) {
77-
$length = strlen($path);
78-
if (substr($browser->getUrl(), -$length) === $path) {
79-
$result = false;
80-
break;
81-
}
47+
$this->assert($checkoutOnepage, $browser);
8248
}
83-
84-
return $result;
8549
}
8650

8751
/**

0 commit comments

Comments
 (0)