mirror of
https://github.com/elyby/mojang-api.git
synced 2025-05-31 14:11:44 +05:30
Remove static create method and clear the constructor. Add CHANGELOG.md
This commit is contained in:
@@ -9,6 +9,7 @@ use Ely\Mojang\Middleware\ResponseConverterMiddleware;
|
||||
use Ely\Mojang\Middleware\RetryMiddleware;
|
||||
use Ely\Mojang\Response\Properties\TexturesProperty;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\ClientInterface;
|
||||
use GuzzleHttp\Handler\MockHandler;
|
||||
use GuzzleHttp\HandlerStack;
|
||||
use GuzzleHttp\Middleware;
|
||||
@@ -42,11 +43,8 @@ class ApiTest extends TestCase {
|
||||
$handlerStack->after('http_errors', ResponseConverterMiddleware::create(), 'mojang_responses');
|
||||
$handlerStack->push(RetryMiddleware::create(), 'retry');
|
||||
$client = new Client(['handler' => $handlerStack]);
|
||||
$this->api = new Api($client);
|
||||
}
|
||||
|
||||
public function testCreate() {
|
||||
$this->assertInstanceOf(Api::class, Api::create());
|
||||
$this->api = new Api();
|
||||
$this->api->setClient($client);
|
||||
}
|
||||
|
||||
public function testUsernameToUuid() {
|
||||
@@ -340,6 +338,15 @@ class ApiTest extends TestCase {
|
||||
$this->api->hasJoinedServer('MockedUsername', 'ad72fe1efe364e6eb78c644a9fba1d30');
|
||||
}
|
||||
|
||||
public function testGetClient() {
|
||||
$child = new class extends Api {
|
||||
public function getDefaultClient() {
|
||||
return $this->getClient();
|
||||
}
|
||||
};
|
||||
$this->assertInstanceOf(ClientInterface::class, $child->getDefaultClient());
|
||||
}
|
||||
|
||||
private function createResponse(int $statusCode, array $response): ResponseInterface {
|
||||
return new Response($statusCode, ['content-type' => 'json'], json_encode($response));
|
||||
}
|
||||
|
Reference in New Issue
Block a user