Skip to content
enygma edited this page Nov 24, 2010 · 13 revisions

###ActionClickLink Finds the link for an anchor tag and follows the link (via GET)

<?php
$this->get('/foo.php','remote-server.com')
    ->clickLink('my_link')
    ->assertContains('next page');
?>

###ActionFindHtml Looks at the response from the previously made request (body) for HTML

<?php
$this->get('/foo.php','remote-server.com')
    ->findHtml('div',array('id'=>'test')
    ->assertContains('inside found div');
?>

###ActionGet Sends a GET request to the remote script

<?php
$this->get('/foo.php','remote-server.com')
    ->assertCookieIsSet('my_cookie');
?>

You can also use an alternative syntax of you have more than just those four parameters to pass in:

<?php
$settings = array(
    'host' => 'remote-server.com',
    'location' => '/foo.php'
);
$this->get($settings)
    ->assertContains('post response');
?>

Current keys for the array are: host, location, requestData, outputFormat, followRedirects.

###ActionHttpAuth Adds the HTTP Authentication headers needed for protected pages

<?php
$this->httpAuth('test_user','test_pass')
    ->get('/foo.php','remote-server.com')
    ->assertContains('must match');
?>

###ActionPost Sends the data as a POST request to the remote script

<?php
$requestData=array('term_one'=>'test1','term_two'=>'test2');
$this->post('/foo.php','remote-server.com',$requestData)
    ->assertContains('post response');
?>

NOTE: $requestData can also be: a string of raw data to post, a SimpleXML object

An optional fourth parameter can be used to specify how to handle the return data. Currently supported values are "json" and "txt".

You can also use an alternative syntax of you have more than just those four parameters to pass in:

<?php
$settings = array(
    'host' => 'remote-server.com',
    'location' => '/foo.php',
    'requestData' => $requestData
);
$this->post($settings)
    ->assertContains('post response');
?>

Current keys for the array are: host, location, requestData, outputFormat, followRedirects.

requestData can also be used with a GET request. The values will be URL encoded and appended to the location called.

followRedirects can be set to either true or false and tells frisk whether or not to follow HTTP redirects if they're given.

###ActionSubmitForm Mimics the submission of a form on a remote site

<?php
$formData=array('field1'=>'value1');
$this->get('/foo.php','remote-server.com')
    ->submitForm($formData)
    ->assertEquals('submitted!');
?>

Note: this Action will check the remote page to ensure that the form data you've given has a matching field.