updated core to 8.6.1 via composer

This commit is contained in:
2018-09-12 13:58:26 +02:00
parent a9a219f2ed
commit ea56b9fba3
4443 changed files with 112098 additions and 40708 deletions
@@ -0,0 +1,26 @@
id: d7_rdf_mapping
label: Drupal 7 RDF Mappings
migration_tags:
- Drupal 7
- Configuration
source:
plugin: d7_rdf_mapping
process:
targetEntityType: type
bundle: bundle
types: types
fieldMappings:
plugin: sub_process
source: fieldMappings
process:
properties: predicates
datatype: datatype
datatype_callback/callable: callback
mapping_type: type
destination:
plugin: entity:rdf_mapping
migration_dependencies:
optional:
- d7_comment_type
- d7_node_type
- d7_taxonomy_vocabulary
+1 -1
View File
@@ -38,6 +38,7 @@ function rdf_help($route_name, RouteMatchInterface $route_match) {
* into variables available to theme functions and templates. All Drupal core
* themes are coded to be RDFa compatible.
*/
/**
* Returns the RDF mapping object associated with a bundle.
*
@@ -293,7 +294,6 @@ function _rdf_set_field_rel_attribute(&$variables) {
}
}
/**
* Implements hook_preprocess_HOOK() for node templates.
*/
@@ -0,0 +1,70 @@
<?php
namespace Drupal\rdf\Plugin\migrate\source\d7;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 7 rdf source from database.
*
* @MigrateSource(
* id = "d7_rdf_mapping",
* source_module = "rdf"
* )
*/
class RdfMapping extends DrupalSqlBase {
/**
* {@inheritdoc}
*/
public function query() {
return $this->select('rdf_mapping', 'r')->fields('r');
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
$field_mappings = [];
foreach (unserialize($row->getSourceProperty('mapping')) as $field => $mapping) {
if ($field === 'rdftype') {
$row->setSourceProperty('types', $mapping);
}
else {
$field_mappings[$field] = $mapping;
}
}
$row->setSourceProperty('fieldMappings', $field_mappings);
return parent::prepareRow($row);
}
/**
* {@inheritdoc}
*/
public function fields() {
return [
'type' => $this->t('The name of the entity type a mapping applies to (node, user, comment, etc.'),
'bundle' => $this->t('The name of the bundle a mapping applies to.'),
'mapping' => $this->t('The serialized mapping of the bundle type and fields to RDF terms.'),
'types' => $this->t('RDF types.'),
'fieldMappings' => $this->t('RDF field mappings.'),
];
}
/**
* {@inheritdoc}
*/
public function getIds() {
return [
'type' => [
'type' => 'string',
],
'bundle' => [
'type' => 'string',
],
];
}
}
@@ -1,50 +0,0 @@
<?php
namespace Drupal\rdf\Tests;
use Drupal\simpletest\WebTestBase;
/**
* Confirm that the serialization of RDF namespaces in present in the HTML
* markup.
*
* @group rdf
*/
class GetNamespacesTest extends WebTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['rdf', 'rdf_test_namespaces'];
/**
* Tests RDF namespaces.
*/
public function testGetRdfNamespaces() {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'rdfs: http://www.w3.org/2000/01/rdf-schema#',
]);
$this->assertTrue(!empty($element), 'A prefix declared once is displayed.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf: http://xmlns.com/foaf/0.1/',
]);
$this->assertTrue(!empty($element), 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'foaf1: http://xmlns.com/foaf/0.1/',
]);
$this->assertTrue(!empty($element), 'Two prefixes can be assigned the same namespace.');
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', [
':prefix_binding' => 'dc: http://purl.org/dc/terms/',
]);
$this->assertTrue(!empty($element), 'When a prefix has conflicting namespaces, the first declared one is used.');
}
}
@@ -5,4 +5,4 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- rdf
- drupal:rdf
@@ -0,0 +1,8 @@
name: 'RDF test module'
type: module
description: 'Test functionality for the RDF module.'
package: Testing
version: VERSION
core: 8.x
dependencies:
- rdf
@@ -1,6 +1,6 @@
<?php
namespace Drupal\rdf\Tests\Field;
namespace Drupal\rdf_test;
/**
* Contains methods for test data conversions.
@@ -5,4 +5,4 @@ package: Testing
version: VERSION
core: 8.x
dependencies:
- rdf
- drupal:rdf
@@ -1,10 +1,10 @@
<?php
namespace Drupal\rdf\Tests;
namespace Drupal\Tests\rdf\Functional;
use Drupal\comment\CommentInterface;
use Drupal\comment\CommentManagerInterface;
use Drupal\comment\Tests\CommentTestBase;
use Drupal\Tests\comment\Functional\CommentTestBase;
use Drupal\user\RoleInterface;
use Drupal\comment\Entity\Comment;
@@ -2,7 +2,7 @@
namespace Drupal\Tests\rdf\Functional;
use Drupal\file\Tests\FileFieldTestBase;
use Drupal\Tests\file\Functional\FileFieldTestBase;
use Drupal\file\Entity\File;
/**
@@ -22,6 +22,25 @@ class GetRdfNamespacesTest extends BrowserTestBase {
* Tests getting RDF namespaces.
*/
public function testGetRdfNamespaces() {
// Fetches the front page and extracts RDFa 1.1 prefixes.
$this->drupalGet('');
// We have to use the find() method on the driver directly because //html is
// prepended to all xpath queries otherwise.
$driver = $this->getSession()->getDriver();
$element = $driver->find('//html[contains(@prefix, "rdfs: http://www.w3.org/2000/01/rdf-schema#")]');
$this->assertCount(1, $element, 'A prefix declared once is displayed.');
$element = $driver->find('//html[contains(@prefix, "foaf: http://xmlns.com/foaf/0.1/")]');
$this->assertCount(1, $element, 'The same prefix declared in several implementations of hook_rdf_namespaces() is valid as long as all the namespaces are the same.');
$element = $driver->find('//html[contains(@prefix, "foaf1: http://xmlns.com/foaf/0.1/")]');
$this->assertCount(1, $element, 'Two prefixes can be assigned the same namespace.');
$element = $driver->find('//html[contains(@prefix, "dc: http://purl.org/dc/terms/")]');
$this->assertCount(1, $element, 'When a prefix has conflicting namespaces, the first declared one is used.');
// Get all RDF namespaces.
$ns = rdf_get_namespaces();
@@ -0,0 +1,30 @@
<?php
namespace Drupal\Tests\rdf\Functional\Hal;
use Drupal\Tests\rdf\Functional\Rest\RdfMappingResourceTestBase;
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
/**
* @group hal
*/
class RdfMappingHalJsonAnonTest extends RdfMappingResourceTestBase {
use AnonResourceTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['hal'];
/**
* {@inheritdoc}
*/
protected static $format = 'hal_json';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'application/hal+json';
}
@@ -0,0 +1,35 @@
<?php
namespace Drupal\Tests\rdf\Functional\Hal;
use Drupal\Tests\rdf\Functional\Rest\RdfMappingResourceTestBase;
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
/**
* @group hal
*/
class RdfMappingHalJsonBasicAuthTest extends RdfMappingResourceTestBase {
use BasicAuthResourceTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['hal', 'basic_auth'];
/**
* {@inheritdoc}
*/
protected static $format = 'hal_json';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'application/hal+json';
/**
* {@inheritdoc}
*/
protected static $auth = 'basic_auth';
}
@@ -0,0 +1,35 @@
<?php
namespace Drupal\Tests\rdf\Functional\Hal;
use Drupal\Tests\rdf\Functional\Rest\RdfMappingResourceTestBase;
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
/**
* @group hal
*/
class RdfMappingHalJsonCookieTest extends RdfMappingResourceTestBase {
use CookieResourceTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['hal'];
/**
* {@inheritdoc}
*/
protected static $format = 'hal_json';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'application/hal+json';
/**
* {@inheritdoc}
*/
protected static $auth = 'cookie';
}
@@ -1,11 +1,12 @@
<?php
namespace Drupal\rdf\Tests;
namespace Drupal\Tests\rdf\Functional;
use Drupal\image\Entity\ImageStyle;
use Drupal\image\Tests\ImageFieldTestBase;
use Drupal\Tests\image\Functional\ImageFieldTestBase;
use Drupal\node\Entity\Node;
use Drupal\file\Entity\File;
use Drupal\Tests\TestFileCreationTrait;
/**
* Tests the RDFa markup of imagefields.
@@ -14,6 +15,10 @@ use Drupal\file\Entity\File;
*/
class ImageFieldAttributesTest extends ImageFieldTestBase {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* Modules to enable.
*
@@ -2,7 +2,7 @@
namespace Drupal\Tests\rdf\Functional;
use Drupal\node\Tests\NodeTestBase;
use Drupal\Tests\node\Functional\NodeTestBase;
/**
* Tests the RDFa markup of Nodes.
@@ -0,0 +1,24 @@
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
/**
* @group rest
*/
class RdfMappingJsonAnonTest extends RdfMappingResourceTestBase {
use AnonResourceTestTrait;
/**
* {@inheritdoc}
*/
protected static $format = 'json';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'application/json';
}
@@ -0,0 +1,34 @@
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
/**
* @group rest
*/
class RdfMappingJsonBasicAuthTest extends RdfMappingResourceTestBase {
use BasicAuthResourceTestTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['basic_auth'];
/**
* {@inheritdoc}
*/
protected static $format = 'json';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'application/json';
/**
* {@inheritdoc}
*/
protected static $auth = 'basic_auth';
}
@@ -0,0 +1,29 @@
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
/**
* @group rest
*/
class RdfMappingJsonCookieTest extends RdfMappingResourceTestBase {
use CookieResourceTestTrait;
/**
* {@inheritdoc}
*/
protected static $format = 'json';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'application/json';
/**
* {@inheritdoc}
*/
protected static $auth = 'cookie';
}
@@ -0,0 +1,125 @@
<?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 {
/**
* {@inheritdoc}
*/
public static $modules = ['node', 'rdf'];
/**
* {@inheritdoc}
*/
protected static $entityTypeId = 'rdf_mapping';
/**
* @var \Drupal\rdf\RdfMappingInterface
*/
protected $entity;
/**
* {@inheritdoc}
*/
protected function setUpAuthorization($method) {
$this->grantPermissionsToTestedRole(['administer site configuration']);
}
/**
* {@inheritdoc}
*/
protected function createEntity() {
// Create a "Camelids" node type.
$camelids = NodeType::create([
'name' => 'Camelids',
'type' => 'camelids',
]);
$camelids->save();
// Create the RDF mapping.
$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;
}
/**
* {@inheritdoc}
*/
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(),
];
}
/**
* {@inheritdoc}
*/
protected function getNormalizedPostEntity() {
// @todo Update in https://www.drupal.org/node/2300677.
}
/**
* {@inheritdoc}
*/
protected function getExpectedCacheContexts() {
return [
'user.permissions',
];
}
}
@@ -0,0 +1,26 @@
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
/**
* @group rest
*/
class RdfMappingXmlAnonTest extends RdfMappingResourceTestBase {
use AnonResourceTestTrait;
use XmlEntityNormalizationQuirksTrait;
/**
* {@inheritdoc}
*/
protected static $format = 'xml';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'text/xml; charset=UTF-8';
}
@@ -0,0 +1,36 @@
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
/**
* @group rest
*/
class RdfMappingXmlBasicAuthTest extends RdfMappingResourceTestBase {
use BasicAuthResourceTestTrait;
use XmlEntityNormalizationQuirksTrait;
/**
* {@inheritdoc}
*/
public static $modules = ['basic_auth'];
/**
* {@inheritdoc}
*/
protected static $format = 'xml';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'text/xml; charset=UTF-8';
/**
* {@inheritdoc}
*/
protected static $auth = 'basic_auth';
}
@@ -0,0 +1,31 @@
<?php
namespace Drupal\Tests\rdf\Functional\Rest;
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
/**
* @group rest
*/
class RdfMappingXmlCookieTest extends RdfMappingResourceTestBase {
use CookieResourceTestTrait;
use XmlEntityNormalizationQuirksTrait;
/**
* {@inheritdoc}
*/
protected static $format = 'xml';
/**
* {@inheritdoc}
*/
protected static $mimeType = 'text/xml; charset=UTF-8';
/**
* {@inheritdoc}
*/
protected static $auth = 'cookie';
}
@@ -136,7 +136,7 @@ class StandardProfileTest extends BrowserTestBase {
$this->term->save();
// Create image.
file_unmanaged_copy(\Drupal::root() . '/core/misc/druplicon.png', 'public://example.jpg');
file_unmanaged_copy($this->root . '/core/misc/druplicon.png', 'public://example.jpg');
$this->image = File::create(['uri' => 'public://example.jpg']);
$this->image->save();
@@ -45,7 +45,7 @@ class UserAttributesTest extends BrowserTestBase {
$authors = [
$this->drupalCreateUser([], $this->randomMachineName(30)),
$this->drupalCreateUser([], $this->randomMachineName(20)),
$this->drupalCreateUser([], $this->randomMachineName(5))
$this->drupalCreateUser([], $this->randomMachineName(5)),
];
$this->drupalLogin($user1);
@@ -19,7 +19,7 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['text', 'filter'];
public static $modules = ['text', 'filter', 'rdf_test'];
protected function setUp() {
parent::setUp();
@@ -33,7 +33,7 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
$mapping->setFieldMapping($this->fieldName, [
'properties' => ['schema:interactionCount'],
'datatype_callback' => [
'callable' => 'Drupal\rdf\Tests\Field\TestDataConverter::convertFoo',
'callable' => 'Drupal\rdf_test\TestDataConverter::convertFoo',
],
])->save();
@@ -42,7 +42,7 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
*/
public function testAllFormattersExternal() {
// Set up test values.
$this->testValue = 'http://test.me/foo/bar/neque/porro/quisquam/est/qui-dolorem?foo/bar/neque/porro/quisquam/est/qui-dolorem';
$this->testValue = 'http://test.me/foo/bar/neque/porro/quisquam/est/qui-dolorem?path=foo/bar/neque/porro/quisquam/est/qui-dolorem';
$this->entity = EntityTest::create([]);
$this->entity->{$this->fieldName}->uri = $this->testValue;
@@ -0,0 +1,389 @@
<?php
namespace Drupal\Tests\rdf\Kernel\Migrate\d7;
use Drupal\rdf\RdfMappingInterface;
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
/**
* Tests RDF mappings migration from Drupal 7 to 8.
*
* @group rdf
*/
class MigrateRdfMappingTest extends MigrateDrupal7TestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'menu_ui',
'node',
'rdf',
'taxonomy',
'text',
];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installConfig(static::$modules);
$this->executeMigrations([
'd7_node_type',
'd7_taxonomy_vocabulary',
'd7_rdf_mapping',
]);
}
/**
* Asserts various aspects of a RDF mapping.
*
* @param string $entity_type
* The entity type.
* @param string $bundle
* The bundle.
* @param string[] $types
* The expected RDF types.
* @param array[] $field_mappings
* The expected RDF field mappings.
*/
protected function assertRdfMapping($entity_type, $bundle, $types, $field_mappings) {
$rdf_mapping = rdf_get_mapping($entity_type, $bundle);
$this->assertInstanceOf(RdfMappingInterface::class, $rdf_mapping);
$this->assertSame($types, $rdf_mapping->getBundleMapping());
foreach ($field_mappings as $field => $mapping) {
$this->assertSame($mapping, $rdf_mapping->getFieldMapping($field));
}
}
/**
* Tests RDF mappings migration from Drupal 7 to 8.
*/
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' => 'date_iso8601',
],
],
'changed' => [
'properties' => [
'dc:modified',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'date_iso8601',
],
],
'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' => 'date_iso8601',
],
],
]
);
$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' => 'date_iso8601',
],
],
'changed' => [
'properties' => [
'dc:modified',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'date_iso8601',
],
],
'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' => 'date_iso8601',
],
],
]
);
$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' => 'date_iso8601',
],
],
'changed' => [
'properties' => [
'dc:modified',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'date_iso8601',
],
],
'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' => 'date_iso8601',
],
],
]
);
$this->assertRdfMapping(
'node',
'page',
[
'types' => [
'foaf:Document',
],
],
[
'title' => [
'properties' => [
'dc:title',
],
],
'created' => [
'properties' => [
'dc:date',
'dc:created',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'date_iso8601',
],
],
'changed' => [
'properties' => [
'dc:modified',
],
'datatype' => 'xsd:dateTime',
'datatype_callback' => [
'callable' => 'date_iso8601',
],
],
'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' => 'date_iso8601',
],
],
]
);
$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',
],
]
);
}
}
@@ -0,0 +1,228 @@
<?php
namespace Drupal\Tests\rdf\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests Drupal 7 RDF mappings source plugin.
*
* @covers \Drupal\rdf\Plugin\migrate\source\d7\RdfMapping
*
* @group rdf
*/
class RdfMappingTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'comment',
'migrate_drupal',
'node',
'rdf',
'taxonomy',
'user',
];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['rdf_mapping'] = [
[
'type' => 'comment',
'bundle' => 'comment_node_article',
'mapping' => 'a:8:{s:7:"rdftype";a:2:{i:0;s:9:"sioc:Post";i:1;s:13:"sioct:Comment";}s:5:"title";a:1:{s:10:"predicates";a:1:{i:0;s:8:"dc:title";}}s:7:"created";a:3:{s:10:"predicates";a:2:{i:0;s:7:"dc:date";i:1;s:10:"dc:created";}s:8:"datatype";s:12:"xsd:dateTime";s:8:"callback";s:12:"date_iso8601";}s:7:"changed";a:3:{s:10:"predicates";a:1:{i:0;s:11:"dc:modified";}s:8:"datatype";s:12:"xsd:dateTime";s:8:"callback";s:12:"date_iso8601";}s:12:"comment_body";a:1:{s:10:"predicates";a:1:{i:0;s:15:"content:encoded";}}s:3:"pid";a:2:{s:10:"predicates";a:1:{i:0;s:13:"sioc:reply_of";}s:4:"type";s:3:"rel";}s:3:"uid";a:2:{s:10:"predicates";a:1:{i:0;s:16:"sioc:has_creator";}s:4:"type";s:3:"rel";}s:4:"name";a:1:{s:10:"predicates";a:1:{i:0;s:9:"foaf:name";}}}',
],
[
'type' => 'node',
'bundle' => 'article',
'mapping' => 'a:9:{s:7:"rdftype";a:2:{i:0;s:9:"sioc:Item";i:1;s:13:"foaf:Document";}s:5:"title";a:1:{s:10:"predicates";a:1:{i:0;s:8:"dc:title";}}s:7:"created";a:3:{s:10:"predicates";a:2:{i:0;s:7:"dc:date";i:1;s:10:"dc:created";}s:8:"datatype";s:12:"xsd:dateTime";s:8:"callback";s:12:"date_iso8601";}s:7:"changed";a:3:{s:10:"predicates";a:1:{i:0;s:11:"dc:modified";}s:8:"datatype";s:12:"xsd:dateTime";s:8:"callback";s:12:"date_iso8601";}s:4:"body";a:1:{s:10:"predicates";a:1:{i:0;s:15:"content:encoded";}}s:3:"uid";a:2:{s:10:"predicates";a:1:{i:0;s:16:"sioc:has_creator";}s:4:"type";s:3:"rel";}s:4:"name";a:1:{s:10:"predicates";a:1:{i:0;s:9:"foaf:name";}}s:13:"comment_count";a:2:{s:10:"predicates";a:1:{i:0;s:16:"sioc:num_replies";}s:8:"datatype";s:11:"xsd:integer";}s:13:"last_activity";a:3:{s:10:"predicates";a:1:{i:0;s:23:"sioc:last_activity_date";}s:8:"datatype";s:12:"xsd:dateTime";s:8:"callback";s:12:"date_iso8601";}}',
],
[
'type' => 'taxonomy_term',
'bundle' => 'tags',
'mapping' => 'a:5:{s:7:"rdftype";a:1:{i:0;s:12:"skos:Concept";}s:4:"name";a:1:{s:10:"predicates";a:2:{i:0;s:10:"rdfs:label";i:1;s:14:"skos:prefLabel";}}s:11:"description";a:1:{s:10:"predicates";a:1:{i:0;s:15:"skos:definition";}}s:3:"vid";a:2:{s:10:"predicates";a:1:{i:0;s:13:"skos:inScheme";}s:4:"type";s:3:"rel";}s:6:"parent";a:2:{s:10:"predicates";a:1:{i:0;s:12:"skos:broader";}s:4:"type";s:3:"rel";}}',
],
[
'type' => 'user',
'bundle' => 'user',
'mapping' => 'a:3:{s:7:"rdftype";a:1:{i:0;s:16:"sioc:UserAccount";}s:4:"name";a:1:{s:10:"predicates";a:1:{i:0;s:9:"foaf:name";}}s:8:"homepage";a:2:{s:10:"predicates";a:1:{i:0;s:9:"foaf:page";}s:4:"type";s:3:"rel";}}',
],
];
// The expected results.
$tests[0]['expected_data'] = [
[
'type' => 'comment',
'bundle' => 'comment_node_article',
'types' => [
'sioc:Post',
'sioct:Comment',
],
'fieldMappings' => [
'changed' => [
'predicates' => [
'dc:modified',
],
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
],
'comment_body' => [
'predicates' => [
'content:encoded',
],
],
'created' => [
'predicates' => [
'dc:date',
'dc:created',
],
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
],
'name' => [
'predicates' => [
'foaf:name',
],
],
'pid' => [
'predicates' => [
'sioc:reply_of',
],
'type' => 'rel',
],
'title' => [
'predicates' => [
'dc:title',
],
],
'uid' => [
'predicates' => [
'sioc:has_creator',
],
'type' => 'rel',
],
],
],
[
'type' => 'node',
'bundle' => 'article',
'types' => [
'sioc:Item',
'foaf:Document',
],
'fieldMappings' => [
'body' => [
'predicates' => [
'content:encoded',
],
],
'changed' => [
'predicates' => [
'dc:modified',
],
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
],
'comment_count' => [
'predicates' => [
'sioc:num_replies',
],
'datatype' => 'xsd:integer',
],
'created' => [
'predicates' => [
'dc:date',
'dc:created',
],
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
],
'last_activity' => [
'predicates' => [
'sioc:last_activity_date',
],
'datatype' => 'xsd:dateTime',
'callback' => 'date_iso8601',
],
'name' => [
'predicates' => [
'foaf:name',
],
],
'title' => [
'predicates' => [
'dc:title',
],
],
'uid' => [
'predicates' => [
'sioc:has_creator',
],
'type' => 'rel',
],
],
],
[
'type' => 'taxonomy_term',
'bundle' => 'tags',
'types' => [
'skos:Concept',
],
'fieldMappings' => [
'description' => [
'predicates' => [
'skos:definition',
],
],
'name' => [
'predicates' => [
'rdfs:label',
'skos:prefLabel',
],
],
'parent' => [
'predicates' => [
'skos:broader',
],
'type' => 'rel',
],
'vid' => [
'predicates' => [
'skos:inScheme',
],
'type' => 'rel',
],
],
],
[
'type' => 'user',
'bundle' => 'user',
'types' => [
'sioc:UserAccount',
],
'fieldMappings' => [
'homepage' => [
'predicates' => [
'foaf:page',
],
'type' => 'rel',
],
'name' => [
'predicates' => [
'foaf:name',
],
],
],
],
];
return $tests;
}
}
@@ -73,7 +73,6 @@ class RdfaAttributesTest extends KernelTestBase {
$this->_testAttributes($expected_attributes, $mapping, $date);
}
/**
* Test attribute creation for mappings which use data converters.
*/