#4-public-user-profile
This commit is contained in:
26
tests/Feature/AuthorProfileTest.php
Normal file
26
tests/Feature/AuthorProfileTest.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
|
||||
test('author profile can be viewed by username', function () {
|
||||
$author = User::factory()->create([
|
||||
'name' => 'Amarul Author',
|
||||
'username' => 'amarul',
|
||||
'email' => 'amarul@example.com',
|
||||
]);
|
||||
$role = Role::query()->create(['name' => 'Writer']);
|
||||
|
||||
$author->roles()->attach($role);
|
||||
|
||||
$this->get('/author/amarul')
|
||||
->assertSuccessful()
|
||||
->assertSee('Amarul Author')
|
||||
->assertSee('@amarul')
|
||||
->assertSee('Writer')
|
||||
->assertDontSee('amarul@example.com');
|
||||
});
|
||||
|
||||
test('author profile returns not found for unknown username', function () {
|
||||
$this->get('/author/missing-author')->assertNotFound();
|
||||
});
|
||||
Reference in New Issue
Block a user