[Unit] Add product option shop tests

This commit is contained in:
Rafikooo 2024-08-13 18:46:35 +02:00 committed by Grzegorz Sadowski
parent 230e03e13c
commit cff4e4a428
4 changed files with 20 additions and 65 deletions

View file

@ -1,12 +1,21 @@
{
"@context": "\/api\/v2\/contexts\/ProductOption",
"@id": "\/api\/v2\/shop\/product-options\/COLOR",
"@type": "ProductOption",
"id": "@integer@",
"code": "COLOR",
"values": [
"\/api\/v2\/shop\/product-option-values\/COLOR_BLUE",
"\/api\/v2\/shop\/product-option-values\/COLOR_RED"
],
"name": "Color"
"@context": "\/api\/v2\/contexts\/ProductOption",
"@id": "\/api\/v2\/shop\/product-options\/COLOR",
"@type": "ProductOption",
"code": "COLOR",
"values": [
{
"@id": "\/api\/v2\/shop\/product-options\/COLOR\/values\/COLOR_BLUE",
"@type": "ProductOptionValue",
"code": "COLOR_BLUE",
"value": "Blue"
},
{
"@id": "\/api\/v2\/shop\/product-options\/COLOR\/values\/COLOR_RED",
"@type": "ProductOptionValue",
"code": "COLOR_RED",
"value": "Red"
}
],
"name": "Color"
}

View file

@ -1,9 +0,0 @@
{
"@context": "\/api\/v2\/contexts\/ProductOptionValue",
"@id": "\/api\/v2\/shop\/product-option-values\/COLOR_RED",
"@type": "ProductOptionValue",
"id": "@integer@",
"code": "COLOR_RED",
"option": "\/api\/v2\/shop\/product-options\/COLOR",
"value": "Red"
}

View file

@ -1,45 +0,0 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Tests\Api\Shop;
use Sylius\Component\Product\Model\ProductOptionValueInterface;
use Sylius\Tests\Api\JsonApiTestCase;
use Symfony\Component\HttpFoundation\Response;
final class ProductOptionValuesTest extends JsonApiTestCase
{
/** @test */
public function it_gets_product_option_value(): void
{
$fixtures = $this->loadFixturesFromFiles([
'channel.yaml',
'product/product_option.yaml',
]);
/** @var ProductOptionValueInterface $productOptionValue */
$productOptionValue = $fixtures['product_option_value_color_red'];
$this->client->request(
method: 'GET',
uri: sprintf('/api/v2/shop/product-option-values/%s', $productOptionValue->getCode()),
server: self::CONTENT_TYPE_HEADER,
);
$this->assertResponse(
$this->client->getResponse(),
'shop/product_option/get_product_option_value',
Response::HTTP_OK,
);
}
}

View file

@ -15,7 +15,7 @@ namespace Sylius\Tests\Api\Shop;
use Sylius\Tests\Api\JsonApiTestCase;
final class ProductOptionTest extends JsonApiTestCase
final class ProductOptionsTest extends JsonApiTestCase
{
/** @test */
public function it_returns_product_option(): void