Skip to content

Commit 70016ef

Browse files
author
Ievgen Shakhsuvarov
committed
MAGETWO-39534: Fix functional test for checkout flow
1 parent 0d9a6a7 commit 70016ef

File tree

9 files changed

+32
-104
lines changed

9 files changed

+32
-104
lines changed

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Login.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
use Magento\Mtf\Fixture\FixtureInterface;
1111

1212
/**
13-
* Class Login
14-
* One page checkout status login block
13+
* One page checkout status login block.
1514
*/
1615
class Login extends Form
1716
{
@@ -51,7 +50,7 @@ class Login extends Form
5150
protected $loadingMask = '.loading-mask';
5251

5352
/**
54-
* Select how to perform checkout whether guest or registered customer
53+
* Select how to perform checkout whether guest or registered customer.
5554
*
5655
* @param FixtureInterface $fixture
5756
* @return void
@@ -68,7 +67,7 @@ public function checkoutMethod(FixtureInterface $fixture)
6867
}
6968

7069
/**
71-
* Perform guest checkout
70+
* Perform guest checkout.
7271
*
7372
* @return void
7473
*/
@@ -79,27 +78,20 @@ public function guestCheckout()
7978
}
8079

8180
/**
82-
* Login customer during checkout
81+
* Login customer during checkout.
8382
*
8483
* @param FixtureInterface $customer
8584
* @return void
8685
*/
8786
public function loginCustomer(FixtureInterface $customer)
8887
{
89-
$data = $customer->getData();
90-
$mapping = $this->dataMapping($data);
91-
$login['email'] = $mapping['email'];
92-
$this->_fill($login);
93-
sleep(3);
94-
$this->waitForElementNotVisible('._block-content-loading');
95-
$password['password'] = $mapping['password'];
96-
$this->_fill($password);
88+
$this->fill($customer);
9789
$this->_rootElement->find($this->login)->click();
9890
$this->waitForElementNotVisible($this->loadingMask);
9991
}
10092

10193
/**
102-
* Click continue on checkout method block
94+
* Click continue on checkout method block.
10395
*
10496
* @return void
10597
*/

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,21 @@
77
namespace Magento\Checkout\Test\Block\Onepage\Payment;
88

99
use Magento\Mtf\Block\Block;
10-
use Magento\Payment\Test\Fixture\CreditCard;
1110

