3 namespace Wallabag\CoreBundle\Tests\Controller
;
5 use Wallabag\CoreBundle\Tests\WallabagTestCase
;
7 class EntryControllerTest
extends WallabagTestCase
9 public function testLogin()
11 $client = $this->getClient();
13 $crawler = $client->request('GET', '/new');
15 $this->assertEquals(302, $client->getResponse()->getStatusCode());
16 $this->assertContains('login', $client->getResponse()->headers
->get('location'));
19 public function testGetNew()
22 $client = $this->getClient();
24 $crawler = $client->request('GET', '/new');
26 $this->assertEquals(200, $client->getResponse()->getStatusCode());
28 $this->assertCount(1, $crawler->filter('input[type=url]'));
29 $this->assertCount(1, $crawler->filter('button[type=submit]'));
32 public function testPostNewEmpty()
35 $client = $this->getClient();
37 $crawler = $client->request('GET', '/new');
39 $this->assertEquals(200, $client->getResponse()->getStatusCode());
41 $form = $crawler->filter('button[type=submit]')->form();
43 $crawler = $client->submit($form);
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]);
50 public function testPostNewOk()
53 $client = $this->getClient();
55 $crawler = $client->request('GET', '/new');
57 $this->assertEquals(200, $client->getResponse()->getStatusCode());
59 $form = $crawler->filter('button[type=submit]')->form();
62 'form[url]' => 'https://www.mailjet.com/blog/mailjet-zapier-integrations-made-easy/',
65 $client->submit($form, $data);
67 $this->assertEquals(302, $client->getResponse()->getStatusCode());
69 $crawler = $client->followRedirect();
71 $this->assertGreaterThan(1, $alert = $crawler->filter('h2 a')->extract(array('_text')));
72 $this->assertContains('Mailjet', $alert[0]);
75 public function testArchive()
78 $client = $this->getClient();
80 $crawler = $client->request('GET', '/archive');
82 $this->assertEquals(200, $client->getResponse()->getStatusCode());
85 public function testStarred()
88 $client = $this->getClient();
90 $crawler = $client->request('GET', '/starred');
92 $this->assertEquals(200, $client->getResponse()->getStatusCode());
95 public function testView()
98 $client = $this->getClient();
100 $content = $client->getContainer()
101 ->get('doctrine.orm.entity_manager')
102 ->getRepository('WallabagCoreBundle:Entry')
103 ->findOneByIsArchived(false);
106 $this->markTestSkipped('No content found in db.');
109 $crawler = $client->request('GET', '/view/'.$content->getId());
111 $this->assertEquals(200, $client->getResponse()->getStatusCode());
112 $this->assertContains($content->getTitle(), $client->getResponse()->getContent());