You are here

public function TestImporter::testCreateParagraph in Feeds Paragraphs 8

@covers ::createParagraph

File

tests/src/Unit/TestImporter.php, line 394

Class

TestImporter
@group Feeds Paragraphs @coversDefaultClass \Drupal\feeds_para_mapper\Importer

Namespace

Drupal\Tests\feeds_para_mapper\Unit

Code

public function testCreateParagraph() {
  $this->entityHelper->values = array();
  $method = $this
    ->getMethod(Importer::class, 'createParagraph');
  $node = $this->node
    ->reveal();
  $args = array(
    $field = "paragraph_field",
    $bundle = "bundle_one",
    $node,
  );
  $result = $method
    ->invokeArgs($this->importer, $args);
  $value = $this->entityHelper->values['paragraph_field'];
  self::assertTrue(isset($value[0]['entity']), 'the host entity has the created paragraph');
  self::assertInstanceOf(Paragraph::class, $result);
  $host_info = $result->host_info;
  $keys = array(
    'type',
    'entity',
    'bundle',
    'field',
  );
  foreach ($keys as $key) {
    self::assertArrayHasKey($key, $host_info);
  }
}