Skip to content

Commit

Permalink
#502 Test for the improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
dpcat237 committed Jun 12, 2016
1 parent 725e4d9 commit 1256275
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/Extractor/Handler/FosRestHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,22 @@ public function testWithRequestParamPlainArrayRequirements()
$this->assertArrayHasKey('requirement', $filters['param1']);
$this->assertEquals('NotNull, NotBlank', $filters['param1']['requirement']);
}

public function testWithRequirementParamNotSet()
{
$container = $this->getContainer();
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::zActionWithRequirementParamNotSet', 'test_route_31');

$this->assertNotNull($annotation);

$filters = $annotation->getFilters();
$this->assertCount(1, $filters);
$this->assertArrayHasKey('param1', $filters);
$filter = $filters['param1'];

$this->assertArrayNotHasKey('requirement', $filter);
$this->assertArrayHasKey('description', $filter);
$this->assertEquals($filter['description'], 'Param1 description.');
}
}
8 changes: 8 additions & 0 deletions Tests/Fixtures/Controller/TestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -414,4 +414,12 @@ public function routeWithQueryParamArrayRequirementsAction()
public function routeWithQueryParamPlainArrayRequirementsAction()
{
}

/**
* @ApiDoc()
* @QueryParam(name="param1", description="Param1 description.")
*/
public function zActionWithRequirementParamNotSet()
{
}
}
5 changes: 5 additions & 0 deletions Tests/Fixtures/app/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,8 @@ test_route_30:
path: /z-query-param-plain-array-requirements
methods: [GET]
defaults: { _controller: NelmioApiDocTestBundle:Test:routeWithQueryParamPlainArrayRequirementsAction }

test_route_31:
path: /z-query-requirement-param-not-set
methods: [GET]
defaults: { _controller: NelmioApiDocTestBundle:Test:zActionWithRequirementParamNotSet }

0 comments on commit 1256275

Please sign in to comment.