1211
/**
1312
* Checkout payment method block.
1413
*/
1514
class Method extends Block
1615
{
1716
/**
18-
* Wait element
17+
* Wait element.
1918
*
2019
* @var string
2120
*/
2221
protected $waitElement = '.loading-mask';
2322

2423
/**
25-
* Purchase order number selector
26-
*
27-
* @var string
28-
*/
29-
protected $purchaseOrderNumber = '#po_number';
30-
31-
/**
32-
* Continue checkout button.
24+
* Place order button selector.
3325
*
3426
* @var string
3527
*/
@@ -56,14 +48,14 @@ public function clickPlaceOrder()
5648
/**
5749
* Get "Billing Address" block.
5850
*
59-
* @return \Magento\Checkout\Test\Block\Onepage\Payment\Methods\Billing
51+
* @return \Magento\Checkout\Test\Block\Onepage\Payment\Method\Billing
6052
*/
6153
public function getBillingBlock()
6254
{
6355
$element = $this->_rootElement->find($this->billingAddressSelector);
6456

6557
return $this->blockFactory->create(
66-
'\Magento\Checkout\Test\Block\Onepage\Payment\Methods\Billing',
58+
'\Magento\Checkout\Test\Block\Onepage\Payment\Method\Billing',
6759
['element' => $element]
6860
);
6961
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Methods/Billing.php renamed to dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Payment/Method/Billing.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
namespace Magento\Checkout\Test\Block\Onepage\Payment\Methods;
7+
namespace Magento\Checkout\Test\Block\Onepage\Payment\Method;
88

99
use Magento\Customer\Test\Fixture\Address;
10-
use Magento\Customer\Test\Fixture\Customer;
1110
use Magento\Mtf\Block\Form;
1211
use Magento\Mtf\Client\Locator;
1312

@@ -43,12 +42,10 @@ class Billing extends Form
4342
* @param Address $billingAddress
4443
* @return void
4544
*/
46-
public function fillBilling(Address $billingAddress = null)
45+
public function fillBilling(Address $billingAddress)
4746
{
48-
if ($billingAddress) {
49-
$this->fill($billingAddress);
50-
$this->clickUpdate();
51-
}
47+
$this->fill($billingAddress);
48+
$this->clickUpdate();
5249
$this->waitForElementNotVisible($this->waitElement);
5350
}
5451

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping.php

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,11 @@
77
namespace Magento\Checkout\Test\Block\Onepage;
88

99
use Magento\Mtf\Block\Form;
10-
use Magento\Mtf\Client\Locator;
11-
use Magento\Mtf\Client\Element\SimpleElement;
12-
use Magento\Checkout\Test\Fixture\Checkout;
1310

1411
/**
15-
* Class Shipping
16-
* One page checkout status shipping block
17-
*
12+
* Checkout shipping address block.
1813
*/
1914
class Shipping extends Form
2015
{
21-
/**
22-
* Continue checkout button
23-
*
24-
* @var string
25-
*/
26-
protected $continue = '#shipping-buttons-container button';
27-
28-
/**
29-
* Wait element
30-
*
31-
* @var string
32-
*/
33-
protected $waitElement = '.loading-mask';
34-
35-
/**
36-
* Fill shipping address
37-
*
38-
* @param $fixture
39-
* @return void
40-
*/
41-
public function fillShipping($fixture)
42-
{
43-
if ($fixture instanceof Checkout) {
44-
$fixture = $fixture->getShippingAddress();
45-
}
46-
if (!$fixture) {
47-
return;
48-
}
49-
$this->fill($fixture);
50-
}
16+
//
5117
}

dev/tests/functional/tests/app/Magento/Checkout/Test/Block/Onepage/Shipping/Method.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
use Magento\Mtf\Client\Locator;
1111

1212
/**
13-
* Class Method
1413
* One page checkout status shipping method block
15-
*
1614
*/
1715
class Method extends Block
1816
{
@@ -45,13 +43,14 @@ class Method extends Block
4543
protected $blockWaitElement = '._block-content-loading';
4644

4745
/**
48-
* Select shipping method
46+
* Select shipping method.
4947
*
5048
* @param array $method
5149
* @return void
5250
*/
5351
public function selectShippingMethod(array $method)
5452
{
53+
// Code under test uses JavaScript setTimeout at this point as well.
5554
sleep(3);
5655
$selector = sprintf($this->shippingMethod, $method['shipping_method'], $method['shipping_service']);
5756
$this->waitForElementNotVisible($this->blockWaitElement);

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function processAssert(CheckoutOnepage $checkoutOnepage, $billingCheckbox
3232
\PHPUnit_Framework_Assert::assertEquals(
3333
$billingCheckboxState,
3434
$actualResult,
35-
"\"Same as Shipping\" checkbox has wrong value"
35+
'"Same as Shipping" checkbox has wrong value'
3636
);
3737
}
3838

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillBillingInformationStep.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,24 @@
1212
use Magento\Checkout\Test\Constraint\AssertBillingAddressSameAsShippingCheckbox;
1313

1414
/**
15-
* Class FillBillingInformationStep
16-
* Fill billing information
15+
* Fill billing information.
1716
*/
1817
class FillBillingInformationStep implements TestStepInterface
1918
{
2019
/**
21-
* Onepage checkout page
20+
* Onepage checkout page.
2221
*
2322
* @var CheckoutOnepage
2423
*/
2524
protected $checkoutOnepage;
2625

2726
/**
28-
* Address fixture
27+
* Address fixture.
2928
*
3029
* @var Address
3130
*/
3231
protected $billingAddress;
3332

34-
/**
35-
* Checkout method
36-
*
37-
* @var string
38-
*/
39-
protected $checkoutMethod;
40-
4133
/**
4234
* "Same as Shipping" checkbox value assertion.
4335
*
@@ -55,36 +47,36 @@ class FillBillingInformationStep implements TestStepInterface
5547
/**
5648
* @constructor
5749
* @param CheckoutOnepage $checkoutOnepage
50+
* @param AssertBillingAddressSameAsShippingCheckbox $assertBillingAddressCheckbox
5851
* @param Address $billingAddress
59-
* @param AssertBillingAddressSameAsShippingCheckbox $assertBillingAddressCheckbox,
60-
* @param string $checkoutMethod
6152
* @param string $billingCheckboxState
6253
*/
6354
public function __construct(
6455
CheckoutOnepage $checkoutOnepage,
65-
$checkoutMethod,
6656
AssertBillingAddressSameAsShippingCheckbox $assertBillingAddressCheckbox,
6757
Address $billingAddress = null,
6858
$billingCheckboxState = null
6959
) {
7060
$this->checkoutOnepage = $checkoutOnepage;
7161
$this->billingAddress = $billingAddress;
72-
$this->checkoutMethod = $checkoutMethod;
7362
$this->assertBillingAddressCheckbox = $assertBillingAddressCheckbox;
7463
$this->billingCheckboxState = $billingCheckboxState;
7564
}
7665

7766
/**
78-
* Fill billing address
67+
* Fill billing address.
7968
*
8069
* @return void
8170
*/
8271
public function run()
8372
{
84-
if ($this->billingCheckboxState !== null) {
73+
if ($this->billingCheckboxState) {
8574
$this->assertBillingAddressCheckbox->processAssert($this->checkoutOnepage, $this->billingCheckboxState);
8675
}
87-
$selectedPaymentMethod = $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock();
88-
$selectedPaymentMethod->getBillingBlock()->fillBilling($this->billingAddress);
76+
77+
if ($this->billingAddress) {
78+
$selectedPaymentMethod = $this->checkoutOnepage->getPaymentBlock()->getSelectedPaymentMethodBlock();
79+
$selectedPaymentMethod->getBillingBlock()->fillBilling($this->billingAddress);
80+
}
8981
}
9082
}

dev/tests/functional/tests/app/Magento/Checkout/Test/TestStep/FillShippingAddressStep.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,17 @@ class FillShippingAddressStep implements TestStepInterface
2929
*/
3030
protected $shippingAddress;
3131

32-
/**
33-
* Checkout method.
34-
*
35-
* @var string
36-
*/
37-
protected $checkoutMethod;
38-
3932
/**
4033
* @constructor
4134
* @param CheckoutOnepage $checkoutOnepage
4235
* @param Address $shippingAddress
43-
* @param string $checkoutMethod
4436
*/
4537
public function __construct(
4638
CheckoutOnepage $checkoutOnepage,
47-
$checkoutMethod,
4839
Address $shippingAddress = null
4940
) {
5041
$this->checkoutOnepage = $checkoutOnepage;
5142
$this->shippingAddress = $shippingAddress;
52-
$this->checkoutMethod = $checkoutMethod;
5343
}
5444

5545
/**
@@ -59,8 +49,8 @@ public function __construct(
5949
*/
6050
public function run()
6151
{
62-
if (!empty($this->shippingAddress)) {
63-
$this->checkoutOnepage->getShippingBlock()->fillShipping($this->shippingAddress);
52+
if ($this->shippingAddress) {
53+
$this->checkoutOnepage->getShippingBlock()->fill($this->shippingAddress);
6454
}
6555
}
6656
}

0 commit comments

Comments
 (0)