diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-24 22:00:24 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 20:50:31 +0100 |
commit | a36737f4859e3acbddf5cfe90c279ba725a6d88a (patch) | |
tree | b65709740a5e92bc53eeb0e3e050e0df3e78f3bb /src/Wallabag/CoreBundle/Tests | |
parent | 46bbd8d321e6a00131f0e6ed96fa6f3d693b3678 (diff) | |
download | wallabag-a36737f4859e3acbddf5cfe90c279ba725a6d88a.tar.gz wallabag-a36737f4859e3acbddf5cfe90c279ba725a6d88a.tar.zst wallabag-a36737f4859e3acbddf5cfe90c279ba725a6d88a.zip |
POST entries/tags with test
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/WallabagRestControllerTest.php | 37 |
1 files changed, 37 insertions, 0 deletions
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 | |||
176 | 176 | ||
177 | $this->assertEquals(json_encode($tags), $client->getResponse()->getContent()); | 177 | $this->assertEquals(json_encode($tags), $client->getResponse()->getContent()); |
178 | } | 178 | } |
179 | |||
180 | public function testPostTagsOnEntry() | ||
181 | { | ||
182 | $client = $this->createClient(); | ||
183 | $client->request('GET', '/api/salts/admin.json'); | ||
184 | $salt = json_decode($client->getResponse()->getContent()); | ||
185 | $headers = $this->generateHeaders('admin', 'test', $salt[0]); | ||
186 | |||
187 | $entry = $client->getContainer() | ||
188 | ->get('doctrine.orm.entity_manager') | ||
189 | ->getRepository('WallabagCoreBundle:Entry') | ||
190 | ->findOneByUser(1); | ||
191 | |||
192 | if (!$entry) { | ||
193 | $this->markTestSkipped('No content found in db.'); | ||
194 | } | ||
195 | |||
196 | $newTags = 'tag1,tag2,tag3'; | ||
197 | |||
198 | $client->request('POST', '/api/entries/'.$entry->getId().'/tags', array('tags' => $newTags), array(), $headers); | ||
199 | |||
200 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | ||
201 | |||
202 | $entryDB = $client->getContainer() | ||
203 | ->get('doctrine.orm.entity_manager') | ||
204 | ->getRepository('WallabagCoreBundle:Entry') | ||
205 | ->find($entry->getId()); | ||
206 | |||
207 | $tagsInDB = array(); | ||
208 | foreach ($entryDB->getTags()->toArray() as $tag) { | ||
209 | $tagsInDB[$tag->getId()] = $tag->getLabel(); | ||
210 | } | ||
211 | |||
212 | foreach (explode(',', $newTags) as $tag) { | ||
213 | $this->assertContains($tag, $tagsInDB); | ||
214 | } | ||
215 | } | ||
179 | } | 216 | } |