Skip to content

Commit

Permalink
FIx spec (#123)
Browse files Browse the repository at this point in the history
  • Loading branch information
lruozzi9 committed Aug 29, 2022
1 parent b95095c commit 8657432
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
7 changes: 5 additions & 2 deletions spec/ValueHandler/FileAttributeValueHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Symfony\Component\Filesystem\Filesystem;
use Webgriffe\SyliusAkeneoPlugin\TemporaryFilesManagerInterface;
use Webgriffe\SyliusAkeneoPlugin\ValueHandler\FileAttributeValueHandler;
use Webgriffe\SyliusAkeneoPlugin\ValueHandlerInterface;
use Webmozart\Assert\InvalidArgumentException;
Expand All @@ -31,7 +32,8 @@ public function let(
MediaFileApiInterface $productMediaFileApi,
Filesystem $filesystem,
ProductVariantInterface $productVariant,
ProductInterface $product
ProductInterface $product,
TemporaryFilesManagerInterface $temporaryFilesManager,
): void {
$commerceChannel = new Channel();
$commerceChannel->setCode('ecommerce');
Expand All @@ -43,7 +45,8 @@ public function let(
$apiClient->getProductMediaFileApi()->willReturn($productMediaFileApi);
$productMediaFileApi->download(Argument::type('string'))->willReturn(new Response(200, [], '__FILE_CONTENT__'));
$attributeApi->get('allegato_1')->willReturn(['type' => 'pim_catalog_file']);
$this->beConstructedWith($apiClient, $filesystem, 'allegato_1', 'public/media/attachment/product/');
$temporaryFilesManager->generateTemporaryFilePath()->willReturn('tempfile');
$this->beConstructedWith($apiClient, $filesystem, $temporaryFilesManager, 'allegato_1', 'public/media/attachment/product/');
}

public function it_is_initializable(): void
Expand Down
6 changes: 5 additions & 1 deletion spec/ValueHandler/ImageValueHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Webgriffe\SyliusAkeneoPlugin\ApiClientInterface;
use Webgriffe\SyliusAkeneoPlugin\TemporaryFilesManagerInterface;
use Webgriffe\SyliusAkeneoPlugin\ValueHandler\ImageValueHandler;

class ImageValueHandlerSpec extends ObjectBehavior
Expand All @@ -45,7 +46,8 @@ public function let(
ResponseInterface $downloadResponse,
StreamInterface $responseBody,
ProductVariantInterface $productVariant,
ProductInterface $product
ProductInterface $product,
TemporaryFilesManagerInterface $temporaryFilesManager,
): void {
$productImageFactory->createNew()->willReturn($productImage);
$apiClient->getProductMediaFileApi()->willReturn($productMediaFileApi);
Expand All @@ -66,10 +68,12 @@ public function let(
$productImageRepository
->findBy(['owner' => $product, 'type' => self::SYLIUS_IMAGE_TYPE])
->willReturn(new ArrayCollection([]));
$temporaryFilesManager->generateTemporaryFilePath()->willReturn('tempfile');
$this->beConstructedWith(
$productImageFactory,
$productImageRepository,
$apiClient,
$temporaryFilesManager,
self::AKENEO_ATTRIBUTE_CODE,
self::SYLIUS_IMAGE_TYPE
);
Expand Down
4 changes: 2 additions & 2 deletions src/ValueHandler/ImageValueHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Webgriffe\SyliusAkeneoPlugin\TemporaryFilesManager;
use Webgriffe\SyliusAkeneoPlugin\TemporaryFilesManagerInterface;
use Webgriffe\SyliusAkeneoPlugin\ValueHandlerInterface;
use Webmozart\Assert\Assert;

Expand All @@ -25,7 +25,7 @@ public function __construct(
private FactoryInterface $productImageFactory,
private RepositoryInterface $productImageRepository,
private AkeneoPimClientInterface $apiClient,
private TemporaryFilesManager $temporaryFilesManager,
private TemporaryFilesManagerInterface $temporaryFilesManager,
private string $akeneoAttributeCode,
private string $syliusImageType,
) {
Expand Down

0 comments on commit 8657432

Please sign in to comment.