Completed
Push — master ( 298ac7...0024da )
by Oleg
12:58
created

AddUserCest::_before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
use Codeception\Util\HttpCode;
4
5
class AddUserCest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
6
{
7
    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...
8
    {
9
        $I->wantTo('create user');
10
        $I->haveHttpHeader('Content-Type', 'application/json');
11
        $I->sendPOST('/user', [
12
            'first' => 'Test',
13
            'last' => 'User',
14
            'email' => '[email protected]',
15
        ]);
16
        $I->seeResponseCodeIs(HttpCode::OK);
17
        $I->seeResponseContainsJson([
18
            'success' => true,
19
            'data' => [
20
                'user' => [
21
                    'first' => 'Test',
22
                    'last' => 'User',
23
                    'email' => '[email protected]',
24
                ]
25
            ]
26
        ]);
27
    }
28
29
    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...
30
    {
31
        $I->wantTo('create user with incomplete data');
32
        $I->haveHttpHeader('Content-Type', 'application/json');
33
        $I->sendPOST('/user', [
34
            'last' => 'User',
35
            'email' => '[email protected]',
36
        ]);
37
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
38
        $I->seeResponseContainsJson([
39
            'success' => false,
40
            'data' => [
41
                'validation' => [
42
                    [
43
                        'field' => 'first',
44
                    ]
45
                ]
46
            ]
47
        ]);
48
    }
49
50
    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...
51
    {
52
        $I->wantTo('create user with wrong email');
53
        $I->haveHttpHeader('Content-Type', 'application/json');
54
        $I->sendPOST('/user', [
55
            'first' => 'Test',
56
            'last' => 'User',
57
            'email' => 'wrong email',
58
        ]);
59
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
60
        $I->seeResponseContainsJson([
61
            'success' => false,
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
        $I->seeResponseContainsJson([
83
            'success' => false,
84
        ]);
85
    }
86
}
87