You are here

class PanelsSubContext in Panopoly 8.2

Same name and namespace in other branches
  1. 7 modules/panopoly/panopoly_test/behat/steps/panopoly_test_panels.behat.inc \PanelsSubContext

Behat sub-context for Panels.

Hierarchy

  • class \PanelsSubContext extends \Drupal\DrupalExtension\Context\RawDrupalContext implements \Drupal\DrupalExtension\Context\DrupalSubContextInterface

Expanded class hierarchy of PanelsSubContext

File

modules/panopoly/panopoly_test/behat/steps/panopoly_test_panels.behat.inc, line 17
Provide Behat step-definitions for Panels.

View source
class PanelsSubContext extends RawDrupalContext implements DrupalSubContextInterface {

  /**
   * Contains the DrupalDriverManager.
   *
   * @var \Drupal\DrupalDriverManager
   */
  private $drupal;

  /**
   * Initializes context.
   */
  public function __construct(DrupalDriverManager $drupal) {
    $this->drupal = $drupal;
  }

  /**
   * Wait until the Panels IPE is activated.
   *
   * @When I wait for the Panels IPE to activate
   */
  public function waitForIpeToActivate() {

    // @todo Implement for Drupal 8!
  }

  /**
   * Wait until the Panels IPE is deactivated.
   *
   * @When I wait for the Panels IPE to deactivate
   */
  public function waitForIpeToDeactivate() {

    // @todo Implement for Drupal 8!
  }

  /**
   * Enable the Panels IPE if it's available on the current page.
   *
   * @When I customize this page with the Panels IPE
   */
  public function customizeThisPageIpe() {

    // @todo Implement for Drupal 8!
  }

  /**
   * Open 'Change layout' dialog if it's available on the current page.
   *
   * @When I change layout with the Panels IPE
   */
  public function changeLayoutIpe() {

    // @todo Implement for Drupal 8!
  }

  /**
   * Ensure the element identified by CSS selector is visible.
   *
   * @param string $selector
   *   The CSS selector.
   */
  protected function checkVisible($selector) {
    $this
      ->getSession()
      ->wait(5000, "jQuery('{$selector}').length > 0 && jQuery('{$selector}').get(0).offsetParent !== null");
  }

  /**
   * Creates a new widget in the Panels IPE.
   *
   * @When I create new :widget content in the Panels IPE
   */
  public function createNewContent($widget) {
    $page = $this
      ->getSession()
      ->getPage();
    $page
      ->clickLink('Manage Content');
    $this
      ->checkVisible(".ipe-block-picker-list.active");
    $page
      ->clickLink('Create Content');
    $this
      ->checkVisible(".ipe-category-picker-top.active");
    if ($create_link = $page
      ->find('xpath', "//a[@data-block-type and div/h5/text() = '{$widget}']")) {
      $create_link
        ->click();
    }
    else {
      throw new \Exception("Unable to find widget called '{$widget}'");
    }
    $this
      ->checkVisible("form.block-content-form");
  }

  /**
   * Waits for IPE to load.
   *
   * @When I wait for the block form to load in the Panels IPE
   */
  public function waitForBlockFormInIpe() {
    $this
      ->checkVisible("form.panels-ipe-block-plugin-form");
  }

}

Members

Namesort descending Modifiers Type Description Overrides
PanelsSubContext::$drupal private property Contains the DrupalDriverManager.
PanelsSubContext::changeLayoutIpe public function Open 'Change layout' dialog if it's available on the current page.
PanelsSubContext::checkVisible protected function Ensure the element identified by CSS selector is visible.
PanelsSubContext::createNewContent public function Creates a new widget in the Panels IPE.
PanelsSubContext::customizeThisPageIpe public function Enable the Panels IPE if it's available on the current page.
PanelsSubContext::waitForBlockFormInIpe public function Waits for IPE to load.
PanelsSubContext::waitForIpeToActivate public function Wait until the Panels IPE is activated.
PanelsSubContext::waitForIpeToDeactivate public function Wait until the Panels IPE is deactivated.
PanelsSubContext::__construct public function Initializes context.