Class WebTestCase

Description

Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.

Located in /libraries/pear/simpletest/web_tester.php (line 326)

SimpleTestCase
   |
   --WebTestCase
Direct descendents
Class Description
 class LiveSitesTestCase Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveFetching Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveFrontControllerEmulation Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveHeaders Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveRedirects Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveCookies Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveForm Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveMultiValueWidgets Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveHistoryNavigation Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLiveAuthentication Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfLoadingFrames Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfFrameAuthentication Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class TestOfNestedFrames Test case for testing of web pages. Allows fetching of pages, parsing of HTML and submitting forms.
 class Delivery_TestOfClick A class for testing ck.php.
 class Delivery_TestOfLog A class for testing alg.php.
Variable Summary
 mixed $_browser
Method Summary
 WebTestCase WebTestCase ([string $label = false])
 void addHeader (string $header)
 void ageCookies (integer $interval)
 boolean assertAuthentication ([string $authentication = false], [string $message = '%s'])
 boolean assertCookie (string $name, [string $expected = false], [string $message = "%s"])
 boolean assertField (string $name, [mixed $expected = true], [string $message = "%s"])
 boolean assertFieldById (string/integer $id, [mixed $expected = true], [string $message = "%s"])
 boolean assertHeader (string $header, [string $value = false], [mixed $message = '%s'])
 boolean assertHeaderPattern (string $header, string $pattern, [mixed $message = '%s'])
 boolean assertLink (string $label, [string $message = "%s"])
 boolean assertLinkById (string $id, [string $message = "%s"])
 boolean assertMime (array $types, [string $message = '%s'])
 boolean assertNoAuthentication ([string $message = '%s'])
 boolean assertNoCookie (string $name, [string $message = "%s"])
 boolean assertNoLink (string/integer $label, [string $message = "%s"])
 boolean assertNoUnwantedHeader (string $header, [mixed $message = '%s'])
 boolean assertNoUnwantedPattern (string $pattern, [string $message = "%s"])
 boolean assertRealm (string $realm, [string $message = '%s'])
 boolean assertResponse (array $responses, [string $message = '%s'])
 boolean assertTitle ([string $title = false], [string $message = '%s'])
 boolean assertWantedPattern (string $pattern, [string $message = '%s'])
 boolean authenticate (string $username, string $password)
 boolean back ()
 void before ()
 void clearFrameFocus ()
 boolean clickImage (string $label, [integer $x = 1], [integer $y = 1])
 boolean clickImageById (integer/string $id, [integer $x = 1], [integer $y = 1])
 boolean clickImageByName (string $name, [integer $x = 1], [integer $y = 1])
 boolean clickLink (string $label, integer $index)
 boolean clickLinkById (string $id)
 boolean clickSubmit ([string $label = 'Submit'])
 boolean clickSubmitById (string $id)
 boolean clickSubmitByName (string $name)
 TestBrowser &createBrowser ()
 boolean forward ()
 boolean get (string $url, [hash $parameters = false])
 void &getBrowser (SimpleBrowser $browser)
 integer/string/boolean getFrameFocus ()
 string getTransportError ()
 string getUrl ()
 boolean head (string $url, [hash $parameters = false])
 void ignoreFrames ()
 boolean post (string $url, [hash $parameters = false])
 void restartSession ([string/integer $date = false])
 boolean retry ()
 void setConnectionTimeout (integer $timeout)
 void setCookie (string $name, string $value, [string $host = false], [string $path = "/"], [string $expiry = false])
 boolean setField (string $name, string $value)
 boolean setFieldById (string/integer $id, string $value)
 boolean setFrameFocus (string $name)
 boolean setFrameFocusByIndex (integer $choice)
 void setMaximumRedirects (integer $max)
 void showHeaders ()
 void showRequest ()
 void showSource ()
 boolean submitFormById (string $id)
 void useProxy (string $proxy, [string $username = false], [string $password = false])
Variables
mixed $_browser (line 327)

Inherited Variables

Inherited from SimpleTestCase

SimpleTestCase::$_label
SimpleTestCase::$_runner
Methods
Constructor WebTestCase (line 336)

Creates an empty test case. Should be subclassed with test methods for a functional test case.

  • access: public
WebTestCase WebTestCase ([string $label = false])
  • string $label: Name of test case. Will use the class name if none specified.
addHeader (line 470)

Adds a header to every fetch.

  • access: public
