X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FUserBundle%2FController%2FManageControllerTest.php;h=44b9a0301c51e11b4ba255c6b0c13a266f6f0af8;hb=cebed9c01f20d47cb60259f0c002ea57a80da4d0;hp=247eb6ba9c20be239a43d380f09d10135afbf614;hpb=152fcccd4489378a8ed9391e3e191df4aeba6435;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index 247eb6ba..44b9a030 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php @@ -10,7 +10,7 @@ class ManageControllerTest extends WallabagCoreTestCase { $client = $this->getClient(); - $client->request('GET', '/users/'); + $client->request('GET', '/users/list'); $this->assertEquals(302, $client->getResponse()->getStatusCode()); $this->assertContains('login', $client->getResponse()->headers->get('location')); @@ -22,8 +22,8 @@ class ManageControllerTest extends WallabagCoreTestCase $client = $this->getClient(); // Create a new user in the database - $crawler = $client->request('GET', '/users/'); - $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /users/"); + $crawler = $client->request('GET', '/users/list'); + $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/'); $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); // Fill in the form and submit it @@ -36,7 +36,7 @@ class ManageControllerTest extends WallabagCoreTestCase $client->submit($form); $client->followRedirect(); - $crawler = $client->request('GET', '/users/'); + $crawler = $client->request('GET', '/users/list'); // Check data in the show view $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); @@ -49,7 +49,6 @@ class ManageControllerTest extends WallabagCoreTestCase 'user[username]' => 'test_user', 'user[email]' => 'test@test.io', 'user[enabled]' => true, - 'user[locked]' => false, )); $client->submit($form); @@ -58,7 +57,7 @@ class ManageControllerTest extends WallabagCoreTestCase // Check the element contains an attribute with value equals "Foo User" $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); - $crawler = $client->request('GET', '/users/'); + $crawler = $client->request('GET', '/users/list'); $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); // Delete the user @@ -68,4 +67,33 @@ class ManageControllerTest extends WallabagCoreTestCase // Check the user has been delete on the list $this->assertNotRegExp('/Foo User/', $client->getResponse()->getContent()); } + + public function testDeleteDisabledForLoggedUser() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + $crawler = $client->request('GET', '/users/'.$this->getLoggedInUserId().'/edit'); + $disabled = $crawler->selectButton('user.form.delete')->extract('disabled'); + + $this->assertEquals('disabled', $disabled[0]); + } + + public function testUserSearch() + { + $this->logInAs('admin'); + $client = $this->getClient(); + + // Search on unread list + $crawler = $client->request('GET', '/users/list'); + + $form = $crawler->filter('form[name=search_users]')->form(); + $data = [ + 'search_user[term]' => 'admin', + ]; + + $crawler = $client->submit($form, $data); + + $this->assertCount(2, $crawler->filter('tr')); // 1 result + table header + } }