You are here

protected function RdfUiContentMappingTest::testNodeTypeCreation in Schema.org configuration tool (RDF UI) 8

Tests creating a content type mapping via UI.

File

src/Tests/RdfUiContentMappingTest.php, line 37

Class

RdfUiContentMappingTest
Tests related to adding and editing RDF mappings for node types.

Namespace

Drupal\rdfui\Tests

Code

protected function testNodeTypeCreation() {

  // Create a content type via the user interface.
  $web_user = $this
    ->drupalCreateUser(array(
    'bypass node access',
    'administer content types',
  ));
  $this
    ->drupalLogin($web_user);
  $edit = array(
    'name' => 'foo',
    'title_label' => 'title for foo',
    'type' => 'foo',
    'types' => 'schema:Person',
  );
  $this
    ->drupalPostForm('admin/structure/types/add', $edit, t('Save and manage fields'));
  $type_exists = (bool) \Drupal::service('entity_type.manager')
    ->getStorage('node_type')
    ->load('foo');
  $this
    ->assertTrue($type_exists, 'The new content type has been created in the database.');
  $mapping = rdf_get_mapping('node', 'foo');
  $bundle_mapping = $mapping
    ->getBundleMapping();
  $type = $bundle_mapping['types'][0];
  $this
    ->assertEqual($type, $edit['types'], 'Content mapping saved correctly.');
}