From eaf46767b217bccfa0813ebcbe00a34f3bac184f Mon Sep 17 00:00:00 2001 From: cooldeark <45022034+cooldeark@users.noreply.github.com> Date: Wed, 24 Apr 2024 17:59:54 +0800 Subject: [PATCH 1/2] support laravel 11 Upgrade the version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c8003ce..be9893c 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ } ], "require": { - "league/glide-symfony": "^1.0" + "league/glide-symfony": "^2.0" }, "require-dev": { "mockery/mockery": "^0.9", From 8025d5dac1320cfa7a3e98dabe4f349b4649b811 Mon Sep 17 00:00:00 2001 From: cooldeark Date: Thu, 30 May 2024 16:37:50 +0800 Subject: [PATCH 2/2] support laravel11 & fix test cases --- composer.json | 7 ++++--- tests/Responses/LaravelResponseFactoryTest.php | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/composer.json b/composer.json index be9893c..96760d2 100644 --- a/composer.json +++ b/composer.json @@ -11,11 +11,12 @@ } ], "require": { - "league/glide-symfony": "^2.0" + "league/glide-symfony": "^2.0", + "league/flysystem": "^2.0" }, "require-dev": { - "mockery/mockery": "^0.9", - "phpunit/phpunit": "^4.0" + "mockery/mockery": "^1.4.4", + "phpunit/phpunit": "~8.5|^9.5.10" }, "autoload": { "psr-4": { diff --git a/tests/Responses/LaravelResponseFactoryTest.php b/tests/Responses/LaravelResponseFactoryTest.php index bd6db28..6075018 100644 --- a/tests/Responses/LaravelResponseFactoryTest.php +++ b/tests/Responses/LaravelResponseFactoryTest.php @@ -3,10 +3,12 @@ namespace League\Glide\Responses; use Mockery; +use PHPUnit\Framework\TestCase; +use Symfony\Component\HttpFoundation\StreamedResponse; -class LaravelResponseFactoryTest extends \PHPUnit_Framework_TestCase +class LaravelResponseFactoryTest extends TestCase { - public function tearDown() + protected function tearDown(): void { Mockery::close(); } @@ -21,19 +23,19 @@ public function testCreateInstance() public function testCreate() { - $this->cache = Mockery::mock('League\Flysystem\FilesystemInterface', function ($mock) { - $mock->shouldReceive('getMimetype')->andReturn('image/jpeg')->once(); - $mock->shouldReceive('getSize')->andReturn(0)->once(); - $mock->shouldReceive('readStream'); + $this->cache = Mockery::mock('League\Flysystem\FilesystemOperator', function ($mock) { + $mock->shouldReceive('mimeType')->andReturn('image/jpeg')->once(); + $mock->shouldReceive('fileSize')->andReturn(0)->once(); + $mock->shouldReceive('readStream')->andReturn(fopen('php://memory', 'r'))->once(); }); $factory = new LaravelResponseFactory(); $response = $factory->create($this->cache, ''); - $this->assertInstanceOf('Symfony\Component\HttpFoundation\StreamedResponse', $response); + $this->assertInstanceOf(StreamedResponse::class, $response); $this->assertEquals('image/jpeg', $response->headers->get('Content-Type')); $this->assertEquals('0', $response->headers->get('Content-Length')); - $this->assertContains(gmdate('D, d M Y H:i', strtotime('+1 years')), $response->headers->get('Expires')); + $this->assertStringContainsString(gmdate('D, d M Y H:i', strtotime('+1 year')), $response->headers->get('Expires')); $this->assertEquals('max-age=31536000, public', $response->headers->get('Cache-Control')); } }