Unverified Commit 51cc243b authored by Sergei Morozov's avatar Sergei Morozov Committed by Michael Moravec

[DBAL-3082] Updated convertParamType(), added a functional test

parent 78abf390
...@@ -216,7 +216,13 @@ class PDOStatement extends \PDOStatement implements Statement ...@@ -216,7 +216,13 @@ class PDOStatement extends \PDOStatement implements Statement
private function convertParamType(int $type) : int private function convertParamType(int $type) : int
{ {
if (! isset(self::PARAM_TYPE_MAP[$type])) { if (! isset(self::PARAM_TYPE_MAP[$type])) {
throw new \InvalidArgumentException('Invalid parameter type: ' . $type); // TODO: next major: throw an exception
@trigger_error(sprintf(
'Using a PDO parameter type (%d given) is deprecated and will cause an error in Doctrine 3.0',
$type
), E_USER_DEPRECATED);
return $type;
} }
return self::PARAM_TYPE_MAP[$type]; return self::PARAM_TYPE_MAP[$type];
......
<?php
namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
use function extension_loaded;
class PDOStatementTest extends DbalFunctionalTestCase
{
protected function setUp()
{
if (! extension_loaded('pdo')) {
$this->markTestSkipped('PDO is not installed');
}
parent::setUp();
if (! $this->_conn->getWrappedConnection() instanceof PDOConnection) {
$this->markTestSkipped('PDO-only test');
}
$table = new Table('stmt_test');
$table->addColumn('id', 'integer');
$table->addColumn('name', 'text');
$this->_conn->getSchemaManager()->dropAndCreateTable($table);
}
/**
* @group legacy
* @expectedDeprecation Using a PDO fetch mode or their combination (%d given) is deprecated and will cause an error in Doctrine 3.0
*/
public function testPDOSpecificModeIsAccepted()
{
$this->_conn->insert('stmt_test', [
'id' => 1,
'name' => 'Alice',
]);
$this->_conn->insert('stmt_test', [
'id' => 2,
'name' => 'Bob',
]);
$data = $this->_conn->query('SELECT id, name FROM stmt_test ORDER BY id')
->fetchAll(PDO::FETCH_KEY_PAIR);
self::assertSame([
1 => 'Alice',
2 => 'Bob',
], $data);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment