aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Wallabag/AnnotationBundle/Controller/AnnotationControllerTest.php2
-rw-r--r--tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php19
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}