]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
fix tests for GET /entries/tags
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 27 Feb 2015 14:24:36 +0000 (15:24 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 6 Mar 2015 20:09:15 +0000 (21:09 +0100)
src/Wallabag/CoreBundle/Controller/WallabagRestController.php
src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php

index 81974371402fa98a7c3ae22fcadd3f9664d1f256..e25ac6db8a545fd69bd96b7a0c46dc6e9319378c 100644 (file)
@@ -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'));
     }
 
     /**
index b0f077550f44606ddf89f3198dd96b76a4934825..ce12ec5d5e6c4c44e4584a16d3e5ee74a6d342fa 100644 (file)
@@ -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();
     }
 
index 7ccc37d20e6790ea98d8ac007832c82c713aee90..c45e52d782be5218f31faded99473a4a4642b778 100644 (file)
@@ -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()