Download the PHP package auto1-oss/php-behat-context-wiremock without Composer

On this page you can find all versions of the php package auto1-oss/php-behat-context-wiremock. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-behat-context-wiremock

php-behat-context-wiremock

This package provides a seamless integration between Behat tests and Wiremock, offering a straightforward method for mocking HTTP requests. It acts as a conduit between Behat scenarios and a Wiremock instance, enabling the creation of HTTP request expectations and mock responses without sacrificing Wiremock's inherent flexibility.

Configuration Example

Below is an example of how to configure the Wiremock context within your Behat setup:

Docker Integration

For those running Behat within Docker, integrating a Wiremock container is straightforward. The following configuration ensures that your tests wait for Wiremock to be fully initialized before running:

Context Steps

Defining Wiremock Stubs

Managing Wiremock State

Validating Stubs

Placeholder Processors

The package includes a powerful placeholder processing system that allows you to dynamically transform content when loading Wiremock stubs. This feature enables you to process data (from external files or generated dynamically) and inject the transformed content directly into your stub definitions.

How Placeholder Processors Work

Placeholder processors use a special syntax within your stub files to reference external content and apply transformations:

The processor system automatically:

  1. Parses the placeholder syntax from your stub files
  2. Loads the referenced external files (if applicable)
  3. Applies the specified transformation
  4. Replaces the placeholder with the processed content

It's important to note that processors are not limited to just retrieving content from files. They can perform any type of manipulation and generate any content that will be injected into the stub. While the built-in processors work with files, custom processors can generate content dynamically without necessarily relying on external files as input.

The system also provides error handling for general processor operations:

Configuration

To use placeholder processors, you need to configure them in your Behat context. WiremockContext expects to receive an array of processor instances:

Note that the @ symbol indicates that these are service references. WiremockContext will receive the actual processor instances from your dependency injection container.

Built-in Processors

FlattenTextProcessor

Name: flatten_text

Purpose: Flattens text by replacing all whitespace characters (spaces, tabs, newlines, etc.) with single spaces and trims leading/trailing whitespace.

Syntax: %flatten_text(filename)%

Arguments:

Example:

Given a file data/multiline.txt:

And a stub file:

The placeholder will be replaced with: "Hello World Test"

Error Handling:

JsonToUrlEncodedQueryStringProcessor

Name: json_to_url_encoded_query_string

Purpose: Converts JSON data to URL-encoded query string format, with support for ignoring specific characters from encoding.

Syntax: %json_to_url_encoded_query_string(filename, [ignored_characters])%

Arguments:

Example 1 - Basic Usage:

Given a file data/params.json:

And a stub file:

The placeholder will be replaced with: "name=John%20Doe&age=30&active=1"

Example 2 - With Ignored Characters:

Given a file data/url_params.json:

And a stub file:

The placeholder will be replaced with: "callback_url=https://example.com/callback?token=abc123&[email protected]"

Example 3 - Complex JSON with Nested Objects:

Given a file data/complex.json:

The processor will JSON-encode nested objects and arrays:

Error Handling:

Advanced Argument Parsing

The placeholder parser supports sophisticated argument parsing including:

Arrays: Use square brackets to define arrays

Associative Arrays: Use => syntax for key-value pairs

Mixed Data Types: Support for strings, integers, floats, booleans, and null

Nested Arrays: Support for multi-dimensional arrays

Creating Custom Processors

You can create custom processors by implementing the PlaceholderProcessorInterface:

For file-based processors, you can extend AbstractFileBasedPlaceholderProcessor:

Processor Naming Rules

Processor names must follow these rules:

Valid examples: flatten_text, json_to_url, custom_processor_v2, data.transformer

This integration aims to simplify the process of testing HTTP interactions within your Behat scenarios, leveraging Wiremock's powerful mocking capabilities to enhance your testing suite.


All versions of php-behat-context-wiremock with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
behat/behat Version >=3.0
symfony/http-client Version >=3.0
symfony/contracts Version >=1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package auto1-oss/php-behat-context-wiremock contains the following files

Loading the files please wait ...