You are here

public function NodeImportTest::testFancyNode in YAML Content 8

File

tests/src/Functional/NodeImportTest.php, line 108

Class

NodeImportTest
Tests general Node creation functionality.

Namespace

Drupal\Tests\yaml_content\Functional

Code

public function testFancyNode() {
  $this
    ->setupTaxonomyField();

  /** @var \Drupal\Core\Entity\Entity[] $entities */
  $entities = $this->contentLoader
    ->loadContent('fancy_node.content.yml');
  $this
    ->assertTrue(is_array($entities), 'An array was not returned from loadContent().');
  $this
    ->assertEquals(2, count($entities), 'No entity IDs were returned from loadContent().');
  $tag = $entities[0];
  $node = $entities[1];
  $tags = $node
    ->get('field_tags');
  $this
    ->assertEquals([
    'target_id' => $tag
      ->id(),
  ], $tags
    ->get(0)
    ->getValue(), 'Existing tag is connected.');
  $this
    ->assertNull($tags
    ->get(1), 'Missing tag is not created.');
}