From ad923742f0efa3b32d0bc785ec4a2ef33591f0a5 Mon Sep 17 00:00:00 2001 From: PovilasKorop Date: Fri, 20 Sep 2024 14:40:29 +0300 Subject: [PATCH] Fix profile and Breeze tests to pass --- app/Http/Requests/ProfileUpdateRequest.php | 3 ++- phpunit.xml | 4 ++-- .../update-profile-information-form.blade.php | 10 ++++++++-- tests/Feature/Auth/RegistrationTest.php | 3 ++- tests/Feature/ProfileTest.php | 11 +++++++---- tests/TestCase.php | 12 +++++++++++- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/app/Http/Requests/ProfileUpdateRequest.php b/app/Http/Requests/ProfileUpdateRequest.php index 93b0022..c0813a7 100644 --- a/app/Http/Requests/ProfileUpdateRequest.php +++ b/app/Http/Requests/ProfileUpdateRequest.php @@ -16,7 +16,8 @@ class ProfileUpdateRequest extends FormRequest public function rules(): array { return [ - 'name' => ['required', 'string', 'max:255'], + 'first_name' => ['required', 'string', 'max:255'], + 'last_name' => ['required', 'string', 'max:255'], 'email' => ['required', 'string', 'lowercase', 'email', 'max:255', Rule::unique(User::class)->ignore($this->user()->id)], ]; } diff --git a/phpunit.xml b/phpunit.xml index 506b9a3..61c031c 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -22,8 +22,8 @@ - - + + diff --git a/resources/views/profile/partials/update-profile-information-form.blade.php b/resources/views/profile/partials/update-profile-information-form.blade.php index 5ae3d35..487f747 100644 --- a/resources/views/profile/partials/update-profile-information-form.blade.php +++ b/resources/views/profile/partials/update-profile-information-form.blade.php @@ -18,11 +18,17 @@ @method('patch')
- - + +
+
+ + + +
+
diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index 352ca78..85e072e 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -8,7 +8,8 @@ test('new users can register', function () { $response = $this->post('/register', [ - 'name' => 'Test User', + 'first_name' => 'Test', + 'last_name' => 'User', 'email' => 'test@example.com', 'password' => 'password', 'password_confirmation' => 'password', diff --git a/tests/Feature/ProfileTest.php b/tests/Feature/ProfileTest.php index 1536458..e2adba6 100644 --- a/tests/Feature/ProfileTest.php +++ b/tests/Feature/ProfileTest.php @@ -18,7 +18,8 @@ $response = $this ->actingAs($user) ->patch('/profile', [ - 'name' => 'Test User', + 'first_name' => 'Test', + 'last_name' => 'User', 'email' => 'test@example.com', ]); @@ -28,7 +29,8 @@ $user->refresh(); - $this->assertSame('Test User', $user->name); + $this->assertSame('Test', $user->first_name); + $this->assertSame('User', $user->last_name); $this->assertSame('test@example.com', $user->email); $this->assertNull($user->email_verified_at); }); @@ -39,7 +41,8 @@ $response = $this ->actingAs($user) ->patch('/profile', [ - 'name' => 'Test User', + 'first_name' => 'Test', + 'last_name' => 'User', 'email' => $user->email, ]); @@ -64,7 +67,7 @@ ->assertRedirect('/'); $this->assertGuest(); - $this->assertNull($user->fresh()); + $this->assertSoftDeleted($user->fresh()); }); test('correct password must be provided to delete account', function () { diff --git a/tests/TestCase.php b/tests/TestCase.php index fe1ffc2..ff555a1 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,9 +2,19 @@ namespace Tests; +use Database\Seeders\PermissionSeeder; +use Database\Seeders\RoleSeeder; use Illuminate\Foundation\Testing\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { - // + protected function setUp(): void + { + parent::setUp(); + + $this->seed([ + RoleSeeder::class, + PermissionSeeder::class, + ]); + } }