From a5b02c49f38c583a0b76057b47677e80281f8b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20M=C3=BCller?= Date: Thu, 9 Feb 2017 15:08:48 +0100 Subject: [PATCH] fix result cache and PDO connection test on pdo_sqlsrv --- .../Functional/Driver/PDOConnectionTest.php | 4 ++++ .../Tests/DBAL/Functional/ResultCacheTest.php | 24 ++++++++++--------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php index b7e06263baa..78b7b57ff90 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Driver/PDOConnectionTest.php @@ -64,6 +64,10 @@ public function testThrowsWrappedExceptionOnExec() */ public function testThrowsWrappedExceptionOnPrepare() { + if ($this->_conn->getDriver()->getName() === 'pdo_sqlsrv') { + $this->markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.'); + } + // Emulated prepared statements have to be disabled for this test // so that PDO actually communicates with the database server to check the query. $this->driverConnection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); diff --git a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php index dc99bf0f75d..1f19394a39a 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php @@ -16,19 +16,14 @@ protected function setUp() { parent::setUp(); - try { - /* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ - $table = new \Doctrine\DBAL\Schema\Table("caching"); - $table->addColumn('test_int', 'integer'); - $table->addColumn('test_string', 'string', array('notnull' => false)); - $table->setPrimaryKey(array('test_int')); + $table = new \Doctrine\DBAL\Schema\Table("caching"); + $table->addColumn('test_int', 'integer'); + $table->addColumn('test_string', 'string', array('notnull' => false)); + $table->setPrimaryKey(array('test_int')); - $sm = $this->_conn->getSchemaManager(); - $sm->createTable($table); - } catch(\Exception $e) { + $sm = $this->_conn->getSchemaManager(); + $sm->createTable($table); - } - $this->_conn->executeUpdate('DELETE FROM caching'); foreach ($this->expectedResult as $row) { $this->_conn->insert('caching', $row); } @@ -40,6 +35,13 @@ protected function setUp() $config->setResultCacheImpl($cache); } + protected function tearDown() + { + $this->_conn->getSchemaManager()->dropTable('caching'); + + parent::tearDown(); + } + public function testCacheFetchAssoc() { $this->assertCacheNonCacheSelectSameFetchModeAreEqual($this->expectedResult, \PDO::FETCH_ASSOC);