27
27
use Symfony \Component \DependencyInjection \Loader \XmlFileLoader ;
28
28
use Symfony \Component \DependencyInjection \ParameterBag \ParameterBag ;
29
29
use Symfony \Component \DependencyInjection \Reference ;
30
+
30
31
use function assert ;
31
32
use function method_exists ;
32
33
use function sys_get_temp_dir ;
33
34
34
35
class DoctrineMigrationsExtensionTest extends TestCase
35
36
{
36
- public function testXmlConfigs () : void
37
+ public function testXmlConfigs (): void
37
38
{
38
39
$ container = $ this ->getContainerBuilder ();
39
40
@@ -53,7 +54,7 @@ public function testXmlConfigs() : void
53
54
$ this ->assertConfigs ($ config );
54
55
}
55
56
56
- public function testFullConfig () : void
57
+ public function testFullConfig (): void
57
58
{
58
59
$ config = [
59
60
'storage ' => [
@@ -90,7 +91,7 @@ public function testFullConfig() : void
90
91
$ this ->assertConfigs ($ config );
91
92
}
92
93
93
- public function testNoConfigsAreNeeded () : void
94
+ public function testNoConfigsAreNeeded (): void
94
95
{
95
96
$ container = $ this ->getContainer ([]);
96
97
@@ -104,7 +105,7 @@ public function testNoConfigsAreNeeded() : void
104
105
self ::assertSame ([], $ config ->getMigrationDirectories ());
105
106
}
106
107
107
- public function testBundleRelativePathResolution () : void
108
+ public function testBundleRelativePathResolution (): void
108
109
{
109
110
$ container = $ this ->getContainer ([
110
111
'migrations_paths ' => [
@@ -128,7 +129,7 @@ public function testBundleRelativePathResolution() : void
128
129
], $ config ->getMigrationDirectories ());
129
130
}
130
131
131
- private function assertConfigs (?object $ config ) : void
132
+ private function assertConfigs (?object $ config ): void
132
133
{
133
134
self ::assertInstanceOf (Configuration::class, $ config );
134
135
self ::assertSame ([
@@ -152,7 +153,7 @@ private function assertConfigs(?object $config) : void
152
153
self ::assertSame ('doctrine_migration_executed_at_column_test ' , $ storage ->getExecutedAtColumnName ());
153
154
}
154
155
155
- public function testCustomSorter () : void
156
+ public function testCustomSorter (): void
156
157
{
157
158
$ config = [
158
159
'migrations_paths ' => ['DoctrineMigrationsTest ' => 'a ' ],
@@ -163,8 +164,8 @@ public function testCustomSorter() : void
163
164
$ conn = $ this ->createMock (Connection::class);
164
165
$ container ->set ('doctrine.dbal.default_connection ' , $ conn );
165
166
166
- $ sorter = new class () implements Comparator{
167
- public function compare (Version $ a , Version $ b ) : int
167
+ $ sorter = new class () implements Comparator{
168
+ public function compare (Version $ a , Version $ b ): int
168
169
{
169
170
return 1 ;
170
171
}
@@ -178,7 +179,7 @@ public function compare(Version $a, Version $b) : int
178
179
self ::assertSame ($ sorter , $ di ->getVersionComparator ());
179
180
}
180
181
181
- public function testServicesAreLazy () : void
182
+ public function testServicesAreLazy (): void
182
183
{
183
184
$ config = [
184
185
'services ' => [Comparator::class => 'my_sorter ' ],
@@ -188,8 +189,8 @@ public function testServicesAreLazy() : void
188
189
$ conn = $ this ->createMock (Connection::class);
189
190
$ container ->set ('doctrine.dbal.default_connection ' , $ conn );
190
191
191
- $ sorterFactory = new class () {
192
- public function __invoke () : void
192
+ $ sorterFactory = new class () {
193
+ public function __invoke (): void
193
194
{
194
195
throw new Exception ('This method should not be invoked. ' );
195
196
}
@@ -206,7 +207,7 @@ public function __invoke() : void
206
207
self ::assertInstanceOf (DependencyFactory::class, $ di );
207
208
}
208
209
209
- public function testServiceFactory () : void
210
+ public function testServiceFactory (): void
210
211
{
211
212
$ mockComparator = $ this ->createMock (Comparator::class);
212
213
$ config = [
@@ -218,7 +219,7 @@ public function testServiceFactory() : void
218
219
$ conn = $ this ->createMock (Connection::class);
219
220
$ container ->set ('doctrine.dbal.default_connection ' , $ conn );
220
221
221
- $ sorterFactory = new class ($ mockComparator ) {
222
+ $ sorterFactory = new class ($ mockComparator ) {
222
223
/** @var Comparator */
223
224
private $ comparator ;
224
225
@@ -227,7 +228,7 @@ public function __construct(Comparator $comparator)
227
228
$ this ->comparator = $ comparator ;
228
229
}
229
230
230
- public function __invoke (DependencyFactory $ di ) : Comparator
231
+ public function __invoke (DependencyFactory $ di ): Comparator
231
232
{
232
233
return $ this ->comparator ;
233
234
}
@@ -241,7 +242,7 @@ public function __invoke(DependencyFactory $di) : Comparator
241
242
self ::assertSame ($ mockComparator , $ di ->getVersionComparator ());
242
243
}
243
244
244
- public function testCustomConnection () : void
245
+ public function testCustomConnection (): void
245
246
{
246
247
$ config = [
247
248
'migrations_paths ' => ['DoctrineMigrationsTest ' => 'a ' ],
@@ -259,8 +260,7 @@ public function testCustomConnection() : void
259
260
self ::assertSame ($ conn , $ di ->getConnection ());
260
261
}
261
262
262
-
263
- public function testPrefersEntityManagerOverConnection () : void
263
+ public function testPrefersEntityManagerOverConnection (): void
264
264
{
265
265
$ config = [
266
266
'migrations_paths ' => ['DoctrineMigrationsTest ' => 'a ' ],
@@ -278,7 +278,7 @@ public function testPrefersEntityManagerOverConnection() : void
278
278
self ::assertSame ($ em , $ di ->getEntityManager ());
279
279
}
280
280
281
- public function testCustomEntityManager () : void
281
+ public function testCustomEntityManager (): void
282
282
{
283
283
$ config = [
284
284
'em ' => 'custom ' ,
@@ -302,7 +302,7 @@ public function testCustomEntityManager() : void
302
302
self ::assertSame ($ em , $ di ->getConnection ()->getEm ());
303
303
}
304
304
305
- public function testCustomMetadataStorage () : void
305
+ public function testCustomMetadataStorage (): void
306
306
{
307
307
$ config = [
308
308
'migrations_paths ' => ['DoctrineMigrationsTest ' => 'a ' ],
@@ -324,7 +324,7 @@ public function testCustomMetadataStorage() : void
324
324
self ::assertSame ($ mockStorage , $ di ->getMetadataStorage ());
325
325
}
326
326
327
- public function testInvalidService () : void
327
+ public function testInvalidService (): void
328
328
{
329
329
$ this ->expectException (InvalidConfigurationException::class);
330
330
$ this ->expectExceptionMessage ('Invalid configuration for path "doctrine_migrations.services": Valid services for the DoctrineMigrationsBundle must be in the "Doctrine\Migrations" namespace. ' );
@@ -341,7 +341,7 @@ public function testInvalidService() : void
341
341
$ container ->compile ();
342
342
}
343
343
344
- public function testCanNotSpecifyBothEmAndConnection () : void
344
+ public function testCanNotSpecifyBothEmAndConnection (): void
345
345
{
346
346
$ this ->expectExceptionMessage ('You cannot specify both "connection" and "em" in the DoctrineMigrationsBundle configurations ' );
347
347
$ this ->expectException (InvalidArgumentException::class);
@@ -360,7 +360,7 @@ public function testCanNotSpecifyBothEmAndConnection() : void
360
360
/**
361
361
* @param mixed[] $config
362
362
*/
363
- private function getContainer (array $ config ) : ContainerBuilder
363
+ private function getContainer (array $ config ): ContainerBuilder
364
364
{
365
365
$ container = $ this ->getContainerBuilder ();
366
366
@@ -377,9 +377,10 @@ private function getContainer(array $config) : ContainerBuilder
377
377
return $ container ;
378
378
}
379
379
380
- private function getContainerBuilder () : ContainerBuilder
380
+ private function getContainerBuilder (): ContainerBuilder
381
381
{
382
382
$ bundle = new TestBundle ();
383
+
383
384
return new ContainerBuilder (new ParameterBag ([
384
385
'kernel.debug ' => false ,
385
386
'kernel.bundles ' => [$ bundle ->getName () => TestBundle::class],
0 commit comments