namespace Tests\Feature; use Tests\TestCase; use App\Models\RSWGSerie; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; class RSWGSerieCrudTest extends TestCase { use RefreshDatabase; /** @test */ public function it_can_display_a_list_of_rs_wg_series() { $user = User::factory()->create(); $this->actingAs($user); RSWGSerie::factory()->count(5)->create(); $response = $this->get(route('rs_wg_series.index')); $response->assertInertia(fn ($page) => $page ->component('Rs_wg_series/Index') // Assuming the Vue component is Rs_wg_series/Index ->has('rs_wg_series', 5) ); } /** @test */ public function it_can_display_a_single_rs_wg_serie() { $user = User::factory()->create(); $this->actingAs($user); $rs_wg_serie = RSWGSerie::factory()->create(); $response = $this->get(route('rs_wg_series.show', $rs_wg_serie)); $response->assertInertia(fn ($page) => $page ->component('Rs_wg_series/Show') // Assuming the Vue component is Rs_wg_series/Show ->where('rs_wg_serie.id', $rs_wg_serie->id) ); } /** @test */ public function it_can_create_a_rs_wg_serie() { $user = User::factory()->create(); $this->actingAs($user); $rs_wg_serieData = [ 'title' => 'New RSWGSerie Title', 'content' => 'Content of the new rs_wg_serie', ]; $response = $this->rs_wg_serie(route('rs_wg_series.store'), $rs_wg_serieData); $response->assertRedirect(route('rs_wg_series.index')); $this->assertDatabaseHas('rs_wg_series', $rs_wg_serieData); } /** @test */ public function it_can_update_a_rs_wg_serie() { $user = User::factory()->create(); $this->actingAs($user); $rs_wg_serie = RSWGSerie::factory()->create(); $updateData = [ 'title' => 'Updated RSWGSerie Title', 'content' => 'Updated content of the rs_wg_serie', ]; $response = $this->put(route('rs_wg_series.update', $rs_wg_serie), $updateData); $response->assertRedirect(route('rs_wg_series.show', $rs_wg_serie)); $this->assertDatabaseHas('rs_wg_series', $updateData); } /** @test */ public function it_can_delete_a_rs_wg_serie() { $user = User::factory()->create(); $this->actingAs($user); $rs_wg_serie = RSWGSerie::factory()->create(); $response = $this->delete(route('rs_wg_series.destroy', $rs_wg_serie)); $response->assertRedirect(route('rs_wg_series.index')); $this->assertDatabaseMissing('rs_wg_series', ['id' => $rs_wg_serie->id]); } }