Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
3 changed files
with
91 additions
and
2 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
...ional/tests/app/Magento/Checkout/Test/Constraint/AssertShippingMethodsSuccessEstimate.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<?php | ||
/** | ||
* Copyright © 2013-2017 Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
namespace Magento\Checkout\Test\Constraint; | ||
|
||
use Magento\Checkout\Test\Page\CheckoutOnepage; | ||
use Magento\Checkout\Test\TestStep\FillShippingAddressStep; | ||
use Magento\Mtf\Client\BrowserInterface; | ||
use Magento\Mtf\Constraint\AbstractConstraint; | ||
use Magento\Mtf\Fixture\FixtureFactory; | ||
use Magento\Mtf\TestStep\TestStepFactory; | ||
|
||
/** | ||
* Asserts that shipping methods are present on checkout page. | ||
*/ | ||
class AssertShippingMethodsSuccessEstimate extends AbstractConstraint | ||
{ | ||
/** | ||
* Asserts that shipping methods are present on checkout page. | ||
* | ||
* @param CheckoutOnepage $checkoutOnepage | ||
* @param BrowserInterface $browser | ||
* @return void | ||
*/ | ||
public function processAssert( | ||
CheckoutOnepage $checkoutOnepage, | ||
BrowserInterface $browser | ||
) { | ||
if ($this->shouldOpenCheckout($checkoutOnepage, $browser)) { | ||
$checkoutOnepage->open(); | ||
} | ||
|
||
\PHPUnit_Framework_Assert::assertFalse( | ||
$checkoutOnepage->getShippingMethodBlock()->isErrorPresent(), | ||
'Shipping estimation error is present.' | ||
); | ||
|
||
$methods = $checkoutOnepage->getShippingMethodBlock()->getAvailableMethods(); | ||
\PHPUnit_Framework_Assert::assertNotEmpty( | ||
$methods, | ||
'No shipping methods are present.' | ||
); | ||
} | ||
|
||
/** | ||
* Should open checkout page or not. | ||
* | ||
* @param CheckoutOnepage $checkoutOnepage | ||
* @param BrowserInterface $browser | ||
* @return bool | ||
*/ | ||
private function shouldOpenCheckout(CheckoutOnepage $checkoutOnepage, BrowserInterface $browser) | ||
{ | ||
$result = true; | ||
|
||
foreach (['checkout/', $checkoutOnepage::MCA] as $path) { | ||
$length = strlen($path); | ||
if (substr($browser->getUrl(), -$length) === $path) { | ||
$result = false; | ||
break; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Returns a string representation of the object. | ||
* | ||
* @return string | ||
*/ | ||
public function toString() | ||
{ | ||
return "Shipping methods are present on checkout page."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters