diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-10-28 10:55:39 +0200 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2016-10-28 10:55:39 +0200 |
commit | f24ea59ea4e854d8a699f51a7347af9d4a222de8 (patch) | |
tree | 24fed3891e3e982222731b8b48b7abbc088a5fc9 /tests/Wallabag/ApiBundle/Controller | |
parent | 23406ca3f12303759ecb46974d6bcb22fb0e037b (diff) | |
download | wallabag-f24ea59ea4e854d8a699f51a7347af9d4a222de8.tar.gz wallabag-f24ea59ea4e854d8a699f51a7347af9d4a222de8.tar.zst wallabag-f24ea59ea4e854d8a699f51a7347af9d4a222de8.zip |
Fixed migration and added tests
Diffstat (limited to 'tests/Wallabag/ApiBundle/Controller')
-rw-r--r-- | tests/Wallabag/ApiBundle/Controller/DeveloperControllerTest.php | 19 |
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 | } |