Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3929cc7

Browse files
Add unit tests symfony#3
1 parent f250b0a commit 3929cc7

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

src/Symfony/Component/Messenger/Tests/Transport/ConnectionTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\DBAL\Platforms\MySQLPlatform;
1818
use PHPUnit\Framework\MockObject\MockObject;
1919
use PHPUnit\Framework\TestCase;
20+
use Symfony\Component\Config\Definition\Exception\Exception;
2021
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\Connection;
2122

2223
class ConnectionTest extends TestCase
@@ -31,6 +32,8 @@ public function testTableNotFoundExceptionWithEnabledAutoSetup()
3132

3233
$transportConnection->expects($this->once())
3334
->method('setup');
35+
$this->expectExceptionMessage('Transaction started');
36+
3437
$transportConnection->get();
3538
}
3639

@@ -41,8 +44,11 @@ public function testTableNotFoundExceptionWithDisabledAutoSetup()
4144
->setConstructorArgs([['auto_setup' => false], $dbalConnection])
4245
->onlyMethods(['setup'])
4346
->getMock();
47+
4448
$transportConnection->expects($this->never())
4549
->method('setup');
50+
$this->expectExceptionMessage('Transaction started');
51+
4652
$transportConnection->get();
4753
}
4854

@@ -53,8 +59,11 @@ public function testDriverException()
5359
->setConstructorArgs([['auto_setup' => false], $dbalConnection])
5460
->onlyMethods(['setup'])
5561
->getMock();
62+
5663
$transportConnection->expects($this->never())
5764
->method('setup');
65+
$this->expectExceptionMessage('Transaction started');
66+
5867
$transportConnection->get();
5968
}
6069

@@ -65,6 +74,8 @@ private function getDbalConnectionMock(string $exceptionClass): MockObject
6574
$exception = $this->createMock($exceptionClass);
6675
$dbalConnection->method('delete')->willThrowException($exception);
6776

77+
$dbalConnection->method('beginTransaction')->willThrowException(new Exception('Transaction started'));
78+
6879
$platform = $this->createMock(MySQLPlatform::class);
6980
$dbalConnection->method('getDatabasePlatform')->willReturn($platform);
7081

0 commit comments

Comments
 (0)