]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Fix tests for all
authorJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 28 Sep 2015 18:26:37 +0000 (20:26 +0200)
committerJeremy Benoist <jeremy.benoist@gmail.com>
Mon, 28 Sep 2015 18:26:37 +0000 (20:26 +0200)
src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php
src/Wallabag/CoreBundle/Repository/EntryRepository.php
src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php

index b4b685f92888b92680e0374892224abbbc8e7f2d..7e64c5e1c887ef72d8f03977315255781309d9f6 100644 (file)
@@ -87,6 +87,7 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface
         $entry5->setContent('This is my content /o/');
         $entry5->setStarred(true);
         $entry5->setLanguage('fr');
+        $entry5->setPreviewPicture('http://0.0.0.0/image.jpg');
 
         $manager->persist($entry5);
 
index 0e82b9b20dbf0698ede8b73386347d19301fd01e..2286317c177097f53ff8cf389e1dd05a72dfc0a5 100644 (file)
@@ -162,24 +162,6 @@ class EntryRepository extends EntityRepository
         return $languages;
     }
 
-    /**
-     * Used only in test case to get the right entry associated to the right user
-     *
-     * @param  string $username
-     *
-     * @return Entry
-     */
-    public function findOneByUsernameAndNotStarred($username)
-    {
-        return $this->createQueryBuilder('e')
-            ->leftJoin('e.user', 'u')
-            ->where('u.username = :username')->setParameter('username', $username)
-            ->andWhere('e.isStarred = false')
-            ->setMaxResults(1)
-            ->getQuery()
-            ->getSingleResult();
-    }
-
     /**
      * Used only in test case to get the right entry associated to the right user
      *
index 456c747a1cd795778b39365916dca9182db59124..e9c85a17225fffedadc3bab17e79c562ba347c17 100644 (file)
@@ -7,6 +7,8 @@ use Doctrine\ORM\AbstractQuery;
 
 class EntryControllerTest extends WallabagCoreTestCase
 {
+    public $url = 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html';
+
     public function testLogin()
     {
         $client = $this->getClient();
@@ -60,7 +62,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form = $crawler->filter('button[type=submit]')->form();
 
         $data = array(
-            'entry[url]' => 'http://www.lemonde.fr/pixels/article/2015/03/28/plongee-dans-l-univers-d-ingress-le-jeu-de-google-aux-frontieres-du-reel_4601155_4408996.html',
+            'entry[url]' => $this->url,
         );
 
         $client->submit($form, $data);
@@ -101,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUsernameAndNotArchived('admin');
+            ->findOneByUrl($this->url);
 
         $client->request('GET', '/view/'.$content->getId());
 
@@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUsernameAndNotArchived('admin');
+            ->findOneByUrl($this->url);
 
         $crawler = $client->request('GET', '/edit/'.$content->getId());
 
@@ -135,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUsernameAndNotArchived('admin');
+            ->findOneByUrl($this->url);
 
         $crawler = $client->request('GET', '/edit/'.$content->getId());
 
@@ -165,7 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUsernameAndNotArchived('admin');
+            ->findOneByUrl($this->url);
 
         $client->request('GET', '/archive/'.$content->getId());
 
@@ -187,7 +189,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUsernameAndNotStarred('admin');
+            ->findOneByUrl($this->url);
 
         $client->request('GET', '/star/'.$content->getId());
 
@@ -209,7 +211,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $content = $client->getContainer()
             ->get('doctrine.orm.entity_manager')
             ->getRepository('WallabagCoreBundle:Entry')
-            ->findOneByUsernameAndNotStarred('admin');
+            ->findOneByUrl($this->url);
 
         $client->request('GET', '/delete/'.$content->getId());
 
@@ -328,11 +330,11 @@ class EntryControllerTest extends WallabagCoreTestCase
         $crawler = $client->request('GET', '/unread/list');
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $data = array(
-            'entry_filter[domainName]' => 'monde',
+            'entry_filter[domainName]' => 'domain',
         );
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(1, $crawler->filter('div[class=entry]'));
+        $this->assertCount(5, $crawler->filter('div[class=entry]'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $data = array(
@@ -361,7 +363,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         $form['entry_filter[isStarred]']->tick();
 
         $crawler = $client->submit($form);
-        $this->assertCount(2, $crawler->filter('div[class=entry]'));
+        $this->assertCount(1, $crawler->filter('div[class=entry]'));
     }
 
     public function testPreviewPictureFilter()
@@ -389,7 +391,7 @@ class EntryControllerTest extends WallabagCoreTestCase
         );
 
         $crawler = $client->submit($form, $data);
-        $this->assertCount(3, $crawler->filter('div[class=entry]'));
+        $this->assertCount(2, $crawler->filter('div[class=entry]'));
 
         $form = $crawler->filter('button[id=submit-filter]')->form();
         $data = array(