From 2b4770301cbcaed3838ae3c0b175a985d1b4fb4f Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 7 Mar 2016 15:00:03 +0100 Subject: Add version in API --- .../ApiBundle/Controller/WallabagRestController.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 35a90edd..5f342825 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -340,6 +340,19 @@ class WallabagRestController extends FOSRestController return $this->renderJsonResponse($json); } + /** + * Retrive version. + * + * @return Response + */ + public function getVersionAction() + { + $version = $this->container->getParameter('wallabag_core.version'); + + $json = $this->get('serializer')->serialize($version, 'json'); + + return $this->renderJsonResponse($json); + } /** * Validate that the first id is equal to the second one. -- cgit v1.2.3 From 9761bfa18e7a481ce9d73c1650e77bccab1927b3 Mon Sep 17 00:00:00 2001 From: Vincent Date: Mon, 7 Mar 2016 15:16:27 +0100 Subject: write test for version --- .../ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 630b75bf..f42c0f57 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -336,4 +336,15 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertCount(0, $entries); } + + public function testGetVersion(){ + + $this->client->request('GET','/api/version'); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + + $content = json_decode($this->client->getResponse()->getContent(), true); + + $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'),$content); + } } -- cgit v1.2.3 From 6f8310b445ce0aeb40aeed78501a6e113c05c087 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 8 Mar 2016 09:22:25 +0100 Subject: typos & cs --- src/Wallabag/ApiBundle/Controller/WallabagRestController.php | 4 +++- .../ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php index 5f342825..29cab1f4 100644 --- a/src/Wallabag/ApiBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/WallabagRestController.php @@ -341,7 +341,9 @@ class WallabagRestController extends FOSRestController return $this->renderJsonResponse($json); } /** - * Retrive version. + * Retrieve version number. + * + * @ApiDoc() * * @return Response */ diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index f42c0f57..a705f9de 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php @@ -337,14 +337,14 @@ class WallabagRestControllerTest extends WallabagApiTestCase $this->assertCount(0, $entries); } - public function testGetVersion(){ - - $this->client->request('GET','/api/version'); + public function testGetVersion() + { + $this->client->request('GET', '/api/version'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); $content = json_decode($this->client->getResponse()->getContent(), true); - $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'),$content); + $this->assertEquals($this->client->getContainer()->getParameter('wallabag_core.version'), $content); } } -- cgit v1.2.3