Completed
Push — master ( 707446...d99c9e )
by Oleg
04:16
created

AddUserCest::addIncompleteUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 12
nc 1
nop 1
1
<?php
2
3
use Codeception\Util\HttpCode;
4
use SlayerBirden\DataFlowServer\Domain\Entities\User;
5
6
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...
7
{
8
    public function _before(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...
9
    {
10
        $I->haveInRepository(User::class, [
11
            'id' => 1,
12
            'first' => 'Tester',
13
            'last' => 'Tester',
14
            'email' => '[email protected]',
15
        ]);
16
    }
17
18
    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...
19
    {
20
        $I->wantTo('create user');
21
        $I->haveHttpHeader('Content-Type', 'application/json');
22
        $I->sendPOST('/user', [
23
            'first' => 'Test',
24
            'last' => 'User',
25
            'email' => '[email protected]',
26
        ]);
27
        $I->seeResponseCodeIs(HttpCode::OK);
28
        $I->seeResponseContainsJson([
29
            'success' => true,
30
            'data' => [
31
                'user' => [
32
                    'first' => 'Test',
33
                    'last' => 'User',
34
                    'email' => '[email protected]',
35
                ]
36
            ]
37
        ]);
38
    }
39
40
    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...
41
    {
42
        $I->wantTo('create user with incomplete data');
43
        $I->haveHttpHeader('Content-Type', 'application/json');
44
        $I->sendPOST('/user', [
45
            'last' => 'User',
46
            'email' => '[email protected]',
47
        ]);
48
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
49
        $I->seeResponseContainsJson([
50
            'success' => false,
51
            'data' => [
52
                'validation' => [
53
                    [
54
                        'field' => 'first',
55
                    ]
56
                ]
57
            ]
58
        ]);
59
    }
60
61
    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...
62
    {
63
        $I->wantTo('create user with wrong email');
64
        $I->haveHttpHeader('Content-Type', 'application/json');
65
        $I->sendPOST('/user', [
66
            'first' => 'Test',
67
            'last' => 'User',
68
            'email' => 'wrong email',
69
        ]);
70
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
71
        $I->seeResponseContainsJson([
72
            'success' => false,
73
            'data' => [
74
                'validation' => [
75
                    [
76
                        'field' => 'email',
77
                    ]
78
                ]
79
            ]
80
        ]);
81
    }
82
83
    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...
84
    {
85
        $I->wantTo('create user with existing email');
86
        $I->haveHttpHeader('Content-Type', 'application/json');
87
        $I->sendPOST('/user', [
88
            'first' => 'Test',
89
            'last' => 'User',
90
            'email' => '[email protected]',
91
        ]);
92
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
93
        $I->seeResponseContainsJson([
94
            'success' => false,
95
        ]);
96
    }
97
}
98