X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2FWallabag%2FUserBundle%2FController%2FManageControllerTest.php;h=f44e6fbf60028b9e7b9ebb5f918abc8810f2a0fb;hb=1e0d8ad7b728f6fb2cd886526b0fb84ef803e84f;hp=4faddfc4da7a6e81616a285e1dc3d882f3c61161;hpb=eef47c0ead8e7aa754f5160d077aaaa9f16937c9;p=github%2Fwallabag%2Fwallabag.git diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php index 4faddfc4..f44e6fbf 100644 --- a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php @@ -1,6 +1,6 @@ getClient(); - $client->request('GET', '/users/'); + $client->request('GET', '/users/list'); - $this->assertEquals(302, $client->getResponse()->getStatusCode()); + $this->assertSame(302, $client->getResponse()->getStatusCode()); $this->assertContains('login', $client->getResponse()->headers->get('location')); } @@ -22,21 +22,21 @@ 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->assertSame(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 - $form = $crawler->selectButton('user.form.save')->form(array( + $form = $crawler->selectButton('user.form.save')->form([ 'new_user[username]' => 'test_user', 'new_user[email]' => 'test@test.io', - 'new_user[plainPassword][first]' => 'test', - 'new_user[plainPassword][second]' => 'test', - )); + 'new_user[plainPassword][first]' => 'testtest', + 'new_user[plainPassword][second]' => 'testtest', + ]); $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")'); @@ -44,12 +44,12 @@ class ManageControllerTest extends WallabagCoreTestCase // Edit the user $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); - $form = $crawler->selectButton('user.form.save')->form(array( + $form = $crawler->selectButton('user.form.save')->form([ 'user[name]' => 'Foo User', 'user[username]' => 'test_user', 'user[email]' => 'test@test.io', 'user[enabled]' => true, - )); + ]); $client->submit($form); $crawler = $client->followRedirect(); @@ -57,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 @@ -73,9 +73,27 @@ class ManageControllerTest extends WallabagCoreTestCase $this->logInAs('admin'); $client = $this->getClient(); - $crawler = $client->request('GET', '/users/'.$this->getLoggedInUserId().'/edit'); + $crawler = $client->request('GET', '/users/' . $this->getLoggedInUserId() . '/edit'); $disabled = $crawler->selectButton('user.form.delete')->extract('disabled'); - $this->assertEquals('disabled', $disabled[0]); + $this->assertSame('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 } }