#6167 - tests - throw exception if wrong method used to get sequence nextval
This commit is contained in:
parent
edffb4d449
commit
71b040c849
@ -14,6 +14,11 @@ class ConnectionMock extends Connection
|
|||||||
*/
|
*/
|
||||||
private $_fetchOneResult;
|
private $_fetchOneResult;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Exception
|
||||||
|
*/
|
||||||
|
private $_fetchOneException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Statement
|
* @var Statement
|
||||||
*/
|
*/
|
||||||
@ -92,6 +97,10 @@ class ConnectionMock extends Connection
|
|||||||
*/
|
*/
|
||||||
public function fetchColumn($statement, array $params = [], $colnum = 0, array $types = [])
|
public function fetchColumn($statement, array $params = [], $colnum = 0, array $types = [])
|
||||||
{
|
{
|
||||||
|
if ($this->_fetchOneException != null) {
|
||||||
|
throw $this->_fetchOneException;
|
||||||
|
}
|
||||||
|
|
||||||
return $this->_fetchOneResult;
|
return $this->_fetchOneResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,6 +135,16 @@ class ConnectionMock extends Connection
|
|||||||
$this->_fetchOneResult = $fetchOneResult;
|
$this->_fetchOneResult = $fetchOneResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Exception $exception
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function setFetchOneException(\Exception $exception = null)
|
||||||
|
{
|
||||||
|
$this->_fetchOneException = $exception;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,10 @@ class SequenceGeneratorTest extends OrmTestCase
|
|||||||
|
|
||||||
public function testGeneration()
|
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) {
|
for ($i=0; $i < 42; ++$i) {
|
||||||
if ($i % 10 == 0) {
|
if ($i % 10 == 0) {
|
||||||
$nextId = array(array((int)($i / 10) * 10));
|
$nextId = array(array((int)($i / 10) * 10));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user