class FeatureContext in Bear 8
Same name and namespace in other branches
- 8.2 tests/features/bootstrap/FeatureContext.php \FeatureContext
- 7.2 tests/features/bootstrap/FeatureContext.php \FeatureContext
- 7 tests/features/bootstrap/FeatureContext.php \FeatureContext
Defines application features from the specific context.
Hierarchy
- class \FeatureContext extends \Drupal\DrupalExtension\Context\RawDrupalContext implements \Behat\Behat\Context\SnippetAcceptingContext
Expanded class hierarchy of FeatureContext
File
- tests/features/ bootstrap/ FeatureContext.php, line 19 
View source
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
  /**
   * An array of Behat Context objects.
   *
   * An array of other contexts that this class delegates to in the event
   * a non-existent method is called on this class.  It's the poor man's traits.
   */
  public $subcontexts = array();
  /**
   * Initializes context.
   *
   * Every scenario gets its own context instance.
   * You can also pass arbitrary arguments to the
   * context constructor through behat.yml.
   */
  public function __construct() {
    #$this->localConf = $this->getConfig();
  }
  #public function getConfig() {
  #  if (!file_exists('local-config.yaml')) {
  #    throw new Exception('Please create a local-config.yaml.  See example.local-config.yaml for structure.');
  #  }
  #  return Yaml::parse('local-config.yaml');
  #}
  /**
   * @Transform /\[.*\](?:.*)/
   */
  public function transformLocalConf($argument) {
    // Token replace the argument.
    preg_match('/\\[(.*)\\]/', $argument, $matches);
    $token = $matches[1];
    if (isset($this->localConf[$token])) {
      // throw new \Exception(sprintf('Argument %s and token %s and result %s', $argument, $token, str_replace('[' . $token . ']', $this->localConf[$token], $argument)));
      return str_replace('[' . $token . ']', $this->localConf[$token], $argument);
    }
  }
  /**
   * @AfterScenario @deleteTestField
   */
  public function deleteTestField() {
    $driver = $this
      ->getSession()
      ->getDriver();
    $driver
      ->visit("/admin/structure/types/manage/page/fields/node.page.field_test/delete");
    $this
      ->getSession()
      ->getPage()
      ->pressButton("Delete");
  }
  /**
   * Checks that a specific radio button is checked, must use radio button's id.
   *
   * @Then /^the "([^"]*)" radio should be checked$/
   */
  public function theRadioShouldBeChecked($arg1) {
    $elementByCss = $this
      ->getSession()
      ->getPage()
      ->find('css', 'input[type="radio"]:checked#' . $arg1);
    if (!$elementByCss) {
      throw new Exception('Radio button with id ' . $arg1 . ' is not checked');
    }
  }
  /**
   * Waits for 1 second.
   *
   * @Given /^I wait (\d+) seconds$/
   */
  public function iWait($time) {
    sleep($time);
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| FeatureContext:: | public | property | An array of Behat Context objects. | |
| FeatureContext:: | public | function | @AfterScenario @deleteTestField | |
| FeatureContext:: | public | function | Waits for 1 second. | |
| FeatureContext:: | public | function | Checks that a specific radio button is checked, must use radio button's id. | |
| FeatureContext:: | public | function | @Transform /\[.*\](?:.*)/ | |
| FeatureContext:: | public | function | Initializes context. | 
