Skip to content

Commit 90eca43

Browse files
committed
Add tests
1 parent 644a645 commit 90eca43

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
/*
6+
* This file is part of the Sonata Project package.
7+
*
8+
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
9+
*
10+
* For the full copyright and license information, please view the LICENSE
11+
* file that was distributed with this source code.
12+
*/
13+
14+
namespace Sonata\UserBundle\Tests\DependencyInjection\Compiler;
15+
16+
use Matthias\SymfonyDependencyInjectionTest\PhpUnit\AbstractCompilerPassTestCase;
17+
use Sonata\UserBundle\DependencyInjection\Compiler\ValidationCompilerPass;
18+
use Symfony\Component\DependencyInjection\ContainerBuilder;
19+
use Symfony\Component\DependencyInjection\Definition;
20+
use Symfony\Component\Validator\ValidatorBuilder;
21+
22+
final class ValidationCompilerPassTest extends AbstractCompilerPassTestCase
23+
{
24+
public function testProcess(): void
25+
{
26+
$this->container->setParameter('sonata.user.manager_type', 'orm');
27+
$this->container->setDefinition('validator.builder', new Definition(ValidatorBuilder::class));
28+
29+
$this->compile();
30+
31+
$filePath = (new \ReflectionClass(ValidationCompilerPass::class))->getFileName();
32+
\assert(\is_string($filePath));
33+
$compilePassDir = \dirname($filePath);
34+
35+
$this->assertContainerBuilderHasServiceDefinitionWithMethodCall(
36+
'validator.builder',
37+
'addXmlMapping',
38+
[$compilePassDir.'/../../Resources/config/storage-validation/orm.xml']
39+
);
40+
}
41+
42+
protected function registerCompilerPass(ContainerBuilder $container): void
43+
{
44+
$container->addCompilerPass(new ValidationCompilerPass());
45+
}
46+
}

0 commit comments

Comments
 (0)