2023-07-23 13:52:33 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace Engelsystem\Test\Unit\Controllers\Api;
|
|
|
|
|
|
|
|
use Engelsystem\Controllers\Api\RoomsController;
|
|
|
|
use Engelsystem\Http\Response;
|
|
|
|
use Engelsystem\Models\Room;
|
|
|
|
|
|
|
|
class RoomsControllerTest extends ApiBaseControllerTest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @covers \Engelsystem\Controllers\Api\RoomsController::index
|
|
|
|
*/
|
|
|
|
public function testIndex(): void
|
|
|
|
{
|
|
|
|
$this->initDatabase();
|
|
|
|
Room::factory(3)->create();
|
|
|
|
|
2023-07-27 14:34:21 +02:00
|
|
|
$controller = new RoomsController(new Response(), $this->url);
|
2023-07-23 13:52:33 +02:00
|
|
|
|
|
|
|
$response = $controller->index();
|
|
|
|
$this->validateApiResponse('/rooms', 'get', $response);
|
|
|
|
|
|
|
|
$this->assertEquals(['application/json'], $response->getHeader('content-type'));
|
|
|
|
$this->assertJson($response->getContent());
|
|
|
|
|
|
|
|
$data = json_decode($response->getContent(), true);
|
|
|
|
$this->assertArrayHasKey('data', $data);
|
|
|
|
$this->assertCount(3, $data['data']);
|
|
|
|
}
|
|
|
|
}
|