Skip to content

Commit 4c62396

Browse files
committed
Test the @Version annotation
1 parent 6cb0673 commit 4c62396

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSRestBundle package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller;
13+
14+
use FOS\RestBundle\Controller\Annotations\Get;
15+
use FOS\RestBundle\Controller\Annotations\Version;
16+
use FOS\RestBundle\Controller\Annotations\View;
17+
18+
/**
19+
* @author Ener-Getick <[email protected]>
20+
*
21+
* @Version({"1.2"})
22+
*/
23+
class Version2Controller
24+
{
25+
/**
26+
* @View("TestBundle:Version:version.html.twig")
27+
* @Get(path="/version")
28+
*/
29+
public function versionAction($version)
30+
{
31+
return array('version' => 'test annotation');
32+
}
33+
}

Tests/Functional/Bundle/TestBundle/Resources/config/routing.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ test_serializer_error_invalid_form:
1414
path: /serializer-error/invalid-form.{_format}
1515
defaults: { _controller: TestBundle:SerializerError:invalidForm }
1616

17+
# Must be defined before test_version
1718
test_version2:
19+
resource: FOS\RestBundle\Tests\Functional\Bundle\TestBundle\Controller\Version2Controller
20+
type: rest
21+
22+
test_version:
1823
path: /version
1924
defaults: { _controller: TestBundle:Version:version }
2025
requirements:

Tests/Functional/VersionTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ public function setUp()
2323
$this->client = $this->createClient(['test_case' => 'Version']);
2424
}
2525

26+
public function testVersionAnnotation()
27+
{
28+
$this->client->request(
29+
'GET',
30+
'/version?query_version=1.2'
31+
);
32+
$this->assertContains('test annotation', $this->client->getResponse()->getContent());
33+
}
34+
2635
public function testCustomHeaderVersion()
2736
{
2837
$this->client->request(

0 commit comments

Comments
 (0)