|
5 | 5 | use League\Glide\Responses\SymfonyResponseFactory; |
6 | 6 | use Mockery; |
7 | 7 | use PHPUnit\Framework\TestCase; |
| 8 | +use Symfony\Component\HttpFoundation\Request; |
8 | 9 |
|
9 | 10 | class SymfonyResponseFactoryTest extends TestCase |
10 | 11 | { |
@@ -38,4 +39,24 @@ public function testCreate(): void |
38 | 39 | self::assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires')); |
39 | 40 | self::assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control')); |
40 | 41 | } |
| 42 | + |
| 43 | + public function testCreateWithRequest(): void |
| 44 | + { |
| 45 | + $cache = Mockery::mock('League\Flysystem\FilesystemOperator', function ($mock) { |
| 46 | + $mock->shouldReceive('mimeType')->andReturn('image/jpeg')->once(); |
| 47 | + $mock->shouldReceive('fileSize')->andReturn(0)->once(); |
| 48 | + $mock->shouldReceive('readStream'); |
| 49 | + $mock->shouldReceive('lastModified')->andReturn(strtotime('2025-01-01')); |
| 50 | + }); |
| 51 | + |
| 52 | + $factory = new SymfonyResponseFactory(new Request()); |
| 53 | + $response = $factory->create($cache, ''); |
| 54 | + |
| 55 | + self::assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); |
| 56 | + self::assertEquals('image/jpeg', $response->headers->get('Content-Type')); |
| 57 | + self::assertEquals('0', $response->headers->get('Content-Length')); |
| 58 | + self::assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires')); |
| 59 | + self::assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control')); |
| 60 | + self::assertEquals('Wed, 01 Jan 2025 00:00:00 GMT', $response->headers->get('Last-Modified')); |
| 61 | + } |
41 | 62 | } |
0 commit comments