Fixes #27. Serialize empty textures as an object

This commit is contained in:
ErickSkrauch
2022-12-05 22:50:22 +01:00
parent 26b2168ae3
commit b113beb78e
4 changed files with 40 additions and 2 deletions

View File

@@ -36,6 +36,10 @@ return [
}
public function profile(string $username, bool $signed = false): ?array {
if ($username === 'NotSynchronized') {
return null;
}
$account = common\models\Account::findOne(['username' => $username]);
$uuid = $account ? str_replace('-', '', $account->uuid) : '00000000000000000000000000000000';

View File

@@ -1,4 +1,6 @@
<?php
declare(strict_types=1);
namespace api\tests\functional\sessionserver;
use api\tests\_pages\SessionServerRoute;
@@ -34,6 +36,20 @@ class ProfileCest {
$I->canSeeValidTexturesResponse('Admin', 'df936908b2e1544d96f82977ec213022', true);
}
public function getProfileWhichIsNotSynchronized(SessionServerSteps $I) {
$I->wantTo('get info about player textures by uuid');
$this->route->profile('7ff4a9dcd1774ea0ab567f31218004f9', true);
// Ensure that empty textures was serialized as an empty object
$I->seeResponseIsJson();
$I->canSeeResponseContainsJson([
'id' => '7ff4a9dcd1774ea0ab567f31218004f9',
]);
$texturesValue = $I->grabDataFromResponseByJsonPath('$.properties[0].value')[0];
$texturesJson = base64_decode($texturesValue);
$I->assertStringContainsString('"textures":{}', $texturesJson);
}
public function directCallWithoutUuidPart(FunctionalTester $I) {
$I->wantTo('call profile route without passing uuid');
$this->route->profile('');