mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-09 02:59:27 +03:00
Add some tests for the cache annotation
This commit is contained in:
parent
5ec931185f
commit
772184cfa1
@ -152,6 +152,10 @@ class ApiDoc
|
|||||||
$this->setAuthentication((bool) $data['authentication']);
|
$this->setAuthentication((bool) $data['authentication']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset($data['cache'])) {
|
||||||
|
$this->setCache($data['cache']);
|
||||||
|
}
|
||||||
|
|
||||||
if (isset($data['section'])) {
|
if (isset($data['section'])) {
|
||||||
$this->section = $data['section'];
|
$this->section = $data['section'];
|
||||||
}
|
}
|
||||||
|
@ -210,4 +210,16 @@ class ApiDocTest extends TestCase
|
|||||||
|
|
||||||
$this->assertTrue($array['authentication']);
|
$this->assertTrue($array['authentication']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testConstructWithCache()
|
||||||
|
{
|
||||||
|
$data = array(
|
||||||
|
'cache' => '60'
|
||||||
|
);
|
||||||
|
|
||||||
|
$annot = new ApiDoc($data);
|
||||||
|
$array = $annot->toArray();
|
||||||
|
|
||||||
|
$this->assertEquals($data['cache'], $array['cache']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,4 +166,17 @@ class ApiDocExtractorTest extends WebTestCase
|
|||||||
$annotation->getAuthentication()
|
$annotation->getAuthentication()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetWithCache()
|
||||||
|
{
|
||||||
|
$container = $this->getContainer();
|
||||||
|
$extractor = $container->get('nelmio_api_doc.extractor.api_doc_extractor');
|
||||||
|
$annotation = $extractor->get('Nelmio\ApiDocBundle\Tests\Fixtures\Controller\TestController::CachedAction', 'test_route_14');
|
||||||
|
|
||||||
|
$this->assertNotNull($annotation);
|
||||||
|
$this->assertEquals(
|
||||||
|
60,
|
||||||
|
$annotation->getCache()
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use FOS\RestBundle\Controller\Annotations\QueryParam;
|
|||||||
use FOS\RestBundle\Controller\Annotations\RequestParam;
|
use FOS\RestBundle\Controller\Annotations\RequestParam;
|
||||||
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
use Nelmio\ApiDocBundle\Annotation\ApiDoc;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;
|
||||||
|
|
||||||
class TestController
|
class TestController
|
||||||
{
|
{
|
||||||
@ -145,4 +146,12 @@ class TestController
|
|||||||
public function authenticatedAction()
|
public function authenticatedAction()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ApiDoc()
|
||||||
|
* @Cache(maxage=60, public=1)
|
||||||
|
*/
|
||||||
|
public function cachedAction()
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,9 @@
|
|||||||
"symfony/validator": "~2.1",
|
"symfony/validator": "~2.1",
|
||||||
"symfony/yaml": "~2.1",
|
"symfony/yaml": "~2.1",
|
||||||
"friendsofsymfony/rest-bundle": "dev-master",
|
"friendsofsymfony/rest-bundle": "dev-master",
|
||||||
"jms/serializer-bundle": ">=0.11"
|
"jms/serializer-bundle": ">=0.11",
|
||||||
|
"phpunit/phpunit-mock-objects": "dev-master",
|
||||||
|
"sensio/framework-extra-bundle": "dev-master"
|
||||||
},
|
},
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user