aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/Wallabag/GroupBundle/Controller/ManageControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Wallabag/GroupBundle/Controller/ManageControllerTest.php')
-rw-r--r--tests/Wallabag/GroupBundle/Controller/ManageControllerTest.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/Wallabag/GroupBundle/Controller/ManageControllerTest.php b/tests/Wallabag/GroupBundle/Controller/ManageControllerTest.php
new file mode 100644
index 00000000..fc1852ef
--- /dev/null
+++ b/tests/Wallabag/GroupBundle/Controller/ManageControllerTest.php
@@ -0,0 +1,64 @@
1<?php
2
3namespace Wallabag\GroupBundle\Tests\Controller;
4
5use Tests\Wallabag\CoreBundle\WallabagCoreTestCase;
6
7class ManageControllerTest extends WallabagCoreTestCase
8{
9 public function testLogin()
10 {
11 $client = $this->getClient();
12
13 $client->request('GET', '/groups/');
14
15 $this->assertEquals(302, $client->getResponse()->getStatusCode());
16 $this->assertContains('login', $client->getResponse()->headers->get('location'));
17 }
18
19 public function testCompleteScenario()
20 {
21 $this->logInAs('admin');
22 $client = $this->getClient();
23
24 // Create a new group in the database
25 $crawler = $client->request('GET', '/groups/');
26 $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Unexpected HTTP status code for GET /groups/');
27 $crawler = $client->click($crawler->selectLink('group.list.create_new_one')->link());
28
29 // Fill in the form and submit it
30 $form = $crawler->selectButton('group.form.save')->form(array(
31 'new_group[name]' => 'test_group',
32 ));
33
34 $client->submit($form);
35 $client->followRedirect();
36 $crawler = $client->request('GET', '/groups/');
37
38 // Check data in the show view
39 $this->assertGreaterThan(0, $crawler->filter('td:contains("test_group")')->count(), 'Missing element td:contains("test_group")');
40
41 // Edit the group
42 $crawler = $client->click($crawler->selectLink('group.list.edit_action')->last()->link());
43
44 $form = $crawler->selectButton('group.form.save')->form(array(
45 'group[name]' => 'test_group',
46 ));
47
48 $client->submit($form);
49 $crawler = $client->followRedirect();
50
51 // Check the element contains an attribute with value equals "test_group"
52 $this->assertGreaterThan(0, $crawler->filter('[value="test_group"]')->count(), 'Missing element [value="test_group"]');
53
54 $crawler = $client->request('GET', '/groups/');
55 $crawler = $client->click($crawler->selectLink('group.list.edit_action')->last()->link());
56
57 // Delete the group
58 $client->submit($crawler->selectButton('group.form.delete')->form());
59 $crawler = $client->followRedirect();
60
61 // Check the user has been delete on the list
62 $this->assertNotRegExp('/test_group/', $client->getResponse()->getContent());
63 }
64}