Completed
Push — master ( 3eb757...3bc7c8 )
by Oleg
03:46
created

AddUserCest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 82
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A addUser() 0 21 1
A addIncompleteUser() 0 20 1
A addUserWithWrongEmail() 0 21 1
A addUserWithExistingEmail() 0 14 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
            'success' => true,
22
            'data' => [
23
                'user' => [
24
                    'first' => 'Test',
25
                    'last' => 'User',
26
                    'email' => '[email protected]',
27
                ]
28
            ]
29
        ]);
30
    }
31
32
    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...
33
    {
34
        $I->wantTo('create user with incomplete data');
35
        $I->haveHttpHeader('Content-Type', 'application/json');
36
        $I->sendPOST('/user', [
37
            'last' => 'User',
38
            'email' => '[email protected]',
39
        ]);
40
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
41
        $I->seeResponseContainsJson([
42
            'success' => false,
43
            'data' => [
44
                'validation' => [
45
                    [
46
                        'field' => 'first',
47
                    ]
48
                ]
49
            ]
50
        ]);
51
    }
52
53
    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...
54
    {
55
        $I->wantTo('create user with wrong email');
56
        $I->haveHttpHeader('Content-Type', 'application/json');
57
        $I->sendPOST('/user', [
58
            'first' => 'Test',
59
            'last' => 'User',
60
            'email' => 'wrong email',
61
        ]);
62
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
63
        $I->seeResponseContainsJson([
64
            'success' => false,
65
            'data' => [
66
                'validation' => [
67
                    [
68
                        'field' => 'email',
69
                    ]
70
                ]
71
            ]
72
        ]);
73
    }
74
75
    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...
76
    {
77
        $I->wantTo('create user with existing email');
78
        $I->haveHttpHeader('Content-Type', 'application/json');
79
        $I->sendPOST('/user', [
80
            'first' => 'Test',
81
            'last' => 'User',
82
            'email' => '[email protected]',
83
        ]);
84
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
85
        $I->seeResponseContainsJson([
86
            'success' => false,
87
        ]);
88
    }
89
}
90