49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
|
|
<?php
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
namespace Phred\Tests\Feature;
|
||
|
|
|
||
|
|
use Phred\Testing\TestCase;
|
||
|
|
|
||
|
|
class FeatureTestCaseTest extends TestCase
|
||
|
|
{
|
||
|
|
public function test_health_check(): void
|
||
|
|
{
|
||
|
|
$this->get('/_phred/health')
|
||
|
|
->assertOk()
|
||
|
|
->assertJson([
|
||
|
|
'ok' => true,
|
||
|
|
'framework' => 'Phred'
|
||
|
|
]);
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_not_found(): void
|
||
|
|
{
|
||
|
|
$this->get('/non-existent-route')
|
||
|
|
->assertNotFound();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function test_api_group_auto_mounting(): void
|
||
|
|
{
|
||
|
|
// Disable debug for this assertion to avoid stack traces in 'detail'
|
||
|
|
$originalDebug = getenv('APP_DEBUG');
|
||
|
|
putenv('APP_DEBUG=false');
|
||
|
|
try {
|
||
|
|
// /_phred/error is in routes/api.php, so it should have 'api' middleware group.
|
||
|
|
// It returns RFC7807 (Problem Details) because it's NOT JSON:API format by default in this test env.
|
||
|
|
$this->get('/_phred/error')
|
||
|
|
->assertStatus(500)
|
||
|
|
->assertJson([
|
||
|
|
'title' => 'RuntimeException',
|
||
|
|
'detail' => 'Boom'
|
||
|
|
]);
|
||
|
|
} finally {
|
||
|
|
if ($originalDebug !== false) {
|
||
|
|
putenv("APP_DEBUG=$originalDebug");
|
||
|
|
} else {
|
||
|
|
putenv('APP_DEBUG');
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|