diff options
Diffstat (limited to 'tests/Wallabag/ApiBundle')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | 15 | ||||
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php | 13 |
2 files changed, 26 insertions, 2 deletions
diff --git a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php index 0968cfaf..4aa60e90 100644 --- a/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/EntryRestControllerTest.php | |||
@@ -345,7 +345,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
345 | 'tags' => 'google', | 345 | 'tags' => 'google', |
346 | 'title' => 'New title for my article', | 346 | 'title' => 'New title for my article', |
347 | 'content' => 'my content', | 347 | 'content' => 'my content', |
348 | 'language' => 'de_DE', | 348 | 'language' => 'de', |
349 | 'published_at' => '2016-09-08T11:55:58+0200', | 349 | 'published_at' => '2016-09-08T11:55:58+0200', |
350 | 'authors' => 'bob,helen', | 350 | 'authors' => 'bob,helen', |
351 | ]); | 351 | ]); |
@@ -362,7 +362,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
362 | $this->assertEquals(1, $content['user_id']); | 362 | $this->assertEquals(1, $content['user_id']); |
363 | $this->assertCount(2, $content['tags']); | 363 | $this->assertCount(2, $content['tags']); |
364 | $this->assertSame('my content', $content['content']); | 364 | $this->assertSame('my content', $content['content']); |
365 | $this->assertSame('de_DE', $content['language']); | 365 | $this->assertSame('de', $content['language']); |
366 | $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']); | 366 | $this->assertSame('2016-09-08T11:55:58+0200', $content['published_at']); |
367 | $this->assertCount(2, $content['published_by']); | 367 | $this->assertCount(2, $content['published_by']); |
368 | $this->assertContains('bob', $content['published_by']); | 368 | $this->assertContains('bob', $content['published_by']); |
@@ -477,6 +477,10 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
477 | 'tags' => 'new tag '.uniqid(), | 477 | 'tags' => 'new tag '.uniqid(), |
478 | 'starred' => '1', | 478 | 'starred' => '1', |
479 | 'archive' => '0', | 479 | 'archive' => '0', |
480 | 'language' => 'de_AT', | ||
481 | 'preview_picture' => 'http://preview.io/picture.jpg', | ||
482 | 'authors' => 'bob,sponge', | ||
483 | 'content' => 'awesome', | ||
480 | ]); | 484 | ]); |
481 | 485 | ||
482 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 486 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
@@ -488,6 +492,11 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
488 | $this->assertEquals('New awesome title', $content['title']); | 492 | $this->assertEquals('New awesome title', $content['title']); |
489 | $this->assertGreaterThan($nbTags, count($content['tags'])); | 493 | $this->assertGreaterThan($nbTags, count($content['tags'])); |
490 | $this->assertEquals(1, $content['user_id']); | 494 | $this->assertEquals(1, $content['user_id']); |
495 | $this->assertEquals('de_AT', $content['language']); | ||
496 | $this->assertEquals('http://preview.io/picture.jpg', $content['preview_picture']); | ||
497 | $this->assertContains('sponge', $content['published_by']); | ||
498 | $this->assertContains('bob', $content['published_by']); | ||
499 | $this->assertEquals('awesome', $content['content']); | ||
491 | } | 500 | } |
492 | 501 | ||
493 | public function testPatchEntryWithoutQuotes() | 502 | public function testPatchEntryWithoutQuotes() |
@@ -509,6 +518,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
509 | 'tags' => 'new tag '.uniqid(), | 518 | 'tags' => 'new tag '.uniqid(), |
510 | 'starred' => 1, | 519 | 'starred' => 1, |
511 | 'archive' => 0, | 520 | 'archive' => 0, |
521 | 'authors' => ['bob', 'sponge'], | ||
512 | ]); | 522 | ]); |
513 | 523 | ||
514 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); | 524 | $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); |
@@ -519,6 +529,7 @@ class EntryRestControllerTest extends WallabagApiTestCase | |||
519 | $this->assertEquals($entry->getUrl(), $content['url']); | 529 | $this->assertEquals($entry->getUrl(), $content['url']); |
520 | $this->assertEquals('New awesome title', $content['title']); | 530 | $this->assertEquals('New awesome title', $content['title']); |
521 | $this->assertGreaterThan($nbTags, count($content['tags'])); | 531 | $this->assertGreaterThan($nbTags, count($content['tags'])); |
532 | $this->assertTrue(empty($content['published_by']), 'Authors were not saved because of an array instead of a string'); | ||
522 | } | 533 | } |
523 | 534 | ||
524 | public function testGetTagsEntry() | 535 | public function testGetTagsEntry() |
diff --git a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php index 5735bc58..4e65f130 100644 --- a/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/UserRestControllerTest.php | |||
@@ -61,10 +61,16 @@ class UserRestControllerTest extends WallabagApiTestCase | |||
61 | $this->assertArrayHasKey('username', $content); | 61 | $this->assertArrayHasKey('username', $content); |
62 | $this->assertArrayHasKey('created_at', $content); | 62 | $this->assertArrayHasKey('created_at', $content); |
63 | $this->assertArrayHasKey('updated_at', $content); | 63 | $this->assertArrayHasKey('updated_at', $content); |
64 | $this->assertArrayHasKey('default_client', $content); | ||
64 | 65 | ||
65 | $this->assertEquals('wallabag@google.com', $content['email']); | 66 | $this->assertEquals('wallabag@google.com', $content['email']); |
66 | $this->assertEquals('google', $content['username']); | 67 | $this->assertEquals('google', $content['username']); |
67 | 68 | ||
69 | $this->assertArrayHasKey('client_secret', $content['default_client']); | ||
70 | $this->assertArrayHasKey('client_id', $content['default_client']); | ||
71 | |||
72 | $this->assertEquals('Default client', $content['default_client']['name']); | ||
73 | |||
68 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); | 74 | $this->assertEquals('application/json', $this->client->getResponse()->headers->get('Content-Type')); |
69 | 75 | ||
70 | $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0); | 76 | $this->client->getContainer()->get('craue_config')->set('api_user_registration', 0); |
@@ -79,6 +85,7 @@ class UserRestControllerTest extends WallabagApiTestCase | |||
79 | 'username' => 'google', | 85 | 'username' => 'google', |
80 | 'password' => 'googlegoogle', | 86 | 'password' => 'googlegoogle', |
81 | 'email' => 'wallabag@google.com', | 87 | 'email' => 'wallabag@google.com', |
88 | 'client_name' => 'My client name !!', | ||
82 | ]); | 89 | ]); |
83 | 90 | ||
84 | $this->assertEquals(201, $client->getResponse()->getStatusCode()); | 91 | $this->assertEquals(201, $client->getResponse()->getStatusCode()); |
@@ -90,10 +97,16 @@ class UserRestControllerTest extends WallabagApiTestCase | |||
90 | $this->assertArrayHasKey('username', $content); | 97 | $this->assertArrayHasKey('username', $content); |
91 | $this->assertArrayHasKey('created_at', $content); | 98 | $this->assertArrayHasKey('created_at', $content); |
92 | $this->assertArrayHasKey('updated_at', $content); | 99 | $this->assertArrayHasKey('updated_at', $content); |
100 | $this->assertArrayHasKey('default_client', $content); | ||
93 | 101 | ||
94 | $this->assertEquals('wallabag@google.com', $content['email']); | 102 | $this->assertEquals('wallabag@google.com', $content['email']); |
95 | $this->assertEquals('google', $content['username']); | 103 | $this->assertEquals('google', $content['username']); |
96 | 104 | ||
105 | $this->assertArrayHasKey('client_secret', $content['default_client']); | ||
106 | $this->assertArrayHasKey('client_id', $content['default_client']); | ||
107 | |||
108 | $this->assertEquals('My client name !!', $content['default_client']['name']); | ||
109 | |||
97 | $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); | 110 | $this->assertEquals('application/json', $client->getResponse()->headers->get('Content-Type')); |
98 | 111 | ||
99 | $client->getContainer()->get('craue_config')->set('api_user_registration', 0); | 112 | $client->getContainer()->get('craue_config')->set('api_user_registration', 0); |