Exemple #1
0
 /**
  * @requires extension fileinfo
  */
 public function testGuessExtensionWithReset()
 {
     $file = new File(__DIR__ . '/Fixtures/other-file.example');
     $guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
     MimeTypeGuesser::getInstance()->register($guesser);
     $this->assertEquals('gif', $file->guessExtension());
     MimeTypeGuesser::reset();
     $this->assertNull($file->guessExtension());
 }
 /**
  * A helper function to register with Symfony's singleton MIME type guesser.
  *
  * Symfony's default mimetype guessers have dependencies on PHP's fileinfo
  * extension or being able to run the system command file. Drupal's guesser
  * does not have these dependencies.
  *
  * @see \Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser
  */
 public static function registerWithSymfonyGuesser(ContainerInterface $container)
 {
     // Reset state, so we do not store more and more services during test runs.
     SymfonyMimeTypeGuesser::reset();
     $singleton = SymfonyMimeTypeGuesser::getInstance();
     $singleton->register($container->get('file.mime_type.guesser'));
 }