vendredi 6 septembre 2019

Laravel Testing for update user data when logged in

I am doing feature testing for my Laravel application. I am trying to update an authenticated user data. I am using actingAs to authenticate my user in my test code and then trying to post with some data to update that user data. But I am getting "Call to a member function update() on null" error.

This problem only happening on test case. original application working fine.

public function an_authenticated_account_user_with_valid_role_can_change_2fa_option()
    {
      $this->withoutExceptionHandling();
      //preventing middlewares
      $this->withoutMiddleware(\App\Application\Middleware\VerifyCsrfToken::class);
      $attributes = [
        'two_step' => 'no'
      ];
      $response = $this->actingAs($this->validRoleUser, 'account')
                ->post('/account/security/change-2fa', $attributes);
      $response->assertStatus(200);
      $response->assertSee('Please select an option');
    }

I am getting this error message during test above code:

Call to a member function update() on null

Aucun commentaire:

Enregistrer un commentaire