vendredi 17 juillet 2020

Laravel Unit Testing for update method not working

I am trying to unit test the update function in a resource controller and I keep getting an error Call to undefined method assertStatus(). Here is my code: $this->withoutExceptionHandling();

$this->withoutExceptionHandling();
    $timesheet = factory(TimeSheets::class)->create();

    $user = factory(UsersLoginModel::class)->create();

    $data = [
        'subject' => $this->faker->text,
        'subjectmatter' => $this->faker->text,
        'description' => $this->faker->text,
    ];
    ;
    $update = $this->actingAs($user)->json('PATCH','timesheets/update'.$timesheet->id, $data);
    $this->assertStatus(200);

    $this->assertEquals($data['subject'], $timesheet->subject);
    $this->assertEquals($data['subjectmatter'], $timesheet->subjectmatter);
    $this->assertEquals($data['description'], $timesheet->description);

Aucun commentaire:

Enregistrer un commentaire