From b0cce9e6369b0b821c01163a0e4df5552f9924f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 27 Feb 2015 15:24:36 +0100 Subject: fix tests for GET /entries/tags --- .../Controller/WallabagRestController.php | 3 ++- .../CoreBundle/DataFixtures/ORM/LoadEntryData.php | 21 +++++++++++++++++++-- .../Tests/Controller/WallabagRestControllerTest.php | 4 +++- 3 files changed, 24 insertions(+), 4 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php index 81974371..e25ac6db 100644 --- a/src/Wallabag/CoreBundle/Controller/WallabagRestController.php +++ b/src/Wallabag/CoreBundle/Controller/WallabagRestController.php @@ -6,6 +6,7 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\JsonResponse; +use Symfony\Component\HttpFoundation\Response; use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Service\Extractor; @@ -246,7 +247,7 @@ class WallabagRestController extends Controller $json = $this->get('serializer')->serialize($entry->getTags(), 'json'); - return new JsonResponse($json, 200); + return new Response($json, 200, array('application/json')); } /** diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index b0f07755..ce12ec5d 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php @@ -38,9 +38,9 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $entry3->setTitle('test title entry3'); $entry3->setContent('This is my content /o/'); - $tag1 = new Tag($this->getReference('admin-user')); + $tag1 = new Tag($this->getReference('bob-user')); $tag1->setLabel("foo"); - $tag2 = new Tag($this->getReference('admin-user')); + $tag2 = new Tag($this->getReference('bob-user')); $tag2->setLabel("bar"); $entry3->addTag($tag1); @@ -50,6 +50,23 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface $this->addReference('entry3', $entry3); + $entry4 = new Entry($this->getReference('admin-user')); + $entry4->setUrl('http://0.0.0.0'); + $entry4->setTitle('test title entry4'); + $entry4->setContent('This is my content /o/'); + + $tag1 = new Tag($this->getReference('admin-user')); + $tag1->setLabel("foo"); + $tag2 = new Tag($this->getReference('admin-user')); + $tag2->setLabel("bar"); + + $entry4->addTag($tag1); + $entry4->addTag($tag2); + + $manager->persist($entry4); + + $this->addReference('entry4', $entry4); + $manager->flush(); } diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 7ccc37d2..c45e52d7 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -159,6 +159,8 @@ class WallabagRestControllerTest extends WallabagTestCase ->getRepository('WallabagCoreBundle:Entry') ->findOneWithTags(1); + $entry = $entry[0]; + if (!$entry) { $this->markTestSkipped('No content found in db.'); } @@ -170,7 +172,7 @@ class WallabagRestControllerTest extends WallabagTestCase $client->request('GET', '/api/entries/'.$entry->getId().'/tags', array(), array(), $headers); - $this->assertEquals(json_encode($tags), $client->getResponse()->getContent()); + $this->assertEquals(json_encode($tags, JSON_HEX_QUOT), $client->getResponse()->getContent()); } public function testPostTagsOnEntry() -- cgit v1.2.3