From 6c3c1a908d0adb929e6737edf2e9a4b87570211c Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Mon, 25 Apr 2022 17:01:28 +0900 Subject: [PATCH] PHPunit fixes for PHP 7.4 --- 4dev/checking/phpunit.sh | 5 +++++ ...minBackend.php => CoreLibsAdminBackendTest.php} | 0 4dev/tests/CoreLibsDBIOTest.php | 14 +++++++------- 4dev/tests/CoreLibsDebugLoggingTest.php | 2 +- 4dev/tests/CoreLibsLanguageGetLocaleTest.php | 2 +- 4dev/tests/CoreLibsLanguageL10nTest.php | 6 +++--- ...ents.php => CoreLibsOutputFormElementsTest.php} | 0 ...rate.php => CoreLibsOutputFormGenerateTest.php} | 0 ...rmToken.php => CoreLibsOutputFormTokenTest.php} | 0 ...OutputImage.php => CoreLibsOutputImageTest.php} | 0 ...ssbar.php => CoreLibsOutputProgressbarTest.php} | 0 www/admin/class_test.debug.php | 3 +++ www/lib/CoreLibs/Combined/DateTime.php | 10 +++++----- www/lib/CoreLibs/Debug/Logging.php | 6 +++--- www/lib/CoreLibs/Language/L10n.php | 2 +- 15 files changed, 29 insertions(+), 21 deletions(-) rename 4dev/tests/{CoreLibsAdminBackend.php => CoreLibsAdminBackendTest.php} (100%) rename 4dev/tests/{CoreLibsOutputFormElements.php => CoreLibsOutputFormElementsTest.php} (100%) rename 4dev/tests/{CoreLibsOutputFormGenerate.php => CoreLibsOutputFormGenerateTest.php} (100%) rename 4dev/tests/{CoreLibsOutputFormToken.php => CoreLibsOutputFormTokenTest.php} (100%) rename 4dev/tests/{CoreLibsOutputImage.php => CoreLibsOutputImageTest.php} (100%) rename 4dev/tests/{CoreLibsOutputProgressbar.php => CoreLibsOutputProgressbarTest.php} (100%) diff --git a/4dev/checking/phpunit.sh b/4dev/checking/phpunit.sh index ed5b66ed..c92f1f17 100755 --- a/4dev/checking/phpunit.sh +++ b/4dev/checking/phpunit.sh @@ -1,4 +1,9 @@ base="/storage/var/www/html/developers/clemens/core_data/php_libraries/trunk/"; # -c phpunit.xml # --testdox +# prefix with PHP bin to test different version +# /usr/bin/php7.3 +# /usr/bin/php7.4 +# /usr/bin/php8.0 +# /usr/bin/php8.1 ${base}www/vendor/bin/phpunit -c ${base}phpunit.xml ${base}4dev/tests/ diff --git a/4dev/tests/CoreLibsAdminBackend.php b/4dev/tests/CoreLibsAdminBackendTest.php similarity index 100% rename from 4dev/tests/CoreLibsAdminBackend.php rename to 4dev/tests/CoreLibsAdminBackendTest.php diff --git a/4dev/tests/CoreLibsDBIOTest.php b/4dev/tests/CoreLibsDBIOTest.php index 5a1c4676..165133b0 100644 --- a/4dev/tests/CoreLibsDBIOTest.php +++ b/4dev/tests/CoreLibsDBIOTest.php @@ -566,7 +566,7 @@ final class CoreLibsDBIOTest extends TestCase public function testDbSetDebug( string $connection, ?bool $set, - bool $expected, + bool $expected ): void { $db = new \CoreLibs\DB\IO( self::$db_config[$connection], @@ -599,7 +599,7 @@ final class CoreLibsDBIOTest extends TestCase public function testDbToggleDebug( string $connection, ?bool $toggle, - bool $expected, + bool $expected ): void { $db = new \CoreLibs\DB\IO( self::$db_config[$connection], @@ -1734,7 +1734,7 @@ final class CoreLibsDBIOTest extends TestCase $expected, string $warning, string $error, - string $insert_data, + string $insert_data ): void { // self::$log->setLogLevelAll('debug', true); // self::$log->setLogLevelAll('print', true); @@ -1871,7 +1871,7 @@ final class CoreLibsDBIOTest extends TestCase $expected, string $warning, string $error, - string $insert_data, + string $insert_data ): void { // self::$log->setLogLevelAll('debug', true); // self::$log->setLogLevelAll('print', true); @@ -2034,7 +2034,7 @@ final class CoreLibsDBIOTest extends TestCase array $cursor_ext_checks, string $warning, string $error, - string $insert_data, + string $insert_data ): void { // self::$log->setLogLevelAll('debug', true); // self::$log->setLogLevelAll('print', true); @@ -2356,7 +2356,7 @@ final class CoreLibsDBIOTest extends TestCase string $error_execute, string $expected_data_query, array $expected_data, - string $insert_data, + string $insert_data ): void { // self::$log->setLogLevelAll('debug', true); // self::$log->setLogLevelAll('print', true); @@ -3010,7 +3010,7 @@ final class CoreLibsDBIOTest extends TestCase string $insert, ?string $pk_name, string $table, - string $primary_key, + string $primary_key ): void { // self::$log->setLogLevelAll('debug', true); // self::$log->setLogLevelAll('print', true); diff --git a/4dev/tests/CoreLibsDebugLoggingTest.php b/4dev/tests/CoreLibsDebugLoggingTest.php index 094c10ad..4aeab1d4 100644 --- a/4dev/tests/CoreLibsDebugLoggingTest.php +++ b/4dev/tests/CoreLibsDebugLoggingTest.php @@ -730,7 +730,7 @@ final class CoreLibsDebugLoggingTest extends TestCase bool $expected_debug, string $expected_file, string $expected_string_start, - string $expected_string_contains, + string $expected_string_contains ): void { // must run with below matrix // level | debug | print | echo | debug() | printErrorMsg() | file diff --git a/4dev/tests/CoreLibsLanguageGetLocaleTest.php b/4dev/tests/CoreLibsLanguageGetLocaleTest.php index d43fe719..981c3e27 100644 --- a/4dev/tests/CoreLibsLanguageGetLocaleTest.php +++ b/4dev/tests/CoreLibsLanguageGetLocaleTest.php @@ -240,7 +240,7 @@ final class CoreLibsLanguageGetLocaleTest extends TestCase ?string $path, ?string $SESSION_DEFAULT_LOCALE, ?string $SESSION_DEFAULT_CHARSET, - array $expected, + array $expected ): void { $return_lang_settings = []; global $_SESSION; diff --git a/4dev/tests/CoreLibsLanguageL10nTest.php b/4dev/tests/CoreLibsLanguageL10nTest.php index e6d53085..ee5bf0f1 100644 --- a/4dev/tests/CoreLibsLanguageL10nTest.php +++ b/4dev/tests/CoreLibsLanguageL10nTest.php @@ -207,7 +207,7 @@ final class CoreLibsLanguageL10nTest extends TestCase string $domain_expected, ?string $context, string $original, - string $translated, + string $translated ): void { if ($locale === null) { $l10n = new \CoreLibs\Language\L10n(); @@ -385,7 +385,7 @@ final class CoreLibsLanguageL10nTest extends TestCase string $locale_expected_b, string $locale_set_expected_b, string $domain_expected_b, - string $translated_b, + string $translated_b ): void { if ($locale === null) { $l10n = new \CoreLibs\Language\L10n(); @@ -763,7 +763,7 @@ final class CoreLibsLanguageL10nTest extends TestCase string $type, string $var, string $value, - string $expected, + string $expected ): void { switch ($type) { case 'global': diff --git a/4dev/tests/CoreLibsOutputFormElements.php b/4dev/tests/CoreLibsOutputFormElementsTest.php similarity index 100% rename from 4dev/tests/CoreLibsOutputFormElements.php rename to 4dev/tests/CoreLibsOutputFormElementsTest.php diff --git a/4dev/tests/CoreLibsOutputFormGenerate.php b/4dev/tests/CoreLibsOutputFormGenerateTest.php similarity index 100% rename from 4dev/tests/CoreLibsOutputFormGenerate.php rename to 4dev/tests/CoreLibsOutputFormGenerateTest.php diff --git a/4dev/tests/CoreLibsOutputFormToken.php b/4dev/tests/CoreLibsOutputFormTokenTest.php similarity index 100% rename from 4dev/tests/CoreLibsOutputFormToken.php rename to 4dev/tests/CoreLibsOutputFormTokenTest.php diff --git a/4dev/tests/CoreLibsOutputImage.php b/4dev/tests/CoreLibsOutputImageTest.php similarity index 100% rename from 4dev/tests/CoreLibsOutputImage.php rename to 4dev/tests/CoreLibsOutputImageTest.php diff --git a/4dev/tests/CoreLibsOutputProgressbar.php b/4dev/tests/CoreLibsOutputProgressbarTest.php similarity index 100% rename from 4dev/tests/CoreLibsOutputProgressbar.php rename to 4dev/tests/CoreLibsOutputProgressbarTest.php diff --git a/www/admin/class_test.debug.php b/www/admin/class_test.debug.php index 418ba77c..9953714e 100644 --- a/www/admin/class_test.debug.php +++ b/www/admin/class_test.debug.php @@ -68,6 +68,9 @@ print "S::DEBUSTRING(s): " . DebugSupport::debugString('SET') . "
"; print "S::DEBUSTRING(''): " . DebugSupport::debugString('') . "
"; print "S::DEBUSTRING(,s): " . DebugSupport::debugString(null, '{-}') . "
"; +// get test +print "LOG FOLDER: " . $debug->getSetting('log_folder') . "
"; + // debug print "C->DEBUG: " . $debug->debug('CLASS-TEST-DEBUG', 'Class Test Debug') . "
"; print "C->DEBUG(html): " . $debug->debug('CLASS-TEST-DEBUG', 'HTML TAG
BOLD') . "
"; diff --git a/www/lib/CoreLibs/Combined/DateTime.php b/www/lib/CoreLibs/Combined/DateTime.php index 2958067f..b2cbaa13 100644 --- a/www/lib/CoreLibs/Combined/DateTime.php +++ b/www/lib/CoreLibs/Combined/DateTime.php @@ -20,7 +20,7 @@ class DateTime 4 => 'Thu', 5 => 'Fri', 6 => 'Sat', - 7 => 'Sun' + 7 => 'Sun', ]; /** @var array */ public const DAY_LONG = [ @@ -30,7 +30,7 @@ class DateTime 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday', - 7 => 'Sunday' + 7 => 'Sunday', ]; /** @var array */ public const MONTH_LONG = [ @@ -45,7 +45,7 @@ class DateTime 9 => 'September', 10 => 'October', 11 => 'November', - 12 => 'December' + 12 => 'December', ]; /** @var array */ public const MONTH_SHORT = [ @@ -60,7 +60,7 @@ class DateTime 9 => 'Sep', 10 => 'Oct', 11 => 'Nov', - 12 => 'Dec' + 12 => 'Dec', ]; /** @@ -349,7 +349,7 @@ class DateTime try { $start = new \DateTime($start_date); $end = new \DateTime($end_date); - } catch (Exception) { + } catch (Exception $e) { if ($return_named === true) { return [ 'overall' => 0, diff --git a/www/lib/CoreLibs/Debug/Logging.php b/www/lib/CoreLibs/Debug/Logging.php index 5dfe77cb..93b5f356 100644 --- a/www/lib/CoreLibs/Debug/Logging.php +++ b/www/lib/CoreLibs/Debug/Logging.php @@ -401,10 +401,10 @@ class Logging /** * Temporary method to read all class variables for testing purpose - * @param string $name - * @return mixed can be anything, bool, string, int, array + * @param string $name what variable to return + * @return mixed can be anything, bool, string, int, array */ - public function getSetting(string $name): mixed + public function getSetting(string $name) //:mixed DOES not work with PHP 7.4 { // for debug purpose only return $this->{$name}; diff --git a/www/lib/CoreLibs/Language/L10n.php b/www/lib/CoreLibs/Language/L10n.php index fca07ce2..c86a1095 100644 --- a/www/lib/CoreLibs/Language/L10n.php +++ b/www/lib/CoreLibs/Language/L10n.php @@ -79,7 +79,7 @@ class L10n public function __construct( string $locale = '', string $domain = '', - string $path = '', + string $path = '' ) { // auto load language only if at least locale and domain is set if (!empty($locale) && !empty($domain)) {