|
Moodle
2.2.1
http://www.collinsharper.com
|
Public Member Functions | |
| WebTestCase ($label=false) | |
| before ($method) | |
| after ($method) | |
| & | getBrowser () |
| setBrowser (&$browser) | |
| unsetBrowser () | |
| & | createBrowser () |
| getTransportError () | |
| getUrl () | |
| showRequest () | |
| showHeaders () | |
| showSource () | |
| showText () | |
| restart ($date=false) | |
| ageCookies ($interval) | |
| ignoreFrames () | |
| ignoreCookies () | |
| ignoreErrors () | |
| _failOnError ($result) | |
| addHeader ($header) | |
| setMaximumRedirects ($max) | |
| setConnectionTimeout ($timeout) | |
| useProxy ($proxy, $username=false, $password=false) | |
| get ($url, $parameters=false) | |
| post ($url, $parameters=false) | |
| head ($url, $parameters=false) | |
| retry () | |
| back () | |
| forward () | |
| authenticate ($username, $password) | |
| getCookie ($name) | |
| setCookie ($name, $value, $host=false, $path= '/', $expiry=false) | |
| getFrameFocus () | |
| setFrameFocusByIndex ($choice) | |
| setFrameFocus ($name) | |
| clearFrameFocus () | |
| click ($label) | |
| assertClickable ($label, $message= '%s') | |
| clickSubmit ($label= 'Submit', $additional=false) | |
| clickSubmitByName ($name, $additional=false) | |
| clickSubmitById ($id, $additional=false) | |
| assertSubmit ($label, $message= '%s') | |
| clickImage ($label, $x=1, $y=1, $additional=false) | |
| clickImageByName ($name, $x=1, $y=1, $additional=false) | |
| clickImageById ($id, $x=1, $y=1, $additional=false) | |
| assertImage ($label, $message= '%s') | |
| submitFormById ($id) | |
| clickLink ($label, $index=0) | |
| clickLinkById ($id) | |
| assertLink ($label, $expected=true, $message= '%s') | |
| assertNoLink ($label, $message= '%s') | |
| assertLinkById ($id, $expected=true, $message= '%s') | |
| assertNoLinkById ($id, $message= '%s') | |
| setField ($label, $value, $position=false) | |
| setFieldByName ($name, $value, $position=false) | |
| setFieldById ($id, $value) | |
| assertField ($label, $expected=true, $message= '%s') | |
| assertFieldByName ($name, $expected=true, $message= '%s') | |
| assertFieldById ($id, $expected=true, $message= '%s') | |
| _assertFieldValue ($identifier, $value, $expected, $message) | |
| assertResponse ($responses, $message= '%s') | |
| assertMime ($types, $message= '%s') | |
| assertAuthentication ($authentication=false, $message= '%s') | |
| assertNoAuthentication ($message= '%s') | |
| assertRealm ($realm, $message= '%s') | |
| assertHeader ($header, $value=false, $message= '%s') | |
| assertHeaderPattern ($header, $pattern, $message= '%s') | |
| assertNoHeader ($header, $message= '%s') | |
| assertNoUnwantedHeader ($header, $message= '%s') | |
| assertTitle ($title=false, $message= '%s') | |
| assertText ($text, $message= '%s') | |
| assertWantedText ($text, $message= '%s') | |
| assertNoText ($text, $message= '%s') | |
| assertNoUnwantedText ($text, $message= '%s') | |
| assertPattern ($pattern, $message= '%s') | |
| assertWantedPattern ($pattern, $message= '%s') | |
| assertNoPattern ($pattern, $message= '%s') | |
| assertNoUnwantedPattern ($pattern, $message= '%s') | |
| assertCookie ($name, $expected=false, $message= '%s') | |
| assertNoCookie ($name, $message= '%s') | |
| assertTrue ($result, $message=false) | |
| assertFalse ($result, $message= '%s') | |
| assertEqual ($first, $second, $message= '%s') | |
| assertNotEqual ($first, $second, $message= '%s') | |
| getAssertionLine () | |
Data Fields | |
| $_browser | |
| $_ignore_errors = false | |
Definition at line 433 of file web_tester.php.
| _assertFieldValue | ( | $ | identifier, |
| $ | value, | ||
| $ | expected, | ||
| $ | message | ||
| ) |
Tests the field value against the expectation.
| string | $identifier | Name, ID or label. |
| mixed | $value | Current field value. |
| mixed | $expected | Expected value to match. |
| string | $message | Failure message. |
Definition at line 1176 of file web_tester.php.


