Fix playernamesToUuids request

This commit is contained in:
ErickSkrauch 2019-05-05 16:18:57 +03:00
parent ec351d9346
commit 24138f24b5
2 changed files with 14 additions and 7 deletions

View File

@ -154,7 +154,7 @@ class Api {
throw new InvalidArgumentException('You cannot request more than 100 names per request'); throw new InvalidArgumentException('You cannot request more than 100 names per request');
} }
$response = $this->getClient()->request('POST', 'https://authserver.mojang.com/authenticate', [ $response = $this->getClient()->request('POST', 'https://api.mojang.com/profiles/minecraft', [
'json' => array_values($names), 'json' => array_values($names),
]); ]);
$body = $this->decode($response->getBody()->getContents()); $body = $this->decode($response->getBody()->getContents());

View File

@ -219,8 +219,10 @@ class ApiTest extends TestCase {
/** @var \Psr\Http\Message\RequestInterface $request */ /** @var \Psr\Http\Message\RequestInterface $request */
$request = $this->history[0]['request']; $request = $this->history[0]['request'];
$body = json_decode($request->getBody()->getContents(), true); $this->assertSame('https://api.mojang.com/profiles/minecraft', (string)$request->getUri());
$this->assertSame(['mockusername', 'nonexists'], $body); $this->assertSame('application/json', $request->getHeaderLine('Content-Type'));
$body = $request->getBody()->getContents();
$this->assertJsonStringEqualsJsonString('["mockusername", "nonexists"]', $body);
$this->assertCount(1, $result); $this->assertCount(1, $result);
$this->assertContainsOnlyInstancesOf(ProfileInfo::class, $result); $this->assertContainsOnlyInstancesOf(ProfileInfo::class, $result);
@ -423,10 +425,15 @@ class ApiTest extends TestCase {
$this->api->joinServer('mocked access token', '86f6e3695b764412a29820cac1d4d0d6', 'ad72fe1efe364e6eb78c644a9fba1d30'); $this->api->joinServer('mocked access token', '86f6e3695b764412a29820cac1d4d0d6', 'ad72fe1efe364e6eb78c644a9fba1d30');
/** @var \Psr\Http\Message\RequestInterface $request */ /** @var \Psr\Http\Message\RequestInterface $request */
$request = $this->history[0]['request']; $request = $this->history[0]['request'];
$params = json_decode($request->getBody()->getContents(), true); $body = $request->getBody()->getContents();
$this->assertSame('mocked access token', $params['accessToken']); $this->assertSame('application/json', $request->getHeaderLine('Content-Type'));
$this->assertSame('86f6e3695b764412a29820cac1d4d0d6', $params['selectedProfile']); $this->assertJsonStringEqualsJsonString('
$this->assertSame('ad72fe1efe364e6eb78c644a9fba1d30', $params['serverId']); {
"accessToken": "mocked access token",
"selectedProfile": "86f6e3695b764412a29820cac1d4d0d6",
"serverId": "ad72fe1efe364e6eb78c644a9fba1d30"
}
', $body);
} }
public function testHasJoinedServer() { public function testHasJoinedServer() {