]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix tests
authorThomas Citharel <tcit@tcit.fr>
Thu, 27 Apr 2017 14:40:18 +0000 (16:40 +0200)
committerNicolas LÅ“uillet <nicolas@loeuillet.org>
Tue, 2 May 2017 13:28:39 +0000 (15:28 +0200)
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
src/Wallabag/UserBundle/Resources/views/Manage/search_form.html.twig
tests/Wallabag/UserBundle/Controller/ManageControllerTest.php

index f59388d09352550578af5883674b8df64c3a3bcb..1d4df20442f50ff8f42b01be34d151c1c69702cf 100644 (file)
@@ -1,4 +1,4 @@
-<form name="search" method="GET" action="{{ path('user-search')}}">
+<form name="search_users" method="GET" action="{{ path('user-search')}}">
     {% if form_errors(form) %}
         <span class="black-text">{{ form_errors(form) }}</span>
     {% endif %}
index 4faddfc4da7a6e81616a285e1dc3d882f3c61161..4154ad126378826456fb5ffa469be24947789837 100644 (file)
@@ -10,7 +10,7 @@ class ManageControllerTest extends WallabagCoreTestCase
     {
         $client = $this->getClient();
 
-        $client->request('GET', '/users/');
+        $client->request('GET', '/users/index');
 
         $this->assertEquals(302, $client->getResponse()->getStatusCode());
         $this->assertContains('login', $client->getResponse()->headers->get('location'));
@@ -22,7 +22,7 @@ class ManageControllerTest extends WallabagCoreTestCase
         $client = $this->getClient();
 
         // Create a new user in the database
-        $crawler = $client->request('GET', '/users/');
+        $crawler = $client->request('GET', '/users/index');
         $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /users/');
         $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link());
 
@@ -36,7 +36,7 @@ class ManageControllerTest extends WallabagCoreTestCase
 
         $client->submit($form);
         $client->followRedirect();
-        $crawler = $client->request('GET', '/users/');
+        $crawler = $client->request('GET', '/users/index');
 
         // Check data in the show view
         $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")');
@@ -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/index');
         $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link());
 
         // Delete the user
@@ -78,4 +78,22 @@ class ManageControllerTest extends WallabagCoreTestCase
 
         $this->assertEquals('disabled', $disabled[0]);
     }
+
+    public function testUserSearch()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        // Search on unread list
+        $crawler = $client->request('GET', '/users/index');
+
+        $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
+    }
 }