Skip to content

Commit

Permalink
Update subcontext example for 3.0 per #117
Browse files Browse the repository at this point in the history
  • Loading branch information
eliza411 committed Dec 6, 2014
1 parent 2985883 commit f3c020b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 58 deletions.
13 changes: 0 additions & 13 deletions doc/_static/snippets/beanslide.behat-1.inc

This file was deleted.

15 changes: 0 additions & 15 deletions doc/_static/snippets/beanslide.behat-2.inc

This file was deleted.

16 changes: 16 additions & 0 deletions doc/_static/snippets/subcontext.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
use Behat\Behat\Tester\Exception\PendingException;
use Drupal\DrupalExtension\Context\DrupalSubContextInterface;
use Drupal\DrupalDriverManager;
class FooFoo implements DrupalSubContextInterface {
private $drupal;
public function __construct(DrupalDriverManager $drupal) {
$this->drupal = $drupal;
}
/**
* @Then /^I should have a subcontext definition$/
*/
public function assertSubContextDefinition() {
throw new PendingException();
}
}
38 changes: 8 additions & 30 deletions doc/subcontexts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,35 +38,13 @@ following:

For Contributors
----------------
Read a detailed discussion of `using sucontexts
<http://docs.behat.org/guides/4.context.html#using-subcontexts>`_ on the Behat
site.
Behat `sucontexts
<http://docs.behat.org/guides/4.context.html#using-subcontexts>`_ are no longer
supported in version 3. The Drupal Extension, however, continues to support
saving module-specific contexts in a file ending with `.behat.inc`

With regard to the Drupal Extension:
Just like functions, preface the filename with the project's machine name to prevent namespace collisions.

* Save custom step definitions in a file ending with `.behat.inc` Just like
functions, preface the filename with the project's machine name to prevent
namespace collisions.

* Writing step definitions for the subcontext is only slightly different than
writing them for the main context.

Your subcontext must include, at a minimum, lines 7 and 8 below.


// sites/all/modules/beanslide/beanslide.behat.inc

.. literalinclude:: _static/snippets/beanslide.behat-2.inc
:language: php
:linenos:
:emphasize-lines: 7,8,10-12

You'll also need to call the main context in order to access the session:

// sites/all/modules/beanslide/beanslide.behat.inc

.. literalinclude:: _static/snippets/beanslide.behat-1.inc
:language: php
:linenos:
:emphasize-lines: 5

.. literalinclude:: _static/snippets/subcontext.inc
:language: php
:linenos:

0 comments on commit f3c020b

Please sign in to comment.