Skip to content

Commit

Permalink
[API][Shop] Add missing contract test for getting only countries from…
Browse files Browse the repository at this point in the history
… current channel
  • Loading branch information
GSadee committed Feb 23, 2024
1 parent 29a8647 commit 2df7a2e
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/Api/DataFixtures/ORM/channel_with_countries.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Sylius\Component\Core\Model\Channel:
channel_web:
code: 'WEB'
name: 'Web Channel'
hostname: 'localhost'
contactEmail: '[email protected]'
description: 'Lorem ipsum'
baseCurrency: '@currency_usd'
defaultLocale: '@locale_en'
locales: ['@locale_en', '@locale_pl']
color: 'black'
enabled: true
taxCalculationStrategy: 'order_items_based'
countries: ['@country_US', '@country_FR']

Sylius\Component\Currency\Model\Currency:
currency_usd:
code: 'USD'

Sylius\Component\Locale\Model\Locale:
locale_en:
code: 'en_US'
locale_pl:
code: 'pl_PL'
locale_de:
code: 'de_DE'
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"@context": "\/api\/v2\/contexts\/Country",
"@id": "\/api\/v2\/shop\/countries",
"@type": "hydra:Collection",
"hydra:member": [
{
"@id": "\/api\/v2\/shop\/countries\/US",
"@type": "Country",
"code": "US",
"name": "United States",
"provinces": [
{
"@id": "\/api\/v2\/shop\/provinces\/US-MI",
"@type": "Province",
"code": "US-MI",
"name": "Minnesota"
},
{
"@id": "\/api\/v2\/shop\/provinces\/US-WY",
"@type": "Province",
"code": "US-WY",
"name": "Wyoming"
}
]
},
{
"@id": "\/api\/v2\/shop\/countries\/FR",
"@type": "Country",
"code": "FR",
"name": "France",
"provinces": []
}
],
"hydra:totalItems": 2
}
11 changes: 11 additions & 0 deletions tests/Api/Shop/CountriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@ public function it_gets_countries(): void
$this->assertResponse($response, 'shop/country/get_countries_response', Response::HTTP_OK);
}

/** @test */
public function it_gets_only_countries_from_current_channel(): void
{
$this->loadFixturesFromFiles(['channel_with_countries.yaml', 'country.yaml']);

$this->client->request(method: 'GET', uri: '/api/v2/shop/countries', server: self::CONTENT_TYPE_HEADER);
$response = $this->client->getResponse();

$this->assertResponse($response, 'shop/country/get_countries_from_channel_response', Response::HTTP_OK);
}

/** @test */
public function it_gets_a_country(): void
{
Expand Down

0 comments on commit 2df7a2e

Please sign in to comment.