aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php')
-rw-r--r--tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php19
1 files changed, 16 insertions, 3 deletions
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}