diff options
author | Jeremy <jeremy.benoist@gmail.com> | 2015-02-07 18:30:46 +0100 |
---|---|---|
committer | Jeremy <jeremy.benoist@gmail.com> | 2015-02-07 18:30:46 +0100 |
commit | 9c0c88200635a979b9abdcba922e1d3904790636 (patch) | |
tree | 8d517780d2a82d68ebd06aea2da2fc4c7c67b5bb | |
parent | 94f2364cd82a7390fbeddcdc02a58222bd60fbf3 (diff) | |
download | wallabag-9c0c88200635a979b9abdcba922e1d3904790636.tar.gz wallabag-9c0c88200635a979b9abdcba922e1d3904790636.tar.zst wallabag-9c0c88200635a979b9abdcba922e1d3904790636.zip |
Add some tests on EntryController
Also, create database schema on test initialisation
-rw-r--r-- | app/build.xml | 5 | ||||
-rw-r--r-- | app/phpunit.xml.dist | 5 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/EntryControllerTest.php | 79 |
3 files changed, 86 insertions, 3 deletions
diff --git a/app/build.xml b/app/build.xml index 700a31b5..6427867c 100644 --- a/app/build.xml +++ b/app/build.xml | |||
@@ -26,6 +26,11 @@ | |||
26 | </exec> | 26 | </exec> |
27 | <exec executable="php"> | 27 | <exec executable="php"> |
28 | <arg value="${basedir}/../app/console"/> | 28 | <arg value="${basedir}/../app/console"/> |
29 | <arg value="doctrine:schema:create"/> | ||
30 | <arg value="--env=test"/> | ||
31 | </exec> | ||
32 | <exec executable="php"> | ||
33 | <arg value="${basedir}/../app/console"/> | ||
29 | <arg value="cache:clear"/> | 34 | <arg value="cache:clear"/> |
30 | <arg value="--env=test"/> | 35 | <arg value="--env=test"/> |
31 | </exec> | 36 | </exec> |
diff --git a/app/phpunit.xml.dist b/app/phpunit.xml.dist index 6593a2f0..b8f38ff8 100644 --- a/app/phpunit.xml.dist +++ b/app/phpunit.xml.dist | |||
@@ -23,8 +23,9 @@ | |||
23 | <directory>../src</directory> | 23 | <directory>../src</directory> |
24 | <exclude> | 24 | <exclude> |
25 | <directory>../vendor</directory> | 25 | <directory>../vendor</directory> |
26 | <directory>../src/Acme</directory> | 26 | <directory>../src/Wallabag/CoreBundle/Resources</directory> |
27 | <directory>../src/AppBundle</directory> | 27 | <directory>../src/Wallabag/CoreBundle/Tests</directory> |
28 | <directory>../src/Wallabag/CoreBundle/DataFixtures</directory> | ||
28 | </exclude> | 29 | </exclude> |
29 | </whitelist> | 30 | </whitelist> |
30 | </filter> | 31 | </filter> |
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 | ||
7 | class EntryControllerTest extends WebTestCase | 7 | class 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 | } |