You are here

public static function ContentProcessorTest::assertFieldEqualsElement in GatherContent 8.4

Assertion for Drupal field and GC element.

1 call to ContentProcessorTest::assertFieldEqualsElement()
ContentProcessorTest::assertNodeEqualsGcItem in tests/src/Kernel/ContentProcessorTest.php
Checks whether a node and a GC item contains the same data.

File

tests/src/Kernel/ContentProcessorTest.php, line 213

Class

ContentProcessorTest
Class for testing core node import functionality.

Namespace

Drupal\Tests\gathercontent\Kernel

Code

public static function assertFieldEqualsElement(array $field, Element $element, array $files) {
  switch ($element->type) {
    case 'text':
      static::assertEquals($element->value, reset($field)['value']);
      break;
    case 'section':
      $section = '<h3>' . $element->title . '</h3>' . $element->subtitle;
      static::assertEquals($section, reset($field)['value']);
      break;
    case 'files':
      static::assertFileFieldEqualsResponseFiles($field, $files);
      break;
    case 'choice_checkbox':
      static::assertCheckboxFieldEqualsOptions($field, $element->options);
      break;
    case 'choice_radio':
      static::assertRadioFieldEqualsOptions($field, $element->options);
      break;
    default:
      throw new \Exception("Unexpected element type: {$element->type}");
  }
}