mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[API][Zone] Show zone API tests
This commit is contained in:
parent
17e298eff3
commit
4438705bd1
4 changed files with 84 additions and 30 deletions
|
|
@ -113,4 +113,42 @@ EOT;
|
|||
$response = $this->client->getResponse();
|
||||
$this->assertResponse($response, 'zone/index_response', Response::HTTP_OK);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_denies_access_to_zone_details_for_not_authenticated_users()
|
||||
{
|
||||
$this->client->request('GET', '/api/zones/1');
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertResponse($response, 'authentication/access_denied_response', Response::HTTP_UNAUTHORIZED);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_returns_not_found_response_when_requesting_details_of_a_zone_which_does_not_exist()
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yml');
|
||||
|
||||
$this->client->request('GET', '/api/zones/-1', [], [], static::$authorizedHeaderWithAccept);
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertResponse($response, 'error/not_found_response', Response::HTTP_NOT_FOUND);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_shows_zone_details()
|
||||
{
|
||||
$this->loadFixturesFromFile('authentication/api_administrator.yml');
|
||||
$zones = $this->loadFixturesFromFile('resources/zones.yml');
|
||||
|
||||
$this->client->request('GET', '/api/zones/'.$zones['zone_eu']->getId(), [], [], static::$authorizedHeaderWithAccept);
|
||||
|
||||
$response = $this->client->getResponse();
|
||||
$this->assertResponse($response, 'zone/show_response', Response::HTTP_OK);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
Sylius\Component\Addressing\Model\ZoneMember:
|
||||
member_{NL, BE}:
|
||||
code: <current()>
|
||||
|
||||
Sylius\Component\Addressing\Model\Zone:
|
||||
zone_eu:
|
||||
code: EU
|
||||
name: European Union
|
||||
type: zone
|
||||
type: country
|
||||
members: [@member_NL, @member_BE]
|
||||
|
|
|
|||
|
|
@ -1,32 +1,32 @@
|
|||
{
|
||||
"page": 1,
|
||||
"limit": 10,
|
||||
"pages": 1,
|
||||
"total": 1,
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "\/api\/zones\/?page=1&limit=10"
|
||||
},
|
||||
"first": {
|
||||
"href": "\/api\/zones\/?page=1&limit=10"
|
||||
},
|
||||
"last": {
|
||||
"href": "\/api\/zones\/?page=1&limit=10"
|
||||
}
|
||||
},
|
||||
"_embedded": {
|
||||
"items": [
|
||||
{
|
||||
"id": @integer@,
|
||||
"code": "EU",
|
||||
"name": "European Union",
|
||||
"type": "zone",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": @string@
|
||||
}
|
||||
"page": 1,
|
||||
"limit": 10,
|
||||
"pages": 1,
|
||||
"total": 1,
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": "\/api\/zones\/?page=1&limit=10"
|
||||
},
|
||||
"first": {
|
||||
"href": "\/api\/zones\/?page=1&limit=10"
|
||||
},
|
||||
"last": {
|
||||
"href": "\/api\/zones\/?page=1&limit=10"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"_embedded": {
|
||||
"items": [
|
||||
{
|
||||
"id": @integer@,
|
||||
"code": "EU",
|
||||
"name": "European Union",
|
||||
"type": "country",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": @string@
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
11
tests/Responses/Expected/zone/show_response.json
Normal file
11
tests/Responses/Expected/zone/show_response.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"id": @integer@,
|
||||
"code": "EU",
|
||||
"name": "European Union",
|
||||
"type": "country",
|
||||
"_links": {
|
||||
"self": {
|
||||
"href": @string@
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue