mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[API][Shop] Enable contract tests for Product Association Type resource
This commit is contained in:
parent
f0108245ea
commit
989459b9b1
3 changed files with 38 additions and 33 deletions
|
|
@ -17,17 +17,8 @@
|
||||||
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
|
xsi:schemaLocation="https://api-platform.com/schema/metadata/resources-3.0 https://api-platform.com/schema/metadata/resources-3.0.xsd"
|
||||||
>
|
>
|
||||||
<resource class="Sylius\Component\Product\Model\ProductAssociationType">
|
<resource class="Sylius\Component\Product\Model\ProductAssociationType">
|
||||||
<validationContext>
|
|
||||||
<values>
|
|
||||||
<value name="groups">
|
|
||||||
<values>
|
|
||||||
<value>sylius</value>
|
|
||||||
</values>
|
|
||||||
</value>
|
|
||||||
</values>
|
|
||||||
</validationContext>
|
|
||||||
|
|
||||||
<operations>
|
<operations>
|
||||||
|
<!-- Admin operations-->
|
||||||
<operation class="ApiPlatform\Metadata\GetCollection" uriTemplate="/admin/product-association-types">
|
<operation class="ApiPlatform\Metadata\GetCollection" uriTemplate="/admin/product-association-types">
|
||||||
<normalizationContext>
|
<normalizationContext>
|
||||||
<values>
|
<values>
|
||||||
|
|
@ -39,10 +30,22 @@
|
||||||
</values>
|
</values>
|
||||||
</normalizationContext>
|
</normalizationContext>
|
||||||
<filters>
|
<filters>
|
||||||
<filter>sylius.api.product_association_type_filter</filter>
|
<filter>sylius_api.search_filter.product_association_type</filter>
|
||||||
</filters>
|
</filters>
|
||||||
</operation>
|
</operation>
|
||||||
|
|
||||||
|
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/admin/product-association-types/{code}">
|
||||||
|
<normalizationContext>
|
||||||
|
<values>
|
||||||
|
<value name="groups">
|
||||||
|
<values>
|
||||||
|
<value>sylius:admin:product_association_type:show</value>
|
||||||
|
</values>
|
||||||
|
</value>
|
||||||
|
</values>
|
||||||
|
</normalizationContext>
|
||||||
|
</operation>
|
||||||
|
|
||||||
<operation class="ApiPlatform\Metadata\Post" uriTemplate="/admin/product-association-types">
|
<operation class="ApiPlatform\Metadata\Post" uriTemplate="/admin/product-association-types">
|
||||||
<denormalizationContext>
|
<denormalizationContext>
|
||||||
<values>
|
<values>
|
||||||
|
|
@ -62,18 +65,15 @@
|
||||||
</value>
|
</value>
|
||||||
</values>
|
</values>
|
||||||
</normalizationContext>
|
</normalizationContext>
|
||||||
</operation>
|
<validationContext>
|
||||||
|
|
||||||
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/admin/product-association-types/{code}">
|
|
||||||
<normalizationContext>
|
|
||||||
<values>
|
<values>
|
||||||
<value name="groups">
|
<value name="groups">
|
||||||
<values>
|
<values>
|
||||||
<value>sylius:admin:product_association_type:show</value>
|
<value>sylius</value>
|
||||||
</values>
|
</values>
|
||||||
</value>
|
</value>
|
||||||
</values>
|
</values>
|
||||||
</normalizationContext>
|
</validationContext>
|
||||||
</operation>
|
</operation>
|
||||||
|
|
||||||
<operation class="ApiPlatform\Metadata\Put" uriTemplate="/admin/product-association-types/{code}">
|
<operation class="ApiPlatform\Metadata\Put" uriTemplate="/admin/product-association-types/{code}">
|
||||||
|
|
@ -95,10 +95,20 @@
|
||||||
</value>
|
</value>
|
||||||
</values>
|
</values>
|
||||||
</normalizationContext>
|
</normalizationContext>
|
||||||
|
<validationContext>
|
||||||
|
<values>
|
||||||
|
<value name="groups">
|
||||||
|
<values>
|
||||||
|
<value>sylius</value>
|
||||||
|
</values>
|
||||||
|
</value>
|
||||||
|
</values>
|
||||||
|
</validationContext>
|
||||||
</operation>
|
</operation>
|
||||||
|
|
||||||
<operation class="ApiPlatform\Metadata\Delete" uriTemplate="/admin/product-association-types/{code}" />
|
<operation class="ApiPlatform\Metadata\Delete" uriTemplate="/admin/product-association-types/{code}" />
|
||||||
|
|
||||||
|
<!-- Shop operations-->
|
||||||
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/shop/product-association-types/{code}">
|
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/shop/product-association-types/{code}">
|
||||||
<normalizationContext>
|
<normalizationContext>
|
||||||
<values>
|
<values>
|
||||||
|
|
@ -110,8 +120,6 @@
|
||||||
</values>
|
</values>
|
||||||
</normalizationContext>
|
</normalizationContext>
|
||||||
</operation>
|
</operation>
|
||||||
|
|
||||||
</operations>
|
</operations>
|
||||||
</resource>
|
</resource>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
"@context": "\/api\/v2\/contexts\/ProductAssociationType",
|
"@context": "\/api\/v2\/contexts\/ProductAssociationType",
|
||||||
"@id": "\/api\/v2\/shop\/product-association-types\/similar_products",
|
"@id": "\/api\/v2\/shop\/product-association-types\/similar_products",
|
||||||
"@type": "ProductAssociationType",
|
"@type": "ProductAssociationType",
|
||||||
"id": "@integer@",
|
|
||||||
"code": "similar_products",
|
"code": "similar_products",
|
||||||
"name": "Similar products"
|
"name": "Similar products"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,23 +19,26 @@ use Symfony\Component\HttpFoundation\Response;
|
||||||
|
|
||||||
final class ProductAssociationTypesTest extends JsonApiTestCase
|
final class ProductAssociationTypesTest extends JsonApiTestCase
|
||||||
{
|
{
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
$this->setUpDefaultGetHeaders();
|
||||||
|
|
||||||
|
parent::setUp();
|
||||||
|
}
|
||||||
|
|
||||||
/** @test */
|
/** @test */
|
||||||
public function it_gets_product_association_type(): void
|
public function it_gets_a_product_association_type(): void
|
||||||
{
|
{
|
||||||
$fixtures = $this->loadFixturesFromFile('product/product_with_many_locales.yaml');
|
$fixtures = $this->loadFixturesFromFile('product/product_with_many_locales.yaml');
|
||||||
|
|
||||||
/** @var ProductAssociationTypeInterface $associationType */
|
/** @var ProductAssociationTypeInterface $associationType */
|
||||||
$associationType = $fixtures['product_association_type'];
|
$associationType = $fixtures['product_association_type'];
|
||||||
|
|
||||||
$this->client->request(
|
$this->requestGet(sprintf('/api/v2/shop/product-association-types/%s', $associationType->getCode()));
|
||||||
method: 'GET',
|
|
||||||
uri: sprintf('/api/v2/shop/product-association-types/%s', $associationType->getCode()),
|
|
||||||
server: self::CONTENT_TYPE_HEADER,
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertResponse(
|
$this->assertResponse(
|
||||||
$this->client->getResponse(),
|
$this->client->getResponse(),
|
||||||
'shop/product_association/get_product_association_type_response',
|
'shop/product_association/get_product_association_type_response',
|
||||||
Response::HTTP_OK,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -44,14 +47,9 @@ final class ProductAssociationTypesTest extends JsonApiTestCase
|
||||||
{
|
{
|
||||||
$this->loadFixturesFromFile('product/product_with_many_locales.yaml');
|
$this->loadFixturesFromFile('product/product_with_many_locales.yaml');
|
||||||
|
|
||||||
$this->client->request(
|
$this->requestGet(sprintf('/api/v2/shop/product-association-types/%s', 'wrong_code'));
|
||||||
method: 'GET',
|
|
||||||
uri: sprintf('/api/v2/shop/product-association-types/%s', 'wrong input'),
|
|
||||||
server: self::CONTENT_TYPE_HEADER,
|
|
||||||
);
|
|
||||||
|
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
$this->assertSame(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
$this->assertSame(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue