36 lines
1.4 KiB
PHP
36 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace Tests\Feature;
|
|
|
|
use App\Models\User;
|
|
use Illuminate\Auth\Notifications\VerifyEmail;
|
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
use Illuminate\Support\Facades\Notification;
|
|
use Inertia\Testing\AssertableInertia as Assert;
|
|
use Tests\TestCase;
|
|
|
|
class ManagementAccessTest extends TestCase
|
|
{
|
|
use RefreshDatabase;
|
|
|
|
public function test_setup_can_be_deferred_without_creating_an_account(): void
|
|
{
|
|
$this->get('/acesso-gestao')->assertOk()->assertInertia(fn (Assert $page) => $page
|
|
->component('management-access')->where('auth.user', null)->where('auth.canManagePortal', false));
|
|
$this->assertDatabaseCount('users', 0);
|
|
}
|
|
|
|
public function test_unverified_manager_can_view_setup_and_request_verification_but_cannot_manage(): void
|
|
{
|
|
Notification::fake();
|
|
$user = User::factory()->unverified()->create();
|
|
config(['portal.managers' => [$user->email]]);
|
|
$this->actingAs($user)->get('/acesso-gestao')->assertOk()
|
|
->assertInertia(fn (Assert $page) => $page->where('auth.canManagePortal', false));
|
|
$this->get('/management/interests')->assertRedirect(route('verification.notice'));
|
|
$this->post(route('verification.send'))->assertRedirect();
|
|
Notification::assertSentTo($user, VerifyEmail::class);
|
|
$this->assertFalse($user->fresh()->hasVerifiedEmail());
|
|
}
|
|
}
|