3 namespace Drupal\Tests\rest\Functional\EntityResource\RdfMapping;
5 use Drupal\node\Entity\NodeType;
6 use Drupal\rdf\Entity\RdfMapping;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
9 abstract class RdfMappingResourceTestBase extends EntityResourceTestBase {
14 public static $modules = ['node', 'rdf'];
19 protected static $entityTypeId = 'rdf_mapping';
22 * @var \Drupal\rdf\RdfMappingInterface
29 protected function setUpAuthorization($method) {
30 $this->grantPermissionsToTestedRole(['administer site configuration']);
36 protected function createEntity() {
37 // Create a "Camelids" node type.
38 $camelids = NodeType::create([
45 // Create the RDF mapping.
46 $llama = RdfMapping::create([
47 'targetEntityType' => 'node',
48 'bundle' => 'camelids',
50 $llama->setBundleMapping([
51 'types' => ['sioc:Item', 'foaf:Document'],
53 ->setFieldMapping('title', [
54 'properties' => ['dc:title'],
56 ->setFieldMapping('created', [
57 'properties' => ['dc:date', 'dc:created'],
58 'datatype' => 'xsd:dateTime',
59 'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
69 protected function getExpectedNormalizedEntity() {
71 'bundle' => 'camelids',
91 'datatype' => 'xsd:dateTime',
92 'datatype_callback' => [
93 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
97 'id' => 'node.camelids',
100 'targetEntityType' => 'node',
105 'uuid' => $this->entity->uuid(),
112 protected function getNormalizedPostEntity() {
113 // @todo Update in https://www.drupal.org/node/2300677.
119 protected function getExpectedCacheContexts() {