class TestSession

Represents a test usage session of a web-app It will maintain session-state from request to request

Methods

__construct()

No description

__destruct()

No description

get(string $url, Session $session = null, array $headers = null, array $cookies = null)

Submit a get request

post(string $url, array $data, array $headers = null, Session $session = null, string $body = null, array $cookies = null)

Submit a post request

submitForm(string $formID, string $button = null, array $data = array())

Submit the form with the given HTML ID, filling it out with the given data.

followRedirection()

If the last request was a 3xx response, then follow the redirection

bool
wasRedirected()

Returns true if the last response was a 3xx redirection

lastResponse()

Get the most recent response

string
lastUrl()

Return the fake HTTP_REFERER; set each time get() or post() is called.

string
lastContent()

Get the most recent response's content

cssParser()

Return a CSSContentParser containing the most recent response

SimplePage
lastPage()

Get the last response as a SimplePage object

session()

Get the current session, as a Session object

Details

at line 42
__construct()

at line 50
__destruct()

at line 68
SS_HTTPResponse get(string $url, Session $session = null, array $headers = null, array $cookies = null)

Submit a get request

Parameters

string $url
Session $session
array $headers
array $cookies

Return Value

SS_HTTPResponse

at line 97
SS_HTTPResponse post(string $url, array $data, array $headers = null, Session $session = null, string $body = null, array $cookies = null)

Submit a post request

Parameters

string $url
array $data
array $headers
Session $session
string $body
array $cookies

Return Value

SS_HTTPResponse

at line 133
SS_HTTPResponse submitForm(string $formID, string $button = null, array $data = array())

Submit the form with the given HTML ID, filling it out with the given data.

Acts on the most recent response.

Any data parameters have to be present in the form, with exact form field name and values, otherwise they are removed from the submission.

Caution: Parameter names have to be formatted as they are in the form submission, not as they are interpreted by PHP. Wrong: array('mycheckboxvalues' => array(1 => 'one', 2 => 'two')) Right: array('mycheckboxvalues[1]' => 'one', 'mycheckboxvalues[2]' => 'two')

Parameters

string $formID HTML 'id' attribute of a form (loaded through a previous response)
string $button HTML 'name' attribute of the button (NOT the 'id' attribute)
array $data Map of GET/POST data.

Return Value

SS_HTTPResponse

See also

http://www.simpletest.org/en/form_testing_documentation.html

at line 169
SS_HTTPResponse followRedirection()

If the last request was a 3xx response, then follow the redirection

Return Value

SS_HTTPResponse The response given, or null if no redirect occurred

at line 182
bool wasRedirected()

Returns true if the last response was a 3xx redirection

Return Value

bool

at line 192
SS_HTTPResponse lastResponse()

Get the most recent response

Return Value

SS_HTTPResponse

at line 201
string lastUrl()

Return the fake HTTP_REFERER; set each time get() or post() is called.

Return Value

string

at line 210
string lastContent()

Get the most recent response's content

Return Value

string

at line 220
CSSContentParser cssParser()

Return a CSSContentParser containing the most recent response

Return Value

CSSContentParser

at line 229
SimplePage lastPage()

Get the last response as a SimplePage object

Return Value

SimplePage The response if available

at line 249
Session session()

Get the current session, as a Session object

Return Value

Session