GetConfigCest::_before()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace codecept\configuration;
4
5
use codecept\ApiTester;
6
use Codeception\Util\HttpCode;
7
use SlayerBirden\DataFlowServer\Db\Entities\DbConfiguration;
8
use SlayerBirden\DataFlowServer\Domain\Entities\User;
9
10
class GetConfigCest
11
{
12
    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...
13
    {
14
        $user = $I->grabEntityFromRepository(User::class, ['id' => 1]);
15
        $I->haveInRepository(DbConfiguration::class, [
16
            'id' => 1,
17
            'owner' => $user,
18
            'title' => 'Test config',
19
            'url' => 'sqlite:///data/db/db.sqlite',
20
        ]);
21
    }
22
23
    public function getConfiguration(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...
24
    {
25
        $I->wantTo('get db configuration');
26
        $I->haveHttpHeader('Content-Type', 'application/json');
27
        $I->sendGET('/config/1');
28
        $I->seeResponseCodeIs(HttpCode::OK);
29
        $I->seeResponseContainsJson([
30
            'data' => [
31
                'configuration' => [
32
                    'title' => 'Test config',
33
                ]
34
            ]
35
        ]);
36
    }
37
38
    public function getNonExistingConfiguration(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...
39
    {
40
        $I->wantTo('get non-existing db configuration');
41
        $I->haveHttpHeader('Content-Type', 'application/json');
42
        $I->sendGET('/config/0');
43
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
44
        $I->seeResponseContainsJson([
45
            'data' => [
46
                'configuration' => null
47
            ]
48
        ]);
49
    }
50
51
    public function getConfigurationWithInvalidId(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...
52
    {
53
        $I->wantTo('get db configuration using invalid id');
54
        $I->haveHttpHeader('Content-Type', 'application/json');
55
        $I->sendGET('/config/bar');
56
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
57
    }
58
59
    public function getConfigurationNoId(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...
60
    {
61
        $I->wantTo('get db configuration without id');
62
        $I->haveHttpHeader('Content-Type', 'application/json');
63
        $I->sendGET('/config/');
64
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
65
    }
66
}
67