Skip to content

Commit

Permalink
Merge branch '2.8'
Browse files Browse the repository at this point in the history
* 2.8: (21 commits)
  Fix merge
  Fix typo
  Various fixes esp. on Windows
  Fix the validation of form resources to register the default theme
  Fix the retrieval of the value with property path when using a loader
  [appveyor] minor enhancements
  [Process] Disable failing tests on Windows
  [Translation] Fix the string casting in the XliffFileLoader
  Windows and Intl fixes
  Add appveyor.yml for C.I. on Windows
  [VarDumper] fixed HtmlDumper to target specific the head tag
  [travis] merge php: nightly and deps=high test-matrix lines
  consistently use str_replace to unify directory separators
  Support omitting the <target> node in an .xlf file.
  Fix the handling of values for multiple choice types
  moved PHP nightly to PHP 7.0
  fixed tests using deprecation features
  [Form] made deprecation notice more precise
  fixed CS
  Fix BC break after split of ACL from core
  ...

Conflicts:
	.travis.yml
	composer.json
	src/Symfony/Bundle/TwigBundle/DependencyInjection/Configuration.php
	src/Symfony/Component/Intl/DateFormatter/IntlDateFormatter.php
	src/Symfony/Component/Intl/Tests/DateFormatter/AbstractIntlDateFormatterTest.php
	src/Symfony/Component/Locale/Tests/LocaleTest.php
  • Loading branch information
nicolas-grekas committed Aug 27, 2015
2 parents 3f7887b + 3f179eb commit a38a6b0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
6 changes: 3 additions & 3 deletions Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -1852,9 +1852,9 @@ protected function prepareBaseUrl()
return $prefix;
}

if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/').'/')) {
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR).'/')) {
// directory portion of $baseUrl matches
return rtrim($prefix, '/');
return rtrim($prefix, '/'.DIRECTORY_SEPARATOR);
}

$truncatedRequestUri = $requestUri;
Expand All @@ -1875,7 +1875,7 @@ protected function prepareBaseUrl()
$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
}

return rtrim($baseUrl, '/');
return rtrim($baseUrl, '/'.DIRECTORY_SEPARATOR);
}

