Completed
Push — master ( 630401...3eb757 )
by Oleg
02:43
created

GetConfigsCest::getWrongFilterUsers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
c 0
b 0
f 0
rs 9.7998
cc 1
nc 1
nop 1
1
<?php
2
3
namespace codecept;
4
5
use Codeception\Util\HttpCode;
6
use SlayerBirden\DataFlowServer\Db\Entities\DbConfiguration;
7
use SlayerBirden\DataFlowServer\Domain\Entities\User;
8
9
class GetConfigsCest
10
{
11
    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...
12
    {
13
        $user = $I->grabEntityFromRepository(User::class, ['id' => 1]);
14
        $I->haveInRepository(DbConfiguration::class, [
15
            'owner' => $user,
16
            'title' => 'sqlite config',
17
            'url' => 'sqlite:///data/db/db.sqlite',
18
        ]);
19
        $I->haveInRepository(DbConfiguration::class, [
20
            'owner' => $user,
21
            'title' => 'mysql config',
22
            'url' => 'mysql://test-user:test-pwd@mysql/test',
23
        ]);
24
        $I->haveInRepository(DbConfiguration::class, [
25
            'owner' => $user,
26
            'title' => 'project 1 config',
27
            'url' => 'sqlite:///data/db/db.sqlite',
28
        ]);
29
        $I->haveInRepository(DbConfiguration::class, [
30
            'owner' => $user,
31
            'title' => 'project 2 config',
32
            'url' => 'sqlite:///data/db/db.sqlite',
33
        ]);
34
        $I->haveInRepository(DbConfiguration::class, [
35
            'owner' => $user,
36
            'title' => 'project 3 config',
37
            'url' => 'sqlite:///data/db/db.sqlite',
38
        ]);
39
        $I->haveInRepository(DbConfiguration::class, [
40
            'owner' => $user,
41
            'title' => 'project 4 config',
42
            'url' => 'sqlite:///data/db/db.sqlite',
43
        ]);
44
        $I->haveInRepository(DbConfiguration::class, [
45
            'owner' => $user,
46
            'title' => 'project 5 config',
47
            'url' => 'sqlite:///data/db/db.sqlite',
48
        ]);
49
        $I->haveInRepository(DbConfiguration::class, [
50
            'owner' => $user,
51
            'title' => 'project 6 config',
52
            'url' => 'sqlite:///data/db/db.sqlite',
53
        ]);
54
        $I->haveInRepository(DbConfiguration::class, [
55
            'owner' => $user,
56
            'title' => 'project 7 config',
57
            'url' => 'sqlite:///data/db/db.sqlite',
58
        ]);
59
        $I->haveInRepository(DbConfiguration::class, [
60
            'owner' => $user,
61
            'title' => 'project 8 config',
62
            'url' => 'sqlite:///data/db/db.sqlite',
63
        ]);
64
        $I->haveInRepository(DbConfiguration::class, [
65
            'owner' => $user,
66
            'title' => 'project 9 config',
67
            'url' => 'sqlite:///data/db/db.sqlite',
68
        ]);
69
    }
70
71
    public function getAllConfigurations(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...
72
    {
73
        $I->wantTo('get all db configurations');
74
        $I->haveHttpHeader('Content-Type', 'application/json');
75
        $I->sendGET('/configs?l=100');
76
        $I->seeResponseCodeIs(HttpCode::OK);
77
        $I->seeResponseContainsJson([
78
            'success' => true,
79
            'data' => [
80
                'configurations' => [
81
                    [
82
                        'title' => 'sqlite config',
83
                    ],
84
                    [
85
                        'title' => 'mysql config',
86
                    ],
87
                    [
88
                        'title' => 'project 1 config',
89
                    ],
90
                    [
91
                        'title' => 'project 2 config',
92
                    ],
93
                    [
94
                        'title' => 'project 3 config',
95
                    ],
96
                    [
97
                        'title' => 'project 4 config',
98
                    ],
99
                    [
100
                        'title' => 'project 5 config',
101
                    ],
102
                    [
103
                        'title' => 'project 6 config',
104
                    ],
105
                    [
106
                        'title' => 'project 7 config',
107
                    ],
108
                    [
109
                        'title' => 'project 8 config',
110
                    ],
111
                    [
112
                        'title' => 'project 9 config',
113
                    ],
114
                ],
115
                'count' => 11,
116
            ]
117
        ]);
118
    }
119
120
    public function getSecondPageConfigurations(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...
121
    {
122
        $I->wantTo('get second page of db configurations');
123
        $I->haveHttpHeader('Content-Type', 'application/json');
124
        $I->sendGET('/configs?p=2');
125
        $I->seeResponseCodeIs(HttpCode::OK);
126
        $I->seeResponseContainsJson([
127
            'success' => true,
128
            'data' => [
129
                'configurations' => [
130
                    [
131
                        'title' => 'project 9 config',
132
                    ],
133
                ],
134
                'count' => 11,
135
            ]
136
        ]);
137
    }
138
139
    public function getFilteredConfigurations(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...
140
    {
141
        $I->wantTo('get configurations filtered by mysql');
142
        $I->haveHttpHeader('Content-Type', 'application/json');
143
        $I->sendGET('/configs?f[title]=mysql');
144
        $I->seeResponseCodeIs(HttpCode::OK);
145
        $I->seeResponseContainsJson([
146
            'success' => true,
147
            'data' => [
148
                'configurations' => [
149
                    [
150
                        'title' => 'mysql config',
151
                    ],
152
                ],
153
                'count' => 1,
154
            ]
155
        ]);
156
    }
157
158
    public function getSortedConfigurations(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...
159
    {
160
        $I->wantTo('get configurations sorted by title asc');
161
        $I->haveHttpHeader('Content-Type', 'application/json');
162
        $I->sendGET('/configs?s[title]=asc');
163
        $I->seeResponseCodeIs(HttpCode::OK);
164
        $I->seeResponseContainsJson([
165
            'success' => true,
166
            'data' => [
167
                'configurations' => [
168
                    [
169
                        'title' => 'mysql config',
170
                    ],
171
                ],
172
                'count' => 11,
173
            ]
174
        ]);
175
    }
176
177
    public function getNoResultsFilterConfigurations(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...
178
    {
179
        $I->wantTo('attempt to get configurations with not matching filter');
180
        $I->haveHttpHeader('Content-Type', 'application/json');
181
        $I->sendGET('/configs?f[title]=bla');
182
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
183
        $I->seeResponseContainsJson([
184
            'success' => false,
185
            'data' => [
186
                'configurations' => [],
187
                'count' => 0,
188
            ]
189
        ]);
190
    }
191
192
    public function getWrongFilterUsers(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...
193
    {
194
        $I->wantTo('attempt to get configurations with wrong filters');
195
        $I->haveHttpHeader('Content-Type', 'application/json');
196
        $I->sendGET('/configs?f[abracadabra]=30');
197
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
198
        $I->seeResponseContainsJson([
199
            'success' => false,
200
            'data' => [
201
                'configurations' => [],
202
                'count' => 0,
203
            ]
204
        ]);
205
    }
206
}
207