@@ -19,14 +19,15 @@ class BinaryFileResponseTest extends ResponseTestCase
19
19
{
20
20
public function testConstruction ()
21
21
{
22
- $ response = new BinaryFileResponse ('README.md ' , 404 , array ('X-Header ' => 'Foo ' ), true , null , true , true );
22
+ $ file = __DIR__ . '/../README.md ' ;
23
+ $ response = new BinaryFileResponse ($ file , 404 , array ('X-Header ' => 'Foo ' ), true , null , true , true );
23
24
$ this ->assertEquals (404 , $ response ->getStatusCode ());
24
25
$ this ->assertEquals ('Foo ' , $ response ->headers ->get ('X-Header ' ));
25
26
$ this ->assertTrue ($ response ->headers ->has ('ETag ' ));
26
27
$ this ->assertTrue ($ response ->headers ->has ('Last-Modified ' ));
27
28
$ this ->assertFalse ($ response ->headers ->has ('Content-Disposition ' ));
28
29
29
- $ response = BinaryFileResponse::create (' README.md ' , 404 , array (), true , ResponseHeaderBag::DISPOSITION_INLINE );
30
+ $ response = BinaryFileResponse::create ($ file , 404 , array (), true , ResponseHeaderBag::DISPOSITION_INLINE );
30
31
$ this ->assertEquals (404 , $ response ->getStatusCode ());
31
32
$ this ->assertFalse ($ response ->headers ->has ('ETag ' ));
32
33
$ this ->assertEquals ('inline; filename="README.md" ' , $ response ->headers ->get ('Content-Disposition ' ));
@@ -37,13 +38,13 @@ public function testConstruction()
37
38
*/
38
39
public function testSetContent ()
39
40
{
40
- $ response = new BinaryFileResponse (' README.md ' );
41
+ $ response = new BinaryFileResponse (__FILE__ );
41
42
$ response ->setContent ('foo ' );
42
43
}
43
44
44
45
public function testGetContent ()
45
46
{
46
- $ response = new BinaryFileResponse (' README.md ' );
47
+ $ response = new BinaryFileResponse (__FILE__ );
47
48
$ this ->assertFalse ($ response ->getContent ());
48
49
}
49
50
@@ -160,7 +161,7 @@ public function testXSendfile()
160
161
$ request ->headers ->set ('X-Sendfile-Type ' , 'X-Sendfile ' );
161
162
162
163
BinaryFileResponse::trustXSendfileTypeHeader ();
163
- $ response = BinaryFileResponse::create (' README.md ' );
164
+ $ response = BinaryFileResponse::create (__DIR__ . ' /../ README.md ' );
164
165
$ response ->prepare ($ request );
165
166
166
167
$ this ->expectOutputString ('' );
@@ -187,9 +188,12 @@ public function testXAccelMapping($realpath, $mapping, $virtual)
187
188
$ file ->expects ($ this ->any ())
188
189
->method ('isReadable ' )
189
190
->will ($ this ->returnValue (true ));
191
+ $ file ->expects ($ this ->any ())
192
+ ->method ('getMT
8D13
ime ' )
193
+ ->will ($ this ->returnValue (time ()));
190
194
191
195
BinaryFileResponse::trustXSendFileTypeHeader ();
192
- $ response = new BinaryFileResponse (' README.md ' );
196
+ $ response = new BinaryFileResponse ($ file );
193
197
$ reflection = new \ReflectionObject ($ response );
194
198
$ property = $ reflection ->getProperty ('file ' );
195
199
$ property ->setAccessible (true );
@@ -209,6 +213,6 @@ public function getSampleXAccelMappings()
209
213
210
214
protected function provideResponse ()
211
215
{
212
- return new BinaryFileResponse (' README.md ' );
216
+ return new BinaryFileResponse (__DIR__ . ' /../ README.md ' );
213
217
}
214
218
}
0 commit comments