intervle - commit a5158a3
tests: testsa5158a3d799d0bb4182319fdcce40b4dfac99b63LukeJ<luke.jones.2567@gmail.com>2026-03-08T15:18:05Zdiff --git a/tests/Feature/GameControllerFeatureTest.php b/tests/Feature/GameControllerFeatureTest.php
index b6a729d..94bf267 100644
--- a/tests/Feature/GameControllerFeatureTest.php
+++ b/tests/Feature/GameControllerFeatureTest.php
@@ -12,6 +12,9 @@ class GameControllerFeatureTest extends TestCase
private static string $currentDateString;
private static string $pastDateString;
private static string $futureDateString;
+ private static string $easyDifficulty;
+ private static string $mediumDifficulty;
+ private static string $hardDifficulty;
public static function setUpBeforeClass(): void
{
@@ -20,13 +23,16 @@ class GameControllerFeatureTest extends TestCase
self::$currentDateString = '/' . Carbon::now()->format('Ymd');
self::$pastDateString = '/' . Carbon::now()->subYear()->format('Ymd');
self::$futureDateString = '/' . Carbon::now()->addYear()->format('Ymd');
+ self::$easyDifficulty = '/easy';
+ self::$mediumDifficulty = '/medium';
+ self::$hardDifficulty = '/hard';
}
- public function testItReturnsFiveEvents(): void
+ public function testItReturnsFiveEventsIfEasy(): void
{
Event::factory()->count(10)->create();
- $response = $this->get(self::$currentDateString);
+ $response = $this->get(self::$easyDifficulty . self::$currentDateString);
$response->assertStatus(200);
@@ -35,12 +41,54 @@ class GameControllerFeatureTest extends TestCase
});
}
+ public function testItReturnsSevenEventsIfMedium(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response = $this->get(self::$mediumDifficulty . self::$currentDateString);
+
+ $response->assertStatus(200);
+
+ $response->assertViewHas('events', function ($events) {
+ return $events->count() === 7;
+ });
+ }
+
+ public function testItReturnsTenEventsIfHard(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response = $this->get(self::$hardDifficulty . self::$currentDateString);
+
+ $response->assertStatus(200);
+
+ $response->assertViewHas('events', function ($events) {
+ return $events->count() === 10;
+ });
+ }
+
public function testItReturnsDifferentEventsForDifferentDates(): void
{
Event::factory()->count(10)->create();
- $response_a = $this->get(self::$currentDateString);
- $response_b = $this->get(self::$pastDateString);
+ $response_a = $this->get(self::$easyDifficulty . self::$currentDateString);
+ $response_b = $this->get(self::$easyDifficulty . 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 testItReturnsDifferentEventsForDifferentDifficulties(): void
+ {
+ Event::factory()->count(10)->create();
+
+ $response_a = $this->get(self::$easyDifficulty . self::$currentDateString);
+ $response_b = $this->get(self::$mediumDifficulty . self::$currentDateString);
$response_a->assertStatus(200);
$response_b->assertStatus(200);
@@ -55,11 +103,11 @@ class GameControllerFeatureTest extends TestCase
{
Event::factory()->count(10)->create();
- $response_a = $this->get(self::$currentDateString);
+ $response_a = $this->get(self::$easyDifficulty . self::$currentDateString);
Event::factory()->count(10)->create();
- $response_b = $this->get(self::$currentDateString);
+ $response_b = $this->get(self::$easyDifficulty . self::$currentDateString);
$response_a->assertStatus(200);
$response_b->assertStatus(200);
@@ -74,7 +122,7 @@ class GameControllerFeatureTest extends TestCase
{
Event::factory()->count(10)->create();
- $response = $this->get(self::$futureDateString);
+ $response = $this->get(self::$easyDifficulty . self::$futureDateString);
$response->assertStatus(400);
}