diff options
Diffstat (limited to 'src/Acme/DemoBundle/Tests/Controller')
-rw-r--r-- | src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php | 45 |
1 files changed, 0 insertions, 45 deletions
diff --git a/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php b/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php deleted file mode 100644 index d2176897..00000000 --- a/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php +++ /dev/null | |||
@@ -1,45 +0,0 @@ | |||
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 | } | ||