From 93fd4692f6eb753cae16358131c8049d84cfbb41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Thu, 22 Jan 2015 08:30:07 +0100 Subject: symfony is there --- .../Tests/Controller/DemoControllerTest.php | 45 ++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php (limited to 'src/Acme/DemoBundle/Tests') 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 @@ +request('GET', '/demo/hello/Fabien'); + + $this->assertGreaterThan(0, $crawler->filter('html:contains("Hello Fabien")')->count()); + } + + public function testSecureSection() + { + $client = static::createClient(); + + // goes to the secure page + $crawler = $client->request('GET', '/demo/secured/hello/World'); + + // redirects to the login page + $crawler = $client->followRedirect(); + + // submits the login form + $form = $crawler->selectButton('Login')->form(array('_username' => 'admin', '_password' => 'adminpass')); + $client->submit($form); + + // redirect to the original page (but now authenticated) + $crawler = $client->followRedirect(); + + // check that the page is the right one + $this->assertCount(1, $crawler->filter('h1.title:contains("Hello World!")')); + + // click on the secure link + $link = $crawler->selectLink('Hello resource secured')->link(); + $crawler = $client->click($link); + + // check that the page is the right one + $this->assertCount(1, $crawler->filter('h1.title:contains("secured for Admins only!")')); + } +} -- cgit v1.2.3