]>
Commit | Line | Data |
---|---|---|
93fd4692 NL |
1 | <?php |
2 | ||
ad4d1caa | 3 | namespace Wallabag\CoreBundle\Tests\Controller; |
93fd4692 NL |
4 | |
5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | |
6 | ||
9d50517c | 7 | class EntryControllerTest extends WebTestCase |
93fd4692 | 8 | { |
9c0c8820 | 9 | public function testGetNew() |
93fd4692 NL |
10 | { |
11 | $client = static::createClient(); | |
12 | ||
aa6e27cf | 13 | $crawler = $client->request('GET', '/new'); |
93fd4692 NL |
14 | |
15 | $this->assertEquals(200, $client->getResponse()->getStatusCode()); | |
9c0c8820 J |
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()); | |
93fd4692 NL |
93 | } |
94 | } |