| _failOnError | ( | $ | result | ) |
Issues a fail if there is a transport error anywhere in the current frameset. Only one such error is reported.
| string/boolean | $result HTML or failure. |
Definition at line 624 of file web_tester.php.

| addHeader | ( | $ | header | ) |
Adds a header to every fetch.
| string | $header | Header line to add to every request until cleared. public |
Definition at line 640 of file web_tester.php.
| after | ( | $ | method | ) |
Announces the end of the test. Includes private clean up.
| string | $method | Test method just finished. public |
Definition at line 463 of file web_tester.php.

| ageCookies | ( | $ | interval | ) |
Moves cookie expiry times back into the past. Useful for testing timeouts and expiries.
| integer | $interval | Amount to age in seconds. public |
Definition at line 585 of file web_tester.php.
| assertAuthentication | ( | $ | authentication = false, |
| $ | message = '%s' |
||
| ) |
Attempt to match the authentication type within the security realm we are currently matching.
| string | $authentication | Usually basic. |
| string | $message | Message to display. |
Definition at line 1232 of file web_tester.php.

| assertClickable | ( | $ | label, |
| $ | message = '%s' |
||
| ) |
Checks for a click target.
| string | $label | Visible text or alt text. |
Definition at line 849 of file web_tester.php.

| assertCookie | ( | $ | name, |
| $ | expected = false, |
||
| $ | message = '%s' |
||
| ) |
Checks that a cookie is set for the current page and optionally checks the value.
| string | $name | Name of cookie to test. |
| string | $expected | Expected value as a string or false if any value will do. |
| string | $message | Message to display. |
Definition at line 1442 of file web_tester.php.

| assertEqual | ( | $ | first, |
| $ | second, | ||
| $ | message = '%s' |
||
| ) |
Will trigger a pass if the two parameters have the same value only. Otherwise a fail. This is for testing hand extracted text, etc.
| mixed | $first | Value to compare. |
| mixed | $second | Value to compare. |
| string | $message | Message to display. |
Definition at line 1506 of file web_tester.php.
| assertFalse | ( | $ | result, |
| $ | message = '%s' |
||
| ) |
Will be true on false and vice versa. False is the PHP definition of false, so that null, empty strings, zero and an empty array all count as false.
| boolean | $result | Pass on false. |
| string | $message | Message to display. |
Definition at line 1492 of file web_tester.php.

| assertField | ( | $ | label, |
| $ | expected = true, |
||
| $ | message = '%s' |
||
| ) |
Confirms that the form element is currently set to the expected value. A missing form will always fail. If no value is given then only the existence of the field is checked.
| string | $name | Name of field in forms. |
| mixed | $expected | Expected string/array value or false for unset fields. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1126 of file web_tester.php.

| assertFieldById | ( | $ | id, |
| $ | expected = true, |
||
| $ | message = '%s' |
||
| ) |
Confirms that the form element is currently set to the expected value. A missing form will always fail. If no ID is given then only the existence of the field is checked.
| string/integer | $id Name of field in forms. | |
| mixed | $expected | Expected string/array value or false for unset fields. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1162 of file web_tester.php.

| assertFieldByName | ( | $ | name, |
| $ | expected = true, |
||
| $ | message = '%s' |
||
| ) |
Confirms that the form element is currently set to the expected value. A missing form element will always fail. If no value is given then only the existence of the field is checked.
| string | $name | Name of field in forms. |
| mixed | $expected | Expected string/array value or false for unset fields. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1144 of file web_tester.php.

