Testing

Test your code with PHPUnit and Mink

[Since 0.5.0]

Introduction

Pletfix comes with PHPUnit for Unit Testing and Mink for Integration Testing.

Configuration

The default test options for your application are stored in phpunit.xml.dist under the application root folder. In addition, all plugins should include a phpunit.xml.dist with test settings.

Read The Appendix C - The XML Configuration File
by the official PHPUnit Page to learn what options are available.

Don't modify this files directly because it comes with the git repository. The changes would be overwritten by the next update! Rather, you should copy phpunit.xml.dist to phpunit.xml (without ".dist") which you can edit.

phpunit.xml.dist is ignored by PHPUnit if phpunit.xml exists in the same directory.

Running Tests

Just enter this command in the terminal to run all tests you have defined:

vendor/bin/phpunit

You can enter a class as argument to run only one test case:

vendor/bin/phpunit tests/ExampleTest

Use switch -c to run the test suites that comes with a plugin (or another third party package) like below:

vendor/bin/phpunit -c ./vendor/pletfix/core

The following code shows how to run tests with the PHPUnit command-line test runner:

HPUnit 5.7.14 by Sebastian Bergmann and contributors.

..                                                                  2 / 2 (100%)

Time: 91 ms, Memory: 6.50MB

OK (2 tests, 2 assertions)

For each test run, the PHPUnit command-line tool prints one character to indicate progress:

  • . - The test succeeds.
  • F - An assertion fails while running the test method.
  • E - An error occurs while running the test method.
  • R - The test has been marked as risky.
  • S - The test has been skipped.
  • I - Test is marked as being incomplete or not yet implemented.

See https://phpunit.de/manual/5.7/en/textui.html for more information.

Code Coverage

By default the Pletfix Application Skeleton has pre-configured the unit test to generate a code coverage. The files for that are stored in storage/coverage as HTML report.

Without a route entry, these pages can not be displayed with the browser. Either you change the default, or you create a symlink anywhere under the web root but outside the application. To do this, enter the following command in the terminal:

ln -s <path-to-your-application>/storage/temp/coverage <path-to-your-web-root>/coverage

Now you can view the report with the browser by visiting this folder.

Code Coverage Report

Writing Unit Tests

Create the test class in folder tests, e.g.:

<?php

use Core\Testing\TestCase;

class ExampleTest extends TestCase
{
    /**
     * A basic functional test example.
     */
    public function testBasicExample()
    {
        $this->assertEquals(1, 1);
    }
}

Please note that the test cases have some conventions:

  • PHP files containing tests should be in your tests directory.
  • The names of these files should end in "Test.php".
  • The classes containing tests should extend Core\Testing\TestCase (for unit tests) or Core\Testing\MinkTestCase (for integration tests).
  • The name of any method containing a test should begin with "test".

Database

If you willtesting database operations, it is the easiest to use a SQLite database. The method below override the database configuration, so the SQLite database is the default which is be stored in memory.

$this->defineMemoryAsDefaultDatabase()
$db = database();

The database is created purely in memory. The database ceases to exist as soon as the database connection is closed. Every :memory: database is distinct from every other. So, opening database connections will create two independent in-memory databases.

Private and protected properties and methods

You may use the following methods if you need access to a non-public property:

$value = $this->getPrivateProperty($object, $property);

$this->setPrivateProperty($object, $property, $value);

$this->invokePrivateMethod($object, $method, $arguments);

Available Unit Test Methods

You may define test methods as you normally would using PHPUnit. See the PHPUnit Documentation for additional information.

Unit Test Method Listing

assertArrayHasKey()

Reports an error if the array does not have the key. assertArrayNotHasKey() is the inverse of this assertion.

$this->assertArrayHasKey('foo', ['bar' => 'baz']);

assertArraySubset()

Reports an error if $array does not contains the $subset.

$this->assertArraySubset(['config' => ['key-a', 'key-b']], ['config' => ['key-a']]);

assertClassHasAttribute()

Reports an error if the class attribute does not exist. assertClassNotHasAttribute() is the inverse of this assertion.

$this->assertClassHasAttribute('foo', stdClass::class);

assertClassHasStaticAttribute()

