From e28b8a9e3b57dc6dc078834a8acfc7998782935d Mon Sep 17 00:00:00 2001 From: Alexander Rakushin Date: Fri, 22 Nov 2019 07:59:23 +0300 Subject: [PATCH] Improved readability in the functional test --- .../Functional/Driver/OCI8/StatementTest.php | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php index e29d76468a2..59848b01fc9 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php @@ -40,15 +40,29 @@ public function testQueryConversion(string $query, array $params, array $expecte } /** + * Low-level approach to working with parameter binding + * * @param mixed[] $params * @param mixed[] $expected * * @dataProvider queryConversionProvider */ - public function testQueryPrepare(string $query, array $params, array $expected) : void + public function testStatementBindParameters(string $query, array $params, array $expected) : void { $stmt = $this->connection->prepare($query); - $stmt->execute($params); + $hasZeroIndex = array_key_exists(0, $params); + + foreach ($params as $key => $val) { + if ($hasZeroIndex && is_int($key)) { + $param = $key + 1; + } else { + $param = $key; + } + + $stmt->bindParam($param, $val); + } + + $stmt->execute(); self::assertEquals( $expected, @@ -62,7 +76,7 @@ public function testQueryPrepare(string $query, array $params, array $expected) public static function queryConversionProvider() : iterable { return [ - 'simple' => [ + 'positional' => [ 'SELECT ? COL1 FROM DUAL', [1], ['COL1' => 1],