You are here

public function ThunderParagraphsTestTrait::addSocialParagraph in Thunder 6.2.x

Same name and namespace in other branches
  1. 8.5 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::addSocialParagraph()
  2. 8.2 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::addSocialParagraph()
  3. 8.3 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::addSocialParagraph()
  4. 8.4 tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::addSocialParagraph()
  5. 6.0.x tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::addSocialParagraph()
  6. 6.1.x tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php \Drupal\Tests\thunder\FunctionalJavascript\ThunderParagraphsTestTrait::addSocialParagraph()

Create Twitter, Instagram or PinterestParagraph.

Parameters

string $fieldName: Field name.

string $socialUrl: Url to tweet, instagram or pinterest.

string $type: Type of paragraph (twitter|instagram|pinterest).

int $position: Position of the paragraph.

1 call to ThunderParagraphsTestTrait::addSocialParagraph()
ArticleCreationTest::testCreateArticle in tests/src/FunctionalJavascript/ArticleCreationTest.php
Test Creation of Article.

File

tests/src/FunctionalJavascript/ThunderParagraphsTestTrait.php, line 211

Class

ThunderParagraphsTestTrait
Trait for handling of Paragraph related test actions.

Namespace

Drupal\Tests\thunder\FunctionalJavascript

Code

public function addSocialParagraph($fieldName, $socialUrl, $type, $position = NULL) {
  $paragraphIndex = $this
    ->addParagraph($fieldName, $type, $position);

  /** @var \Behat\Mink\Element\DocumentElement $page */
  $page = $this
    ->getSession()
    ->getPage();
  if ($page
    ->hasField("{$fieldName}[{$paragraphIndex}][subform][field_media][0][inline_entity_form][field_url][0][value]")) {
    $page
      ->fillField("{$fieldName}[{$paragraphIndex}][subform][field_media][0][inline_entity_form][field_url][0][value]", $socialUrl);
  }
  elseif ($page
    ->hasField("{$fieldName}[{$paragraphIndex}][subform][field_media][0][inline_entity_form][field_url][0][uri]")) {
    $page
      ->fillField("{$fieldName}[{$paragraphIndex}][subform][field_media][0][inline_entity_form][field_url][0][uri]", $socialUrl);
  }
}