mirror of
https://github.com/pacnpal/thrillwiki_laravel.git
synced 2025-12-20 07:11:09 -05:00
feat: Complete implementation of Ride CRUD system with full functionality and testing
- Added Ride CRUD system documentation detailing implementation summary, generated components, and performance metrics. - Created Ride CRUD system prompt for future development with core requirements and implementation strategy. - Established relationships between rides and parks, ensuring Django parity and optimized performance. - Implemented waiting for user command execution documentation for Park CRUD generation. - Developed Livewire components for RideForm and RideList with basic structure. - Created feature tests for Park and Ride components, ensuring proper rendering and functionality. - Added comprehensive tests for ParkController, ReviewImage, and ReviewReport models, validating CRUD operations and relationships.
This commit is contained in:
106
tests/Feature/ParkControllerTest.php
Normal file
106
tests/Feature/ParkControllerTest.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Park;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class ParkControllerTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected User $user;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->user = User::factory()->create();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_display_parks_index(): void
|
||||
{
|
||||
Park::factory()->count(3)->create();
|
||||
|
||||
$response = $this->actingAs($this->user)->get(route('parks.index'));
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertSee('Parks');
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_create_a_park(): void
|
||||
{
|
||||
$parkData = [
|
||||
'name' => 'Test Park',
|
||||
'description' => 'Test description',
|
||||
'is_active' => true,
|
||||
];
|
||||
|
||||
$response = $this->actingAs($this->user)->post(route('parks.store'), $parkData);
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertDatabaseHas('parks', $parkData);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_show_a_park(): void
|
||||
{
|
||||
$park = Park::factory()->create();
|
||||
|
||||
$response = $this->actingAs($this->user)->get(route('parks.show', $park));
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertSee($park->name);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_update_a_park(): void
|
||||
{
|
||||
$park = Park::factory()->create();
|
||||
$updateData = [
|
||||
'name' => 'Updated Park',
|
||||
'description' => 'Updated description',
|
||||
'is_active' => false,
|
||||
];
|
||||
|
||||
$response = $this->actingAs($this->user)->put(route('parks.update', $park), $updateData);
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertDatabaseHas('parks', $updateData);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_delete_a_park(): void
|
||||
{
|
||||
$park = Park::factory()->create();
|
||||
|
||||
$response = $this->actingAs($this->user)->delete(route('parks.destroy', $park));
|
||||
|
||||
$response->assertRedirect();
|
||||
$this->assertSoftDeleted('parks', ['id' => $park->id]);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_validates_required_fields(): void
|
||||
{
|
||||
$response = $this->actingAs($this->user)->post(route('parks.store'), []);
|
||||
|
||||
$response->assertSessionHasErrors(['name']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_can_search_parks(): void
|
||||
{
|
||||
$park1 = Park::factory()->create(['name' => 'Searchable Park']);
|
||||
$park2 = Park::factory()->create(['name' => 'Other Park']);
|
||||
|
||||
$response = $this->actingAs($this->user)->get(route('parks.index', ['search' => 'Searchable']));
|
||||
|
||||
$response->assertStatus(200)
|
||||
->assertSee($park1->name)
|
||||
->assertDontSee($park2->name);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user