Skip to content

Commit f190729

Browse files
authored
Merge pull request #9 from Lustmored/master
Use Glide 2.0
2 parents 8162ec0 + 6638a98 commit f190729

File tree

5 files changed

+50
-45
lines changed

5 files changed

+50
-45
lines changed

.github/workflows/unit-tests.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: "Unit Tests"
2+
3+
on:
4+
pull_request:
5+
push:
6+
workflow_dispatch:
7+
8+
jobs:
9+
unit-tests:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
php-versions: ['7.2', '7.3', '7.4', '8.0']
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v2
17+
- name: Install PHP
18+
uses: shivammathur/setup-php@v2
19+
with:
20+
php-version: ${{ matrix.php-versions }}
21+
- name: Install dependencies
22+
run: composer install --no-interaction --no-ansi
23+
- name: PHPUnit
24+
run: php vendor/bin/phpunit

.travis.yml

Lines changed: 0 additions & 21 deletions
This file was deleted.

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
}
1212
],
1313
"require": {
14-
"league/glide": "^1.0",
14+
"league/glide": "^2.0",
1515
"symfony/http-foundation": "^2.3|^3.0|^4.0|^5.0"
1616
},
1717
"require-dev": {
18-
"mockery/mockery": "^0.9",
19-
"phpunit/phpunit": "^4.0"
18+
"mockery/mockery": "^1.3.3",
19+
"phpunit/phpunit": "^8.5|^9.4"
2020
},
2121
"autoload": {
2222
"psr-4": {

src/Responses/SymfonyResponseFactory.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace League\Glide\Responses;
44

5-
use League\Flysystem\FilesystemInterface;
5+
use League\Flysystem\FilesystemOperator;
66
use Symfony\Component\HttpFoundation\Request;
77
use Symfony\Component\HttpFoundation\StreamedResponse;
88

@@ -25,23 +25,23 @@ public function __construct(Request $request = null)
2525

2626
/**
2727
* Create the response.
28-
* @param FilesystemInterface $cache The cache file system.
28+
* @param FilesystemOperator $cache The cache file system.
2929
* @param string $path The cached file path.
3030
* @return StreamedResponse The response object.
3131
*/
32-
public function create(FilesystemInterface $cache, $path)
32+
public function create(FilesystemOperator $cache, $path)
3333
{
3434
$stream = $cache->readStream($path);
3535

3636
$response = new StreamedResponse();
37-
$response->headers->set('Content-Type', $cache->getMimetype($path));
38-
$response->headers->set('Content-Length', $cache->getSize($path));
37+
$response->headers->set('Content-Type', $cache->mimeType($path));
38+
$response->headers->set('Content-Length', $cache->fileSize($path));
3939
$response->setPublic();
4040
$response->setMaxAge(31536000);
4141
$response->setExpires(date_create()->modify('+1 years'));
4242

4343
if ($this->request) {
44-
$response->setLastModified(date_create()->setTimestamp($cache->getTimestamp($path)));
44+
$response->setLastModified(date_create()->setTimestamp($cache->lastModified($path)));
4545
$response->isNotModified($this->request);
4646
}
4747

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,41 @@
11
<?php
22

3-
namespace League\Glide\Responses;
3+
namespace Responses;
44

5+
use League\Glide\Responses\SymfonyResponseFactory;
56
use Mockery;
7+
use PHPUnit\Framework\TestCase;
68

7-
class SymfonyResponseFactoryTest extends \PHPUnit_Framework_TestCase
9+
class SymfonyResponseFactoryTest extends TestCase
810
{
9-
public function tearDown()
11+
public function tearDown(): void
1012
{
1113
Mockery::close();
1214
}
1315

14-
public function testCreateInstance()
16+
public function testCreateInstance(): void
1517
{
16-
$this->assertInstanceOf(
18+
self::assertInstanceOf(
1719
'League\Glide\Responses\SymfonyResponseFactory',
1820
new SymfonyResponseFactory()
1921
);
2022
}
2123

22-
public function testCreate()
24+
public function testCreate(): void
2325
{
24-
$this->cache = Mockery::mock('League\Flysystem\FilesystemInterface', function ($mock) {
25-
$mock->shouldReceive('getMimetype')->andReturn('image/jpeg')->once();
26-
$mock->shouldReceive('getSize')->andReturn(0)->once();
26+
$cache = Mockery::mock('League\Flysystem\FilesystemOperator', function ($mock) {
27+
$mock->shouldReceive('mimeType')->andReturn('image/jpeg')->once();
28+
$mock->shouldReceive('fileSize')->andReturn(0)->once();
2729
$mock->shouldReceive('readStream');
2830
});
2931

3032
$factory = new SymfonyResponseFactory();
31-
$response = $factory->create($this->cache, '');
33+
$response = $factory->create($cache, '');
3234

33-
$this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
34-
$this->assertEquals('image/jpeg', $response->headers->get('Content-Type'));
35-
$this->assertEquals('0', $response->headers->get('Content-Length'));
36-
$this->assertContains(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires'));
37-
$this->assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control'));
35+
self::assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response);
36+
self::assertEquals('image/jpeg', $response->headers->get('Content-Type'));
37+
self::assertEquals('0', $response->headers->get('Content-Length'));
38+
self::assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires'));
39+
self::assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control'));
3840
}
3941
}

0 commit comments

Comments
 (0)