Fix tests for all

This commit is contained in:
Jeremy Benoist 2015-09-28 20:26:37 +02:00
parent 159986c4fb
commit 02d17813a1
3 changed files with 14 additions and 29 deletions

View 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);

View 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
*

View 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(