You are here

public function MigrateRdfMappingTest::testRdfMappingMigration in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/rdf/tests/src/Kernel/Migrate/d7/MigrateRdfMappingTest.php \Drupal\Tests\rdf\Kernel\Migrate\d7\MigrateRdfMappingTest::testRdfMappingMigration()
  2. 10 core/modules/rdf/tests/src/Kernel/Migrate/d7/MigrateRdfMappingTest.php \Drupal\Tests\rdf\Kernel\Migrate\d7\MigrateRdfMappingTest::testRdfMappingMigration()

Tests RDF mappings migration from Drupal 7 to 8.

File

core/modules/rdf/tests/src/Kernel/Migrate/d7/MigrateRdfMappingTest.php, line 65

Class

MigrateRdfMappingTest
Tests RDF mappings migration from Drupal 7 to 8.

Namespace

Drupal\Tests\rdf\Kernel\Migrate\d7

Code

public function testRdfMappingMigration() {
  $this
    ->assertRdfMapping('node', 'article', [
    'types' => [
      'sioc:Item',
      'foaf:Document',
    ],
  ], [
    'field_image' => [
      'properties' => [
        'og:image',
        'rdfs:seeAlso',
      ],
      'mapping_type' => 'rel',
    ],
    'field_tags' => [
      'properties' => [
        'dc:subject',
      ],
      'mapping_type' => 'rel',
    ],
    'title' => [
      'properties' => [
        'dc:title',
      ],
    ],
    'created' => [
      'properties' => [
        'dc:date',
        'dc:created',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'changed' => [
      'properties' => [
        'dc:modified',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'body' => [
      'properties' => [
        'content:encoded',
      ],
    ],
    'uid' => [
      'properties' => [
        'sioc:has_creator',
      ],
      'mapping_type' => 'rel',
    ],
    'name' => [
      'properties' => [
        'foaf:name',
      ],
    ],
    'comment_count' => [
      'properties' => [
        'sioc:num_replies',
      ],
      'datatype' => 'xsd:integer',
    ],
    'last_activity' => [
      'properties' => [
        'sioc:last_activity_date',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
  ]);
  $this
    ->assertRdfMapping('node', 'blog', [
    'types' => [
      'sioc:Post',
      'sioct:BlogPost',
    ],
  ], [
    'title' => [
      'properties' => [
        'dc:title',
      ],
    ],
    'created' => [
      'properties' => [
        'dc:date',
        'dc:created',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'changed' => [
      'properties' => [
        'dc:modified',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'body' => [
      'properties' => [
        'content:encoded',
      ],
    ],
    'uid' => [
      'properties' => [
        'sioc:has_creator',
      ],
      'mapping_type' => 'rel',
    ],
    'name' => [
      'properties' => [
        'foaf:name',
      ],
    ],
    'comment_count' => [
      'properties' => [
        'sioc:num_replies',
      ],
      'datatype' => 'xsd:integer',
    ],
    'last_activity' => [
      'properties' => [
        'sioc:last_activity_date',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
  ]);
  $this
    ->assertRdfMapping('node', 'forum', [
    'types' => [
      'sioc:Post',
      'sioct:BoardPost',
    ],
  ], [
    'taxonomy_forums' => [
      'properties' => [
        'sioc:has_container',
      ],
      'mapping_type' => 'rel',
    ],
    'title' => [
      'properties' => [
        'dc:title',
      ],
    ],
    'created' => [
      'properties' => [
        'dc:date',
        'dc:created',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'changed' => [
      'properties' => [
        'dc:modified',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'body' => [
      'properties' => [
        'content:encoded',
      ],
    ],
    'uid' => [
      'properties' => [
        'sioc:has_creator',
      ],
      'mapping_type' => 'rel',
    ],
    'name' => [
      'properties' => [
        'foaf:name',
      ],
    ],
    'comment_count' => [
      'properties' => [
        'sioc:num_replies',
      ],
      'datatype' => 'xsd:integer',
    ],
    'last_activity' => [
      'properties' => [
        'sioc:last_activity_date',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
  ]);
  $this
    ->assertRdfMapping('node', 'page', [
    'types' => [
      'foaf:Document',
    ],
  ], [
    'title' => [
      'properties' => [
        'dc:title',
      ],
    ],
    'created' => [
      'properties' => [
        'dc:date',
        'dc:created',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'changed' => [
      'properties' => [
        'dc:modified',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
    'body' => [
      'properties' => [
        'content:encoded',
      ],
    ],
    'uid' => [
      'properties' => [
        'sioc:has_creator',
      ],
      'mapping_type' => 'rel',
    ],
    'name' => [
      'properties' => [
        'foaf:name',
      ],
    ],
    'comment_count' => [
      'properties' => [
        'sioc:num_replies',
      ],
      'datatype' => 'xsd:integer',
    ],
    'last_activity' => [
      'properties' => [
        'sioc:last_activity_date',
      ],
      'datatype' => 'xsd:dateTime',
      'datatype_callback' => [
        'callable' => 'Drupal\\rdf\\CommonDataConverter::dateIso8601Value',
      ],
    ],
  ]);
  $this
    ->assertRdfMapping('taxonomy_term', 'forums', [
    'types' => [
      'sioc:Container',
      'sioc:Forum',
    ],
  ], [
    'name' => [
      'properties' => [
        'rdfs:label',
        'skos:prefLabel',
      ],
    ],
    'description' => [
      'properties' => [
        'skos:definition',
      ],
    ],
    'vid' => [
      'properties' => [
        'skos:inScheme',
      ],
      'mapping_type' => 'rel',
    ],
    'parent' => [
      'properties' => [
        'skos:broader',
      ],
      'mapping_type' => 'rel',
    ],
  ]);

  // Clear the map table and check that the migration runs successfully when
  // the rdf mappings already exist.
  $id_map = $this
    ->getMigration('d7_rdf_mapping')
    ->getIdMap();
  $id_map
    ->destroy();
  $this
    ->executeMigration('d7_rdf_mapping');
}