2023-07-22 20:35:45 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Controllers\Api;
|
|
|
|
|
|
|
|
use Engelsystem\Controllers\Api\ApiController;
|
|
|
|
use Engelsystem\Http\Response;
|
|
|
|
|
|
|
|
class ApiControllerTest extends ApiBaseControllerTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\Api\ApiController::__construct
|
|
|
|
*/
|
|
|
|
public function testConstruct(): void
|
|
|
|
{
|
2023-11-15 02:29:58 +01:00
|
|
|
$controller = new class (new Response('{"some":"json"}')) extends ApiController {
|
2023-07-22 20:35:45 +02:00
|
|
|
public function getResponse(): Response
|
|
|
|
{
|
|
|
|
return $this->response;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
$response = $controller->getResponse();
|
|
|
|
|
|
|
|
$this->assertEquals(['application/json'], $response->getHeader('content-type'));
|
|
|
|
$this->assertJson($response->getContent());
|
|
|
|
|
|
|
|
$this->assertEquals(['*'], $response->getHeader('access-control-allow-origin'));
|
|
|
|
$this->assertJson($response->getContent());
|
|
|
|
}
|
|
|
|
}
|