diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php index 11d08d480..ba0be9ee4 100644 --- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php +++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php @@ -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 * diff --git a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php b/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php index c87547934..b972d0640 100644 --- a/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php +++ b/tests/Doctrine/Tests/ORM/Id/SequenceGeneratorTest.php @@ -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));