Skip to content

Commit 0615753

Browse files
committed
MTA-1594: Re-factor Functional tests which are not end-to-end
- Re-factored ForgotPasswordOnFrontendTest
1 parent fb42f3a commit 0615753

File tree

4 files changed

+127
-54
lines changed

4 files changed

+127
-54
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Test\Constraint;
8+
9+
use Magento\Customer\Test\Fixture\Customer;
10+
use Magento\Mtf\Constraint\AbstractConstraint;
11+
use Magento\Customer\Test\Page\CustomerAccountLogin;
12+
use Magento\Customer\Test\Page\CustomerAccountForgotPassword;
13+
14+
/**
15+
* Assert that customer forgot password message is present on customer account forgot password page.
16+
*/
17+
class AssertCustomerForgotPasswordSuccessMessage extends AbstractConstraint
18+
{
19+
const SUCCESS_MESSAGE_FIRST_PART = 'If there is an account associated with %s';
20+
const SUCCESS_MESSAGE_SECOND_PART = ' you will receive an email with a link to reset your password.';
21+
22+
/**
23+
* Assert that customer forgot password message is present on customer account forgot password page.
24+
*
25+
* @param CustomerAccountLogin $customerLogin
26+
* @param CustomerAccountForgotPassword $forgotPassword
27+
* @param Customer $customer
28+
* @return void
29+
*/
30+
public function processAssert(
31+
CustomerAccountLogin $customerLogin,
32+
CustomerAccountForgotPassword $forgotPassword,
33+
Customer $customer
34+
) {
35+
$forgotPassword->open();
36+
$forgotPassword->getForgotPasswordForm()->resetForgotPassword($customer);
37+
38+
$message = sprintf(
39+
self::SUCCESS_MESSAGE_FIRST_PART . self::SUCCESS_MESSAGE_SECOND_PART,
40+
$customer->getEmail()
41+
);
42+
43+
\PHPUnit_Framework_Assert::assertEquals(
44+
$message,
45+
$customerLogin->getMessages()->getSuccessMessages(),
46+
'Wrong forgot password message is displayed.'
47+
);
48+
}
49+
50+
/**
51+
* Returns a string representation of the object.
52+
*
53+
* @return string
54+
*/
55+
public function toString()
56+
{
57+
return 'Customer forgot password message is present on customer account forgot password page.';
58+
}
59+
}

dev/tests/functional/tests/app/Magento/Customer/Test/TestCase/ForgotPasswordOnFrontendTest.php

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,31 @@
66

77
namespace Magento\Customer\Test\TestCase;
88

9-
use Magento\Mtf\Factory\Factory;
10-
use Magento\Mtf\TestCase\Functional;
9+
use Magento\Mtf\TestCase\Injectable;
10+
use Magento\Customer\Test\Fixture\Customer;
1111

