https://github.com/minkphp/driver-testsuite
Functional testsuite for Mink drivers
https://github.com/minkphp/driver-testsuite
mink php testsuite
Last synced: 11 months ago
JSON representation
Functional testsuite for Mink drivers
- Host: GitHub
- URL: https://github.com/minkphp/driver-testsuite
- Owner: minkphp
- License: mit
- Created: 2016-09-27T22:30:47.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-01-13T11:18:17.000Z (about 1 year ago)
- Last Synced: 2025-03-29T15:08:28.888Z (11 months ago)
- Topics: mink, php, testsuite
- Language: PHP
- Size: 199 KB
- Stars: 8
- Watchers: 4
- Forks: 28
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Mink Driver testsuite
=====================
This is the common testsuite for Mink drivers to ensure consistency among implementations.
Usage
-----
The testsuite of a driver should be based as follow:
```json
{
"require": {
"behat/mink": "^1.9"
},
"require-dev": {
"mink/driver-testsuite": "dev-master",
"phpunit/phpunit": "^8.5.22 || ^9.5.11"
},
"autoload-dev": {
"psr-4": {
"Acme\\MyDriver\\Tests\\": "tests"
}
}
}
```
The PHPUnit config should look like this:
```xml
vendor/mink/driver-testsuite/tests
./tests/
./src
```
Then create the driver config for the testsuite:
```php
// tests/Config.php
namespace Acme\MyDriver\Tests;
use Behat\Mink\Tests\Driver\AbstractConfig;
class Config extends AbstractConfig
{
/**
* Creates an instance of the config.
*
* This is the callable registered as a php variable in the phpunit.xml config file.
* It could be outside the class but this is convenient.
*/
public static function getInstance()
{
return new self();
}
/**
* Creates driver instance.
*
* @return \Behat\Mink\Driver\DriverInterface
*/
public function createDriver()
{
return new \Acme\MyDriver\MyDriver();
}
}
```
Some other methods are available in the AbstractConfig which can be overwritten to adapt the testsuite to
the needs of the driver (skipping some tests for instance).
Running tests
-------------
Before running tests, you need to start the webserver exposing the web fixtures (unless the driver does
not perform real HTTP requests). This is done using this command:
```bash
$ vendor/bin/mink-test-server
```
To stop the server at the end of tests, cancel the command.
> Note: this command requires Bash. If you are on Windows, use either GitBash or Cygwin (or another
> equivalent tool) to launch it.
>
> This command also requires PHP 5.4+ to be able to use the builtin webserver. If the PHP version available
> in the PATH is a different one, use the `MINK_PHP_BIN` env variable to select a different PHP runtime.
You can now run tests for your driver with `vendor/bin/phpunit`.
This package installs PHPUnit as a dependency to ensure that a version of PHPUnit compatible with the testsuite is used.
Adding Driver-specific Tests
----------------------------
When adding extra test cases specific to the driver, either use your own namespace or put them in the
`Behat\Mink\Tests\Driver\Custom` subnamespace to ensure that you will not create conflicts with test cases
added in the driver testsuite in the future.
When the driver has its own tests, it is recommended to add the dev requirement on `phpunit/phpunit` to
ensure that the tests are compatible with phpunit even if driver-testsuite adds support for newer versions.