From 26af6a07f44c8f1e31ddcd7362524a9ba87df5ba Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Fri, 9 Dec 2022 16:53:10 +0900 Subject: [PATCH] PHP unit tests updates for class changes --- 4dev/tests/CoreLibsConvertByteTest.php | 25 ++++++++++++++++++++++++- 4dev/tests/CoreLibsCreateEmailTest.php | 10 +++++++++- 4dev/tests/CoreLibsDBIOTest.php | 8 +++++++- 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/4dev/tests/CoreLibsConvertByteTest.php b/4dev/tests/CoreLibsConvertByteTest.php index 5e6813d6..0a226f73 100644 --- a/4dev/tests/CoreLibsConvertByteTest.php +++ b/4dev/tests/CoreLibsConvertByteTest.php @@ -16,7 +16,6 @@ use PHPUnit\Framework\TestCase; */ final class CoreLibsConvertByteTest extends TestCase { - /** * Undocumented function * @@ -24,7 +23,31 @@ final class CoreLibsConvertByteTest extends TestCase */ public function byteProvider(): array { + /* + * 0: input string + * 1: default flags + * 2: BYTE_FORMAT_SI + * 3: BYTE_FORMAT_NOSPACE + * 4: BYTE_FORMAT_ADJUST + * 5: BYTE_FORMAT_SI | BYTE_FORMAT_NOSPACE + */ return [ + 'string number' => [ + 0 => '1024', + 1 => '1 KB', + 2 => '1.02 KiB', + 3 => '1KB', + 4 => '1.00 KB', + 5 => '1.02KiB', + ], + 'invalud string number' => [ + 0 => '1024 MB', + 1 => '1024 MB', + 2 => '1024 MB', + 3 => '1024 MB', + 4 => '1024 MB', + 5 => '1024 MB', + ], 'negative number' => [ 0 => -123123123, 1 => '-117.42 MB', diff --git a/4dev/tests/CoreLibsCreateEmailTest.php b/4dev/tests/CoreLibsCreateEmailTest.php index 25c343ef..c0301004 100644 --- a/4dev/tests/CoreLibsCreateEmailTest.php +++ b/4dev/tests/CoreLibsCreateEmailTest.php @@ -113,7 +113,10 @@ final class CoreLibsCreateEmailTest extends TestCase '日本語カタカナパ', 'ISO-2022-JP', true, - '"=?ISO-2022-JP?B?GyRCRnxLXDhsGyhCPz8/Pz8=?=" ' + // was ok php 8.1 + // '"=?ISO-2022-JP?B?GyRCRnxLXDhsGyhCPz8/Pz8=?=" ' + // below ok php 8.1.12, 2022/12/9 + '"=?ISO-2022-JP?B?GyRCRnxLXDhsGyhCPz8/Pz8/?=" ' ] ]; } @@ -124,6 +127,11 @@ final class CoreLibsCreateEmailTest extends TestCase * @dataProvider encodeEmailNameProvider * @testdox encode email $email, name $name, encoding $encoding, folding $kv_folding will be $expected [$_dataName] * + * @param string $email + * @param string|null $name + * @param string|null $encoding + * @param bool|null $kv_folding + * @param string $expected * @return void */ public function testEncodeEmailName( diff --git a/4dev/tests/CoreLibsDBIOTest.php b/4dev/tests/CoreLibsDBIOTest.php index c840c6a1..2d7d428c 100644 --- a/4dev/tests/CoreLibsDBIOTest.php +++ b/4dev/tests/CoreLibsDBIOTest.php @@ -1189,7 +1189,13 @@ final class CoreLibsDBIOTest extends TestCase $this->assertEquals( $expected, - $db->dbEscapeBytea($input) + $db->dbEscapeBytea($input), + 'Assert error to bytea' + ); + $this->assertEquals( + $input, + $db->dbUnescapeBytea($expected), + 'Assert error from bytes' ); $db->dbClose();