|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\AddMimeTypeGuesserPass; |
| 16 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 17 | +use Symfony\Component\DependencyInjection\Definition; |
| 18 | +use Symfony\Component\DependencyInjection\Reference; |
| 19 | +use Symfony\Component\Mime\FileinfoMimeTypeGuesser; |
| 20 | +use Symfony\Component\Mime\MimeTypes; |
| 21 | + |
| 22 | +class AddMimeTypeGuesserPassTest extends TestCase |
| 23 | +{ |
| 24 | + public function testTags() |
| 25 | + { |
| 26 | + $container = new ContainerBuilder(); |
| 27 | + $container->addCompilerPass(new AddMimeTypeGuesserPass()); |
| 28 | + |
| 29 | + $definition = new Definition(FileinfoMimeTypeGuesser::class); |
| 30 | + $definition->addArgument('/path/to/magic/file'); |
| 31 | + $definition->addTag('mime.mime_type_guesser'); |
| 32 | + $container->setDefinition('some_mime_type_guesser', $definition->setPublic(true)); |
| 33 | + $container->register('mime_types', MimeTypes::class)->setPublic(true); |
| 34 | + $container->compile(); |
| 35 | + |
| 36 | + $router = $container->getDefinition('mime_types'); |
| 37 | + $calls = $router->getMethodCalls(); |
| 38 | + $this->assertCount(1, $calls); |
| 39 | + $this->assertEquals('registerGuesser', $calls[0][0]); |
| 40 | + $this->assertEquals(new Reference('some_mime_type_guesser'), $calls[0][1][0]); |
| 41 | + } |
| 42 | +} |
0 commit comments