Completed
Push — master ( 298ac7...0024da )
by Oleg
12:58
created

AddConfigCest::_before()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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