Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -5,4 +5,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- rdf
|
||||
- drupal:rdf
|
||||
|
|
8
web/core/modules/rdf/tests/rdf_test/rdf_test.info.yml
Normal file
8
web/core/modules/rdf/tests/rdf_test/rdf_test.info.yml
Normal file
|
@ -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
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf_test;
|
||||
|
||||
/**
|
||||
* Contains methods for test data conversions.
|
||||
*/
|
||||
class TestDataConverter {
|
||||
|
||||
/**
|
||||
* Converts data into a string for placement into a content attribute.
|
||||
*
|
||||
* @param array $data
|
||||
* The data to be altered and placed in the content attribute.
|
||||
*
|
||||
* @return string
|
||||
* Returns the data.
|
||||
*/
|
||||
public static function convertFoo($data) {
|
||||
return 'foo' . $data['value'];
|
||||
}
|
||||
|
||||
}
|
|
@ -5,4 +5,4 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- rdf
|
||||
- drupal:rdf
|
||||
|
|
|
@ -0,0 +1,376 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\comment\CommentInterface;
|
||||
use Drupal\comment\CommentManagerInterface;
|
||||
use Drupal\Tests\comment\Functional\CommentTestBase;
|
||||
use Drupal\user\RoleInterface;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
|
||||
/**
|
||||
* Tests the RDFa markup of comments.
|
||||
*
|
||||
* @group rdf
|
||||
*/
|
||||
class CommentAttributesTest extends CommentTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['views', 'node', 'comment', 'rdf'];
|
||||
|
||||
/**
|
||||
* URI of the front page of the Drupal site.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $baseUri;
|
||||
|
||||
/**
|
||||
* URI of the test node created by CommentTestBase::setUp().
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $nodeUri;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Enables anonymous user comments.
|
||||
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
|
||||
'access comments' => TRUE,
|
||||
'post comments' => TRUE,
|
||||
'skip comment approval' => TRUE,
|
||||
]);
|
||||
// Allows anonymous to leave their contact information.
|
||||
$this->setCommentAnonymous(COMMENT_ANONYMOUS_MAY_CONTACT);
|
||||
$this->setCommentPreview(DRUPAL_OPTIONAL);
|
||||
$this->setCommentForm(TRUE);
|
||||
$this->setCommentSubject(TRUE);
|
||||
$this->setCommentSettings('comment_default_mode', CommentManagerInterface::COMMENT_MODE_THREADED, 'Comment paging changed.');
|
||||
|
||||
// Prepares commonly used URIs.
|
||||
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
|
||||
$this->nodeUri = $this->node->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
// Set relation between node and comment.
|
||||
$article_mapping = rdf_get_mapping('node', 'article');
|
||||
$comment_count_mapping = [
|
||||
'properties' => ['sioc:num_replies'],
|
||||
'datatype' => 'xsd:integer',
|
||||
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::rawValue'],
|
||||
];
|
||||
$article_mapping->setFieldMapping('comment_count', $comment_count_mapping)->save();
|
||||
|
||||
// Save user mapping.
|
||||
$user_mapping = rdf_get_mapping('user', 'user');
|
||||
$username_mapping = [
|
||||
'properties' => ['foaf:name'],
|
||||
];
|
||||
$user_mapping->setFieldMapping('name', $username_mapping)->save();
|
||||
$user_mapping->setFieldMapping('homepage', ['properties' => ['foaf:page'], 'mapping_type' => 'rel'])->save();
|
||||
|
||||
// Save comment mapping.
|
||||
$mapping = rdf_get_mapping('comment', 'comment');
|
||||
$mapping->setBundleMapping(['types' => ['sioc:Post', 'sioct:Comment']])->save();
|
||||
$field_mappings = [
|
||||
'subject' => [
|
||||
'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'],
|
||||
],
|
||||
'comment_body' => [
|
||||
'properties' => ['content:encoded'],
|
||||
],
|
||||
'pid' => [
|
||||
'properties' => ['sioc:reply_of'],
|
||||
'mapping_type' => 'rel',
|
||||
],
|
||||
'uid' => [
|
||||
'properties' => ['sioc:has_creator'],
|
||||
'mapping_type' => 'rel',
|
||||
],
|
||||
'name' => [
|
||||
'properties' => ['foaf:name'],
|
||||
],
|
||||
];
|
||||
// Iterate over shared field mappings and save.
|
||||
foreach ($field_mappings as $field_name => $field_mapping) {
|
||||
$mapping->setFieldMapping($field_name, $field_mapping)->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the presence of the RDFa markup for the number of comments.
|
||||
*/
|
||||
public function testNumberOfCommentsRdfaMarkup() {
|
||||
// Posts 2 comments on behalf of registered user.
|
||||
$this->saveComment($this->node->id(), $this->webUser->id());
|
||||
$this->saveComment($this->node->id(), $this->webUser->id());
|
||||
|
||||
// Tests number of comments in teaser view.
|
||||
$this->drupalLogin($this->webUser);
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node'), 'rdfa', $this->baseUri);
|
||||
|
||||
// Number of comments.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => 2,
|
||||
'datatype' => 'http://www.w3.org/2001/XMLSchema#integer',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of teaser view (sioc:num_replies).');
|
||||
|
||||
// Tests number of comments in full node view, expected value is the same.
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
$this->assertTrue($graph->hasProperty($this->nodeUri, 'http://rdfs.org/sioc/ns#num_replies', $expected_value), 'Number of comments found in RDF output of full node view mode (sioc:num_replies).');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests comment author link markup has not been broken by RDF.
|
||||
*/
|
||||
public function testCommentRdfAuthorMarkup() {
|
||||
// Post a comment as a registered user.
|
||||
$this->saveComment($this->node->id(), $this->webUser->id());
|
||||
|
||||
// Give the user access to view user profiles so the profile link shows up.
|
||||
user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, ['access user profiles']);
|
||||
$this->drupalLogin($this->webUser);
|
||||
|
||||
// Ensure that the author link still works properly after the author output
|
||||
// is modified by the RDF module.
|
||||
$this->drupalGet('node/' . $this->node->id());
|
||||
$this->assertLink($this->webUser->getUsername());
|
||||
$this->assertLinkByHref('user/' . $this->webUser->id());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if RDFa markup for meta information is present in comments.
|
||||
*
|
||||
* Tests presence of RDFa markup for the title, date and author and homepage
|
||||
* on comments from registered and anonymous users.
|
||||
*/
|
||||
public function testCommentRdfaMarkup() {
|
||||
// Posts comment #1 on behalf of registered user.
|
||||
$comment1 = $this->saveComment($this->node->id(), $this->webUser->id());
|
||||
|
||||
// Tests comment #1 with access to the user profile.
|
||||
$this->drupalLogin($this->webUser);
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
|
||||
|
||||
// Tests comment #1 with no access to the user profile (as anonymous user).
|
||||
$this->drupalLogout();
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
|
||||
|
||||
// Posts comment #2 as anonymous user.
|
||||
$anonymous_user = [];
|
||||
$anonymous_user['name'] = $this->randomMachineName();
|
||||
$anonymous_user['mail'] = 'tester@simpletest.org';
|
||||
$anonymous_user['homepage'] = 'http://example.org/';
|
||||
$comment2 = $this->saveComment($this->node->id(), 0, $anonymous_user);
|
||||
|
||||
// Tests comment #2 as anonymous user.
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
$this->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);
|
||||
|
||||
// Tests comment #2 as logged in user.
|
||||
$this->drupalLogin($this->webUser);
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
$this->_testBasicCommentRdfaMarkup($graph, $comment2, $anonymous_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests RDF comment replies.
|
||||
*/
|
||||
public function testCommentReplyOfRdfaMarkup() {
|
||||
// Posts comment #1 on behalf of registered user.
|
||||
$this->drupalLogin($this->webUser);
|
||||
$comment_1 = $this->saveComment($this->node->id(), $this->webUser->id());
|
||||
|
||||
$comment_1_uri = $comment_1->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
// Posts a reply to the first comment.
|
||||
$comment_2 = $this->saveComment($this->node->id(), $this->webUser->id(), NULL, $comment_1->id());
|
||||
$comment_2_uri = $comment_2->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
|
||||
// Tests the reply_of relationship of a first level comment.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->nodeUri,
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_1_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
|
||||
|
||||
// Tests the reply_of relationship of a second level comment.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->nodeUri,
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its node found in RDF output (sioc:reply_of).');
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $comment_1_uri,
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_2_uri, 'http://rdfs.org/sioc/ns#reply_of', $expected_value), 'Comment relation to its parent comment found in RDF output (sioc:reply_of).');
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for testCommentRdfaMarkup().
|
||||
*
|
||||
* Tests the current page for basic comment RDFa markup.
|
||||
*
|
||||
* @param $comment
|
||||
* Comment object.
|
||||
* @param $account
|
||||
* An array containing information about an anonymous user.
|
||||
*/
|
||||
public function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = []) {
|
||||
$comment_uri = $comment->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
// Comment type.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://rdfs.org/sioc/types#Comment',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioct:Comment).');
|
||||
// Comment type.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://rdfs.org/sioc/ns#Post',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Comment type found in RDF output (sioc:Post).');
|
||||
|
||||
// Comment title.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $comment->getSubject(),
|
||||
'lang' => 'en',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Comment subject found in RDF output (dc:title).');
|
||||
|
||||
// Comment date.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
|
||||
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Comment date found in RDF output (dc:date).');
|
||||
// Comment date.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => format_date($comment->getCreatedTime(), 'custom', 'c', 'UTC'),
|
||||
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Comment date found in RDF output (dc:created).');
|
||||
|
||||
// Comment body.
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $comment->comment_body->value . "\n",
|
||||
'lang' => 'en',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://purl.org/rss/1.0/modules/content/encoded', $expected_value), 'Comment body found in RDF output (content:encoded).');
|
||||
|
||||
// The comment author can be a registered user or an anonymous user.
|
||||
if ($comment->getOwnerId() > 0) {
|
||||
$author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], ['absolute' => TRUE]);
|
||||
// Comment relation to author.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $author_uri,
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($comment_uri, 'http://rdfs.org/sioc/ns#has_creator', $expected_value), 'Comment relation to author found in RDF output (sioc:has_creator).');
|
||||
}
|
||||
else {
|
||||
// The author is expected to be a blank node.
|
||||
$author_uri = $graph->get($comment_uri, '<http://rdfs.org/sioc/ns#has_creator>');
|
||||
if ($author_uri instanceof \EasyRdf_Resource) {
|
||||
$this->assertTrue($author_uri->isBnode(), 'Comment relation to author found in RDF output (sioc:has_creator) and author is blank node.');
|
||||
}
|
||||
else {
|
||||
$this->fail('Comment relation to author found in RDF output (sioc:has_creator).');
|
||||
}
|
||||
}
|
||||
|
||||
// Author name.
|
||||
$name = empty($account["name"]) ? $this->webUser->getUsername() : $account["name"] . " (not verified)";
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $name,
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'Comment author name found in RDF output (foaf:name).');
|
||||
|
||||
// Comment author homepage (only for anonymous authors).
|
||||
if ($comment->getOwnerId() == 0) {
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://example.org/',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($author_uri, 'http://xmlns.com/foaf/0.1/page', $expected_value), 'Comment author link found in RDF output (foaf:page).');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a comment entity.
|
||||
*
|
||||
* @param $nid
|
||||
* Node id which will hold the comment.
|
||||
* @param $uid
|
||||
* User id of the author of the comment. Can be NULL if $contact provided.
|
||||
* @param $contact
|
||||
* Set to NULL for no contact info, TRUE to ignore success checking, and
|
||||
* array of values to set contact info.
|
||||
* @param $pid
|
||||
* Comment id of the parent comment in a thread.
|
||||
*
|
||||
* @return \Drupal\comment\Entity\Comment
|
||||
* The saved comment.
|
||||
*/
|
||||
public function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
|
||||
$values = [
|
||||
'entity_id' => $nid,
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
'uid' => $uid,
|
||||
'pid' => $pid,
|
||||
'subject' => $this->randomMachineName(),
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
'status' => 1,
|
||||
];
|
||||
if ($contact) {
|
||||
$values += $contact;
|
||||
}
|
||||
|
||||
$comment = Comment::create($values);
|
||||
$comment->save();
|
||||
return $comment;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\taxonomy\Tests\TaxonomyTestBase;
|
||||
use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase;
|
||||
|
||||
/**
|
||||
* Tests RDFa markup generation for taxonomy term fields.
|
||||
|
@ -125,23 +125,23 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
|
|||
'value' => 'http://www.w3.org/2004/02/skos/core#Concept',
|
||||
];
|
||||
// @todo Enable with https://www.drupal.org/node/2072791.
|
||||
//$this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
|
||||
// $this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $term1->getName(),
|
||||
];
|
||||
//$this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
|
||||
// $this->assertTrue($graph->hasProperty($taxonomy_term_1_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
|
||||
// Term 2.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://www.w3.org/2004/02/skos/core#Concept',
|
||||
];
|
||||
//$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
|
||||
// $this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Taxonomy term type found in RDF output (skos:Concept).');
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $term2->getName(),
|
||||
];
|
||||
//$this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
|
||||
// $this->assertTrue($graph->hasProperty($taxonomy_term_2_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Taxonomy term name found in RDF output (rdfs:label).');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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';
|
||||
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
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.
|
||||
*
|
||||
* @group rdf
|
||||
*/
|
||||
class ImageFieldAttributesTest extends ImageFieldTestBase {
|
||||
|
||||
use TestFileCreationTrait {
|
||||
getTestFiles as drupalGetTestFiles;
|
||||
}
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['rdf', 'image'];
|
||||
|
||||
/**
|
||||
* The name of the image field used in the test.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldName;
|
||||
|
||||
/**
|
||||
* The file object used in the test.
|
||||
*
|
||||
* @var \Drupal\file\FileInterface
|
||||
*/
|
||||
protected $file;
|
||||
|
||||
/**
|
||||
* The node object used in the test.
|
||||
*
|
||||
* @var \Drupal\node\NodeInterface
|
||||
*/
|
||||
protected $node;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->fieldName = 'field_image';
|
||||
|
||||
// Create the image field.
|
||||
$this->createImageField($this->fieldName, 'article');
|
||||
|
||||
// Set the RDF mapping for the new field.
|
||||
rdf_get_mapping('node', 'article')
|
||||
->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['og:image'],
|
||||
'mapping_type' => 'rel',
|
||||
])
|
||||
->setBundleMapping(['types' => []])
|
||||
->save();
|
||||
|
||||
// Get the test image that simpletest provides.
|
||||
$image = current($this->drupalGetTestFiles('image'));
|
||||
|
||||
// Save a node with the image.
|
||||
$nid = $this->uploadNodeImage($image, $this->fieldName, 'article', $this->randomMachineName());
|
||||
$this->node = Node::load($nid);
|
||||
$this->file = File::load($this->node->{$this->fieldName}->target_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that image fields in teasers have correct resources.
|
||||
*/
|
||||
public function testNodeTeaser() {
|
||||
// Set the display options for the teaser.
|
||||
$display_options = [
|
||||
'type' => 'image',
|
||||
'settings' => ['image_style' => 'medium', 'image_link' => 'content'],
|
||||
];
|
||||
$display = entity_get_display('node', 'article', 'teaser');
|
||||
$display->setComponent($this->fieldName, $display_options)
|
||||
->save();
|
||||
|
||||
// Render the teaser.
|
||||
$node_render_array = node_view($this->node, 'teaser');
|
||||
$html = \Drupal::service('renderer')->renderRoot($node_render_array);
|
||||
|
||||
// Parse the teaser.
|
||||
$parser = new \EasyRdf_Parser_Rdfa();
|
||||
$graph = new \EasyRdf_Graph();
|
||||
$base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
|
||||
$parser->parse($graph, $html, 'rdfa', $base_uri);
|
||||
|
||||
// Construct the node and image URIs for testing.
|
||||
$node_uri = $this->node->url('canonical', ['absolute' => TRUE]);
|
||||
$image_uri = ImageStyle::load('medium')->buildUrl($this->file->getFileUri());
|
||||
|
||||
// Test relations from node to image.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $image_uri,
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://ogp.me/ns#image', $expected_value), 'Node to file relation found in RDF output (og:image).');
|
||||
|
||||
// Test image type.
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://xmlns.com/foaf/0.1/Image',
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($image_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Image type found in RDF output (foaf:Image).');
|
||||
}
|
||||
|
||||
}
|
|
@ -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();
|
||||
|
||||
|
@ -407,7 +407,7 @@ class StandardProfileTest extends BrowserTestBase {
|
|||
|
||||
// Tag type.
|
||||
// @todo Enable with https://www.drupal.org/node/2072791.
|
||||
//$this->assertEqual($graph->type($this->termUri), 'schema:Thing', 'Tag type was found (schema:Thing).');
|
||||
// $this->assertEqual($graph->type($this->termUri), 'schema:Thing', 'Tag type was found (schema:Thing).');
|
||||
|
||||
// Tag name.
|
||||
$expected_value = [
|
||||
|
@ -416,7 +416,7 @@ class StandardProfileTest extends BrowserTestBase {
|
|||
'lang' => 'en',
|
||||
];
|
||||
// @todo Enable with https://www.drupal.org/node/2072791.
|
||||
//$this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "$message_prefix name was found (schema:name).");
|
||||
// $this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "$message_prefix name was found (schema:name).");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\taxonomy\Tests\TaxonomyTestBase;
|
||||
use Drupal\Tests\taxonomy\Functional\TaxonomyTestBase;
|
||||
|
||||
/**
|
||||
* Tests the RDFa markup of Taxonomy terms.
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\rdf\Kernel\Field;
|
||||
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
|
|
|
@ -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,395 @@
|
|||
<?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' => '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');
|
||||
}
|
||||
|
||||
}
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
namespace Drupal\Tests\rdf\Unit;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Entity\EntityManager;
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\rdf\Entity\RdfMapping;
|
||||
|
||||
|
@ -26,6 +28,13 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* The entity type manager used for testing.
|
||||
*
|
||||
* @var \Drupal\Core\Entity\EntityTypeManagerInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||
*/
|
||||
protected $entityTypeManager;
|
||||
|
||||
/**
|
||||
* The ID of the type of the entity under test.
|
||||
*
|
||||
|
@ -51,13 +60,16 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
->method('getProvider')
|
||||
->will($this->returnValue('entity'));
|
||||
|
||||
$this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface');
|
||||
$this->entityManager = new EntityManager();
|
||||
$this->entityTypeManager = $this->getMock(EntityTypeManagerInterface::class);
|
||||
|
||||
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
|
||||
|
||||
$container = new ContainerBuilder();
|
||||
$container->set('entity.manager', $this->entityManager);
|
||||
$container->set('entity_type.manager', $this->entityTypeManager);
|
||||
$container->set('uuid', $this->uuid);
|
||||
$this->entityManager->setContainer($container);
|
||||
\Drupal::setContainer($container);
|
||||
|
||||
}
|
||||
|
@ -77,11 +89,11 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
->method('getBundleEntityType')
|
||||
->will($this->returnValue(NULL));
|
||||
|
||||
$this->entityManager->expects($this->at(0))
|
||||
$this->entityTypeManager->expects($this->at(0))
|
||||
->method('getDefinition')
|
||||
->with($target_entity_type_id)
|
||||
->will($this->returnValue($target_entity_type));
|
||||
$this->entityManager->expects($this->at(1))
|
||||
$this->entityTypeManager->expects($this->at(1))
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
|
@ -108,11 +120,11 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
->method('getBundleConfigDependency')
|
||||
->will($this->returnValue(['type' => 'config', 'name' => 'test_module.type.' . $bundle_id]));
|
||||
|
||||
$this->entityManager->expects($this->at(0))
|
||||
$this->entityTypeManager->expects($this->at(0))
|
||||
->method('getDefinition')
|
||||
->with($target_entity_type_id)
|
||||
->will($this->returnValue($target_entity_type));
|
||||
$this->entityManager->expects($this->at(1))
|
||||
$this->entityTypeManager->expects($this->at(1))
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
|
|
Reference in a new issue