@@ -48,26 +48,10 @@ protected function setUp(): void
4848 $ this ->loadFixtures ();
4949 }
5050
51- /**
52- * @return array<string, int|string> name => id mapping
53- */
54- private function getChickenIds (): array
55- {
56- $ response = self ::createClient ()->request ('GET ' , '/chickens?itemsPerPage=10 ' );
57- $ members = $ response ->toArray ()['member ' ];
58- $ ids = [];
59- foreach ($ members as $ member ) {
60- $ ids [$ member ['name ' ]] = $ member ['id ' ];
61- }
62-
63- return $ ids ;
64- }
65-
6651 public function testGt (): void
6752 {
68- $ ids = $ this ->getChickenIds ();
69- // gt: id > second chicken should return third and fourth
70- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison[gt]= ' .$ ids ['Bravo ' ]);
53+ // gt "Bravo": names > "Bravo" alphabetically → Charlie, Delta
54+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison[gt]=Bravo ' );
7155 $ this ->assertResponseIsSuccessful ();
7256 $ names = array_map (static fn ($ c ) => $ c ['name ' ], $ response ->toArray ()['member ' ]);
7357 sort ($ names );
@@ -76,8 +60,8 @@ public function testGt(): void
7660
7761 public function testGte (): void
7862 {
79- $ ids = $ this -> getChickenIds ();
80- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison [gte]= ' . $ ids [ ' Bravo '] );
63+ // gte "Bravo": names >= "Bravo" → Bravo, Charlie, Delta
64+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison [gte]=Bravo ' );
8165 $ this ->assertResponseIsSuccessful ();
8266 $ names = array_map (static fn ($ c ) => $ c ['name ' ], $ response ->toArray ()['member ' ]);
8367 sort ($ names );
@@ -86,8 +70,8 @@ public function testGte(): void
8670
8771 public function testLt (): void
8872 {
89- $ ids = $ this -> getChickenIds ();
90- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison [lt]= ' . $ ids [ ' Charlie '] );
73+ // lt "Charlie": names < "Charlie" → Alpha, Bravo
74+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison [lt]=Charlie ' );
9175 $ this ->assertResponseIsSuccessful ();
9276 $ names = array_map (static fn ($ c ) => $ c ['name ' ], $ response ->toArray ()['member ' ]);
9377 sort ($ names );
@@ -96,8 +80,8 @@ public function testLt(): void
9680
9781 public function testLte (): void
9882 {
99- $ ids = $ this -> getChickenIds ();
100- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison [lte]= ' . $ ids [ ' Charlie '] );
83+ // lte "Charlie": names <= "Charlie" → Alpha, Bravo, Charlie
84+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison [lte]=Charlie ' );
10185 $ this ->assertResponseIsSuccessful ();
10286 $ names = array_map (static fn ($ c ) => $ c ['name ' ], $ response ->toArray ()['member ' ]);
10387 sort ($ names );
@@ -106,8 +90,8 @@ public function testLte(): void
10690
10791 public function testCombinedGtAndLt (): void
10892 {
109- $ ids = $ this -> getChickenIds ();
110- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison [gt]= ' . $ ids [ ' Alpha ' ]. ' &idComparison [lt]=' . $ ids [ ' Delta '] );
93+ // gt "Alpha" AND lt "Delta" → Bravo, Charlie
94+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison [gt]=Alpha&nameComparison [lt]=Delta ' );
11195 $ this ->assertResponseIsSuccessful ();
11296 $ names = array_map (static fn ($ c ) => $ c ['name ' ], $ response ->toArray ()['member ' ]);
11397 sort ($ names );
@@ -116,16 +100,16 @@ public function testCombinedGtAndLt(): void
116100
117101 public function testGtNoResults (): void
118102 {
119- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison[gt]=999999 ' );
103+ // gt "ZZZZ": no name is alphabetically after "ZZZZ"
104+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison[gt]=ZZZZ ' );
120105 $ this ->assertResponseIsSuccessful ();
121106 $ this ->assertCount (0 , $ response ->toArray ()['member ' ]);
122107 }
123108
124109 public function testGteAllResults (): void
125110 {
126- $ ids = $ this ->getChickenIds ();
127- $ minId = min ($ ids );
128- $ response = self ::createClient ()->request ('GET ' , '/chickens?idComparison[gte]= ' .$ minId .'&itemsPerPage=10 ' );
111+ // gte "A": all names start with A or later → all 4
112+ $ response = self ::createClient ()->request ('GET ' , '/chickens?nameComparison[gte]=A&itemsPerPage=10 ' );
129113 $ this ->assertResponseIsSuccessful ();
130114 $ this ->assertCount (4 , $ response ->toArray ()['member ' ]);
131115 }
@@ -141,16 +125,13 @@ public function testOpenApiDocumentation(): void
141125 $ parameters = $ openApiDoc ['paths ' ]['/chickens ' ]['get ' ]['parameters ' ];
142126 $ parameterNames = array_column ($ parameters , 'name ' );
143127
144- foreach (['idComparison [gt] ' , 'idComparison [gte] ' , 'idComparison [lt] ' , 'idComparison [lte] ' ] as $ expectedName ) {
128+ foreach (['nameComparison [gt] ' , 'nameComparison [gte] ' , 'nameComparison [lt] ' , 'nameComparison [lte] ' ] as $ expectedName ) {
145129 $ this ->assertContains ($ expectedName , $ parameterNames , \sprintf ('Expected parameter "%s" in OpenAPI documentation ' , $ expectedName ));
146130 }
147131
148- $ comparisonParams = array_filter ($ parameters , static fn ($ p ) => str_starts_with ($ p ['name ' ], 'idComparison [ ' ));
132+ $ comparisonParams = array_filter ($ parameters , static fn ($ p ) => str_starts_with ($ p ['name ' ], 'nameComparison [ ' ));
149133 foreach ($ comparisonParams as $ param ) {
150134 $ this ->assertSame ('query ' , $ param ['in ' ]);
151- $ this ->assertArrayHasKey ('schema ' , $ param );
152-
153- $ this ->assertSame ('string ' , $ param ['schema ' ]['type ' ]);
154135 }
155136 }
156137
0 commit comments