You are here

public function ImportBasicTest::testReferenceDeserialization in Bibliography & Citation 8

Same name and namespace in other branches
  1. 2.0.x modules/bibcite_import/tests/src/Kernel/ImportBasicTest.php \Drupal\Tests\bibcite_import\Kernel\ImportBasicTest::testReferenceDeserialization()

Test decode and denormalization from available text formats to entity.

@dataProvider importData

File

modules/bibcite_import/tests/src/Kernel/ImportBasicTest.php, line 84

Class

ImportBasicTest
Basic import tests.

Namespace

Drupal\Tests\bibcite_import\Kernel

Code

public function testReferenceDeserialization($format, $text, $expected_type, $entity_expected_values) {
  $entries = $this->serializer
    ->decode($text, $format);
  foreach ($entries as $entry) {

    /* @var \Drupal\bibcite_entity\Entity\Reference $entity */
    $entity = $this->serializer
      ->denormalize($entry, Reference::class, $format);
    $this
      ->assertTrue($entity instanceof Reference);
    $this
      ->assertEquals($expected_type, $entity->type->target_id);
    $this
      ->assertEntityValues($entity, $entity_expected_values);
  }
}