Skip to content

Commit 2258f1c

Browse files
author
Vadim Zubovich
committed
Merge branch 'MTO-77-new' into 'iteration2-pr-new'
MTO-77: [Test] Checkout with Persistent Shopping Cart - Implemented test for checkout with Persistent Shopping Cart See merge request !95
2 parents 67c1a2d + 16084cd commit 2258f1c

File tree

5 files changed

+280
-2
lines changed

5 files changed

+280
-2
lines changed

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

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

1212
/**
13-
* One page checkout status shipping method block
13+
* One page checkout status shipping method block.
1414
*/
1515
class Method extends Block
1616
{
1717
/**
18-
* Shipping method selector
18+
* Shipping method selector.
1919
*
2020
* @var string
2121
*/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Persistent\Test\Constraint;
8+
9+
use Magento\Checkout\Test\Page\CheckoutOnepage;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
12+
/**
13+
* Assert first step on Checkout page is available.
14+
*/
15+
class AssertCustomerIsRedirectedToCheckout extends AbstractConstraint
16+
{
17+
/**
18+
* Assert first step on Checkout page is available.
19+
*
20+
* @param CheckoutOnepage $checkoutOnepage
21+
* @return void
22+
*/
23+
public function processAssert(CheckoutOnepage $checkoutOnepage)
24+
{
25+
$checkoutOnepage->open();
26+
\PHPUnit_Framework_Assert::assertTrue(
27+
!$checkoutOnepage->getMessagesBlock()->isVisible()
28+
&& $checkoutOnepage->getShippingMethodBlock()->isVisible(),
29+
'Checkout first step is not available.'
30+
);
31+
}
32+
33+
/**
34+
* Returns string representation of successful assertion.
35+
*
36+
* @return string
37+
*/
38+
public function toString()
39+
{
40+
return 'Checkout first step is available.';
41+
}
42+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/Magento/Mtf/Repository/etc/repository.xsd">
9+
<repository class="Magento\Config\Test\Repository\ConfigData">
10+
<dataset name="clearpersistence_on_signout">
11+
<field name="persistent/options/enabled" xsi:type="array">
12+
<item name="scope" xsi:type="string">persistent</item>
13+
<item name="scope_id" xsi:type="number">1</item>
14+
<item name="label" xsi:type="string">Yes</item>
15+
<item name="value" xsi:type="number">1</item>
16+
</field>
17+
<field name="persistent/options/logout_clear" xsi:type="array">
18+
<item name="scope" xsi:type="string">persistent</item>
19+
<item name="scope_id" xsi:type="number">1</item>
20+
<item name="label" xsi:type="string">No</item>
21+
<item name="value" xsi:type="number">0</item>
22+
</field>
23+
</dataset>
24+
25+
<dataset name="clearpersistence_on_signout_rollback">
26+
<field name="persistent/options/enabled" xsi:type="array">
27+
<item name="scope" xsi:type="string">persistent</item>
28+
<item name="scope_id" xsi:type="number">1</item>
29+
<item name="label" xsi:type="string">No</item>
30+
<item name="value" xsi:type="number">0</item>
31+
</field>
32+
<field name="persistent/options/logout_clear" xsi:type="array">
33+
<item name="scope" xsi:type="string">persistent</item>
34+
<item name="scope_id" xsi:type="number">1</item>
35+
<item name="label" xsi:type="string">Yes</item>
36+
<item name="value" xsi:type="number">1</item>
37+
</field>
38+
</dataset>
39+
</repository>
40+
</config>
Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<?php
2+
/**
3+
* Copyright © 2016 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Persistent\Test\TestCase;
8+
9+
use Magento\Customer\Test\Fixture\Customer;
10+
use Magento\Catalog\Test\Fixture\CatalogProductSimple;
11+
use Magento\Customer\Test\Page\CustomerAccountCreate;
12+
use Magento\Cms\Test\Page\CmsIndex;
13+
use Magento\Catalog\Test\Page\Product\CatalogProductView;
14+
use Magento\Checkout\Test\Page\CheckoutCart;
15+
use Magento\Mtf\Client\BrowserInterface;
16+
use Magento\Customer\Test\TestStep\LogoutCustomerOnFrontendStep;
17+
use Magento\Mtf\TestCase\Injectable;
18+
use Magento\Mtf\TestStep\TestStepFactory;
19+
20+
/**
21+
* Preconditions:
22+
* Apply configs:
23+
* 1. Enable Persistent Shopping Cart.
24+
* 2. Disable Clear Persistence on Sign Out.
25+
*
26+
* Steps:
27+
* 1. Go to frontend.
28+
* 2. Click Register link.
29+
* 3. Fill registry form.
30+
* 4. Click 'Create account' button.
31+
* 5. Add simple product to shopping cart.
32+
* 6. Sign out.
33+
*
34+
* @ZephyrId MAGETWO-45381
35+
*/
36+
class CheckoutWthPersistentShoppingCartTest extends Injectable
37+
{
38+
/**
39+
* Config data.
40+
*
41+
* @string $configData
42+
*/
43+
private $configData;
44+
45+
/**
46+
* Customer registry page.
47+
*
48+
* @var CustomerAccountCreate
49+
*/
50+
private $customerAccountCreate;
51+
52+
/**
53+
* Cms page.
54+
*
55+
* @var CmsIndex $cmsIndex.
56+
*/
57+
private $cmsIndex;
58+
59+
/**
60+
* Frontend product view page.
61+
*
62+
* @var CatalogProductView
63+
*/
64+
private $catalogProductView;
65+
66+
/**
67+
* Interface Browser.
68+
*
69+
* @var BrowserInterface.
70+
*/
71+
private $browser;
72+
73+
/**
74+
* Page of checkout page.
75+
*
76+
* @var CheckoutCart
77+
*/
78+
private $checkoutCart;
79+
80+
/**
81+
* Customer log out step.
82+
*
83+
* @var LogoutCustomerOnFrontendStep
84+
*/
85+
private $logoutCustomerOnFrontendStep;
86+
87+
/**
88+
* Factory for Test Steps.
89+
*
90+
* @var TestStepFactory
91+
*/
92+
private $stepFactory;
93+
94+
/**
95+
* Inject data.
96+
*
97+
* @param CustomerAccountCreate $customerAccountCreate
98+
* @param CmsIndex $cmsIndex
99+
* @param LogoutCustomerOnFrontendStep $logoutCustomerOnFrontendStep
100+
* @param CatalogProductView $catalogProductView
101+
* @param BrowserInterface $browser
102+
* @param CheckoutCart $checkoutCart
103+
* @param TestStepFactory $stepFactory
104+
* @return void
105+
*/
106+
public function __inject(
107+
CustomerAccountCreate $customerAccountCreate,
108+
CmsIndex $cmsIndex,
109+
LogoutCustomerOnFrontendStep $logoutCustomerOnFrontendStep,
110+
CatalogProductView $catalogProductView,
111+
BrowserInterface $browser,
112+
CheckoutCart $checkoutCart,
113+
TestStepFactory $stepFactory
114+
) {
115+
$this->customerAccountCreate = $customerAccountCreate;
116+
$this->cmsIndex = $cmsIndex;
117+
$this->logoutCustomerOnFrontendStep = $logoutCustomerOnFrontendStep;
118+
$this->browser = $browser;
119+
$this->catalogProductView = $catalogProductView;
120+
$this->checkoutCart = $checkoutCart;
121+
$this->stepFactory = $stepFactory;
122+
}
123+
124+
/**
125+
* Prepare data.
126+
*
127+
* @param CatalogProductSimple $product
128+
* @return array
129+
*/
130+
public function __prepare(CatalogProductSimple $product)
131+
{
132+
$product->persist();
133+
134+
return ['product' => $product];
135+
}
136+
137+
/**
138+
* Create Customer account on Storefront.
139+
*
140+
* @param string $configData
141+
* @param CatalogProductSimple $product
142+
* @param Customer $customer
143+
* @return void
144+
*/
145+
public function test($configData, CatalogProductSimple $product, Customer $customer)
146+
{
147+
$this->configData = $configData;
148+
$this->stepFactory->create(
149+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
150+
['configData' => $configData]
151+
)->run();
152+
153+
// Steps
154+
$this->cmsIndex->open();
155+
$this->cmsIndex->getLinksBlock()->openLink('Create an Account');
156+
$this->customerAccountCreate->getRegisterForm()->registerCustomer($customer);
157+
158+
// Ensure that shopping cart is empty
159+
$this->checkoutCart->open()->getCartBlock()->clearShoppingCart();
160+
161+
$this->browser->open($_ENV['app_frontend_url'] . $product->getUrlKey() . '.html');
162+
$this->catalogProductView->getViewBlock()->addToCart($product);
163+
$this->catalogProductView->getMessagesBlock()->waitSuccessMessage();
164+
$this->logoutCustomerOnFrontendStep->run();
165+
}
166+
167+
/**
168+
* Clean data after running test.
169+
*
170+
* @return void
171+
*/
172+
public function tearDown()
173+
{
174+
$this->stepFactory->create(
175+
\Magento\Config\Test\TestStep\SetupConfigurationStep::class,
176+
['configData' => $this->configData, 'rollback' => true]
177+
)->run();
178+
}
179+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2016 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/mtf/etc/variations.xsd">
9+
<testCase name="Magento\Persistent\Test\TestCase\CheckoutWthPersistentShoppingCartTest" summary="Checkout with Persistent Shopping Cart" ticketId="MAGETWO-45381">
10+
<variation name="RedirectCustomerToCheckoutTestVariation1" summary="Checkout with Persistent Shopping Cart">
11+
<data name="issue" xsi:type="string">MAGETWO-59976: Customer can't open Product on Storefront if Persistent Cart is enabled</data>
12+
<data name="customer/dataset" xsi:type="string">register_customer</data>
13+
<data name="configData" xsi:type="string">clearpersistence_on_signout</data>
14+
<constraint name="Magento\Persistent\Test\Constraint\AssertCustomerIsRedirectedToCheckout" />
15+
</variation>
16+
</testCase>
17+
</config>

0 commit comments

Comments
 (0)