Skip to content

Commit aacd2c3

Browse files
committed
Merge branch '2.4' into 2.5
* 2.4: Fixed failed config schema loads due to libxml_disable_entity_loader usage. enabled PHP 5.6 for tests [Process] Fix ExecutableFinder with open basedir Refactored the CssSelector to remove the circular object graph Fix mocks to support >=5.5.14 and >=5.4.30 [ClassLoader] fixed PHP warning on PHP 5.3 [Validator] added Lithuanian translation for empty file Added missing dutch translations [Components][Serializer] optional constructor arguments can be omitted during the denormalization process [DomCrawler] properly handle buttons with single and double quotes inside the name attribute Added missing pt and pt_BR translations
2 parents 69f0f70 + b6ef1c1 commit aacd2c3

File tree

2 files changed

+47
-12
lines changed

2 files changed

+47
-12
lines changed

Resources/stubs/FakeFile.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\HttpFoundation\Resources\stubs;
13+
14+
use Symfony\Component\HttpFoundation\File\File as OrigFile;
15+
16+
class FakeFile extends OrigFile
17+
{
18+
private $realpath;
19+
20+
public function __construct($realpath, $path)
21+
{
22+
$this->realpath = $realpath;
23+
parent::__construct($path, false);
24+
}
25+
26+
public function isReadable()
27+
{
28+
return true;
29+
}
30+
31+
public function getRealpath()
32+
{
33+
return $this->realpath;
34+
}
35+
36+
public function getSize()
37+
{
38+
return 42;
39+
}
40+
41+
public function getMTime()
42+
{
43+
return time();
44+
}
45+
}

Tests/BinaryFileResponseTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Symfony\Component\HttpFoundation\BinaryFileResponse;
1515
use Symfony\Component\HttpFoundation\Request;
1616
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
17+
use Symfony\Component\HttpFoundation\Resources\stubs\FakeFile;
1718

1819
class BinaryFileResponseTest extends ResponseTestCase
1920
{
@@ -179,18 +180,7 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
179180
$request->headers->set('X-Sendfile-Type', 'X-Accel-Redirect');
180181
$request->headers->set('X-Accel-Mapping', $mapping);
181182

182-
$file = $this->getMockBuilder('Symfony\Component\HttpFoundation\File\File')
183-
->setConstructorArgs(array(__DIR__.'/File/Fixtures/test'))
184-
->getMock();
185-
$file->expects($this->any())
186-
->method('getRealPath')
187-
->will($this->returnValue($realpath));
188-
$file->expects($this->any())
189-
->method('isReadable')
190-
->will($this->returnValue(true));
191-
$file->expects($this->any())
192-
->method('getMTime')
193-
->will($this->returnValue(time()));
183+
$file = new FakeFile($realpath, __DIR__.'/File/Fixtures/test');
194184

195185
BinaryFileResponse::trustXSendFileTypeHeader();
196186
$response = new BinaryFileResponse($file);

0 commit comments

Comments
 (0)