From 504462eb6c98ac66360db40b4c2f2cb535da06ab Mon Sep 17 00:00:00 2001 From: Soner Sayakci Date: Wed, 23 Aug 2023 06:47:27 +0000 Subject: [PATCH] Fix IBM DB2 tests --- src/Driver/IBMDB2/Statement.php | 4 -- tests/Functional/BinaryDataAccessTest.php | 46 ++++++++++++++--------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/src/Driver/IBMDB2/Statement.php b/src/Driver/IBMDB2/Statement.php index 316e984d175..699e236d715 100644 --- a/src/Driver/IBMDB2/Statement.php +++ b/src/Driver/IBMDB2/Statement.php @@ -108,10 +108,6 @@ public function bindParam($param, &$variable, $type = ParameterType::STRING, $le $this->lobs[$param] = &$variable; break; - case ParameterType::BINARY: - $this->bind($param, $variable, DB2_PARAM_IN, DB2_BINARY); - break; - default: $this->bind($param, $variable, DB2_PARAM_IN, DB2_CHAR); break; diff --git a/tests/Functional/BinaryDataAccessTest.php b/tests/Functional/BinaryDataAccessTest.php index c4cb97a489e..50be983860f 100644 --- a/tests/Functional/BinaryDataAccessTest.php +++ b/tests/Functional/BinaryDataAccessTest.php @@ -16,7 +16,6 @@ use function array_map; use function hex2bin; use function is_resource; -use function pack; use function stream_get_contents; use const CASE_LOWER; @@ -270,10 +269,23 @@ public function testFetchOneWithTypes(): void public function testNativeArrayListSupport(): void { + $binaryValues = [ + hex2bin('A0AEFA'), + hex2bin('1F43BA'), + hex2bin('8C9D2A'), + hex2bin('72E8AA'), + hex2bin('5B6F9A'), + hex2bin('DAB24A'), + hex2bin('3E71CA'), + hex2bin('F0D6EA'), + hex2bin('6A8B5A'), + hex2bin('C582FA'), + ]; + for ($i = 100; $i < 110; $i++) { $this->connection->insert('binary_fetch_table', [ 'test_int' => $i, - 'test_binary' => pack('L', $i), + 'test_binary' => $binaryValues[$i - 100], ], [ 'test_binary' => ParameterType::BINARY, ]); @@ -293,11 +305,11 @@ public function testNativeArrayListSupport(): void 'SELECT test_int FROM binary_fetch_table WHERE test_binary IN (?)', [ [ - pack('L', 100), - pack('L', 101), - pack('L', 102), - pack('L', 103), - pack('L', 104), + $binaryValues[0], + $binaryValues[1], + $binaryValues[2], + $binaryValues[3], + $binaryValues[4], ], ], [ArrayParameterType::BINARY], @@ -311,11 +323,11 @@ public function testNativeArrayListSupport(): void 'SELECT test_binary FROM binary_fetch_table WHERE test_binary IN (?)', [ [ - pack('L', 100), - pack('L', 101), - pack('L', 102), - pack('L', 103), - pack('L', 104), + $binaryValues[0], + $binaryValues[1], + $binaryValues[2], + $binaryValues[3], + $binaryValues[4], ], ], [ArrayParameterType::BINARY], @@ -332,11 +344,11 @@ public function testNativeArrayListSupport(): void ); self::assertEquals([ - pack('L', 100), - pack('L', 101), - pack('L', 102), - pack('L', 103), - pack('L', 104), + $binaryValues[0], + $binaryValues[1], + $binaryValues[2], + $binaryValues[3], + $binaryValues[4], ], $data); } }