aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-08 23:05:51 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-08 23:13:40 +0100
commit3b815d2de5a852fe2ebad5827bd4c9070aa175ea (patch)
tree504e54ecfd8ae6203f76a19a910e5e6c5dee1c3e /src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
parentd91691573f108422cc2080462af35ebd62dc93fb (diff)
downloadwallabag-3b815d2de5a852fe2ebad5827bd4c9070aa175ea.tar.gz
wallabag-3b815d2de5a852fe2ebad5827bd4c9070aa175ea.tar.zst
wallabag-3b815d2de5a852fe2ebad5827bd4c9070aa175ea.zip
Add some fixtures
Improve test, so user can login Fix some leftJoin Cleanup EntryController
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index fde210c9..5d8daea3 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -2,13 +2,24 @@
2 2
3namespace Wallabag\CoreBundle\Tests\Controller; 3namespace Wallabag\CoreBundle\Tests\Controller;
4 4
5use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; 5use Wallabag\CoreBundle\Tests\WallabagTestCase;
6 6
7class EntryControllerTest extends WebTestCase 7class EntryControllerTest extends WallabagTestCase
8{ 8{
9 public function testLogin()
10 {
11 $client = $this->getClient();
12
13 $crawler = $client->request('GET', '/new');
14
15 $this->assertEquals(302, $client->getResponse()->getStatusCode());
16 $this->assertContains('login', $client->getResponse()->headers->get('location'));
17 }
18
9 public function testGetNew() 19 public function testGetNew()
10 { 20 {
11 $client = static::createClient(); 21 $this->logIn();
22 $client = $this->getClient();
12 23
13 $crawler = $client->request('GET', '/new'); 24 $crawler = $client->request('GET', '/new');
14 25
@@ -20,7 +31,8 @@ class EntryControllerTest extends WebTestCase
20 31
21 public function testPostNewEmpty() 32 public function testPostNewEmpty()
22 { 33 {
23 $client = static::createClient(); 34 $this->logIn();
35 $client = $this->getClient();
24 36
25 $crawler = $client->request('GET', '/new'); 37 $crawler = $client->request('GET', '/new');
26 38
@@ -37,7 +49,8 @@ class EntryControllerTest extends WebTestCase
37 49
38 public function testPostNewOk() 50 public function testPostNewOk()
39 { 51 {
40 $client = static::createClient(); 52 $this->logIn();
53 $client = $this->getClient();
41 54
42 $crawler = $client->request('GET', '/new'); 55 $crawler = $client->request('GET', '/new');
43 56
@@ -55,13 +68,14 @@ class EntryControllerTest extends WebTestCase
55 68
56 $crawler = $client->followRedirect(); 69 $crawler = $client->followRedirect();
57 70
58 $this->assertCount(1, $alert = $crawler->filter('h2 a')->extract(array('_text'))); 71 $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text')));
59 $this->assertContains('Mailjet', $alert[0]); 72 $this->assertContains('Mailjet', $alert[0]);
60 } 73 }
61 74
62 public function testArchive() 75 public function testArchive()
63 { 76 {
64 $client = static::createClient(); 77 $this->logIn();
78 $client = $this->getClient();
65 79
66 $crawler = $client->request('GET', '/archive'); 80 $crawler = $client->request('GET', '/archive');
67 81
@@ -70,7 +84,8 @@ class EntryControllerTest extends WebTestCase
70 84
71 public function testStarred() 85 public function testStarred()
72 { 86 {
73 $client = static::createClient(); 87 $this->logIn();
88 $client = $this->getClient();
74 89
75 $crawler = $client->request('GET', '/starred'); 90 $crawler = $client->request('GET', '/starred');
76 91
@@ -79,13 +94,18 @@ class EntryControllerTest extends WebTestCase
79 94
80 public function testView() 95 public function testView()
81 { 96 {
82 $client = static::createClient(); 97 $this->logIn();
98 $client = $this->getClient();
83 99
84 $content = $client->getContainer() 100 $content = $client->getContainer()
85 ->get('doctrine.orm.entity_manager') 101 ->get('doctrine.orm.entity_manager')
86 ->getRepository('WallabagCoreBundle:Entry') 102 ->getRepository('WallabagCoreBundle:Entry')
87 ->findOneByIsArchived(false); 103 ->findOneByIsArchived(false);
88 104
105 if (!$content) {
106 $this->markTestSkipped('No content found in db.');
107 }
108
89 $crawler = $client->request('GET', '/view/'.$content->getId()); 109 $crawler = $client->request('GET', '/view/'.$content->getId());
90 110
91 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 111 $this->assertEquals(200, $client->getResponse()->getStatusCode());