SignupCest::_after()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
1
<?php
2
3
namespace tests\codeception\frontend\acceptance;
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\Event\TestEvent $event
14
     */
15
    public function _before($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
16
    {
17
    }
18
19
    /**
20
     * This method is called after each cest class test method, even if test failed.
21
     * @param \Codeception\Event\TestEvent $event
22
     */
23
    public function _after($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
    {
25
        User::deleteAll([
26
            'email' => '[email protected]',
27
            'username' => 'tester',
28
        ]);
29
    }
30
31
    /**
32
     * This method is called when test fails.
33
     * @param \Codeception\Event\FailEvent $event
34
     */
35
    public function _fail($event)
0 ignored issues
show
Unused Code introduced by
The parameter $event is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
36
    {
37
    }
38
39
    /**
40
     * @param \codeception_frontend\AcceptanceTester $I
41
     * @param \Codeception\Scenario $scenario
42
     */
43
    public function testUserSignup($I, $scenario)
0 ignored issues
show
Unused Code introduced by
The parameter $scenario is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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 logged in');
80
        $I->see('Logout (tester)', 'form button[type=submit]');
81
    }
82
}
83