diff options
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | src/Wallabag/ApiBundle/Controller/TagRestController.php | 4 | ||||
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | 30 |
3 files changed, 29 insertions, 6 deletions
diff --git a/.travis.yml b/.travis.yml index d7c28388..fb32befb 100644 --- a/.travis.yml +++ b/.travis.yml | |||
@@ -21,6 +21,7 @@ cache: | |||
21 | - $HOME/.composer/cache | 21 | - $HOME/.composer/cache |
22 | - node_modules | 22 | - node_modules |
23 | - $HOME/.npm | 23 | - $HOME/.npm |
24 | - $HOME/.yarn-cache | ||
24 | 25 | ||
25 | php: | 26 | php: |
26 | - 5.6 | 27 | - 5.6 |
diff --git a/src/Wallabag/ApiBundle/Controller/TagRestController.php b/src/Wallabag/ApiBundle/Controller/TagRestController.php index 47298d7e..354187a0 100644 --- a/src/Wallabag/ApiBundle/Controller/TagRestController.php +++ b/src/Wallabag/ApiBundle/Controller/TagRestController.php | |||
@@ -44,7 +44,7 @@ class TagRestController extends WallabagRestController | |||
44 | public function deleteTagLabelAction(Request $request) | 44 | public function deleteTagLabelAction(Request $request) |
45 | { | 45 | { |
46 | $this->validateAuthentication(); | 46 | $this->validateAuthentication(); |
47 | $label = $request->request->get('tag', ''); | 47 | $label = $request->get('tag', ''); |
48 | 48 | ||
49 | $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label); | 49 | $tag = $this->getDoctrine()->getRepository('WallabagCoreBundle:Tag')->findOneByLabel($label); |
50 | 50 | ||
@@ -78,7 +78,7 @@ class TagRestController extends WallabagRestController | |||
78 | { | 78 | { |
79 | $this->validateAuthentication(); | 79 | $this->validateAuthentication(); |
80 | 80 | ||
81 | $tagsLabels = $request->request->get('tags', ''); | 81 | $tagsLabels = $request->get('tags', ''); |
82 | 82 | ||
83 | $tags = []; | 83 | $tags = []; |
84 | 84 | ||
diff --git a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php index bde5251f..90b132eb 100644 --- a/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/TagRestControllerTest.php | |||
@@ -54,7 +54,18 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
54 | $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); | 54 | $this->assertNull($tag, $tagName.' was removed because it begun an orphan tag'); |
55 | } | 55 | } |
56 | 56 | ||
57 | public function testDeleteTagByLabel() | 57 | public function dataForDeletingTagByLabel() |
58 | { | ||
59 | return [ | ||
60 | 'by_query' => [true], | ||
61 | 'by_body' => [false], | ||
62 | ]; | ||
63 | } | ||
64 | |||
65 | /** | ||
66 | * @dataProvider dataForDeletingTagByLabel | ||
67 | */ | ||
68 | public function testDeleteTagByLabel($useQueryString) | ||
58 | { | 69 | { |
59 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 70 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
60 | $entry = $this->client->getContainer() | 71 | $entry = $this->client->getContainer() |
@@ -73,7 +84,11 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
73 | $em->persist($entry); | 84 | $em->persist($entry); |
74 | $em->flush(); | 85 | $em->flush(); |
75 | 86 | ||
76 | $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]); | 87 | if ($useQueryString) { |
88 | $this->client->request('DELETE', '/api/tag/label.json?tag='.$tag->getLabel()); | ||
89 | } else { | ||
90 | $this->client->request('DELETE', '/api/tag/label.json', ['tag' => $tag->getLabel()]); | ||
91 | } | ||
77 | 92 | ||
78 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 93 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
79 | 94 | ||
@@ -98,7 +113,10 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
98 | $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); | 113 | $this->assertEquals(404, $this->client->getResponse()->getStatusCode()); |
99 | } | 114 | } |
100 | 115 | ||
101 | public function testDeleteTagsByLabel() | 116 | /** |
117 | * @dataProvider dataForDeletingTagByLabel | ||
118 | */ | ||
119 | public function testDeleteTagsByLabel($useQueryString) | ||
102 | { | 120 | { |
103 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); | 121 | $em = $this->client->getContainer()->get('doctrine.orm.entity_manager'); |
104 | $entry = $this->client->getContainer() | 122 | $entry = $this->client->getContainer() |
@@ -122,7 +140,11 @@ class TagRestControllerTest extends WallabagApiTestCase | |||
122 | $em->persist($entry); | 140 | $em->persist($entry); |
123 | $em->flush(); | 141 | $em->flush(); |
124 | 142 | ||
125 | $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]); | 143 | if ($useQueryString) { |
144 | $this->client->request('DELETE', '/api/tags/label.json?tags='.$tag->getLabel().','.$tag2->getLabel()); | ||
145 | } else { | ||
146 | $this->client->request('DELETE', '/api/tags/label.json', ['tags' => $tag->getLabel().','.$tag2->getLabel()]); | ||
147 | } | ||
126 | 148 | ||
127 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 149 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
128 | 150 | ||