13
13
use InvalidArgumentException ;
14
14
use ProxyManager \Proxy \ProxyInterface ;
15
15
use stdClass ;
16
- use Symfony \Component \DependencyInjection \ContainerInterface ;
16
+ use Symfony \Component \DependencyInjection \Container ;
17
17
use Symfony \Component \VarExporter \LazyObjectInterface ;
18
18
19
19
use function assert ;
@@ -26,28 +26,23 @@ class RegistryTest extends TestCase
26
26
{
27
27
public function testGetDefaultConnectionName (): void
28
28
{
29
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
30
- $ registry = new Registry ($ container , [], [], 'default ' , 'default ' );
29
+ $ registry = new Registry (new Container (), [], [], 'default ' , 'default ' );
31
30
32
31
$ this ->assertEquals ('default ' , $ registry ->getDefaultConnectionName ());
33
32
}
34
33
35
34
public function testGetDefaultEntityManagerName (): void
36
35
{
37
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
38
- $ registry = new Registry ($ container , [], [], 'default ' , 'default ' );
36
+ $ registry = new Registry (new Container (), [], [], 'default ' , 'default ' );
39
37
40
38
$ this ->assertEquals ('default ' , $ registry ->getDefaultManagerName ());
41
39
}
42
40
43
41
public function testGetDefaultConnection (): void
44
42
{
45
43
$ conn = $ this ->getMockBuilder (Connection::class)->disableOriginalConstructor ()->getMock ();
46
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
47
- $ container ->expects ($ this ->once ())
48
- ->method ('get ' )
49
- ->with ($ this ->equalTo ('doctrine.dbal.default_connection ' ))
50
- ->will ($ this ->returnValue ($ conn ));
44
+ $ container = new Container ();
45
+ $ container ->set ('doctrine.dbal.default_connection ' , $ conn );
51
46
52
47
$ registry = new Registry ($ container , ['default ' => 'doctrine.dbal.default_connection ' ], [], 'default ' , 'default ' );
53
48
@@ -57,11 +52,8 @@ public function testGetDefaultConnection(): void
57
52
public function testGetConnection (): void
58
53
{
59
54
$ conn = $ this ->getMockBuilder (Connection::class)->disableOriginalConstructor ()->getMock ();
60
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
61
- $ container ->expects ($ this ->once ())
62
- ->method ('get ' )
63
- ->with ($ this ->equalTo ('doctrine.dbal.default_connection ' ))
64
- ->will ($ this ->returnValue ($ conn ));
55
+ $ container = new Container ();
56
+ $ container ->set ('doctrine.dbal.default_connection ' , $ conn );
65
57
66
58
$ registry = new Registry ($ container , ['default ' => 'doctrine.dbal.default_connection ' ], [], 'default ' , 'default ' );
67
59
@@ -70,8 +62,7 @@ public function testGetConnection(): void
70
62
71
63
public function testGetUnknownConnection (): void
72
64
{
73
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
74
- $ registry = new Registry ($ container , [], [], 'default ' , 'default ' );
65
+ $ registry = new Registry (new Container (), [], [], 'default ' , 'default ' );
75
66
76
67
$ this ->expectException (InvalidArgumentException::class);
77
68
$ this ->expectExceptionMessage ('Doctrine ORM Connection named "default" does not exist. ' );
@@ -80,20 +71,16 @@ public function testGetUnknownConnection(): void
80
71
81
72
public function testGetConnectionNames (): void
82
73
{
83
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
84
- $ registry = new Registry ($ container , ['default ' => 'doctrine.dbal.default_connection ' ], [], 'default ' , 'default ' );
74
+ $ registry = new Registry (new Container (), ['default ' => 'doctrine.dbal.default_connection ' ], [], 'default ' , 'default ' );
85
75
86
76
$ this ->assertEquals (['default ' => 'doctrine.dbal.default_connection ' ], $ registry ->getConnectionNames ());
87
77
}
88
78
89
79
public function testGetDefaultEntityManager (): void
90
80
{
91
81
$ em = new stdClass ();
92
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
93
- $ container ->expects ($ this ->once ())
94
- ->method ('get ' )
95
- ->with ($ this ->equalTo ('doctrine.orm.default_entity_manager ' ))
96
- ->will ($ this ->returnValue ($ em ));
82
+ $ container = new Container ();
83
+ $ container ->set ('doctrine.orm.default_entity_manager ' , $ em );
97
84
98
85
$ registry = new Registry ($ container , [], ['default ' => 'doctrine.orm.default_entity_manager ' ], 'default ' , 'default ' );
99
86
@@ -103,11 +90,8 @@ public function testGetDefaultEntityManager(): void
103
90
public function testGetEntityManager (): void
104
91
{
105
92
$ em = new stdClass ();
106
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
107
- $ container ->expects ($ this ->once ())
108
- ->method ('get ' )
109
- ->with ($ this ->equalTo ('doctrine.orm.default_entity_manager ' ))
110
- ->will ($ this ->returnValue ($ em ));
93
+ $ container = new Container ();
94
+ $ container ->set ('doctrine.orm.default_entity_manager ' , $ em );
111
95
112
96
$ registry = new Registry ($ container , [], ['default ' => 'doctrine.orm.default_entity_manager ' ], 'default ' , 'default ' );
113
97
@@ -116,8 +100,7 @@ public function testGetEntityManager(): void
116
100
117
101
public function testGetUnknownEntityManager (): void
118
102
{
119
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
120
- $ registry = new Registry ($ container , [], [], 'default ' , 'default ' );
103
+ $ registry = new Registry (new Container (), [], [], 'default ' , 'default ' );
121
104
122
105
$ this ->expectException (InvalidArgumentException::class);
123
106
$ this ->expectExceptionMessage (
@@ -128,8 +111,7 @@ public function testGetUnknownEntityManager(): void
128
111
129
112
public function testResetUnknownEntityManager (): void
130
113
{
131
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
132
- $ registry = new Registry ($ container , [], [], 'default ' , 'default ' );
114
+ $ registry = new Registry (new Container (), [], [], 'default ' , 'default ' );
133
115
134
116
$ this ->expectException (InvalidArgumentException::class);
135
117
$ this ->expectExceptionMessage (
@@ -153,16 +135,9 @@ public function testReset(): void
153
135
->method ('setProxyInitializer ' )
154
136
->with ($ this ->isInstanceOf (Closure::class));
155
137
156
- $ container = $ this ->getMockBuilder (ContainerInterface::class)->getMock ();
157
- $ container ->expects ($ this ->any ())
158
- ->method ('initialized ' )
159
- ->withConsecutive (['doctrine.orm.uninitialized_entity_manager ' ], ['doctrine.orm.noproxy_entity_manager ' ], ['doctrine.orm.proxy_entity_manager ' ])
160
- ->willReturnOnConsecutiveCalls (false , true , true , true );
161
-
162
- $ container ->expects ($ this ->any ())
163
- ->method ('get ' )
164
- ->withConsecutive (['doctrine.orm.noproxy_entity_manager ' ], ['doctrine.orm.proxy_entity_manager ' ], ['doctrine.orm.proxy_entity_manager ' ], ['doctrine.orm.proxy_entity_manager ' ])
165
- ->willReturnOnConsecutiveCalls ($ noProxyManager , $ proxyManager , $ proxyManager , $ proxyManager );
138
+ $ container = new Container ();
139
+ $ container ->set ('doctrine.orm.noproxy_entity_manager ' , $ noProxyManager );
140
+ $ container ->set ('doctrine.orm.proxy_entity_manager ' , $ proxyManager );
166
141
167
142
$ entityManagers = [
168
143
'uninitialized ' => 'doctrine.orm.uninitialized_entity_manager ' ,
@@ -185,13 +160,8 @@ public function testResetLazyObject(): void
185
160
/** @psalm-suppress MissingDependency https://github.com/vimeo/psalm/issues/8258 */
186
161
$ ghostManager ->expects ($ this ->once ())->method ('resetLazyObject ' )->willReturn (true );
187
162
188
- $ container = $ this ->createMock (ContainerInterface::class);
189
- $ container ->method ('initialized ' )
190
- ->withConsecutive (['doctrine.orm.uninitialized_entity_manager ' ], ['doctrine.orm.ghost_entity_manager ' ])
191
- ->willReturnOnConsecutiveCalls (false , true , true );
192
- $ container ->method ('get ' )
193
- ->withConsecutive (['doctrine.orm.ghost_entity_manager ' ], ['doctrine.orm.ghost_entity_manager ' ], ['doctrine.orm.ghost_entity_manager ' ])
194
- ->willReturnOnConsecutiveCalls ($ ghostManager , $ ghostManager , $ ghostManager );
163
+ $ container = new Container ();
164
+ $ container ->set ('doctrine.orm.ghost_entity_manager ' , $ ghostManager );
195
165
196
166
$ entityManagers = [
197
167
'uninitialized ' => 'doctrine.orm.uninitialized_entity_manager ' ,
0 commit comments