diff --git a/tests/MD_STD_IN_Test.php b/tests/MD_STD_IN_Test.php index 93bd4b5..ec400b6 100644 --- a/tests/MD_STD_IN_Test.php +++ b/tests/MD_STD_IN_Test.php @@ -116,7 +116,7 @@ final class MD_STD_IN_Test extends TestCase { /** * Data provider for invalid latitudes. * - * @return array + * @return array}> */ public static function invalid_latitude_provider():array { @@ -588,8 +588,8 @@ final class MD_STD_IN_Test extends TestCase { /** * Function for testing validate_longitude(). * - * @param mixed $to_validate Input to validate. - * @param string $exceptionClass Exception class. + * @param mixed $to_validate Input to validate. + * @param class-string $exceptionClass Exception class. * * @return void */ @@ -619,8 +619,8 @@ final class MD_STD_IN_Test extends TestCase { /** * Function for testing validate_latitude(). * - * @param mixed $to_validate Input to validate. - * @param string $exceptionClass Exception class. + * @param mixed $to_validate Input to validate. + * @param class-string $exceptionClass Exception class. * * @return void */ @@ -677,9 +677,16 @@ final class MD_STD_IN_Test extends TestCase { */ public function test_ensureStringIsUtf8():void { + if (empty($convToIso8859 = iconv("UTF-8", 'ISO-8859-1//TRANSLIT', "ä"))) { + throw new Exception("Iconv returned empty result"); + } + if (empty($convToIso2022 = iconv("UTF-8", 'ISO-2022-JP//TRANSLIT', "ä"))) { + throw new Exception("Iconv returned empty result"); + } + self::assertEquals("ä", MD_STD_IN::ensureStringIsUtf8("ä")); - self::assertEquals("ä", MD_STD_IN::ensureStringIsUtf8(iconv("UTF-8", 'ISO-8859-1//TRANSLIT', "ä"))); - self::assertEquals("a", MD_STD_IN::ensureStringIsUtf8(iconv("UTF-8", 'ISO-2022-JP//TRANSLIT', "ä"))); + self::assertEquals("ä", MD_STD_IN::ensureStringIsUtf8($convToIso8859)); + self::assertEquals("a", MD_STD_IN::ensureStringIsUtf8($convToIso2022)); } } diff --git a/tests/MD_STD_Test.php b/tests/MD_STD_Test.php index c931ccd..7aa0435 100644 --- a/tests/MD_STD_Test.php +++ b/tests/MD_STD_Test.php @@ -21,7 +21,7 @@ final class MD_STD_Test extends TestCase { /** * Data provider for returning a tmp file. * - * @return array + * @return array */ public static function file_name_in_tmp_provider():array { @@ -37,7 +37,7 @@ final class MD_STD_Test extends TestCase { /** * Data provider for invalid directories. * - * @return array + * @return array */ public static function invalid_directory_provider():array { @@ -118,7 +118,7 @@ final class MD_STD_Test extends TestCase { /** * Checks if a file can be written. * - * @param string $temp_file Tmp file. + * @param non-empty-string $temp_file Tmp file. * * @return void */ @@ -146,8 +146,8 @@ final class MD_STD_Test extends TestCase { /** * Check MD_STD::realpath throws exception on non-existing path. * - * @param string $to_validate Input to validate. - * @param string $exceptionClass Exception class. + * @param non-empty-string $to_validate Input to validate. + * @param class-string $exceptionClass Exception class. * * @return void */ @@ -162,8 +162,8 @@ final class MD_STD_Test extends TestCase { /** * Checks if a file can be read. * - * @param string $to_validate Input to validate. - * @param string $exceptionClass Exception class. + * @param non-empty-string $to_validate Input to validate. + * @param class-string $exceptionClass Exception class. * * @return void */ @@ -229,7 +229,7 @@ final class MD_STD_Test extends TestCase { /** * Checks if nothing happens if a file does not exist. * - * @param string $temp_file Tmp file. + * @param non-empty-string $temp_file Tmp file. * * @return void */ @@ -248,7 +248,7 @@ final class MD_STD_Test extends TestCase { /** * Checks unlink_if_exists works. * - * @param string $temp_file Tmp file. + * @param non-empty-string $temp_file Tmp file. * * @return void */ @@ -268,7 +268,10 @@ final class MD_STD_Test extends TestCase { */ public function test_scandir():void { - $files = scandir(__DIR__); + if (empty($files = scandir(__DIR__))) { + throw new Exception("Running regular scandir() failed on script directory: " . __DIR__); + } + $filesChecked = MD_STD::scandir(__DIR__); foreach ($filesChecked as $file) { @@ -284,7 +287,7 @@ final class MD_STD_Test extends TestCase { /** * Checks invalid directory. * - * @param string $dir Dir name. + * @param non-empty-string $dir Dir name. * * @return void */ @@ -520,9 +523,9 @@ final class MD_STD_Test extends TestCase { /** * Checks that minimizeHTMLString works. * - * @param string $filepath File path. - * @param array $mime_types Mime types expected. - * @param string $exception Exception class name. + * @param non-empty-string $filepath File path. + * @param array $mime_types Mime types expected. + * @param class-string $exception Exception class. * * @return void */ @@ -568,7 +571,7 @@ final class MD_STD_Test extends TestCase { /** * Checks check_is_writable does not work with non-existent or non-directory paths. * - * @param string $dir Dir name. + * @param non-empty-string $dir Dir name. * * @return void */