You are here

public function GatherContentUploadTest::assertParagraphText in GatherContent 8.5

Check paragraph text value.

Parameters

string $fieldValue: GatherContent field value.

\Drupal\Core\Field\FieldItemListInterface $itemList: Item list.

bool $isPop: Use array_pop or not.

bool $translated: Is the content translated.

2 calls to GatherContentUploadTest::assertParagraphText()
GatherContentUploadTest::assertItemChanged in gathercontent_upload/tests/src/Kernel/GatherContentUploadTest.php
Checks if all the fields are correctly set.
GatherContentUploadTest::assertItemChangedMultilang in gathercontent_upload/tests/src/Kernel/GatherContentUploadTest.php
Checks if all the fields are correctly set for multilingual content.

File

gathercontent_upload/tests/src/Kernel/GatherContentUploadTest.php, line 312

Class

GatherContentUploadTest
@coversDefaultClass \Drupal\gathercontent_upload\Export\Exporter @group gathercontent_upload

Namespace

Drupal\Tests\gathercontent_upload\Kernel

Code

public function assertParagraphText($fieldValue, FieldItemListInterface $itemList, $isPop = FALSE, $translated = FALSE) {
  $targets = $itemList
    ->getValue();
  if ($isPop) {
    $target = array_pop($targets);
  }
  else {
    $target = array_shift($targets);
  }
  $para = Paragraph::load($target['target_id']);
  if ($translated) {
    $value = $para
      ->getTranslation('hu')
      ->get('field_text')
      ->getValue()[0]['value'];
  }
  else {
    $value = $para
      ->get('field_text')
      ->getValue()[0]['value'];
  }
  $this
    ->assertEquals($value, $fieldValue);
}