Download the PHP package openbuildings/phpunit-spiderling without Composer
On this page you can find all versions of the php package openbuildings/phpunit-spiderling. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download openbuildings/phpunit-spiderling
More information about openbuildings/phpunit-spiderling
Files in openbuildings/phpunit-spiderling
Package phpunit-spiderling
Short Description Use openbuildings/spiderling in phpunit tests
License BSD-3-Clause
Informations about the package phpunit-spiderling
PHPUnit Spiderling
Heavily inspired by capybara capybara. Using the spiderling package to the fullest. It gives you the ability to quickly write integration test with powerful DSL and choose between different drivers with different combinations of features and performance - e.g. phanomjs or raw php with curl.
Example Test:
Spiderling
Spiderling has a fluid DSL that its best you get familiar with. The testcase has all the methods of Openbuildings\Spiderling\Page so you can use them directly along with some additional assertions.
The Testcase
To use phpunit spiderling you need to write your test as extends \Openbuildings\PHPUnitSpiderlingTestCase
- it will give you all of the feature as methods of the class.
Assertions
The custom assertions are:
assertHasCss($selector, array $filters = array(), $message = NULL)
assertHasNoCss($selector, array $filters = array(), $message = NULL)
assertHasField($selector, array $filters = array(), $message = NULL)
assertHasNoField($selector, array $filters = array(), $message = NULL)
assertHasXPath($selector, array $filters = array(), $message = NULL)
assertHasNoXPath($selector, array $filters = array(), $message = NULL)
assertHasLink($selector, array $filters = array(), $message = NULL)
assertHasNoLink($selector, array $filters = array(), $message = NULL)
assertHasButton($selector, array $filters = array(), $message = NULL)
assertHasNoButton($selector, array $filters = array(), $message = NULL)
All of them assert that an element is on the page (or is not) by using a specific locator type and filters. Also they are actually an extension of Openbuildings\Spiderling\Page so they are available to all the nested nodes (and are asserting only in the context of the node)
For example:
Environment
You can modify the environment only for a specific test by using the ->environment()
method. It returns a Environment Backup object, and whatever you set it to will be restored at the end of the test.
Here's an example usage:
Switching drivers
PHPUnit Spiderling uses the PHP Annotations to set up which driver to use fore each test. Heres how you do that:
You can have different drivers for each test, the available ones are: simple
, kohana
and phantomjs
- where the default driver is simple
. Each driver is loaded with the default configuration, but you can change it by modifying the appropriate method that loads the driver
- driver_simple() - will return Driver_Simple object
- driver_kohana() - will return Driver_Kohana object
- driver_phantomjs() - will return Driver_Phantomjs object
Save on failure
There is a special testcase listener class included that saves the state of the test when there is a failure, and saves it as an html page for ease referance later. This is the Saveonfailure
class. In order to use it, you'll need to modify your phpunit.xml like this:
License
Copyright (c) 2012-2013, OpenBuildings Ltd. Developed by Ivan Kerin as part of clippings.com
Under BSD-3-Clause license, read LICENSE file.
All versions of phpunit-spiderling with dependencies
openbuildings/spiderling Version ^0.4
openbuildings/environment-backup Version ^0.1
phpunit/phpunit Version ^9