diff options
Diffstat (limited to 'src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php')
-rw-r--r-- | src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php index 2e78d8b2..ccb72d23 100644 --- a/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php +++ b/src/Wallabag/ApiBundle/Tests/Controller/WallabagRestControllerTest.php | |||
@@ -188,8 +188,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
188 | { | 188 | { |
189 | $this->client->request('POST', '/api/entries.json', array( | 189 | $this->client->request('POST', '/api/entries.json', array( |
190 | 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', | 190 | 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', |
191 | 'archive' => true, | 191 | 'archive' => '1', |
192 | 'starred' => true, | 192 | 'starred' => '1', |
193 | )); | 193 | )); |
194 | 194 | ||
195 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 195 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
@@ -203,6 +203,24 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
203 | $this->assertEquals(1, $content['user_id']); | 203 | $this->assertEquals(1, $content['user_id']); |
204 | } | 204 | } |
205 | 205 | ||
206 | public function testPostArchivedAndStarredEntryWithoutQuotes() | ||
207 | { | ||
208 | $this->client->request('POST', '/api/entries.json', array( | ||
209 | 'url' => 'http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', | ||
210 | 'archive' => 0, | ||
211 | 'starred' => 1, | ||
212 | )); | ||
213 | |||
214 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
215 | |||
216 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
217 | |||
218 | $this->assertGreaterThan(0, $content['id']); | ||
219 | $this->assertEquals('http://www.lemonde.fr/idees/article/2016/02/08/preserver-la-liberte-d-expression-sur-les-reseaux-sociaux_4861503_3232.html', $content['url']); | ||
220 | $this->assertEquals(false, $content['is_archived']); | ||
221 | $this->assertEquals(true, $content['is_starred']); | ||
222 | } | ||
223 | |||
206 | public function testPatchEntry() | 224 | public function testPatchEntry() |
207 | { | 225 | { |
208 | $entry = $this->client->getContainer() | 226 | $entry = $this->client->getContainer() |
@@ -220,8 +238,8 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
220 | $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array( | 238 | $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array( |
221 | 'title' => 'New awesome title', | 239 | 'title' => 'New awesome title', |
222 | 'tags' => 'new tag '.uniqid(), | 240 | 'tags' => 'new tag '.uniqid(), |
223 | 'star' => true, | 241 | 'starred' => '1', |
224 | 'archive' => false, | 242 | 'archive' => '0', |
225 | )); | 243 | )); |
226 | 244 | ||
227 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 245 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
@@ -235,6 +253,37 @@ class WallabagRestControllerTest extends WallabagApiTestCase | |||
235 | $this->assertEquals(1, $content['user_id']); | 253 | $this->assertEquals(1, $content['user_id']); |
236 | } | 254 | } |
237 | 255 | ||
256 | public function testPatchEntryWithoutQuotes() | ||
257 | { | ||
258 | $entry = $this->client->getContainer() | ||
259 | ->get('doctrine.orm.entity_manager') | ||
260 | ->getRepository('WallabagCoreBundle:Entry') | ||
261 | ->findOneByUser(1); | ||
262 | |||
263 | if (!$entry) { | ||
264 | $this->markTestSkipped('No content found in db.'); | ||
265 | } | ||
266 | |||
267 | // hydrate the tags relations | ||
268 | $nbTags = count($entry->getTags()); | ||
269 | |||
270 | $this->client->request('PATCH', '/api/entries/'.$entry->getId().'.json', array( | ||
271 | 'title' => 'New awesome title', | ||
272 | 'tags' => 'new tag '.uniqid(), | ||
273 | 'starred' => 1, | ||
274 | 'archive' => 0, | ||
275 | )); | ||
276 | |||
277 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | ||
278 | |||
279 | $content = json_decode($this->client->getResponse()->getContent(), true); | ||
280 | |||
281 | $this->assertEquals($entry->getId(), $content['id']); | ||
282 | $this->assertEquals($entry->getUrl(), $content['url']); | ||
283 | $this->assertEquals('New awesome title', $content['title']); | ||
284 | $this->assertGreaterThan($nbTags, count($content['tags'])); | ||
285 | } | ||
286 | |||
238 | public function testGetTagsEntry() | 287 | public function testGetTagsEntry() |
239 | { | 288 | { |
240 | $entry = $this->client->getContainer() | 289 | $entry = $this->client->getContainer() |