diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-27 15:24:36 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 21:09:15 +0100 |
commit | b0cce9e6369b0b821c01163a0e4df5552f9924f6 (patch) | |
tree | 001890dc2d7a7c99bf144edf4ffea713aa52a7c2 | |
parent | 1df1204d94a26cda064886c827a23ba642ebc769 (diff) | |
download | wallabag-b0cce9e6369b0b821c01163a0e4df5552f9924f6.tar.gz wallabag-b0cce9e6369b0b821c01163a0e4df5552f9924f6.tar.zst wallabag-b0cce9e6369b0b821c01163a0e4df5552f9924f6.zip |
fix tests for GET /entries/tags
3 files changed, 24 insertions, 4 deletions
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; | |||
6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; | 6 | use Symfony\Bundle\FrameworkBundle\Controller\Controller; |
7 | use Symfony\Component\HttpFoundation\Request; | 7 | use Symfony\Component\HttpFoundation\Request; |
8 | use Symfony\Component\HttpFoundation\JsonResponse; | 8 | use Symfony\Component\HttpFoundation\JsonResponse; |
9 | use Symfony\Component\HttpFoundation\Response; | ||
9 | use Wallabag\CoreBundle\Entity\Entry; | 10 | use Wallabag\CoreBundle\Entity\Entry; |
10 | use Wallabag\CoreBundle\Entity\Tag; | 11 | use Wallabag\CoreBundle\Entity\Tag; |
11 | use Wallabag\CoreBundle\Service\Extractor; | 12 | use Wallabag\CoreBundle\Service\Extractor; |
@@ -246,7 +247,7 @@ class WallabagRestController extends Controller | |||
246 | 247 | ||
247 | $json = $this->get('serializer')->serialize($entry->getTags(), 'json'); | 248 | $json = $this->get('serializer')->serialize($entry->getTags(), 'json'); |
248 | 249 | ||
249 | return new JsonResponse($json, 200); | 250 | return new Response($json, 200, array('application/json')); |
250 | } | 251 | } |
251 | 252 | ||
252 | /** | 253 | /** |
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 | |||
38 | $entry3->setTitle('test title entry3'); | 38 | $entry3->setTitle('test title entry3'); |
39 | $entry3->setContent('This is my content /o/'); | 39 | $entry3->setContent('This is my content /o/'); |
40 | 40 | ||
41 | $tag1 = new Tag($this->getReference('admin-user')); | 41 | $tag1 = new Tag($this->getReference('bob-user')); |
42 | $tag1->setLabel("foo"); | 42 | $tag1->setLabel("foo"); |
43 | $tag2 = new Tag($this->getReference('admin-user')); | 43 | $tag2 = new Tag($this->getReference('bob-user')); |
44 | $tag2->setLabel("bar"); | 44 | $tag2->setLabel("bar"); |
45 | 45 | ||
46 | $entry3->addTag($tag1); | 46 | $entry3->addTag($tag1); |
@@ -50,6 +50,23 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
50 | 50 | ||
51 | $this->addReference('entry3', $entry3); | 51 | $this->addReference('entry3', $entry3); |
52 | 52 | ||
53 | $entry4 = new Entry($this->getReference('admin-user')); | ||
54 | $entry4->setUrl('http://0.0.0.0'); | ||
55 | $entry4->setTitle('test title entry4'); | ||
56 | $entry4->setContent('This is my content /o/'); | ||
57 | |||
58 | $tag1 = new Tag($this->getReference('admin-user')); | ||
59 | $tag1->setLabel("foo"); | ||
60 | $tag2 = new Tag($this->getReference('admin-user')); | ||
61 | $tag2->setLabel("bar"); | ||
62 | |||
63 | $entry4->addTag($tag1); | ||
64 | $entry4->addTag($tag2); | ||
65 | |||
66 | $manager->persist($entry4); | ||
67 | |||
68 | $this->addReference('entry4', $entry4); | ||
69 | |||
53 | $manager->flush(); | 70 | $manager->flush(); |
54 | } | 71 | } |
55 | 72 | ||
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 | |||
159 | ->getRepository('WallabagCoreBundle:Entry') | 159 | ->getRepository('WallabagCoreBundle:Entry') |
160 | ->findOneWithTags(1); | 160 | ->findOneWithTags(1); |
161 | 161 | ||
162 | $entry = $entry[0]; | ||
163 | |||
162 | if (!$entry) { | 164 | if (!$entry) { |
163 | $this->markTestSkipped('No content found in db.'); | 165 | $this->markTestSkipped('No content found in db.'); |
164 | } | 166 | } |
@@ -170,7 +172,7 @@ class WallabagRestControllerTest extends WallabagTestCase | |||
170 | 172 | ||
171 | $client->request('GET', '/api/entries/'.$entry->getId().'/tags', array(), array(), $headers); | 173 | $client->request('GET', '/api/entries/'.$entry->getId().'/tags', array(), array(), $headers); |
172 | 174 | ||
173 | $this->assertEquals(json_encode($tags), $client->getResponse()->getContent()); | 175 | $this->assertEquals(json_encode($tags, JSON_HEX_QUOT), $client->getResponse()->getContent()); |
174 | } | 176 | } |
175 | 177 | ||
176 | public function testPostTagsOnEntry() | 178 | public function testPostTagsOnEntry() |