Remove static create method and clear the constructor. Add CHANGELOG.md

This commit is contained in:
ErickSkrauch
2019-04-07 01:29:16 +02:00
parent e55c5f3b14
commit c5f432b659
4 changed files with 57 additions and 27 deletions

View File

@@ -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));
}