11
11
12
12
namespace Symfony \Component \Messenger \Bridge \Doctrine \Tests \Transport ;
13
13
14
+ use Doctrine \DBAL \Platforms \AbstractPlatform ;
15
+ use Doctrine \DBAL \Platforms \PostgreSQLPlatform ;
14
16
use Doctrine \DBAL \Schema \AbstractSchemaManager ;
15
17
use Doctrine \DBAL \Schema \SchemaConfig ;
16
18
use Doctrine \Persistence \ConnectionRegistry ;
22
24
use Symfony \Component \Messenger \Exception \TransportException ;
23
25
use Symfony \Component \Messenger \Transport \Serialization \SerializerInterface ;
24
26
27
+ // Doctrine DBAL 2 compatibility
28
+ class_exists (\Doctrine \DBAL \Platforms \PostgreSqlPlatform::class);
29
+
25
30
class DoctrineTransportFactoryTest extends TestCase
26
31
{
27
32
public function testSupports ()
@@ -39,8 +44,10 @@ public function testCreateTransport()
39
44
$ driverConnection = $ this ->createMock (\Doctrine \DBAL \Connection::class);
40
45
$ schemaManager = $ this ->createMock (AbstractSchemaManager::class);
41
46
$ schemaConfig = $ this ->createMock (SchemaConfig::class);
47
+ $ platform = $ this ->createMock (AbstractPlatform::class);
42
48
$ schemaManager ->method ('createSchemaConfig ' )->willReturn ($ schemaConfig );
43
49
$ driverConnection ->method ('getSchemaManager ' )->willReturn ($ schemaManager );
50
+ $ driverConnection ->method ('getDatabasePlatform ' )->willReturn ($ platform );
44
51
$ registry = $ this ->createMock (ConnectionRegistry::class);
45
52
46
53
$ registry ->expects ($ this ->once ())
@@ -56,6 +63,30 @@ public function testCreateTransport()
56
63
);
57
64
}
58
65
66
+ public function testCreateTransportNotifyWithPostgreSQLPlatform ()
67
+ {
68
+ $ driverConnection = $ this ->createMock (\Doctrine \DBAL \Connection::class);
69
+ $ schemaManager = $ this ->createMock (AbstractSchemaManager::class);
70
+ $ schemaConfig = $ this ->createMock (SchemaConfig::class);
71
+ $ platform = $ this ->createMock (PostgreSQLPlatform::class);
72
+ $ schemaManager ->method ('createSchemaConfig ' )->willReturn ($ schemaConfig );
73
+ $ driverConnection ->method ('getSchemaManager ' )->willReturn ($ schemaManager );
74
+ $ driverConnection ->method ('getDatabasePlatform ' )->willReturn ($ platform );
75
+ $ registry = $ this ->createMock (ConnectionRegistry::class);
76
+
77
+ $ registry ->expects ($ this ->once ())
78
+ ->method ('getConnection ' )
79
+ ->willReturn ($ driverConnection );
80
+
81
+ $ factory = new DoctrineTransportFactory ($ registry );
82
+ $ serializer = $ this ->createMock (SerializerInterface::class);
83
+
84
+ $ this ->assertEquals (
85
+ new DoctrineTransport (new PostgreSqlConnection (PostgreSqlConnection::buildConfiguration ('doctrine://default ' ), $ driverConnection ), $ serializer ),
86
+ $ factory ->createTransport ('doctrine://default ' , [], $ serializer )
87
+ );
88
+ }
89
+
59
90
public function testCreateTransportMustThrowAnExceptionIfManagerIsNotFound ()
60
91
{
61
92
$ this ->expectException (TransportException::class);
0 commit comments