mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-05 20:57: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"
|
||||
>
|
||||
<resource class="Sylius\Component\Product\Model\ProductAssociationType">
|
||||
<validationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</validationContext>
|
||||
|
||||
<operations>
|
||||
<!-- Admin operations-->
|
||||
<operation class="ApiPlatform\Metadata\GetCollection" uriTemplate="/admin/product-association-types">
|
||||
<normalizationContext>
|
||||
<values>
|
||||
|
|
@ -39,10 +30,22 @@
|
|||
</values>
|
||||
</normalizationContext>
|
||||
<filters>
|
||||
<filter>sylius.api.product_association_type_filter</filter>
|
||||
<filter>sylius_api.search_filter.product_association_type</filter>
|
||||
</filters>
|
||||
</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">
|
||||
<denormalizationContext>
|
||||
<values>
|
||||
|
|
@ -62,18 +65,15 @@
|
|||
</value>
|
||||
</values>
|
||||
</normalizationContext>
|
||||
</operation>
|
||||
|
||||
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/admin/product-association-types/{code}">
|
||||
<normalizationContext>
|
||||
<validationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius:admin:product_association_type:show</value>
|
||||
<value>sylius</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</normalizationContext>
|
||||
</validationContext>
|
||||
</operation>
|
||||
|
||||
<operation class="ApiPlatform\Metadata\Put" uriTemplate="/admin/product-association-types/{code}">
|
||||
|
|
@ -95,10 +95,20 @@
|
|||
</value>
|
||||
</values>
|
||||
</normalizationContext>
|
||||
<validationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
<values>
|
||||
<value>sylius</value>
|
||||
</values>
|
||||
</value>
|
||||
</values>
|
||||
</validationContext>
|
||||
</operation>
|
||||
|
||||
<operation class="ApiPlatform\Metadata\Delete" uriTemplate="/admin/product-association-types/{code}" />
|
||||
|
||||
<!-- Shop operations-->
|
||||
<operation class="ApiPlatform\Metadata\Get" uriTemplate="/shop/product-association-types/{code}">
|
||||
<normalizationContext>
|
||||
<values>
|
||||
|
|
@ -110,8 +120,6 @@
|
|||
</values>
|
||||
</normalizationContext>
|
||||
</operation>
|
||||
|
||||
</operations>
|
||||
</resource>
|
||||
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
"@context": "\/api\/v2\/contexts\/ProductAssociationType",
|
||||
"@id": "\/api\/v2\/shop\/product-association-types\/similar_products",
|
||||
"@type": "ProductAssociationType",
|
||||
"id": "@integer@",
|
||||
"code": "similar_products",
|
||||
"name": "Similar products"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,23 +19,26 @@ use Symfony\Component\HttpFoundation\Response;
|
|||
|
||||
final class ProductAssociationTypesTest extends JsonApiTestCase
|
||||
{
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->setUpDefaultGetHeaders();
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
/** @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');
|
||||
|
||||
/** @var ProductAssociationTypeInterface $associationType */
|
||||
$associationType = $fixtures['product_association_type'];
|
||||
|
||||
$this->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/shop/product-association-types/%s', $associationType->getCode()),
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
$this->requestGet(sprintf('/api/v2/shop/product-association-types/%s', $associationType->getCode()));
|
||||
|
||||
$this->assertResponse(
|
||||
$this->client->getResponse(),
|
||||
'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->client->request(
|
||||
method: 'GET',
|
||||
uri: sprintf('/api/v2/shop/product-association-types/%s', 'wrong input'),
|
||||
server: self::CONTENT_TYPE_HEADER,
|
||||
);
|
||||
$this->requestGet(sprintf('/api/v2/shop/product-association-types/%s', 'wrong_code'));
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
|
||||
$this->assertSame(Response::HTTP_NOT_FOUND, $response->getStatusCode());
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue