fix tests for GET /entries/tags

This commit is contained in:
Nicolas Lœuillet 2015-02-27 15:24:36 +01:00
parent 1df1204d94
commit b0cce9e636
3 changed files with 24 additions and 4 deletions

View file

@ -6,6 +6,7 @@ use Nelmio\ApiDocBundle\Annotation\ApiDoc;
use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Response;
use Wallabag\CoreBundle\Entity\Entry; use Wallabag\CoreBundle\Entity\Entry;
use Wallabag\CoreBundle\Entity\Tag; use Wallabag\CoreBundle\Entity\Tag;
use Wallabag\CoreBundle\Service\Extractor; use Wallabag\CoreBundle\Service\Extractor;
@ -246,7 +247,7 @@ class WallabagRestController extends Controller
$json = $this->get('serializer')->serialize($entry->getTags(), 'json'); $json = $this->get('serializer')->serialize($entry->getTags(), 'json');
return new JsonResponse($json, 200); return new Response($json, 200, array('application/json'));
} }
/** /**

View file

@ -38,9 +38,9 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$entry3->setTitle('test title entry3'); $entry3->setTitle('test title entry3');
$entry3->setContent('This is my content /o/'); $entry3->setContent('This is my content /o/');
$tag1 = new Tag($this->getReference('admin-user')); $tag1 = new Tag($this->getReference('bob-user'));
$tag1->setLabel("foo"); $tag1->setLabel("foo");
$tag2 = new Tag($this->getReference('admin-user')); $tag2 = new Tag($this->getReference('bob-user'));
$tag2->setLabel("bar"); $tag2->setLabel("bar");
$entry3->addTag($tag1); $entry3->addTag($tag1);
@ -50,6 +50,23 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
$this->addReference('entry3', $entry3); $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(); $manager->flush();
} }

View file

@ -159,6 +159,8 @@ class WallabagRestControllerTest extends WallabagTestCase
->getRepository('WallabagCoreBundle:Entry') ->getRepository('WallabagCoreBundle:Entry')
->findOneWithTags(1); ->findOneWithTags(1);
$entry = $entry[0];
if (!$entry) { if (!$entry) {
$this->markTestSkipped('No content found in db.'); $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); $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() public function testPostTagsOnEntry()