Skip to content

Commit

Permalink
Merge pull request #2650 from deeky666/fix-pdo_sqlsrv-tests
Browse files Browse the repository at this point in the history
Fix result cache and PDO connection test on pdo_sqlsrv
  • Loading branch information
Ocramius authored Feb 9, 2017
2 parents b627771 + a5b02c4 commit 0bd7781
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
24 changes: 13 additions & 11 deletions tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down

0 comments on commit 0bd7781

Please sign in to comment.