<?php

namespace AsyncAws\Athena\Tests\Unit\Result;

use AsyncAws\Athena\Result\GetDatabaseOutput;
use AsyncAws\Athena\ValueObject\Database;
use AsyncAws\Core\Response;
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
use AsyncAws\Core\Test\TestCase;
use Psr\Log\NullLogger;
use Symfony\Component\HttpClient\MockHttpClient;

class GetDatabaseOutputTest extends TestCase
{
    public function testGetDatabaseOutput(): void
    {
        // see https://docs.aws.amazon.com/athena/latest/APIReference/API_GetDatabase.html
        $response = new SimpleMockedResponse('{
   "Database": {
      "Description": "iad international async_aws",
      "Name": "Iad2023",
      "Parameters": {
         "contrib" : "iad"
      }
   }
}');

        $client = new MockHttpClient($response);
        $result = new GetDatabaseOutput(new Response($client->request('POST', 'http://localhost'), $client, new NullLogger()));

        self::assertInstanceOf(Database::class, $result->getDatabase());
        self::assertSame('Iad2023', $result->getDatabase()->getName());
    }
}
