Completed
Push — master ( 3eb757...3bc7c8 )
by Oleg
03:46
created

UpdateConfigCest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 70
c 0
b 0
f 0
rs 10

4 Methods

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