Skip to content

Commit

Permalink
Improved readability in the functional test
Browse files Browse the repository at this point in the history
  • Loading branch information
eisberg committed Nov 22, 2019
1 parent cefd2dd commit e28b8a9
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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],
Expand Down

0 comments on commit e28b8a9

Please sign in to comment.