[API][Zone] Index zone API test

This commit is contained in:
Mateusz Zalewski 2016-08-05 09:45:05 +02:00
parent c46d5c8431
commit 0c8c782b40
4 changed files with 83 additions and 0 deletions

View file

@ -10,6 +10,12 @@ sylius_api_zone_index:
paginate: $limit
sortable: true
sylius_api_zone_create:
path: /{type}
methods: [POST]
defaults:
_controller: sylius.controller.zone:createAction
sylius_api_zone_delete:
path: /{id}
methods: [DELETE]

View file

@ -0,0 +1,40 @@
<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sylius\Tests\Controller;
use Lakion\ApiTestCase\JsonApiTestCase;
use Symfony\Component\HttpFoundation\Response;
/**
* @author Mateusz Zalewski <mateusz.zalewski@lakion.com>
*/
class ZoneApiTest extends JsonApiTestCase
{
/**
* @var array
*/
private static $authorizedHeaderWithAccept = [
'HTTP_Authorization' => 'Bearer SampleTokenNjZkNjY2MDEwMTAzMDkxMGE0OTlhYzU3NzYyMTE0ZGQ3ODcyMDAwM2EwMDZjNDI5NDlhMDdlMQ',
'ACCEPT' => 'application/json',
];
public function testGetZonesListResponse()
{
$this->loadFixturesFromFile('authentication/api_administrator.yml');
$this->loadFixturesFromFile('resources/zones.yml');
$this->client->request('GET', '/api/zones/', [], [], static::$authorizedHeaderWithAccept);
$response = $this->client->getResponse();
$this->assertResponse($response, 'zone/index_response', Response::HTTP_OK);
}
}

View file

@ -0,0 +1,5 @@
Sylius\Component\Addressing\Model\Zone:
zone_eu:
code: EU
name: European Union
type: zone

View file

@ -0,0 +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@
}
}
}
]
}
}