From 173cc14eef01d9e9d782b8ed82514193825cf846 Mon Sep 17 00:00:00 2001 From: FaerieAI <123517983+FaerieAI@users.noreply.github.com> Date: Fri, 1 Dec 2023 15:13:37 -0500 Subject: [PATCH] Update MemoryTest class --- tests/Features/MemoryTest.php | 67 +++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 tests/Features/MemoryTest.php diff --git a/tests/Features/MemoryTest.php b/tests/Features/MemoryTest.php new file mode 100644 index 000000000..124eb1369 --- /dev/null +++ b/tests/Features/MemoryTest.php @@ -0,0 +1,67 @@ + 'Test Memory', + 'description' => 'This is a test memory', + 'date' => '2021-01-01', + 'location' => 'Test Location', + 'image' => 'test_image.jpg', + ]; + + $this->post(route('memories.store'), $memory) + ->assertStatus(201) + ->assertJson($memory); + } + + public function test_can_get_all_memories() + { + $memories = factory(Memory::class, 5)->create(); + + $this->get(route('memories.index')) + ->assertStatus(200) + ->assertJson($memories->toArray()); + } + + public function test_can_get_memory() + { + $memory = factory(Memory::class)->create(); + + $this->get(route('memories.show', $memory->id)) + ->assertStatus(200) + ->assertJson($memory->toArray()); + } + + public function test_can_update_memory() + { + $memory = factory(Memory::class)->create(); + + $updatedMemory = [ + 'title' => 'Updated Memory', + 'description' => 'This is an updated memory', + 'date' => '2021-01-02', + 'location' => 'Updated Location', + 'image' => 'updated_image.jpg', + ]; + + $this->put(route('memories.update', $memory->id), $updatedMemory) + ->assertStatus(200) + ->assertJson($updatedMemory); + } + + public function test_can_delete_memory() + { + $memory = factory(Memory::class)->create(); + + $this->delete(route('memories.destroy', $memory->id)) + ->assertStatus(204); + } +} \ No newline at end of file