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>
This commit is contained in:
43
tests/Api/HealthCheckTest.php
Normal file
43
tests/Api/HealthCheckTest.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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',
|
||||
],
|
||||
],
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user