You are here

class FeatureContext in Accordion Blocks 8

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

1 string reference to 'FeatureContext'
behat.yml in tests/behat.yml
tests/behat.yml

File

tests/features/bootstrap/FeatureContext.php, line 11

View source
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {

  /**
   * 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() {
  }

  /**
   * Remove terms that we probably created. Nodes
   * are handled because when a user is deleted their content
   * is deleted as well. This not true for terms
   * that they create though.
   *
   * @AfterScenario
   */
  public function cleanupBlocks() {
    $query = Drupal::entityQuery('block_content');
    $result = $query
      ->condition('info', 'BDD TESTING', 'STARTS_WITH')
      ->execute();
    $eids = array_keys($result);
    entity_delete_multiple('block_content', $eids);
  }

  /**
   * @Then /^I wait for the suggestion box to appear$/
   */
  public function iWaitForTheSuggestionBoxToAppear() {
    $this
      ->getSession()
      ->wait(5000, "jQuery('.ui-dialog.ui-widget').length > 0");
  }

  /**
   * @When I wait for the field items to appear
   */
  public function iWaitForTheFieldItemsToAppear() {
    $this
      ->getSession()
      ->wait(5000, "jQuery('input[name=\"field_blocks[2][target_id]\"]').length > 0");
  }

  /**
   * @When I Save Block Placement
   */
  public function iSaveBlockPlacement() {
    $this
      ->getSession()
      ->wait(100, "jQuery('.ui-dialog-buttonset.form-actions button').click()");
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FeatureContext::cleanupBlocks public function Remove terms that we probably created. Nodes are handled because when a user is deleted their content is deleted as well. This not true for terms that they create though.
FeatureContext::iSaveBlockPlacement public function @When I Save Block Placement
FeatureContext::iWaitForTheFieldItemsToAppear public function @When I wait for the field items to appear
FeatureContext::iWaitForTheSuggestionBoxToAppear public function @Then /^I wait for the suggestion box to appear$/
FeatureContext::__construct public function Initializes context.