Skip to content

Commit

Permalink
Merge pull request #181 from LinioIT/feat/SCP-4578_add_content_score_…
Browse files Browse the repository at this point in the history
…property_to_product_model

[SCP-4578] feta: add content score property to product model
  • Loading branch information
lhbarrientosz authored Apr 24, 2024
2 parents 162ca2d + a7e124a commit 703a86c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Factory/Xml/Product/GlobalProductFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public static function make(SimpleXMLElement $element): GlobalProduct
(string) $element->TaxClass,
$productData,
$images ?? null,
(string) $element->QCStatus ?? null
(string) $element->QCStatus ?? null,
(int) $element->ContentScore ?? null
);

if (!empty($element->ShopSku)) {
Expand Down
22 changes: 21 additions & 1 deletion src/Model/Product/GlobalProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class GlobalProduct extends BaseProduct implements JsonSerializable, ProductInte
*/
protected $talla;

/**
* @var int|null
*/
protected $contentScore;

public function __construct()
{
$this->productData = new ProductData();
Expand All @@ -65,7 +70,8 @@ public static function fromBasicData(
?string $taxClass,
ProductData $productData,
?Images $images = null,
?string $qcStatus = null
?string $qcStatus = null,
?int $contentScore = null
): self {
self::ValidateArguments($sellerSku, $name, $description, $productId);

Expand Down Expand Up @@ -96,6 +102,10 @@ public static function fromBasicData(
$product->setQcStatus($qcStatus);
}

if (!empty($contentScore)) {
$product->setContentScore($contentScore);
}

return $product;
}

Expand Down Expand Up @@ -133,6 +143,11 @@ public function getTalla(): ?string
return $this->talla;
}

public function getContentScore(): ?int
{
return $this->contentScore;
}

public function setQcStatus(string $qcStatus): void
{
$this->qcStatus = $qcStatus;
Expand Down Expand Up @@ -163,6 +178,11 @@ public function setTalla(string $talla): void
$this->talla = $talla;
}

public function setContentScore(int $contentScore): void
{
$this->contentScore = $contentScore;
}

/**
* @return mixed[]
*/
Expand Down
7 changes: 6 additions & 1 deletion tests/Unit/Product/GlobalProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ class GlobalProductTest extends LinioTestCase
protected $mainImage;
protected $images;

protected $contentScore = 40;

protected $conditionType = 'Nuevo';
protected $packageHeight = 3;
protected $packageWidth = 0;
Expand Down Expand Up @@ -124,7 +126,9 @@ public function testItCreatesAGlobalProductWithMandatoryParameters(): void
$this->productId,
$this->taxClass,
$this->productData,
$this->images
$this->images,
null,
$this->contentScore
);

$this->assertInstanceOf(GlobalProduct::class, $product);
Expand All @@ -138,6 +142,7 @@ public function testItCreatesAGlobalProductWithMandatoryParameters(): void
$this->assertEquals($product->getTaxClass(), $this->taxClass);
$this->assertEquals($product->getProductData(), $this->productData);
$this->assertEquals($product->getQcStatus(), null);
$this->assertEquals($product->getContentScore(), $this->contentScore);
$this->assertInstanceOf(Images::class, $product->getImages());
$this->assertInstanceOf(BusinessUnits::class, $product->getBusinessUnits());
}
Expand Down
1 change: 1 addition & 0 deletions tests/_schemas/Product/GlobalProduct.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<Image>https://i.linio.com.co/p/4a3e6ac763e2289c2952e0b00fd7b4a5-catalog.jpg</Image>
<Image>https://i.linio.com.co/p/4a3e6ac763e2289c2952e0b00fd7b4a6-catalog.jpg</Image>
</Images>
<ContentScore>26</ContentScore>
<Color>Beige</Color>
<ColorBasico>Beige</ColorBasico>
<Size>L</Size>
Expand Down
2 changes: 2 additions & 0 deletions tests/_schemas/Product/GlobalProductsResponse.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<Image>http://static.somesite.com/p/image2.jpg</Image>
<Image>http://static.somesite.com/p/image3.jpg</Image>
</Images>
<ContentScore>26</ContentScore>
<Description>fdsfdsfds&lt;span&gt;&lt;/span&gt;</Description>
<TaxClass>IVA 19%</TaxClass>
<Brand>GENERIC</Brand>
Expand Down Expand Up @@ -122,6 +123,7 @@
<Image>http://static.somesite.com/p/image2.jpg</Image>
<Image>http://static.somesite.com/p/image3.jpg</Image>
</Images>
<ContentScore>26</ContentScore>
<Description>fdsfdsfds&lt;span&gt;&lt;/span&gt;</Description>
<TaxClass>IVA 19%</TaxClass>
<Brand>GENERIC</Brand>
Expand Down

0 comments on commit 703a86c

Please sign in to comment.