I'm experimenting with Laravel. Now I've got a problem. I have activated SoftDeletes in the User-Model.
Whenever I run the tests I get ONE failed test and it is the "test_user_accounts_can_be_deleted" method.
I get the following response:
Failed asserting that App\Models\User Object #2494 (
'connection' => 'mysql',
'table' => 'users',
'primaryKey' => 'id',
'keyType' => 'int',
'incrementing' => true,
'with' => Array &0 [],
'withCount' => Array &1 [],
'preventsLazyLoading' => false,
'perPage' => 15,
'exists' => true,
'wasRecentlyCreated' => false,
'escapeWhenCastingToString' => false,
'attributes' => Array &2 [
'id' => 4,
'name' => 'Mr. Shaun Rempel II',
'email' => '[email protected]',
'email_verified_at' => '2024-01-20 19:52:53',
'password' => 'yIXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'two_factor_confirmed_at' => null,
'remember_token' => 'GEMPVprS7b8zg20eUNIEnC9HoK3BACIldEKSV9Ek8smmzGB8sDXBArj74lgC',
'current_team_id' => null,
'profile_photo_path' => null,
'deleted_at' => '2024-01-20 19:52:53',
'created_at' => '2024-01-20 19:52:53',
'updated_at' => '2024-01-20 19:52:53',
'isAdmin' => 0,
],
'original' => Array &3 [
'id' => 4,
'name' => 'Mr. Shaun Rempel II',
'email' => '[email protected]',
'email_verified_at' => '2024-01-20 19:52:53',
'password' => 'yIXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi',
'two_factor_secret' => null,
'two_factor_recovery_codes' => null,
'two_factor_confirmed_at' => null,
'remember_token' => 'GEMPVprS7b8zg20eUNIEnC9HoK3BACIldEKSV9Ek8smmzGB8sDXBArj74lgC',
'current_team_id' => null,
'profile_photo_path' => null,
'deleted_at' => '2024-01-20 19:52:53',
'created_at' => '2024-01-20 19:52:53',
'updated_at' => '2024-01-20 19:52:53',
'isAdmin' => 0,
],
'changes' => Array &4 [],
'casts' => Array &5 [
'email_verified_at' => 'datetime',
'deleted_at' => 'datetime',
'isAdmin' => 'boolean',
],
'classCastCache' => Array &6 [],
'attributeCastCache' => Array &7 [],
'dateFormat' => null,
'appends' => Array &8 [
0 => 'profile_photo_url',
],
'dispatchesEvents' => Array &9 [],
'observables' => Array &10 [],
'relations' => Array &11 [],
'touches' => Array &12 [],
'timestamps' => true,
'usesUniqueIds' => false,
'hidden' => Array &13 [
0 => 'password',
1 => 'remember_token',
2 => 'two_factor_recovery_codes',
3 => 'two_factor_secret',
],
'visible' => Array &14 [],
'fillable' => Array &15 [
0 => 'name',
1 => 'email',
2 => 'password',
3 => 'isAdmin',
],
'guarded' => Array &16 [
0 => '*',
],
'rememberTokenName' => 'remember_token',
'accessToken' => null,
'forceDeleting' => false,
) is null.
at tests\Feature\DeleteAccountTest.php:27
23▕ $response = $this->delete('/user', [
24▕ 'password' => 'password',
25▕ ]);
26▕
➜ 27▕ $this->assertNull($user->fresh());
28▕ }
29▕
30▕ public function test_correct_password_must_be_provided_before_account_can_be_deleted(): void
31▕ {
1 tests\Feature\DeleteAccountTest.php:27
However: When I try it in the app everything works totally fine. I'm using PHPStorm on Windows 11 as editor.
What's going on here? BTW: It does NOT matter which database I use (mysql or sqlinte).
I use Jetstream + Inertia + Vue