Class FunctionalTest
Sapphire-specific testing object designed to support functional testing of your web app. It simulates get/post requests, form submission, and can validate resulting HTML, looking up content by CSS selector.
The example below shows how it works.
function testMyForm() { // Visit a URL $this->get("your/url"); // Submit a form on the page that you get in response $this->submitForm("MyForm_ID", array("Email" => "invalid email ^&*&^")); // Validate the content that is returned $this->assertExactMatchBySelector("#MyForm_ID p.error", array("That email address is invalid.")); }
- PHPUnit_Framework_TestCase
-
SapphireTest
-
FunctionalTest
Methods summary
public
|
|
public
|
|
public
|
|
public
|
|
public
|
|
public
|
#
submitForm( mixed $formID, mixed $button = null, mixed $data = array() )
Submit the form with the given HTML ID, filling it out with the given data. Acts on the most recent response |
public
|
|
public
|
#
findAttribute(
Find an attribute in a SimpleXMLElement object by name. |
public
|
|
public
boolean
|
#
assertPartialMatchBySelector( string $selector, array|string $expectedMatches )
Assert that the most recently queried page contains a number of content tags specified by a CSS selector. The given CSS 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. |
public
boolean
|
#
assertExactMatchBySelector( string $selector, array|string $expectedMatches )
Assert that the most recently queried page contains a number of content tags specified by a CSS selector. The given CSS 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. |
public
boolean
|
#
assertPartialHTMLMatchBySelector( string $selector, array|string $expectedMatches )
Assert that the most recently queried page contains a number of content tags specified by a CSS selector. The given CSS 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. |
public
boolean
|
#
assertExactHTMLMatchBySelector( string $selector, array|string $expectedMatches )
Assert that the most recently queried page contains a number of content tags specified by a CSS selector. The given CSS 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. |
public
|
|
public
|
#
useDraftSite( )
Use the draft (stage) site for testing. This is helpful if you're not testing publication functionality and don't want "stage management" cluttering your test. |
public
|
Methods inherited from SapphireTest
allFixtureIDs(),
assertDOSAllMatch(),
assertDOSContains(),
assertDOSEquals(),
assertEmailSent(),
clearEmails(),
clearFixtures(),
create_temp_db(),
delete_all_temp_dbs(),
empty_temp_db(),
findEmail(),
idFromFixture(),
is_running_test(),
kill_temp_db(),
loadFixture(),
logInWithPermission(),
objFromFixture(),
resetDBSchema(),
setUpOnce(),
tearDownOnce(),
using_temp_db()
Magic methods summary
Properties summary
public static
boolean
|
$disable_themes |
#
Set this to true on your sub-class to disable the use of themes in this test. This can be handy for functional testing of modules without having to worry about whether a user has changed behaviour by replacing the theme. |
public static
boolean
|
$use_draft_site |
#
Set this to true on your sub-class to use the draft site by default for every test in this class. |
protected
mixed
|
$mainSession | |
protected
mixed
|
$cssParser |
#
CSSContentParser for the most recently requested page. |
protected
boolean
|
$autoFollowRedirection |
#
If this is true, then 30x Location headers will be automatically followed. If not, then you will have to manaully call $this->mainSession->followRedirection() to follow them. However, this will let you inspect the intermediary headers |
Properties inherited from SapphireTest
$backupGlobals,
$cache_generatedMembers,
$extraDataObjects,
$fixtureDictionary,
$fixture_file,
$fixtures,
$illegalExtensions,
$is_running_test,
$mailer,
$originalIsRunningTest,
$originalMailer,
$originalMemberPasswordValidator,
$originalNestedURLsState,
$originalRequirements,
$originalTheme,
$requireDefaultRecordsFrom,
$requiredExtensions