Skip to content

Commit

Permalink
Merge pull request #205 from jhedstrom/document-context-communication
Browse files Browse the repository at this point in the history
Adding documentation for context communication.
  • Loading branch information
jhedstrom committed Aug 26, 2015
2 parents 236d29b + e7609c2 commit 64c5e5d
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions doc/_static/snippets/subcontext.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Contains \FooFoo.
*/

use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Behat\Tester\Exception\PendingException;
use Drupal\DrupalExtension\Context\DrupalSubContextBase;
use Drupal\DrupalExtension\Context\DrupalSubContextInterface;
Expand All @@ -13,6 +14,37 @@ use Drupal\DrupalExtension\Context\DrupalSubContextInterface;
*/
class FooFoo extends DrupalSubContextBase implements DrupalSubContextInterface {

/**
* @var \Drupal\DrupalExtension\Context\DrupalContext
*/
protected $drupalContext;

/**
* @var \Drupal\DrupalExtension\Context\MinkContext
*/
protected $minkContext;

/**
* @BeforeScenario
*/
public function gatherContexts(BeforeScenarioScope $scope) {
$environment = $scope->getEnvironment();

$this->drupalContext = $environment->getContext('Drupal\DrupalExtension\Context\DrupalContext');
$this->minkContext = $environment->getContext('Drupal\DrupalExtension\Context\MinkContext');
}

/**
* @Given I create a(an) :arg1 content type
*/
public function CreateAContentType($arg1) {
$this->minkContext->assertAtPath("admin/structure/types/add");
$node = [
'title' => 'Test content!',
];
$this->drupalContext->nodeCreate($node);
}

/**
* @Then /^I should have a subcontext definition$/
*/
Expand Down

0 comments on commit 64c5e5d

Please sign in to comment.