Upgraded drupal core with security updates
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / RdfMapping / RdfMappingResourceTestBase.php
1 <?php
2
3 namespace Drupal\Tests\rest\Functional\EntityResource\RdfMapping;
4
5 use Drupal\node\Entity\NodeType;
6 use Drupal\rdf\Entity\RdfMapping;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
8
9 abstract class RdfMappingResourceTestBase extends EntityResourceTestBase {
10
11   /**
12    * {@inheritdoc}
13    */
14   public static $modules = ['node', 'rdf'];
15
16   /**
17    * {@inheritdoc}
18    */
19   protected static $entityTypeId = 'rdf_mapping';
20
21   /**
22    * @var \Drupal\rdf\RdfMappingInterface
23    */
24   protected $entity;
25
26   /**
27    * {@inheritdoc}
28    */
29   protected function setUpAuthorization($method) {
30     $this->grantPermissionsToTestedRole(['administer site configuration']);
31   }
32
33   /**
34    * {@inheritdoc}
35    */
36   protected function createEntity() {
37     // Create a "Camelids" node type.
38     $camelids = NodeType::create([
39       'name' => 'Camelids',
40       'type' => 'camelids',
41     ]);
42
43     $camelids->save();
44
45     // Create the RDF mapping.
46     $llama = RdfMapping::create([
47       'targetEntityType' => 'node',
48       'bundle' => 'camelids',
49     ]);
50     $llama->setBundleMapping([
51       'types' => ['sioc:Item', 'foaf:Document'],
52     ])
53       ->setFieldMapping('title', [
54         'properties' => ['dc:title'],
55       ])
56       ->setFieldMapping('created', [
57         'properties' => ['dc:date', 'dc:created'],
58         'datatype' => 'xsd:dateTime',
59         'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
60       ])
61       ->save();
62
63     return $llama;
64   }
65
66   /**
67    * {@inheritdoc}
68    */
69   protected function getExpectedNormalizedEntity() {
70     return [
71       'bundle' => 'camelids',
72       'dependencies' => [
73         'config' => [
74           'node.type.camelids',
75         ],
76         'module' => [
77           'node',
78         ],
79       ],
80       'fieldMappings' => [
81         'title' => [
82           'properties' => [
83             'dc:title',
84           ],
85         ],
86         'created' => [
87           'properties' => [
88             'dc:date',
89             'dc:created',
90           ],
91           'datatype' => 'xsd:dateTime',
92           'datatype_callback' => [
93             'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
94           ],
95         ],
96       ],
97       'id' => 'node.camelids',
98       'langcode' => 'en',
99       'status' => TRUE,
100       'targetEntityType' => 'node',
101       'types' => [
102         'sioc:Item',
103         'foaf:Document',
104       ],
105       'uuid' => $this->entity->uuid(),
106     ];
107   }
108
109   /**
110    * {@inheritdoc}
111    */
112   protected function getNormalizedPostEntity() {
113     // @todo Update in https://www.drupal.org/node/2300677.
114   }
115
116   /**
117    * {@inheritdoc}
118    */
119   protected function getExpectedCacheContexts() {
120     return [
121       'user.permissions',
122     ];
123   }
124
125 }