| assertHeader | ( | $ | header, |
| $ | value = false, |
||
| $ | message = '%s' |
||
| ) |
Checks each header line for the required value. If no value is given then only an existence check is made.
| string | $header | Case insensitive header name. |
| mixed | $value | Case sensitive trimmed string to match against. An expectation object can be used for pattern matching. |
Definition at line 1288 of file web_tester.php.
| assertHeaderPattern | ( | $ | header, |
| $ | pattern, | ||
| $ | message = '%s' |
||
| ) |
Definition at line 1298 of file web_tester.php.
| assertImage | ( | $ | label, |
| $ | message = '%s' |
||
| ) |
Checks for a valid image with atht alt text or title.
| string | $label | Visible text. |
Definition at line 966 of file web_tester.php.

| assertLink | ( | $ | label, |
| $ | expected = true, |
||
| $ | message = '%s' |
||
| ) |
Tests for the presence of a link label. Match is case insensitive with normalised space.
| string | $label | Text between the anchor tags. |
| mixed | $expected | Expected URL or expectation object. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1017 of file web_tester.php.

| assertLinkById | ( | $ | id, |
| $ | expected = true, |
||
| $ | message = '%s' |
||
| ) |
Tests for the presence of a link id attribute.
| string | $id | Id attribute value. |
| mixed | $expected | Expected URL or expectation object. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1053 of file web_tester.php.

| assertMime | ( | $ | types, |
| $ | message = '%s' |
||
| ) |
Checks the mime type against a list of possible values.
| array | $types | Possible mime types for a pass. |
| string | $message | Message to display. |
Definition at line 1216 of file web_tester.php.

| assertNoAuthentication | ( | $ | message = '%s' | ) |
Checks that no authentication is necessary to view the desired page.
| string | $message | Message to display. |
Definition at line 1255 of file web_tester.php.

| assertNoCookie | ( | $ | name, |
| $ | message = '%s' |
||
| ) |
Checks that no cookie is present or that it has been successfully cleared.
| string | $name | Name of cookie to test. |
| string | $message | Message to display. |
Definition at line 1463 of file web_tester.php.

| assertNoHeader | ( | $ | header, |
| $ | message = '%s' |
||
| ) |
Confirms that the header type has not been received. Only the landing page is checked. If you want to check redirect pages, then you should limit redirects so as to capture the page you want.
| string | $header | Case insensitive header name. |
Definition at line 1314 of file web_tester.php.

| assertNoLink | ( | $ | label, |
| $ | message = '%s' |
||
| ) |
Tests for the non-presence of a link label. Match is case insensitive with normalised space.
| string/integer | $label Text between the anchor tags or ID attribute. | |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1038 of file web_tester.php.

| assertNoLinkById | ( | $ | id, |
| $ | message = '%s' |
||
| ) |
Tests for the non-presence of a link label. Match is case insensitive with normalised space.
| string | $id | Id attribute value. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1073 of file web_tester.php.

| assertNoPattern | ( | $ | pattern, |
| $ | message = '%s' |
||
| ) |
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 1418 of file web_tester.php.

| assertNotEqual | ( | $ | first, |
| $ | second, | ||
| $ | message = '%s' |
||
| ) |
Will trigger a pass if the two parameters have a different value. Otherwise a fail. This is for testing hand extracted text, etc.
| mixed | $first | Value to compare. |
| mixed | $second | Value to compare. |
| string | $message | Message to display. |
Definition at line 1523 of file web_tester.php.
| assertNoText | ( | $ | text, |
| $ | message = '%s' |
||
| ) |
Will trigger a pass if the text is not found in the plain text form of the page.
| string | $text | Text to look for. |
| string | $message | Message to display. |
Definition at line 1372 of file web_tester.php.

| assertNoUnwantedHeader | ( | $ | header, |
| $ | message = '%s' |
||
| ) |
| assertNoUnwantedPattern | ( | $ | pattern, |
| $ | message = '%s' |
||
| ) |
| assertNoUnwantedText | ( | $ | text, |
| $ | message = '%s' |
||
| ) |
| assertPattern | ( | $ | pattern, |
| $ | message = '%s' |
||
| ) |
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 1395 of file web_tester.php.

