From 6ecdd2e3106886bb53063894c7a064b02eb70000 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 9 Feb 2026 06:24:27 +0000 Subject: [PATCH] Add tests for LiveTvController - Added `tests/Feature/LiveTvTest.php` to cover CRUD and bulk actions for Live Tvs. - Added `tests/Enums/UserStatus.php` to mock `UserStatus` enum for testing environment, required by User model casting. Co-authored-by: juzaweb <47020363+juzaweb@users.noreply.github.com> --- tests/Enums/UserStatus.php | 11 ++++ tests/Feature/LiveTvTest.php | 124 +++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+) create mode 100644 tests/Enums/UserStatus.php create mode 100644 tests/Feature/LiveTvTest.php diff --git a/tests/Enums/UserStatus.php b/tests/Enums/UserStatus.php new file mode 100644 index 0000000..417ba9b --- /dev/null +++ b/tests/Enums/UserStatus.php @@ -0,0 +1,11 @@ +forceFill([ + 'name' => 'Admin', + 'email' => 'admin@example.com', + 'password' => bcrypt('password'), + 'is_super_admin' => 1, + 'email_verified_at' => now(), + 'status' => UserStatus::ACTIVE, + ]); + $user->save(); + $this->user = $user; + } + + public function test_index() + { + $response = $this->actingAs($this->user) + ->get(route('admin.live-tvs.index')); + + $response->assertStatus(200); + } + + public function test_create() + { + $response = $this->actingAs($this->user) + ->get(route('admin.live-tvs.create')); + + $response->assertStatus(200); + } + + public function test_store() + { + $data = [ + 'name' => 'Test Live TV', + 'streaming_url' => 'https://example.com/stream.m3u8', + ]; + + $response = $this->actingAs($this->user) + ->post(route('admin.live-tvs.store'), $data); + + $response->assertStatus(302); + + $this->assertDatabaseHas('live_tvs', [ + 'streaming_url' => 'https://example.com/stream.m3u8', + ]); + } + + public function test_edit() + { + $liveTv = LiveTv::create([ + 'name' => 'Test Live TV Edit', + 'streaming_url' => 'https://example.com/stream.m3u8', + ]); + + $response = $this->actingAs($this->user) + ->get(route('admin.live-tvs.edit', [$liveTv->id])); + + $response->assertStatus(200); + } + + public function test_update() + { + $liveTv = LiveTv::create([ + 'name' => 'Test Live TV Update', + 'streaming_url' => 'https://example.com/stream.m3u8', + ]); + + $data = [ + 'name' => 'Test Live TV Updated', + 'streaming_url' => 'https://example.com/stream-updated.m3u8', + ]; + + $response = $this->actingAs($this->user) + ->put(route('admin.live-tvs.update', [$liveTv->id]), $data); + + $response->assertStatus(302); + + $this->assertDatabaseHas('live_tvs', [ + 'id' => $liveTv->id, + 'streaming_url' => 'https://example.com/stream-updated.m3u8', + ]); + } + + public function test_bulk_delete() + { + $liveTv = LiveTv::create([ + 'name' => 'Test Live TV Delete', + 'streaming_url' => 'https://example.com/stream.m3u8', + ]); + + $response = $this->actingAs($this->user) + ->post(route('admin.live-tvs.bulk'), [ + 'ids' => [$liveTv->id], + 'action' => 'delete', + ]); + + // It might redirect if not AJAX + if ($response->status() === 302) { + $response->assertStatus(302); + } else { + $response->assertStatus(200); + } + + $this->assertDatabaseMissing('live_tvs', ['id' => $liveTv->id]); + } +}