You are here

final class ImageBrowserContext in Lightning Media 8.3

Same name and namespace in other branches
  1. 8 tests/contexts/ImageBrowserContext.behat.inc \Acquia\LightningExtension\Context\ImageBrowserContext
  2. 8.2 tests/contexts/ImageBrowserContext.behat.inc \Acquia\LightningExtension\Context\ImageBrowserContext

Contains step definitions for interacting with Lightning's image browsers.

@internal This is an internal part of Lightning Media's testing system and may be changed or removed at any time without warning. It should not be extended, instantiated, or used in any way by external code! If you need to use this functionality, you should copy the relevant code into your own project.

Hierarchy

  • class \Acquia\LightningExtension\Context\ImageBrowserContext extends \Drupal\DrupalExtension\Context\DrupalSubContextBase uses \Acquia\LightningExtension\Context\AwaitTrait

Expanded class hierarchy of ImageBrowserContext

File

tests/contexts/ImageBrowserContext.behat.inc, line 17

Namespace

Acquia\LightningExtension\Context
View source
final class ImageBrowserContext extends DrupalSubContextBase {
  use AwaitTrait;

  /**
   * Opens an image browser for a particular field.
   *
   * @param string $field
   *   The field label.
   *
   * @When I open the :field image browser
   */
  public function open($field) {

    /** @var ElementContext $context */
    $context = $this
      ->getContext(ElementContext::class);
    $context
      ->assertDetails($field)
      ->pressButton('Select Image(s)');
    $this
      ->awaitAjax();
    $context
      ->enterFrame('entity_browser_iframe_image_browser');
  }

  /**
   * Asserts that cropping is enabled for an uploaded image.
   *
   * @Then I should be able to crop the image
   */
  public function assertCrop() {

    /** @var \Acquia\LightningExtension\Context\ElementContext $context */
    $context = $this
      ->getContext(ElementContext::class);

    // There should always be a collapsible cropping area, but depending on the
    // circumstances, the Freeform crop widget might either be a vertical tab
    // inside that area, or its own cropping area. Try to account for both.
    $crop = $context
      ->assertOpenDetails('Crop image');
    try {
      $context
        ->assertVerticalTab('Freeform', $crop);
    } catch (ElementNotFoundException $e) {
      $context
        ->assertDetails('Freeform');
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ImageBrowserContext::assertCrop public function Asserts that cropping is enabled for an uploaded image.
ImageBrowserContext::open public function Opens an image browser for a particular field.