yiisoft /
demo
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Tests\Acceptance; |
||
| 6 | |||
| 7 | use App\Tests\Support\AcceptanceTester; |
||
| 8 | use Codeception\Util\HttpCode; |
||
|
0 ignored issues
–
show
|
|||
| 9 | use Yiisoft\Json\Json; |
||
|
0 ignored issues
–
show
The type
Yiisoft\Json\Json was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 10 | |||
| 11 | final class AuthCest |
||
| 12 | { |
||
| 13 | public function testAuth(AcceptanceTester $I): void |
||
| 14 | { |
||
| 15 | $I->haveHttpHeader('Content-Type', 'application/json'); |
||
| 16 | $I->sendPOST( |
||
| 17 | '/auth/', |
||
| 18 | [ |
||
| 19 | 'login' => 'Opal1144', |
||
| 20 | 'password' => 'Opal1144', |
||
| 21 | ] |
||
| 22 | ); |
||
| 23 | $I->seeResponseCodeIs(HttpCode::OK); |
||
| 24 | $I->seeResponseIsJson(); |
||
| 25 | $I->seeResponseContainsJson( |
||
| 26 | [ |
||
| 27 | 'status' => 'success', |
||
| 28 | 'error_message' => '', |
||
| 29 | 'error_code' => null, |
||
| 30 | ] |
||
| 31 | ); |
||
| 32 | |||
| 33 | $response = Json::decode($I->grabResponse()); |
||
| 34 | $I->seeInDatabase( |
||
| 35 | 'user', |
||
| 36 | [ |
||
| 37 | 'id' => 1, |
||
| 38 | 'token' => $response['data']['token'], |
||
| 39 | ] |
||
| 40 | ); |
||
| 41 | } |
||
| 42 | |||
| 43 | public function logout(AcceptanceTester $I): void |
||
| 44 | { |
||
| 45 | $I->haveHttpHeader( |
||
| 46 | 'X-Api-Key', |
||
| 47 | 'lev1ZsWCzqrMlXRI2sT8h4ApYpSgBMl1xf6D4bCRtiKtDqw6JN36yLznargilQ_rEJz9zTfcUxm53PLODCToF9gGin38Rd4NkhQPOVeH5VvZvBaQlUg64E6icNCubiAv' |
||
| 48 | ); |
||
| 49 | |||
| 50 | $I->sendPOST( |
||
| 51 | '/logout/' |
||
| 52 | ); |
||
| 53 | |||
| 54 | $I->seeResponseCodeIs(HttpCode::OK); |
||
| 55 | $I->seeResponseIsJson(); |
||
| 56 | $I->seeResponseContainsJson( |
||
| 57 | [ |
||
| 58 | 'status' => 'success', |
||
| 59 | 'error_message' => '', |
||
| 60 | 'error_code' => null, |
||
| 61 | ] |
||
| 62 | ); |
||
| 63 | |||
| 64 | $I->dontSeeInDatabase( |
||
| 65 | 'user', |
||
| 66 | [ |
||
| 67 | 'id' => 1, |
||
| 68 | 'token' => 'lev1ZsWCzqrMlXRI2sT8h4ApYpSgBMl1xf6D4bCRtiKtDqw6JN36yLznargilQ_rEJz9zTfcUxm53PLODCToF9gGin38Rd4NkhQPOVeH5VvZvBaQlUg64E6icNCubiAv', |
||
| 69 | ] |
||
| 70 | ); |
||
| 71 | } |
||
| 72 | |||
| 73 | public function logoutWithBadToken(AcceptanceTester $I): void |
||
| 74 | { |
||
| 75 | $I->haveHttpHeader( |
||
| 76 | 'X-Api-Key', |
||
| 77 | 'bad-token' |
||
| 78 | ); |
||
| 79 | |||
| 80 | $I->haveHttpHeader( |
||
| 81 | 'Accept', |
||
| 82 | 'application/json' |
||
| 83 | ); |
||
| 84 | |||
| 85 | $I->sendPOST( |
||
| 86 | '/logout/' |
||
| 87 | ); |
||
| 88 | |||
| 89 | $I->seeResponseCodeIs(HttpCode::UNAUTHORIZED); |
||
| 90 | $I->seeResponseIsJson(); |
||
| 91 | $I->seeResponseContainsJson( |
||
| 92 | [ |
||
| 93 | 'status' => 'failed', |
||
| 94 | 'error_message' => 'Unauthorised request', |
||
| 95 | 'error_code' => HttpCode::UNAUTHORIZED, |
||
| 96 | 'data' => null, |
||
| 97 | ] |
||
| 98 | ); |
||
| 99 | } |
||
| 100 | } |
||
| 101 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths