[API][Zone] Show zone API tests

This commit is contained in:
Mateusz Zalewski 2016-08-05 20:23:51 +02:00
parent 17e298eff3
commit 4438705bd1
4 changed files with 84 additions and 30 deletions

View file

@ -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);
}
}

View file

@ -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]

View file

@ -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@
}
}
}
]
}
}

View file

@ -0,0 +1,11 @@
{
"id": @integer@,
"code": "EU",
"name": "European Union",
"type": "country",
"_links": {
"self": {
"href": @string@
}
}
}