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

UpdateConfigCest::updateIncompleteConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
c 0
b 0
f 0
rs 9.6333
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 UpdateConfigCest
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
            'id' => 1,
16
            'owner' => $user,
17
            'title' => 'sqlite config',
18
            'url' => 'sqlite:///data/db/db.sqlite',
19
        ]);
20
    }
21
22
    public function updateConfiguration(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...
23
    {
24
        $I->wantTo('update db configuration');
25
        $I->haveHttpHeader('Content-Type', 'application/json');
26
        $I->sendPUT('/config/1', [
27
            'title' => 'sqlite updated',
28
            'url' => 'sqlite:///data/db/db.sqlite',
29
        ]);
30
        $I->seeResponseCodeIs(HttpCode::OK);
31
        $I->seeResponseContainsJson([
32
            'success' => true,
33
            'data' => [
34
                'configuration' => [
35
                    'title' => 'sqlite updated',
36
                    'url' => 'sqlite:///data/db/db.sqlite',
37
                ]
38
            ]
39
        ]);
40
    }
41
42
    public function updateNonExistingConfig(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...
43
    {
44
        $I->wantTo('update non existing db configuration');
45
        $I->haveHttpHeader('Content-Type', 'application/json');
46
        $I->sendPUT('/config/0', [
47
            'title' => 'Test config',
48
            'url' => 'sqlite:///data/db/db.sqlite',
49
        ]);
50
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
51
        $I->seeResponseContainsJson([
52
            'success' => false,
53
            'data' => [
54
                'configuration' => null
55
            ]
56
        ]);
57
    }
58
59
    public function updateIncompleteConfig(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('update incomplete db configuration');
62
        $I->haveHttpHeader('Content-Type', 'application/json');
63
        $I->sendPUT('/config/1', [
64
            'title' => 'Test config',
65
        ]);
66
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
67
        $I->seeResponseContainsJson([
68
            'success' => false,
69
            'data' => [
70
                'validation' => [
71
                    [
72
                        'field' => 'user',
73
                    ]
74
                ]
75
            ]
76
        ]);
77
    }
78
}
79