carlosv2 / mink-legacy-driver
Driver for Mink/Behat providing a bridge for legacy applications
Requires
- php: >=5.3
- behat/behat: ^3.3
- behat/mink: ^1.7
- behat/mink-browserkit-driver: ^1.3
- behat/mink-extension: ^2.2
- ringcentral/psr7: ^1.2
- symfony/process: ^2.8
- symfony/routing: ^2.8
Requires (Dev)
- phpspec/phpspec: ^2.5
- symfony/filesystem: ^2.8
- symfony/yaml: ^2.8
This package is not auto-updated.
Last update: 2024-12-21 21:31:23 UTC
README
This project aims to provide a bridge between Mink and legacy apps. In general terms, legacy apps are not written with the best practices in mind or they are too old to support them.
Why?
Legacy apps are hard to maintain mainly because of the lack of tests or because of very slow and painful tests. This situation produces fear to change as the side effects are unknown. In addition to this, legacy apps use to suffer from the following situations:
- No usage of composer autoload.
- Rely on PHP superglobals (like
$_GET
,$_POST
,$_SERVER
, etc). - Having many frontend controllers.
- Usage of
exit
/die
to abruptly finish the request.
Installation
Install with:
$ composer require --dev carlosv2/mink-legacy-driver
Usage
Set up your behat.yml
file as follows:
default: extensions: carlosV2\LegacyDriver\Extension: ~ Behat\MinkExtension: sessions: default: legacy: environment: <array> controller: <string|array> document_root: <string> bootstrap: <string|array>
Where:
-
environment
: Key/value array containing the environment variables. For example:environment: variable: value env: prod
-
controller
: Location of the frontend controller. For example:controller: path/to/the/controller.php
Alternatively you can supply an array of frontend controllers. For example:
controller: - path: /uri/to/match file: path/to/the/uri/to/match.php - path: /uri/to/another file: another/path/to/match.php
The controllers key configures the
symfony/routing
component underneath. As a result, you can also add themethods
andrequirements
keys. For example:controller: - path: /item/{id} file: process_item.php methods: ["GET", "PUT"] requirements: id: \d+
-
document_root
: Location of the document root. For example:document_root: path/to/the/document/root/
-
bootstrap
: Location of the bootstrap file to execute before every request. For example:bootstrap: path/to/the/bootstrap/file.php
Alternatively you can supply multiple files to be executed before every request. For example:
bootstrap: - path/to/the/bootstrap/file.php - another/path/to/bootstrap.php