]> git.immae.eu Git - github/wallabag/wallabag.git/blame - src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php
Merge pull request #1069 from wallabag/v2-fix-return-entries
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Tests / Controller / EntryControllerTest.php
CommitLineData
93fd4692
NL
1<?php
2
ad4d1caa 3namespace Wallabag\CoreBundle\Tests\Controller;
93fd4692 4
3b815d2d 5use Wallabag\CoreBundle\Tests\WallabagTestCase;
93fd4692 6
3b815d2d 7class EntryControllerTest extends WallabagTestCase
93fd4692 8{
3b815d2d
J
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
9c0c8820 19 public function testGetNew()
93fd4692 20 {
3b815d2d
J
21 $this->logIn();
22 $client = $this->getClient();
93fd4692 23
aa6e27cf 24 $crawler = $client->request('GET', '/new');
93fd4692
NL
25
26 $this->assertEquals(200, $client->getResponse()->getStatusCode());
9c0c8820
J
27
28 $this->assertCount(1, $crawler->filter('input[type=url]'));
29 $this->assertCount(1, $crawler->filter('button[type=submit]'));
30 }
31
32 public function testPostNewEmpty()
33 {
3b815d2d
J
34 $this->logIn();
35 $client = $this->getClient();
9c0c8820
J
36
37 $crawler = $client->request('GET', '/new');
38
39 $this->assertEquals(200, $client->getResponse()->getStatusCode());
40
41 $form = $crawler->filter('button[type=submit]')->form();
42
43 $crawler = $client->submit($form);
44
45 $this->assertEquals(200, $client->getResponse()->getStatusCode());
46 $this->assertCount(1, $alert = $crawler->filter('form ul li')->extract(array('_text')));
47 $this->assertEquals('This value should not be blank.', $alert[0]);
48 }
49
50 public function testPostNewOk()
51 {
3b815d2d
J
52 $this->logIn();
53 $client = $this->getClient();
9c0c8820
J
54
55 $crawler = $client->request('GET', '/new');
56
57 $this->assertEquals(200, $client->getResponse()->getStatusCode());
58
59 $form = $crawler->filter('button[type=submit]')->form();
60
61 $data = array(
62 'form[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/',
63 );
64
65 $client->submit($form, $data);
66
67 $this->assertEquals(302, $client->getResponse()->getStatusCode());
68
69 $crawler = $client->followRedirect();
70
3b815d2d 71 $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text')));
9c0c8820
J
72 $this->assertContains('Mailjet', $alert[0]);
73 }
74
75 public function testArchive()
76 {
3b815d2d
J
77 $this->logIn();
78 $client = $this->getClient();
9c0c8820
J
79
80 $crawler = $client->request('GET', '/archive');
81
82 $this->assertEquals(200, $client->getResponse()->getStatusCode());
83 }
84
85 public function testStarred()
86 {
3b815d2d
J
87 $this->logIn();
88 $client = $this->getClient();
9c0c8820
J
89
90 $crawler = $client->request('GET', '/starred');
91
92 $this->assertEquals(200, $client->getResponse()->getStatusCode());
93 }
94
95 public function testView()
96 {
3b815d2d
J
97 $this->logIn();
98 $client = $this->getClient();
9c0c8820
J
99
100 $content = $client->getContainer()
101 ->get('doctrine.orm.entity_manager')
102 ->getRepository('WallabagCoreBundle:Entry')
103 ->findOneByIsArchived(false);
104
3b815d2d
J
105 if (!$content) {
106 $this->markTestSkipped('No content found in db.');
107 }
108
9c0c8820
J
109 $crawler = $client->request('GET', '/view/'.$content->getId());
110
111 $this->assertEquals(200, $client->getResponse()->getStatusCode());
112 $this->assertContains($content->getTitle(), $client->getResponse()->getContent());
93fd4692
NL
113 }
114}