-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |