|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace tests\codeception\frontend\functional; |
|
4
|
|
|
|
|
5
|
|
|
use tests\codeception\frontend\_pages\SignupPage; |
|
6
|
|
|
use common\models\User; |
|
7
|
|
|
|
|
8
|
|
|
class SignupCest |
|
9
|
|
|
{ |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* This method is called before each cest class test method |
|
13
|
|
|
* @param \codeception_frontend\FunctionalTester $I |
|
14
|
|
|
*/ |
|
15
|
|
|
public function _before($I) |
|
|
|
|
|
|
16
|
|
|
{ |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* This method is called after each cest class test method, even if test failed. |
|
21
|
|
|
* @param \codeception_frontend\FunctionalTester $I |
|
22
|
|
|
*/ |
|
23
|
|
|
public function _after($I) |
|
24
|
|
|
{ |
|
25
|
|
|
//reload default fixtures |
|
26
|
|
|
$I->loadFixtures(); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* This method is called when test fails. |
|
31
|
|
|
* @param \codeception_frontend\FunctionalTester $I |
|
32
|
|
|
*/ |
|
33
|
|
|
public function _failed($I) |
|
|
|
|
|
|
34
|
|
|
{ |
|
35
|
|
|
|
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* |
|
40
|
|
|
* @param \codeception_frontend\FunctionalTester $I |
|
41
|
|
|
* @param \Codeception\Scenario $scenario |
|
42
|
|
|
*/ |
|
43
|
|
|
public function testUserSignup($I, $scenario) |
|
|
|
|
|
|
44
|
|
|
{ |
|
45
|
|
|
$I->wantTo('ensure that signup works'); |
|
46
|
|
|
|
|
47
|
|
|
$signupPage = SignupPage::openBy($I); |
|
48
|
|
|
$I->see('Signup', 'h1'); |
|
49
|
|
|
$I->see('Please fill out the following fields to signup:'); |
|
50
|
|
|
|
|
51
|
|
|
$I->amGoingTo('submit signup form with no data'); |
|
52
|
|
|
|
|
53
|
|
|
$signupPage->submit([]); |
|
54
|
|
|
|
|
55
|
|
|
$I->expectTo('see validation errors'); |
|
56
|
|
|
$I->see('Username cannot be blank.', '.help-block'); |
|
57
|
|
|
$I->see('Email cannot be blank.', '.help-block'); |
|
58
|
|
|
$I->see('Password cannot be blank.', '.help-block'); |
|
59
|
|
|
|
|
60
|
|
|
$I->amGoingTo('submit signup form with not correct email'); |
|
61
|
|
|
$signupPage->submit([ |
|
62
|
|
|
'username' => 'tester', |
|
63
|
|
|
'email' => 'tester.email', |
|
64
|
|
|
'password' => 'tester_password', |
|
65
|
|
|
]); |
|
66
|
|
|
|
|
67
|
|
|
$I->expectTo('see that email address is wrong'); |
|
68
|
|
|
$I->dontSee('Username cannot be blank.', '.help-block'); |
|
69
|
|
|
$I->dontSee('Password cannot be blank.', '.help-block'); |
|
70
|
|
|
$I->see('Email is not a valid email address.', '.help-block'); |
|
71
|
|
|
|
|
72
|
|
|
$I->amGoingTo('submit signup form with correct email'); |
|
73
|
|
|
$signupPage->submit([ |
|
74
|
|
|
'username' => 'tester', |
|
75
|
|
|
'email' => '[email protected]', |
|
76
|
|
|
'password' => 'tester_password', |
|
77
|
|
|
]); |
|
78
|
|
|
|
|
79
|
|
|
$I->expectTo('see that user is created'); |
|
80
|
|
|
$I->seeRecord('common\models\User', [ |
|
81
|
|
|
'username' => 'tester', |
|
82
|
|
|
'email' => '[email protected]', |
|
83
|
|
|
]); |
|
84
|
|
|
|
|
85
|
|
|
$I->expectTo('see that user logged in'); |
|
86
|
|
|
$I->see('Logout (tester)', 'form button[type=submit]'); |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.