aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2015-09-28 20:26:37 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2015-09-28 20:26:37 +0200
commit02d17813a11d27e0232c38d1adf037cefdb176c1 (patch)
tree3e4be06bd9dde18c9b64ee34ced5850523849e6b /src/Wallabag
parent159986c4fbf63dd93136ea5c52ff0be705aefaf3 (diff)
downloadwallabag-02d17813a11d27e0232c38d1adf037cefdb176c1.tar.gz
wallabag-02d17813a11d27e0232c38d1adf037cefdb176c1.tar.zst
wallabag-02d17813a11d27e0232c38d1adf037cefdb176c1.zip
Fix tests for all
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php1
-rw-r--r--src/Wallabag/CoreBundle/Repository/EntryRepository.php18
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php24
3 files changed, 14 insertions, 29 deletions
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
87 $entry5->setContent('This is my content /o/'); 87 $entry5->setContent('This is my content /o/');
88 $entry5->setStarred(true); 88 $entry5->setStarred(true);
89 $entry5->setLanguage('fr'); 89 $entry5->setLanguage('fr');
90 $entry5->setPreviewPicture('http://0.0.0.0/image.jpg');
90 91
91 $manager->persist($entry5); 92 $manager->persist($entry5);
92 93
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
@@ -169,24 +169,6 @@ class EntryRepository extends EntityRepository
169 * 169 *
170 * @return Entry 170 * @return Entry
171 */ 171 */
172 public function findOneByUsernameAndNotStarred($username)
173 {
174 return $this->createQueryBuilder('e')
175 ->leftJoin('e.user', 'u')
176 ->where('u.username = :username')->setParameter('username', $username)
177 ->andWhere('e.isStarred = false')
178 ->setMaxResults(1)
179 ->getQuery()
180 ->getSingleResult();
181 }
182
183 /**
184 * Used only in test case to get the right entry associated to the right user
185 *
186 * @param string $username
187 *
188 * @return Entry
189 */
190 public function findOneByUsernameAndNotArchived($username) 172 public function findOneByUsernameAndNotArchived($username)
191 { 173 {
192 return $this->createQueryBuilder('e') 174 return $this->createQueryBuilder('e')
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;
7 7
8class EntryControllerTest extends WallabagCoreTestCase 8class EntryControllerTest extends WallabagCoreTestCase
9{ 9{
10 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';
11
10 public function testLogin() 12 public function testLogin()
11 { 13 {
12 $client = $this->getClient(); 14 $client = $this->getClient();
@@ -60,7 +62,7 @@ class EntryControllerTest extends WallabagCoreTestCase
60 $form = $crawler->filter('button[type=submit]')->form(); 62 $form = $crawler->filter('button[type=submit]')->form();
61 63
62 $data = array( 64 $data = array(
63 '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', 65 'entry[url]' => $this->url,
64 ); 66 );
65 67
66 $client->submit($form, $data); 68 $client->submit($form, $data);
@@ -101,7 +103,7 @@ class EntryControllerTest extends WallabagCoreTestCase
101 $content = $client->getContainer() 103 $content = $client->getContainer()
102 ->get('doctrine.orm.entity_manager') 104 ->get('doctrine.orm.entity_manager')
103 ->getRepository('WallabagCoreBundle:Entry') 105 ->getRepository('WallabagCoreBundle:Entry')
104 ->findOneByUsernameAndNotArchived('admin'); 106 ->findOneByUrl($this->url);
105 107
106 $client->request('GET', '/view/'.$content->getId()); 108 $client->request('GET', '/view/'.$content->getId());
107 109
@@ -117,7 +119,7 @@ class EntryControllerTest extends WallabagCoreTestCase
117 $content = $client->getContainer() 119 $content = $client->getContainer()
118 ->get('doctrine.orm.entity_manager') 120 ->get('doctrine.orm.entity_manager')
119 ->getRepository('WallabagCoreBundle:Entry') 121 ->getRepository('WallabagCoreBundle:Entry')
120 ->findOneByUsernameAndNotArchived('admin'); 122 ->findOneByUrl($this->url);
121 123
122 $crawler = $client->request('GET', '/edit/'.$content->getId()); 124 $crawler = $client->request('GET', '/edit/'.$content->getId());
123 125
@@ -135,7 +137,7 @@ class EntryControllerTest extends WallabagCoreTestCase
135 $content = $client->getContainer() 137 $content = $client->getContainer()
136 ->get('doctrine.orm.entity_manager') 138 ->get('doctrine.orm.entity_manager')
137 ->getRepository('WallabagCoreBundle:Entry') 139 ->getRepository('WallabagCoreBundle:Entry')
138 ->findOneByUsernameAndNotArchived('admin'); 140 ->findOneByUrl($this->url);
139 141
140 $crawler = $client->request('GET', '/edit/'.$content->getId()); 142 $crawler = $client->request('GET', '/edit/'.$content->getId());
141 143
@@ -165,7 +167,7 @@ class EntryControllerTest extends WallabagCoreTestCase
165 $content = $client->getContainer() 167 $content = $client->getContainer()
166 ->get('doctrine.orm.entity_manager') 168 ->get('doctrine.orm.entity_manager')
167 ->getRepository('WallabagCoreBundle:Entry') 169 ->getRepository('WallabagCoreBundle:Entry')
168 ->findOneByUsernameAndNotArchived('admin'); 170 ->findOneByUrl($this->url);
169 171
170 $client->request('GET', '/archive/'.$content->getId()); 172 $client->request('GET', '/archive/'.$content->getId());
171 173
@@ -187,7 +189,7 @@ class EntryControllerTest extends WallabagCoreTestCase
187 $content = $client->getContainer() 189 $content = $client->getContainer()
188 ->get('doctrine.orm.entity_manager') 190 ->get('doctrine.orm.entity_manager')
189 ->getRepository('WallabagCoreBundle:Entry') 191 ->getRepository('WallabagCoreBundle:Entry')
190 ->findOneByUsernameAndNotStarred('admin'); 192 ->findOneByUrl($this->url);
191 193
192 $client->request('GET', '/star/'.$content->getId()); 194 $client->request('GET', '/star/'.$content->getId());
193 195
@@ -209,7 +211,7 @@ class EntryControllerTest extends WallabagCoreTestCase
209 $content = $client->getContainer() 211 $content = $client->getContainer()
210 ->get('doctrine.orm.entity_manager') 212 ->get('doctrine.orm.entity_manager')
211 ->getRepository('WallabagCoreBundle:Entry') 213 ->getRepository('WallabagCoreBundle:Entry')
212 ->findOneByUsernameAndNotStarred('admin'); 214 ->findOneByUrl($this->url);
213 215
214 $client->request('GET', '/delete/'.$content->getId()); 216 $client->request('GET', '/delete/'.$content->getId());
215 217
@@ -328,11 +330,11 @@ class EntryControllerTest extends WallabagCoreTestCase
328 $crawler = $client->request('GET', '/unread/list'); 330 $crawler = $client->request('GET', '/unread/list');
329 $form = $crawler->filter('button[id=submit-filter]')->form(); 331 $form = $crawler->filter('button[id=submit-filter]')->form();
330 $data = array( 332 $data = array(
331 'entry_filter[domainName]' => 'monde', 333 'entry_filter[domainName]' => 'domain',
332 ); 334 );
333 335
334 $crawler = $client->submit($form, $data); 336 $crawler = $client->submit($form, $data);
335 $this->assertCount(1, $crawler->filter('div[class=entry]')); 337 $this->assertCount(5, $crawler->filter('div[class=entry]'));
336 338
337 $form = $crawler->filter('button[id=submit-filter]')->form(); 339 $form = $crawler->filter('button[id=submit-filter]')->form();
338 $data = array( 340 $data = array(
@@ -361,7 +363,7 @@ class EntryControllerTest extends WallabagCoreTestCase
361 $form['entry_filter[isStarred]']->tick(); 363 $form['entry_filter[isStarred]']->tick();
362 364
363 $crawler = $client->submit($form); 365 $crawler = $client->submit($form);
364 $this->assertCount(2, $crawler->filter('div[class=entry]')); 366 $this->assertCount(1, $crawler->filter('div[class=entry]'));
365 } 367 }
366 368
367 public function testPreviewPictureFilter() 369 public function testPreviewPictureFilter()
@@ -389,7 +391,7 @@ class EntryControllerTest extends WallabagCoreTestCase
389 ); 391 );
390 392
391 $crawler = $client->submit($form, $data); 393 $crawler = $client->submit($form, $data);
392 $this->assertCount(3, $crawler->filter('div[class=entry]')); 394 $this->assertCount(2, $crawler->filter('div[class=entry]'));
393 395
394 $form = $crawler->filter('button[id=submit-filter]')->form(); 396 $form = $crawler->filter('button[id=submit-filter]')->form();
395 $data = array( 397 $data = array(