Add a way to reset the singleton
This commit is contained in:
parent
8a8a929d5c
commit
0096266009
|
@ -67,6 +67,13 @@ class MimeTypeGuesser implements MimeTypeGuesserInterface
|
|||
return self::$instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the singleton instance.
|
||||
*/
|
||||
public static function reset() {
|
||||
self::$instance = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all natively provided mime type guessers.
|
||||
*/
|
||||
|
|
|
@ -45,6 +45,18 @@ class FileTest extends \PHPUnit_Framework_TestCase
|
|||
$this->assertEquals('gif', $file->guessExtension());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
public function testConstructWhenFileNotExists()
|
||||
{
|
||||
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');
|
||||
|
|
Reference in New Issue