public function RdfMappingEventTest::testMapInputType

Test that other modules can define incoming type mappings.

File

drupal/core/modules/rdf/lib/Drupal/rdf/Tests/RdfMappingEventTest.php, line 43
Contains RdfMappingEventTest.

Class

RdfMappingEventTest
Test the RDF mapping events.

Namespace

Drupal\rdf\Tests

Code

public function testMapInputType() {
  $dispatcher = new EventDispatcher();
  $dispatcher
    ->addSubscriber(new MappingSubscriber());
  $dispatcher
    ->addSubscriber(new TestMappingSubscriber());
  $site_schema_manager = new SiteSchemaManager($this->container
    ->get('cache.cache'));
  $mapping_manager = new RdfMappingManager($dispatcher, $site_schema_manager);

  // Test that a site schema URI is mapped to itself. This is the default
  // behavior.
  $schema = new SiteSchema(SiteSchema::CONTENT_DEPLOYMENT);
  $bundle_schema = $schema
    ->bundle('entity_test', 'entity_test');
  $site_schema_type = $bundle_schema
    ->getUri();
  $typed_data_ids = $mapping_manager
    ->getTypedDataIdsFromTypeUris(array(
    $site_schema_type,
  ));
  $this
    ->assertTrue($typed_data_ids['bundle'] == 'entity_test', 'An internal site schema type URI is properly handled.');

  // Test that a module can map an external URI to a site schema URI.
  $typed_data_ids = $mapping_manager
    ->getTypedDataIdsFromTypeUris(array(
    TestMappingSubscriber::STAGING_SITE_TYPE_URI,
  ));
  $this
    ->assertTrue($typed_data_ids['bundle'] == 'entity_test', 'Modules can map external type URIs to a site schema type.');
}