Behat Mink: Drush Driver Compser Install

Drush Installation

https://github.com/drush-ops/drush

 

Via Composer with composer.json

composer require drush-ops/behat-drush-endpoint:^1

 

T:\git\behatmink (master -> origin)
λ php composer.phar require drush-ops/behat-drush-endpoint:^1
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 2 installs, 0 updates, 0 removals
  - Installing composer/installers (v1.6.0): Downloading (100%)
  - Installing drush-ops/behat-drush-endpoint (1.0.0): Downloading (100%)
Writing lock file
Generating autoload files

 

Composer.json

  •  
{
  "require":{
      "drupal/drupal-extension":"~3.0",
      "guzzlehttp/guzzle" : "^6.0@dev",
    "drush-ops/behat-drush-endpoint": "1"
    },
    "require-dev":{
      "phpunit/phpunit": "^4.8.36|^6.3"
    },
      "config":{
        "bin-dir":"bin/"
      }
}

 

 

 

Via GitHub Clone & Composer install

If you are not using composer.json on the remote Drupal site, then copy the entire contents of this project to either ROOT/drush or ROOT/sites/all/drush, then cd behat-drush-endpoint and run composer install.

 


The Behat Drush Endpoint is the remote component needed to work with the Behat Drupal Driver.

The Behat Drupal Driver contains three drivers: Blackbox, Direct Drupal API, and Drush. The Behat Drush Endpoint is only necessary when using the Drush driver.

Installation Instructions

If you are managing your Drupal site with Composer, then add the Behat Drush Endpoint to your project as follows:

composer require drush-ops/behat-drush-endpoint:^1

If you are not using composer.json on the remote Drupal site, then copy the entire contents of this project to either ROOT/drush or ROOT/sites/all/drush, then cd behat-drush-endpoint and run composer install.

 


 

 

Behat Throws Error When Attempting To Call Drush

T:\git\behatmink (master -> origin)
λ bin\behat -c tests\behat\behat-drush.yml
Feature: Drush alias
  In order to demonstrate the Drush driver
  As a trainer
  I need to show how to tag scenarios

  Scenario: Untagged scenario uses blackbox driver and fails          # features\Drush\DrushTests.feature:6
    Given I am logged in as a user with the "authenticated user" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
      No ability to generate random in Drupal\Driver\BlackboxDriver. Put `@api` into your feature and add an API driver (ex: `api_driver: drupal`) in behat.yml. (Drupal\Driver\Exception\UnsupportedDriverActionException)
    When I click "My account"                                         # Drupal\DrupalExtension\Context\MinkContext::assertClick()
    Then I should see the heading "History"                           # Drupal\DrupalExtension\Context\MinkContext::assertHeading()

  @api
  Scenario: Tagged scenario uses Drush driver and succeeds            # features\Drush\DrushTests.feature:12
    Given I am logged in as a user with the "authenticated user" role # Drupal\DrupalExtension\Context\DrupalContext::assertAuthenticatedByRole()
      'drush' is not recognized as an internal or external command,
      operable program or batch file.
       (RuntimeException)
    When I click "My account"                                         # Drupal\DrupalExtension\Context\MinkContext::assertClick()
    Then I should see the heading "History"                           # Drupal\DrupalExtension\Context\MinkContext::assertHeading()

--- Failed scenarios:

    features\Drush\DrushTests.feature:6
    features\Drush\DrushTests.feature:12

2 scenarios (2 failed)
6 steps (2 failed, 4 skipped)
0m20.27s (10.43Mb)

 

/drush/README.md

## Installation Instructions

If you are managing your Drupal site with Composer, ensure that your composer.json contains the following entries:
``` json
{
    "require-dev": {
        "drush-ops/behat-drush-endpoint": "*",
        "drupal/drupal-driver": "dev-master"
    },
}

 


Adding drupa/drupal-driver Failed

 

T:\git\behatmink (master -> origin)
λ php composer.phar require --dev drupal/drupal-driver:dev-master
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - drupal/drupal-extension v3.4.1 requires drupal/drupal-driver ~1.3 -> satisfiable by drupal/drupal-driver[1.3.x-dev, 1.4.x-dev].
    - drupal/drupal-extension v3.4.1 requires drupal/drupal-driver ~1.3 -> satisfiable by drupal/drupal-driver[1.3.x-dev, 1.4.x-dev].
    - drupal/drupal-extension v3.4.1 requires drupal/drupal-driver ~1.3 -> satisfiable by drupal/drupal-driver[1.3.x-dev, 1.4.x-dev].
    - Can only install one of: drupal/drupal-driver[dev-master, 1.3.x-dev].
    - Can only install one of: drupal/drupal-driver[dev-master, 1.4.x-dev].
    - Installation request for drupal/drupal-driver dev-master -> satisfiable by drupal/drupal-driver[dev-master].
    - Installation request for drupal/drupal-extension (locked at v3.4.1, required as ~3.0) -> satisfiable by drupal/drupal-extension[v3.4.1].


Installation failed, reverting ./composer.json to its original content.

 


 

CMDER: Install Drush Launcher phar to PATH

  • Behat Feature Files were failling due to 'drush' command not found
  • Installed Drush Launcher to the cmder/bin folder & created a windows batch file to call it with PHP

curl drush.phar to cmder's /bin folder ( so that its in the PATH )

cd bin
;curl -OL https://github.com/drush-ops/drush-launcher/releases/download/0.6.0/drush.phar

 

drush.bat

@echo off
php "%~dp0\drush.phar" %*

 

 

 

 

 

 

 

 

 

Tags