Public Member Functions | |
__construct ($label=NULL) | |
drupalCreateNode ($settings=array()) | |
drupalCreateContentType ($settings=array()) | |
drupalGetTestFiles ($type, $size=NULL) | |
drupalCompareFiles ($file1, $file2) | |
randomName ($number=4, $prefix= 'simpletest_') | |
drupalModuleEnable ($name) | |
drupalModuleDisable ($name) | |
drupalCreateUser ($permissions=NULL) | |
drupalLogin ($user=NULL) | |
drupalLogout () | |
setUp () | |
refreshVariables () | |
tearDown () | |
run (&$reporter) | |
drupalGet ($path, $options=array()) | |
drupalPost ($path, $edit, $submit, $tamper=FALSE) | |
clickLink ($label, $index=0) | |
getAbsoluteUrl ($path) | |
getUrl () | |
drupalGetContent () | |
assertRaw ($raw, $message="%s", $group= 'Other') | |
assertNoRaw ($raw, $message="%s", $group= 'Other') | |
assertText ($text, $message= '', $group= 'Other') | |
assertNoText ($text, $message= '', $group= 'Other') | |
assertPattern ($pattern, $message= '%s', $group= 'Other') | |
assertNoPattern ($pattern, $message= '%s', $group= 'Other') | |
assertTitle ($title, $message, $group= 'Other') | |
assertFieldByXPath ($xpath, $value, $message, $group= 'Other') | |
assertNoFieldByXPath ($xpath, $value, $message, $group= 'Other') | |
assertFieldByName ($name, $value= '', $message= '') | |
assertNoFieldByName ($name, $value= '', $message= '') | |
assertFieldById ($id, $value= '', $message= '') | |
assertNoFieldById ($id, $value= '', $message= '') | |
assertField ($field, $message= '', $group= 'Other') | |
assertNoField ($field, $message= '', $group= 'Other') | |
_constructFieldXpath ($attribute, $value) | |
assertResponse ($code, $message= '') | |
Protected Member Functions | |
curlConnect () | |
curlExec ($curl_options) | |
curlClose () | |
parse () | |
handleForm (&$post, &$edit, &$upload, $submit, $form) | |
assertTextHelper ($text, $message, $group, $not_exists) | |
Protected Attributes | |
$_logged_in = FALSE | |
$_content | |
$plain_text | |
$ch | |
$elements | |
$_modules = array() | |
$cookie_file = NULL | |
$curl_options = array() | |
$db_prefix_original | |
$original_file_directory | |
Private Member Functions | |
_drupalCreateRole ($permissions=NULL) | |
getAllOptions (SimpleXMLElement $element) |
Definition at line 7 of file drupal_web_test_case.php.
DrupalWebTestCase::__construct | ( | $ | label = NULL |
) |
Retrieve the test information from getInfo().
string | $label Name of the test to be used by the SimpleTest library. |
Definition at line 28 of file drupal_web_test_case.php.
DrupalWebTestCase::drupalCreateNode | ( | $ | settings = array() |
) |
Creates a node based on default settings.
settings | An assocative array of settings to change from the defaults, keys are node properties, for example 'body' => 'Hello, world!'. |
Definition at line 46 of file drupal_web_test_case.php.
References db_query(), format_date(), and randomName().
DrupalWebTestCase::drupalCreateContentType | ( | $ | settings = array() |
) |
Creates a custom content type based on default settings.
settings | An array of settings to change from the defaults. Example: 'type' => 'foo'. |
Definition at line 91 of file drupal_web_test_case.php.
References $name, $type, and randomName().
DrupalWebTestCase::drupalGetTestFiles | ( | $ | type, | |
$ | size = NULL | |||
) |
Get a list files that can be used in tests.
string | $type File type, possible values: 'binary', 'html', 'image', 'javascript', 'php', 'sql', 'text'. | |
integer | $size File size in bytes to match. Please check the tests/files folder. |
Definition at line 134 of file drupal_web_test_case.php.
References $type, and file_scan_directory().
DrupalWebTestCase::drupalCompareFiles | ( | $ | file1, | |
$ | file2 | |||
) |
Compare two files based on size.
Definition at line 160 of file drupal_web_test_case.php.
DrupalWebTestCase::randomName | ( | $ | number = 4 , |
|
$ | prefix = 'simpletest_' | |||
) |
Generates a random string.
integer | $number Number of characters in length to append to the prefix. | |
string | $prefix Prefix to use. |
Definition at line 174 of file drupal_web_test_case.php.
Referenced by _drupalCreateRole(), drupalCreateContentType(), drupalCreateNode(), and drupalCreateUser().
DrupalWebTestCase::drupalModuleEnable | ( | $ | name | ) |
Enables a drupal module in the test database. Any module that is not part of the required core modules needs to be enabled in order to use it in a test.
string | $name Name of the module to enable. |
Definition at line 193 of file drupal_web_test_case.php.
References $name, UnitTestCase::assertTrue(), cache_clear_all(), drupal_execute(), drupal_rebuild_theme_registry(), menu_rebuild(), module_exists(), module_rebuild_cache(), SimpleTestCase::pass(), and t().
DrupalWebTestCase::drupalModuleDisable | ( | $ | name | ) |
Disables a drupal module in the test database.
string | $name Name of the module. |
Definition at line 218 of file drupal_web_test_case.php.
References $name, UnitTestCase::assertTrue(), cache_clear_all(), drupal_execute(), drupal_rebuild_theme_registry(), menu_rebuild(), module_exists(), module_rebuild_cache(), SimpleTestCase::pass(), and t().
DrupalWebTestCase::drupalCreateUser | ( | $ | permissions = NULL |
) |
Create a user with a given set of permissions. The permissions correspond to the names given on the privileges page.
array | $permissions Array of permission names to assign to user. |
Definition at line 244 of file drupal_web_test_case.php.
References _drupalCreateRole(), UnitTestCase::assertTrue(), randomName(), and t().
DrupalWebTestCase::_drupalCreateRole | ( | $ | permissions = NULL |
) | [private] |
Internal helper function; Create a role with specified permissions.
array | $permissions Array of permission names to assign to role. |
Definition at line 277 of file drupal_web_test_case.php.
References UnitTestCase::assertTrue(), db_fetch_object(), db_query(), db_result(), randomName(), and t().
Referenced by drupalCreateUser(), and drupalLogin().
DrupalWebTestCase::drupalLogin | ( | $ | user = NULL |
) |
Logs in a user with the internal browser. If already logged in then logs the current user out before logging in the specified user. If no user is specified then a new user will be created and logged in.
object | $user User object representing the user to login. |
Definition at line 311 of file drupal_web_test_case.php.
References _drupalCreateRole(), assertNoText(), assertText(), drupalLogout(), drupalPost(), name, and t().
DrupalWebTestCase::drupalLogout | ( | ) |
Definition at line 338 of file drupal_web_test_case.php.
References assertField(), drupalGet(), and t().
Referenced by drupalLogin().
DrupalWebTestCase::setUp | ( | ) |
Generates a random database prefix and runs the install scripts on the prefixed database. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.
... | List modules to enable. |
Reimplemented from SimpleTestCase.
Definition at line 358 of file drupal_web_test_case.php.
References $db_prefix, _drupal_flush_css_js(), actions_synchronize(), drupal_install_modules(), drupal_install_system(), drupal_map_assoc(), drupal_verify_profile(), file_check_directory(), file_directory_path(), menu_rebuild(), refreshVariables(), variable_get(), and variable_set().
DrupalWebTestCase::refreshVariables | ( | ) |
Refresh the in-memory set of variables. Useful after a page request is made that changes a variable in a different thread.
In other words calling a settings page with $this->drupalPost() with a changed value would update a variable to reflect that change, but in the thread that made the call (thread running the test) the changed variable would not be picked up.
This method clears the variables cache and loads a fresh copy from the database to ensure that the most up-to-date set of variables is loaded.
Definition at line 414 of file drupal_web_test_case.php.
References cache_clear_all(), and variable_init().
Referenced by drupalGet(), drupalPost(), and setUp().
DrupalWebTestCase::tearDown | ( | ) |
Delete created files and temporary files directory, delete the tables created by setUp(), and reset the database prefix.
Reimplemented from SimpleTestCase.
Definition at line 424 of file drupal_web_test_case.php.
References $db_prefix, $name, curlClose(), db_drop_table(), drupal_get_schema(), file_directory_path(), and variable_set().
DrupalWebTestCase::run | ( | &$ | reporter | ) |
Set necessary reporter info.
Reimplemented from SimpleTestCase.
Definition at line 453 of file drupal_web_test_case.php.
DrupalWebTestCase::curlConnect | ( | ) | [protected] |
Initializes the cURL connection and gets a session cookie.
This function will add authentaticon headers as specified in simpletest_httpauth_username and simpletest_httpauth_pass variables. Also, see the description of $curl_options among the properties.
Definition at line 470 of file drupal_web_test_case.php.
References $base_url, $curl_options, $db_prefix, curlExec(), and variable_get().
Referenced by curlExec().
DrupalWebTestCase::curlExec | ( | $ | curl_options | ) | [protected] |
Peforms a cURL exec with the specified options after calling curlConnect().
array | $curl_options Custom cURL options. |
Definition at line 499 of file drupal_web_test_case.php.
References $curl_options, $url, UnitTestCase::assertTrue(), curlConnect(), and t().
Referenced by clickLink(), curlConnect(), drupalGet(), and drupalPost().
DrupalWebTestCase::curlClose | ( | ) | [protected] |
Close the cURL handler and unset the handler.
Definition at line 513 of file drupal_web_test_case.php.
Referenced by tearDown().
DrupalWebTestCase::parse | ( | ) | [protected] |
Parse content returned from curlExec using DOM and simplexml.
Definition at line 525 of file drupal_web_test_case.php.
References UnitTestCase::assertTrue(), SimpleTestCase::fail(), getUrl(), and t().
Referenced by assertFieldByXPath(), assertNoFieldByXPath(), assertTitle(), clickLink(), and drupalPost().
DrupalWebTestCase::drupalGet | ( | $ | path, | |
$ | options = array() | |||
) |
Retrieves a Drupal path or an absolute path.
$path | string Drupal path or url to load into internal browser | |
array | $options Options to be forwarded to url(). |
Definition at line 550 of file drupal_web_test_case.php.
References curlExec(), refreshVariables(), and url().
Referenced by drupalLogout(), and drupalPost().
DrupalWebTestCase::drupalPost | ( | $ | path, | |
$ | edit, | |||
$ | submit, | |||
$ | tamper = FALSE | |||
) |
Do a post request on a drupal page. It will be done as usual post request with SimpleBrowser By $reporting you specify if this request does assertions or not Warning: empty ("") returns will cause fails with $reporting
string | $path Location of the post form. Either a Drupal path or an absolute path or NULL to post to the current page. | |
array | $edit Field data in an assocative array. Changes the current input fields (where possible) to the values indicated. A checkbox can be set to TRUE to be checked and FALSE to be unchecked. | |
string | $submit Untranslated value, id or name of the submit button. | |
$tamper | If this is set to TRUE then you can post anything, otherwise hidden and nonexistent fields are not posted. |
Definition at line 580 of file drupal_web_test_case.php.
References $name, $value, UnitTestCase::assertTrue(), curlExec(), drupalGet(), SimpleTestCase::fail(), getAbsoluteUrl(), getUrl(), handleForm(), parse(), refreshVariables(), and t().
Referenced by drupalLogin().
DrupalWebTestCase::handleForm | ( | &$ | post, | |
&$ | edit, | |||
&$ | upload, | |||
$ | submit, | |||
$ | form | |||
) | [protected] |
Handle form input related to drupalPost(). Ensure that the specified fields exist and attempt to create POST data in the correct manor for the particular field type.
array | $post Reference to array of post values. | |
array | $edit Reference to array of edit values to be checked against the form. | |
string | $submit Form submit button value. | |
array | $form Array of form elements. |
Definition at line 652 of file drupal_web_test_case.php.
References $elements, $name, $type, $value, and getAllOptions().
Referenced by drupalPost().
DrupalWebTestCase::getAllOptions | ( | SimpleXMLElement $ | element | ) | [private] |
Get all option elements, including nested options, in a select.
SimpleXMLElement | $element |
Definition at line 772 of file drupal_web_test_case.php.
Referenced by handleForm().
DrupalWebTestCase::clickLink | ( | $ | label, | |
$ | index = 0 | |||
) |
Follows a link by name.
Will click the first link found with this link text by default, or a later one if an index is given. Match is case insensitive with normalized space. The label is translated label. There is an assert for successful click. WARNING: Assertion fails on empty ("") output from the clicked link.
string | $label Text between the anchor tags. | |
integer | $index Link position counting from zero. | |
boolean | $reporting Assertions or not. |
Definition at line 800 of file drupal_web_test_case.php.
References $curl_options, UnitTestCase::assertTrue(), curlExec(), getAbsoluteUrl(), getUrl(), parse(), and t().
DrupalWebTestCase::getAbsoluteUrl | ( | $ | path | ) |
Takes a path and returns an absolute path.
@path | The path, can be a Drupal path or a site-relative path. It might have a query, too. Can even be an absolute path which is just passed through. |
Definition at line 824 of file drupal_web_test_case.php.
References base_path(), and url().
Referenced by clickLink(), and drupalPost().
DrupalWebTestCase::getUrl | ( | ) |
Get the current url from the cURL handler.
Definition at line 848 of file drupal_web_test_case.php.
Referenced by clickLink(), drupalPost(), and parse().
DrupalWebTestCase::drupalGetContent | ( | ) |
Gets the current raw HTML of requested page.
Definition at line 855 of file drupal_web_test_case.php.
Referenced by assertNoPattern(), and assertPattern().
DrupalWebTestCase::assertRaw | ( | $ | raw, | |
$ | message = "%s" , |
|||
$ | group = 'Other' | |||
) |
Pass if the raw text IS found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
string | $raw Raw string to look for. | |
string | $message Message to display. |
Definition at line 867 of file drupal_web_test_case.php.
References UnitTestCase::assertFalse().
DrupalWebTestCase::assertNoRaw | ( | $ | raw, | |
$ | message = "%s" , |
|||
$ | group = 'Other' | |||
) |
Pass if the raw text is NOT found on the loaded page, fail otherwise. Raw text refers to the raw HTML that the page generated.
string | $raw Raw string to look for. | |
string | $message Message to display. |
Definition at line 879 of file drupal_web_test_case.php.
References UnitTestCase::assertTrue().
DrupalWebTestCase::assertText | ( | $ | text, | |
$ | message = '' , |
|||
$ | group = 'Other' | |||
) |
Pass if the text IS found on the text version of the page. The text version is the equivilent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
string | $raw Text string to look for. | |
string | $message Message to display. |
Definition at line 892 of file drupal_web_test_case.php.
References assertTextHelper().
Referenced by drupalLogin().
DrupalWebTestCase::assertNoText | ( | $ | text, | |
$ | message = '' , |
|||
$ | group = 'Other' | |||
) |
Pass if the text is NOT found on the text version of the page. The text version is the equivilent of what a user would see when viewing through a web browser. In other words the HTML has been filtered out of the contents.
string | $raw Text string to look for. | |
string | $message Message to display. |
Definition at line 905 of file drupal_web_test_case.php.
References assertTextHelper().
Referenced by drupalLogin().
DrupalWebTestCase::assertTextHelper | ( | $ | text, | |
$ | message, | |||
$ | group, | |||
$ | not_exists | |||
) | [protected] |
Filter out the HTML of the page and assert that the plain text us found. Called by the plain text assertions.
string | $text Text to look for. | |
string | $message Message to display. | |
boolean | $not_exists The assert to make in relation to the text's existance. |
Definition at line 918 of file drupal_web_test_case.php.
References UnitTestCase::assertTrue().
Referenced by assertNoText(), and assertText().
DrupalWebTestCase::assertPattern | ( | $ | pattern, | |
$ | message = '%s' , |
|||
$ | group = 'Other' | |||
) |
Will trigger a pass if the Perl regex pattern is found in the raw content.
string | $pattern Perl regex to look for including the regex delimiters. | |
string | $message Message to display. |
Definition at line 935 of file drupal_web_test_case.php.
References UnitTestCase::assertTrue(), and drupalGetContent().
DrupalWebTestCase::assertNoPattern | ( | $ | pattern, | |
$ | message = '%s' , |
|||
$ | group = 'Other' | |||
) |
Will trigger a pass if the perl regex pattern is not present in raw content.
string | $pattern Perl regex to look for including the regex delimiters. | |
string | $message Message to display. |
Definition at line 946 of file drupal_web_test_case.php.
References UnitTestCase::assertFalse(), and drupalGetContent().
DrupalWebTestCase::assertTitle | ( | $ | title, | |
$ | message, | |||
$ | group = 'Other' | |||
) |
Pass if the page title is the given string.
$title | Text string to look for. | |
$message | Message to display. |
Definition at line 957 of file drupal_web_test_case.php.
References $title, UnitTestCase::assertTrue(), and parse().
DrupalWebTestCase::assertFieldByXPath | ( | $ | xpath, | |
$ | value, | |||
$ | message, | |||
$ | group = 'Other' | |||
) |
Assert that a field exists in the current page by the given XPath.
string | $xpath XPath used to find the field. | |
string | $value Value of the field to assert. | |
string | $message Message to display. |
Definition at line 969 of file drupal_web_test_case.php.
References $value, UnitTestCase::assertTrue(), and parse().
Referenced by assertField(), assertFieldById(), and assertFieldByName().
DrupalWebTestCase::assertNoFieldByXPath | ( | $ | xpath, | |
$ | value, | |||
$ | message, | |||
$ | group = 'Other' | |||
) |
Assert that a field does not exists in the current page by the given XPath.
string | $xpath XPath used to find the field. | |
string | $value Value of the field to assert. | |
string | $message Message to display. |
Definition at line 996 of file drupal_web_test_case.php.
References $value, UnitTestCase::assertFalse(), and parse().
Referenced by assertNoField(), assertNoFieldById(), and assertNoFieldByName().
DrupalWebTestCase::assertFieldByName | ( | $ | name, | |
$ | value = '' , |
|||
$ | message = '' | |||
) |
Assert that a field exists in the current page with the given name and value.
string | $name Name of field to assert. | |
string | $value Value of the field to assert. | |
string | $message Message to display. |
Definition at line 1023 of file drupal_web_test_case.php.
References $name, $value, _constructFieldXpath(), assertFieldByXPath(), and t().
DrupalWebTestCase::assertNoFieldByName | ( | $ | name, | |
$ | value = '' , |
|||
$ | message = '' | |||
) |
Assert that a field does not exists in the current page with the given name and value.
string | $name Name of field to assert. | |
string | $value Value of the field to assert. | |
string | $message Message to display. |
Definition at line 1035 of file drupal_web_test_case.php.
References $name, $value, _constructFieldXpath(), assertNoFieldByXPath(), and t().
DrupalWebTestCase::assertFieldById | ( | $ | id, | |
$ | value = '' , |
|||
$ | message = '' | |||
) |
Assert that a field exists in the current page with the given id and value.
string | $id Id of field to assert. | |
string | $value Value of the field to assert. | |
string | $message Message to display. |
Definition at line 1047 of file drupal_web_test_case.php.
References $value, _constructFieldXpath(), assertFieldByXPath(), and t().
DrupalWebTestCase::assertNoFieldById | ( | $ | id, | |
$ | value = '' , |
|||
$ | message = '' | |||
) |
Assert that a field does not exists in the current page with the given id and value.
string | $id Id of field to assert. | |
string | $value Value of the field to assert. | |
string | $message Message to display. |
Definition at line 1059 of file drupal_web_test_case.php.
References $value, _constructFieldXpath(), assertNoFieldByXPath(), and t().
DrupalWebTestCase::assertField | ( | $ | field, | |
$ | message = '' , |
|||
$ | group = 'Other' | |||
) |
Assert that a field exists in the current page with the given name or id.
string | $field Name or id of the field. | |
string | $message Message to display. |
Definition at line 1070 of file drupal_web_test_case.php.
References _constructFieldXpath(), and assertFieldByXPath().
Referenced by drupalLogout().
DrupalWebTestCase::assertNoField | ( | $ | field, | |
$ | message = '' , |
|||
$ | group = 'Other' | |||
) |
Assert that a field does not exists in the current page with the given name or id.
string | $field Name or id of the field. | |
string | $message Message to display. |
Definition at line 1081 of file drupal_web_test_case.php.
References _constructFieldXpath(), and assertNoFieldByXPath().
DrupalWebTestCase::_constructFieldXpath | ( | $ | attribute, | |
$ | value | |||
) |
Construct an XPath for the given set of attributes and value.
array | $attribute Field attributes. | |
string | $value Value of field. |
Definition at line 1092 of file drupal_web_test_case.php.
References $value.
Referenced by assertField(), assertFieldById(), assertFieldByName(), assertNoField(), assertNoFieldById(), and assertNoFieldByName().
DrupalWebTestCase::assertResponse | ( | $ | code, | |
$ | message = '' | |||
) |
Assert the page responds with the specified response code.
integer | $code Reponse code. For example 200 is a successful page request. For a list of all codes see | |
string | $message Message to display. |
Definition at line 1104 of file drupal_web_test_case.php.
References UnitTestCase::assertTrue(), and t().
DrupalWebTestCase::$_logged_in = FALSE [protected] |
Definition at line 8 of file drupal_web_test_case.php.
DrupalWebTestCase::$_content [protected] |
Definition at line 9 of file drupal_web_test_case.php.
DrupalWebTestCase::$plain_text [protected] |
Definition at line 10 of file drupal_web_test_case.php.
DrupalWebTestCase::$ch [protected] |
Definition at line 11 of file drupal_web_test_case.php.
DrupalWebTestCase::$elements [protected] |
DrupalWebTestCase::$_modules = array() [protected] |
Definition at line 13 of file drupal_web_test_case.php.
DrupalWebTestCase::$cookie_file = NULL [protected] |
Definition at line 16 of file drupal_web_test_case.php.
DrupalWebTestCase::$curl_options = array() [protected] |
Definition at line 19 of file drupal_web_test_case.php.
Referenced by clickLink(), curlConnect(), and curlExec().
DrupalWebTestCase::$db_prefix_original [protected] |
Definition at line 20 of file drupal_web_test_case.php.
DrupalWebTestCase::$original_file_directory [protected] |
Definition at line 21 of file drupal_web_test_case.php.