80
80
use Symfony \Component \Translation \DependencyInjection \TranslatorPass ;
81
81
use Symfony \Component \Translation \LocaleSwitcher ;
82
82
use Symfony \Component \Validator \DependencyInjection \AddConstraintValidatorsPass ;
83
+ use Symfony \Component \Validator \DependencyInjection \AddGroupSequenceProvidersPass ;
83
84
use Symfony \Component \Validator \Validation ;
84
85
use Symfony \Component \Validator \Validator \ValidatorInterface ;
85
86
use Symfony \Component \Validator \ValidatorBuilder ;
@@ -1230,16 +1231,18 @@ public function testValidation()
1230
1231
1231
1232
$ annotations = !class_exists (FullStack::class);
1232
1233
1233
- $ this ->assertCount ($ annotations ? 7 : 6 , $ calls );
1234
+ $ this ->assertCount ($ annotations ? 8 : 7 , $ calls );
1234
1235
$ this ->assertSame ('setConstraintValidatorFactory ' , $ calls [0 ][0 ]);
1235
1236
$ this ->assertEquals ([new Reference ('validator.validator_factory ' )], $ calls [0 ][1 ]);
1236
- $ this ->assertSame ('setTranslator ' , $ calls [1 ][0 ]);
1237
- $ this ->assertEquals ([new Reference ('translator ' , ContainerBuilder::IGNORE_ON_INVALID_REFERENCE )], $ calls [1 ][1 ]);
1238
- $ this ->assertSame ('setTranslationDomain ' , $ calls [2 ][0 ]);
1239
- $ this ->assertSame (['%validator.translation_domain% ' ], $ calls [2 ][1 ]);
1240
- $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
1241
- $ this ->assertSame ([$ xmlMappings ], $ calls [3 ][1 ]);
1242
- $ i = 3 ;
1237
+ $ this ->assertSame ('setGroupSequenceProviderFactory ' , $ calls [1 ][0 ]);
1238
+ $ this ->assertEquals ([new Reference ('validator.group_sequence_provider_factory ' )], $ calls [1 ][1 ]);
1239
+ $ this ->assertSame ('setTranslator ' , $ calls [2 ][0 ]);
1240
+ $ this ->assertEquals ([new Reference ('translator ' , ContainerBuilder::IGNORE_ON_INVALID_REFERENCE )], $ calls [2 ][1 ]);
1241
+ $ this ->assertSame ('setTranslationDomain ' , $ calls [3 ][0 ]);
1242
+ $ this ->assertSame (['%validator.translation_domain% ' ], $ calls [3 ][1 ]);
1243
+ $ this ->assertSame ('addXmlMappings ' , $ calls [4 ][0 ]);
1244
+ $ this ->assertSame ([$ xmlMappings ], $ calls [4 ][1 ]);
1245
+ $ i = 4 ;
1243
1246
if ($ annotations ) {
1244
1247
$ this ->assertSame ('enableAnnotationMapping ' , $ calls [++$ i ][0 ]);
1245
1248
}
@@ -1288,12 +1291,12 @@ public function testValidationAnnotations()
1288
1291
1289
1292
$ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
1290
1293
1291
- $ this ->assertCount (7 , $ calls );
1292
- $ this ->assertSame ('enableAnnotationMapping ' , $ calls [4 ][0 ]);
1293
- $ this ->assertSame ('addMethodMapping ' , $ calls [5 ][0 ]);
1294
- $ this ->assertSame (['loadValidatorMetadata ' ], $ calls [5 ][1 ]);
1295
- $ this ->assertSame ('setMappingCache ' , $ calls [6 ][0 ]);
1296
- $ this ->assertEquals ([new Reference ('validator.mapping.cache.adapter ' )], $ calls [6 ][1 ]);
1294
+ $ this ->assertCount (8 , $ calls );
1295
+ $ this ->assertSame ('enableAnnotationMapping ' , $ calls [5 ][0 ]);
1296
+ $ this ->assertSame ('addMethodMapping ' , $ calls [6 ][0 ]);
1297
+ $ this ->assertSame (['loadValidatorMetadata ' ], $ calls [6 ][1 ]);
1298
+ $ this ->assertSame ('setMappingCache ' , $ calls [7 ][0 ]);
1299
+ $ this ->assertEquals ([new Reference ('validator.mapping.cache.adapter ' )], $ calls [7 ][1 ]);
1297
1300
// no cache this time
1298
1301
}
1299
1302
@@ -1308,14 +1311,14 @@ public function testValidationLegacyAnnotations()
1308
1311
1309
1312
$ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
1310
1313
1311
- $ this ->assertCount (8 , $ calls );
1312
- $ this ->assertSame ('enableAnnotationMapping ' , $ calls [4 ][0 ]);
1314
+ $ this ->assertCount (9 , $ calls );
1315
+ $ this ->assertSame ('enableAnnotationMapping ' , $ calls [5 ][0 ]);
1313
1316
if (method_exists (ValidatorBuilder::class, 'setDoctrineAnnotationReader ' )) {
1314
- $ this ->assertSame ('setDoctrineAnnotationReader ' , $ calls [5 ][0 ]);
1315
- $ this ->assertEquals ([new Reference ('annotation_reader ' )], $ calls [5 ][1 ]);
1316
- $ i = 6 ;
1317
+ $ this ->assertSame ('setDoctrineAnnotationReader ' , $ calls [6 ][0 ]);
1318
+ $ this ->assertEquals ([new Reference ('annotation_reader ' )], $ calls [6 ][1 ]);
1319
+ $ i = 7 ;
1317
1320
} else {
1318
- $ i = 5 ;
1321
+ $ i = 6 ;
1319
1322
}
1320
1323
$ this ->assertSame ('addMethodMapping ' , $ calls [$ i ][0 ]);
1321
1324
$ this ->assertSame (['loadValidatorMetadata ' ], $ calls [$ i ][1 ]);
@@ -1335,16 +1338,16 @@ public function testValidationPaths()
1335
1338
1336
1339
$ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
1337
1340
1338
- $ this ->assertCount (8 , $ calls );
1339
- $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
1340
- $ this ->assertSame ('addYamlMappings ' , $ calls [4 ][0 ]);
1341
- $ this ->assertSame ('enableAnnotationMapping ' , $ calls [5 ][0 ]);
1342
- $ this ->assertSame ('addMethodMapping ' , $ calls [6 ][0 ]);
1343
- $ this ->assertSame (['loadValidatorMetadata ' ], $ calls [6 ][1 ]);
1344
- $ this ->assertSame ('setMappingCache ' , $ calls [7 ][0 ]);
1345
- $ this ->assertEquals ([new Reference ('validator.mapping.cache.adapter ' )], $ calls [7 ][1 ]);
1341
+ $ this ->assertCount (9 , $ calls );
1342
+ $ this ->assertSame ('addXmlMappings ' , $ calls [4 ][0 ]);
1343
+ $ this ->assertSame ('addYamlMappings ' , $ calls [5 ][0 ]);
1344
+ $ this ->assertSame ('enableAnnotationMapping ' , $ calls [6 ][0 ]);
1345
+ $ this ->assertSame ('addMethodMapping ' , $ calls [7 ][0 ]);
1346
+ $ this ->assertSame (['loadValidatorMetadata ' ], $ calls [7 ][1 ]);
1347
+ $ this ->assertSame ('setMappingCache ' , $ calls [8 ][0 ]);
1348
+ $ this ->assertEquals ([new Reference ('validator.mapping.cache.adapter ' )], $ calls [8 ][1 ]);
1346
1349
1347
- $ xmlMappings = $ calls [3 ][1 ][0 ];
1350
+ $ xmlMappings = $ calls [4 ][1 ][0 ];
1348
1351
$ this ->assertCount (3 , $ xmlMappings );
1349
1352
try {
1350
1353
// Testing symfony/symfony
@@ -1355,7 +1358,7 @@ public function testValidationPaths()
1355
1358
}
1356
1359
$ this ->assertStringEndsWith ('TestBundle/Resources/config/validation.xml ' , $ xmlMappings [1 ]);
1357
1360
1358
- $ yamlMappings = $ calls [4 ][1 ][0 ];
1361
+ $ yamlMappings = $ calls [5 ][1 ][0 ];
1359
1362
$ this ->assertCount (1 , $ yamlMappings );
1360
1363
$ this ->assertStringEndsWith ('TestBundle/Resources/config/validation.yml ' , $ yamlMappings [0 ]);
1361
1364
}
@@ -1370,7 +1373,7 @@ public function testValidationPathsUsingCustomBundlePath()
1370
1373
]);
1371
1374
1372
1375
$ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
1373
- $ xmlMappings = $ calls [3 ][1 ][0 ];
1376
+ $ xmlMappings = $ calls [4 ][1 ][0 ];
1374
1377
$ this ->assertCount (3 , $ xmlMappings );
1375
1378
1376
1379
try {
@@ -1382,7 +1385,7 @@ public function testValidationPathsUsingCustomBundlePath()
1382
1385
}
1383
1386
$ this ->assertStringEndsWith ('CustomPathBundle/Resources/config/validation.xml ' , $ xmlMappings [1 ]);
1384
1387
1385
- $ yamlMappings = $ calls [4 ][1 ][0 ];
1388
+ $ yamlMappings = $ calls [5 ][1 ][0 ];
1386
1389
$ this ->assertCount (1 , $ yamlMappings );
1387
1390
$ this ->assertStringEndsWith ('CustomPathBundle/Resources/config/validation.yml ' , $ yamlMappings [0 ]);
1388
1391
}
@@ -1395,9 +1398,9 @@ public function testValidationNoStaticMethod()
1395
1398
1396
1399
$ annotations = !class_exists (FullStack::class);
1397
1400
1398
- $ this ->assertCount ($ annotations ? 6 : 5 , $ calls );
1399
- $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
1400
- $ i = 3 ;
1401
+ $ this ->assertCount ($ annotations ? 7 : 6 , $ calls );
1402
+ $ this ->assertSame ('addXmlMappings ' , $ calls [4 ][0 ]);
1403
+ $ i = 4 ;
1401
1404
if ($ annotations ) {
1402
1405
$ this ->assertSame ('enableAnnotationMapping ' , $ calls [++$ i ][0 ]);
1403
1406
}
@@ -1426,14 +1429,14 @@ public function testValidationMapping()
1426
1429
1427
1430
$ calls = $ container ->getDefinition ('validator.builder ' )->getMethodCalls ();
1428
1431
1429
- $ this ->assertSame ('addXmlMappings ' , $ calls [3 ][0 ]);
1430
- $ this ->assertCount (3 , $ calls [3 ][1 ][0 ]);
1431
-
1432
- $ this ->assertSame ('addYamlMappings ' , $ calls [4 ][0 ]);
1432
+ $ this ->assertSame ('addXmlMappings ' , $ calls [4 ][0 ]);
1433
1433
$ this ->assertCount (3 , $ calls [4 ][1 ][0 ]);
1434
- $ this ->assertStringContainsString ('foo.yml ' , $ calls [4 ][1 ][0 ][0 ]);
1435
- $ this ->assertStringContainsString ('validation.yml ' , $ calls [4 ][1 ][0 ][1 ]);
1436
- $ this ->assertStringContainsString ('validation.yaml ' , $ calls [4 ][1 ][0 ][2 ]);
1434
+
1435
+ $ this ->assertSame ('addYamlMappings ' , $ calls [5 ][0 ]);
1436
+ $ this ->assertCount (3 , $ calls [5 ][1 ][0 ]);
1437
+ $ this ->assertStringContainsString ('foo.yml ' , $ calls [5 ][1 ][0 ][0 ]);
1438
+ $ this ->assertStringContainsString ('validation.yml ' , $ calls [5 ][1 ][0 ][1 ]);
1439
+ $ this ->assertStringContainsString ('validation.yaml ' , $ calls [5 ][1 ][0 ][2 ]);
1437
1440
}
1438
1441
1439
1442
public function testValidationAutoMapping ()
@@ -2383,7 +2386,7 @@ protected function createContainerFromFile(string $file, array $data = [], bool
2383
2386
$ container ->getCompilerPassConfig ()->setAfterRemovingPasses ([]);
2384
2387
}
2385
2388
$ container ->getCompilerPassConfig ()->setBeforeOptimizationPasses ([new LoggerPass ()]);
2386
- $ container ->getCompilerPassConfig ()->setBeforeRemovingPasses ([new AddConstraintValidatorsPass (), new TranslatorPass ()]);
2389
+ $ container ->getCompilerPassConfig ()->setBeforeRemovingPasses ([new AddConstraintValidatorsPass (), new AddGroupSequenceProvidersPass (), new TranslatorPass ()]);
2387
2390
$ container ->getCompilerPassConfig ()->setAfterRemovingPasses ([new AddAnnotationsCachedReaderPass ()]);
2388
2391
2389
2392
if (!$ compile ) {
0 commit comments