Reports an error if the class attribute does not exist. assertClassNotHasStaticAttribute() is the inverse of this assertion.

$this->assertClassHasStaticAttribute('foo', stdClass::class);

assertContains()

Reports an error if the needle is not an element of the haystack.

$this->assertContains(4, [1, 2, 3]);

assertContainsOnly()

Reports an error if the haystack does not contain only variables of the given type.

$this->assertContainsOnly('string', ['1', '2', 3]);

assertContainsOnlyInstancesOf()

Reports an error if the haystack does not contain only instances of the given class.

$this->assertContainsOnlyInstancesOf(Foo::class, [new Foo, new Bar, new Foo]);

assertCount()

Reports an error if the number of elements in the haystack is not the expected count. assertNotCount() is the inverse of this assertion.

$this->assertCount(0, ['foo']);

assertDirectoryExists()

Reports an error if the specified directory does not exist. assertDirectoryNotExists() is the inverse of this assertion.

$this->assertDirectoryExists('/path/to/directory');

assertDirectoryIsReadable()

Reports an error if the directory specified by $directory is not a directory or is not readable. assertDirectoryNotIsReadable() is the inverse of this assertion.

$this->assertDirectoryIsReadable('/path/to/directory');

assertDirectoryIsWritable()

Reports an error if the directory specified by $directory is not a directory or is not writable. assertDirectoryNotIsWritable() is the inverse of this assertion.

$this->assertDirectoryIsWritable('/path/to/directory');

assertEmpty()

