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 3776e75

Browse filesBrowse files
committed
minor #46180 [Messenger] Add PostgreSqlConnection tests (Jean-Beru)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Messenger] Add PostgreSqlConnection tests | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | Fix #43631 | License | MIT | Doc PR | This PR adds integration tests on `PostgreSqlConnection::get` method to prevent bugs on Doctrine changes. Commits ------- 1f15941 [Messenger] Add PostgreSqlConnection tests
2 parents 10f9df7 + 1f15941 commit 3776e75
Copy full SHA for 3776e75

File tree

Expand file treeCollapse file tree

1 file changed

+66
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+66
-0
lines changed
+66Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Bridge\Doctrine\Tests\Transport;
13+
14+
use Doctrine\DBAL\Connection;
15+
use Doctrine\DBAL\DriverManager;
16+
use Doctrine\DBAL\Schema\AbstractSchemaManager;
17+
use PHPUnit\Framework\TestCase;
18+
use Symfony\Component\Messenger\Bridge\Doctrine\Tests\Fixtures\DummyMessage;
19+
use Symfony\Component\Messenger\Bridge\Doctrine\Transport\PostgreSqlConnection;
20+
21+
/**
22+
* @requires extension pdo_pgsql
23+
* @group integration
24+
*/
25+
class DoctrinePostgreSqlIntegrationTest extends TestCase
26+
{
27+
/** @var Connection */
28+
private $driverConnection;
29+
/** @var PostgreSqlConnection */
30+
private $connection;
31+
32+
protected function setUp(): void
33+
{
34+
if (!$host = getenv('POSTGRES_HOST')) {
35+
$this->markTestSkipped('Missing POSTGRES_HOST env variable');
36+
}
37+
38+
$this->driverConnection = DriverManager::getConnection(['url' => "pgsql://postgres:password@$host"]);
39+
$this->connection = new PostgreSqlConnection(['table_name' => 'queue_table'], $this->driverConnection);
40+
$this->connection->setup();
41+
}
42+
43+
protected function tearDown(): void
44+
{
45+
$this->createSchemaManager()->dropTable('queue_table');
46+
$this->driverConnection->close();
47+
}
48+
49+
public function testPostgreSqlConnectionSendAndGet()
50+
{
51+
$this->connection->send('{"message": "Hi"}', ['type' => DummyMessage::class]);
52+
53+
$encoded = $this->connection->get();
54+
$this->assertEquals('{"message": "Hi"}', $encoded['body']);
55+
$this->assertEquals(['type' => DummyMessage::class], $encoded['headers']);
56+
57+
$this->assertNull($this->connection->get());
58+
}
59+
60+
private function createSchemaManager(): AbstractSchemaManager
61+
{
62+
return method_exists($this->driverConnection, 'createSchemaManager')
63+
? $this->driverConnection->createSchemaManager()
64+
: $this->driverConnection->getSchemaManager();
65+
}
66+
}

0 commit comments

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