Commit 0dd4b6ae authored by Benjamin Eberlei's avatar Benjamin Eberlei

Refactor PostgreSQL lastInsertId() test which fails on travis

parent b6f48e1a
......@@ -153,16 +153,21 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->markTestSkipped('Test only works on platforms with sequences.');
}
$sequence = new \Doctrine\DBAL\Schema\Sequence('write_table_seq');
$sequence = new \Doctrine\DBAL\Schema\Sequence('write_table_id_seq');
try {
$this->_conn->getSchemaManager()->dropSequence($sequence);
} catch(\Exception $e) {}
$this->_conn->getSchemaManager()->createSequence($sequence);
$this->_conn->getSchemaManager()->createSequence($sequence);
} catch(\Exception $e) {
}
$sequences = $this->_conn->getSchemaManager()->listSequences();
$this->assertEquals(1, count(array_filter($sequences, function($sequence) {
return $sequence->getName() === 'write_table_id_seq';
})));
$stmt = $this->_conn->query($this->_conn->getDatabasePlatform()->getSequenceNextValSQL('write_table_seq'));
$stmt = $this->_conn->query($this->_conn->getDatabasePlatform()->getSequenceNextValSQL('write_table_id_seq'));
$nextSequenceVal = $stmt->fetchColumn();
$lastInsertId = $this->_conn->lastInsertId('write_table_seq');
$lastInsertId = $this->_conn->lastInsertId('write_table_id_seq');
$this->assertTrue($lastInsertId > 0);
$this->assertEquals($nextSequenceVal, $lastInsertId);
......
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