Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Middleware/GlideMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
use Cake\Event\EventDispatcherTrait;
use Cake\Event\EventManagerInterface;
use Cake\Http\Response;
use Cake\Http\Stream;
use Cake\Utility\Security;
use Exception;
use Laminas\Diactoros\Stream;
use League\Glide\Api\Encoder;
use League\Glide\Server;
use League\Glide\ServerFactory;
Expand Down
2 changes: 1 addition & 1 deletion src/Response/PsrResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

use ADmad\Glide\Exception\ResponseException;
use Cake\Http\Response;
use Laminas\Diactoros\Stream;
use Cake\Http\Stream;
use League\Flysystem\FilesystemException;
use League\Flysystem\FilesystemOperator;
use League\Glide\Responses\ResponseFactoryInterface;
Expand Down
15 changes: 14 additions & 1 deletion tests/TestCase/Middleware/GlideMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
use Cake\Http\Response;
use Cake\Http\ServerRequest;
use Cake\Http\ServerRequestFactory;
use Cake\Http\Stream;
use Cake\TestSuite\TestCase;
use Cake\Utility\Security;
use Laminas\Diactoros\Stream;
use League\Flysystem\UnableToRetrieveMetadata;
use League\Glide\ServerFactory;
use League\Glide\Signatures\Signature;
Expand Down Expand Up @@ -59,6 +59,13 @@ public function testNormalResponse()

$headers = $response->getHeaders();
$this->assertTrue(isset($headers['Content-Length']));
$this->assertInstanceOf(Stream::class, $response->getBody());
$this->assertSame('image/png', $response->getHeaderLine('Content-Type'));
$body = (string)$response->getBody();
$this->assertSame(strlen($body), (int)$response->getHeaderLine('Content-Length'));
$imageSize = getimagesizefromstring($body);
$this->assertNotFalse($imageSize);
$this->assertSame(100, $imageSize[0]);
}

public function testDefaultConfig(): void
Expand Down Expand Up @@ -134,6 +141,12 @@ public function testOriginalPassThrough()

$headers = $response->getHeaders();
$this->assertSame($fileSize, (int)$headers['Content-Length'][0]);
$this->assertInstanceOf(Stream::class, $response->getBody());
$this->assertSame('image/png', $response->getHeaderLine('Content-Type'));
$this->assertSame(
file_get_contents(PLUGIN_ROOT . '/test_app/webroot/upload/cake-logo.png'),
(string)$response->getBody(),
);
}

/**
Expand Down
Loading