2012-04-13 14:11:54 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the NelmioApiDocBundle.
|
|
|
|
*
|
|
|
|
* (c) Nelmio <hello@nelm.io>
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2012-04-13 14:22:07 +02:00
|
|
|
namespace Nelmio\ApiDocBundle\Tests\Formatter;
|
|
|
|
|
|
|
|
use Nelmio\ApiDocBundle\Tests\WebTestCase;
|
2012-04-13 14:11:54 +02:00
|
|
|
|
|
|
|
class SimpleFormatterTest extends WebTestCase
|
|
|
|
{
|
|
|
|
public function testFormat()
|
|
|
|
{
|
|
|
|
$container = $this->getContainer();
|
|
|
|
|
|
|
|
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
2013-02-15 13:33:05 +01:00
|
|
|
set_error_handler(array($this, 'handleDeprecation'));
|
2012-04-13 15:00:46 +02:00
|
|
|
$data = $extractor->all();
|
2013-02-11 14:42:17 +01:00
|
|
|
restore_error_handler();
|
2012-04-13 15:00:46 +02:00
|
|
|
$result = $container->get('nelmio_api_doc.formatter.simple_formatter')->format($data);
|
2012-04-13 14:11:54 +02:00
|
|
|
|
2013-04-30 16:19:00 +02:00
|
|
|
$expected = array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'/tests' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
0 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'method' => 'GET',
|
2012-08-10 11:38:01 +02:00
|
|
|
'uri' => '/tests.{_format}',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'index action',
|
2012-04-14 10:11:52 +02:00
|
|
|
'filters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'a' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'dataType' => 'integer',
|
|
|
|
),
|
|
|
|
'b' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'dataType' => 'string',
|
|
|
|
'arbitrary' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
0 => 'arg1',
|
|
|
|
1 => 'arg2',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'_format' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
2012-08-10 11:38:01 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
|
|
|
1 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-13 14:11:54 +02:00
|
|
|
'method' => 'GET',
|
2012-08-10 11:38:01 +02:00
|
|
|
'uri' => '/tests.{_format}',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'index action',
|
2012-04-14 10:11:52 +02:00
|
|
|
'filters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'a' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-13 14:11:54 +02:00
|
|
|
'dataType' => 'integer',
|
|
|
|
),
|
2012-04-14 10:11:52 +02:00
|
|
|
'b' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-13 14:11:54 +02:00
|
|
|
'dataType' => 'string',
|
2012-04-14 10:11:52 +02:00
|
|
|
'arbitrary' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
0 => 'arg1',
|
|
|
|
1 => 'arg2',
|
2012-04-13 14:11:54 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'_format' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
2012-08-10 11:38:01 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-13 14:11:54 +02:00
|
|
|
),
|
2012-04-14 10:11:52 +02:00
|
|
|
2 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'method' => 'POST',
|
2012-08-10 11:38:01 +02:00
|
|
|
'uri' => '/tests.{_format}',
|
2013-04-11 22:03:40 +02:00
|
|
|
'host' => 'api.test.dev',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'create test',
|
2012-04-14 10:11:52 +02:00
|
|
|
'parameters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
|
|
|
'test_type[a]' =>
|
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => true,
|
|
|
|
'description' => 'A nice description',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2013-04-30 16:19:00 +02:00
|
|
|
'test_type[b]' =>
|
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'dataType' => 'string',
|
2012-06-20 23:19:34 +02:00
|
|
|
'required' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
'description' => '',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2013-04-30 16:19:00 +02:00
|
|
|
'test_type[c]' =>
|
|
|
|
array(
|
2012-05-23 00:20:03 +02:00
|
|
|
'dataType' => 'boolean',
|
|
|
|
'required' => true,
|
|
|
|
'description' => '',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-05-23 00:20:03 +02:00
|
|
|
),
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'_format' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
2012-08-10 11:38:01 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
|
|
|
3 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-13 14:11:54 +02:00
|
|
|
'method' => 'POST',
|
2012-08-10 11:38:01 +02:00
|
|
|
'uri' => '/tests.{_format}',
|
2013-04-11 22:03:40 +02:00
|
|
|
'host' => 'api.test.dev',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'create test',
|
2012-04-14 10:11:52 +02:00
|
|
|
'parameters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
|
|
|
'test_type[a]' =>
|
|
|
|
array(
|
2012-04-13 14:11:54 +02:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => true,
|
2012-04-13 14:20:12 +02:00
|
|
|
'description' => 'A nice description',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-04-13 14:11:54 +02:00
|
|
|
),
|
2013-04-30 16:19:00 +02:00
|
|
|
'test_type[b]' =>
|
|
|
|
array(
|
2012-04-13 14:11:54 +02:00
|
|
|
'dataType' => 'string',
|
2012-06-20 23:19:34 +02:00
|
|
|
'required' => false,
|
2012-04-13 14:20:12 +02:00
|
|
|
'description' => '',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-04-13 14:11:54 +02:00
|
|
|
),
|
2013-04-30 16:19:00 +02:00
|
|
|
'test_type[c]' =>
|
|
|
|
array(
|
2012-05-23 00:20:03 +02:00
|
|
|
'dataType' => 'boolean',
|
|
|
|
'required' => true,
|
|
|
|
'description' => '',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-05-23 00:20:03 +02:00
|
|
|
),
|
2012-04-13 14:11:54 +02:00
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'_format' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
2012-08-10 11:38:01 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-13 14:11:54 +02:00
|
|
|
),
|
|
|
|
),
|
2012-04-14 10:11:52 +02:00
|
|
|
'others' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
0 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-06-21 00:12:21 +02:00
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => '/another-post',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'create another test',
|
2012-06-21 00:12:21 +02:00
|
|
|
'parameters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
|
|
|
'dependency_type[a]' =>
|
|
|
|
array(
|
2012-06-21 00:12:21 +02:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => true,
|
|
|
|
'description' => 'A nice description',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-06-21 00:12:21 +02:00
|
|
|
),
|
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-06-21 00:12:21 +02:00
|
|
|
),
|
|
|
|
1 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'method' => 'ANY',
|
|
|
|
'uri' => '/any',
|
|
|
|
'description' => 'Action without HTTP verb',
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2012-06-21 00:12:21 +02:00
|
|
|
2 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-04-14 10:11:52 +02:00
|
|
|
'method' => 'ANY',
|
2012-04-19 20:27:27 +02:00
|
|
|
'uri' => '/any/{foo}',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'Action without HTTP verb',
|
2012-04-14 10:11:52 +02:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'foo' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2012-06-21 00:12:21 +02:00
|
|
|
3 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-16 18:45:41 +01:00
|
|
|
'method' => 'ANY',
|
|
|
|
'uri' => '/authenticated',
|
|
|
|
'https' => false,
|
|
|
|
'authentication' => true,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
),
|
|
|
|
4 =>
|
2012-08-07 17:50:58 -04:00
|
|
|
array(
|
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => '/jms-input-test',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'Testing JMS',
|
2012-08-07 17:50:58 -04:00
|
|
|
'parameters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-07 17:50:58 -04:00
|
|
|
'foo' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-07 17:50:58 -04:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-08-07 17:50:58 -04:00
|
|
|
),
|
|
|
|
'bar' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-07 17:50:58 -04:00
|
|
|
'dataType' => 'DateTime',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => true,
|
2012-08-07 17:50:58 -04:00
|
|
|
),
|
|
|
|
'number' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-07 17:50:58 -04:00
|
|
|
'dataType' => 'double',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-08-07 17:50:58 -04:00
|
|
|
),
|
|
|
|
'arr' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-07 17:50:58 -04:00
|
|
|
'dataType' => 'array',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
2012-08-24 11:10:25 -04:00
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'nested' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-24 11:10:25 -04:00
|
|
|
'dataType' => 'object (JmsNested)',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
2012-12-20 10:12:50 +01:00
|
|
|
'children' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'foo' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-24 11:10:25 -04:00
|
|
|
'dataType' => 'DateTime',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => true,
|
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'bar' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-24 11:10:25 -04:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
2012-08-24 14:34:48 -04:00
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'baz' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-08-24 14:34:48 -04:00
|
|
|
'dataType' => 'array of integers',
|
|
|
|
'required' => false,
|
2012-08-31 14:57:42 -04:00
|
|
|
'description' => 'Epic description.
|
|
|
|
|
|
|
|
With multiple lines.',
|
2012-08-24 14:34:48 -04:00
|
|
|
'readonly' => false,
|
2012-08-24 11:10:25 -04:00
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'circular' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'object (JmsNested)',
|
2012-08-24 11:10:25 -04:00
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
2012-08-24 14:34:48 -04:00
|
|
|
),
|
2012-12-20 10:12:50 +01:00
|
|
|
'parent' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'object (JmsTest)',
|
2012-08-24 14:34:48 -04:00
|
|
|
'required' => false,
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'No description.',
|
2012-08-24 14:34:48 -04:00
|
|
|
'readonly' => false,
|
2012-12-20 10:12:50 +01:00
|
|
|
'children' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'foo' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
|
|
|
),
|
|
|
|
'bar' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'DateTime',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => true,
|
|
|
|
),
|
|
|
|
'number' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'double',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
|
|
|
),
|
|
|
|
'arr' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'array',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
|
|
|
),
|
|
|
|
'nested' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'object (JmsNested)',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
|
|
|
),
|
2013-03-26 10:37:33 -07:00
|
|
|
'nested_array' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'array of objects (JmsNested)',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2013-03-26 10:37:33 -07:00
|
|
|
'nested_array' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'array of objects (JmsNested)',
|
|
|
|
'required' => false,
|
|
|
|
'description' => 'No description.',
|
|
|
|
'readonly' => false,
|
2012-08-24 11:10:25 -04:00
|
|
|
),
|
2012-08-07 17:50:58 -04:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-08-07 17:50:58 -04:00
|
|
|
),
|
2013-03-16 18:45:41 +01:00
|
|
|
5 =>
|
2012-08-27 12:56:19 -04:00
|
|
|
array(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => '/jms-return-test',
|
|
|
|
'description' => 'Testing return',
|
2012-12-20 10:12:50 +01:00
|
|
|
'response' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
|
|
|
'dependency_type[a]' =>
|
|
|
|
array(
|
2012-08-27 13:25:03 -04:00
|
|
|
'dataType' => 'string',
|
|
|
|
'required' => true,
|
|
|
|
'description' => 'A nice description',
|
2012-12-20 10:12:50 +01:00
|
|
|
'readonly' => false,
|
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
),
|
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-08-27 12:56:19 -04:00
|
|
|
),
|
2013-03-16 18:45:41 +01:00
|
|
|
6 =>
|
2012-04-19 17:05:59 +02:00
|
|
|
array(
|
|
|
|
'method' => 'ANY',
|
2013-05-03 14:49:17 +01:00
|
|
|
'uri' => '/my-commented/{id}/{page}/{paramType}/{param}',
|
2012-12-20 10:12:50 +01:00
|
|
|
'description' => 'This method is useful to test if the getDocComment works.',
|
|
|
|
'documentation' => 'This method is useful to test if the getDocComment works.
|
|
|
|
And, it supports multilines until the first \'@\' char.',
|
2012-04-19 17:05:59 +02:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'id' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'int',
|
|
|
|
'description' => 'A nice comment',
|
|
|
|
'requirement' => '',
|
|
|
|
),
|
|
|
|
'page' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => 'int',
|
|
|
|
'description' => '',
|
|
|
|
'requirement' => '',
|
|
|
|
),
|
2013-05-03 14:49:17 +01:00
|
|
|
'paramType' =>
|
|
|
|
array (
|
|
|
|
'dataType' => 'int',
|
|
|
|
'description' => 'The param type',
|
|
|
|
'requirement' => '',
|
|
|
|
),
|
|
|
|
'param' =>
|
|
|
|
array (
|
|
|
|
'dataType' => 'int',
|
|
|
|
'description' => 'The param id',
|
|
|
|
'requirement' => '',
|
|
|
|
),
|
2012-04-19 17:05:59 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2012-07-13 16:04:29 +02:00
|
|
|
'description' => 'This method is useful to test if the getDocComment works.',
|
2013-03-16 18:45:41 +01:00
|
|
|
'documentation' => "This method is useful to test if the getDocComment works.\nAnd, it supports multilines until the first '@' char.",
|
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-19 17:05:59 +02:00
|
|
|
),
|
2013-03-16 18:45:41 +01:00
|
|
|
7 =>
|
2012-12-10 10:21:04 -08:00
|
|
|
array(
|
|
|
|
'method' => 'ANY',
|
|
|
|
'uri' => '/secure-route',
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'_scheme' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-10 10:21:04 -08:00
|
|
|
'requirement' => 'https',
|
2012-12-20 10:12:50 +01:00
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
2012-12-10 10:21:04 -08:00
|
|
|
),
|
|
|
|
),
|
|
|
|
'https' => true,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-12-10 10:21:04 -08:00
|
|
|
),
|
2013-03-16 18:45:41 +01:00
|
|
|
8 =>
|
2012-04-19 20:27:27 +02:00
|
|
|
array(
|
|
|
|
'method' => 'ANY',
|
|
|
|
'uri' => '/yet-another/{id}',
|
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'id' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '\\d+',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
2012-04-19 20:27:27 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-19 20:27:27 +02:00
|
|
|
),
|
2013-03-16 18:45:41 +01:00
|
|
|
9 =>
|
2012-07-20 00:58:58 +02:00
|
|
|
array(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => '/z-action-with-query-param',
|
|
|
|
'filters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'page' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'requirement' => '\\d+',
|
|
|
|
'description' => 'Page of the overview.',
|
2013-04-30 16:21:12 +04:00
|
|
|
'default' => '1',
|
2012-12-20 10:12:50 +01:00
|
|
|
),
|
2012-07-20 00:58:58 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-07-20 00:58:58 +02:00
|
|
|
),
|
2013-03-16 18:45:41 +01:00
|
|
|
10 =>
|
2013-04-30 16:21:12 +04:00
|
|
|
array(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => '/z-action-with-query-param-no-default',
|
|
|
|
'filters' =>
|
|
|
|
array (
|
|
|
|
'page' =>
|
|
|
|
array (
|
|
|
|
'requirement' => '\\d+',
|
|
|
|
'description' => 'Page of the overview.',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'https' => false,
|
|
|
|
'authentication' => false,
|
|
|
|
'deprecated' => false,
|
|
|
|
),
|
|
|
|
11 =>
|
|
|
|
array(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => '/z-action-with-query-param-strict',
|
|
|
|
'requirements' =>
|
|
|
|
array (
|
|
|
|
'page' =>
|
|
|
|
array (
|
|
|
|
'requirement' => '\\d+',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => 'Page of the overview.',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'https' => false,
|
|
|
|
'authentication' => false,
|
|
|
|
'deprecated' => false,
|
|
|
|
),
|
|
|
|
12 =>
|
2012-11-14 23:59:06 +01:00
|
|
|
array(
|
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => '/z-action-with-request-param',
|
|
|
|
'parameters' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'param1' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2012-12-20 10:12:50 +01:00
|
|
|
'required' => true,
|
|
|
|
'dataType' => 'string',
|
|
|
|
'description' => 'Param1 description.',
|
|
|
|
'readonly' => false,
|
|
|
|
),
|
2012-11-14 23:59:06 +01:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2013-03-16 18:45:41 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-11-14 23:59:06 +01:00
|
|
|
),
|
2012-04-14 10:11:52 +02:00
|
|
|
),
|
2013-03-21 12:15:44 +01:00
|
|
|
'/tests2' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-21 12:15:44 +01:00
|
|
|
0 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-21 12:15:44 +01:00
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => '/tests2.{_format}',
|
|
|
|
'description' => 'post test 2',
|
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-21 12:15:44 +01:00
|
|
|
'_format' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-21 12:15:44 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'https' => false,
|
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'/tests2' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-18 08:40:03 +01:00
|
|
|
0 =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-18 08:40:03 +01:00
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => '/tests2.{_format}',
|
|
|
|
'description' => 'post test 2',
|
|
|
|
'requirements' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-18 08:40:03 +01:00
|
|
|
'_format' =>
|
2013-04-30 16:19:00 +02:00
|
|
|
array(
|
2013-03-18 08:40:03 +01:00
|
|
|
'requirement' => '',
|
|
|
|
'dataType' => '',
|
|
|
|
'description' => '',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
'https' => false,
|
|
|
|
'authentication' => false,
|
|
|
|
'deprecated' => false,
|
2013-03-21 12:15:44 +01:00
|
|
|
),
|
|
|
|
),
|
2012-04-13 14:11:54 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
2012-04-13 15:00:46 +02:00
|
|
|
|
|
|
|
public function testFormatOne()
|
|
|
|
{
|
|
|
|
$container = $this->getContainer();
|
|
|
|
|
2012-07-20 00:58:58 +02:00
|
|
|
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
|
|
|
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::indexAction', 'test_route_1');
|
|
|
|
$result = $container->get('nelmio_api_doc.formatter.simple_formatter')->formatOne($annotation);
|
2012-04-13 15:00:46 +02:00
|
|
|
|
|
|
|
$expected = array(
|
|
|
|
'method' => 'GET',
|
2012-08-10 11:38:01 +02:00
|
|
|
'uri' => '/tests.{_format}',
|
2012-04-13 15:00:46 +02:00
|
|
|
'filters' => array(
|
|
|
|
'a' => array(
|
|
|
|
'dataType' => 'integer',
|
|
|
|
),
|
|
|
|
'b' => array(
|
|
|
|
'dataType' => 'string',
|
|
|
|
'arbitrary' => array(
|
|
|
|
'arg1',
|
|
|
|
'arg2',
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
2012-08-10 11:38:01 +02:00
|
|
|
'description' => 'index action',
|
|
|
|
'requirements' => array(
|
2012-11-17 18:05:05 +01:00
|
|
|
'_format' => array('dataType' => '', 'description' => '', 'requirement' => ''),
|
2012-08-10 11:38:01 +02:00
|
|
|
),
|
2012-12-10 10:21:04 -08:00
|
|
|
'https' => false,
|
2012-12-26 12:23:28 +01:00
|
|
|
'authentication' => false,
|
2013-03-18 08:40:03 +01:00
|
|
|
'deprecated' => false,
|
2012-04-13 15:00:46 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
2012-04-13 14:11:54 +02:00
|
|
|
}
|