Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit 60d1d0e

Browse files
committed
merged branch fabpot/more-tests (PR #590)
This PR was merged into the master branch. Discussion ---------- added some functional tests for the secure section of the demo bundle Commits ------- 8a5dd7f added some functional tests for the secure section of the demo bundle
2 parents e7b509d + 8a5dd7f commit 60d1d0e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,32 @@ public function testIndex()
1414

1515
$this->assertGreaterThan(0, $crawler->filter('html:contains("Hello Fabien")')->count());
1616
}
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+
}
1745
}

0 commit comments

Comments
 (0)