Skip to content

Commit

Permalink
Further work towards Behat 3.
Browse files Browse the repository at this point in the history
* Continues to extend the Mink Context
* Adds the Behat Chained Steps Extension
* Further API changes.
  • Loading branch information
jhedstrom committed Jun 19, 2014
1 parent 4b9d2e2 commit 35e2158
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion behat.yml.dist
@@ -1,7 +1,7 @@
default:
suites:
default:
contexts: [Behat\MinkExtension\Context\MinkContext, Drupal\DrupalExtension\Context\DrupalContext]
contexts: [Drupal\DrupalExtension\Context\DrupalContext]
filters:
tags: "~@api&&~@drush"
extensions:
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Expand Up @@ -16,7 +16,8 @@
"behat/mink-goutte-driver": "*",
"behat/mink-selenium2-driver": "*",
"behat/behat": "~3.0,>=3.0.5",
"behat/mink-extension": "2.0.x-dev"
"behat/mink-extension": "2.0.x-dev",
"behat/chained-steps-extension": "1.0.x-dev"
},
"require-dev": {
"phpunit/phpunit": "3.7.*"
Expand All @@ -34,5 +35,11 @@
"branch-alias": {
"dev-master": "2.0.x-dev"
}
}
},
"repositories": [
{
"type": "vcs",
"url": "https://github.com/Behat/ChainedStepsExtension.git"
}
]
}
8 changes: 5 additions & 3 deletions src/Drupal/DrupalExtension/Context/DrupalContext.php
Expand Up @@ -14,8 +14,8 @@
use Symfony\Component\Process\Process;
use Symfony\Component\EventDispatcher\EventDispatcher;

use Behat\Behat\Definition\Call\Given;
use Behat\Behat\Definition\Call\Then;
use Behat\ChainedStepsExtension\Step\Given;
use Behat\ChainedStepsExtension\Step\Then;
use Behat\Behat\Context\TranslatableContext;

use Behat\Gherkin\Node\PyStringNode;
Expand All @@ -25,8 +25,10 @@

/**
* Features context.
*
* @todo is there a way to inject a MinkContext instead?
*/
class DrupalContext implements DrupalAwareInterface, TranslatableContext {
class DrupalContext extends MinkContext implements DrupalAwareInterface, TranslatableContext {

private $drupal, $drupalParameters;

Expand Down
Expand Up @@ -2,21 +2,22 @@

namespace Drupal\DrupalExtension\Context\Initializer;

use Behat\Behat\Context\Initializer\InitializerInterface,
Behat\Behat\Context\ContextInterface,
use Behat\Behat\Context\Initializer\ContextInitializer,
Behat\Behat\Context\Context,
Behat\Behat\Event\ScenarioEvent,
Behat\Behat\Event\OutlineEvent;

use Drupal\Drupal,
Drupal\DrupalExtension\Context\DrupalContext,
Drupal\DrupalExtension\Context\DrupalSubContextFinderInterface;
use Drupal\Drupal;
use Drupal\DrupalExtension\Context\DrupalContext;
use Drupal\DrupalExtension\Context\DrupalAwareInterface;
use Drupal\DrupalExtension\Context\DrupalSubContextFinderInterface;

use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

use Symfony\Component\Finder\Finder;

class DrupalAwareInitializer implements InitializerInterface, EventSubscriberInterface {
class DrupalAwareInitializer implements ContextInitializer, EventSubscriberInterface {
private $drupal, $parameters, $dispatcher;

public function __construct(Drupal $drupal, array $parameters, EventDispatcher $dispatcher) {
Expand All @@ -25,7 +26,10 @@ public function __construct(Drupal $drupal, array $parameters, EventDispatcher $
$this->dispatcher = $dispatcher;
}

public function initialize(ContextInterface $context) {
/**
* {@inheritdocs}
*/
public function initializeContext(Context $context) {
// Set Drupal driver manager.
$context->setDrupal($this->drupal);

Expand Down
14 changes: 2 additions & 12 deletions src/Drupal/DrupalExtension/ServiceContainer/DrupalExtension.php
Expand Up @@ -25,7 +25,7 @@ class DrupalExtension implements ExtensionInterface {
* {@inheritDoc}
*/
public function getConfigKey() {
return SELF::DRUPAL_ID;
return self::DRUPAL_ID;
}

/**
Expand Down Expand Up @@ -84,10 +84,7 @@ public function process(ContainerBuilder $container) {
}

/**
* Setup configuration for this extension.
*
* @param ArrayNodeDefinition $builder
* ArrayNodeDefinition instance.
* {@inheritDoc}
*/
public function configure(ArrayNodeDefinition $builder) {
$builder->
Expand Down Expand Up @@ -168,13 +165,6 @@ public function configure(ArrayNodeDefinition $builder) {
end();
}

/**
* Load Drupal Extension selectors handler.
*/
private function loadSelectorsHandler(ContainerBuilder $container) {
$container->setDefinition(self::SELECTORS_HANDLER_ID);
}

/**
* Returns compiler passes used by mink extension.
*
Expand Down
Expand Up @@ -48,8 +48,8 @@ services:
- %drupal.parameters%
- @drupal.event_dispatcher
tags:
- { name: behat.context.initializer }
- { name: behat.event_subscriber, priority: 0 }
- { name: context.initializer }
- { name: event_dispatcher.subscriber, priority: 0 }
drupal.context.class_guesser:
class: %drupal.context.class_guesser.class%
tags:
Expand Down

0 comments on commit 35e2158

Please sign in to comment.