You are here

protected function ParagraphsFeaturesSplitTextTest::createNewTextParagraph in Paragraphs Features 8

Same name and namespace in other branches
  1. 2.x tests/src/FunctionalJavascript/ParagraphsFeaturesSplitTextTest.php \Drupal\Tests\paragraphs_features\FunctionalJavascript\ParagraphsFeaturesSplitTextTest::createNewTextParagraph()

Create new text paragraph to end of paragraphs list.

Parameters

int $index: Index of new paragraph.

string $text: Text that will be filled to text field with CKEditor.

Return value

string Returns CKEditor ID.

Throws

\Behat\Mink\Exception\DriverException

\Behat\Mink\Exception\UnsupportedDriverActionException

1 call to ParagraphsFeaturesSplitTextTest::createNewTextParagraph()
ParagraphsFeaturesSplitTextTest::testSplitTextFeature in tests/src/FunctionalJavascript/ParagraphsFeaturesSplitTextTest.php
Test split text feature.

File

tests/src/FunctionalJavascript/ParagraphsFeaturesSplitTextTest.php, line 26

Class

ParagraphsFeaturesSplitTextTest
Tests the paragraph text split feature.

Namespace

Drupal\Tests\paragraphs_features\FunctionalJavascript

Code

protected function createNewTextParagraph($index, $text) {
  $session = $this
    ->getSession();
  $page = $session
    ->getPage();
  $driver = $session
    ->getDriver();
  $page
    ->find('xpath', '(//*[contains(@class, "paragraph-type-add-modal-button")])[1]')
    ->click();
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $page
    ->find('xpath', '//*[contains(@class, "paragraphs-add-dialog") and contains(@class, "ui-dialog-content")]//*[contains(@name, "test_1")]')
    ->click();
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  sleep(1);
  $ck_editor_id = $this
    ->getCkEditorId($index);
  $driver
    ->executeScript("CKEDITOR.instances['{$ck_editor_id}'].insertHtml('{$text}');");
  return $ck_editor_id;
}