55namespace PhpMyAdmin \Tests \Utils ;
66
77use PhpMyAdmin \DatabaseInterface ;
8+ use PhpMyAdmin \Http \RequestMethod ;
89use PhpMyAdmin \Tests \AbstractTestCase ;
910use PhpMyAdmin \Utils \HttpRequest ;
1011use PHPUnit \Framework \Attributes \CoversClass ;
@@ -61,15 +62,19 @@ private function checkCurlSslFlagsSupport(): void
6162 * Test for http request using Curl
6263 *
6364 * @param string $url url
64- * @param string $method method
65+ * @param RequestMethod $method method
6566 * @param bool $returnOnlyStatus return only status
6667 * @param bool|string|null $expected expected result
6768 */
6869 #[DataProvider('httpRequests ' )]
6970 #[Group('network ' )]
7071 #[RequiresPhpExtension('curl ' )]
71- public function testCurl (string $ url , string $ method , bool $ returnOnlyStatus , bool |string |null $ expected ): void
72- {
72+ public function testCurl (
73+ string $ url ,
74+ RequestMethod $ method ,
75+ bool $ returnOnlyStatus ,
76+ bool |string |null $ expected ,
77+ ): void {
7378 $ result = $ this ->callFunction (
7479 $ this ->httpRequest ,
7580 HttpRequest::class,
@@ -83,7 +88,7 @@ public function testCurl(string $url, string $method, bool $returnOnlyStatus, bo
8388 * Test for http request using Curl with CURLOPT_CAPATH
8489 *
8590 * @param string $url url
86- * @param string $method method
91+ * @param RequestMethod $method method
8792 * @param bool $returnOnlyStatus return only status
8893 * @param bool|string|null $expected expected result
8994 */
@@ -92,7 +97,7 @@ public function testCurl(string $url, string $method, bool $returnOnlyStatus, bo
9297 #[RequiresPhpExtension('curl ' )]
9398 public function testCurlCAPath (
9499 string $ url ,
95- string $ method ,
100+ RequestMethod $ method ,
96101 bool $ returnOnlyStatus ,
97102 bool |string |null $ expected ,
98103 ): void {
@@ -112,7 +117,7 @@ public function testCurlCAPath(
112117 * Test for http request using Curl with CURLOPT_CAINFO
113118 *
114119 * @param string $url url
115- * @param string $method method
120+ * @param RequestMethod $method method
116121 * @param bool $returnOnlyStatus return only status
117122 * @param bool|string|null $expected expected result
118123 */
@@ -121,7 +126,7 @@ public function testCurlCAPath(
121126 #[RequiresPhpExtension('curl ' )]
122127 public function testCurlCAInfo (
123128 string $ url ,
124- string $ method ,
129+ RequestMethod $ method ,
125130 bool $ returnOnlyStatus ,
126131 bool |string |null $ expected ,
127132 ): void {
@@ -141,14 +146,18 @@ public function testCurlCAInfo(
141146 * Test for http request using fopen
142147 *
143148 * @param string $url url
144- * @param string $method method
149+ * @param RequestMethod $method method
145150 * @param bool $returnOnlyStatus return only status
146151 * @param bool|string|null $expected expected result
147152 */
148153 #[DataProvider('httpRequests ' )]
149154 #[Group('network ' )]
150- public function testFopen (string $ url , string $ method , bool $ returnOnlyStatus , bool |string |null $ expected ): void
151- {
155+ public function testFopen (
156+ string $ url ,
157+ RequestMethod $ method ,
158+ bool $ returnOnlyStatus ,
159+ bool |string |null $ expected ,
160+ ): void {
152161 if (! ini_get ('allow_url_fopen ' )) {
153162 self ::markTestSkipped ('Configuration directive allow_url_fopen is not enabled. ' );
154163 }
@@ -166,15 +175,19 @@ public function testFopen(string $url, string $method, bool $returnOnlyStatus, b
166175 * Test for http request using generic interface
167176 *
168177 * @param string $url url
169- * @param string $method method
178+ * @param RequestMethod $method method
170179 * @param bool $returnOnlyStatus return only status
171180 * @param bool|string|null $expected expected result
172181 */
173182 #[DataProvider('httpRequests ' )]
174183 #[Group('network ' )]
175184 #[RequiresPhpExtension('curl ' )]
176- public function testCreate (string $ url , string $ method , bool $ returnOnlyStatus , bool |string |null $ expected ): void
177- {
185+ public function testCreate (
186+ string $ url ,
187+ RequestMethod $ method ,
188+ bool $ returnOnlyStatus ,
189+ bool |string |null $ expected ,
190+ ): void {
178191 if (! ini_get ('allow_url_fopen ' )) {
179192 self ::markTestSkipped ('Configuration directive allow_url_fopen is not enabled. ' );
180193 }
@@ -206,16 +219,16 @@ private function validateHttp(mixed $result, mixed $expected): void
206219 /**
207220 * Data provider for HTTP tests
208221 *
209- * @return mixed[][]
222+ * @return list<array{string, RequestMethod, bool, bool|string|null}>
210223 */
211224 public static function httpRequests (): array
212225 {
213226 return [
214- ['https://www.phpmyadmin.net/test/data ' , ' GET ' , true , true ],
215- ['https://www.phpmyadmin.net/test/data ' , ' POST ' , true , null ],
216- ['https://nonexisting.phpmyadmin.net/test/data ' , ' GET ' , true , null ],
217- ['https://www.phpmyadmin.net/test/data ' , ' GET ' , false , 'TEST DATA ' ],
218- ['https://www.phpmyadmin.net/test/nothing ' , ' GET ' , true , false ],
227+ ['https://www.phpmyadmin.net/test/data ' , RequestMethod::Get , true , true ],
228+ ['https://www.phpmyadmin.net/test/data ' , RequestMethod::Post , true , null ],
229+ ['https://nonexisting.phpmyadmin.net/test/data ' , RequestMethod::Get , true , null ],
230+ ['https://www.phpmyadmin.net/test/data ' , RequestMethod::Get , false , 'TEST DATA ' ],
231+ ['https://www.phpmyadmin.net/test/nothing ' , RequestMethod::Get , true , false ],
219232 ];
220233 }
221234}
0 commit comments