1 month ago

Unit test keeps failing

Posted 1 month ago by Troj

I make use of laravel-boilerplate but i added some fields to the usertable, for example a username (required field) and some other additional fields. But now the UpdateUserTest keeps failing and i cant figure out what goes wrong. I dont understand the error either.

   FAIL  Tests\Feature\Backend\User\UpdateUserTest
  ✓ an admin can access the edit user page
  ✕ a user can be updated

  Tests:  1 failed, 55 passed, 55 pending

  Failed asserting that a row in the table [users] matches the attributes {     "id": 3,     "type": "admin",     "name": "John Doe",     "username": "JohnDoe",     "email": "[email protected]" }.  Found similar results: [     {         "id": "3",         "type": "user",         "name": "Dr. Cristopher Koss",         "username": "rau.meta",         "gender": "male",         "birthday": "2003-07-01 00:00:00",         "location": "Starkstad",         "description": "Tempore quo inventore ut natus molestiae ipsum. Deleniti vel neque alias consequatur occaecati.",         "email": "[email protected]",         "email_verified_at": "2020-09-01 13:51:22",         "password": "y$JZJyErTJskW93LINSX5L6u2nhyqxFVl7OkBnGbsiFV\/kD1EIKsjIi",         "password_changed_at": null,         "active": "1",         "timezone": null,         "last_login_at": null,         "last_login_ip": null,         "to_be_logged_out": "0",         "provider": null,         "provider_id": null,         "remember_token": "bJFcU0eD8d",         "created_at": "2020-09-01 13:51:22",         "updated_at": "2020-09-01 13:51:22",         "deleted_at": null     } ].

  at tests/Feature/Backend/User/UpdateUserTest.php:63
    59|             'id' => $user->id,
    60|             'type' => User::TYPE_ADMIN,
    61|             'name' => 'John Doe',
    62|             'username' => 'JohnDoe',
  > 63|             'email' => '[email protected]',
    64|         ]);
    66|         $this->assertDatabaseHas('model_has_roles', [
    67|             'role_id' => Role::whereName(config('boilerplate.access.role.admin'))->first()->id,

Anyone a clue where to start looking. Actually in my adminpanel i cant update a user either, so it's not the test thats wrong, but somewhere i've probably forgotton something.

Please sign in or create an account to participate in this conversation.