Download the PHP package metadrop/behat-contexts without Composer

On this page you can find all versions of the php package metadrop/behat-contexts. 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 behat-contexts

tests project is maintained GitHub Release

Behat Contexts for Drupal

Contexts that we use with Behat 3.x tests on Drupal sites.

This repository is based on Nuvole Drupal extension.

Table of Contents

Install

Install with Composer:

composer require metadrop/behat-contexts

Configure

Each context may have its own configuration. Here is an example with all the contexts added.

Testing

This library includes a BATS-based testing infrastructure to validate Behat context behaviors and outputs. See the Testing documentation for detailed information.

Contexts

AntiSpam Context

Provides functionality to temporarily disable Honeypot time limits during test execution to prevent false negatives.

Steps

No manual steps. This context uses tags.

Tags

Configuration

No configuration needed.

Notes

Cache context

Steps to clear caches.

Steps

Configuration

No configuration needed.

Content authored context

Allows creating content owned by the logged-in user.

Steps

Configuration

No configuration needed.

Cron context

Helpers to execute cron.

Steps

Configuration

No configuration needed.

Cookie compliance context

It allows to check that sites are GDPR-compliant with regard to cookies. This feature is compatible with any cookie banner integration with the proper configuration. The context includes preconfigurations for OneTrust, Klaro and EU Cookie Compliance Drupal modules.

It can check that there are no cookies saved in the browser before they are accepted. It can also check the expected cookies appear when cookies are accepted.

The context has a default list of domains of typical third party services that may add cookies to the browser, but this list is not exhaustive. Check your site and add any additional domains you may need to the cookies_third_party_domains_included parameter.

By default, only those iframes whose domains belong to the THIRD_PARTY_COOKIE_HOSTS CookieComplianceContext constant will be detected as iframes that will add unwanted cookies.

There are two main ways to use this context: using one of the cookie managers supported (OneTrust, Klaro and EU Cookie Compliance Drupal module), or configuring all the parameters manually.

For a supported provider, just set the cookie_manager_type parameter to the desired value:

Example configuration with Cookie Manager type:

If you are using an unsupported cookie manager or if for whatever reason you want to configure the parameters manually, you can set parameters you need as shown in the example below.

Example configuration without Cookie Manager type:

Additionally, you can enable debug mode by setting the debug parameter to true. This will print the cookies present in the browser after accepting or rejecting cookies.

Steps

Tags

DebugContext

Simple context to help debugging tests with some steps. Additionally, it hooks in the after step event to add a step that generates an error report on failed steps.

This report includes:

Steps

Configuration

Add DebugContext to your suite.

This is an example when bootstrap directory is in DRUPALROOT/sites/all/tests/behat/bootstrap.

Parameters

Drupal Groups Extended Context

Utilities for testing with Drupal Group module.

Steps

Configuration

No configuration needed.

Notes

Drupal Organic Groups Extended Context

Utilities for testing with Drupal 7 Organic Groups module.

Steps

Configuration

No configuration needed.

Notes

Entity Context

Agnostic steps related to entities.

Steps

Configuration

No configuration needed.

File context

Create files in Drupal.

Steps

Configuration

Configure the files_path parameter in your behat.yml to specify where test files are located.

Form Context

Steps for form elements.

Steps

Configuration

No configuration needed.

I18n Context

Internationalization steps for testing multilingual sites, allowing interaction with translated interface elements.

When steps reference "translated" fields, buttons, pages, or text, they use Drupal's translation system to find the translated label or text from the provided text.

Steps

Configuration

No configuration needed.

Notes

Logs Context

Monitors and reports watchdog (dblog) errors during Behat test execution.

Steps

No manual steps. This context automatically displays logs after scenarios and provides a summary after the suite.

Functionality

Configuration

Parameters:

Notes

Media Context

Steps for working with Drupal Media entities through the media library widget.

Steps

Configuration

No configuration needed.

Notes

Node Access context

Steps related to the node access system. Only for D7.

Steps

Configuration

No configuration needed.

Paragraphs context

Steps to attach paragraphs to content.

Steps

Configuration

No configuration needed.

Search API Context

Automatically indexes content in Search API immediately after entity creation during tests.

Steps

No manual steps. This context automatically indexes entities using hooks.

Functionality

Configuration

No configuration needed.

Notes

Url Context

Steps to check url values

Steps

Configuration

No configuration needed.

UIContext

This context provides steps for certain UI elements.

Steps

Configuration

No configuration needed.

Advanced usage

Using elementShouldBeInPosition method

The UIContext provides an elementShouldBeInPosition method that can be used to verify element positions in lists or grids. This is useful for testing sorting, ordering, or layout functionality.

Example implementation in a custom step:

Users Context

Context for user-related operations and assertions. Provides steps to verify user existence, check user roles, and authenticate as users with specific roles.

Steps

Configuration

No configuration needed.

Users Random Context

Context used to generate random user data (username, email, password) for testing purposes. This context does NOT create actual Drupal users - it only generates random user data that can be used to fill forms during tests. This is particularly useful for testing interactions with remote APIs that require unique values on each test run and cannot clean previous data.

Steps

Configuration

No configuration needed.

Usage Example

Important Notes

WaitingContext

This context provides waiting time after defined steps, and extra waiting steps.

Waiting steps - Sometimes steps are running faster than our site, if this is the case you can delay them a few seconds. Don't abuse this functionality, if Behat is running slow maybe there is a performance global site issue that needs to be solved first!

Steps

- Then I wait for :seconds second(s)
  Step waits for a defined number of seconds before executing the next step.

Configure waiting time before executing the next step

Set in behat.yml the step action with wait time in seconds before executing the next step.

Configuration
Action

Wait 1 second before the next step to Then I press "Log in" (Then the url should match "/example-page")

Configuration

No configuration needed.

Video Recording Context

This context helps with video recording of Behat scenarios by displaying scenario metadata in the browser before each test. It is useful for identifying tests in video recordings.

Functionality

Configuration

Add VideoRecordingContext to your suite in behat.yml:


- Metadrop\Behat\Context\VideoRecordingContext:
    parameters:
      enabled: true
      show_test_info_screen: true
      show_test_info_screen_time: 2000
      show_green_screen: false
      show_green_screen_time: 1000
      show_step_info_bubble: true
      show_step_info_bubble_time: 2000
      show_error_info_bubble: true
      show_error_info_bubble_time: 2000

All versions of behat-contexts with dependencies

PHP Build Version
Package Version
Requires nuvoleweb/drupal-behat Version ^1.3
webmozart/assert Version ^1.11
symfony/console Version >= 4
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 metadrop/behat-contexts contains the following files

Loading the files please wait ...