void addHeader (string $header)
  • string $header: Header line to add to every request until cleared.
ageCookies (line 407)

Moves cookie expiry times back into the past.

Useful for testing timeouts and expiries.

  • access: public
void ageCookies (integer $interval)
  • integer $interval: Amount to age in seconds.
assertAuthentication (line 924)

Attempt to match the authentication type within the security realm we are currently matching.

  • return: True if pass.
  • access: public
boolean assertAuthentication ([string $authentication = false], [string $message = '%s'])
  • string $authentication: Usually basic.
  • string $message: Message to display.
assertCookie (line 1072)

Checks that a cookie is set for the current page and optionally checks the value.

  • return: True if pass.
  • access: public
boolean assertCookie (string $name, [string $expected = false], [string $message = "%s"])
  • 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.
assertField (line 842)

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.

  • return: True if pass.
  • access: public
boolean assertField (string $name, [mixed $expected = true], [string $message = "%s"])
  • 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.
assertFieldById (line 869)

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.

  • return: True if pass.
  • access: public
boolean assertFieldById (string/integer $id, [mixed $expected = true], [string $message = "%s"])
  • 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.
assertHeader (line 977)

Checks each header line for the required value. If no value is given then only an existence check is made.

  • return: True if pass.
  • access: public
boolean assertHeader (string $header, [string $value = false], [mixed $message = '%s'])
  • string $header: Case insensitive header name.
  • string $value: Case sensitive trimmed string to match against.
assertHeaderPattern (line 991)

Checks each header line for the required pattern.

  • return: True if pass.
  • access: public
boolean assertHeaderPattern (string $header, string $pattern, [mixed $message = '%s'])
  • string $header: Case insensitive header name.
  • string $pattern: Pattern to match value against.
assertLink (line 771)

Tests for the presence of a link label. Match is case insensitive with normalised space.

  • return: True if link present.
  • access: public
boolean assertLink (string $label, [string $message = "%s"])
  • string $label: Text between the anchor tags.
  • string $message: Message to display. Default can be embedded with %s.
assertLinkById (line 801)

Tests for the presence of a link id attribute.

  • return: True if link present.
  • access: public
boolean assertLinkById (string $id, [string $message = "%s"])
  • string $id: Id attribute value.
  • string $message: Message to display. Default can be embedded with %s.
assertMime (line 908)

Checks the mime type against a list of possible values.

  • return: True if pass.
  • access: public
boolean assertMime (array $types, [string $message = '%s'])
  • array $types: Possible mime types for a pass.
  • string $message: Message to display.
assertNoAuthentication (line 947)

Checks that no authentication is necessary to view the desired page.

  • return: True if pass.
  • access: public
boolean assertNoAuthentication ([string $message = '%s'])
  • string $message: Message to display.
assertNoCookie (line 1093)

Checks that no cookie is present or that it has been successfully cleared.

  • return: True if pass.
  • access: public
boolean assertNoCookie (string $name, [string $message = "%s"])
  • string $name: Name of cookie to test.
  • string $message: Message to display.
assertNoLink (line 787)

Tests for the non-presence of a link label. Match is case insensitive with normalised space.

  • return: True if link missing.
  • access: public
boolean assertNoLink (string/integer $label, [string $message = "%s"])
  • string/integer $label: Text between the anchor tags or ID attribute.
  • string $message: Message to display. Default can be embedded with %s.
assertNoUnwantedHeader (line 1007)

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.

  • return: True if pass.
  • access: public
boolean assertNoUnwantedHeader (string $header, [mixed $message = '%s'])
  • string $header: Case insensitive header name.
assertNoUnwantedPattern (line 1055)

Will trigger a pass if the perl regex pattern is not present in raw content.

  • return: True if pass.
  • access: public
boolean assertNoUnwantedPattern (string $pattern, [string $message = "%s"])
  • string $pattern: Perl regex to look for including the regex delimiters.
  • string $message: Message to display.
assertRealm (line 960)

Attempts to match the current security realm.

  • return: True if pass.
  • access: public
boolean assertRealm (string $realm, [string $message = '%s'])
  • string $realm: Name of security realm.
  • string $message: Message to display.
assertResponse (line 892)

Checks the response code against a list of possible values.

  • return: True if pass.
  • access: public
boolean assertResponse (array $responses, [string $message = '%s'])
  • array $responses: Possible responses for a pass.
  • string $message: Message to display. Default can be embedded with %s.
