Skip to content

Commit

Permalink
Add a way to reset the singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
dawehner authored and fabpot committed Jul 5, 2015
1 parent 8a8a929 commit 0096266
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Expand Up @@ -67,6 +67,13 @@ public static function getInstance()
return self::$instance;
}

/**
* Resets the singleton instance.
*/
public static function reset() {
self::$instance = null;
}

/**
* Registers all natively provided mime type guessers.
*/
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Component/HttpFoundation/Tests/File/FileTest.php
Expand Up @@ -45,6 +45,18 @@ public function testGuessExtensionIsBasedOnMimeType()
$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');
Expand Down
Empty file.

0 comments on commit 0096266

Please sign in to comment.