diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-22 08:30:07 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-01-22 08:30:07 +0100 |
commit | 93fd4692f6eb753cae16358131c8049d84cfbb41 (patch) | |
tree | 1ef2f66eb378cf419d1aa033a2c772539e60537d /src/Acme/DemoBundle/Tests/Controller | |
parent | 0440249631164a378981d014bf71b617c082bf5a (diff) | |
download | wallabag-93fd4692f6eb753cae16358131c8049d84cfbb41.tar.gz wallabag-93fd4692f6eb753cae16358131c8049d84cfbb41.tar.zst wallabag-93fd4692f6eb753cae16358131c8049d84cfbb41.zip |
symfony is there
Diffstat (limited to 'src/Acme/DemoBundle/Tests/Controller')
-rw-r--r-- | src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php b/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php new file mode 100644 index 00000000..d2176897 --- /dev/null +++ b/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php | |||
@@ -0,0 +1,45 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Acme\DemoBundle\Tests\Controller; | ||
4 | |||
5 | use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; | ||
6 | |||
7 | class DemoControllerTest extends WebTestCase | ||
8 | { | ||
9 | public function testIndex() | ||
10 | { | ||
11 | $client = static::createClient(); | ||
12 | |||
13 | $crawler = $client->request('GET', '/demo/hello/Fabien'); | ||
14 | |||
15 | $this->assertGreaterThan(0, $crawler->filter('html:contains("Hello Fabien")')->count()); | ||
16 | } | ||
17 | |||
18 | public function testSecureSection() | ||
19 | { | ||
20 | $client = static::createClient(); | ||
21 | |||
22 | // goes to the secure page | ||
23 | $crawler = $client->request('GET', '/demo/secured/hello/World'); | ||
24 | |||
25 | // redirects to the login page | ||
26 | $crawler = $client->followRedirect(); | ||
27 | |||
28 | // submits the login form | ||
29 | $form = $crawler->selectButton('Login')->form(array('_username' => 'admin', '_password' => 'adminpass')); | ||
30 | $client->submit($form); | ||
31 | |||
32 | // redirect to the original page (but now authenticated) | ||
33 | $crawler = $client->followRedirect(); | ||
34 | |||
35 | // check that the page is the right one | ||
36 | $this->assertCount(1, $crawler->filter('h1.title:contains("Hello World!")')); | ||
37 | |||
38 | // click on the secure link | ||
39 | $link = $crawler->selectLink('Hello resource secured')->link(); | ||
40 | $crawler = $client->click($link); | ||
41 | |||
42 | // check that the page is the right one | ||
43 | $this->assertCount(1, $crawler->filter('h1.title:contains("secured for Admins only!")')); | ||
44 | } | ||
45 | } | ||