2016-09-21 13:43:43 +05:30
|
|
|
<?php
|
2019-02-21 01:28:52 +05:30
|
|
|
namespace api\tests\functional\authserver;
|
2016-09-21 13:43:43 +05:30
|
|
|
|
2019-02-21 01:28:52 +05:30
|
|
|
use api\tests\_pages\MojangApiRoute;
|
|
|
|
use api\tests\FunctionalTester;
|
2019-02-23 04:41:57 +05:30
|
|
|
use Faker\Provider\Uuid;
|
2016-09-21 13:43:43 +05:30
|
|
|
|
|
|
|
class UuidToUsernamesHistoryCest {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var MojangApiRoute
|
|
|
|
*/
|
|
|
|
private $route;
|
|
|
|
|
|
|
|
public function _before(FunctionalTester $I) {
|
|
|
|
$this->route = new MojangApiRoute($I);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsernameByUuid(FunctionalTester $I) {
|
|
|
|
$I->wantTo('get usernames history by uuid for user, without history');
|
|
|
|
$this->route->usernamesByUuid('df936908b2e1544d96f82977ec213022');
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
[
|
|
|
|
'name' => 'Admin',
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getUsernameByUuidWithHistory(FunctionalTester $I) {
|
|
|
|
$I->wantTo('get usernames history by dashed uuid and expect history with time marks');
|
|
|
|
$this->route->usernamesByUuid('d6b3e935-6466-4cb8-86db-b5df91ae6541');
|
|
|
|
$I->canSeeResponseCodeIs(200);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
[
|
|
|
|
'name' => 'klik202',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => 'klik201',
|
|
|
|
'changedToAt' => 1474404141000,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'name' => 'klik202',
|
|
|
|
'changedToAt' => 1474404143000,
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function passWrongUuid(FunctionalTester $I) {
|
|
|
|
$I->wantTo('get user username by some wrong uuid');
|
|
|
|
$this->route->usernamesByUuid(Uuid::uuid());
|
|
|
|
$I->canSeeResponseCodeIs(204);
|
|
|
|
$I->canSeeResponseEquals('');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function passWrongUuidFormat(FunctionalTester $I) {
|
|
|
|
$I->wantTo('call profile route with invalid uuid string');
|
|
|
|
$this->route->usernamesByUuid('bla-bla-bla');
|
|
|
|
$I->canSeeResponseCodeIs(400);
|
|
|
|
$I->canSeeResponseIsJson();
|
|
|
|
$I->canSeeResponseContainsJson([
|
|
|
|
'error' => 'IllegalArgumentException',
|
|
|
|
'errorMessage' => 'Invalid uuid format.',
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|