1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace App\Tests\Acceptance; |
6
|
|
|
|
7
|
|
|
use App\Tests\AcceptanceTester; |
8
|
|
|
use Codeception\Util\HttpCode; |
9
|
|
|
|
10
|
|
|
final class UserCest |
11
|
|
|
{ |
12
|
|
|
public function index(AcceptanceTester $I): void |
13
|
|
|
{ |
14
|
|
|
$I->haveHttpHeader( |
15
|
|
|
'X-Api-Key', |
16
|
|
|
'lev1ZsWCzqrMlXRI2sT8h4ApYpSgBMl1xf6D4bCRtiKtDqw6JN36yLznargilQ_rEJz9zTfcUxm53PLODCToF9gGin38Rd4NkhQPOVeH5VvZvBaQlUg64E6icNCubiAv' |
17
|
|
|
); |
18
|
|
|
$I->sendGET('/users/'); |
19
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
20
|
|
|
$I->seeResponseIsJson(); |
21
|
|
|
$I->seeResponseContainsJson( |
22
|
|
|
[ |
23
|
|
|
'status' => 'success', |
24
|
|
|
'error_message' => '', |
25
|
|
|
'error_code' => null, |
26
|
|
|
'data' => [ |
27
|
|
|
'users' => [ |
28
|
|
|
[ |
29
|
|
|
'login' => 'Athena7928', |
30
|
|
|
'created_at' => '26.07.2020 20:18:11', |
31
|
|
|
], |
32
|
|
|
], |
33
|
|
|
], |
34
|
|
|
] |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function view(AcceptanceTester $I): void |
39
|
|
|
{ |
40
|
|
|
$I->haveHttpHeader( |
41
|
|
|
'X-Api-Key', |
42
|
|
|
'lev1ZsWCzqrMlXRI2sT8h4ApYpSgBMl1xf6D4bCRtiKtDqw6JN36yLznargilQ_rEJz9zTfcUxm53PLODCToF9gGin38Rd4NkhQPOVeH5VvZvBaQlUg64E6icNCubiAv' |
43
|
|
|
); |
44
|
|
|
$I->sendGET('/users/1'); |
45
|
|
|
$I->seeResponseCodeIs(HttpCode::OK); |
46
|
|
|
$I->seeResponseIsJson(); |
47
|
|
|
$I->seeResponseContainsJson( |
48
|
|
|
[ |
49
|
|
|
'status' => 'success', |
50
|
|
|
'error_message' => '', |
51
|
|
|
'error_code' => null, |
52
|
|
|
'data' => [ |
53
|
|
|
'user' => [ |
54
|
|
|
'login' => 'Opal1144', |
55
|
|
|
'created_at' => '26.07.2020 20:18:11', |
56
|
|
|
], |
57
|
|
|
], |
58
|
|
|
] |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function viewBadId(AcceptanceTester $I): void |
63
|
|
|
{ |
64
|
|
|
$I->haveHttpHeader( |
65
|
|
|
'X-Api-Key', |
66
|
|
|
'lev1ZsWCzqrMlXRI2sT8h4ApYpSgBMl1xf6D4bCRtiKtDqw6JN36yLznargilQ_rEJz9zTfcUxm53PLODCToF9gGin38Rd4NkhQPOVeH5VvZvBaQlUg64E6icNCubiAv' |
67
|
|
|
); |
68
|
|
|
$I->sendGET('/users/1000'); |
69
|
|
|
$I->seeResponseCodeIs(HttpCode::NOT_FOUND); |
70
|
|
|
$I->seeResponseIsJson(); |
71
|
|
|
$I->seeResponseContainsJson( |
72
|
|
|
[ |
73
|
|
|
'status' => 'failed', |
74
|
|
|
'error_message' => 'Entity not found', |
75
|
|
|
'error_code' => HttpCode::NOT_FOUND, |
76
|
|
|
'data' => null, |
77
|
|
|
] |
78
|
|
|
); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
public function notAllowedMethod(AcceptanceTester $I): void |
82
|
|
|
{ |
83
|
|
|
$I->haveHttpHeader( |
84
|
|
|
'X-Api-Key', |
85
|
|
|
'lev1ZsWCzqrMlXRI2sT8h4ApYpSgBMl1xf6D4bCRtiKtDqw6JN36yLznargilQ_rEJz9zTfcUxm53PLODCToF9gGin38Rd4NkhQPOVeH5VvZvBaQlUg64E6icNCubiAv' |
86
|
|
|
); |
87
|
|
|
$I->sendPut('/users/1'); |
88
|
|
|
$I->seeResponseCodeIs(HttpCode::METHOD_NOT_ALLOWED); |
89
|
|
|
$I->seeResponseIsJson(); |
90
|
|
|
$I->seeResponseContainsJson( |
91
|
|
|
[ |
92
|
|
|
'status' => 'failed', |
93
|
|
|
'error_message' => 'Method is not implemented yet', |
94
|
|
|
'error_code' => HttpCode::METHOD_NOT_ALLOWED, |
95
|
|
|
'data' => null, |
96
|
|
|
] |
97
|
|
|
); |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|