Assertions
Last modified: May 14, 2009 - 14:59
Assertions make up the core of any testing framework, and SimpleTest is no exception. In your test cases, you have the option of using any of a wide range of assertion types, each of which either directly or indirectly call either $this->_assert() in order to save the assertion to the database.
Here is a table of all API assertions available in the DrupalWebTestCase class. Note that all assertions accept the parameters $message and $group; these represent respectively the message to display upon passing/failing and the group to which this assertion belongs.
| Method | Description | Example usage |
|---|---|---|
<?php |
Asserts that the variable $result resolves to TRUE.
|
<?php |
<?php |
Asserts that the variable $result resolves to FALSE.
|
<?php |
<?php |
Asserts that the variable $value resolves to NULL.
|
<?php |
<?php |
Asserts that the variable $value does NOT resolves to NULL.
|
<?php |
<?php |
Asserts that the variable $first is roughly equivalent (==) to $second.
|
<?php |
<?php |
Asserts that the variable $first is not roughly equivalent (!=) to $second.
|
<?php |
<?php |
Asserts that the variable $first is absolutely identical (===) to $second.
|
<?php |
<?php |
Asserts that the variable $first is not absolutely identical (!==) to $second.
|
<?php |
<?php |
Asserts that the raw html content of the current page matches the regular expression $pattern.
|
<?php |
<?php |
Asserts that the raw html content of the current page does not match the regular expression $pattern.
|
<?php |
<?php |
Asserts that the html $raw appears in the raw html content of the current page in the SimpleTest browser.
|
<?php |
<?php |
Asserts that the html $raw does NOT appear in the raw html content of the current page in the SimpleTest browser.
|
<?php |
<?php |
Asserts that the text in $text appears in the content of the current page in the SimpleTest browser (html-stripped).
|
<?php |
<?php |
Asserts that the text in $text does NOT appear in the content of the current page in the SimpleTest browser (html-stripped).
|
<?php |
<?php |
Asserts that the title given in $title is the title of the current page in the SimpleTest browser.
|
<?php |
<?php |
Asserts that the text in $text appears exactly once in the content of the current page in the SimpleTest browser (html-stripped).
|
<?php |
<?php |
Asserts that the text in $text appears more than once in the content of the current page in the SimpleTest browser (html-stripped).
|
<?php |
<?php |
Asserts that the http response code for the current page in the simpletest browser matches $code.
|
<?php |
