From 02d17813a11d27e0232c38d1adf037cefdb176c1 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Mon, 28 Sep 2015 20:26:37 +0200 Subject: Fix tests for all --- .../CoreBundle/DataFixtures/ORM/LoadEntryData.php | 1 + .../CoreBundle/Repository/EntryRepository.php | 18 ---------------- .../Tests/Controller/EntryControllerTest.php | 24 ++++++++++++---------- 3 files changed, 14 insertions(+), 29 deletions(-) (limited to 'src/Wallabag') diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index b4b685f9..7e64c5e1 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php @@ -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); diff --git a/src/Wallabag/CoreBundle/Repository/EntryRepository.php b/src/Wallabag/CoreBundle/Repository/EntryRepository.php index 0e82b9b2..2286317c 100644 --- a/src/Wallabag/CoreBundle/Repository/EntryRepository.php +++ b/src/Wallabag/CoreBundle/Repository/EntryRepository.php @@ -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 * diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php index 456c747a..e9c85a17 100644 --- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php +++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php @@ -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( -- cgit v1.2.3