diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2021-10-07 19:40:50 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2021-10-07 19:40:50 +0300 |
commit | d49c24346953fd742a8ab456f3be9f4ebf8f3b12 (patch) | |
tree | 7c7a157f94f4bae065e96c064b3aca84bdd3fe37 /test | |
parent | 68d689946fa5fc26a6128e1ea2bfd1955030d2ad (diff) |
Use `@requires` annotation for required extensions
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r-- | test/classes/Dbal/DbiMysqliTest.php | 8 | ||||
-rw-r--r-- | test/classes/EncodingTest.php | 12 | ||||
-rw-r--r-- | test/classes/Gis/GisGeometryCollectionTest.php | 8 | ||||
-rw-r--r-- | test/classes/Gis/GisLineStringTest.php | 8 | ||||
-rw-r--r-- | test/classes/Gis/GisMultiLineStringTest.php | 8 | ||||
-rw-r--r-- | test/classes/Gis/GisMultiPointTest.php | 8 | ||||
-rw-r--r-- | test/classes/Gis/GisMultiPolygonTest.php | 8 | ||||
-rw-r--r-- | test/classes/Gis/GisPointTest.php | 9 | ||||
-rw-r--r-- | test/classes/Gis/GisPolygonTest.php | 8 | ||||
-rw-r--r-- | test/classes/Plugins/Auth/AuthenticationCookieTest.php | 15 | ||||
-rw-r--r-- | test/classes/Plugins/Import/ImportOdsTest.php | 1 | ||||
-rw-r--r-- | test/classes/Plugins/Import/ImportXmlTest.php | 1 | ||||
-rw-r--r-- | test/classes/TwoFactorTest.php | 2 | ||||
-rw-r--r-- | test/classes/Utils/HttpRequestTest.php | 30 |
14 files changed, 49 insertions, 77 deletions
diff --git a/test/classes/Dbal/DbiMysqliTest.php b/test/classes/Dbal/DbiMysqliTest.php index 584deb8219..d27e46f3d8 100644 --- a/test/classes/Dbal/DbiMysqliTest.php +++ b/test/classes/Dbal/DbiMysqliTest.php @@ -12,7 +12,6 @@ use PhpMyAdmin\Tests\AbstractTestCase; use const MYSQLI_ASSOC; use const MYSQLI_BOTH; use const MYSQLI_NUM; -use const PHP_VERSION_ID; /** * @covers \PhpMyAdmin\Dbal\DbiMysqli @@ -34,12 +33,11 @@ class DbiMysqliTest extends AbstractTestCase $this->object = new DbiMysqli(); } + /** + * @requires PHP >= 8.1 + */ public function testGetClientInfo(): void { - if (PHP_VERSION_ID < 80100) { - $this->markTestSkipped('This test requires PHP 8.1'); - } - /** @var mysqli $obj */ $obj = null; $this->assertNotEmpty($this->object->getClientInfo($obj)); diff --git a/test/classes/EncodingTest.php b/test/classes/EncodingTest.php index 92971565c8..fc563cf133 100644 --- a/test/classes/EncodingTest.php +++ b/test/classes/EncodingTest.php @@ -58,12 +58,11 @@ class EncodingTest extends AbstractTestCase ); } + /** + * @requires extension recode + */ public function testRecode(): void { - if (! function_exists('recode_string')) { - $this->markTestSkipped('recode extension missing'); - } - Encoding::setEngine(Encoding::ENGINE_RECODE); $this->assertEquals( 'Only That ecole & Can Be My Blame', @@ -81,13 +80,10 @@ class EncodingTest extends AbstractTestCase * @see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=854821#27 * * @group extension-iconv + * @requires extension iconv */ public function testIconv(): void { - if (! function_exists('iconv')) { - $this->markTestSkipped('iconv extension missing'); - } - // Set PHP native locale if (function_exists('setlocale')) { if (setlocale(0, 'POSIX') === false) { diff --git a/test/classes/Gis/GisGeometryCollectionTest.php b/test/classes/Gis/GisGeometryCollectionTest.php index 66dde2a74f..eda5ca61ae 100644 --- a/test/classes/Gis/GisGeometryCollectionTest.php +++ b/test/classes/Gis/GisGeometryCollectionTest.php @@ -9,7 +9,6 @@ use PhpMyAdmin\Image\ImageWrapper; use PhpMyAdmin\Tests\AbstractTestCase; use TCPDF; -use function function_exists; use function method_exists; use function preg_match; @@ -175,12 +174,11 @@ class GisGeometryCollectionTest extends AbstractTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Gis/GisLineStringTest.php b/test/classes/Gis/GisLineStringTest.php index 832672ecd4..a83fc7b2b5 100644 --- a/test/classes/Gis/GisLineStringTest.php +++ b/test/classes/Gis/GisLineStringTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Gis\GisLineString; use PhpMyAdmin\Image\ImageWrapper; use TCPDF; -use function function_exists; use function preg_match; /** @@ -171,12 +170,11 @@ class GisLineStringTest extends GisGeomTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Gis/GisMultiLineStringTest.php b/test/classes/Gis/GisMultiLineStringTest.php index 1c8f4bf939..28bb824ea5 100644 --- a/test/classes/Gis/GisMultiLineStringTest.php +++ b/test/classes/Gis/GisMultiLineStringTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Gis\GisMultiLineString; use PhpMyAdmin\Image\ImageWrapper; use TCPDF; -use function function_exists; use function preg_match; /** @@ -253,12 +252,11 @@ class GisMultiLineStringTest extends GisGeomTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Gis/GisMultiPointTest.php b/test/classes/Gis/GisMultiPointTest.php index 26820e30a2..c480425512 100644 --- a/test/classes/Gis/GisMultiPointTest.php +++ b/test/classes/Gis/GisMultiPointTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Gis\GisMultiPoint; use PhpMyAdmin\Image\ImageWrapper; use TCPDF; -use function function_exists; use function preg_match; /** @@ -173,12 +172,11 @@ class GisMultiPointTest extends GisGeomTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Gis/GisMultiPolygonTest.php b/test/classes/Gis/GisMultiPolygonTest.php index 525dc08283..783c37f9aa 100644 --- a/test/classes/Gis/GisMultiPolygonTest.php +++ b/test/classes/Gis/GisMultiPolygonTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Gis\GisMultiPolygon; use PhpMyAdmin\Image\ImageWrapper; use TCPDF; -use function function_exists; use function preg_match; /** @@ -338,12 +337,11 @@ class GisMultiPolygonTest extends GisGeomTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Gis/GisPointTest.php b/test/classes/Gis/GisPointTest.php index 901fc236e0..2ba27e4930 100644 --- a/test/classes/Gis/GisPointTest.php +++ b/test/classes/Gis/GisPointTest.php @@ -8,8 +8,6 @@ use PhpMyAdmin\Gis\GisPoint; use PhpMyAdmin\Image\ImageWrapper; use TCPDF; -use function function_exists; - /** * @covers \PhpMyAdmin\Gis\GisPoint */ @@ -188,12 +186,11 @@ class GisPointTest extends GisGeomTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Gis/GisPolygonTest.php b/test/classes/Gis/GisPolygonTest.php index 2ff9f6f467..efe02d0fa9 100644 --- a/test/classes/Gis/GisPolygonTest.php +++ b/test/classes/Gis/GisPolygonTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Gis\GisPolygon; use PhpMyAdmin\Image\ImageWrapper; use TCPDF; -use function function_exists; use function preg_match; /** @@ -424,12 +423,11 @@ class GisPolygonTest extends GisGeomTestCase ]; } + /** + * @requires extension gd + */ public function testPrepareRowAsPng(): void { - if (! function_exists('imagecreatetruecolor')) { - $this->markTestSkipped('GD extension missing!'); - } - $image = ImageWrapper::create(120, 150); $this->assertNotNull($image); $return = $this->object->prepareRowAsPng( diff --git a/test/classes/Plugins/Auth/AuthenticationCookieTest.php b/test/classes/Plugins/Auth/AuthenticationCookieTest.php index ccf5e2e1fc..146f5632be 100644 --- a/test/classes/Plugins/Auth/AuthenticationCookieTest.php +++ b/test/classes/Plugins/Auth/AuthenticationCookieTest.php @@ -15,7 +15,6 @@ use ReflectionException; use ReflectionMethod; use function base64_encode; -use function function_exists; use function is_readable; use function json_encode; use function ob_get_clean; @@ -949,12 +948,11 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase $this->testCookieEncrypt(); } + /** + * @requires extension openssl + */ public function testCookieEncryptOpenSSL(): void { - if (! function_exists('openssl_encrypt')) { - $this->markTestSkipped('openssl not available'); - } - $this->object->setUseOpenSSL(true); $this->testCookieEncrypt(); } @@ -993,12 +991,11 @@ class AuthenticationCookieTest extends AbstractNetworkTestCase $this->testCookieDecrypt(); } + /** + * @requires extension openssl + */ public function testCookieDecryptOpenSSL(): void { - if (! function_exists('openssl_encrypt')) { - $this->markTestSkipped('openssl not available'); - } - $this->object->setUseOpenSSL(true); $this->testCookieDecrypt(); } diff --git a/test/classes/Plugins/Import/ImportOdsTest.php b/test/classes/Plugins/Import/ImportOdsTest.php index b588cdd099..0baedee98f 100644 --- a/test/classes/Plugins/Import/ImportOdsTest.php +++ b/test/classes/Plugins/Import/ImportOdsTest.php @@ -145,6 +145,7 @@ class ImportOdsTest extends AbstractTestCase * * @group medium * @dataProvider dataProviderOdsEmptyRows + * @requires extension simplexml */ public function testDoImportDataset2(bool $odsEmptyRowsMode): void { diff --git a/test/classes/Plugins/Import/ImportXmlTest.php b/test/classes/Plugins/Import/ImportXmlTest.php index 6f9dbe498d..f8bd923604 100644 --- a/test/classes/Plugins/Import/ImportXmlTest.php +++ b/test/classes/Plugins/Import/ImportXmlTest.php @@ -90,6 +90,7 @@ class ImportXmlTest extends AbstractTestCase * Test for doImport * * @group medium + * @requires extension simplexml */ public function testDoImport(): void { diff --git a/test/classes/TwoFactorTest.php b/test/classes/TwoFactorTest.php index 6217bf569c..4910e13b61 100644 --- a/test/classes/TwoFactorTest.php +++ b/test/classes/TwoFactorTest.php @@ -245,7 +245,9 @@ class TwoFactorTest extends AbstractTestCase } /** + * @group extension-iconv * @requires extension xmlwriter + * @requires extension iconv */ public function testApplication(): void { diff --git a/test/classes/Utils/HttpRequestTest.php b/test/classes/Utils/HttpRequestTest.php index 4aa8faea34..3824aa15e8 100644 --- a/test/classes/Utils/HttpRequestTest.php +++ b/test/classes/Utils/HttpRequestTest.php @@ -8,7 +8,6 @@ use PhpMyAdmin\Tests\AbstractTestCase; use PhpMyAdmin\Utils\HttpRequest; use function curl_version; -use function function_exists; use function ini_get; use function stripos; @@ -31,20 +30,10 @@ class HttpRequestTest extends AbstractTestCase } /** - * Skip test if CURL extension is not installed - * - * @param bool $ssl_flags Whether to check support for SSL flags + * Skip test if CURL extension does not support SSL flags */ - public function checkCurl(bool $ssl_flags = false): void + private function checkCurlSslFlagsSupport(): void { - if (! function_exists('curl_init')) { - $this->markTestSkipped('curl not supported'); - } - - if (! $ssl_flags) { - return; - } - $curl = curl_version(); /* * Some SSL engines in CURL do not support CURLOPT_CAPATH @@ -72,10 +61,10 @@ class HttpRequestTest extends AbstractTestCase * @group medium * @dataProvider httpRequests * @group network + * @requires extension curl */ public function testCurl(string $url, string $method, bool $return_only_status, $expected): void { - $this->checkCurl(); $result = $this->callFunction( $this->httpRequest, HttpRequest::class, @@ -96,10 +85,11 @@ class HttpRequestTest extends AbstractTestCase * @group medium * @dataProvider httpRequests * @group network + * @requires extension curl */ public function testCurlCAPath(string $url, string $method, bool $return_only_status, $expected): void { - $this->checkCurl(true); + $this->checkCurlSslFlagsSupport(); $result = $this->callFunction($this->httpRequest, HttpRequest::class, 'curl', [ $url, $method, @@ -122,10 +112,11 @@ class HttpRequestTest extends AbstractTestCase * @group medium * @dataProvider httpRequests * @group network + * @requires extension curl */ public function testCurlCAInfo(string $url, string $method, bool $return_only_status, $expected): void { - $this->checkCurl(true); + $this->checkCurlSslFlagsSupport(); $result = $this->callFunction($this->httpRequest, HttpRequest::class, 'curl', [ $url, $method, @@ -152,7 +143,7 @@ class HttpRequestTest extends AbstractTestCase public function testFopen(string $url, string $method, bool $return_only_status, $expected): void { if (! ini_get('allow_url_fopen')) { - $this->markTestSkipped('allow_url_fopen not supported'); + $this->markTestSkipped('Configuration directive allow_url_fopen is not enabled.'); } $result = $this->callFunction( @@ -175,11 +166,12 @@ class HttpRequestTest extends AbstractTestCase * @group medium * @dataProvider httpRequests * @group network + * @requires extension curl */ public function testCreate(string $url, string $method, bool $return_only_status, $expected): void { - if (! function_exists('curl_init') && ! ini_get('allow_url_fopen')) { - $this->markTestSkipped('neither curl nor allow_url_fopen are supported'); + if (! ini_get('allow_url_fopen')) { + $this->markTestSkipped('Configuration directive allow_url_fopen is not enabled.'); } $result = $this->httpRequest->create($url, $method, $return_only_status); |