Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 5700919

Browse filesBrowse files
committed
add a test for the listen
1 parent 3f2b95b commit 5700919
Copy full SHA for 5700919

File tree

1 file changed

+53
-0
lines changed
Filter options

1 file changed

+53
-0
lines changed

‎src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/Doctrine/Tests/Transport/PostgreSqlConnectionTest.php
+53Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
1313

14+
use Doctrine\DBAL\Cache\ArrayResult;
15+
use Doctrine\DBAL\Platforms\PostgreSQLPlatform;
16+
use Doctrine\DBAL\Query\QueryBuilder;
17+
use Doctrine\DBAL\Result;
1418
use Doctrine\DBAL\Schema\Table;
1519
use PHPUnit\Framework\TestCase;
1620
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection;
@@ -42,6 +46,55 @@ public function testUnserialize()
4246
$connection->__wakeup();
4347
}
4448

49+
public function testListenOnConnection()
50+
{
51+
$driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);
52+
53+
$driverConnection
54+
->expects(self::any())
55+
->method('getDatabasePlatform')
56+
->willReturn(new PostgreSQLPlatform());
57+
58+
$driverConnection
59+
->expects(self::any())
60+
->method('executeQuery')
61+
->willReturn(new Result(new ArrayResult([]), $driverConnection));
62+
63+
$driverConnection
64+
->expects(self::any())
65+
->method('createQueryBuilder')
66+
->willReturn(new QueryBuilder($driverConnection));
67+
68+
$wrappedConnection = new class() {
69+
private $notifyCalls = 0;
70+
71+
public function pgsqlGetNotify()
72+
{
73+
++$this->notifyCalls;
74+
75+
return false;
76+
}
77+
78+
public function countNotifyCalls()
79+
{
80+
return $this->notifyCalls;
81+
}
82+
};
83+
84+
$driverConnection
85+
->expects(self::exactly(2))
86+
->method('getNativeConnection')
87+
->willReturn($wrappedConnection);
88+
89+
$connection = new PostgreSqlConnection(['table_name' => 'queue_table'], $driverConnection);
90+
91+
$connection->get(); // first time we have queueEmptiedAt === null, fallback on the parent implementation
92+
$connection->get();
93+
$connection->get();
94+
95+
$this->assertSame(2, $wrappedConnection->countNotifyCalls());
96+
}
97+
4598
public function testGetExtraSetupSql()
4699
{
47100
$driverConnection = $this->createMock(\Doctrine\DBAL\Connection::class);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.