You are here

public function CrudTest::testBundleMapping in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Kernel/CrudTest.php \Drupal\Tests\rdf\Kernel\CrudTest::testBundleMapping()
  2. 10 core/modules/rdf/tests/src/Kernel/CrudTest.php \Drupal\Tests\rdf\Kernel\CrudTest::testBundleMapping()

Tests the handling of bundle mappings.

File

core/modules/rdf/tests/src/Kernel/CrudTest.php, line 58

Class

CrudTest
Tests the RDF mapping CRUD functions.

Namespace

Drupal\Tests\rdf\Kernel

Code

public function testBundleMapping() {

  // Test that the bundle mapping can be saved.
  $types = [
    'sioc:Post',
    'foaf:Document',
  ];
  rdf_get_mapping($this->entityType, $this->bundle)
    ->setBundleMapping([
    'types' => $types,
  ])
    ->save();
  $bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
    ->getBundleMapping();
  $this
    ->assertEquals($types, $bundle_mapping['types'], 'Bundle mapping saved.');

  // Test that the bundle mapping can be edited.
  $types = [
    'schema:BlogPosting',
  ];
  rdf_get_mapping($this->entityType, $this->bundle)
    ->setBundleMapping([
    'types' => $types,
  ])
    ->save();
  $bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
    ->getBundleMapping();
  $this
    ->assertEquals($types, $bundle_mapping['types'], 'Bundle mapping updated.');
}