Version 3 end of life
This version of Silverstripe CMS will not recieve any additional bug fixes or documentation updates. Go to documentation for the most recent stable version.

Functional Testing

FunctionalTest test your applications Controller logic and anything else which requires a web request. The core idea of these tests is the same as SapphireTest unit tests but FunctionalTest adds several methods for creating SS_HTTPRequest, receiving SS_HTTPResponse objects and modifying the current user session.

Get

	$page = $this->get($url);
	

of the response.

Post

	$page = $this->post($url);
	

of the response.

Submit

	$submit = $this->submitForm($formID, $button = null, $data = array());

LogInAs

	$this->logInAs($member);
	$this->logInAs(null);

The FunctionalTest class also provides additional asserts to validate your tests.

assertPartialMatchBySelector

	$this->assertPartialMatchBySelector('p.good',array(
		'Test save was successful'
	));

selector will be applied to the HTML of the most recent page. The content of every matching tag will be examined. The assertion fails if one of the expectedMatches fails to appear.

assertExactMatchBySelector

	$this->assertExactMatchBySelector("#MyForm_ID p.error", array(
		"That email address is invalid."
	));

selector will be applied to the HTML of the most recent page. The full HTML of every matching tag will be examined. The assertion fails if one of the expectedMatches fails to appear.

assertPartialHTMLMatchBySelector

	$this->assertPartialHTMLMatchBySelector("#MyForm_ID p.error", array(
		"That email address is invalid."
	));

selector will be applied to the HTML of the most recent page. The content of every matching tag will be examined. The assertion fails if one of the expectedMatches fails to appear.

[notice]   characters are stripped from the content; make sure that your assertions take this into account. [/notice]

assertExactHTMLMatchBySelector

	$this->assertExactHTMLMatchBySelector("#MyForm_ID p.error", array(
		"That email address is invalid."
	));

selector will be applied to the HTML of the most recent page. The full HTML of every matching tag will be examined. The assertion fails if one of the expectedMatches fails to appear.

[notice]   characters are stripped from the content; make sure that your assertions take this into account. [/notice]

Related Documentation

API Documentation