Phred/tests/Feature/FeatureTestCaseTest.php
Funky Waddle 54303282d7
Some checks failed
CI / PHP ${{ matrix.php }} (8.1) (push) Has been cancelled
CI / PHP ${{ matrix.php }} (8.2) (push) Has been cancelled
CI / PHP ${{ matrix.php }} (8.3) (push) Has been cancelled
Too many things
2026-01-06 11:02:05 -06:00

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');
}
}
}
}