AddUserCest::addUserWithWrongEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace codecept\user;
4
5
use codecept\ApiTester;
6
use Codeception\Util\HttpCode;
7
8
class AddUserCest
9
{
10
    public function addUser(ApiTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
11
    {
12
        $I->wantTo('create user');
13
        $I->haveHttpHeader('Content-Type', 'application/json');
14
        $I->sendPOST('/user', [
15
            'first' => 'Test',
16
            'last' => 'User',
17
            'email' => '[email protected]',
18
        ]);
19
        $I->seeResponseCodeIs(HttpCode::OK);
20
        $I->seeResponseContainsJson([
21
            'data' => [
22
                'user' => [
23
                    'first' => 'Test',
24
                    'last' => 'User',
25
                    'email' => '[email protected]',
26
                ]
27
            ]
28
        ]);
29
    }
30
31
    public function addIncompleteUser(ApiTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
32
    {
33
        $I->wantTo('create user with incomplete data');
34
        $I->haveHttpHeader('Content-Type', 'application/json');
35
        $I->sendPOST('/user', [
36
            'last' => 'User',
37
            'email' => '[email protected]',
38
        ]);
39
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
40
        $I->seeResponseContainsJson([
41
            'data' => [
42
                'validation' => [
43
                    [
44
                        'field' => 'first',
45
                    ]
46
                ]
47
            ]
48
        ]);
49
    }
50
51
    public function addUserWithWrongEmail(ApiTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
52
    {
53
        $I->wantTo('create user with wrong email');
54
        $I->haveHttpHeader('Content-Type', 'application/json');
55
        $I->sendPOST('/user', [
56
            'first' => 'Test',
57
            'last' => 'User',
58
            'email' => 'wrong email',
59
        ]);
60
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
61
        $I->seeResponseContainsJson([
62
            'data' => [
63
                'validation' => [
64
                    [
65
                        'field' => 'email',
66
                    ]
67
                ]
68
            ]
69
        ]);
70
    }
71
72
    public function addUserWithExistingEmail(ApiTester $I)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $I. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
73
    {
74
        $I->wantTo('create user with existing email');
75
        $I->haveHttpHeader('Content-Type', 'application/json');
76
        $I->sendPOST('/user', [
77
            'first' => 'Test',
78
            'last' => 'User',
79
            'email' => '[email protected]',
80
        ]);
81
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
82
    }
83
}
84