]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\Tests\Controller; | |
4 | ||
5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; | |
6 | ||
7 | class EntryControllerTest extends WallabagTestCase | |
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 | ||
19 | public function testGetNew() | |
20 | { | |
21 | $this->logIn(); | |
22 | $client = $this->getClient(); | |
23 | ||
24 | $crawler = $client->request('GET', '/new'); | |
25 | ||
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
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 | { | |
34 | $this->logIn(); | |
35 | $client = $this->getClient(); | |
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 | { | |
52 | $this->logIn(); | |
53 | $client = $this->getClient(); | |
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 | ||
71 | $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text'))); | |
72 | $this->assertContains('Mailjet', $alert[0]); | |
73 | } | |
74 | ||
75 | public function testArchive() | |
76 | { | |
77 | $this->logIn(); | |
78 | $client = $this->getClient(); | |
79 | ||
80 | $crawler = $client->request('GET', '/archive'); | |
81 | ||
82 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
83 | } | |
84 | ||
85 | public function testStarred() | |
86 | { | |
87 | $this->logIn(); | |
88 | $client = $this->getClient(); | |
89 | ||
90 | $crawler = $client->request('GET', '/starred'); | |
91 | ||
92 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
93 | } | |
94 | ||
95 | public function testView() | |
96 | { | |
97 | $this->logIn(); | |
98 | $client = $this->getClient(); | |
99 | ||
100 | $content = $client->getContainer() | |
101 | ->get('doctrine.orm.entity_manager') | |
102 | ->getRepository('WallabagCoreBundle:Entry') | |
103 | ->findOneByIsArchived(false); | |
104 | ||
105 | if (!$content) { | |
106 | $this->markTestSkipped('No content found in db.'); | |
107 | } | |
108 | ||
109 | $crawler = $client->request('GET', '/view/'.$content->getId()); | |
110 | ||
111 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
112 | $this->assertContains($content->getTitle(), $client->getResponse()->getContent()); | |
113 | } | |
114 | } |