1212
/**
13-
* Reset password on frontend
13+
* Precondition:
14+
* 1. Customer is created.
15+
*
16+
* @group Customer_(CS)
1417
*/
15-
class ForgotPasswordOnFrontendTest extends Functional
18+
class ForgotPasswordOnFrontendTest extends Injectable
1619
{
20+
/* tags */
21+
const MVP = 'yes';
22+
const DOMAIN = 'CS';
23+
/* end tags */
24+
1725
/**
18-
* Reset password on frontend
26+
* Create customer.
27+
*
28+
* @param Customer $customer
29+
* @return void
1930
*/
20-
public function testForgotPassword()
31+
public function test(Customer $customer)
2132
{
22-
// Create Customer
23-
$customer = $this->objectManager->getInstance()->create(
24-
'Magento\Customer\Test\Fixture\Customer',
25-
['dataSet' => 'customer_US_1']
26-
);
33+
// Precondition
2734
$customer->persist();
28-
29-
$customerAccountLoginPage = Factory::getPageFactory()->getCustomerAccountLogin();
30-
$forgotPasswordPage = Factory::getPageFactory()->getCustomerAccountForgotpassword();
31-
$forgotPasswordPage->open();
32-
33-
$forgotPasswordPage->getForgotPasswordForm()->resetForgotPassword($customer);
34-
35-
//Verifying
36-
$message = sprintf(
37-
'If there is an account associated with %s you will receive an email with a link to reset your password.',
38-
$customer->getEmail()
39-
);
40-
$this->assertContains($message, $customerAccountLoginPage->getMessages()->getSuccessMessages());
4135
}
4236
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 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\Customer\Test\TestCase\ForgotPasswordOnFrontendTest">
10+
<variation name="ForgotPasswordOnFrontendTestVariation1">
11+
<data name="customer/dataSet" xsi:type="string">customer_US_1</data>
12+
<constraint name="Magento\Customer\Test\Constraint\AssertCustomerForgotPasswordSuccessMessage"/>
13+
</variation>
14+
</testCase>
15+
</config>

dev/tests/functional/tests/app/Magento/Customer/Test/etc/di.xml

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,39 @@
66
*/
77
-->
88
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../../../lib/internal/Magento/Framework/ObjectManager/etc/config.xsd">
9-
<type name="Magento\Customer\Test\Constraint\AssertCustomerInGrid">
10-
<arguments>
11-
<argument name="severity" xsi:type="string">middle</argument>
12-
</arguments>
13-
</type>
14-
<type name="Magento\Customer\Test\Constraint\AssertCustomerNotInGrid">
15-
<arguments>
16-
<argument name="severity" xsi:type="string">middle</argument>
17-
</arguments>
18-
</type>
19-
<type name="Magento\Customer\Test\Constraint\AssertCustomerForm">
20-
<arguments>
21-
<argument name="severity" xsi:type="string">middle</argument>
22-
</arguments>
23-
</type>
24-
<type name="Magento\Customer\Test\Constraint\AssertCustomerInvalidEmail">
25-
<arguments>
26-
<argument name="severity" xsi:type="string">middle</argument>
27-
</arguments>
28-
</type>
29-
<type name="Magento\Customer\Test\Constraint\AssertCustomerFailRegisterMessage">
30-
<arguments>
31-
<argument name="severity" xsi:type="string">high</argument>
32-
</arguments>
33-
</type>
34-
<type name="Magento\Customer\Test\Constraint\AssertCustomerGroupSuccessDeleteMessage">
35-
<arguments>
36-
<argument name="severity" xsi:type="string">high</argument>
37-
</arguments>
38-
</type>
9+
<type name="Magento\Customer\Test\Constraint\AssertCustomerInGrid">
10+
<arguments>
11+
<argument name="severity" xsi:type="string">middle</argument>
12+
</arguments>
13+
</type>
14+
<type name="Magento\Customer\Test\Constraint\AssertCustomerNotInGrid">
15+
<arguments>
16+
<argument name="severity" xsi:type="string">middle</argument>
17+
</arguments>
18+
</type>
19+
<type name="Magento\Customer\Test\Constraint\AssertCustomerForm">
20+
<arguments>
21+
<argument name="severity" xsi:type="string">middle</argument>
22+
</arguments>
23+
</type>
24+
<type name="Magento\Customer\Test\Constraint\AssertCustomerInvalidEmail">
25+
<arguments>
26+
<argument name="severity" xsi:type="string">middle</argument>
27+
</arguments>
28+
</type>
29+
<type name="Magento\Customer\Test\Constraint\AssertCustomerFailRegisterMessage">
30+
<arguments>
31+
<argument name="severity" xsi:type="string">high</argument>
32+
</arguments>
33+
</type>
34+
<type name="Magento\Customer\Test\Constraint\AssertCustomerGroupSuccessDeleteMessage">
35+
<arguments>
36+
<argument name="severity" xsi:type="string">high</argument>
37+
</arguments>
38+
</type>
39+
<type name="Magento\Customer\Test\Constraint\AssertCustomerForgotPasswordSuccessMessage">
40+
<arguments>
41+
<argument name="severity" xsi:type="string">high</argument>
42+
</arguments>
43+
</type>
3944
</config>

0 commit comments

Comments
 (0)