| assertRealm | ( | $ | realm, |
| $ | message = '%s' |
||
| ) |
Attempts to match the current security realm.
| string | $realm | Name of security realm. |
| string | $message | Message to display. |
Definition at line 1268 of file web_tester.php.

| assertResponse | ( | $ | responses, |
| $ | message = '%s' |
||
| ) |
Checks the response code against a list of possible values.
| array | $responses | Possible responses for a pass. |
| string | $message | Message to display. Default can be embedded with s. |
Definition at line 1200 of file web_tester.php.

| assertSubmit | ( | $ | label, |
| $ | message = '%s' |
||
| ) |
Checks for a valid button label.
| string | $label | Visible text. |
Definition at line 901 of file web_tester.php.

| assertText | ( | $ | text, |
| $ | message = '%s' |
||
| ) |
Will trigger a pass if the text is found in the plain text form of the page.
| string | $text | Text to look for. |
| string | $message | Message to display. |
Definition at line 1350 of file web_tester.php.

| assertTitle | ( | $ | title = false, |
| $ | message = '%s' |
||
| ) |
Tests the text between the title tags.
| string/SimpleExpectation | $title Expected title. | |
| string | $message | Message to display. |
Definition at line 1335 of file web_tester.php.

| assertTrue | ( | $ | result, |
| $ | message = false |
||
| ) |
Called from within the test methods to register passes and failures.
| boolean | $result | Pass on true. |
| string | $message | Message to display describing the test state. |
Definition at line 1478 of file web_tester.php.

| assertWantedPattern | ( | $ | pattern, |
| $ | message = '%s' |
||
| ) |
| assertWantedText | ( | $ | text, |
| $ | message = '%s' |
||
| ) |
| authenticate | ( | $ | username, |
| $ | password | ||
| ) |
Retries a request after setting the authentication for the current realm.
| string | $username | Username for realm. |
| string | $password | Password for realm. |
Definition at line 763 of file web_tester.php.

| back | ( | ) |
Equivalent to hitting the back button on the browser.
Definition at line 738 of file web_tester.php.

| before | ( | $ | method | ) |
Announces the start of the test.
| string | $method | Test method just started. public |
Definition at line 453 of file web_tester.php.

| clearFrameFocus | ( | ) |
Clears the frame focus. All frames will be searched for content. public
Definition at line 828 of file web_tester.php.
| click | ( | $ | label | ) |
Clicks a visible text item. Will first try buttons, then links and then images.
| string | $label | Visible text or alt text. |
Definition at line 839 of file web_tester.php.

| clickImage | ( | $ | label, |
| $ | x = 1, |
||
| $ | y = 1, |
||
| $ | additional = false |
||
| ) |
Clicks the submit image by some kind of label. Usually the alt tag or the nearest equivalent. The owning form will be submitted by this. Clicking outside of the boundary of the coordinates will result in a failure.
| string | $label | Alt attribute of button. |
| integer | $x | X-coordinate of imaginary click. |
| integer | $y | Y-coordinate of imaginary click. |
| hash | $additional | Additional form values. |
Definition at line 920 of file web_tester.php.

| clickImageById | ( | $ | id, |
| $ | x = 1, |
||
| $ | y = 1, |
||
| $ | additional = false |
||
| ) |
Clicks the submit image by ID attribute. The owning form will be submitted by this. Clicking outside of the boundary of the coordinates will result in a failure.
| integer/string | $id ID attribute of button. | |
| integer | $x | X-coordinate of imaginary click. |
| integer | $y | Y-coordinate of imaginary click. |
| hash | $additional | Additional form values. |
Definition at line 955 of file web_tester.php.

| clickImageByName | ( | $ | name, |
| $ | x = 1, |
||
| $ | y = 1, |
||
| $ | additional = false |
||
| ) |
Clicks the submit image by the name. Usually the alt tag or the nearest equivalent. The owning form will be submitted by this. Clicking outside of the boundary of the coordinates will result in a failure.
| string | $name | Name attribute of button. |
| integer | $x | X-coordinate of imaginary click. |
| integer | $y | Y-coordinate of imaginary click. |
| hash | $additional | Additional form values. |
Definition at line 938 of file web_tester.php.

