Skip to content

Commit

Permalink
Merge pull request #127 from LinioIT/fix/gsc-sdk-products-with-more-t…
Browse files Browse the repository at this point in the history
…han-7-images-are-discarded

[SCP-2650] fix: gsc sdk products with more than 7 images are discarded
  • Loading branch information
miguel-serfe authored Mar 16, 2022
2 parents 826d247 + 14d6129 commit a41fe8b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 22 deletions.
5 changes: 0 additions & 5 deletions src/Model/Product/Images.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use JsonSerializable;
use Linio\SellerCenter\Contract\CollectionInterface;
use Linio\SellerCenter\Exception\MaxImagesExceededException;

class Images implements CollectionInterface, JsonSerializable
{
Expand All @@ -27,10 +26,6 @@ public function all(): array

public function add(Image $image): void
{
if (count($this->collection) >= self::MAX_IMAGES_ALLOWED) {
throw new MaxImagesExceededException(self::MAX_IMAGES_ALLOWED);
}

$this->collection[] = $image;
}

Expand Down
17 changes: 0 additions & 17 deletions tests/Unit/Product/ImagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Linio\SellerCenter\Product;

use Linio\SellerCenter\Exception\MaxImagesExceededException;
use Linio\SellerCenter\Factory\Xml\Product\ImagesFactory;
use Linio\SellerCenter\LinioTestCase;
use Linio\SellerCenter\Model\Product\Image;
Expand Down Expand Up @@ -76,22 +75,6 @@ public function testItReturnAnArrayWithTheMaxAmountOfImagesByAddingMultipleAtOnc
$this->assertCount(8, $images->all());
}

/**
* @dataProvider generatedImages
*/
public function testItThrowsAnExceptionByOverflow(array $imageStack): void
{
$this->expectException(MaxImagesExceededException::class);
$this->expectExceptionMessage(sprintf('Only %s are supported into the collection.', Images::MAX_IMAGES_ALLOWED));

$availableImages = array_slice($imageStack, 0, Images::MAX_IMAGES_ALLOWED);
$image = array_slice($imageStack, 8, 1)[0];

$images = new Images();
$images->addMany($availableImages);
$images->add($image);
}

/**
* @dataProvider generatedImages
*/
Expand Down

0 comments on commit a41fe8b

Please sign in to comment.