Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Drupal 8 include for drush 9. #11

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/Commands/BehatDrushEndpointCommands.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace Drush\Commands;

use Drush\Commands\DrushCommands;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\node\Entity\Node;
use Drupal\node\NodeInterface;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\TermInterface;

/**
* A Drush commandfile.
*
* Contains Behat Drush commands, for use by the Behat Drush Extension.
* These commands are specifically for Drush 9
*
* See these files for an example of injecting Drupal services:
* - http://cgit.drupalcode.org/devel/tree/src/Commands/DevelCommands.php
* - http://cgit.drupalcode.org/devel/tree/drush.services.yml
*/
class BehatDrushEndpointCommands extends DrushCommands {

public function __construct() {
include __DIR__ . '/../../behat.d8.drush.inc';
}

/**
* Behat Drush endpoint. Serves as an entrypoint for Behat to make remote calls into the Drupal site being tested.
*
* @param $operation
* Behat operation, e.g. create-node.
* @param $data
* Operation data in json format.
* @usage drush behat create-node '{"title":"Example page","type":"page"}'
* Create a page with the title "Example page".
*
* @bootstrap full
* @command behat:create
* @aliases behat
*/
public function behat($operation, $data) {
$obj = json_decode($data);

// Dispatch if the operation exists.
$fn = 'drush_behat_op_' . strtr($operation, '-', '_');
if (function_exists($fn)) {
return $fn($obj);
}
else {
throw new \Exception(dt("Operation '!op' unknown", array('!op' => $operation)));
}
}

}