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: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

Drop support for PHP 5.6, PHP 7.0 and PHP 7.1

Change the response type from `StreamInterface` to `Response` for `\Akeneo\Pim\ApiClient\Api\MediaFileApiInterface::download`

# 3.0.0 (2018-06-26)

# 2.0.1 (2018-05-03)
Expand Down
4 changes: 1 addition & 3 deletions spec/Api/ProductMediaFileApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,6 @@ function it_downloads_a_media_file($resourceClient, ResponseInterface $response,
->getStreamedResource(ProductMediaFileApi::MEDIA_FILE_DOWNLOAD_URI, ['42.jpg'])
->willReturn($response);

$response->getBody()->willReturn($streamBody);

$this->download('42.jpg')->shouldReturn($streamBody);
$this->download('42.jpg')->shouldReturn($response);
}
}
5 changes: 3 additions & 2 deletions src/Api/Operation/DownloadableResourceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Akeneo\Pim\ApiClient\Api\Operation;

use Akeneo\Pim\ApiClient\Exception\HttpException;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

/**
Expand All @@ -21,7 +22,7 @@ interface DownloadableResourceInterface
*
* @throws HttpException
*
* @return StreamInterface
* @return ResponseInterface
*/
public function download(string $code): StreamInterface;
public function download(string $code): ResponseInterface;
}
4 changes: 2 additions & 2 deletions src/Api/ProductMediaFileApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ public function create($mediaFile, array $data): string
/**
* {@inheritdoc}
*/
public function download(string $code): StreamInterface
public function download(string $code): ResponseInterface
{
return $this->resourceClient->getStreamedResource(static::MEDIA_FILE_DOWNLOAD_URI, [$code])->getBody();
return $this->resourceClient->getStreamedResource(static::MEDIA_FILE_DOWNLOAD_URI, [$code]);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions tests/Api/DownloadProductMediaFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use donatj\MockWebServer\Response;
use donatj\MockWebServer\ResponseStack;
use PHPUnit\Framework\Assert;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;

class DownloadProductMediaFileTest extends ApiTestCase
Expand All @@ -26,7 +27,7 @@ public function test_download_media_file()
$mediaFile = $api->download('/f/b/0/6/fb068ccc9e3c5609d73c28d852812ba5faeeab28_akeneo.png');

Assert::assertSame($this->server->getLastRequest()->jsonSerialize()[RequestInfo::JSON_KEY_METHOD], 'GET');
Assert::assertInstanceOf(StreamInterface::class, $mediaFile);
Assert::assertSame(file_get_contents($expectedMediaFilePath), $mediaFile->getContents());
Assert::assertInstanceOf(ResponseInterface::class, $mediaFile);
Assert::assertSame(file_get_contents($expectedMediaFilePath), $mediaFile->getBody()->getContents());
}
}