Skip to content

Commit

Permalink
Update MemoryTest class
Browse files Browse the repository at this point in the history
  • Loading branch information
FaerieAI committed Dec 1, 2023
1 parent fa78bc2 commit 173cc14
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions tests/Features/MemoryTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php

use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;

class MemoryTest extends TestCase
{
use RefreshDatabase;

public function test_can_store_memory()
{
$memory = [
'title' => '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);
}
}

0 comments on commit 173cc14

Please sign in to comment.