mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
#6167 - tests - throw exception if wrong method used to get sequence nextval
This commit is contained in:
committed by
Marco Pivetta
parent
edffb4d449
commit
71b040c849
@@ -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
|
||||
*
|
||||
|
||||
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user