mirror of
https://github.com/elyby/mojang-api.git
synced 2025-05-31 14:11:44 +05:30
Implemented API State endpoint
This commit is contained in:
@@ -7,6 +7,7 @@ use Ely\Mojang\Api;
|
||||
use Ely\Mojang\Exception\NoContentException;
|
||||
use Ely\Mojang\Middleware\ResponseConverterMiddleware;
|
||||
use Ely\Mojang\Middleware\RetryMiddleware;
|
||||
use Ely\Mojang\Response\ApiStatus;
|
||||
use Ely\Mojang\Response\Properties\TexturesProperty;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\ClientInterface;
|
||||
@@ -47,6 +48,40 @@ class ApiTest extends TestCase {
|
||||
$this->api->setClient($client);
|
||||
}
|
||||
|
||||
public function testApiStatus() {
|
||||
$this->mockHandler->append($this->createResponse(200, [
|
||||
[
|
||||
'minecraft.net' => 'yellow',
|
||||
],
|
||||
[
|
||||
'session.minecraft.net' => 'green',
|
||||
],
|
||||
[
|
||||
'textures.minecraft.net' => 'red',
|
||||
],
|
||||
]));
|
||||
|
||||
$result = $this->api->apiStatus();
|
||||
|
||||
/** @var \Psr\Http\Message\RequestInterface $request */
|
||||
$request = $this->history[0]['request'];
|
||||
$this->assertSame('https://status.mojang.com/check', (string)$request->getUri());
|
||||
|
||||
$this->assertCount(3, $result);
|
||||
$this->assertContainsOnlyInstancesOf(ApiStatus::class, $result);
|
||||
$this->assertArrayHasKey('minecraft.net', $result);
|
||||
$this->assertSame('minecraft.net', $result['minecraft.net']->getServiceName());
|
||||
$this->assertSame('yellow', $result['minecraft.net']->getStatus());
|
||||
|
||||
$this->assertArrayHasKey('session.minecraft.net', $result);
|
||||
$this->assertSame('session.minecraft.net', $result['session.minecraft.net']->getServiceName());
|
||||
$this->assertSame('green', $result['session.minecraft.net']->getStatus());
|
||||
|
||||
$this->assertArrayHasKey('textures.minecraft.net', $result);
|
||||
$this->assertSame('textures.minecraft.net', $result['textures.minecraft.net']->getServiceName());
|
||||
$this->assertSame('red', $result['textures.minecraft.net']->getStatus());
|
||||
}
|
||||
|
||||
public function testUsernameToUuid() {
|
||||
$this->mockHandler->append($this->createResponse(200, [
|
||||
'id' => '86f6e3695b764412a29820cac1d4d0d6',
|
||||
|
Reference in New Issue
Block a user