diff options
Diffstat (limited to 'src/Wallabag/CoreBundle/Tests')
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/Controller/ConfigControllerTest.php | 96 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/Tests/WallabagTestCase.php | 2 |
2 files changed, 97 insertions, 1 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 | |||
3 | namespace Wallabag\CoreBundle\Tests\Controller; | ||
4 | |||
5 | use Wallabag\CoreBundle\Tests\WallabagTestCase; | ||
6 | |||
7 | class 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 | } | ||
diff --git a/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php b/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php index a80b8bac..39794545 100644 --- a/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php +++ b/src/Wallabag/CoreBundle/Tests/WallabagTestCase.php | |||
@@ -4,7 +4,7 @@ namespace Wallabag\CoreBundle\Tests; | |||
4 | 4 | ||
5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | 5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; |
6 | 6 | ||
7 | class WallabagTestCase extends WebTestCase | 7 | abstract class WallabagTestCase extends WebTestCase |
8 | { | 8 | { |
9 | private $client = null; | 9 | private $client = null; |
10 | 10 | ||