assertTitle (line 1022)

Tests the text between the title tags.

  • return: True if pass.
  • access: public
boolean assertTitle ([string $title = false], [string $message = '%s'])
  • string $title: Expected title or empty if expecting no title.
  • string $message: Message to display.
assertWantedPattern (line 1039)

Will trigger a pass if the Perl regex pattern is found in the raw content.

  • return: True if pass.
  • access: public
boolean assertWantedPattern (string $pattern, [string $message = '%s'])
  • string $pattern: Perl regex to look for including the regex delimiters.
  • string $message: Message to display.
authenticate (line 601)

Retries a request after setting the authentication for the current realm.

  • return: True if successful fetch. Note that authentication may still have failed.
  • access: public
boolean authenticate (string $username, string $password)
  • string $username: Username for realm.
  • string $password: Password for realm.
back (line 576)

Equivalent to hitting the back button on the browser.

  • return: True if history entry and fetch succeeded.
  • access: public
boolean back ()
before (line 437)

Sets up a browser for the start of each test method.

  • access: public
void before ()

Redefinition of:
SimpleTestCase::before()
Runs test case specific code before the user setUp().
clearFrameFocus (line 642)

Clears the frame focus. All frames will be searched for content.

  • access: public
void clearFrameFocus ()
clickImage (line 692)

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.

  • return: True on successful submit.
  • access: public
boolean clickImage (string $label, [integer $x = 1], [integer $y = 1])
  • string $label: Alt attribute of button.
  • integer $x: X-coordinate of imaginary click.
  • integer $y: Y-coordinate of imaginary click.
clickImageById (line 723)

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.

  • return: True on successful submit.
  • access: public
boolean clickImageById (integer/string $id, [integer $x = 1], [integer $y = 1])
  • integer/string $id: ID attribute of button.
  • integer $x: X-coordinate of imaginary click.
  • integer $y: Y-coordinate of imaginary click.
clickImageByName (line 708)

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.

  • return: True on successful submit.
  • access: public
boolean clickImageByName (string $name, [integer $x = 1], [integer $y = 1])
  • string $name: Name attribute of button.
  • integer $x: X-coordinate of imaginary click.
  • integer $y: Y-coordinate of imaginary click.
clickLink (line 748)

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.

  • return: True if link present.
  • access: public
boolean clickLink (string $label, integer $index)
  • string $label: Text between the anchor tags.
  • integer $index: Link position counting from zero.
clickLinkById (line 758)

Follows a link by id attribute.

  • return: True if successful.
  • access: public
boolean clickLinkById (string $id)
  • string $id: ID attribute value.
clickSubmit (line 654)

Clicks the submit button by label. The owning form will be submitted by this.

  • return: True on success.
  • access: public
boolean clickSubmit ([string $label = 'Submit'])
  • string $label: Button label. An unlabeled button can be triggered by 'Submit'.
clickSubmitById (line 676)

Clicks the submit button by ID attribute. The owning form will be submitted by this.

  • return: True on successful submit.
  • access: public
boolean clickSubmitById (string $id)
  • string $id: ID attribute of button.
clickSubmitByName (line 665)

Clicks the submit button by name attribute. The owning form will be submitted by this.

  • return: True on success.
  • access: public
boolean clickSubmitByName (string $name)
  • string $name: Name attribute of button.
createBrowser (line 428)

Creates a new default web browser object.

Will be cleared at the end of the test method.

  • return: New browser.
  • access: public
TestBrowser &createBrowser ()
forward (line 587)

Equivalent to hitting the forward button on the browser.

  • return: True if history entry and fetch succeeded.
  • access: public
boolean forward ()
get (line 521)

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.

  • return: True on success.
  • access: public
boolean get (string $url, [hash $parameters = false])
  • string $url: URL to fetch.
  • hash $parameters: Optional additional GET data.
getBrowser (line 418)

Gets a current browser reference for setting special expectations or for detailed examination of page fetches.

  • access: public
void &getBrowser (SimpleBrowser $browser)
getFrameFocus (line 613)

Accessor for current frame focus. Will be false if no frame has focus.

  • return: Label if any, otherwise the position in the frameset or false if none.
  • access: public
integer/string/boolean getFrameFocus ()
getTransportError (line 345)

Gets the last response error.

  • return: Last low level HTTP error.
  • access: public
string getTransportError ()
getUrl (line 355)

