mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
[API][Zone] Index zone API test
This commit is contained in:
parent
c46d5c8431
commit
0c8c782b40
4 changed files with 83 additions and 0 deletions
|
|
@ -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]
|
||||
|
|
|
|||
40
tests/Controller/ZoneApiTest.php
Normal file
40
tests/Controller/ZoneApiTest.php
Normal 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);
|
||||
}
|
||||
}
|
||||
5
tests/DataFixtures/ORM/resources/zones.yml
Normal file
5
tests/DataFixtures/ORM/resources/zones.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
Sylius\Component\Addressing\Model\Zone:
|
||||
zone_eu:
|
||||
code: EU
|
||||
name: European Union
|
||||
type: zone
|
||||
32
tests/Responses/Expected/zone/index_response.json
Normal file
32
tests/Responses/Expected/zone/index_response.json
Normal 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@
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue