DeleteConfigCest::_before()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
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 DeleteConfigCest
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
            'owner' => $user,
17
            'title' => 'Test config',
18
            'url' => 'sqlite:///data/db/db.sqlite',
19
        ]);
20
    }
21
22
    public function deleteConfiguration(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('delete db configuration');
25
        $I->haveHttpHeader('Content-Type', 'application/json');
26
        $I->sendDELETE('/config/1');
27
        $I->seeResponseCodeIs(HttpCode::OK);
28
        $I->seeResponseContainsJson([
29
            'data' => [
30
                'configuration' => [
31
                    'title' => 'Test config',
32
                ]
33
            ]
34
        ]);
35
    }
36
37
    public function deleteNonExistingConfiguration(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...
38
    {
39
        $I->wantTo('delete non-existing db configuration');
40
        $I->haveHttpHeader('Content-Type', 'application/json');
41
        $I->sendDELETE('/config/0');
42
        $I->seeResponseCodeIs(HttpCode::NOT_FOUND);
43
        $I->seeResponseContainsJson([
44
            'data' => [
45
                'configuration' => null
46
            ]
47
        ]);
48
    }
49
50
    public function deleteSomeoneElsesConfiguration(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...
51
    {
52
        $userId = $I->haveInRepository(User::class, [
53
            'first' => 'Tester2',
54
            'last' => 'Tester2',
55
            'email' => '[email protected]',
56
        ]);
57
        $user = $I->grabEntityFromRepository(User::class, ['id' => $userId]);
58
        $I->haveInRepository(DbConfiguration::class, [
59
            'owner' => $user,
60
            'title' => 'Test config 2',
61
            'url' => 'sqlite:///data/db/db2.sqlite',
62
        ]);
63
64
        $I->wantTo('delete someone elses db configuration');
65
        $I->haveHttpHeader('Content-Type', 'application/json');
66
        $I->sendDELETE('/config/2');
67
        $I->seeResponseCodeIs(HttpCode::FORBIDDEN);
68
    }
69
}
70