diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-30 20:09:06 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-10-02 11:08:53 +0200 |
commit | 152fcccd4489378a8ed9391e3e191df4aeba6435 (patch) | |
tree | c64685be77d9e850d5370c66fac3ffb5b12f095b /tests | |
parent | 52c1fc7449554c942c945e6c740e0e11d2f60a0d (diff) | |
download | wallabag-152fcccd4489378a8ed9391e3e191df4aeba6435.tar.gz wallabag-152fcccd4489378a8ed9391e3e191df4aeba6435.tar.zst wallabag-152fcccd4489378a8ed9391e3e191df4aeba6435.zip |
Add users management UI
- remove the “add a user” from the config page
- add a CRUD on user
- fix some missing translations (+ bad indentation)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php new file mode 100644 index 00000000..247eb6ba --- /dev/null +++ b/tests/Wallabag/UserBundle/Controller/ManageControllerTest.php | |||
@@ -0,0 +1,71 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\UserBundle\Tests\Controller; | ||
4 | |||
5 | use Tests\Wallabag\CoreBundle\WallabagCoreTestCase; | ||
6 | |||
7 | class ManageControllerTest extends WallabagCoreTestCase | ||
8 | { | ||
9 | public function testLogin() | ||
10 | { | ||
11 | $client = $this->getClient(); | ||
12 | |||
13 | $client->request('GET', '/users/'); | ||
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 user in the database | ||
25 | $crawler = $client->request('GET', '/users/'); | ||
26 | $this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /users/"); | ||
27 | $crawler = $client->click($crawler->selectLink('user.list.create_new_one')->link()); | ||
28 | |||
29 | // Fill in the form and submit it | ||
30 | $form = $crawler->selectButton('user.form.save')->form(array( | ||
31 | 'new_user[username]' => 'test_user', | ||
32 | 'new_user[email]' => 'test@test.io', | ||
33 | 'new_user[plainPassword][first]' => 'test', | ||
34 | 'new_user[plainPassword][second]' => 'test', | ||
35 | )); | ||
36 | |||
37 | $client->submit($form); | ||
38 | $client->followRedirect(); | ||
39 | $crawler = $client->request('GET', '/users/'); | ||
40 | |||
41 | // Check data in the show view | ||
42 | $this->assertGreaterThan(0, $crawler->filter('td:contains("test_user")')->count(), 'Missing element td:contains("test_user")'); | ||
43 | |||
44 | // Edit the user | ||
45 | $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); | ||
46 | |||
47 | $form = $crawler->selectButton('user.form.save')->form(array( | ||
48 | 'user[name]' => 'Foo User', | ||
49 | 'user[username]' => 'test_user', | ||
50 | 'user[email]' => 'test@test.io', | ||
51 | 'user[enabled]' => true, | ||
52 | 'user[locked]' => false, | ||
53 | )); | ||
54 | |||
55 | $client->submit($form); | ||
56 | $crawler = $client->followRedirect(); | ||
57 | |||
58 | // Check the element contains an attribute with value equals "Foo User" | ||
59 | $this->assertGreaterThan(0, $crawler->filter('[value="Foo User"]')->count(), 'Missing element [value="Foo User"]'); | ||
60 | |||
61 | $crawler = $client->request('GET', '/users/'); | ||
62 | $crawler = $client->click($crawler->selectLink('user.list.edit_action')->last()->link()); | ||
63 | |||
64 | // Delete the user | ||
65 | $client->submit($crawler->selectButton('user.form.delete')->form()); | ||
66 | $crawler = $client->followRedirect(); | ||
67 | |||
68 | // Check the user has been delete on the list | ||
69 | $this->assertNotRegExp('/Foo User/', $client->getResponse()->getContent()); | ||
70 | } | ||
71 | } | ||