diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-03-16 23:23:42 +0100 |
---|---|---|
committer | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-03-16 23:23:42 +0100 |
commit | 1978d0e3b63286bbf329b967bf1e6b2e3abef1b4 (patch) | |
tree | 60297ba36d01f9ae25dad3febf3f7d54000d52cf /src/Wallabag/ApiBundle/Tests/Controller | |
parent | 3500d4099f88f7db22eba42fdb7e8926f1f1cdac (diff) | |
parent | bc2b947cd54e49a03c267f3c0f13dc5b8a04d962 (diff) | |
download | wallabag-1978d0e3b63286bbf329b967bf1e6b2e3abef1b4.tar.gz wallabag-1978d0e3b63286bbf329b967bf1e6b2e3abef1b4.tar.zst wallabag-1978d0e3b63286bbf329b967bf1e6b2e3abef1b4.zip |
Merge pull request #1791 from wallabag/v2-fix-api-entry-properties
fix api properties and typo
Diffstat (limited to 'src/Wallabag/ApiBundle/Tests/Controller')
-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() |