test: functional test infrastructure (ApiTestCase + db_test + JWT helpers)
- .env.test points at db_test (doctrine when@test appends _test suffix) - ApiTestCase: WebTestCase base with createUser/jwtFor/authJson helpers - InfraSmokeTest: proves boot + DB + JWT auth pipeline works (/health 200, unauth /oauth/userinfo 401, JWT-auth userinfo 200) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Tests\Smoke;
|
||||
|
||||
use App\Tests\ApiTestCase;
|
||||
|
||||
/**
|
||||
* Confirms the test infrastructure itself works: app boots, /health serves,
|
||||
* and JWT-authenticated requests reach protected endpoints.
|
||||
*/
|
||||
class InfraSmokeTest extends ApiTestCase
|
||||
{
|
||||
public function testHealthIsPublicAnd200(): void
|
||||
{
|
||||
$this->client->request('GET', '/health');
|
||||
$this->assertSame(200, $this->responseCode());
|
||||
}
|
||||
|
||||
public function testUnauthenticatedApiIs401(): void
|
||||
{
|
||||
$this->client->request('GET', '/oauth/userinfo');
|
||||
$this->assertSame(401, $this->responseCode());
|
||||
}
|
||||
|
||||
public function testJwtAuthReachesUserInfo(): void
|
||||
{
|
||||
$user = $this->createUser(['ROLE_USER']);
|
||||
$body = $this->authJson('GET', '/oauth/userinfo', $user);
|
||||
|
||||
$this->assertSame(200, $this->responseCode());
|
||||
$this->assertTrue($body['success']);
|
||||
$this->assertSame($user->getUuid(), $body['data']['uuid']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user