| 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 normalised space.
| string | $label | Text between the anchor tags. |
| integer | $index | Link position counting from zero. |
Definition at line 993 of file web_tester.php.

| clickLinkById | ( | $ | id | ) |
Follows a link by id attribute.
| string | $id | ID attribute value. |
Definition at line 1003 of file web_tester.php.

| clickSubmit | ( | $ | label = 'Submit', |
| $ | additional = false |
||
| ) |
Clicks the submit button by label. The owning form will be submitted by this.
| string | $label | Button label. An unlabeled button can be triggered by 'Submit'. |
| hash | $additional | Additional form values. |
Definition at line 864 of file web_tester.php.

| clickSubmitById | ( | $ | id, |
| $ | additional = false |
||
| ) |
Clicks the submit button by ID attribute. The owning form will be submitted by this.
| string | $id | ID attribute of button. |
| hash | $additional | Additional form values. |
Definition at line 890 of file web_tester.php.

| clickSubmitByName | ( | $ | name, |
| $ | additional = false |
||
| ) |
Clicks the submit button by name attribute. The owning form will be submitted by this.
| string | $name | Name attribute of button. |
| hash | $additional | Additional form values. |
Definition at line 877 of file web_tester.php.

| & createBrowser | ( | ) |
Creates a new default web browser object. Will be cleared at the end of the test method.
Definition at line 505 of file web_tester.php.

| forward | ( | ) |
Equivalent to hitting the forward button on the browser.
Definition at line 749 of file web_tester.php.

| get | ( | $ | url, |
| $ | parameters = false |
||
| ) |
Fetches a page into the page buffer. If there is no base for the URL then the current base URL is used. After the fetch the base URL reflects the new location.
| string | $url | URL to fetch. |
| hash | $parameters | Optional additional GET data. |
Definition at line 691 of file web_tester.php.

| getAssertionLine | ( | ) |
Uses a stack trace to find the line of an assertion.
Definition at line 1536 of file web_tester.php.
| & getBrowser | ( | ) |
Gets a current browser reference for setting special expectations or for detailed examination of page fetches.
Definition at line 475 of file web_tester.php.
| getCookie | ( | $ | name | ) |
Gets the cookie value for the current browser context.
| string | $name | Name of cookie. |
Definition at line 774 of file web_tester.php.

| getFrameFocus | ( | ) |
Accessor for current frame focus. Will be false if no frame has focus.
Definition at line 799 of file web_tester.php.
Gets the last response error.
Definition at line 515 of file web_tester.php.
| getUrl | ( | ) |
Accessor for the currently selected URL.
Definition at line 525 of file web_tester.php.
| head | ( | $ | url, |
| $ | parameters = false |
||
| ) |
Does a HTTP HEAD fetch, fetching only the page headers. The current base URL is unchanged by this.
| string | $url | URL to fetch. |
| hash | $parameters | Optional additional GET data. |
Definition at line 717 of file web_tester.php.

| ignoreCookies | ( | ) |
Switches off cookie sending and recieving. public
Definition at line 602 of file web_tester.php.
| ignoreErrors | ( | ) |
Skips errors for the next request only. You might want to confirm that a page is unreachable for example. public
Definition at line 612 of file web_tester.php.
| ignoreFrames | ( | ) |
Disables frames support. Frames will not be fetched and the frameset page will be used instead. public
Definition at line 594 of file web_tester.php.
| post | ( | $ | url, |
| $ | parameters = false |
||
| ) |
Fetches a page by POST into the page buffer. If there is no base for the URL then the current base URL is used. After the fetch the base URL reflects the new location.
| string | $url | URL to fetch. |
| hash | $parameters | Optional additional GET data. |
Definition at line 705 of file web_tester.php.

| restart | ( | $ | date = false | ) |
Simulates the closing and reopening of the browser. Temporary cookies will be discarded and timed cookies will be expired if later than the specified time.
| string/integer | $date Time when session restarted. If ommitted then all persistent cookies are kept. Time is either Cookie format string or timestamp. public |
Definition at line 572 of file web_tester.php.
| retry | ( | ) |
Equivalent to hitting the retry button on the browser. Will attempt to repeat the page fetch.
Definition at line 727 of file web_tester.php.

