File: /home/xedaptot/be.naniguide.com/tests/Feature/UnauthenticatedResponseTest.php
<?php
/**
* Feature tests for the auth-failure response shape after the Laravel 12
* exception handler was wired up in bootstrap/app.php (replacing the dead
* app/Exceptions/Handler.php). Covers the three branches of the renderer:
* - JSON request → 401 with `{"message":"Unauthenticated."}`
* - HTML admin path → redirect to refactor.admin.login
* - HTML customer → redirect to the `login` route
*/
uses(\Tests\TestCase::class);
test('JSON 401 returns the framework-default message shape', function () {
$response = $this->getJson('/rui/admin');
expect($response->status())->toBe(401);
expect($response->json('message'))->toBe('Unauthenticated.');
});
test('HTML admin path 401 redirects to the admin login', function () {
$response = $this->get('/rui/admin');
$response->assertRedirect(route('refactor.admin.login'));
});
test('HTML customer path 401 redirects to the customer login', function () {
$response = $this->get('/dashboard');
$response->assertRedirect(route('login'));
});