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

AddConfigCest::addCompleteNonUrlConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 9.456
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace codecept;
4
5
use Codeception\Util\HttpCode;
6
use SlayerBirden\DataFlowServer\Doctrine\Hydrator\Strategy\ObscuredStrategy;
7
8
class AddConfigCest
9
{
10
    public function addConfiguration(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...
11
    {
12
        $I->wantTo('create db configuration');
13
        $I->haveHttpHeader('Content-Type', 'application/json');
14
        $I->sendPOST('/config', [
15
            'title' => 'Test config',
16
            'url' => 'test_url',
17
        ]);
18
        $I->seeResponseCodeIs(HttpCode::OK);
19
        $I->seeResponseContainsJson([
20
            'success' => true,
21
            'data' => [
22
                'configuration' => [
23
                    'title' => 'Test config',
24
                    'url' => 'test_url',
25
                ]
26
            ]
27
        ]);
28
    }
29
30
    public function addIncompleteConfig(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...
31
    {
32
        $I->wantTo('create incomplete db configuration');
33
        $I->haveHttpHeader('Content-Type', 'application/json');
34
        $I->sendPOST('/config', [
35
            'title' => 'Test config',
36
            'dbname' => 'test',
37
        ]);
38
        $I->seeResponseCodeIs(HttpCode::BAD_REQUEST);
39
        $I->seeResponseContainsJson([
40
            'success' => false,
41
            'data' => [
42
                'validation' => [
43
                    [
44
                        'field' => 'user',
45
                    ]
46
                ]
47
            ]
48
        ]);
49
    }
50
51
    public function addCompleteNonUrlConfig(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('create incomplete db configuration');
54
        $I->haveHttpHeader('Content-Type', 'application/json');
55
        $I->sendPOST('/config', [
56
            'title' => 'Test config',
57
            'dbname' => 'test',
58
            'user' => 'test-user',
59
            'password' => 'test-pwd',
60
            'port' => '3306',
61
            'host' => 'localhost',
62
            'driver' => 'pdo_mysql'
63
        ]);
64
        $I->seeResponseCodeIs(HttpCode::OK);
65
        $I->seeResponseContainsJson([
66
            'success' => true,
67
            'data' => [
68
                'configuration' => [
69
                    'title' => 'Test config',
70
                    'dbname' => 'test',
71
                    'user' => 'test-user',
72
                    'password' => ObscuredStrategy::OBSCURED_STRING,
73
                    'port' => '3306',
74
                    'host' => 'localhost',
75
                    'driver' => 'pdo_mysql'
76
                ]
77
            ]
78
        ]);
79
    }
80
}
81