Download the PHP package integratedexperts/behat-phpserver without Composer
On this page you can find all versions of the php package integratedexperts/behat-phpserver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download integratedexperts/behat-phpserver
More information about integratedexperts/behat-phpserver
Files in integratedexperts/behat-phpserver
Package behat-phpserver
Short Description Behat Context to enable PHP server for tests
License GPL-2.0-or-later
Homepage https://github.com/drevops/behat-phpserver
Informations about the package behat-phpserver
PHP and API server for Behat tests
[](https://github.com/drevops/behat-phpserver/issues)
[](https://github.com/drevops/behat-phpserver/pulls)
[](https://github.com/drevops/behat-phpserver/actions/workflows/test-php.yml)
[](https://codecov.io/gh/drevops/behat-phpserver)

[](https://packagist.org/packages/drevops/behat-phpserver)


Features
PhpServerContext
context
to start and stop PHP server:
- Automatically start and stop PHP server for each scenario.
- Serve files from a configurable document root.
- Configurable PHP server protocol, host and port.
ApiServerContext
context
to serve queued API responses for API mocking:
- A RESTful API server used to queue up expected API
responses.
- Step definition to queue up API responses.
- Automatically start and stop PHP server for each scenario.
- Serve files from a configurable document root.
- Configurable PHP server protocol, host and port.
Installation
composer require --dev drevops/behat-phpserver
Usage
PhpServerContext
PhpServerContext
context
to start and stop PHP server:
- Automatically start and stop PHP server for each scenario.
- Serve files from a configurable document root.
- Configurable PHP server protocol, host and port.
ApiServerContext
context
to serve queued API responses for API mocking:
- A RESTful API server used to queue up expected API responses.
- Step definition to queue up API responses.
- Automatically start and stop PHP server for each scenario.
- Serve files from a configurable document root.
- Configurable PHP server protocol, host and port.
composer require --dev drevops/behat-phpserver
PhpServerContext
Used to serve assets from a pre-defined document root.
ApiServerContext
Used to serve a pre-set API responses from a pre-defined document root.
API responses can be queued up in the API server server by sending
PUT
requests to /admin/responses
as an array of the expected responses
using following JSON format:
The ApiServerContext
provides several step definitions to make it easier to
work with the API server:
See this test feature for more examples.
Using File Responses
The apiWillRespondWithFile
step definition allows you to respond with the contents of a file
from one of the configured fixture paths. The context will automatically detect the appropriate
content type based on the file extension:
.json
→application/json
.xml
→application/xml
.html
,.htm
→text/html
.txt
→text/plain
- All other extensions →
application/octet-stream
Multiple fixture paths can be configured in the behat.yml
file. The context will search for the
file in each path in the order specified until it finds a match.
Resetting the API Server
The resetApi
step definition allows you to clear all queued responses and request history in the API server.
This is useful for ensuring a clean state between test steps, especially when multiple scenarios
interact with the API server:
For more information on supported RESTful API endpoints, see the API server implementation.
Accessing the API server URL from your contexts
If you need to access the API server URL from your context to update the base
URL of your API client, you can do so by using beforeScenario
in your
FeatureContext
class:
Maintenance
Lint code
Run tests
This repository was created using the Scaffold project template