diff options
author | Jeremy Benoist <j0k3r@users.noreply.github.com> | 2016-10-29 13:20:55 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-29 13:20:55 +0200 |
commit | 5feef9f7a4e6852415feb388190b7ca141f116d1 (patch) | |
tree | 773b12c221b089ba508040e855d78f27edb589b0 /tests | |
parent | 8e58be9fb62615cdd8f4b55ad0981f57641bf0ab (diff) | |
parent | f08ec5f88a78bfe2edf2c2148094f3f099e8389c (diff) | |
download | wallabag-5feef9f7a4e6852415feb388190b7ca141f116d1.tar.gz wallabag-5feef9f7a4e6852415feb388190b7ca141f116d1.tar.zst wallabag-5feef9f7a4e6852415feb388190b7ca141f116d1.zip |
Merge pull request #2499 from wallabag/add-relation-client-user
Added relation between API Client and User
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | 2 | ||||
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php | 19 |
2 files changed, 17 insertions, 4 deletions
diff --git a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php index cee0b847..81f9e9ec 100644 --- a/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php +++ b/tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php | |||
@@ -11,7 +11,7 @@ class AnnotationControllerTest extends WallabagAnnotationTestCase | |||
11 | /** | 11 | /** |
12 | * This data provider allow to tests annotation from the : | 12 | * This data provider allow to tests annotation from the : |
13 | * - API POV (when user use the api to manage annotations) | 13 | * - API POV (when user use the api to manage annotations) |
14 | * - and User POV (when user use the web interface - using javascript - to manage annotations) | 14 | * - and User POV (when user use the web interface - using javascript - to manage annotations). |
15 | */ | 15 | */ |
16 | public function dataForEachAnnotations() | 16 | public function dataForEachAnnotations() |
17 | { | 17 | { |
diff --git a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php index 95befa9c..6659443b 100644 --- a/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php +++ b/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php | |||
@@ -82,11 +82,24 @@ class DeveloperControllerTest extends WallabagCoreTestCase | |||
82 | 82 | ||
83 | public function testRemoveClient() | 83 | public function testRemoveClient() |
84 | { | 84 | { |
85 | $this->logInAs('admin'); | ||
86 | $client = $this->getClient(); | 85 | $client = $this->getClient(); |
87 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); | 86 | $em = $client->getContainer()->get('doctrine.orm.entity_manager'); |
88 | $nbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | ||
89 | 87 | ||
88 | // Try to remove an admin's client with a wrong user | ||
89 | $this->logInAs('bob'); | ||
90 | $client->request('GET', '/developer'); | ||
91 | $this->assertContains('no_client', $client->getResponse()->getContent()); | ||
92 | |||
93 | // get an ID of a admin's client | ||
94 | $this->logInAs('admin'); | ||
95 | $nbClients = $em->getRepository('WallabagApiBundle:Client')->findByUser($this->getLoggedInUserId()); | ||
96 | |||
97 | $this->logInAs('bob'); | ||
98 | $client->request('GET', '/developer/client/delete/'.$nbClients[0]->getId()); | ||
99 | $this->assertEquals(403, $client->getResponse()->getStatusCode()); | ||
100 | |||
101 | // Try to remove the admin's client with the good user | ||
102 | $this->logInAs('admin'); | ||
90 | $crawler = $client->request('GET', '/developer'); | 103 | $crawler = $client->request('GET', '/developer'); |
91 | 104 | ||
92 | $link = $crawler | 105 | $link = $crawler |
@@ -98,7 +111,7 @@ class DeveloperControllerTest extends WallabagCoreTestCase | |||
98 | $client->click($link); | 111 | $client->click($link); |
99 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); | 112 | $this->assertEquals(302, $client->getResponse()->getStatusCode()); |
100 | 113 | ||
101 | $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findAll(); | 114 | $newNbClients = $em->getRepository('WallabagApiBundle:Client')->findByUser($this->getLoggedInUserId()); |
102 | $this->assertGreaterThan(count($newNbClients), count($nbClients)); | 115 | $this->assertGreaterThan(count($newNbClients), count($nbClients)); |
103 | } | 116 | } |
104 | } | 117 | } |