#4-public-user-profile
This commit is contained in:
@@ -9,6 +9,7 @@ test('registration screen can be rendered', function () {
|
||||
test('new users can register', function () {
|
||||
$response = $this->post('/register', [
|
||||
'name' => 'Test User',
|
||||
'username' => 'test-user',
|
||||
'email' => 'test@example.com',
|
||||
'password' => 'password',
|
||||
'password_confirmation' => 'password',
|
||||
|
||||
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();
|
||||
});
|
||||
@@ -23,6 +23,7 @@ test('authenticated users can view the user edit page', function () {
|
||||
->assertSuccessful()
|
||||
->assertSee('Edit User')
|
||||
->assertSee($user->name)
|
||||
->assertSee($user->username)
|
||||
->assertSee($user->email)
|
||||
->assertSee('Roles')
|
||||
->assertSee('Admin')
|
||||
@@ -39,6 +40,7 @@ test('authenticated users can update a user', function () {
|
||||
->actingAs($actingUser)
|
||||
->patch("/user/{$user->id}", [
|
||||
'name' => 'Updated User',
|
||||
'username' => 'updated-user',
|
||||
'email' => 'updated@example.com',
|
||||
'roles' => [$adminRole->id, $editorRole->id],
|
||||
]);
|
||||
@@ -49,6 +51,7 @@ test('authenticated users can update a user', function () {
|
||||
$user->refresh();
|
||||
|
||||
$this->assertSame('Updated User', $user->name);
|
||||
$this->assertSame('updated-user', $user->username);
|
||||
$this->assertSame('updated@example.com', $user->email);
|
||||
expect($user->roles()->pluck('roles.id')->all())
|
||||
->toMatchArray([$adminRole->id, $editorRole->id]);
|
||||
@@ -65,6 +68,7 @@ test('user roles can be cleared by submitting no roles', function () {
|
||||
->actingAs($actingUser)
|
||||
->patch("/user/{$user->id}", [
|
||||
'name' => $user->name,
|
||||
'username' => $user->username,
|
||||
'email' => $user->email,
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user