aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
diff options
context:
space:
mode:
authorJeremy <jeremy.benoist@gmail.com>2015-02-16 21:28:49 +0100
committerJeremy <jeremy.benoist@gmail.com>2015-02-16 21:31:58 +0100
commit4d85d7e9ba676bd5ac3428976ce9227f460eb542 (patch)
treeacf77c5baced69e689fcfc2d9463a9b75b9b3657 /src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
parent7a577c519ffc254b6ddecd75c9ee84f656d759e1 (diff)
downloadwallabag-4d85d7e9ba676bd5ac3428976ce9227f460eb542.tar.gz
wallabag-4d85d7e9ba676bd5ac3428976ce9227f460eb542.tar.zst
wallabag-4d85d7e9ba676bd5ac3428976ce9227f460eb542.zip
Implement simple config
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php')
-rw-r--r--src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php96
1 files changed, 96 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
new file mode 100644
index 00000000..30809a04
--- /dev/null
+++ b/src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php
@@ -0,0 +1,96 @@
1<?php
2
3namespace Wallabag\CoreBundle\Tests\Controller;
4
5use Wallabag\CoreBundle\Tests\WallabagTestCase;
6
7class ConfigControllerTest extends WallabagTestCase
8{
9 public function testLogin()
10 {
11 $client = $this->getClient();
12
13 $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 testIndex()
20 {
21 $this->logInAs('admin');
22 $client = $this->getClient();
23
24 $crawler = $client->request('GET', '/config');
25
26 $this->assertEquals(200, $client->getResponse()->getStatusCode());
27
28 $this->assertCount(1, $crawler->filter('input[type=number]'));
29 $this->assertCount(1, $crawler->filter('button[type=submit]'));
30 }
31
32 public function testUpdate()
33 {
34 $this->logInAs('admin');
35 $client = $this->getClient();
36
37 $crawler = $client->request('GET', '/config');
38
39 $this->assertEquals(200, $client->getResponse()->getStatusCode());
40
41 $form = $crawler->filter('button[type=submit]')->form();
42
43 $data = array(
44 'config[theme]' => 'baggy',
45 'config[items_per_page]' => '30',
46 'config[language]' => 'fr_FR',
47 );
48
49 $client->submit($form, $data);
50
51 $this->assertEquals(302, $client->getResponse()->getStatusCode());
52
53 $crawler = $client->followRedirect();
54
55 $this->assertGreaterThan(1, $alert = $crawler->filter('div.flash-notice')->extract(array('_text')));
56 $this->assertContains('Config saved', $alert[0]);
57 }
58
59 public function dataForUpdateFailed()
60 {
61 return array(
62 array(array(
63 'config[theme]' => 'baggy',
64 'config[items_per_page]' => '',
65 'config[language]' => 'fr_FR',
66 )),
67 array(array(
68 'config[theme]' => 'baggy',
69 'config[items_per_page]' => '12',
70 'config[language]' => '',
71 )),
72 );
73 }
74
75 /**
76 * @dataProvider dataForUpdateFailed
77 */
78 public function testUpdateFailed($data)
79 {
80 $this->logInAs('admin');
81 $client = $this->getClient();
82
83 $crawler = $client->request('GET', '/config');
84
85 $this->assertEquals(200, $client->getResponse()->getStatusCode());
86
87 $form = $crawler->filter('button[type=submit]')->form();
88
89 $crawler = $client->submit($form, $data);
90
91 $this->assertEquals(200, $client->getResponse()->getStatusCode());
92
93 $this->assertGreaterThan(1, $alert = $crawler->filter('body')->extract(array('_text')));
94 $this->assertContains('This value should not be blank', $alert[0]);
95 }
96}