Skip to content

Commit 758ff20

Browse files
authored
Merge pull request #21 from barryvdh/allow-glide-3
Allow glide 3 and update testsuite
2 parents 56db02b + 4d71734 commit 758ff20

5 files changed

Lines changed: 41 additions & 18 deletions

File tree

.github/workflows/unit-tests.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,23 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3', '8.4']
13+
php-version: [8.1, 8.2, 8.3, 8.4]
14+
symfony-version: [^5, ^6, ^7]
15+
glide-version: [^2, ^3]
16+
dependencies: [lowest, stable]
17+
exclude:
18+
- php-version: 8.1
19+
symfony-version: ^7
1420
steps:
1521
- name: Checkout
1622
uses: actions/checkout@v4
1723
- name: Install PHP
1824
uses: shivammathur/setup-php@v2
1925
with:
20-
php-version: ${{ matrix.php-versions }}
26+
php-version: ${{ matrix.php-version }}
2127
- name: Install dependencies
22-
run: composer install --no-interaction --no-ansi
28+
run: |
29+
composer require "symfony/http-foundation:${{ matrix.symfony-version }}" "league/glide:${{ matrix.glide-version }}" --no-interaction --no-update
30+
composer update --prefer-${{ matrix.dependencies }} --prefer-dist --no-interaction --no-suggest --with-all-dependencies
2331
- name: PHPUnit
2432
run: php vendor/bin/phpunit

composer.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
}
1212
],
1313
"require": {
14-
"league/glide": "^2.0",
15-
"symfony/http-foundation": "^2.3|^3.0|^4.0|^5.0|^6.0|^7.0|^8.0"
14+
"php": "^8.1",
15+
"league/glide": "^2.0|^3.0",
16+
"symfony/http-foundation": "^5|^6|^7|^8"
1617
},
1718
"require-dev": {
1819
"mockery/mockery": "^1.3.3",
19-
"phpunit/phpunit": "^8.5|^9.4"
20+
"phpunit/phpunit": "^10.5"
2021
},
2122
"autoload": {
2223
"psr-4": {

phpunit.xml.dist

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55
<directory suffix="Test.php">tests/</directory>
66
</testsuite>
77
</testsuites>
8-
<filter>
9-
<whitelist>
8+
<source>
9+
<include>
1010
<directory suffix=".php">src/</directory>
11-
</whitelist>
12-
</filter>
13-
<logging>
14-
<log type="tap" target="build/report.tap"/>
15-
<log type="junit" target="build/report.junit.xml"/>
16-
<log type="coverage-html" target="build/coverage" charset="UTF-8" yui="true" highlight="true"/>
17-
<log type="coverage-text" target="build/coverage.txt"/>
18-
<log type="coverage-clover" target="build/logs/clover.xml"/>
19-
</logging>
11+
</include>
12+
</source>
2013
</phpunit>

src/Responses/SymfonyResponseFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SymfonyResponseFactory implements ResponseFactoryInterface
1818
* Create SymfonyResponseFactory instance.
1919
* @param Request|null $request Request object to check "is not modified".
2020
*/
21-
public function __construct(Request $request = null)
21+
public function __construct(?Request $request = null)
2222
{
2323
$this->request = $request;
2424
}

tests/Responses/SymfonyResponseFactoryTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use League\Glide\Responses\SymfonyResponseFactory;
66
use Mockery;
77
use PHPUnit\Framework\TestCase;
8+
use Symfony\Component\HttpFoundation\Request;
89

910
class SymfonyResponseFactoryTest extends TestCase
1011
{
@@ -38,4 +39,24 @@ public function testCreate(): void
3839
self::assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires'));
3940
self::assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control'));
4041
}
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+
}
4162
}

0 commit comments

Comments
 (0)