2017-04-03 17:24:33 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional\internal;
|
2017-04-03 17:24:33 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\_pages\InternalRoute;
|
|
|
|
use api\tests\functional\_steps\OauthSteps;
|
|
|
|
use api\tests\FunctionalTester;
|
2017-04-03 17:24:33 +05:30
|
|
|
|
|
|
|
class InfoCest {
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
private InternalRoute $route;
|
2017-04-03 17:24:33 +05:30
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function _before(FunctionalTester $I): void {
|
2017-04-03 17:24:33 +05:30
|
|
|
$this->route = new InternalRoute($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testGetInfoById(OauthSteps $I): void {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['internal_account_info']);
|
2017-04-03 17:24:33 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
$this->route->info('id', '1');
|
2017-04-03 17:24:33 +05:30
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testGetInfoByUuid(OauthSteps $I): void {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['internal_account_info']);
|
2017-04-03 17:24:33 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->info('uuid', 'df936908-b2e1-544d-96f8-2977ec213022');
|
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testGetInfoByUsername(OauthSteps $I): void {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['internal_account_info']);
|
2017-04-03 17:24:33 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->info('username', 'admin');
|
|
|
|
$this->expectSuccessResponse($I);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testInvalidParams(OauthSteps $I): void {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['internal_account_info']);
|
2017-04-03 17:24:33 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->info('', '');
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
}
|
|
|
|
|
2024-12-02 15:40:55 +05:30
|
|
|
public function testAccountNotFound(OauthSteps $I): void {
|
2017-09-19 22:36:16 +05:30
|
|
|
$accessToken = $I->getAccessTokenByClientCredentialsGrant(['internal_account_info']);
|
2017-04-03 17:24:33 +05:30
|
|
|
$I->amBearerAuthenticated($accessToken);
|
|
|
|
|
|
|
|
$this->route->info('username', 'this-user-not-exists');
|
|
|
|
$I->canSeeResponseCodeIs(404);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param OauthSteps $I
|
|
|
|
*/
|
|
|
|
private function expectSuccessResponse(OauthSteps $I): void {
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'id' => 1,
|
|
|
|
'uuid' => 'df936908-b2e1-544d-96f8-2977ec213022',
|
|
|
|
'email' => 'admin@ely.by',
|
|
|
|
'username' => 'Admin',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|