Skip to content

Commit 0096266

Browse files
dawehnerfabpot
authored andcommitted
Add a way to reset the singleton
1 parent 8a8a929 commit 0096266

File tree

3 files changed

+19
-0
lines changed

3 files changed

+19
-0
lines changed

src/Symfony/Component/HttpFoundation/File/MimeType/MimeTypeGuesser.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public static function getInstance()
6767
return self::$instance;
6868
}
6969

70+
/**
71+
* Resets the singleton instance.
72+
*/
73+
public static function reset() {
74+
self::$instance = null;
75+
}
76+
7077
/**
7178
* Registers all natively provided mime type guessers.
7279
*/

src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,18 @@ public function testGuessExtensionIsBasedOnMimeType()
4545
$this->assertEquals('gif', $file->guessExtension());
4646
}
4747

48+
public function testGuessExtensionWithReset() {
49+
$file = new File(__DIR__.'/Fixtures/other-file.example');
50+
$guesser = $this->createMockGuesser($file->getPathname(), 'image/gif');
51+
MimeTypeGuesser::getInstance()->register($guesser);
52+
53+
$this->assertEquals('gif', $file->guessExtension());
54+
55+
MimeTypeGuesser::reset();
56+
57+
$this->assertNull($file->guessExtension());
58+
}
59+
4860
public function testConstructWhenFileNotExists()
4961
{
5062
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException');

src/Symfony/Component/HttpFoundation/Tests/File/Fixtures/other-file.example

Whitespace-only changes.

0 commit comments

Comments
 (0)