View source
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\node\Entity\NodeType;
use Drupal\rdf\Entity\RdfMapping;
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
abstract class RdfMappingResourceTestBase extends EntityResourceTestBase {
protected static $modules = [
'node',
'rdf',
];
protected static $entityTypeId = 'rdf_mapping';
protected $entity;
protected function setUpAuthorization($method) {
$this
->grantPermissionsToTestedRole([
'administer site configuration',
]);
}
protected function createEntity() {
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
]);
$camelids
->save();
$llama = RdfMapping::create([
'targetEntityType' => 'node',
'bundle' => 'camelids',
]);
$llama
->setBundleMapping([
'types' => [
'sioc:Item',
'foaf:Document',
],
])
->setFieldMapping('title', [
'properties' => [
'dc:title',
],
])
->setFieldMapping('created', [
'properties' => [
'dc:date',
'dc:created',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
],
])
->save();
return $llama;
}
protected function getExpectedNormalizedEntity() {
return [
'bundle' => 'camelids',
'dependencies' => [
'config' => [
'node.type.camelids',
],
'module' => [
'node',
],
],
'fieldMappings' => [
'title' => [
'properties' => [
'dc:title',
],
],
'created' => [
'properties' => [
'dc:date',
'dc:created',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
],
],
],
'id' => 'node.camelids',
'langcode' => 'en',
'status' => TRUE,
'targetEntityType' => 'node',
'types' => [
'sioc:Item',
'foaf:Document',
],
'uuid' => $this->entity
->uuid(),
];
}
protected function getNormalizedPostEntity() {
}
protected function getExpectedCacheContexts() {
return [
'user.permissions',
];
}
}