Skip to content

Commit

Permalink
bernardphp#251 generic exceptions should always bubble up
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius authored and acrobat committed Jul 9, 2017
1 parent 97710bf commit 0329283
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Driver/AbstractDoctrineDriverTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,27 @@ public function testCreateQueueWillNotAttemptDuplicateQueueCreation()
self::assertStringMatchesFormat('%aCOMMIT%a', $logger->queries[7]['sql']);
}

public function testGenericExceptionsBubbleUpWhenThrownOnQueueCreation()
{
$connection = $this->getMockBuilder('Doctrine\DBAL\Connection')->disableOriginalConstructor()->getMock();
$exception = new \Exception();
$queryBuilder = $this->connection->createQueryBuilder();

$connection->expects(self::once())->method('transactional')->willReturnCallback('call_user_func');
$connection->expects(self::once())->method('insert')->willThrowException($exception);
$connection->expects(self::any())->method('createQueryBuilder')->willReturn($queryBuilder);

$driver = new DoctrineDriver($connection);

try {
$driver->createQueue('foo');

self::fail('An exception was supposed to be thrown');
} catch (\Exception $thrown) {
self::assertSame($exception, $thrown);
}
}

public function testPushMessageLazilyCreatesQueue()
{
$this->driver->pushMessage('send-newsletter', 'something');
Expand Down

0 comments on commit 0329283

Please sign in to comment.