mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 09:02:12 +00:00
[API] Add tests for overwrite endpoints with YAML configurations
This commit is contained in:
parent
b657e63891
commit
dfcdee2844
3 changed files with 38 additions and 3 deletions
|
|
@ -19,7 +19,7 @@
|
|||
<resource class="%sylius.model.channel.class%">
|
||||
<operations>
|
||||
<operation
|
||||
name="test_channels_new_path_xml"
|
||||
name="test_channel_new_path_xml"
|
||||
class="ApiPlatform\Metadata\GetCollection"
|
||||
uriTemplate="/shop/channels-new-path-xml"
|
||||
>
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
</normalizationContext>
|
||||
</operation>
|
||||
|
||||
<operation name="sylius_api_shop_channel_get" class="ApiPlatform\Metadata\Get" uriTemplate="/shop/channels/new/{code}">
|
||||
<operation name="sylius_api_shop_channel_get" class="ApiPlatform\Metadata\Get" uriTemplate="/shop/channels/new-xml/{code}">
|
||||
<normalizationContext>
|
||||
<values>
|
||||
<value name="groups">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
resources:
|
||||
'%sylius.model.currency.class%':
|
||||
operations:
|
||||
ApiPlatform\Metadata\GetCollection:
|
||||
name: test_currency_new_path_yaml
|
||||
uriTemplate: '/shop/currencies-new-path-yaml'
|
||||
normalizationContext:
|
||||
groups: ['sylius:shop:currency:index']
|
||||
|
||||
ApiPlatform\Metadata\Get:
|
||||
name: sylius_api_shop_currency_get
|
||||
uriTemplate: '/shop/currencies/new-yaml/{code}'
|
||||
normalizationContext:
|
||||
groups: ['sylius:shop:currency:show']
|
||||
|
|
@ -35,6 +35,15 @@ final class MergingConfigsTest extends ApiTestCase
|
|||
self::assertJsonContains(['@type' => 'hydra:Collection']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_allows_to_add_a_new_operation_with_yaml(): void
|
||||
{
|
||||
static::createClient()->request('GET', '/api/v2/shop/currencies-new-path-yaml');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
self::assertJsonContains(['@type' => 'hydra:Collection']);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_allows_to_overwrite_an_existing_endpoint_with_xml(): void
|
||||
{
|
||||
|
|
@ -42,7 +51,19 @@ final class MergingConfigsTest extends ApiTestCase
|
|||
|
||||
self::assertResponseStatusCodeSame(404);
|
||||
|
||||
static::createClient()->request('GET', '/api/v2/shop/channels/new/WEB');
|
||||
static::createClient()->request('GET', '/api/v2/shop/channels/new-xml/WEB');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function it_allows_to_overwrite_an_existing_endpoint_with_yaml(): void
|
||||
{
|
||||
static::createClient()->request('GET', '/api/v2/shop/currencies/USD');
|
||||
|
||||
self::assertResponseStatusCodeSame(404);
|
||||
|
||||
static::createClient()->request('GET', '/api/v2/shop/currencies/new-yaml/USD');
|
||||
|
||||
self::assertResponseIsSuccessful();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue