1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use Codeception\Util\HttpCode; |
4
|
|
|
|
5
|
|
|
class AddConfigCest |
|
|
|
|
6
|
|
|
{ |
7
|
|
|
public function addConfiguration(ApiTester $I) |
|
|
|
|
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) |
|
|
|
|
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) |
|
|
|
|
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
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.