AddMimeTypeGuesserPass example

use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\Mime\DependencyInjection\AddMimeTypeGuesserPass;
use Symfony\Component\Mime\FileinfoMimeTypeGuesser;
use Symfony\Component\Mime\MimeTypes;

class AddMimeTypeGuesserPassTest extends TestCase
{
    public function testTags()
    {
        $container = new ContainerBuilder();
        $container->addCompilerPass(new AddMimeTypeGuesserPass());

        $definition = new Definition(FileinfoMimeTypeGuesser::class);
        $definition->addArgument('/path/to/magic/file');
        $definition->addTag('mime.mime_type_guesser');
        $container->setDefinition('some_mime_type_guesser', $definition->setPublic(true));
        $container->register('mime_types', MimeTypes::class)->setPublic(true);
        $container->compile();

        $router = $container->getDefinition('mime_types');
        $calls = $router->getMethodCalls();
        $this->assertCount(1, $calls);
        
Home | Imprint | This part of the site doesn't use cookies.