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

AddConfigCest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 73
c 0
b 0
f 0
rs 10

3 Methods

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