You are here

public function TestMapper::testGetSubFields in Feeds Paragraphs 8

@covers ::getSubFields

File

tests/src/Unit/TestMapper.php, line 74

Class

TestMapper
@group Feeds Paragraphs @coversDefaultClass \Drupal\feeds_para_mapper\Mapper

Namespace

Drupal\Tests\feeds_para_mapper\Unit

Code

public function testGetSubFields() {

  // Test against a paragraph field:
  $field = $this->fields[0]
    ->reveal();
  $subFields = $this->mapper
    ->getSubFields($field);
  $targetInfo = $subFields[0]
    ->get('target_info');
  $message = "TargetInfo object is attached to the target field";
  self::assertTrue(isset($targetInfo), $message);
  $notParagraph = $subFields[0]
    ->getType() !== "entity_reference_revisions";
  $message = "Field type not paragraph";
  self::assertTrue($notParagraph, $message);

  // Test against non-paragraph field:
  $field = $this->fieldHelper
    ->getBundleFields('bundle_two')[0]
    ->reveal();
  $subFields = $this->mapper
    ->getSubFields($field);
  $message = "Returns array if no sub-fields found";
  self::assertTrue(is_array($subFields) && count($subFields) === 0, $message);
}