]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Added tests
authorNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 18 Nov 2016 16:36:19 +0000 (17:36 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Sat, 19 Nov 2016 19:05:16 +0000 (20:05 +0100)
app/Resources/static/themes/material/css/main.css
src/Wallabag/CoreBundle/Repository/EntryRepository.php
src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml
src/Wallabag/CoreBundle/Resources/views/themes/baggy/Entry/search_form.html.twig
src/Wallabag/CoreBundle/Resources/views/themes/baggy/layout.html.twig
tests/Wallabag/CoreBundle/Controller/EntryControllerTest.php

index 21f948b158d409eec8ecde243c771a57f878d9b9..8e33cfbcb12e5cc63287b5b5a47bf9b523db7450 100755 (executable)
@@ -349,7 +349,7 @@ nav input {
 .input-field.nav-panel-add,
 .input-field.nav-panel-add form,
 .input-field.nav-panel-search,
-.input-field.nav-panel-search form{
+.input-field.nav-panel-search form {
   height: 100%;
 }
 
index 51cfe4d195447be7e87b696ee3b394dba78ca824..47e24d6b4796a572fac31fbb0de3636630441d3e 100644 (file)
@@ -110,8 +110,7 @@ class EntryRepository extends EntityRepository
         $qb
             ->andWhere('e.content LIKE :term OR e.title LIKE :term')->setParameter('term', '%'.$term.'%')
             ->leftJoin('e.tags', 't')
-            ->groupBy('e.id')
-            ->having('count(t.id) = 0');
+            ->groupBy('e.id');
 
         return $qb;
     }
index d5c00e525df504f3121993340492662ddd7d0e3c..d97eab269fb820660884f7bfa244a3c3f8bf90d3 100644 (file)
@@ -162,7 +162,7 @@ entry:
         archived: "Articles lus"
         filtered: "Articles filtrés"
         filtered_tags: "Articles filtrés par tags :"
-        filtered_search: 'Articles filtrés par une recherche :'
+        filtered_search: 'Articles filtrés par recherche :'
         untagged: "Article sans tag"
     list:
         number_on_the_page: "{0} Il n’y a pas d’articles.|{1} Il y a un article.|]1,Inf[ Il y a %count% articles."
index 818513f31bd8e10fccfda63f58969887e617baf6..20821b6d3ce7898038cbe3c56572a36cfdcfb2a3 100644 (file)
@@ -9,6 +9,8 @@
         <span class="black-text">{{ form_errors(form.term) }}</span>
     {% endif %}
 
+    <input type="hidden" name="currentRoute" value="{{ currentRoute }}" />
+
     {{ form_widget(form.term, { 'attr': {'autocomplete': 'off', 'placeholder': 'entry.search.placeholder'} }) }}
 
     {{ form_rest(form) }}
index fc024aff506751553cb87fa1cf78440df1192850..07ff8e14a8046c1fa42dbefa79f3e8f6b4d29797 100644 (file)
@@ -33,7 +33,7 @@
         <li class="menu new"><a href="{{ path('new') }}">{{ 'menu.left.save_link'|trans }}</a></li>
         <li style="position: relative;"><a href="javascript: void(null);" id="search">{{ 'menu.left.search'|trans }}</a>
             <div id="search-form" class="messages info popup-form">
-                {{ render(controller("WallabagCoreBundle:Entry:searchForm")) }}
+                {{ render(controller("WallabagCoreBundle:Entry:searchForm", {'currentRoute': app.request.attributes.get('_route')})) }}
             </div>
         </li>
         <li class="menu config"><a href="{{ path('config') }}">{{ 'menu.left.config'|trans }}</a></li>
index 09cf01b8c51e8e90882fa72112db9ef8bb93ebb0..b248b1781c66d1f1536abffc3bb12af1ede6fa56 100644 (file)
@@ -1018,4 +1018,71 @@ class EntryControllerTest extends WallabagCoreTestCase
 
         $this->assertCount(7, $crawler->filter('div[class=entry]'));
     }
+
+    public function testSearch()
+    {
+        $this->logInAs('admin');
+        $client = $this->getClient();
+
+        // Search on unread list
+        $crawler = $client->request('GET', '/unread/list');
+
+        $form = $crawler->filter('form[name=search]')->form();
+        $data = [
+            'search_entry[term]' => 'title',
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(4, $crawler->filter('div[class=entry]'));
+
+        // Search on starred list
+        $crawler = $client->request('GET', '/starred/list');
+
+        $form = $crawler->filter('form[name=search]')->form();
+        $data = [
+            'search_entry[term]' => 'title',
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+
+        // Added new article to test on archive list
+        $crawler = $client->request('GET', '/new');
+        $form = $crawler->filter('form[name=entry]')->form();
+        $data = [
+            'entry[url]' => $this->url,
+        ];
+        $client->submit($form, $data);
+        $content = $client->getContainer()
+            ->get('doctrine.orm.entity_manager')
+            ->getRepository('WallabagCoreBundle:Entry')
+            ->findByUrlAndUserId($this->url, $this->getLoggedInUserId());
+        $client->request('GET', '/archive/'.$content->getId());
+
+        $crawler = $client->request('GET', '/archive/list');
+
+        $form = $crawler->filter('form[name=search]')->form();
+        $data = [
+            'search_entry[term]' => 'manège',
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $client->request('GET', '/delete/'.$content->getId());
+
+        // test on list of all articles
+        $crawler = $client->request('GET', '/all/list');
+
+        $form = $crawler->filter('form[name=search]')->form();
+        $data = [
+            'search_entry[term]' => 'pocket',
+        ];
+
+        $crawler = $client->submit($form, $data);
+
+        $this->assertCount(0, $crawler->filter('div[class=entry]'));
+    }
 }