1
0
mirror of synced 2025-03-06 12:56:10 +03:00

#6167 - tests - throw exception if wrong method used to get sequence nextval

This commit is contained in:
Michał Kurzeja 2016-12-12 12:29:29 +01:00 committed by Marco Pivetta
parent edffb4d449
commit 71b040c849
No known key found for this signature in database
GPG Key ID: 4167D3337FD9D629
2 changed files with 23 additions and 0 deletions

View File

@ -14,6 +14,11 @@ class ConnectionMock extends Connection
*/
private $_fetchOneResult;
/**
* @var \Exception
*/
private $_fetchOneException;
/**
* @var Statement
*/
@ -92,6 +97,10 @@ class ConnectionMock extends Connection
*/
public function fetchColumn($statement, array $params = [], $colnum = 0, array $types = [])
{
if ($this->_fetchOneException != null) {
throw $this->_fetchOneException;
}
return $this->_fetchOneResult;
}
@ -126,6 +135,16 @@ class ConnectionMock extends Connection
$this->_fetchOneResult = $fetchOneResult;
}
/**
* @param \Exception $exception
*
* @return void
*/
public function setFetchOneException(\Exception $exception = null)
{
$this->_fetchOneException = $exception;
}
/**
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*

View File

@ -24,6 +24,10 @@ class SequenceGeneratorTest extends OrmTestCase
public function testGeneration()
{
$this->_em->getConnection()->setFetchOneException(
new \Exception('Fetch* method used. Query method should be used instead, as NEXTVAL should be run on a master server in master-slave setup.')
);
for ($i=0; $i < 42; ++$i) {
if ($i % 10 == 0) {
$nextId = array(array((int)($i / 10) * 10));