Reports an error if the given value is not empty. `assertNotEmpty() is the inverse of this assertion.

$this->assertEmpty(['foo']);

assertEqualXMLStructure()

Reports an error if the XML Structure of the given DOMElement is not equal to the expected XML structure.

// failure with different node attributes

$expected = new DOMDocument;
$expected->loadXML('<foo bar="true" />');

$actual = new DOMDocument;
$actual->loadXML('<foo/>');

$this->assertEqualXMLStructure(
  $expected->firstChild, $actual->firstChild, true
);

assertEquals()

Reports an error if the two variables are not equal. assertNotEquals() is the inverse of this assertion.

$this->assertEquals('bar', 'baz');

assertFalse()

Reports an error if the condition is true. assertNotFalse() is the inverse of this assertion.

$this->assertFalse(true);

assertFileEquals()

Reports an error if the actual file does not have the same contents as the expected file. assertFileNotEquals() is the inverse of this assertion.

$this->assertFileEquals('/home/sb/expected', '/home/sb/actual');

assertFileExists()

Reports an error if the given file does not exist. assertFileNotExists() is the inverse of this assertion.

$this->assertFileExists('/path/to/file');

assertFileIsReadable()

Reports an error if the given file is not a real file or is not readable. assertFileNotIsReadable() is the inverse of this assertion.

$this->assertFileIsReadable('/path/to/file');

assertFileIsWritable()

Reports an error if the given file is not a real file or is not writable. assertFileNotIsWritable() is the inverse of this assertion.

$this->assertFileIsWritable('/path/to/file');

assertGreaterThan()

Reports an error if the actual value is not greater than the expected value.

$this->assertGreaterThan(2, 1);

assertGreaterThanOrEqual()

Reports an error if the actual value is not greater than or equal to the expected value.

$this->assertGreaterThanOrEqual(2, 1);

assertInfinite()

Reports an error if the given variable is not INF. assertFinite() is the inverse of this assertion.

$this->assertInfinite(1);

assertInstanceOf()

Reports an error if $actual is not an instance of $expected. assertNotInstanceOf() is the inverse of this assertion.

$this->assertInstanceOf(RuntimeException::class, new Exception);

assertInternalType()

Reports an error if $actual is not of the $expected type. assertNotInternalType() is the inverse of this assertion.

$this->assertInternalType('string', 42);

assertIsReadable()

Reports an error if the file or directory specified by $filename is not readable. assertNotIsReadable() is the inverse of this assertion.

$this->assertIsReadable('/path/to/unreadable');

assertIsWritable()

Reports an error if the file or directory specified by $filename is not writable. assertNotIsWritable() is the inverse of this assertion.

$this->assertIsWritable('/path/to/unwritable');

assertJsonFileEqualsJsonFile()

Reports an error if the value of $actualFile does not match the value of $expectedFile.

$this->assertJsonFileEqualsJsonFile('path/to/fixture/file', 'path/to/actual/file');

assertJsonStringEqualsJsonFile()

Reports an error if the value of $actualJson does not match the value of $expectedFile.

$this->assertJsonStringEqualsJsonFile('path/to/fixture/file', json_encode(['Mascot' => 'ux']));

assertJsonStringEqualsJsonString()

Reports an error if the value of $actualJson does not match the value of $expectedJson.

$this->assertJsonStringEqualsJsonString(
    json_encode(['Mascot' => 'Tux']),
    json_encode(['Mascot' => 'ux'])
);

assertLessThan()

Reports an error if the value of $actual is not less than the value of $expected.

$this->assertLessThan(1, 2);

assertLessThanOrEqual()

Reports an error if the value of $actual is not less than or equal to the value of $expected.

$this->assertLessThanOrEqual(1, 2);

assertNan()

Reports an error if if $variable is not NAN.

$this->assertNan(1);

assertNull()

Reports an error if $variable is not null. assertNotNull() is the inverse of this assertion.

$this->assertNull('foo');

assertObjectHasAttribute()

Reports an error if $object->attributeName does not exist. assertObjectNotHasAttribute() is the inverse of this assertion.

$this->assertObjectHasAttribute('foo', new stdClass);

assertRedirectedTo()

Reports an error if the client is not redirected to the given URL.

$this->assertRedirectedTo('https://pletfix.com');  

assertRegExp()

Reports an error if $string does not match the regular expression $pattern. assertNotRegExp() is the inverse of this assertion.

$this->assertRegExp('/foo/', 'bar');

assertSame()

Reports an error if the two variables $expected and $actual do not have the same type and value. assertNotSame() is the inverse of this assertion.

$this->assertSame('2204', 2204);

assertStringMatchesFormat()

Reports an error if the $string does not match the $format string. assertStringNotMatchesFormat() is the inverse of this assertion.

The format string (first argument) may contain the following placeholders:

  • %e: Represents a directory separator, for example / on Linux.
  • %s: One or more of anything (character or white space) except the end of line character.
  • %S: Zero or more of anything (character or white space) except the end of line character.
  • %a: One or more of anything (character or white space) including the end of line character.
  • %A: Zero or more of anything (character or white space) including the end of line character.
  • %w: Zero or more white space characters.
  • %i: A signed integer value, for example +3142, -3142.
  • %d: An unsigned integer value, for example 123456.
  • %x: One or more hexadecimal character. That is, characters in the range 0-9, a-f, A-F.
  • %f: A floating point number, for example: 3.142, -3.142, 3.142E-10, 3.142e+10.
  • %c: A single character of any sort.

    $this->assertStringMatchesFormat('%i', 'foo');

assertStringMatchesFormatFile()

Reports an error if the $string does not match the contents of the $formatFile. assertStringNotMatchesFormatFile() is the inverse of this assertion.

$this->assertStringMatchesFormatFile('/path/to/expected.txt', 'foo');

assertStringEndsWith()

Reports an error if the $string does not end with $suffix. assertStringEndsNotWith() is the inverse of this assertion.

$this->assertStringEndsWith('suffix', 'foo');

assertStringEqualsFile()

Reports an error if the file specified by $expectedFile does not have $actualString as its contents. assertStringNotEqualsFile() is the inverse of this assertion.

$this->assertStringEqualsFile('/home/sb/expected', 'actual');

assertStringStartsWith()

Reports an error if the $string does not start with $prefix. assertStringStartsNotWith() is the inverse of this assertion.

$this->assertStringStartsWith('prefix', 'foo');

assertThat()

Reports an error if the $value does not match the $constraint.

$theBiscuit = new Biscuit('Ginger');
$myBiscuit  = new Biscuit('Ginger');

$this->assertThat(
    $theBiscuit,
    $this->logicalNot(
        $this->equalTo($myBiscuit)
    )
);

See the [original PHPUnit Documentation](https://phpunit.de/manual/5.7/en/appendixes.assertions.html#appendixes.assertions.assertThat) for more details.

assertTrue()

Reports an error if the condition is false. assertNotTrue() is the inverse of this assertion.

$this->assertTrue(false);

assertXmlFileEqualsXmlFile()

Reports an error if the XML document in $actualFile is not equal to the XML document in $expectedFile. assertXmlFileNotEqualsXmlFile() is the inverse of this assertion.

$this->assertXmlFileEqualsXmlFile('/home/sb/expected.xml', '/home/sb/actual.xml');

assertXmlStringEqualsXmlFile()

Reports an error if the XML document in $actualXml is not equal to the XML document in $expectedFile. assertXmlStringNotEqualsXmlFile() is the inverse of this assertion.

$this->$this->assertXmlStringEqualsXmlFile('/home/sb/expected.xml', '<foo><baz/></foo>');

assertXmlStringEqualsXmlString()

Reports an error if the XML document in $actualXml is not equal to the XML document in $expectedXml. assertXmlStringNotEqualsXmlString() is the inverse of this assertion.

$this->$this->assertXmlStringEqualsXmlString('<foo><bar/></foo>', '<foo><baz/></foo>');

Writing Integration Tests

<?php

use Core\Testing\MinkTestCase;

class ExampleTest extends MinkTestCase
{
    /**
     * A mink test example.
     */
    public function testMinkExample()
    {
        $url = config('app.url');
        $this->session->visit($url);
        $page = $this->session->getPage();

        $title = $page->find('xpath', '//title');
        if ($title !== null) {
            $title = $title->getText();
        }

        $this->assertEquals($title, 'Pletfix Workbench');
    }    
}

Available Integration Test Methods

You may define test methods as you normally would using Mink. See the Mink Documentation for additional information.

Integration Test Method Listing

attachFile()

Attaches a file in a file input.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->attachFile($path);

attachFileToField()

Attaches file to file field with specified locator (input id, name or label).

$page = $this->session->getPage();   
$page->attachFileToField($locator, $path);

back()

Moves backward 1 page in history.

$this->session->back();

blur()

Removes focus from element.

See also focus.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->blur(); 

check()

Checks a checkbox field.

See also uncheck and isChecked.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->check();

checkField()

Checks checkbox with specified locator (input id, name or label).

See also uncheckField and hasCheckedField.

$page = $this->session->getPage();
$page->checkField($locator);  

click()

This method lets you click the links on the page.

See also clickLink, doubleClick, rightClick and press

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->click();

clickLink()

Clicks link with specified locator (link id, title, text or image alt).

See also click

$page = $this->session->getPage();  
$page->clickLink($locator);

doubleClick()

Performs a double click on the element.

See also click and rightClick.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->doubleClick();

dragTo()

Drags current node onto other node.

$page = $this->session->getPage();
$dragged = $page->find(...);
$target = $page->find(...);
$dragged->dragTo($target);

evaluateScript()

Executes JS in browser and return it's response.

$this->session->evaluateScript($script);

executeScript()

Executes JS in browser.

$this->session->executeScript($script);

fillField()

Fills in field (input, textarea, select) with specified locator (input id, name or label).

$page = $this->session->getPage();  
$page->fillField($locator, 'foo'); 

find()

Finds first element with specified selector inside the current element.

$page = $this->session->getPage();
$registerForm = $page->find('css', 'form.register');

The first argument of find is the kind of the selector. Following kinds of selectors are supported:

  • css

    $title = $page->find('css', 'h1');
    
    $buttonIcon = $page->find('css', '.btn > .icon');
  • xpath
    $anchorsWithoutUrl = $page->findAll('xpath', '//a[not(@href)]');
  • named

    $topLink = $page->find('named', array('link', $escapedValue));

    For the named selector type, the second argument of the find() method is an array with 2 elements: The name of the query to use and the value to search with this query.

    The following queries are supported by the named selector:

    • id - Searches for an element by its id.
    • id_or_name - Searches for an element by its id or name.
    • link - Searches for a link by its id, title, img alt, rel or text.
    • button - Searches for a button by its name, id, text, img alt or title.
    • link_or_button - Searches for both links and buttons.
    • content - Searches for a specific page content (text).
    • field - Searches for a form field by its id, name, label or placeholder.
    • select - Searches for a select field by its id, name or label.
    • checkbox - Searches for a checkbox by its id, name, or label.
    • radio - Searches for a radio button by its id, name, or label.
    • file - Searches for a file input by its id, name, or label.
    • optgroup - Searches for an optgroup by its label.
    • option - Searches for an option by its content or value.
    • fieldset - Searches for a fieldset by its id or legend.
    • table - Searches for a table by its id or caption.

findAll()

Finds all element with specified selector inside the current element.

The first argument of findAll is the kind of the selector, as in find.

$page = $this->session->getPage();
$registerForm = $page->findAll('css', 'form.register');

findButton()

Looks for a button with the given text, title, id, name attribute or alt attribute (for images used inside links).

See also hasButton.

$page = $this->session->getPage();
$button = $page->findButton($locator);       

findById()

Looks for a child element with the given id.

$page = $this->session->getPage();
$mainContent = $page->findById('main-content');     

findField()

Looks for a field (input, textarea or select) with the given label, placeholder, id or name attribute.

See also hasField.

$page = $this->session->getPage();
$field = $registerForm->findField($locator);    

findLink()

Looks for a link with the given text, title, id or alt attribute (for images used inside links).

See also hasLink.

$page = $this->session->getPage();
$link = $page->findLink($locator);

hasSelect()

Checks whether element has a select field with specified locator (select id, name or label).

$page = $this->session->getPage();
$hasSelect = $page->hasSelect($locator);

hasTable()

Checks whether element has a table with specified locator (table id or caption).

$page = $this->session->getPage();
$hasTable = $page->hasTable($locator);

forward()

Moves forward 1 page in history.

$this->session->forward();

focus()

Brings focus to element.

See also blur.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->focus(); 

getAttribute()

Gets the value of an attribute.

See also hasAttribute.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
if ($el->hasAttribute('href')) {
    echo $el->getAttribute('href');
} else {
    echo 'This anchor is not a link. It does not have an href.';
}

getCookie()

Returns cookie by name.

$this->session->getCookie($name);

getCurrentUrl()

Returns current URL address.

$this->session->getCurrentUrl();

getHtml()

Gets the inner HTML of the element, i.e. all children of the element.

See also getOuterHtml and getText.

$page = $this->session->getPage();
$title = $page->find('xpath', '//title');
if ($title !== null) {
    $title = $title->getHtml();
}

getOuterHtml()

Gets the outer HTML of the element, i.e. including the element itself.

See also getHtml and getText.

$page = $this->session->getPage();
$title = $page->find('xpath', '//title');
if ($title !== null) {
    $title = $title->getOuterHtml();
}

getPage()

Returns page element.

$this->session->getPage();

getResponseHeader()

Returns specific response header.

$this->session->getResponseHeader($name);

getResponseHeaders()

Returns all response headers.

$this->session->getResponseHeaders();

getScreenshot()

Capture a screenshot of the current window.

The function returns the screenshot of MIME type image/* depending on driver (e.g., image/png, image/jpeg).

$this->session->getScreenshot();

getStatusCode()

Returns response status code.

$this->session->getStatusCode();

getTagName()

This method allows you to get the tag name of the element. This tag name is always returned lowercased.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$tagName = $el->getTagName();

getText()

Returns element text (inside tag).

See also getHtml and getOuterHtml.

$page = $this->session->getPage();
$title = $page->find('xpath', '//title');
if ($title !== null) {
    $title = $title->getText();
}

getWindowName()

Return the name of the currently active window.

$this->session->getWindowName();

getWindowNames()

Return the names of all open windows.

$this->session->getWindowNames();

getValue()

Gets the value of the element.

See also setValue.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$value = $el->getValue();

has()

Checks whether a child element matches the given selector but without returning it.
The first argument of findAll is the kind of the selector, as in find.

$page = $this->session->getPage();
$registerForm = $page->has('css', 'form.register');

hasAttribute()

Checks whether the element has a given attribute.

See also getAttribute, hasClass.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
if ($el->hasAttribute('href')) {
    echo $el->getAttribute('href');
} else {
    echo 'This anchor is not a link. It does not have an href.';
}    

hasButton()

Checks whether element has a button (input[type=submit|image|button|reset], button) with specified locator (button id, value or alt).

See also findButton.

$page = $this->session->getPage(); 
$hasButton = $page->hasButton($locator);

hasCheckedField()

Checks whether element has a checkbox with specified locator (input id, name or label), which is checked.

See also hasUncheckedField, checkField and isChecked.

$page = $this->session->getPage();
$hasCheckedField = $page->hasCheckedField($locator);    

hasClass()

Checks whether the element has the given class (convenience wrapper around getAttribute('class')).

See also hasAttribute.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$hasButton = $el->hasClass('button');

hasField()

Checks whether element has a field (input, textarea, select) with specified locator (input id, name or label).

See also findField.

$page = $this->session->getPage(); 
$hasField = $page->hasField($locator);

hasLink()

Checks whether element has a link with specified locator (link id, title, text or image alt).

See also findLink.

$page = $this->session->getPage(); 
$hasLink = $page->hasLink($locator);

hasUncheckedField()

Checks whether element has a checkbox with specified locator (input id, name or label), which is unchecked. See also hasCheckedField, uncheckField and isChecked

$page = $this->session->getPage();
$hasUncheckedField = $form->hasUncheckedField($locator); 

isChecked()

Checks whether the checkbox or radio button is checked.

See also check and uncheck.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$isChecked = $el->isChecked();

isSelected()

Checks whether the <option> element is selected.

See also isVisible, isChecked and getValue.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$isSelected = $el->isSelected();                

keyDown()

Pressed down specific keyboard key. The first argument could be either char ('b') or char-code (98). The second argument is a keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta').

See also keyUp and keyPress.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->keyDown('b', 'ctrl');

keyPress()

Presses specific keyboard key. The first argument could be either char ('b') or char-code (98). The second argument is a keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta').

See also keyUp and keyDown.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->keyPress('b', 'ctrl');    

keyUp()

Pressed up specific keyboard key. The first argument could be either char ('b') or char-code (98). The second argument is a keyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta').

See also keyDown and keyPress.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->keyUp('b', 'ctrl');   

mouseOver()

Moves the mouse over the element.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->mouseOver();         

maximizeWindow()

Maximize the window if it is not maximized already.

$this->session->maximizeWindow($name)

press()

This method let you press the buttons on the page.

See also pressButton and click.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->press();

pressButton()

Presses button (input[type=submit|image|button|reset], button) with specified locator (button id, value or alt).

See also press.

$page = $this->session->getPage();    
$page->pressButton($locator);

reload()

Reloads current session page.

$this->session->reload();

resizeWindow()

Set the dimensions of the window.

$this->session->resizeWindow($width, $height, $name);

rightClick()

Performs a right click on the element.

See also click and doubleClick.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->rightClick();

mouseOver()

Moves the mouse over the element.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->mouseOver();  

selectFieldOption()

Selects option from select field with specified locator (input id, name or label).

$page = $this->session->getPage(); 
$page->selectFieldOption($locator, $value, $multiple);   

selectOption()

Selects an option in a select box or in a radio group.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->selectOption('foo');

setBasicAuth()

Sets HTTP Basic authentication parameters.

$this->session->setBasicAuth($user, $password);

setCookie()

Sets cookie.

$this->session->setCookie($name, $value);

setRequestHeader()

Sets specific request header.

$this->session->setRequestHeader($name, $value);

setValue()

Gets the value of the element.

See also getValue.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$value = $el->setValue('foo'); 

submit()

Submits the form.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->submit();

switchToIFrame()

Switches to specific iFrame.

$this->session->switchToIFrame($name);

switchToWindow()

Switches to specific browser window.

public function switchToWindow($name);

visit()

Visit specified URL:

$this->session->visit('http://my_project.dev/some_page.php');

uncheck()

Unchecks a checkbox field.

See also check and isChecked.

$page = $this->session->getPage();
$el = $page->find('css', '.something');    
$el->uncheck();

uncheckField()

Unchecks checkbox with specified locator (input id, name or label).

See also checkField and hasUncheckedField.

$page = $this->session->getPage();
$page->uncheckField($locator);     

wait()

Waits some time or until JS condition turns true.

$this->session->wait($time, $condition);      

(edit on GitHub)