27 lines
717 B
PHP
27 lines
717 B
PHP
<?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();
|
|
});
|