3 namespace Drupal\Tests\rdf\Kernel\Migrate\d7;
5 use Drupal\rdf\RdfMappingInterface;
6 use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
9 * Tests RDF mappings migration from Drupal 7 to 8.
13 class MigrateRdfMappingTest extends MigrateDrupal7TestBase {
18 public static $modules = [
29 protected function setUp() {
32 $this->installConfig(static::$modules);
34 $this->executeMigrations([
36 'd7_taxonomy_vocabulary',
42 * Asserts various aspects of a RDF mapping.
44 * @param string $entity_type
46 * @param string $bundle
48 * @param string[] $types
49 * The expected RDF types.
50 * @param array[] $field_mappings
51 * The expected RDF field mappings.
53 protected function assertRdfMapping($entity_type, $bundle, $types, $field_mappings) {
54 $rdf_mapping = rdf_get_mapping($entity_type, $bundle);
55 $this->assertInstanceOf(RdfMappingInterface::class, $rdf_mapping);
56 $this->assertSame($types, $rdf_mapping->getBundleMapping());
57 foreach ($field_mappings as $field => $mapping) {
58 $this->assertSame($mapping, $rdf_mapping->getFieldMapping($field));
63 * Tests RDF mappings migration from Drupal 7 to 8.
65 public function testRdfMappingMigration() {
66 $this->assertRdfMapping(
81 'mapping_type' => 'rel',
87 'mapping_type' => 'rel',
99 'datatype' => 'xsd:dateTime',
100 'datatype_callback' => [
101 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
108 'datatype' => 'xsd:dateTime',
109 'datatype_callback' => [
110 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
122 'mapping_type' => 'rel',
133 'datatype' => 'xsd:integer',
137 'sioc:last_activity_date',
139 'datatype' => 'xsd:dateTime',
140 'datatype_callback' => [
141 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
146 $this->assertRdfMapping(
166 'datatype' => 'xsd:dateTime',
167 'datatype_callback' => [
168 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
175 'datatype' => 'xsd:dateTime',
176 'datatype_callback' => [
177 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
189 'mapping_type' => 'rel',
200 'datatype' => 'xsd:integer',
204 'sioc:last_activity_date',
206 'datatype' => 'xsd:dateTime',
207 'datatype_callback' => [
208 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
213 $this->assertRdfMapping(
223 'taxonomy_forums' => [
225 'sioc:has_container',
227 'mapping_type' => 'rel',
239 'datatype' => 'xsd:dateTime',
240 'datatype_callback' => [
241 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
248 'datatype' => 'xsd:dateTime',
249 'datatype_callback' => [
250 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
262 'mapping_type' => 'rel',
273 'datatype' => 'xsd:integer',
277 'sioc:last_activity_date',
279 'datatype' => 'xsd:dateTime',
280 'datatype_callback' => [
281 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
286 $this->assertRdfMapping(
305 'datatype' => 'xsd:dateTime',
306 'datatype_callback' => [
307 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
314 'datatype' => 'xsd:dateTime',
315 'datatype_callback' => [
316 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
328 'mapping_type' => 'rel',
339 'datatype' => 'xsd:integer',
343 'sioc:last_activity_date',
345 'datatype' => 'xsd:dateTime',
346 'datatype_callback' => [
347 'callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value',
352 $this->assertRdfMapping(
377 'mapping_type' => 'rel',
383 'mapping_type' => 'rel',
388 // Clear the map table and check that the migration runs successfully when
389 // the rdf mappings already exist.
390 $id_map = $this->getMigration('d7_rdf_mapping')->getIdMap();
392 $this->executeMigration('d7_rdf_mapping');