From 1d14779154481b320e1c44fccf2558d8c9fa43a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 20 Feb 2015 15:36:25 +0100 Subject: remove isDeleted flag --- .../CoreBundle/Tests/Controller/EntryControllerTest.php | 9 +++------ .../Tests/Controller/WallabagRestControllerTest.php | 16 ++++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 2634141e..99a3a945 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -161,18 +161,15 @@ class EntryControllerTest extends WallabagTestCase $content = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByIsDeleted(false); + ->findOneById(1); $client->request('GET', '/delete/'.$content->getId()); $this->assertEquals(302, $client->getResponse()->getStatusCode()); - $res = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findOneById($content->getId()); + $client->request('GET', '/delete/'.$content->getId()); - $this->assertEquals($res->isDeleted(), true); + $this->assertEquals(404, $client->getResponse()->getStatusCode()); } public function testViewOtherUserEntry() diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index fcfa8ccf..4164e516 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -130,7 +130,7 @@ class WallabagRestControllerTest extends WallabagTestCase $entry = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneByIsDeleted(false); + ->findOneByUser(1); if (!$entry) { $this->markTestSkipped('No content found in db.'); @@ -140,10 +140,14 @@ class WallabagRestControllerTest extends WallabagTestCase $this->assertEquals(200, $client->getResponse()->getStatusCode()); - $res = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Entry') - ->findOneById($entry->getId()); - $this->assertEquals($res->isDeleted(), true); + // We'll try to delete this entry again + $client->request('GET', '/api/salts/admin.json'); + $salt = json_decode($client->getResponse()->getContent()); + + $headers = $this->generateHeaders('admin', 'test', $salt[0]); + + $client->request('DELETE', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers); + + $this->assertEquals(404, $client->getResponse()->getStatusCode()); } } -- cgit v1.2.3 From 2691cf04384239c546e141af6cc3c22b210dae58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 20 Feb 2015 16:38:24 +0100 Subject: GET /api/tags/id_tag method --- .../Controller/WallabagRestControllerTest.php | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 4164e516..0ffe7fe6 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -150,4 +150,33 @@ class WallabagRestControllerTest extends WallabagTestCase $this->assertEquals(404, $client->getResponse()->getStatusCode()); } + + public function testGetOneTag() + { + $client = $this->createClient(); + $client->request('GET', '/api/salts/admin.json'); + $salt = json_decode($client->getResponse()->getContent()); + + $headers = $this->generateHeaders('admin', 'test', $salt[0]); + + $tag = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Tag') + ->findOneByLabel('foo'); + + if (!$tag) { + $this->markTestSkipped('No content found in db.'); + } + + $client->request('GET', '/api/tags/'.$tag->getLabel().'.json', array(), array(), $headers); + + $this->assertEquals(json_encode($tag), $client->getResponse()->getContent()); + + $this->assertTrue( + $client->getResponse()->headers->contains( + 'Content-Type', + 'application/json' + ) + ); + } } -- cgit v1.2.3 From 0a018fe03980b35c9f7aca838e67a8efa43b7f2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Fri, 20 Feb 2015 20:29:33 +0100 Subject: add relation between entry and tag --- .../Controller/WallabagRestControllerTest.php | 29 ---------------------- 1 file changed, 29 deletions(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 0ffe7fe6..4164e516 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -150,33 +150,4 @@ class WallabagRestControllerTest extends WallabagTestCase $this->assertEquals(404, $client->getResponse()->getStatusCode()); } - - public function testGetOneTag() - { - $client = $this->createClient(); - $client->request('GET', '/api/salts/admin.json'); - $salt = json_decode($client->getResponse()->getContent()); - - $headers = $this->generateHeaders('admin', 'test', $salt[0]); - - $tag = $client->getContainer() - ->get('doctrine.orm.entity_manager') - ->getRepository('WallabagCoreBundle:Tag') - ->findOneByLabel('foo'); - - if (!$tag) { - $this->markTestSkipped('No content found in db.'); - } - - $client->request('GET', '/api/tags/'.$tag->getLabel().'.json', array(), array(), $headers); - - $this->assertEquals(json_encode($tag), $client->getResponse()->getContent()); - - $this->assertTrue( - $client->getResponse()->headers->contains( - 'Content-Type', - 'application/json' - ) - ); - } } -- cgit v1.2.3 From 46bbd8d321e6a00131f0e6ed96fa6f3d693b3678 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 24 Feb 2015 07:42:09 +0100 Subject: relation between tags and entries --- .../Controller/WallabagRestControllerTest.php | 26 ++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 4164e516..d2390055 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -150,4 +150,30 @@ class WallabagRestControllerTest extends WallabagTestCase $this->assertEquals(404, $client->getResponse()->getStatusCode()); } + + public function testGetTagsEntry() + { + $client = $this->createClient(); + $client->request('GET', '/api/salts/admin.json'); + $salt = json_decode($client->getResponse()->getContent()); + $headers = $this->generateHeaders('admin', 'test', $salt[0]); + + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneWithTags(); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $tags = array(); + foreach ($entry->getTags() as $tag) { + $tags[] = array('id' => $tag->getId(), 'label' => $tag->getLabel()); + } + + $client->request('GET', '/api/entries/'.$entry->getId().'/tags', array(), array(), $headers); + + $this->assertEquals(json_encode($tags), $client->getResponse()->getContent()); + } } -- cgit v1.2.3 From a36737f4859e3acbddf5cfe90c279ba725a6d88a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 24 Feb 2015 22:00:24 +0100 Subject: POST entries/tags with test --- .../Controller/WallabagRestControllerTest.php | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index d2390055..cadbb70b 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -176,4 +176,41 @@ class WallabagRestControllerTest extends WallabagTestCase $this->assertEquals(json_encode($tags), $client->getResponse()->getContent()); } + + public function testPostTagsOnEntry() + { + $client = $this->createClient(); + $client->request('GET', '/api/salts/admin.json'); + $salt = json_decode($client->getResponse()->getContent()); + $headers = $this->generateHeaders('admin', 'test', $salt[0]); + + $entry = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->findOneByUser(1); + + if (!$entry) { + $this->markTestSkipped('No content found in db.'); + } + + $newTags = 'tag1,tag2,tag3'; + + $client->request('POST', '/api/entries/'.$entry->getId().'/tags', array('tags' => $newTags), array(), $headers); + + $this->assertEquals(200, $client->getResponse()->getStatusCode()); + + $entryDB = $client->getContainer() + ->get('doctrine.orm.entity_manager') + ->getRepository('WallabagCoreBundle:Entry') + ->find($entry->getId()); + + $tagsInDB = array(); + foreach ($entryDB->getTags()->toArray() as $tag) { + $tagsInDB[$tag->getId()] = $tag->getLabel(); + } + + foreach (explode(',', $newTags) as $tag) { + $this->assertContains($tag, $tagsInDB); + } + } } -- cgit v1.2.3 From 092ca70725b0263390e45c46f93828c613eca3f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 26 Feb 2015 09:41:42 +0100 Subject: add relation between user and tags, tests are broken --- .../CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index cadbb70b..04448537 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -161,7 +161,9 @@ class WallabagRestControllerTest extends WallabagTestCase $entry = $client->getContainer() ->get('doctrine.orm.entity_manager') ->getRepository('WallabagCoreBundle:Entry') - ->findOneWithTags(); + ->findOneWithTags(1); + + var_dump($entry->getTitle()); if (!$entry) { $this->markTestSkipped('No content found in db.'); -- cgit v1.2.3 From d8f9f37ab2deb172f8dfc58b3b3775990188762f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 26 Feb 2015 12:35:59 +0100 Subject: remove debug lines --- src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index 04448537..b0f4a842 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -163,8 +163,6 @@ class WallabagRestControllerTest extends WallabagTestCase ->getRepository('WallabagCoreBundle:Entry') ->findOneWithTags(1); - var_dump($entry->getTitle()); - if (!$entry) { $this->markTestSkipped('No content found in db.'); } -- cgit v1.2.3 From 1df1204d94a26cda064886c827a23ba642ebc769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 26 Feb 2015 15:27:00 +0100 Subject: remove useless code --- .../CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index b0f4a842..7ccc37d2 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -44,10 +44,6 @@ class WallabagRestControllerTest extends WallabagTestCase public function testWithBadHeaders() { $client = $this->createClient(); - $client->request('GET', '/api/salts/admin.json'); - $salt = json_decode($client->getResponse()->getContent()); - - $headers = $this->generateHeaders('admin', 'mypassword', $salt[0]); $entry = $client->getContainer() ->get('doctrine.orm.entity_manager') -- cgit v1.2.3 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 --- .../CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') 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 From 2ab8cb681608d5887e0b6a92fcafff600a435e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Sat, 28 Feb 2015 14:22:11 +0100 Subject: fix tests --- .../CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/Wallabag/CoreBundle/Tests/Controller') diff --git a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php index c45e52d7..0eca7cde 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php @@ -140,7 +140,7 @@ class WallabagRestControllerTest extends WallabagTestCase $client->request('GET', '/api/salts/admin.json'); $salt = json_decode($client->getResponse()->getContent()); - $headers = $this->generateHeaders('admin', 'test', $salt[0]); + $headers = $this->generateHeaders('admin', 'mypassword', $salt[0]); $client->request('DELETE', '/api/entries/'.$entry->getId().'.json', array(), array(), $headers); @@ -152,7 +152,7 @@ class WallabagRestControllerTest extends WallabagTestCase $client = $this->createClient(); $client->request('GET', '/api/salts/admin.json'); $salt = json_decode($client->getResponse()->getContent()); - $headers = $this->generateHeaders('admin', 'test', $salt[0]); + $headers = $this->generateHeaders('admin', 'mypassword', $salt[0]); $entry = $client->getContainer() ->get('doctrine.orm.entity_manager') @@ -180,7 +180,7 @@ class WallabagRestControllerTest extends WallabagTestCase $client = $this->createClient(); $client->request('GET', '/api/salts/admin.json'); $salt = json_decode($client->getResponse()->getContent()); - $headers = $this->generateHeaders('admin', 'test', $salt[0]); + $headers = $this->generateHeaders('admin', 'mypassword', $salt[0]); $entry = $client->getContainer() ->get('doctrine.orm.entity_manager') -- cgit v1.2.3