/**
Expand Down
18 changes: 9 additions & 9 deletions Tests/BinaryFileResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function testGetContent()
*/
public function testRequests($requestRange, $offset, $length, $responseRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag();

// do a request to get the ETag
$request = Request::create('/');
Expand Down Expand Up @@ -96,7 +96,7 @@ public function provideRanges()
*/
public function testFullFileRequests($requestRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag();

// prepare a request for a range of the testing file
$request = Request::create('/');
Expand Down Expand Up @@ -131,7 +131,7 @@ public function provideFullFileRanges()
*/
public function testInvalidRequests($requestRange)
{
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif')->setAutoEtag();
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'))->setAutoEtag();

// prepare a request for a range of the testing file
$request = Request::create('/');
Expand Down Expand Up @@ -159,7 +159,7 @@ public function testXSendfile()
$request->headers->set('X-Sendfile-Type', 'X-Sendfile');

BinaryFileResponse::trustXSendfileTypeHeader();
$response = BinaryFileResponse::create(__DIR__.'/../README.md');
$response = BinaryFileResponse::create(__DIR__.'/../README.md', 200, array('Content-Type' => 'application/octet-stream'));
$response->prepare($request);

$this->expectOutputString('');
Expand All @@ -180,7 +180,7 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
$file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test');

BinaryFileResponse::trustXSendfileTypeHeader();
$response = new BinaryFileResponse($file);
$response = new BinaryFileResponse($file, 200, array('Content-Type' => 'application/octet-stream'));
$reflection = new \ReflectionObject($response);
$property = $reflection->getProperty('file');
$property->setAccessible(true);
Expand All @@ -199,7 +199,7 @@ public function testDeleteFileAfterSend()
$realPath = realpath($path);
$this->assertFileExists($realPath);

$response = new BinaryFileResponse($realPath);
$response = new BinaryFileResponse($realPath, 200, array('Content-Type' => 'application/octet-stream'));
$response->deleteFileAfterSend(true);

$response->prepare($request);
Expand All @@ -211,7 +211,7 @@ public function testDeleteFileAfterSend()
public function testAcceptRangeOnUnsafeMethods()
{
$request = Request::create('/', 'POST');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'));
$response->prepare($request);

$this->assertEquals('none', $response->headers->get('Accept-Ranges'));
Expand All @@ -220,7 +220,7 @@ public function testAcceptRangeOnUnsafeMethods()
public function testAcceptRangeNotOverriden()
{
$request = Request::create('/', 'POST');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif');
$response = BinaryFileResponse::create(__DIR__.'/File/Fixtures/test.gif', 200, array('Content-Type' => 'application/octet-stream'));
$response->headers->set('Accept-Ranges', 'foo');
$response->prepare($request);

Expand All @@ -237,7 +237,7 @@ public function getSampleXAccelMappings()

protected function provideResponse()
{
return new BinaryFileResponse(__DIR__.'/../README.md');
return new BinaryFileResponse(__DIR__.'/../README.md', 200, array('Content-Type' => 'application/octet-stream'));
}

public static function tearDownAfterClass()
Expand Down
3 changes: 3 additions & 0 deletions Tests/File/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function testGuessExtensionIsBasedOnMimeType()
$this->assertEquals('gif', $file->guessExtension());
}

/**
* @requires extension fileinfo
*/
public function testGuessExtensionWithReset()
{
$file = new File(__DIR__.'/Fixtures/other-file.example');
Expand Down
31 changes: 9 additions & 22 deletions Tests/File/MimeType/MimeTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@
use Symfony\Component\HttpFoundation\File\MimeType\MimeTypeGuesser;
use Symfony\Component\HttpFoundation\File\MimeType\FileBinaryMimeTypeGuesser;

/**
* @requires extension fileinfo
*/
class MimeTypeTest extends \PHPUnit_Framework_TestCase
{
protected $path;

public function testGuessImageWithoutExtension()
{
if (extension_loaded('fileinfo')) {
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}

public function testGuessImageWithDirectory()
Expand All @@ -38,29 +37,17 @@ public function testGuessImageWithFileBinaryMimeTypeGuesser()
{
$guesser = MimeTypeGuesser::getInstance();
$guesser->register(new FileBinaryMimeTypeGuesser());
if (extension_loaded('fileinfo')) {
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test'));
}

public function testGuessImageWithKnownExtension()
{
if (extension_loaded('fileinfo')) {
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
}
$this->assertEquals('image/gif', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/test.gif'));
}

public function testGuessFileWithUnknownExtension()
{
if (extension_loaded('fileinfo')) {
$this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
} else {
$this->assertNull(MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
}
$this->assertEquals('application/octet-stream', MimeTypeGuesser::getInstance()->guess(__DIR__.'/../Fixtures/.unknownextension'));
}

public function testGuessWithIncorrectPath()
Expand All @@ -75,15 +62,15 @@ public function testGuessWithNonReadablePath()
$this->markTestSkipped('Can not verify chmod operations on Windows');
}

if ('root' === get_current_user()) {
if (!getenv('USER') || 'root' === getenv('USER')) {
$this->markTestSkipped('This test will fail if run under superuser');
}

$path = __DIR__.'/../Fixtures/to_delete';
touch($path);
@chmod($path, 0333);

if (get_current_user() != 'root' && substr(sprintf('%o', fileperms($path)), -4) == '0333') {
if (substr(sprintf('%o', fileperms($path)), -4) == '0333') {
$this->setExpectedException('Symfony\Component\HttpFoundation\File\Exception\AccessDeniedException');
MimeTypeGuesser::getInstance()->guess($path);
} else {
Expand Down

0 comments on commit a38a6b0

Please sign in to comment.