Accessor for the currently selected URL.

  • return: Current location or false if no page yet fetched.
  • access: public
string getUrl ()
head (line 555)

Does a HTTP HEAD fetch, fetching only the page headers. The current base URL is unchanged by this.

  • return: True on success.
  • access: public
boolean head (string $url, [hash $parameters = false])
  • string $url: URL to fetch.
  • hash $parameters: Optional additional GET data.
ignoreFrames (line 447)

Disables frames support. Frames will not be fetched and the frameset page will be used instead.

  • access: public
void ignoreFrames ()
post (line 539)

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.

  • return: True on success.
  • access: public
boolean post (string $url, [hash $parameters = false])
  • string $url: URL to fetch.
  • hash $parameters: Optional additional GET data.
restartSession (line 394)

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.

  • access: public
void restartSession ([string/integer $date = false])
  • string/integer $date: Time when session restarted. If ommitted then all persistent cookies are kept. Time is either Cookie format string or timestamp.
retry (line 565)

Equivalent to hitting the retry button on the browser. Will attempt to repeat the page fetch.

  • return: True if fetch succeeded.
  • access: public
boolean retry ()
setConnectionTimeout (line 494)

Sets the socket timeout for opening a connection and receiving at least one byte of information.

  • access: public
void setConnectionTimeout (integer $timeout)
  • integer $timeout: Maximum time in seconds.
setCookie (line 460)

Sets a cookie in the current browser.

  • access: public
void setCookie (string $name, string $value, [string $host = false], [string $path = "/"], [string $expiry = false])
  • 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.
setField (line 814)

Sets all form fields with that name.

  • return: True if field exists, otherwise false.
  • access: public
boolean setField (string $name, string $value)
  • string $name: Name of field in forms.
  • string $value: New value of field.
setFieldById (line 825)

Sets all form fields with that name.

  • return: True if field exists, otherwise false.
  • access: public
boolean setFieldById (string/integer $id, string $value)
  • string/integer $id: Id of field in forms.
  • string $value: New value of field.
setFrameFocus (line 633)

Sets the focus by name.

  • return: True if frame exists.
  • access: public
boolean setFrameFocus (string $name)
  • string $name: Chosen frame.
setFrameFocusByIndex (line 623)

Sets the focus by index. The integer index starts from 1.

  • return: True if frame exists.
  • access: public
boolean setFrameFocusByIndex (integer $choice)
  • integer $choice: Chosen frame.
setMaximumRedirects (line 480)

Sets the maximum number of redirects before the web page is loaded regardless.

  • access: public
void setMaximumRedirects (integer $max)
  • integer $max: Maximum hops.
showHeaders (line 371)

Dumps the current HTTP headers for debugging.

  • access: public
void showHeaders ()
showRequest (line 363)

Dumps the current request for debugging.

  • access: public
void showRequest ()
showSource (line 379)

Dumps the current HTML source for debugging.

  • access: public
void showSource ()
submitFormById (line 734)

Submits a form by the ID.

  • return: True on success.
  • access: public
boolean submitFormById (string $id)
  • string $id: Form ID. No button information is submitted this way.
useProxy (line 507)

Sets proxy to use on all requests for when testing from behind a firewall. Set URL to false to disable.

  • access: public
void useProxy (string $proxy, [string $username = false], [string $password = false])
  • string $proxy: Proxy URL.
  • string $username: Proxy username for authentication.
  • string $password: Proxy password for authentication.

Inherited Methods

Inherited From SimpleTestCase

 SimpleTestCase::SimpleTestCase()
 SimpleTestCase::after()
 SimpleTestCase::assertExpectation()
 SimpleTestCase::assertFalse()
 SimpleTestCase::assertTrue()
 SimpleTestCase::before()
 SimpleTestCase::dump()
 SimpleTestCase::error()
 SimpleTestCase::fail()
 SimpleTestCase::getAssertionLine()
 SimpleTestCase::getLabel()
 SimpleTestCase::getSize()
 SimpleTestCase::pass()
 SimpleTestCase::run()
 SimpleTestCase::sendMessage()
 SimpleTestCase::setUp()
 SimpleTestCase::signal()
 SimpleTestCase::swallowErrors()
 SimpleTestCase::tearDown()
 SimpleTestCase::_createRunner()

Documentation generated on Fri, 11 Feb 2005 18:14:36 +0000 by phpDocumentor 1.3.0RC3