Files
Inventory/tests/Api/HealthCheckTest.php
r-dev efc6ec5691 test(api) : add comprehensive API test suite (161 tests)
- Add AbstractApiTestCase with auth helpers and entity factories
- Add tests for all entities: Machine, Piece, Composant, Product, Site,
  ModelType, Constructeur, CustomField, CustomFieldValue, Document,
  MachineComponentLink, MachinePieceLink, MachineProductLink, Profile
- Add controller tests: CommentController, EntityHistory
- Add HealthCheck, Filter, Pagination, Validation, Session tests
- Test auth (401), authorization (403), CRUD, and edge cases

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 13:42:56 +01:00

44 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Tests\Api;
use App\Tests\AbstractApiTestCase;
/**
* @internal
*/
class HealthCheckTest extends AbstractApiTestCase
{
public function testHealthEndpointPublicReturnsMinimalInfo(): void
{
$client = $this->createUnauthenticatedClient();
$client->request('GET', '/api/health');
$this->assertResponseIsSuccessful();
$this->assertJsonContains(['status' => 'ok']);
$data = $client->getResponse()->toArray();
$this->assertArrayNotHasKey('php', $data);
$this->assertArrayNotHasKey('checks', $data);
$this->assertArrayNotHasKey('memory_mb', $data);
}
public function testHealthEndpointAdminReturnsFullInfo(): void
{
$client = $this->createAdminClient();
$client->request('GET', '/api/health');
$this->assertResponseIsSuccessful();
$this->assertJsonContains([
'status' => 'ok',
'checks' => [
'database' => [
'status' => 'ok',
],
],
]);
}
}