View source
<?php
namespace Drupal\rdfui\Tests;
use Drupal\field\Entity\FieldInstanceConfig;
use Drupal\node\Tests\NodeTestBase;
class RdfUiContentMappingTest extends NodeTestBase {
public static $modules = array(
'rdfui',
'rdf',
'field_ui',
);
public static function getInfo() {
return array(
'name' => 'RDF UI Content Mapping',
'description' => 'Ensures that the RDF mappings for a Content type works correctly.',
'group' => 'RDF UI',
);
}
protected function testNodeTypeCreation() {
$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.');
}
protected function testNodeTypeEditing() {
$web_user = $this
->drupalCreateUser(array(
'bypass node access',
'administer content types',
'administer node fields',
));
$this
->drupalLogin($web_user);
$edit_type = 'admin/structure/types/manage/page';
$this
->drupalGet($edit_type);
$this
->assertRaw('Schema.org Mappings', 'Schema.Org tab found.');
$this
->assertRaw('Schema.org Type', 'Schema.Org tab content found.');
$edit = array(
'types' => 'schema:Person',
);
$this
->drupalPostForm($edit_type, $edit, t('Save content type'));
$mapping = rdf_get_mapping('node', 'page');
$type = $mapping
->getBundleMapping();
$this
->assertEqual($type['types'][0], $edit['types'], 'Content mapping saved correctly.');
}
}