diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml
index 9b82195..f629a63 100644
--- a/.github/workflows/unit-tests.yaml
+++ b/.github/workflows/unit-tests.yaml
@@ -10,15 +10,23 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
- php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
+ php-version: [8.1, 8.2, 8.3, 8.4]
+ symfony-version: [^5, ^6, ^7]
+ glide-version: [^2, ^3]
+ dependencies: [lowest, stable]
+ exclude:
+ - php-version: 8.1
+ symfony-version: ^7
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install PHP
uses: shivammathur/setup-php@v2
with:
- php-version: ${{ matrix.php-versions }}
+ php-version: ${{ matrix.php-version }}
- name: Install dependencies
- run: composer install --no-interaction --no-ansi
+ run: |
+ composer require "symfony/http-foundation:${{ matrix.symfony-version }}" "league/glide:${{ matrix.glide-version }}" --no-interaction --no-update
+ composer update --prefer-${{ matrix.dependencies }} --prefer-dist --no-interaction --no-suggest --with-all-dependencies
- name: PHPUnit
run: php vendor/bin/phpunit
diff --git a/composer.json b/composer.json
index 96477b4..375618f 100644
--- a/composer.json
+++ b/composer.json
@@ -11,12 +11,13 @@
}
],
"require": {
- "league/glide": "^2.0",
- "symfony/http-foundation": "^2.3|^3.0|^4.0|^5.0|^6.0|^7.0"
+ "php": "^8.1",
+ "league/glide": "^2.0|^3.0",
+ "symfony/http-foundation": "^5|^6|^7"
},
"require-dev": {
"mockery/mockery": "^1.3.3",
- "phpunit/phpunit": "^8.5|^9.4"
+ "phpunit/phpunit": "^10.5"
},
"autoload": {
"psr-4": {
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 2c7e087..c915551 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -5,16 +5,9 @@
tests/
-
-
+
+
src/
-
-
-
-
-
-
-
-
-
+
+
\ No newline at end of file
diff --git a/src/Responses/SymfonyResponseFactory.php b/src/Responses/SymfonyResponseFactory.php
index ca4c1c5..23c5c95 100644
--- a/src/Responses/SymfonyResponseFactory.php
+++ b/src/Responses/SymfonyResponseFactory.php
@@ -18,7 +18,7 @@ class SymfonyResponseFactory implements ResponseFactoryInterface
* Create SymfonyResponseFactory instance.
* @param Request|null $request Request object to check "is not modified".
*/
- public function __construct(Request $request = null)
+ public function __construct(?Request $request = null)
{
$this->request = $request;
}
diff --git a/tests/Responses/SymfonyResponseFactoryTest.php b/tests/Responses/SymfonyResponseFactoryTest.php
index 6250077..3363f7a 100644
--- a/tests/Responses/SymfonyResponseFactoryTest.php
+++ b/tests/Responses/SymfonyResponseFactoryTest.php
@@ -5,6 +5,7 @@
use League\Glide\Responses\SymfonyResponseFactory;
use Mockery;
use PHPUnit\Framework\TestCase;
+use Symfony\Component\HttpFoundation\Request;
class SymfonyResponseFactoryTest extends TestCase
{
@@ -38,4 +39,24 @@ public function testCreate(): void
self::assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires'));
self::assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control'));
}
+
+ public function testCreateWithRequest(): void
+ {
+ $cache = Mockery::mock('League\Flysystem\FilesystemOperator', function ($mock) {
+ $mock->shouldReceive('mimeType')->andReturn('image/jpeg')->once();
+ $mock->shouldReceive('fileSize')->andReturn(0)->once();
+ $mock->shouldReceive('readStream');
+ $mock->shouldReceive('lastModified')->andReturn(strtotime('2025-01-01'));
+ });
+
+ $factory = new SymfonyResponseFactory(new Request());
+ $response = $factory->create($cache, '');
+
+ self::assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
+ self::assertEquals('image/jpeg', $response->headers->get('Content-Type'));
+ self::assertEquals('0', $response->headers->get('Content-Length'));
+ self::assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires'));
+ self::assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control'));
+ self::assertEquals('Wed, 01 Jan 2025 00:00:00 GMT', $response->headers->get('Last-Modified'));
+ }
}