| setBrowser | ( | &$ | browser | ) |
Gets a current browser reference for setting special expectations or for detailed examination of page fetches.
| SimpleBrowser | $browser | New test browser object. public |
Definition at line 486 of file web_tester.php.

| setConnectionTimeout | ( | $ | timeout | ) |
Sets the socket timeout for opening a connection and receiving at least one byte of information.
| integer | $timeout | Maximum time in seconds. public |
Definition at line 664 of file web_tester.php.
| setCookie | ( | $ | name, |
| $ | value, | ||
| $ | host = false, |
||
| $ | path = '/', |
||
| $ | expiry = false |
||
| ) |
Sets a cookie in the current browser.
| string | $name | Name of cookie. |
| string | $value | Cookie value. |
| string | $host | Host upon which the cookie is valid. |
| string | $path | Cookie path if not host wide. |
| string | $expiry | Expiry date. public |
Definition at line 787 of file web_tester.php.
| setField | ( | $ | label, |
| $ | value, | ||
| $ | position = false |
||
| ) |
Sets all form fields with that label, or name if there is no label attached.
| string | $name | Name of field in forms. |
| string | $value | New value of field. |
Definition at line 1087 of file web_tester.php.
| setFieldById | ( | $ | id, |
| $ | value | ||
| ) |
Sets all form fields with that id.
| string/integer | $id Id of field in forms. | |
| string | $value | New value of field. |
Definition at line 1109 of file web_tester.php.
| setFieldByName | ( | $ | name, |
| $ | value, | ||
| $ | position = false |
||
| ) |
Sets all form fields with that name.
| string | $name | Name of field in forms. |
| string | $value | New value of field. |
Definition at line 1098 of file web_tester.php.
| setFrameFocus | ( | $ | name | ) |
Sets the focus by name.
| string | $name | Chosen frame. |
Definition at line 819 of file web_tester.php.
| setFrameFocusByIndex | ( | $ | choice | ) |
Sets the focus by index. The integer index starts from 1.
| integer | $choice | Chosen frame. |
Definition at line 809 of file web_tester.php.
| setMaximumRedirects | ( | $ | max | ) |
Sets the maximum number of redirects before the web page is loaded regardless.
| integer | $max | Maximum hops. public |
Definition at line 650 of file web_tester.php.
| showHeaders | ( | ) |
Dumps the current HTTP headers for debugging. public
Definition at line 541 of file web_tester.php.
| showRequest | ( | ) |
Dumps the current request for debugging. public
Definition at line 533 of file web_tester.php.
| showSource | ( | ) |
Dumps the current HTML source for debugging. public
Definition at line 549 of file web_tester.php.
| showText | ( | ) |
Dumps the visible text only for debugging. public
Definition at line 557 of file web_tester.php.
| submitFormById | ( | $ | id | ) |
Submits a form by the ID.
| string | $id | Form ID. No button information is submitted this way. |
Definition at line 979 of file web_tester.php.

| unsetBrowser | ( | ) |
Clears the current browser reference to help the PHP garbage collector. public
Definition at line 495 of file web_tester.php.

| useProxy | ( | $ | proxy, |
| $ | username = false, |
||
| $ | password = false |
||
| ) |
Sets proxy to use on all requests for when testing from behind a firewall. Set URL to false to disable.
| string | $proxy | Proxy URL. |
| string | $username | Proxy username for authentication. |
| string | $password | Proxy password for authentication. public |
Definition at line 677 of file web_tester.php.
| WebTestCase | ( | $ | label = false | ) |
Creates an empty test case. Should be subclassed with test methods for a functional test case.
| string | $label | Name of test case. Will use the class name if none specified. public |
Definition at line 444 of file web_tester.php.
| $_browser |
Definition at line 434 of file web_tester.php.
| $_ignore_errors = false |
Definition at line 435 of file web_tester.php.