intervle - commit ce94582
tests: testsce94582412eea5b85a2e78d237871164d8a7e6baLukeJ<luke.jones.2567@gmail.com>2026-03-07T23:42:28Zdiff --git a/tests/Feature/GameControllerFeatureTest.php b/tests/Feature/GameControllerFeatureTest.php
new file mode 100644
index 0000000..b6a729d
--- /dev/null
+++ b/tests/Feature/GameControllerFeatureTest.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Tests\Feature;
+
+use App\Models\Event;
+use Carbon\Carbon;
+use Illuminate\Foundation\Testing\RefreshDatabase;
+use Tests\TestCase;
+
+class GameControllerFeatureTest extends TestCase
+{
+ private static string $currentDateString;
+ private static string $pastDateString;
+ private static string $futureDateString;
+
+ public static function setUpBeforeClass(): void
+ {
+ parent::setUpBeforeClass();
+
+ self::$currentDateString = '/' . Carbon::now()->format('Ymd');
+ self::$pastDateString = '/' . Carbon::now()->subYear()->format('Ymd');
+ self::$futureDateString = '/' . Carbon::now()->addYear()->format('Ymd');
+ }
+
+ public function testItReturnsFiveEvents(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response = $this->get(self::$currentDateString);
+
+ $response->assertStatus(200);
+
+ $response->assertViewHas('events', function ($events) {
+ return $events->count() === 5;
+ });
+ }
+
+ public function testItReturnsDifferentEventsForDifferentDates(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response_a = $this->get(self::$currentDateString);
+ $response_b = $this->get(self::$pastDateString);
+
+ $response_a->assertStatus(200);
+ $response_b->assertStatus(200);
+
+ $events_a = $response_a->viewData('events')->pluck('id')->toArray();
+ $events_b = $response_b->viewData('events')->pluck('id')->toArray();
+
+ $this->assertNotEquals($events_a, $events_b, 'Events do not differ for different dates');
+ }
+
+ public function testItReturnsSameEventsAfterEventsTableGrows(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response_a = $this->get(self::$currentDateString);
+
+ Event::factory()->count(10)->create();
+
+ $response_b = $this->get(self::$currentDateString);
+
+ $response_a->assertStatus(200);
+ $response_b->assertStatus(200);
+
+ $events_a = $response_a->viewData('events')->pluck('id')->toArray();
+ $events_b = $response_b->viewData('events')->pluck('id')->toArray();
+
+ $this->assertEquals($events_a, $events_b, 'Events do not match after more events added to table');
+ }
+
+ public function testItFailsIfADateAfterTodayIsRequested(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response = $this->get(self::$futureDateString);
+
+ $response->assertStatus(400);
+ }
+}
diff --git a/tests/Unit/Http/Controllers/GameControllerTest.php b/tests/Unit/Http/Controllers/GameControllerTest.php
new file mode 100644
index 0000000..be6e3d9
--- /dev/null
+++ b/tests/Unit/Http/Controllers/GameControllerTest.php
@@ -0,0 +1,14 @@
+<?php
+
+namespace Tests\Unit;
+
+use App\Http\Controllers\GameController;
+use App\Models\Event;
+use Illuminate\Support\Facades\View;
+use Mockery;
+use Tests\TestCase;
+
+class GameControllerTest extends TestCase
+{
+ //
+}