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

added some functional tests for the secure section of the demo bundle #590

Merged
merged 1 commit into from
Sep 8, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,32 @@ public function testIndex()

$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!")'));
}
}