Completed
Push — master ( d99c9e...a21e34 )
by Oleg
05:49
created

GetConfigsCest::getNoResultsFilterConfigurations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

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