Skip to content

Commit

Permalink
bug #24856 [FrameworkBundle] Add default mapping path for validator c…
Browse files Browse the repository at this point in the history
…omponent in bundle-less app (yceruto)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Add default mapping path for validator component in bundle-less app

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | ToDo

Same approach of #24833

Commits
-------

4e0daec Add default mapping path for validator component
  • Loading branch information
fabpot committed Nov 10, 2017
2 parents 93f206e + 4e0daec commit c549e3c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Expand Up @@ -1291,6 +1291,11 @@ private function registerValidatorMapping(ContainerBuilder $container, array $co
}
}

$projectDir = $container->getParameter('kernel.project_dir');
if ($container->fileExists($dir = $projectDir.'/config/validator', '/^$/')) {
$this->registerMappingFilesFromDir($dir, $fileRecorder);
}

$this->registerMappingFilesFromConfig($container, $config, $fileRecorder);
}

Expand Down
Expand Up @@ -543,9 +543,13 @@ public function testTemplatingRequiresAtLeastOneEngine()
public function testValidation()
{
$container = $this->createContainerFromFile('full');
$projectDir = $container->getParameter('kernel.project_dir');

$ref = new \ReflectionClass('Symfony\Component\Form\Form');
$xmlMappings = array(dirname($ref->getFileName()).'/Resources/config/validation.xml');
$xmlMappings = array(
dirname($ref->getFileName()).'/Resources/config/validation.xml',
strtr($projectDir.'/config/validator/foo.xml', '/', DIRECTORY_SEPARATOR),
);

$calls = $container->getDefinition('validator.builder')->getMethodCalls();

Expand Down Expand Up @@ -633,7 +637,7 @@ public function testValidationPaths()
$this->assertEquals(array(new Reference('validator.mapping.cache.symfony')), $calls[7][1]);

$xmlMappings = $calls[3][1][0];
$this->assertCount(2, $xmlMappings);
$this->assertCount(3, $xmlMappings);
try {
// Testing symfony/symfony
$this->assertStringEndsWith('Component'.DIRECTORY_SEPARATOR.'Form/Resources/config/validation.xml', $xmlMappings[0]);
Expand All @@ -659,7 +663,7 @@ public function testValidationPathsUsingCustomBundlePath()

$calls = $container->getDefinition('validator.builder')->getMethodCalls();
$xmlMappings = $calls[3][1][0];
$this->assertCount(2, $xmlMappings);
$this->assertCount(3, $xmlMappings);

try {
// Testing symfony/symfony
Expand Down Expand Up @@ -701,7 +705,7 @@ public function testValidationMapping()
$calls = $container->getDefinition('validator.builder')->getMethodCalls();

$this->assertSame('addXmlMappings', $calls[3][0]);
$this->assertCount(2, $calls[3][1][0]);
$this->assertCount(3, $calls[3][1][0]);

$this->assertSame('addYamlMappings', $calls[4][0]);
$this->assertCount(3, $calls[4][1][0]);
Expand Down
Empty file.

0 comments on commit c549e3c

Please sign in to comment.