You are here

public function CkEditorContext::execute in Lightning Core 8.4

Same name and namespace in other branches
  1. 8.5 tests/contexts/CkEditorContext.behat.inc \Acquia\LightningExtension\Context\CkEditorContext::execute()
  2. 8 tests/contexts/CkEditorContext.behat.inc \Acquia\LightningExtension\Context\CkEditorContext::execute()
  3. 8.2 tests/contexts/CkEditorContext.behat.inc \Acquia\LightningExtension\Context\CkEditorContext::execute()
  4. 8.3 tests/contexts/CkEditorContext.behat.inc \Acquia\LightningExtension\Context\CkEditorContext::execute()

Executes a CKEditor command.

@When I execute the :command command in CKEditor @When I execute the :command command in CKEditor :id

Parameters

string $command: The command ID, as known to CKEditor's API.

string $id: (optional) The editor instance ID.

mixed $data: Additional data to pass to the executed command.

Throws

\Behat\Mink\Exception\ExpectationException If the command cannot be executed (i.e., returns a falsy value).

File

tests/contexts/CkEditorContext.behat.inc, line 138

Class

CkEditorContext
Contains step definitions for working with CKEditor instances.

Namespace

Acquia\LightningExtension\Context

Code

public function execute($command, $id = NULL, $data = NULL) {
  $js = $this
    ->assertEditor($id);
  $session = $this
    ->getSession();
  $return = Json::decode($session
    ->evaluateScript("{$js}.execCommand('{$command}', " . Json::encode($data) . ')'));
  if (empty($return)) {
    throw new ExpectationException('CKEditor command ' . $command . ' returned ' . var_export($return, TRUE) . ', expected truthy.', $session
      ->getDriver());
  }
}