aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-07 18:30:46 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-07 18:30:46 +0100
commit9c0c88200635a979b9abdcba922e1d3904790636 (patch)
tree8d517780d2a82d68ebd06aea2da2fc4c7c67b5bb /src/Wallabag
parent94f2364cd82a7390fbeddcdc02a58222bd60fbf3 (diff)
downloadwallabag-9c0c88200635a979b9abdcba922e1d3904790636.tar.gz
wallabag-9c0c88200635a979b9abdcba922e1d3904790636.tar.zst
wallabag-9c0c88200635a979b9abdcba922e1d3904790636.zip
Add some tests on EntryController
Also, create database schema on test initialisation
Diffstat (limited to 'src/Wallabag')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php79
1 files changed, 78 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
index 786ff811..fde210c9 100644
--- a/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
+++ b/src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
@@ -6,12 +6,89 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6 6
7class EntryControllerTest extends WebTestCase 7class EntryControllerTest extends WebTestCase
8{ 8{
9 public function testIndex() 9 public function testGetNew()
10 { 10 {
11 $client = static::createClient(); 11 $client = static::createClient();
12 12
13 $crawler = $client->request('GET', '/new'); 13 $crawler = $client->request('GET', '/new');
14 14
15 $this->assertEquals(200, $client->getResponse()->getStatusCode()); 15 $this->assertEquals(200, $client->getResponse()->getStatusCode());
16
17 $this->assertCount(1, $crawler->filter('input[type=url]'));
18 $this->assertCount(1, $crawler->filter('button[type=submit]'));
19 }
20
21 public function testPostNewEmpty()
22 {
23 $client = static::createClient();
24
25 $crawler = $client->request('GET', '/new');
26
27 $this->assertEquals(200, $client->getResponse()->getStatusCode());
28
29 $form = $crawler->filter('button[type=submit]')->form();
30
31 $crawler = $client->submit($form);
32
33 $this->assertEquals(200, $client->getResponse()->getStatusCode());
34 $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text')));
35 $this->assertEquals('This value should not be blank.', $alert[0]);
36 }
37
38 public function testPostNewOk()
39 {
40 $client = static::createClient();
41
42 $crawler = $client->request('GET', '/new');
43
44 $this->assertEquals(200, $client->getResponse()->getStatusCode());
45
46 $form = $crawler->filter('button[type=submit]')->form();
47
48 $data = array(
49 'form[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/',
50 );
51
52 $client->submit($form, $data);
53
54 $this->assertEquals(302, $client->getResponse()->getStatusCode());
55
56 $crawler = $client->followRedirect();
57
58 $this->assertCount(1, $alert = $crawler->filter('h2 a')->extract(array('_text')));
59 $this->assertContains('Mailjet', $alert[0]);
60 }
61
62 public function testArchive()
63 {
64 $client = static::createClient();
65
66 $crawler = $client->request('GET', '/archive');
67
68 $this->assertEquals(200, $client->getResponse()->getStatusCode());
69 }
70
71 public function testStarred()
72 {
73 $client = static::createClient();
74
75 $crawler = $client->request('GET', '/starred');
76
77 $this->assertEquals(200, $client->getResponse()->getStatusCode());
78 }
79
80 public function testView()
81 {
82 $client = static::createClient();
83
84 $content = $client->getContainer()
85 ->get('doctrine.orm.entity_manager')
86 ->getRepository('WallabagCoreBundle:Entry')
87 ->findOneByIsArchived(false);
88
89 $crawler = $client->request('GET', '/view/'.$content->getId());
90
91 $this->assertEquals(200, $client->getResponse()->getStatusCode());
92 $this->assertContains($content->getTitle(), $client->getResponse()->getContent());
16 } 93 }
17} 94}