Added a test for types defined as services

This commit is contained in:
Christophe Coevoet 2012-06-21 00:12:21 +02:00
parent fd8ee2679a
commit 5b70c775c0
7 changed files with 107 additions and 4 deletions

View File

@ -22,7 +22,7 @@ class ApiDocExtractorTest extends WebTestCase
$data = $extractor->all();
$this->assertTrue(is_array($data));
$this->assertCount(8, $data);
$this->assertCount(9, $data);
foreach ($data as $d) {
$this->assertTrue(is_array($d));

View File

@ -71,4 +71,14 @@ class TestController
public function yetAnotherAction()
{
}
/**
* @ApiDoc(
* description="create another test",
* formType="dependency_type"
* )
*/
public function anotherPostAction()
{
}
}

View File

@ -0,0 +1,50 @@
<?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.
*/
namespace Nelmio\ApiDocBundle\Tests\Fixtures\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class DependencyType extends AbstractType
{
public function __construct(array $mandatoryArgument)
{
}
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('a', null, array('description' => 'A nice description'))
;
}
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Nelmio\ApiDocBundle\Tests\Fixtures\Model\Test',
));
return;
}
public function getName()
{
return 'dependency_type';
}
}

View File

@ -22,3 +22,9 @@ twig:
services:
nemlio.test.controller:
class: Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestServiceController
nelmio.test.type:
class: Nelmio\ApiDocBundle\Tests\Fixtures\Form\DependencyType
arguments:
- [foo, bar]
tags:
- { name: form.type, alias: dependency_type }

View File

@ -28,6 +28,12 @@ test_route_6:
requirements:
id: \d+
test_route_7:
pattern: /another-post
defaults: { _controller: NelmioApiDocTestBundle:Test:anotherPost, _format: json }
requirements:
_method: POST
test_service_route_1:
pattern: /tests
defaults: { _controller: nemlio.test.controller:indexAction, _format: json }

View File

@ -107,6 +107,19 @@ b:
# others #
### `POST` /another-post ###
_create another test_
#### Parameters ####
a:
* type: string
* required: true
* description: A nice description
### `ANY` /any ###
_Action without HTTP verb_

View File

@ -140,6 +140,24 @@ class SimpleFormatterTest extends WebTestCase
'others' =>
array(
0 =>
array(
'method' => 'POST',
'uri' => '/another-post',
'requirements' =>
array(
),
'parameters' =>
array(
'a' =>
array(
'dataType' => 'string',
'required' => true,
'description' => 'A nice description',
),
),
'description' => 'create another test',
),
1 =>
array(
'method' => 'ANY',
'uri' => '/any',
@ -148,7 +166,7 @@ class SimpleFormatterTest extends WebTestCase
),
'description' => 'Action without HTTP verb',
),
1 =>
2 =>
array(
'method' => 'ANY',
'uri' => '/any/{foo}',
@ -158,7 +176,7 @@ class SimpleFormatterTest extends WebTestCase
),
'description' => 'Action without HTTP verb',
),
2 =>
3 =>
array(
'method' => 'ANY',
'uri' => '/my-commented/{id}/{page}',
@ -169,7 +187,7 @@ class SimpleFormatterTest extends WebTestCase
),
'description' => 'This method is useful to test if the getDocComment works. And, it supports multilines until the first \'@\' char.',
),
3 =>
4 =>
array(
'method' => 'ANY',
'uri' => '/yet-another/{id}',