61 lines
1.9 KiB
PHP
61 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature\Api;
|
|
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Tests\TestCase;
|
|
|
|
class ApiPublicEndpointsTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_health_endpoint_is_available(): void
|
|
{
|
|
$this->getJson('/api/v1/health')
|
|
->assertOk();
|
|
}
|
|
|
|
public function test_public_policy_endpoints_are_available(): void
|
|
{
|
|
foreach (['/api/v1/policies/school', '/api/v1/policies/picture'] as $uri) {
|
|
$response = $this->getJson($uri);
|
|
|
|
$this->assertLessThan(500, $response->getStatusCode(), "$uri returned a server error");
|
|
}
|
|
}
|
|
|
|
public function test_public_static_pages_are_available(): void
|
|
{
|
|
foreach (['privacy', 'terms', 'help'] as $page) {
|
|
$response = $this->getJson("/api/v1/pages/$page");
|
|
|
|
$this->assertLessThan(500, $response->getStatusCode(), "/api/v1/pages/$page returned a server error");
|
|
}
|
|
}
|
|
|
|
public function test_public_frontend_content_endpoints_do_not_server_error(): void
|
|
{
|
|
foreach (['/', 'facility', 'team', 'call-to-action', 'testimonial', 'not-found'] as $path) {
|
|
$uri = '/api/v1/frontend'.($path === '/' ? '' : '/'.$path);
|
|
$response = $this->getJson($uri);
|
|
|
|
$this->assertLessThan(500, $response->getStatusCode(), "$uri returned a server error");
|
|
}
|
|
}
|
|
|
|
public function test_registration_captcha_endpoint_returns_captcha_payload(): void
|
|
{
|
|
$this->getJson('/api/v1/auth/register/captcha')
|
|
->assertOk()
|
|
->assertJsonPath('ok', true)
|
|
->assertJsonStructure(['ok', 'captcha']);
|
|
}
|
|
|
|
public function test_invalid_login_payload_is_rejected_cleanly(): void
|
|
{
|
|
$this->postJson('/api/v1/auth/login', [])
|
|
->assertStatus(400)
|
|
->assertJsonPath('status', false);
|
|
}
|
|
}
|