Completed
Push — master ( 707446...d99c9e )
by Oleg
04:16
created

UpdateConfigCest::updateIncompleteConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

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