From 4363f289fcaacf02731ff3fe3a6250719f04ad07 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 12 Jan 2022 20:27:13 +0900 Subject: [PATCH] PHPunit tests adds and updates --- 4dev/tests/CoreLibsACLLoginTest.php | 46 ++++ 4dev/tests/CoreLibsAdminBackend.php | 47 ++++ 4dev/tests/CoreLibsCheckEmailTest.php | 10 +- 4dev/tests/CoreLibsCheckFileTest.php | 5 +- 4dev/tests/CoreLibsCheckPasswordTest.php | 8 +- 4dev/tests/CoreLibsCheckPhpVersionTest.php | 4 +- .../CoreLibsCombinedArrayHandlerTest.php | 14 +- 4dev/tests/CoreLibsCombinedDateTimeTest.php | 11 +- 4dev/tests/CoreLibsConvertByteTest.php | 5 +- 4dev/tests/CoreLibsConvertColorsTest.php | 9 +- 4dev/tests/CoreLibsConvertHtmlTest.php | 6 +- 4dev/tests/CoreLibsConvertJsonTest.php | 5 +- 4dev/tests/CoreLibsConvertMathTest.php | 26 +-- 4dev/tests/CoreLibsConvertMimeAppNameTest.php | 5 +- 4dev/tests/CoreLibsCreateHashTest.php | 145 ++++++++++++- 4dev/tests/CoreLibsCreateRandomKeyTest.php | 205 ++++++++++++++++++ 4dev/tests/CoreLibsCreateUidsTest.php | 106 +++++++++ 4dev/tests/CoreLibsDBExtendedArrayIOTest.php | 48 ++++ 4dev/tests/CoreLibsDBIOTest.php | 48 ++++ 4dev/tests/CoreLibsDebugFileWriterTest.php | 176 +++++++++++++++ 4dev/tests/CoreLibsDebugRunningTimeTest.php | 124 +++++++++++ 4dev/tests/CoreLibsDebugSupportTest.php | 198 +++++++++++++++++ 4dev/tests/CoreLibsGetSystemTest.php | 196 +++++++++++++++++ 4dev/tests/CoreLibsLanguageEncodingTest.php | 32 +++ 4dev/tests/CoreLibsLanguageL10n.php | 34 +++ 4dev/tests/CoreLibsOutputFormElements.php | 33 +++ 4dev/tests/CoreLibsOutputFormGenerate.php | 33 +++ 4dev/tests/CoreLibsOutputFormToken.php | 33 +++ 4dev/tests/CoreLibsOutputImage.php | 33 +++ 4dev/tests/CoreLibsOutputProgressbar.php | 33 +++ 30 files changed, 1636 insertions(+), 42 deletions(-) create mode 100644 4dev/tests/CoreLibsACLLoginTest.php create mode 100644 4dev/tests/CoreLibsAdminBackend.php create mode 100644 4dev/tests/CoreLibsCreateRandomKeyTest.php create mode 100644 4dev/tests/CoreLibsCreateUidsTest.php create mode 100644 4dev/tests/CoreLibsDBExtendedArrayIOTest.php create mode 100644 4dev/tests/CoreLibsDBIOTest.php create mode 100644 4dev/tests/CoreLibsDebugFileWriterTest.php create mode 100644 4dev/tests/CoreLibsDebugRunningTimeTest.php create mode 100644 4dev/tests/CoreLibsDebugSupportTest.php create mode 100644 4dev/tests/CoreLibsGetSystemTest.php create mode 100644 4dev/tests/CoreLibsLanguageEncodingTest.php create mode 100644 4dev/tests/CoreLibsLanguageL10n.php create mode 100644 4dev/tests/CoreLibsOutputFormElements.php create mode 100644 4dev/tests/CoreLibsOutputFormGenerate.php create mode 100644 4dev/tests/CoreLibsOutputFormToken.php create mode 100644 4dev/tests/CoreLibsOutputImage.php create mode 100644 4dev/tests/CoreLibsOutputProgressbar.php diff --git a/4dev/tests/CoreLibsACLLoginTest.php b/4dev/tests/CoreLibsACLLoginTest.php new file mode 100644 index 00000000..fe967e53 --- /dev/null +++ b/4dev/tests/CoreLibsACLLoginTest.php @@ -0,0 +1,46 @@ +markTestSkipped( + 'The PgSQL extension is not available.' + ); + } + } + + /** + * Undocumented function + * + * @testdox ACL\Login Class tests + * + * @return void + */ + public function testACLLogin() + { + $this->assertTrue(true, 'ACL Login Tests not implemented'); + $this->markTestIncomplete( + 'ACL\Login Tests have not yet been implemented' + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsAdminBackend.php b/4dev/tests/CoreLibsAdminBackend.php new file mode 100644 index 00000000..2cfc898f --- /dev/null +++ b/4dev/tests/CoreLibsAdminBackend.php @@ -0,0 +1,47 @@ +markTestSkipped( + 'The PgSQL extension is not available.' + ); + } + } + + /** + * Undocumented function + * + * @testdox Admin\Backend Class tests + * + * @return void + */ + public function testAdminBackend() + { + /* $this->assertTrue(true, 'ACL Login Tests not implemented'); + $this->markTestIncomplete( + 'ACL\Login Tests have not yet been implemented' + ); */ + $this->markTestSkipped('No implementation for Admin\Backend at the moment'); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsCheckEmailTest.php b/4dev/tests/CoreLibsCheckEmailTest.php index 5778a0d6..81aeceb7 100644 --- a/4dev/tests/CoreLibsCheckEmailTest.php +++ b/4dev/tests/CoreLibsCheckEmailTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Undocumented class - * @testdox CoreLibs\Check\Email method tests + * @coversDefaultClass \CoreLibs\Check\Email + * @testdox \CoreLibs\Check\Email method tests */ final class CoreLibsCheckEmailTest extends TestCase { @@ -40,6 +41,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Test regex level return * + * @covers ::getEmailRegex * @dataProvider emailRegexProvider * @testdox getEmailRegex $input will be $expected [$_dataName] * @@ -93,6 +95,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Undocumented function * + * @covers ::checkEmail * @dataProvider emailCheckProvider * @testdox checkEmail $input will be $expected [$_dataName] * @@ -124,6 +127,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Undocumented function * + * @covers ::checkEmailFull * @dataProvider emailCheckFullProvider * @testdox checkEmailFull $input will be $expected [$_dataName] * @@ -218,6 +222,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Undocumented function * + * @covers ::getEmailRegexErrorMessage * @dataProvider emailRegexErrorProvider * @testdox getEmailRegexErrorMessage $input will be $expected [$_dataName] * @@ -282,6 +287,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Undocumented function * + * @covers ::getEmailType * @dataProvider emailTypeProviderLong * @testdox getEmailType $input will be normal $expected [$_dataName] * @@ -300,6 +306,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Undocumented function * + * @covers ::getEmailType * @dataProvider emailTypeProviderShort * @testdox getEmailType $input will be short $expected [$_dataName] * @@ -354,6 +361,7 @@ final class CoreLibsCheckEmailTest extends TestCase /** * Undocumented function * + * @covers ::getShortEmailType * @dataProvider emailProviderTypeLongToShort * @testdox getShortEmailType $input will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsCheckFileTest.php b/4dev/tests/CoreLibsCheckFileTest.php index 91912548..c94ad943 100644 --- a/4dev/tests/CoreLibsCheckFileTest.php +++ b/4dev/tests/CoreLibsCheckFileTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Check\File - * @testdox CoreLibs\Check\File method tests + * @coversDefaultClass \CoreLibs\Check\File + * @testdox \CoreLibs\Check\File method tests */ final class CoreLibsCheckFileTest extends TestCase { @@ -65,6 +66,7 @@ final class CoreLibsCheckFileTest extends TestCase /** * Tests if file extension matches * + * @covers ::getFilenameEnding * @dataProvider filesExtensionProvider * @testdox getFilenameEnding $input must be extension $expected [$_dataName] * @@ -84,6 +86,7 @@ final class CoreLibsCheckFileTest extends TestCase /** * Tests the file line read * + * @covers ::getLinesFromFile * @dataProvider filesLinesProvider * @testdox getLinesFromFile $input must have $expected lines [$_dataName] * diff --git a/4dev/tests/CoreLibsCheckPasswordTest.php b/4dev/tests/CoreLibsCheckPasswordTest.php index b1d67ea8..ce6a749d 100644 --- a/4dev/tests/CoreLibsCheckPasswordTest.php +++ b/4dev/tests/CoreLibsCheckPasswordTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Check\Password - * @testdox CoreLibs\Check\Password method tests + * @coversDefaultClass \CoreLibs\Check\Password + * @testdox \CoreLibs\Check\Password method tests */ final class CoreLibsCheckPasswordTest extends TestCase { @@ -31,8 +32,10 @@ final class CoreLibsCheckPasswordTest extends TestCase /** * Undocumented function * + * @covers ::passwordVerify + * @covers ::passwordSet * @dataProvider passwordProvider - * @testdox passwordVerify $input compare to $input_hash: $expected [$_dataName] + * @testdox passwordSet $input compare to $input_hash: passwordVerify $expected [$_dataName] * * @param string $input * @param string $input_hash @@ -50,6 +53,7 @@ final class CoreLibsCheckPasswordTest extends TestCase /** * Undocumented function * + * @covers ::passwordRehashCheck * @dataProvider passwordRehashProvider * @testdox passwordRehashCheck $input will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsCheckPhpVersionTest.php b/4dev/tests/CoreLibsCheckPhpVersionTest.php index 8c503630..7db6e7bc 100644 --- a/4dev/tests/CoreLibsCheckPhpVersionTest.php +++ b/4dev/tests/CoreLibsCheckPhpVersionTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Check\PHPVersion - * @testdox CoreLibs\Check\PHPVersion method tests + * @coversDefaultClass \CoreLibs\Check\PHPVersion + * @testdox \CoreLibs\Check\PHPVersion method tests */ final class CoreLibsCheckPHPVersionTest extends TestCase { @@ -42,6 +43,7 @@ final class CoreLibsCheckPHPVersionTest extends TestCase /** * Undocumented function * + * @covers ::checkPHPVersion * @dataProvider phpVersionProvider * @testdox checkPHPVersion $input_min and $input_max will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsCombinedArrayHandlerTest.php b/4dev/tests/CoreLibsCombinedArrayHandlerTest.php index e7674b81..8ea87742 100644 --- a/4dev/tests/CoreLibsCombinedArrayHandlerTest.php +++ b/4dev/tests/CoreLibsCombinedArrayHandlerTest.php @@ -11,7 +11,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Combined\ArrayHandler - * @testdox CoreLibs\Combined\ArrayHandler method tests + * @coversDefaultClass \CoreLibs\Combined\ArrayHandler + * @testdox \CoreLibs\Combined\ArrayHandler method tests */ final class CoreLibsCombinedArrayHandlerTest extends TestCase { @@ -562,6 +563,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::arraySearchRecursive * @dataProvider arraySearchRecursiveProvider * @testdox arraySearchRecursive $needle (key $key_search_for) in $input and will be $expected [$_dataName] * @@ -581,6 +583,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::arraySearchRecursiveAll * @dataProvider arraySearchRecursiveAllProvider * @testdox arraySearchRecursiveAll $needle (key $key_search_for) in $input and will be $expected (old: $flag) [$_dataName] * @@ -601,6 +604,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::arraySearchSimple * @dataProvider arraySearchSimpleProvider * @testdox arraySearchSimple $input searched with key: $key / value: $value (strict: $flag) will be $expected [$_dataName] * @@ -621,6 +625,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::arrayMergeRecursive * @#dataProvider arrayMergeRecursiveProvider * @testdox arrayMergeRecursive ... will be $expected [$_dataName] * @@ -641,6 +646,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::arrayDiff * @dataProvider arrayCompareProvider * @testdox arrayDiff $input_a diff $input_b will be $expected [$_dataName] * @@ -660,6 +666,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::inArrayAny * @dataProvider inArrayAnyProvider * @testdox inArrayAny needle $input_a in haystack $input_b will be $expected [$_dataName] * @@ -679,6 +686,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::genAssocArray * @dataProvider genAssocArrayProvider * @testdox genAssocArray array $input with $key or $value and flag set only $flag will be $expected [$_dataName] * @@ -700,6 +708,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::flattenArray * @dataProvider flattenArrayProvider * @testdox testFlattenArray array $input will be $expected [$_dataName] * @@ -718,6 +727,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::flattenArrayKey * @dataProvider flattenArrayKeyProvider * @testdox flattenArrayKey array $input will be $expected [$_dataName] * @@ -736,6 +746,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::flattenArrayKeyLeavesOnly * @dataProvider flattenArrayKeyLeavesOnlyProvider * @testdox flattenArrayKeyLeavesOnly array $input will be $expected [$_dataName] * @@ -754,6 +765,7 @@ final class CoreLibsCombinedArrayHandlerTest extends TestCase /** * Undocumented function * + * @covers ::arrayFlatForKey * @dataProvider arrayFlatForKeyProvider * @testdox arrayFlatForKey array $input will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsCombinedDateTimeTest.php b/4dev/tests/CoreLibsCombinedDateTimeTest.php index 273bea33..71fafcb3 100644 --- a/4dev/tests/CoreLibsCombinedDateTimeTest.php +++ b/4dev/tests/CoreLibsCombinedDateTimeTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Combined\DateTime - * @testdox CoreLibs\Combined\DateTime method tests + * @coversDefaultClass \CoreLibs\Combined\DateTime + * @testdox \CoreLibs\Combined\DateTime method tests */ final class CoreLibsCombinedDateTimeTest extends TestCase { @@ -444,6 +445,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * date string convert test * + * @covers ::dateStringFormat * @dataProvider timestampProvider * @testdox dateStringFormat $input (microtime $flag) will be $expected [$_dataName] * @@ -463,6 +465,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * interval convert test * + * @covers ::timeStringFormat * @dataProvider intervalProvider * @testdox timeStringFormat $input (microtime $flag) will be $expected [$_dataName] * @@ -482,6 +485,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * Undocumented function * + * @covers ::stringToTime * @dataProvider reverseIntervalProvider * @testdox stringToTime $input will be $expected [$_dataName] * @@ -500,6 +504,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * Undocumented function * + * @covers ::checkDate * @dataProvider dateProvider * @testdox checkDate $input will be $expected [$_dataName] * @@ -518,6 +523,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * Undocumented function * + * @covers ::checkDateTime * @dataProvider dateTimeProvider * @testdox checkDateTime $input will be $expected [$_dataName] * @@ -536,6 +542,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * Undocumented function * + * @covers ::compareDate * @dataProvider dateCompareProvider * @testdox compareDate $input_a compared to $input_b will be $expected [$_dataName] * @@ -555,6 +562,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * Undocumented function * + * @covers ::compareDateTime * @dataProvider dateTimeCompareProvider * @testdox compareDateTime $input_a compared to $input_b will be $expected [$_dataName] * @@ -574,6 +582,7 @@ final class CoreLibsCombinedDateTimeTest extends TestCase /** * Undocumented function * + * @covers ::calcDaysInterval * @dataProvider daysIntervalProvider * @testdox calcDaysInterval $input_a compared to $input_b will be $expected [$_dataName] * @medium diff --git a/4dev/tests/CoreLibsConvertByteTest.php b/4dev/tests/CoreLibsConvertByteTest.php index db90541b..5e6813d6 100644 --- a/4dev/tests/CoreLibsConvertByteTest.php +++ b/4dev/tests/CoreLibsConvertByteTest.php @@ -11,7 +11,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Convert\Byte - * @testdox CoreLibs\Convert\Byte method tests + * @coversDefaultClass \CoreLibs\Convert\Byte + * @testdox \CoreLibs\Convert\Byte method tests */ final class CoreLibsConvertByteTest extends TestCase { @@ -143,6 +144,7 @@ final class CoreLibsConvertByteTest extends TestCase /** * Undocumented function * + * @covers ::humanReadableByteFormat * @dataProvider byteProvider * @testdox humanReadableByteFormat $input will be $expected, $expected_si SI, $expected_no_space no space, $expected_adjust adjust, $expected_si_no_space SI/no space [$_dataName] * @@ -195,6 +197,7 @@ final class CoreLibsConvertByteTest extends TestCase /** * Undocumented function * + * @covers ::stringByteFormat * @dataProvider byteStringProvider * @testdox stringByteFormat $input will be $expected and $expected_si SI [$_dataName] * diff --git a/4dev/tests/CoreLibsConvertColorsTest.php b/4dev/tests/CoreLibsConvertColorsTest.php index 6414c090..a890ab0a 100644 --- a/4dev/tests/CoreLibsConvertColorsTest.php +++ b/4dev/tests/CoreLibsConvertColorsTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Convert\Colors - * @testdox CoreLibs\Convert\Colors method tests + * @coversDefaultClass \CoreLibs\Convert\Colors + * @testdox \CoreLibs\Convert\Colors method tests */ final class CoreLibsConvertColorsTest extends TestCase { @@ -226,6 +227,7 @@ final class CoreLibsConvertColorsTest extends TestCase * Undocumented function * TODO: add cross convert check * + * @covers ::rgb2hex * @dataProvider rgb2hexColorProvider * @testdox rgb2hex $input_r,$input_g,$input_b will be $expected [$_dataName] * @@ -265,6 +267,7 @@ final class CoreLibsConvertColorsTest extends TestCase /** * Undocumented function * + * @covers ::hex2rgb * @dataProvider hex2rgbColorProvider * @testdox hex2rgb $input will be $expected, $expected_str str[,], $expected_str_sep str[$separator] [$_dataName] * @@ -299,6 +302,7 @@ final class CoreLibsConvertColorsTest extends TestCase /** * Undocumented function * + * @covers ::rgb2hsb * @dataProvider rgb2hsbColorProvider * @testdox rgb2hsb $input_r,$input_g,$input_b will be $expected [$_dataName] * @@ -319,6 +323,7 @@ final class CoreLibsConvertColorsTest extends TestCase /** * Undocumented function * + * @covers ::hsb2rgb * @dataProvider hsb2rgbColorProvider * @testdox hsb2rgb $input_h,$input_s,$input_b will be $expected [$_dataName] * @@ -339,6 +344,7 @@ final class CoreLibsConvertColorsTest extends TestCase /** * Undocumented function * + * @covers ::rgb2hsl * @dataProvider rgb2hslColorProvider * @testdox rgb2hsl $input_r,$input_g,$input_b will be $expected [$_dataName] * @@ -359,6 +365,7 @@ final class CoreLibsConvertColorsTest extends TestCase /** * Undocumented function * + * @covers ::hsl2rgb * @dataProvider hsl2rgbColorProvider * @testdox hsl2rgb $input_h,$input_s,$input_l will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsConvertHtmlTest.php b/4dev/tests/CoreLibsConvertHtmlTest.php index 1c4cacea..138eee94 100644 --- a/4dev/tests/CoreLibsConvertHtmlTest.php +++ b/4dev/tests/CoreLibsConvertHtmlTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Convert\Html - * @testdox CoreLibs\Convert\Html method tests + * @coversDefaultClass \CoreLibs\Convert\Html + * @testdox \CoreLibs\Convert\Html method tests */ final class CoreLibsConvertHtmlTest extends TestCase { @@ -119,6 +120,7 @@ final class CoreLibsConvertHtmlTest extends TestCase /** * Undocumented function * + * @covers ::htmlent * @dataProvider htmlentProvider * @testdox htmlent $input will be $expected [$_dataName] * @@ -137,6 +139,7 @@ final class CoreLibsConvertHtmlTest extends TestCase /** * Undocumented function * + * @covers ::removeLB * @dataProvider removeLBProvider * @testdox removeLB $input with replace $replace will be $expected [$_dataName] * @@ -163,6 +166,7 @@ final class CoreLibsConvertHtmlTest extends TestCase /** * Undocumented function * + * @covers ::checked * @dataProvider checkedProvider * @testdox checked find $needle in $haystack and return $type will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsConvertJsonTest.php b/4dev/tests/CoreLibsConvertJsonTest.php index 4fc4b375..f00ed09a 100644 --- a/4dev/tests/CoreLibsConvertJsonTest.php +++ b/4dev/tests/CoreLibsConvertJsonTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Check\Json - * @testdox CoreLibs\Convert\Json method tests + * @coversDefaultClass \CoreLibs\Convert\Json + * @testdox \CoreLibs\Convert\Json method tests */ final class CoreLibsCheckJsonTest extends TestCase { @@ -121,6 +122,7 @@ final class CoreLibsCheckJsonTest extends TestCase /** * test json convert states * + * @covers ::jsonConvertToArray * @dataProvider jsonProvider * @testdox jsonConvertToArray $input (Override: $flag) will be $expected [$_dataName] * @@ -140,6 +142,7 @@ final class CoreLibsCheckJsonTest extends TestCase /** * test json error states * + * @covers ::jsonGetLastError * @dataProvider jsonErrorProvider * @testdox jsonGetLastError $input will be $expected_i/$expected_s [$_dataName] * diff --git a/4dev/tests/CoreLibsConvertMathTest.php b/4dev/tests/CoreLibsConvertMathTest.php index c5d91689..9a97e37e 100644 --- a/4dev/tests/CoreLibsConvertMathTest.php +++ b/4dev/tests/CoreLibsConvertMathTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Undocumented class - * @testdox CoreLibs\Convert\Math method tests + * @coversDefaultClass \CoreLibs\Convert\Math + * @testdox \CoreLibs\Convert\Math method tests */ final class CoreLibsConvertMathTest extends TestCase { @@ -29,6 +30,7 @@ final class CoreLibsConvertMathTest extends TestCase /** * Undocumented function * + * @covers ::fceil * @dataProvider fceilProvider * @testdox fceil: Input $input must be $expected * @@ -60,6 +62,7 @@ final class CoreLibsConvertMathTest extends TestCase /** * Undocumented function * + * @covers ::floorp * @dataProvider floorProvider * @testdox floor: Input $input with cutoff $cutoff must be $expected * @@ -94,6 +97,7 @@ final class CoreLibsConvertMathTest extends TestCase /** * Undocumented function * + * @covers ::initNumeric * @dataProvider initNumericProvider * @testdox initNumeric: Input $info $input must match $expected [$_dataName] * @@ -109,26 +113,6 @@ final class CoreLibsConvertMathTest extends TestCase \CoreLibs\Convert\Math::initNumeric($input) ); } - - /** - * A testWith sample - * - * @testdox initNumeric: alternate tests $input => $expected ($info) [$_dataName] - * @testWith [123.123, 123.123, "float"] - * ["123.123", 123.123, "string"] - * - * @param int|float|string $input - * @param float $expected - * @param string $info - * @return void - */ - public function testMathInitNumericValueAlt($input, float $expected, string $info): void - { - $this->assertEquals( - $expected, - \CoreLibs\Convert\Math::initNumeric($input) - ); - } } // __END__ diff --git a/4dev/tests/CoreLibsConvertMimeAppNameTest.php b/4dev/tests/CoreLibsConvertMimeAppNameTest.php index 24eb9e1d..6284d7a8 100644 --- a/4dev/tests/CoreLibsConvertMimeAppNameTest.php +++ b/4dev/tests/CoreLibsConvertMimeAppNameTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; /** * Test class for Convert\MimeAppName - * @testdox CoreLibs\Convert\MimeAppName method tests + * @coversDefaultClass \CoreLibs\Convert\MimeAppName + * @testdox \CoreLibs\Convert\MimeAppName method tests */ final class CoreLibsConvertMimeAppNameTest extends TestCase { @@ -37,6 +38,8 @@ final class CoreLibsConvertMimeAppNameTest extends TestCase /** * Undocumented function * + * @covers ::mimeGetAppName + * @covers ::mimeSetAppName * @dataProvider mimeProvider * @testdox mimeSetAppName set $mime with $app and will be $expected [$_dataName] * diff --git a/4dev/tests/CoreLibsCreateHashTest.php b/4dev/tests/CoreLibsCreateHashTest.php index 815d7823..58c58c81 100644 --- a/4dev/tests/CoreLibsCreateHashTest.php +++ b/4dev/tests/CoreLibsCreateHashTest.php @@ -8,32 +8,38 @@ use PHPUnit\Framework\TestCase; /** * Test class for Create\Hash - * @testdox CoreLibs\Create\Hash method tests + * @coversDefaultClass \CoreLibs\Create\Hash + * @testdox \CoreLibs\Create\Hash method tests */ final class CoreLibsCreateHashTest extends TestCase { - public function hashProvider(): array + public function hashData(): array { return [ 'any string' => [ 'text' => 'Some String Text', 'crc32b_reverse' => 'c5c21d91', // crc32b (in revere) - 'sha1Short' => '', // sha1Short + 'sha1Short' => '4d2bc9ba0', // sha1Short // via hash - 'crc32b' => '', // hash: crc32b - 'alder32' => '', // hash: alder32 - 'fnv132' => '', // hash: fnv132 - 'fnv1a32' => '', // hash: fnv1a32 - 'joaat' => '', // hash: joaat + 'crc32b' => '911dc2c5', // hash: crc32b + 'adler32' => '31aa05f1', // hash: alder32 + 'fnv132' => '9df444f9', // hash: fnv132 + 'fnv1a32' => '2c5f91b9', // hash: fnv1a32 + 'joaat' => '50dab846', // hash: joaat ] ]; } + /** + * Undocumented function + * + * @return array + */ public function crc32bProvider(): array { $list = []; - foreach ($this->hashProvider() as $name => $values) { + foreach ($this->hashData() as $name => $values) { $list[$name . ' to crc32b reverse'] = [ 0 => $values['text'], 1 => $values['crc32b_reverse'], @@ -45,6 +51,53 @@ final class CoreLibsCreateHashTest extends TestCase /** * Undocumented function * + * @return array + */ + public function sha1ShortProvider(): array + { + $list = []; + foreach ($this->hashData() as $name => $values) { + $list[$name . ' to sha1 short'] = [ + 0 => $values['text'], + 1 => $values['crc32b_reverse'], + 2 => $values['sha1Short'], + ]; + } + return $list; + } + + /** + * test all hash functions + * NOTE: if we add new hash functions in the __hash method + * they need to be added here too (and in the master hashData array too) + * + * @return array + */ + public function hashProvider(): array + { + $list = []; + foreach ($this->hashData() as $name => $values) { + foreach ([null, 'crc32b', 'adler32', 'fnv132', 'fnv1a32', 'joaat'] as $_hash_type) { + // default value test + if ($_hash_type === null) { + $hash_type = 'crc32b'; + } else { + $hash_type = $_hash_type; + } + $list[$name . ' to ' . $hash_type] = [ + 0 => $values['text'], + 1 => $_hash_type, + 2 => $values[$hash_type] + ]; + } + } + return $list; + } + + /** + * Undocumented function + * + * @covers ::__crc32b * @dataProvider crc32bProvider * @testdox __crc32b $input will be $expected [$_dataName] * @@ -59,6 +112,80 @@ final class CoreLibsCreateHashTest extends TestCase \CoreLibs\Create\Hash::__crc32b($input) ); } + + /** + * Undocumented function + * + * @covers ::__sha1Short + * @dataProvider sha1ShortProvider + * @testdox __sha1Short $input will be $expected (crc32b) and $expected_sha1 (sha1 short) [$_dataName] + * + * @param string $input + * @param string $expected + * @return void + */ + public function testSha1Short(string $input, string $expected, string $expected_sha1): void + { + // uses crc32b + $this->assertEquals( + $expected, + \CoreLibs\Create\Hash::__sha1Short($input) + ); + $this->assertEquals( + $expected, + \CoreLibs\Create\Hash::__sha1Short($input, false) + ); + // sha1 type + $this->assertEquals( + $expected_sha1, + \CoreLibs\Create\Hash::__sha1Short($input, true) + ); + } + + /** + * Undocumented function + * + * @covers ::__hash + * @dataProvider hashProvider + * @testdox __hash $input with $hash_type will be $expected [$_dataName] + * + * @param string $input + * @param string|null $hash_type + * @param string $expected + * @return void + */ + public function testHash(string $input, ?string $hash_type, string $expected): void + { + if ($hash_type === null) { + $this->assertEquals( + $expected, + \CoreLibs\Create\Hash::__hash($input) + ); + } else { + $this->assertEquals( + $expected, + \CoreLibs\Create\Hash::__hash($input, $hash_type) + ); + } + } + + /** + * Undocumented function + * + * @covers ::__uniqueID + * @testWith [8] + * @testdox __uniqId will be length $expected [$_dataName] + * + * @param integer $expected + * @return void + */ + public function testUniqID(int $expected): void + { + $this->assertEquals( + $expected, + strlen(\CoreLibs\Create\Hash::__uniqId()) + ); + } } // __END__ diff --git a/4dev/tests/CoreLibsCreateRandomKeyTest.php b/4dev/tests/CoreLibsCreateRandomKeyTest.php new file mode 100644 index 00000000..3662aa65 --- /dev/null +++ b/4dev/tests/CoreLibsCreateRandomKeyTest.php @@ -0,0 +1,205 @@ + [ + 0 => 6, + 1 => true, + 2 => 6, + ], + 'negative key length' => [ + 0 => -1, + 1 => false, + 2 => 4, + ], + 'tpp big key length' => [ + 0 => 300, + 1 => false, + 2 => 4, + ], + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function randomKeyGenProvider(): array + { + return [ + 'default key length' => [ + 0 => null, + 1 => 4 + ], + 'set -1 key length default' => [ + 0 => -1, + 1 => 4, + ], + 'set too large key length' => [ + 0 => 300, + 1 => 4, + ], + 'set override key lenght' => [ + 0 => 6, + 1 => 6, + ], + ]; + } + + /** + * 1 + * + * @return array + */ + public function keepKeyLengthProvider(): array + { + return [ + 'set too large' => [ + 0 => 6, + 1 => 300, + 2 => 6, + ], + 'set too small' => [ + 0 => 8, + 1 => -2, + 2 => 8, + ], + 'change valid' => [ + 0 => 10, + 1 => 6, + 2 => 6, + ] + ]; + } + + /** + * run before each test and reset to default 4 + * + * @before + * + * @return void + */ + public function resetKeyLength(): void + { + \CoreLibs\Create\RandomKey::setRandomKeyLength(4); + } + + /** + * check that first length is 4 + * + * @covers ::getRandomKeyLength + * @testWith [4] + * @testdox getRandomKeyLength on init will be $expected [$_dataName] + * + * @param integer $expected + * @return void + */ + public function testGetRandomKeyLengthInit(int $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Create\RandomKey::getRandomKeyLength() + ); + } + + /** + * Undocumented function + * + * @covers ::setRandomKeyLength + * @covers ::getRandomKeyLength + * @dataProvider keyLenghtProvider + * @testdox setRandomKeyLength $input will be $expected, compare to $compare [$_dataName] + * + * @param integer $input + * @param boolean $expected + * @param integer $compare + * @return void + */ + public function testSetRandomKeyLength(int $input, bool $expected, int $compare): void + { + // set + $this->assertEquals( + $expected, + \CoreLibs\Create\RandomKey::setRandomKeyLength($input) + ); + // read test, if false, use compare check + if ($expected === false) { + $input = $compare; + } + $this->assertEquals( + $input, + \CoreLibs\Create\RandomKey::getRandomKeyLength() + ); + } + + /** + * Undocumented function + * + * @covers ::randomKeyGeyn + * @dataProvider randomKeyGenProvider + * @testdox randomKeyGen use $input key length $expected [$_dataName] + * + * @param integer|null $input + * @param integer $expected + * @return void + */ + public function testRandomKeyGen(?int $input, int $expected): void + { + if ($input === null) { + $this->assertEquals( + $expected, + strlen(\CoreLibs\Create\RandomKey::randomKeyGen()) + ); + } else { + $this->assertEquals( + $expected, + strlen(\CoreLibs\Create\RandomKey::randomKeyGen($input)) + ); + } + } + + /** + * Check that if set to n and then invalid, it keeps the previous one + * or if second change valid, second will be shown + * + * @covers ::setRandomKeyLength + * @dataProvider keepKeyLengthProvider + * @testdox keep setRandomKeyLength set with $input_valid and then $input_invalid will be $expected [$_dataName] + * + * @param integer $input_valid + * @param integer $input_invalid + * @param integer $expected + * @return void + */ + public function testKeepKeyLength(int $input_valid, int $input_invalid, int $expected): void + { + \CoreLibs\Create\RandomKey::setRandomKeyLength($input_valid); + \CoreLibs\Create\RandomKey::setRandomKeyLength($input_invalid); + $this->assertEquals( + $expected, + \CoreLibs\Create\RandomKey::getRandomKeyLength() + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsCreateUidsTest.php b/4dev/tests/CoreLibsCreateUidsTest.php new file mode 100644 index 00000000..c6e12117 --- /dev/null +++ b/4dev/tests/CoreLibsCreateUidsTest.php @@ -0,0 +1,106 @@ + [ + 0 => 'md5', + 1 => 32, + ], + 'sha256 hash' => [ + 0 => 'sha256', + 1 => 64 + ], + 'default hash DEFAULT_HASH not set' => [ + 0 => null, + 1 => 64, + ], + 'invalid name' => [ + 0 => 'iamnotavalidhash', + 1 => 64, + ] + ]; + } + + /** + * must match 7e78fe0d-59b8-4637-af7f-e88d221a7d1e + * + * @covers ::uuidv4 + * @testdox uuidv4 check that return is matching regex [$_dataName] + * + * @return void + */ + public function testUuidv4(): void + { + $uuid = \CoreLibs\Create\Uids::uuidv4(); + $this->assertMatchesRegularExpression( + '/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/', + $uuid + ); + // $this->assertStringMatchesFormat( + // '%4s%4s-%4s-%4s-%4s-%4s%4s%4s', + // $uuid + // ); + } + + /** + * Undocumented function + * + * @covers ::uniqId + * @dataProvider uniqIdProvider + * @testdox uniqId $input will be length $expected [$_dataName] + * + * @param string|null $input + * @param string $expected + * @return void + */ + public function testUniqId(?string $input, int $expected): void + { + if ($input === null) { + $this->assertEquals( + $expected, + strlen(\CoreLibs\Create\Uids::uniqId()) + ); + } else { + $this->assertEquals( + $expected, + strlen(\CoreLibs\Create\Uids::uniqId($input)) + ); + } + } + + /** + * Because we set a constant here, we can only run one test + * so we test invalid one to force check + * + * @covers ::uniqId + * @#dataProvider uniqIdProvider + * @testWith ["invalidhash", 64] + * @testdox uniqId use DEFAULT_HASH set $input with length $expected [$_dataName] + * + * @return void + */ + public function testUnidIdDefaultHash(string $input, int $expected): void + { + define('DEFAULT_HASH', $input); + $this->assertEquals( + $expected, + strlen(\CoreLibs\Create\Uids::uniqId()) + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsDBExtendedArrayIOTest.php b/4dev/tests/CoreLibsDBExtendedArrayIOTest.php new file mode 100644 index 00000000..0ea1f86f --- /dev/null +++ b/4dev/tests/CoreLibsDBExtendedArrayIOTest.php @@ -0,0 +1,48 @@ +markTestSkipped( + 'The PgSQL extension is not available.' + ); + } + } + + /** + * Undocumented function + * + * @testdox DB\Extended\ArrayIO Class tests + * + * @return void + */ + public function testDBIO() + { + $this->assertTrue(true, 'DB Extended ArrayIO Tests not implemented'); + $this->markTestIncomplete( + 'DB\Extended\ArrayIO Tests have not yet been implemented' + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsDBIOTest.php b/4dev/tests/CoreLibsDBIOTest.php new file mode 100644 index 00000000..f75b6b0f --- /dev/null +++ b/4dev/tests/CoreLibsDBIOTest.php @@ -0,0 +1,48 @@ +markTestSkipped( + 'The PgSQL extension is not available.' + ); + } + } + + /** + * Undocumented function + * + * @testdox DB\IO Class tests + * + * @return void + */ + public function testDBIO() + { + $this->assertTrue(true, 'DB IO Tests not implemented'); + $this->markTestIncomplete( + 'DB\IO Tests have not yet been implemented' + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsDebugFileWriterTest.php b/4dev/tests/CoreLibsDebugFileWriterTest.php new file mode 100644 index 00000000..1248e2ea --- /dev/null +++ b/4dev/tests/CoreLibsDebugFileWriterTest.php @@ -0,0 +1,176 @@ + [ + 0 => '/tmp/', + 1 => true, + ], + 'invalid log folder name' => [ + 0 => 'some name', + 1 => false, + ], + 'not writeable log folder name' => [ + 0 => '/opt', + 1 => false, + ] + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function fsetFilenameProvider(): array + { + return [ + 'valid log file name' => [ + 0 => 'some_valid_name.log', + 1 => true, + ], + 'file name contains path' => [ + 0 => 'log/debug.log', + 1 => false, + ], + 'invalid log file name' => [ + 0 => 'invalid name', + 1 => false, + ] + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function fdebugProvider(): array + { + return [ + 'debug with default enter' => [ + 0 => 'test string', + 1 => null, + 2 => true, + 3 => 'test string' . "\n" + ], + 'debug with no enter' => [ + 0 => 'test string', + 1 => false, + 2 => true, + 3 => 'test string' + ] + ]; + } + + /** + * Undocumented function + * + * @dataProvider fsetFolderProvider + * @testdox fsetFolder $input will match $expected [$_dataName] + * + * @param string $input + * @param boolean $expected + * @return void + */ + public function testFsetFolder(string $input, bool $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Debug\FileWriter::fsetFolder($input) + ); + } + + /** + * Undocumented function + * + * @dataProvider fsetFilenameProvider + * @testdox fsetFilename $input will match $expected [$_dataName] + * + * @param string $input + * @param boolean $expected + * @return void + */ + public function testFsetFilename(string $input, bool $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Debug\FileWriter::fsetFilename($input) + ); + } + + /** + * Undocumented function + * + * @dataProvider fdebugProvider + * @testdox fdebug write $input with enter $enter and will be $expected and written $expected_log [$_dataName] + * + * @param string $input + * @param boolean|null $enter + * @param boolean $expected + * @param string $expected_log + * @return void + */ + public function testFdebug(string $input, ?bool $enter, bool $expected, string $expected_log): void + { + // set debug log folder + $file = 'FileWriterTest.log'; + $folder = '/tmp'; + $debug_file = $folder . DIRECTORY_SEPARATOR . $file; + $valid_folder = \CoreLibs\Debug\FileWriter::fsetFolder($folder); + $this->assertTrue( + $valid_folder + ); + $valid_file = \CoreLibs\Debug\FileWriter::fsetFilename($file); + $this->assertTrue( + $valid_file + ); + // write the log line + if ($enter === null) { + $this->assertEquals( + $expected, + \CoreLibs\Debug\FileWriter::fdebug($input) + ); + } else { + $this->assertEquals( + $expected, + \CoreLibs\Debug\FileWriter::fdebug($input, $enter) + ); + } + if (is_file($debug_file)) { + // open file, load data, compre to expected_log + $log_data = file_get_contents($debug_file); + if ($log_data === false) { + $this->fail('fdebug file not readable or not data: ' . $debug_file); + } + $this->assertStringEndsWith( + $expected_log, + $log_data + ); + unlink($debug_file); + } else { + $this->fail('fdebug file not found: ' . $debug_file); + } + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsDebugRunningTimeTest.php b/4dev/tests/CoreLibsDebugRunningTimeTest.php new file mode 100644 index 00000000..1eaeb203 --- /dev/null +++ b/4dev/tests/CoreLibsDebugRunningTimeTest.php @@ -0,0 +1,124 @@ + [ + 0 => null, + 1 => '/^\d{4}\.\d{5,}$/' + ], + 'nanoseconds' => [ + 0 => 'ns', + 1 => '/^\d{10}$/' + ], + 'microseconds' => [ + 0 => 'ys', + 1 => '/^\d{7}\.\d{3}$/' + ], + 'milliseconds' => [ + 0 => 'ms', + 1 => '/^\d{4}\.\d{6}$/' + ], + 'seconds' => [ + 0 => 's', + 1 => '/^\d{1}\.\d{9}$/' + ], + 'invalid fallback to ms' => [ + 0 => 'invalid', + 1 => '/^\d{4}\.\d{6}$/' + ] + ]; + } + + public function runningTimeProvider(): array + { + return [ + 'run time test' => [ + 0 => '/^\d{1}$/', + 1 => '/^Start: \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} 0\.\d{7,}$/', + 2 => '/^Start:$/' + ] + ]; + } + + /** + * Undocumented function + * + * @cover ::hrRunningTime + * @dataProvider hrRunningTimeProvider + * @testdox hrRunningTime with $out_time matching $expected [$_dataName] + * + * @param string|null $out_time + * @param string $expected + * @return void + */ + public function testHrRunningTime(?string $out_time, string $expected): void + { + $start = \CoreLibs\Debug\RunningTime::hrRunningTime(); + $this->assertEquals( + 0, + $start + ); + time_nanosleep(1, 500); + if ($out_time === null) { + $end = \CoreLibs\Debug\RunningTime::hrRunningTime(); + } else { + $end = \CoreLibs\Debug\RunningTime::hrRunningTime($out_time); + } + $this->assertMatchesRegularExpression( + $expected, + (string)$end + ); + } + + /** + * Undocumented function + * + * @dataProvider runningTimeProvider + * @testdox runningTime matching return $expected_number and start $expected_start end $expected_end [$_dataName] + * + * @param string $expected_number + * @param string $expected_start + * @param string $expected_end + * @return void + */ + public function testRunningTime(string $expected_number, string $expected_start, string $expected_end): void + { + $start = \CoreLibs\Debug\RunningTime::runningTime(true); + $this->assertEquals( + 0, + $start + ); + $this->assertMatchesRegularExpression( + $expected_start, + \CoreLibs\Debug\RunningTime::runningTimeString() + ); + time_nanosleep(1, 500); + $end = \CoreLibs\Debug\RunningTime::runningTime(true); + $this->assertMatchesRegularExpression( + $expected_number, + (string)$end + ); + $this->assertMatchesRegularExpression( + $expected_end, + \CoreLibs\Debug\RunningTime::runningTimeString() + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsDebugSupportTest.php b/4dev/tests/CoreLibsDebugSupportTest.php new file mode 100644 index 00000000..0538ddac --- /dev/null +++ b/4dev/tests/CoreLibsDebugSupportTest.php @@ -0,0 +1,198 @@ + [ + 0 => null, + 1 => "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{8}$/", + ], + 'microtime -1' => [ + 0 => -1, + 1 => "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{8}$/", + ], + 'microtime 0' => [ + 0 => 0, + 1 => "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/", + ], + 'microtime 4' => [ + 0 => 4, + 1 => "/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}.\d{4}$/", + ], + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function printArProvider(): array + { + return [ + 'empty array' => [ + 0 => [], + 1 => "
Array\n(\n)\n
" + ], + 'simple array' => [ + 0 => ['a', 'b'], + 1 => "
Array\n(\n"
+					. "    [0] => a\n"
+					. "    [1] => b\n"
+					. ")\n
" + ], + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function debugStringProvider(): array + { + return [ + 'null string, default' => [ + 0 => null, + 1 => null, + 2 => '-' + ], + 'empty string, ... replace' => [ + 0 => '', + 1 => '...', + 2 => '...' + ], + 'filled string' => [ + 0 => 'some string', + 1 => null, + 2 => 'some string' + ] + ]; + } + + /** + * Undocumented function + * + * @cover ::printTime + * @dataProvider printTimeProvider + * @testdox printTime test with $microtime and match to regex [$_dataName] + * + * @param int|null $mircrotime + * @param string $expected + * @return void + */ + public function testPrintTime(?int $microtime, string $regex): void + { + if ($microtime === null) { + $this->assertMatchesRegularExpression( + $regex, + \CoreLibs\Debug\Support::printTime() + ); + } else { + $this->assertMatchesRegularExpression( + $regex, + \CoreLibs\Debug\Support::printTime($microtime) + ); + } + } + + /** + * Undocumented function + * + * @cover ::printAr + * @dataProvider printArProvider + * @testdox printAr $input will be $expected[$_dataName] + * + * @param array $input + * @param string $expected + * @return void + */ + public function testPrintAr(array $input, string $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Debug\Support::printAr($input) + ); + } + + /** + * Undocumented function + * + * @cover ::getCallerMethod + * @testWith ["testGetCallerMethod"] + * @testdox getCallerMethod check if it returns $expected [$_dataName] + * + * @return void + */ + public function testGetCallerMethod(string $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Debug\Support::getCallerMethod() + ); + } + + /** + * Undocumented function + * + * @cover ::getCallerClass + * @testWith ["PHPUnit\\TextUI\\Command"] + * @testdox getCallerClass check if it returns $expected [$_dataName] + * + * @return void + */ + public function testGetCallerClass(string $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Debug\Support::getCallerClass() + ); + } + + /** + * Undocumented function + * + * @cover ::debugString + * @dataProvider debugStringProvider + * @testdox debugString $input with replace $replace will be $expected [$_dataName] + * + * @param string|null $input + * @param string|null $replace + * @param string $expected + * @return void + */ + public function testDebugString(?string $input, ?string $replace, string $expected) + { + if ($replace === null) { + $this->assertEquals( + $expected, + \CoreLibs\Debug\Support::debugString($input) + ); + } else { + $this->assertEquals( + $expected, + \CoreLibs\Debug\Support::debugString($input, $replace) + ); + } + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsGetSystemTest.php b/4dev/tests/CoreLibsGetSystemTest.php new file mode 100644 index 00000000..db604309 --- /dev/null +++ b/4dev/tests/CoreLibsGetSystemTest.php @@ -0,0 +1,196 @@ + [ + 0 => UPLOAD_ERR_INI_SIZE, + 1 => 'The uploaded file exceeds the upload_max_filesize directive in php.ini', + ], + 'upload err from size' => [ + 0 => UPLOAD_ERR_FORM_SIZE, + 1 => 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form' + ], + 'upload err partial' => [ + 0 => UPLOAD_ERR_PARTIAL, + 1 => 'The uploaded file was only partially uploaded' + ], + 'upload err no file' => [ + 0 => UPLOAD_ERR_NO_FILE, + 1 => 'No file was uploaded' + ], + 'upload err no tmp dir' => [ + 0 => UPLOAD_ERR_NO_TMP_DIR, + 1 => 'Missing a temporary folder' + ], + 'upload err cant write' => [ + 0 => UPLOAD_ERR_CANT_WRITE, + 1 => 'Failed to write file to disk' + ], + 'upload err extension' => [ + 0 => UPLOAD_ERR_EXTENSION, + 1 => 'File upload stopped by extension' + ], + 'unkown error' => [ + 0 => 99999, + 1 => 'Unknown upload error' + ] + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function getHostNameProvider(): array + { + return [ + 'original set' => [ + 0 => null, + 1 => 'NOHOST', + 2 => 'NOPORT', + ], + 'override set no port' => [ + 0 => 'foo.org', + 1 => 'foo.org', + 2 => '80' + ], + 'override set with port' => [ + 0 => 'foo.org:443', + 1 => 'foo.org', + 2 => '443' + ] + ]; + } + + /** + * Undocumented function + * + * @return array + */ + public function getPageNameProvider(): array + { + return [ + 'original set' => [ + 0 => null, // input + 1 => 'phpunit', + 2 => 'phpunit', + 3 => 'www/vendor/bin/phpunit', // NOTE: this can change + ], + 'some path with extension' => [ + 0 => '/some/path/to/file.txt', + 1 => 'file.txt', + 2 => 'file', + 3 => '/some/path/to/file.txt', + ] + ]; + } + + /** + * Undocumented function + * + * @covers ::fileUploadErrorMessage + * @dataProvider fileUploadErrorMessageProvider + * @testdox fileUploadErrorMessage $input error matches $expected [$_dataName] + * + * @param integer $input + * @param string $expected + * @return void + */ + public function testFileUploadErrorMessage(int $input, string $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Get\System::fileUploadErrorMessage($input) + ); + } + + /** + * Undocumented function + * + * @covers ::getHostName + * @dataProvider getHostNameProvider + * @testdox getHostName $input must match $expected_host:$expected_port [$_dataName] + * + * @param string|null $input + * @param string $expected_host + * @param string $expected_port + * @return void + */ + public function testGetHostNanme(?string $input, string $expected_host, string $expected_port): void + { + // print "HOSTNAME: " . $_SERVER['HTTP_HOST'] . "
"; + // print "SERVER: " . print_r($_SERVER, true) . "\n"; + // print "SELF: " . $_SERVER['PHP_SELF'] . "\n"; + if ($input !== null) { + $_SERVER['HTTP_HOST'] = $input; + } + list ($host, $port) = \CoreLibs\Get\System::getHostName(); + $this->assertEquals( + $expected_host, + $host + ); + $this->assertEquals( + $expected_port, + $port + ); + } + + /** + * Undocumented function + * + * @covers ::getPageName + * @dataProvider getPageNameProvider + * @testdox getPageName $input will match 0: $expected_0, 1: $expected_1, 2: $expected_2 [$_dataName] + * + * @param string|null $input + * @param string $expected_0 default with extension + * @param string $expected_1 no extension + * @param string $expected_2 full path + * @return void + */ + public function testGetPageName(?string $input, string $expected_0, string $expected_1, string $expected_2) + { + if ($input !== null) { + $_SERVER['PHP_SELF'] = $input; + } + // default 0, + $this->assertEquals( + $expected_0, + \CoreLibs\Get\System::getPageName() + ); + $this->assertEquals( + $expected_0, + \CoreLibs\Get\System::getPageName(\CoreLibs\Get\System::WITH_EXTENSION) + ); + $this->assertEquals( + $expected_1, + \CoreLibs\Get\System::getPageName(\CoreLibs\Get\System::NO_EXTENSION) + ); + $this->assertEquals( + $expected_2, + \CoreLibs\Get\System::getPageName(\CoreLibs\Get\System::FULL_PATH) + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsLanguageEncodingTest.php b/4dev/tests/CoreLibsLanguageEncodingTest.php new file mode 100644 index 00000000..2664693f --- /dev/null +++ b/4dev/tests/CoreLibsLanguageEncodingTest.php @@ -0,0 +1,32 @@ +assertTrue(true, 'Language Encoding Tests not implemented'); + $this->markTestIncomplete( + 'Language\Encoding Tests have not yet been implemented' + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsLanguageL10n.php b/4dev/tests/CoreLibsLanguageL10n.php new file mode 100644 index 00000000..57adf084 --- /dev/null +++ b/4dev/tests/CoreLibsLanguageL10n.php @@ -0,0 +1,34 @@ +assertTrue(true, 'Language L10n Tests not implemented'); + $this->markTestIncomplete( + 'Language\L10n Tests have not yet been implemented' + ); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsOutputFormElements.php b/4dev/tests/CoreLibsOutputFormElements.php new file mode 100644 index 00000000..7c11d80a --- /dev/null +++ b/4dev/tests/CoreLibsOutputFormElements.php @@ -0,0 +1,33 @@ +assertTrue(true, 'Output Form Elements Tests not implemented'); + $this->markTestIncomplete( + 'Output\Form\Elements Tests have not yet been implemented' + ); + // $this->markTestSkipped('No implementation for Output\Form\Elements at the moment'); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsOutputFormGenerate.php b/4dev/tests/CoreLibsOutputFormGenerate.php new file mode 100644 index 00000000..40ba194f --- /dev/null +++ b/4dev/tests/CoreLibsOutputFormGenerate.php @@ -0,0 +1,33 @@ +assertTrue(true, 'Output Form Generate Tests not implemented'); + $this->markTestIncomplete( + 'Output\Form\Generate Tests have not yet been implemented' + ); */ + $this->markTestSkipped('No implementation for Output\Form\Generate at the moment'); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsOutputFormToken.php b/4dev/tests/CoreLibsOutputFormToken.php new file mode 100644 index 00000000..652029e5 --- /dev/null +++ b/4dev/tests/CoreLibsOutputFormToken.php @@ -0,0 +1,33 @@ +assertTrue(true, 'Output Form Token Tests not implemented'); + $this->markTestIncomplete( + 'Output\Form\Token Tests have not yet been implemented' + ); + // $this->markTestSkipped('No implementation for Output\Form\Token at the moment'); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsOutputImage.php b/4dev/tests/CoreLibsOutputImage.php new file mode 100644 index 00000000..c0168cfe --- /dev/null +++ b/4dev/tests/CoreLibsOutputImage.php @@ -0,0 +1,33 @@ +assertTrue(true, 'Output Image Tests not implemented'); + $this->markTestIncomplete( + 'Output\Image Tests have not yet been implemented' + ); + // $this->markTestSkipped('No implementation for Output\Image at the moment'); + } +} + +// __END__ diff --git a/4dev/tests/CoreLibsOutputProgressbar.php b/4dev/tests/CoreLibsOutputProgressbar.php new file mode 100644 index 00000000..908f3811 --- /dev/null +++ b/4dev/tests/CoreLibsOutputProgressbar.php @@ -0,0 +1,33 @@ +assertTrue(true, 'Output Progressbar Tests not implemented'); + $this->markTestIncomplete( + 'Output\Progressbar Tests have not yet been implemented' + ); */ + $this->markTestSkipped('No implementation for Output\Progressbar at the moment'); + } +} + +// __END__