Completed
Push — master ( 630401...3eb757 )
by Oleg
02:43
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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addUser() 0 21 1
A addIncompleteUser() 0 20 1
A addUserWithWrongEmail() 0 21 1
1
<?php
2
3
namespace codecept;
4
5
use Codeception\Util\HttpCode;
6
7
class AddUserCest
8
{
9
    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...
10
    {
11
        $I->wantTo('create user');
12
        $I->haveHttpHeader('Content-Type', 'application/json');
13
        $I->sendPOST('/user', [
14
            'first' => 'Test',
15
            'last' => 'User',
16
            'email' => '[email protected]',
17
        ]);
18
        $I->seeResponseCodeIs(HttpCode::OK);
19
        $I->seeResponseContainsJson([
20
            'success' => true,
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
            'success' => false,
42
            'data' => [
43
                'validation' => [
44
                    [
45
                        'field' => 'first',
46
                    ]
47
                ]
48
            ]
49
        ]);
50
    }
51
52
    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...
53
    {
54
        $I->wantTo('create user with wrong email');
55
        $I->haveHttpHeader('Content-Type', 'application/json');
56
        $I->sendPOST('/user', [
57
            'first' => 'Test',
58
            'last' => 'User',
59
            'email' => 'wrong email',
60
        ]);
61
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
62
        $I->seeResponseContainsJson([
63
            'success' => false,
64
            'data' => [
65
                'validation' => [
66
                    [
67
                        'field' => 'email',
68
                    ]
69
                ]
70
            ]
71
        ]);
72
    }
73
74
    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...
75
    {
76
        $I->wantTo('create user with existing email');
77
        $I->haveHttpHeader('Content-Type', 'application/json');
78
        $I->sendPOST('/user', [
79
            'first' => 'Test',
80
            'last' => 'User',
81
            'email' => '[email protected]',
82
        ]);
83
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
84
        $I->seeResponseContainsJson([
85
            'success' => false,
86
        ]);
87
    }
88
}
89