From 6be48846b08a9c73817a6f4686f8b75b61b033d1 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Mon, 1 Apr 2024 20:29:47 +0200 Subject: [PATCH] add test --- tests/Feature/ToDoTest.php | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/Feature/ToDoTest.php b/tests/Feature/ToDoTest.php index 077c763..541482f 100644 --- a/tests/Feature/ToDoTest.php +++ b/tests/Feature/ToDoTest.php @@ -11,11 +11,10 @@ beforeEach(function () { test('an user can add todo', function () { Sanctum::actingAs($this->user); - $response = $this->post('api/todos', [ + $this->post('api/todos', [ 'name' => 'Test', - ]); - - $response->assertStatus(201) + ]) + ->assertStatus(201) ->assertJson([ 'user_id' => $this->user->id, 'name' => 'Test', @@ -77,9 +76,8 @@ test('an user can retrieve a to do', function () { $toDo = $toDos[rand(0, 9)]; - $response = $this->get('api/todos/'.$toDo->id); - - $response->assertOk() + $this->get('api/todos/'.$toDo->id) + ->assertOk() ->assertJson([ 'id' => $toDo->id, 'user_id' => $toDo->user_id, @@ -128,9 +126,8 @@ test('an user can delete a to do', function () { $toDo = $toDos[rand(0, 9)]; - $response = $this->delete('api/todos/'.$toDo->id); - - $response->assertNoContent(); + $this->delete('api/todos/'.$toDo->id) + ->assertNoContent(); expect(ToDo::all())->toHaveCount(9); });