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-07-27 14:34:21 +02:00
|
|
|
$controller = new class (new Response('{"some":"json"}'), $this->url) 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());
|
|
|
|
}
|
|
|
|
}
|