Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -25,7 +25,7 @@
|
|||
* @ingroup rdf
|
||||
*/
|
||||
function hook_rdf_namespaces() {
|
||||
return array(
|
||||
return [
|
||||
'content' => 'http://purl.org/rss/1.0/modules/content/',
|
||||
'dc' => 'http://purl.org/dc/terms/',
|
||||
'foaf' => 'http://xmlns.com/foaf/0.1/',
|
||||
|
@ -35,7 +35,7 @@ function hook_rdf_namespaces() {
|
|||
'sioct' => 'http://rdfs.org/sioc/types#',
|
||||
'skos' => 'http://www.w3.org/2004/02/skos/core#',
|
||||
'xsd' => 'http://www.w3.org/2001/XMLSchema#',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -17,7 +17,7 @@ function rdf_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'help.page.rdf':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The RDF module enriches your content with metadata to let other applications (e.g., search engines, aggregators, and so on) better understand its relationships and attributes. This semantically enriched, machine-readable output for your website uses the <a href=":rdfa">RDFa specification</a>, which allows RDF data to be embedded in HTML markup. Other modules can define mappings of their data to RDF terms, and the RDF module makes this RDF data available to the theme. The core modules define RDF mappings for their data model, and the core themes output this RDF metadata information along with the human-readable visual information. For more information, see the <a href=":rdf">online documentation for the RDF module</a>.', array(':rdfa' => 'http://www.w3.org/TR/xhtml-rdfa-primer/', ':rdf' => 'https://www.drupal.org/documentation/modules/rdf')) . '</p>';
|
||||
$output .= '<p>' . t('The RDF module enriches your content with metadata to let other applications (e.g., search engines, aggregators, and so on) better understand its relationships and attributes. This semantically enriched, machine-readable output for your website uses the <a href=":rdfa">RDFa specification</a>, which allows RDF data to be embedded in HTML markup. Other modules can define mappings of their data to RDF terms, and the RDF module makes this RDF data available to the theme. The core modules define RDF mappings for their data model, and the core themes output this RDF metadata information along with the human-readable visual information. For more information, see the <a href=":rdf">online documentation for the RDF module</a>.', [':rdfa' => 'http://www.w3.org/TR/xhtml-rdfa-primer/', ':rdf' => 'https://www.drupal.org/documentation/modules/rdf']) . '</p>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -74,10 +74,10 @@ function rdf_get_mapping($entity_type, $bundle) {
|
|||
|
||||
// If not found, create a fresh mapping object.
|
||||
if (!$mapping) {
|
||||
$mapping = RdfMapping::create(array(
|
||||
$mapping = RdfMapping::create([
|
||||
'targetEntityType' => $entity_type,
|
||||
'bundle' => $bundle,
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
return $mapping;
|
||||
|
@ -87,7 +87,7 @@ function rdf_get_mapping($entity_type, $bundle) {
|
|||
* Implements hook_rdf_namespaces().
|
||||
*/
|
||||
function rdf_rdf_namespaces() {
|
||||
return array(
|
||||
return [
|
||||
'content' => 'http://purl.org/rss/1.0/modules/content/',
|
||||
'dc' => 'http://purl.org/dc/terms/',
|
||||
'foaf' => 'http://xmlns.com/foaf/0.1/',
|
||||
|
@ -98,7 +98,7 @@ function rdf_rdf_namespaces() {
|
|||
'sioct' => 'http://rdfs.org/sioc/types#',
|
||||
'skos' => 'http://www.w3.org/2004/02/skos/core#',
|
||||
'xsd' => 'http://www.w3.org/2001/XMLSchema#',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -108,14 +108,14 @@ function rdf_rdf_namespaces() {
|
|||
* implement it.
|
||||
*/
|
||||
function rdf_get_namespaces() {
|
||||
$namespaces = array();
|
||||
$namespaces = [];
|
||||
// In order to resolve duplicate namespaces by using the earliest defined
|
||||
// namespace, do not use \Drupal::moduleHandler()->invokeAll().
|
||||
foreach (\Drupal::moduleHandler()->getImplementations('rdf_namespaces') as $module) {
|
||||
$function = $module . '_rdf_namespaces';
|
||||
foreach ($function() as $prefix => $namespace) {
|
||||
if (array_key_exists($prefix, $namespaces) && $namespace !== $namespaces[$prefix]) {
|
||||
throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', array('@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix])));
|
||||
throw new Exception(t('Tried to map @prefix to @namespace, but @prefix is already mapped to @orig_namespace.', ['@prefix' => $prefix, '@namespace' => $namespace, '@orig_namespace' => $namespaces[$prefix]]));
|
||||
}
|
||||
else {
|
||||
$namespaces[$prefix] = $namespace;
|
||||
|
@ -165,7 +165,7 @@ function rdf_get_namespaces() {
|
|||
* RDFa attributes suitable for Drupal\Core\Template\Attribute.
|
||||
*/
|
||||
function rdf_rdfa_attributes($mapping, $data = NULL) {
|
||||
$attributes = array();
|
||||
$attributes = [];
|
||||
|
||||
// The type of mapping defaults to 'property'.
|
||||
$type = isset($mapping['mapping_type']) ? $mapping['mapping_type'] : 'property';
|
||||
|
@ -249,14 +249,14 @@ function rdf_comment_storage_load($comments) {
|
|||
* Implements hook_theme().
|
||||
*/
|
||||
function rdf_theme() {
|
||||
return array(
|
||||
'rdf_wrapper' => array(
|
||||
'variables' => array('attributes' => array(), 'content' => NULL),
|
||||
),
|
||||
'rdf_metadata' => array(
|
||||
'variables' => array('metadata' => array()),
|
||||
),
|
||||
);
|
||||
return [
|
||||
'rdf_wrapper' => [
|
||||
'variables' => ['attributes' => [], 'content' => NULL],
|
||||
],
|
||||
'rdf_metadata' => [
|
||||
'variables' => ['metadata' => []],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,7 +266,7 @@ function rdf_preprocess_html(&$variables) {
|
|||
// Adds RDF namespace prefix bindings in the form of an RDFa 1.1 prefix
|
||||
// attribute inside the html element.
|
||||
if (!isset($variables['html_attributes']['prefix'])) {
|
||||
$variables['html_attributes']['prefix'] = array();
|
||||
$variables['html_attributes']['prefix'] = [];
|
||||
}
|
||||
foreach (rdf_get_namespaces() as $prefix => $uri) {
|
||||
$variables['html_attributes']['prefix'][] = $prefix . ': ' . $uri . " ";
|
||||
|
@ -315,20 +315,20 @@ function rdf_preprocess_node(&$variables) {
|
|||
if ($title_mapping) {
|
||||
$title_attributes['property'] = empty($title_mapping['properties']) ? NULL : $title_mapping['properties'];
|
||||
$title_attributes['content'] = $variables['node']->label();
|
||||
$variables['title_suffix']['rdf_meta_title'] = array(
|
||||
$variables['title_suffix']['rdf_meta_title'] = [
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => array($title_attributes),
|
||||
);
|
||||
'#metadata' => [$title_attributes],
|
||||
];
|
||||
}
|
||||
|
||||
// Adds RDFa markup for the date.
|
||||
$created_mapping = $mapping->getPreparedFieldMapping('created');
|
||||
if (!empty($created_mapping) && $variables['display_submitted']) {
|
||||
$date_attributes = rdf_rdfa_attributes($created_mapping, $variables['node']->get('created')->first()->toArray());
|
||||
$rdf_metadata = array(
|
||||
$rdf_metadata = [
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => array($date_attributes),
|
||||
);
|
||||
'#metadata' => [$date_attributes],
|
||||
];
|
||||
$variables['metadata'] = drupal_render($rdf_metadata);
|
||||
}
|
||||
|
||||
|
@ -345,10 +345,10 @@ function rdf_preprocess_node(&$variables) {
|
|||
// Adds RDFa markup for the comment count near the node title as
|
||||
// metadata.
|
||||
$comment_count_attributes = rdf_rdfa_attributes($comment_count_mapping, $variables['node']->get($field_name)->comment_count);
|
||||
$variables['title_suffix']['rdf_meta_comment_count'] = array(
|
||||
$variables['title_suffix']['rdf_meta_comment_count'] = [
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => array($comment_count_attributes),
|
||||
);
|
||||
'#metadata' => [$comment_count_attributes],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -377,15 +377,15 @@ function rdf_preprocess_user(&$variables) {
|
|||
// rdf_preprocess_username().
|
||||
$name_mapping = $mapping->getPreparedFieldMapping('name');
|
||||
if (!empty($name_mapping['properties'])) {
|
||||
$username_meta = array(
|
||||
$username_meta = [
|
||||
'#tag' => 'meta',
|
||||
'#attributes' => array(
|
||||
'#attributes' => [
|
||||
'about' => $account->url(),
|
||||
'property' => $name_mapping['properties'],
|
||||
'content' => $account->getDisplayName(),
|
||||
'lang' => '',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$variables['#attached']['html_head'][] = [$username_meta, 'rdf_user_username'];
|
||||
}
|
||||
}
|
||||
|
@ -482,10 +482,10 @@ function rdf_preprocess_comment(&$variables) {
|
|||
// cached as part of the entity.
|
||||
$date_attributes = $comment->rdf_data['date'];
|
||||
|
||||
$rdf_metadata = array(
|
||||
$rdf_metadata = [
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => array($date_attributes),
|
||||
);
|
||||
'#metadata' => [$date_attributes],
|
||||
];
|
||||
// Ensure the original variable is represented as a render array.
|
||||
$created = !is_array($variables['created']) ? ['#markup' => $variables['created']] : $variables['created'];
|
||||
$submitted = !is_array($variables['submitted']) ? ['#markup' => $variables['submitted']] : $variables['submitted'];
|
||||
|
@ -527,10 +527,10 @@ function rdf_preprocess_comment(&$variables) {
|
|||
}
|
||||
// Adds RDF metadata markup above comment body if any.
|
||||
if (!empty($variables['rdf_metadata_attributes']) && isset($variables['content']['comment_body'])) {
|
||||
$rdf_metadata = array(
|
||||
$rdf_metadata = [
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => $variables['rdf_metadata_attributes'],
|
||||
);
|
||||
];
|
||||
if (!empty($variables['content']['comment_body']['#prefix'])) {
|
||||
$rdf_metadata['#suffix'] = $variables['content']['comment_body']['#prefix'];
|
||||
}
|
||||
|
@ -555,14 +555,14 @@ function rdf_preprocess_taxonomy_term(&$variables) {
|
|||
// Add RDFa markup for the taxonomy term name as metadata, if present.
|
||||
$name_field_mapping = $mapping->getPreparedFieldMapping('name');
|
||||
if (!empty($name_field_mapping) && !empty($name_field_mapping['properties'])) {
|
||||
$name_attributes = array(
|
||||
$name_attributes = [
|
||||
'property' => $name_field_mapping['properties'],
|
||||
'content' => $term->getName(),
|
||||
);
|
||||
$variables['title_suffix']['taxonomy_term_rdfa'] = array(
|
||||
];
|
||||
$variables['title_suffix']['taxonomy_term_rdfa'] = [
|
||||
'#theme' => 'rdf_metadata',
|
||||
'#metadata' => array($name_attributes),
|
||||
);
|
||||
'#metadata' => [$name_attributes],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -573,7 +573,7 @@ function rdf_preprocess_image(&$variables) {
|
|||
// Adds the RDF type for image. We cannot use the usual entity-based mapping
|
||||
// to get 'foaf:Image' because image does not have its own entity type or
|
||||
// bundle.
|
||||
$variables['attributes']['typeof'] = array('foaf:Image');
|
||||
$variables['attributes']['typeof'] = ['foaf:Image'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,12 @@ use Drupal\rdf\RdfMappingInterface;
|
|||
* @ConfigEntityType(
|
||||
* id = "rdf_mapping",
|
||||
* label = @Translation("RDF mapping"),
|
||||
* label_singular = @Translation("RDF mapping item"),
|
||||
* label_plural = @Translation("RDF mappings items"),
|
||||
* label_count = @PluralTranslation(
|
||||
* singular = "@count RDF mapping item",
|
||||
* plural = "@count RDF mapping items",
|
||||
* ),
|
||||
* config_prefix = "mapping",
|
||||
* entity_keys = {
|
||||
* "id" = "id"
|
||||
|
@ -53,20 +59,20 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $types = array();
|
||||
protected $types = [];
|
||||
|
||||
/**
|
||||
* The mappings for fields on this bundle.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldMappings = array();
|
||||
protected $fieldMappings = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPreparedBundleMapping() {
|
||||
return array('types' => $this->types);
|
||||
return ['types' => $this->types];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -74,9 +80,9 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
|
|||
*/
|
||||
public function getBundleMapping() {
|
||||
if (!empty($this->types)) {
|
||||
return array('types' => $this->types);
|
||||
return ['types' => $this->types];
|
||||
}
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -94,16 +100,16 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPreparedFieldMapping($field_name) {
|
||||
$field_mapping = array(
|
||||
$field_mapping = [
|
||||
'properties' => NULL,
|
||||
'datatype' => NULL,
|
||||
'datatype_callback' => NULL,
|
||||
'mapping_type' => NULL,
|
||||
);
|
||||
];
|
||||
if (isset($this->fieldMappings[$field_name])) {
|
||||
$field_mapping = array_merge($field_mapping, $this->fieldMappings[$field_name]);
|
||||
}
|
||||
return empty($field_mapping['properties']) ? array() : $field_mapping;
|
||||
return empty($field_mapping['properties']) ? [] : $field_mapping;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,13 +119,13 @@ class RdfMapping extends ConfigEntityBase implements RdfMappingInterface {
|
|||
if (isset($this->fieldMappings[$field_name])) {
|
||||
return $this->fieldMappings[$field_name];
|
||||
}
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setFieldMapping($field_name, array $mapping = array()) {
|
||||
public function setFieldMapping($field_name, array $mapping = []) {
|
||||
$this->fieldMappings[$field_name] = $mapping;
|
||||
return $this;
|
||||
}
|
||||
|
|
|
@ -102,6 +102,6 @@ interface RdfMappingInterface extends ConfigEntityInterface {
|
|||
* @return \Drupal\rdf\Entity\RdfMapping
|
||||
* The RdfMapping object.
|
||||
*/
|
||||
public function setFieldMapping($field_name, array $mapping = array());
|
||||
public function setFieldMapping($field_name, array $mapping = []);
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class SchemaOrgDataConverter {
|
|||
*
|
||||
* @see http://schema.org/UserInteraction
|
||||
*/
|
||||
static function interactionCount($count, $arguments) {
|
||||
public static function interactionCount($count, $arguments) {
|
||||
$interaction_type = $arguments['interaction_type'];
|
||||
return "$interaction_type:$count";
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('views', 'node', 'comment', 'rdf');
|
||||
public static $modules = ['views', 'node', 'comment', 'rdf'];
|
||||
|
||||
/**
|
||||
* URI of the front page of the Drupal site.
|
||||
|
@ -40,11 +40,11 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Enables anonymous user comments.
|
||||
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, array(
|
||||
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);
|
||||
|
@ -58,53 +58,53 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
|
||||
// Set relation between node and comment.
|
||||
$article_mapping = rdf_get_mapping('node', 'article');
|
||||
$comment_count_mapping = array(
|
||||
'properties' => array('sioc:num_replies'),
|
||||
$comment_count_mapping = [
|
||||
'properties' => ['sioc:num_replies'],
|
||||
'datatype' => 'xsd:integer',
|
||||
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::rawValue'),
|
||||
);
|
||||
'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 = array(
|
||||
'properties' => array('foaf:name'),
|
||||
);
|
||||
$username_mapping = [
|
||||
'properties' => ['foaf:name'],
|
||||
];
|
||||
$user_mapping->setFieldMapping('name', $username_mapping)->save();
|
||||
$user_mapping->setFieldMapping('homepage', array('properties' => array('foaf:page'), 'mapping_type' => 'rel'))->save();
|
||||
$user_mapping->setFieldMapping('homepage', ['properties' => ['foaf:page'], 'mapping_type' => 'rel'])->save();
|
||||
|
||||
// Save comment mapping.
|
||||
$mapping = rdf_get_mapping('comment', 'comment');
|
||||
$mapping->setBundleMapping(array('types' => array('sioc:Post', 'sioct:Comment')))->save();
|
||||
$field_mappings = array(
|
||||
'subject' => array(
|
||||
'properties' => array('dc:title'),
|
||||
),
|
||||
'created' => array(
|
||||
'properties' => array('dc:date', 'dc:created'),
|
||||
$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' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
|
||||
),
|
||||
'changed' => array(
|
||||
'properties' => array('dc:modified'),
|
||||
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
|
||||
],
|
||||
'changed' => [
|
||||
'properties' => ['dc:modified'],
|
||||
'datatype' => 'xsd:dateTime',
|
||||
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
|
||||
),
|
||||
'comment_body' => array(
|
||||
'properties' => array('content:encoded'),
|
||||
),
|
||||
'pid' => array(
|
||||
'properties' => array('sioc:reply_of'),
|
||||
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
|
||||
],
|
||||
'comment_body' => [
|
||||
'properties' => ['content:encoded'],
|
||||
],
|
||||
'pid' => [
|
||||
'properties' => ['sioc:reply_of'],
|
||||
'mapping_type' => 'rel',
|
||||
),
|
||||
'uid' => array(
|
||||
'properties' => array('sioc:has_creator'),
|
||||
],
|
||||
'uid' => [
|
||||
'properties' => ['sioc:has_creator'],
|
||||
'mapping_type' => 'rel',
|
||||
),
|
||||
'name' => array(
|
||||
'properties' => array('foaf:name'),
|
||||
),
|
||||
);
|
||||
],
|
||||
'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();
|
||||
|
@ -126,11 +126,11 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
$parser->parse($graph, $this->drupalGet('node'), 'rdfa', $this->baseUri);
|
||||
|
||||
// Number of comments.
|
||||
$expected_value = array(
|
||||
$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.
|
||||
|
@ -183,7 +183,7 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
$this->_testBasicCommentRdfaMarkup($graph, $comment1);
|
||||
|
||||
// Posts comment #2 as anonymous user.
|
||||
$anonymous_user = array();
|
||||
$anonymous_user = [];
|
||||
$anonymous_user['name'] = $this->randomMachineName();
|
||||
$anonymous_user['mail'] = 'tester@simpletest.org';
|
||||
$anonymous_user['homepage'] = 'http://example.org/';
|
||||
|
@ -222,22 +222,22 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
$parser->parse($graph, $this->drupalGet('node/' . $this->node->id()), 'rdfa', $this->baseUri);
|
||||
|
||||
// Tests the reply_of relationship of a first level comment.
|
||||
$expected_value = array(
|
||||
$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 = array(
|
||||
$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 = array(
|
||||
$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).');
|
||||
}
|
||||
|
||||
|
@ -251,61 +251,61 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
* @param $account
|
||||
* An array containing information about an anonymous user.
|
||||
*/
|
||||
function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = array()) {
|
||||
$comment_uri = $comment->url('canonical', array('absolute' => TRUE));
|
||||
public function _testBasicCommentRdfaMarkup($graph, CommentInterface $comment, $account = []) {
|
||||
$comment_uri = $comment->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
// Comment type.
|
||||
$expected_value = array(
|
||||
$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 = array(
|
||||
$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 = array(
|
||||
$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 = array(
|
||||
$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 = array(
|
||||
$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 = array(
|
||||
$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()], array('absolute' => TRUE));
|
||||
$author_uri = \Drupal::url('entity.user.canonical', ['user' => $comment->getOwnerId()], ['absolute' => TRUE]);
|
||||
// Comment relation to author.
|
||||
$expected_value = array(
|
||||
$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 {
|
||||
|
@ -321,18 +321,18 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
|
||||
// Author name.
|
||||
$name = empty($account["name"]) ? $this->webUser->getUsername() : $account["name"] . " (not verified)";
|
||||
$expected_value = array(
|
||||
$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 = array(
|
||||
$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).');
|
||||
}
|
||||
}
|
||||
|
@ -353,8 +353,8 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
* @return \Drupal\comment\Entity\Comment
|
||||
* The saved comment.
|
||||
*/
|
||||
function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
|
||||
$values = array(
|
||||
public function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
|
||||
$values = [
|
||||
'entity_id' => $nid,
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
|
@ -363,7 +363,7 @@ class CommentAttributesTest extends CommentTestBase {
|
|||
'subject' => $this->randomMachineName(),
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
'status' => 1,
|
||||
);
|
||||
];
|
||||
if ($contact) {
|
||||
$values += $contact;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ class TestDataConverter {
|
|||
* @return string
|
||||
* Returns the data.
|
||||
*/
|
||||
static function convertFoo($data) {
|
||||
public static function convertFoo($data) {
|
||||
return 'foo' . $data['value'];
|
||||
}
|
||||
|
||||
|
|
|
@ -17,33 +17,33 @@ class GetNamespacesTest extends WebTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'rdf_test_namespaces');
|
||||
public static $modules = ['rdf', 'rdf_test_namespaces'];
|
||||
|
||||
/**
|
||||
* Tests RDF namespaces.
|
||||
*/
|
||||
function testGetRdfNamespaces() {
|
||||
public function testGetRdfNamespaces() {
|
||||
// Fetches the front page and extracts RDFa 1.1 prefixes.
|
||||
$this->drupalGet('');
|
||||
|
||||
$element = $this->xpath('//html[contains(@prefix, :prefix_binding)]', array(
|
||||
$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)]', array(
|
||||
$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)]', array(
|
||||
$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)]', array(
|
||||
$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.');
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'image');
|
||||
public static $modules = ['rdf', 'image'];
|
||||
|
||||
/**
|
||||
* The name of the image field used in the test.
|
||||
|
@ -52,11 +52,11 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
|
|||
|
||||
// Set the RDF mapping for the new field.
|
||||
rdf_get_mapping('node', 'article')
|
||||
->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('og:image'),
|
||||
->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['og:image'],
|
||||
'mapping_type' => 'rel',
|
||||
))
|
||||
->setBundleMapping(array('types' => array()))
|
||||
])
|
||||
->setBundleMapping(['types' => []])
|
||||
->save();
|
||||
|
||||
// Get the test image that simpletest provides.
|
||||
|
@ -71,12 +71,12 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
|
|||
/**
|
||||
* Tests that image fields in teasers have correct resources.
|
||||
*/
|
||||
function testNodeTeaser() {
|
||||
public function testNodeTeaser() {
|
||||
// Set the display options for the teaser.
|
||||
$display_options = array(
|
||||
$display_options = [
|
||||
'type' => 'image',
|
||||
'settings' => array('image_style' => 'medium', 'image_link' => 'content'),
|
||||
);
|
||||
'settings' => ['image_style' => 'medium', 'image_link' => 'content'],
|
||||
];
|
||||
$display = entity_get_display('node', 'article', 'teaser');
|
||||
$display->setComponent($this->fieldName, $display_options)
|
||||
->save();
|
||||
|
@ -96,17 +96,17 @@ class ImageFieldAttributesTest extends ImageFieldTestBase {
|
|||
$image_uri = ImageStyle::load('medium')->buildUrl($this->file->getFileUri());
|
||||
|
||||
// Test relations from node to image.
|
||||
$expected_value = array(
|
||||
$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 = array(
|
||||
$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).');
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* Implements hook_rdf_namespaces().
|
||||
*/
|
||||
function rdf_conflicting_namespaces_rdf_namespaces() {
|
||||
return array(
|
||||
return [
|
||||
'dc' => 'http://purl.org/conflicting/namespace',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
* Implements hook_rdf_namespaces().
|
||||
*/
|
||||
function rdf_test_namespaces_rdf_namespaces() {
|
||||
return array(
|
||||
return [
|
||||
'foaf' => 'http://xmlns.com/foaf/0.1/',
|
||||
'foaf1' => 'http://xmlns.com/foaf/0.1/',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\taxonomy\Tests\TaxonomyTestBase;
|
||||
|
@ -17,7 +17,7 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'field_test', 'file', 'image');
|
||||
public static $modules = ['rdf', 'field_test', 'file', 'image'];
|
||||
|
||||
/**
|
||||
* The name of the taxonomy term reference field used in the test.
|
||||
|
@ -36,38 +36,38 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$web_user = $this->drupalCreateUser(array('bypass node access', 'administer taxonomy'));
|
||||
$web_user = $this->drupalCreateUser(['bypass node access', 'administer taxonomy']);
|
||||
$this->drupalLogin($web_user);
|
||||
$this->vocabulary = $this->createVocabulary();
|
||||
|
||||
// Create the field.
|
||||
$this->fieldName = 'field_taxonomy_test';
|
||||
$handler_settings = array(
|
||||
'target_bundles' => array(
|
||||
$handler_settings = [
|
||||
'target_bundles' => [
|
||||
$this->vocabulary->id() => $this->vocabulary->id(),
|
||||
),
|
||||
],
|
||||
'auto_create' => TRUE,
|
||||
);
|
||||
];
|
||||
$this->createEntityReferenceField('node', 'article', $this->fieldName, 'Tags', 'taxonomy_term', 'default', $handler_settings, FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED);
|
||||
|
||||
entity_get_form_display('node', 'article', 'default')
|
||||
->setComponent($this->fieldName, array('type' => 'options_select'))
|
||||
->setComponent($this->fieldName, ['type' => 'options_select'])
|
||||
->save();
|
||||
entity_get_display('node', 'article', 'full')
|
||||
->setComponent($this->fieldName, array('type' => 'entity_reference_label'))
|
||||
->setComponent($this->fieldName, ['type' => 'entity_reference_label'])
|
||||
->save();
|
||||
|
||||
// Set the RDF mapping for the new field.
|
||||
rdf_get_mapping('node', 'article')
|
||||
->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('dc:subject'),
|
||||
->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['dc:subject'],
|
||||
'mapping_type' => 'rel',
|
||||
))
|
||||
])
|
||||
->save();
|
||||
|
||||
rdf_get_mapping('taxonomy_term', $this->vocabulary->id())
|
||||
->setBundleMapping(array('types' => array('skos:Concept')))
|
||||
->setFieldMapping('name', array('properties' => array('rdfs:label')))
|
||||
->setBundleMapping(['types' => ['skos:Concept']])
|
||||
->setFieldMapping('name', ['properties' => ['rdfs:label']])
|
||||
->save();
|
||||
}
|
||||
|
||||
|
@ -77,10 +77,10 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
|
|||
* Ensure that file fields have the correct resource as the object in RDFa
|
||||
* when displayed as a teaser.
|
||||
*/
|
||||
function testNodeTeaser() {
|
||||
public function testNodeTeaser() {
|
||||
// Set the teaser display to show this field.
|
||||
entity_get_display('node', 'article', 'teaser')
|
||||
->setComponent($this->fieldName, array('type' => 'entity_reference_label'))
|
||||
->setComponent($this->fieldName, ['type' => 'entity_reference_label'])
|
||||
->save();
|
||||
|
||||
// Create a term in each vocabulary.
|
||||
|
@ -90,14 +90,14 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
|
|||
$taxonomy_term_2_uri = $term2->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
// Create the node.
|
||||
$node = $this->drupalCreateNode(array('type' => 'article'));
|
||||
$node->set($this->fieldName, array(
|
||||
array('target_id' => $term1->id()),
|
||||
array('target_id' => $term2->id()),
|
||||
));
|
||||
$node = $this->drupalCreateNode(['type' => 'article']);
|
||||
$node->set($this->fieldName, [
|
||||
['target_id' => $term1->id()],
|
||||
['target_id' => $term2->id()],
|
||||
]);
|
||||
|
||||
// Render the node.
|
||||
$node_render_array = entity_view_multiple(array($node), 'teaser');
|
||||
$node_render_array = entity_view_multiple([$node], 'teaser');
|
||||
$html = \Drupal::service('renderer')->renderRoot($node_render_array);
|
||||
|
||||
// Parse the teaser.
|
||||
|
@ -108,39 +108,39 @@ class EntityReferenceFieldAttributesTest extends TaxonomyTestBase {
|
|||
|
||||
// Node relations to taxonomy terms.
|
||||
$node_uri = $node->url('canonical', ['absolute' => TRUE]);
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $taxonomy_term_1_uri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/subject', $expected_value), 'Node to term relation found in RDF output (dc:subject).');
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $taxonomy_term_2_uri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/subject', $expected_value), 'Node to term relation found in RDF output (dc:subject).');
|
||||
// Taxonomy terms triples.
|
||||
// Term 1.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'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).');
|
||||
$expected_value = array(
|
||||
$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).');
|
||||
// Term 2.
|
||||
$expected_value = array(
|
||||
$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).');
|
||||
$expected_value = array(
|
||||
$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).');
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\file\Tests\FileFieldTestBase;
|
||||
use Drupal\file\Entity\File;
|
||||
|
@ -17,7 +17,7 @@ class FileFieldAttributesTest extends FileFieldTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'file');
|
||||
public static $modules = ['rdf', 'file'];
|
||||
|
||||
/**
|
||||
* The name of the file field used in the test.
|
||||
|
@ -50,19 +50,19 @@ class FileFieldAttributesTest extends FileFieldTestBase {
|
|||
|
||||
// Set the teaser display to show this field.
|
||||
entity_get_display('node', 'article', 'teaser')
|
||||
->setComponent($this->fieldName, array('type' => 'file_default'))
|
||||
->setComponent($this->fieldName, ['type' => 'file_default'])
|
||||
->save();
|
||||
|
||||
// Set the RDF mapping for the new field.
|
||||
$mapping = rdf_get_mapping('node', 'article');
|
||||
$mapping->setFieldMapping($this->fieldName, array('properties' => array('rdfs:seeAlso'), 'mapping_type' => 'rel'))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, ['properties' => ['rdfs:seeAlso'], 'mapping_type' => 'rel'])->save();
|
||||
|
||||
$test_file = $this->getTestFile('text');
|
||||
|
||||
// Create a new node with the uploaded file.
|
||||
$nid = $this->uploadNodeFile($test_file, $this->fieldName, $type_name);
|
||||
|
||||
$node_storage->resetCache(array($nid));
|
||||
$node_storage->resetCache([$nid]);
|
||||
$this->node = $node_storage->load($nid);
|
||||
$this->file = File::load($this->node->{$this->fieldName}->target_id);
|
||||
}
|
||||
|
@ -73,9 +73,9 @@ class FileFieldAttributesTest extends FileFieldTestBase {
|
|||
* Ensure that file fields have the correct resource as the object in RDFa
|
||||
* when displayed as a teaser.
|
||||
*/
|
||||
function testNodeTeaser() {
|
||||
public function testNodeTeaser() {
|
||||
// Render the teaser.
|
||||
$node_render_array = entity_view_multiple(array($this->node), 'teaser');
|
||||
$node_render_array = entity_view_multiple([$this->node], 'teaser');
|
||||
$html = \Drupal::service('renderer')->renderRoot($node_render_array);
|
||||
|
||||
// Parses front page where the node is displayed in its teaser form.
|
||||
|
@ -88,10 +88,10 @@ class FileFieldAttributesTest extends FileFieldTestBase {
|
|||
$file_uri = file_create_url($this->file->getFileUri());
|
||||
|
||||
// Node relation to attached file.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $file_uri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://www.w3.org/2000/01/rdf-schema#seeAlso', $expected_value), 'Node to file relation found in RDF output (rdfs:seeAlso).');
|
||||
$this->drupalGet('node');
|
||||
}
|
|
@ -1,27 +1,27 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests hook_rdf_namespaces().
|
||||
*
|
||||
* @group rdf
|
||||
*/
|
||||
class GetRdfNamespacesTest extends WebTestBase {
|
||||
class GetRdfNamespacesTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'rdf_test_namespaces');
|
||||
public static $modules = ['rdf', 'rdf_test_namespaces'];
|
||||
|
||||
/**
|
||||
* Tests getting RDF namespaces.
|
||||
*/
|
||||
function testGetRdfNamespaces() {
|
||||
public function testGetRdfNamespaces() {
|
||||
// Get all RDF namespaces.
|
||||
$ns = rdf_get_namespaces();
|
||||
|
||||
|
@ -31,7 +31,7 @@ class GetRdfNamespacesTest extends WebTestBase {
|
|||
|
||||
// Enable rdf_conflicting_namespaces to ensure that an exception is thrown
|
||||
// when RDF namespaces are conflicting.
|
||||
\Drupal::service('module_installer')->install(array('rdf_conflicting_namespaces'), TRUE);
|
||||
\Drupal::service('module_installer')->install(['rdf_conflicting_namespaces'], TRUE);
|
||||
try {
|
||||
$ns = rdf_get_namespaces();
|
||||
$this->fail('Expected exception not thrown for conflicting namespace declaration.');
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\node\Tests\NodeTestBase;
|
||||
|
||||
|
@ -16,36 +16,36 @@ class NodeAttributesTest extends NodeTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf');
|
||||
public static $modules = ['rdf'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
rdf_get_mapping('node', 'article')
|
||||
->setBundleMapping(array(
|
||||
'types' => array('sioc:Item', 'foaf:Document'),
|
||||
))
|
||||
->setFieldMapping('title', array(
|
||||
'properties' => array('dc:title'),
|
||||
))
|
||||
->setFieldMapping('created', array(
|
||||
'properties' => array('dc:date', 'dc:created'),
|
||||
->setBundleMapping([
|
||||
'types' => ['sioc:Item', 'foaf:Document'],
|
||||
])
|
||||
->setFieldMapping('title', [
|
||||
'properties' => ['dc:title'],
|
||||
])
|
||||
->setFieldMapping('created', [
|
||||
'properties' => ['dc:date', 'dc:created'],
|
||||
'datatype' => 'xsd:dateTime',
|
||||
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
|
||||
))
|
||||
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
|
||||
])
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a node of type article and tests its RDFa markup.
|
||||
*/
|
||||
function testNodeAttributes() {
|
||||
public function testNodeAttributes() {
|
||||
// Create node with single quotation mark title to ensure it does not get
|
||||
// escaped more than once.
|
||||
$node = $this->drupalCreateNode(array(
|
||||
$node = $this->drupalCreateNode([
|
||||
'type' => 'article',
|
||||
'title' => $this->randomMachineName(8) . "'",
|
||||
));
|
||||
]);
|
||||
|
||||
$node_uri = $node->url('canonical', ['absolute' => TRUE]);
|
||||
$base_uri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
|
||||
|
@ -57,37 +57,37 @@ class NodeAttributesTest extends NodeTestBase {
|
|||
|
||||
// Inspects RDF graph output.
|
||||
// Node type.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://rdfs.org/sioc/ns#Item',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Node type found in RDF output (sioc:Item).');
|
||||
// Node type.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://xmlns.com/foaf/0.1/Document',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Node type found in RDF output (foaf:Document).');
|
||||
// Node title.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $node->getTitle(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/title', $expected_value), 'Node title found in RDF output (dc:title).');
|
||||
// Node date (date format must be UTC).
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => \Drupal::service('date.formatter')->format($node->getCreatedTime(), 'custom', 'c', 'UTC'),
|
||||
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/date', $expected_value), 'Node date found in RDF output (dc:date).');
|
||||
// Node date (date format must be UTC).
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => \Drupal::service('date.formatter')->format($node->getCreatedTime(), 'custom', 'c', 'UTC'),
|
||||
'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($node_uri, 'http://purl.org/dc/terms/created', $expected_value), 'Node date found in RDF output (dc:created).');
|
||||
}
|
||||
|
|
@ -1,13 +1,13 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\file\Entity\File;
|
||||
use Drupal\image\Entity\ImageStyle;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\comment\Entity\Comment;
|
||||
use Drupal\taxonomy\Entity\Term;
|
||||
|
||||
|
@ -16,7 +16,7 @@ use Drupal\taxonomy\Entity\Term;
|
|||
*
|
||||
* @group rdf
|
||||
*/
|
||||
class StandardProfileTest extends WebTestBase {
|
||||
class StandardProfileTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* The profile used during tests.
|
||||
|
@ -107,23 +107,23 @@ class StandardProfileTest extends WebTestBase {
|
|||
|
||||
// Use Classy theme for testing markup output.
|
||||
\Drupal::service('theme_handler')->install(['classy']);
|
||||
\Drupal::service('theme_handler')->setDefault('classy');
|
||||
$this->config('system.theme')->set('default', 'classy')->save();
|
||||
|
||||
$this->baseUri = \Drupal::url('<front>', [], ['absolute' => TRUE]);
|
||||
|
||||
// Create two test users.
|
||||
$this->adminUser = $this->drupalCreateUser(array(
|
||||
$this->adminUser = $this->drupalCreateUser([
|
||||
'administer content types',
|
||||
'administer comments',
|
||||
'access comments',
|
||||
'access content',
|
||||
));
|
||||
$this->webUser = $this->drupalCreateUser(array(
|
||||
]);
|
||||
$this->webUser = $this->drupalCreateUser([
|
||||
'access comments',
|
||||
'post comments',
|
||||
'skip comment approval',
|
||||
'access content',
|
||||
));
|
||||
]);
|
||||
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
|
@ -141,46 +141,46 @@ class StandardProfileTest extends WebTestBase {
|
|||
$this->image->save();
|
||||
|
||||
// Create article.
|
||||
$article_settings = array(
|
||||
$article_settings = [
|
||||
'type' => 'article',
|
||||
'promote' => NODE_PROMOTED,
|
||||
'field_image' => array(
|
||||
array(
|
||||
'promote' => NodeInterface::PROMOTED,
|
||||
'field_image' => [
|
||||
[
|
||||
'target_id' => $this->image->id(),
|
||||
),
|
||||
),
|
||||
'field_tags' => array(
|
||||
array(
|
||||
],
|
||||
],
|
||||
'field_tags' => [
|
||||
[
|
||||
'target_id' => $this->term->id(),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
];
|
||||
$this->article = $this->drupalCreateNode($article_settings);
|
||||
// Create second article to test teaser list.
|
||||
$this->drupalCreateNode(array('type' => 'article', 'promote' => NODE_PROMOTED,));
|
||||
$this->drupalCreateNode(['type' => 'article', 'promote' => NodeInterface::PROMOTED]);
|
||||
|
||||
// Create article comment.
|
||||
$this->articleComment = $this->saveComment($this->article->id(), $this->webUser->id(), NULL, 0);
|
||||
|
||||
// Create page.
|
||||
$this->page = $this->drupalCreateNode(array('type' => 'page'));
|
||||
$this->page = $this->drupalCreateNode(['type' => 'page']);
|
||||
|
||||
// Set URIs.
|
||||
// Image.
|
||||
$image_file = $this->article->get('field_image')->entity;
|
||||
$this->imageUri = ImageStyle::load('large')->buildUrl($image_file->getFileUri());
|
||||
// Term.
|
||||
$this->termUri = $this->term->url('canonical', array('absolute' => TRUE));
|
||||
$this->termUri = $this->term->url('canonical', ['absolute' => TRUE]);
|
||||
// Article.
|
||||
$this->articleUri = $this->article->url('canonical', array('absolute' => TRUE));
|
||||
$this->articleUri = $this->article->url('canonical', ['absolute' => TRUE]);
|
||||
// Page.
|
||||
$this->pageUri = $this->page->url('canonical', array('absolute' => TRUE));
|
||||
$this->pageUri = $this->page->url('canonical', ['absolute' => TRUE]);
|
||||
// Author.
|
||||
$this->authorUri = $this->adminUser->url('canonical', array('absolute' => TRUE));
|
||||
$this->authorUri = $this->adminUser->url('canonical', ['absolute' => TRUE]);
|
||||
// Comment.
|
||||
$this->articleCommentUri = $this->articleComment->url('canonical', array('absolute' => TRUE));
|
||||
$this->articleCommentUri = $this->articleComment->url('canonical', ['absolute' => TRUE]);
|
||||
// Commenter.
|
||||
$this->commenterUri = $this->webUser->url('canonical', array('absolute' => TRUE));
|
||||
$this->commenterUri = $this->webUser->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
$this->drupalLogout();
|
||||
}
|
||||
|
@ -211,11 +211,11 @@ class StandardProfileTest extends WebTestBase {
|
|||
$this->assertEqual(2, count($graph->allOfType('http://schema.org/Article')), 'Two articles found on front page.');
|
||||
|
||||
// Test interaction count.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => 'UserComments:1',
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/interactionCount', $expected_value), "Teaser comment count was found (schema:interactionCount).");
|
||||
|
||||
// Test the properties that are common between pages and articles and are
|
||||
|
@ -228,10 +228,10 @@ class StandardProfileTest extends WebTestBase {
|
|||
// image, move this to testArticleProperties().
|
||||
$image_file = $this->article->get('field_image')->entity;
|
||||
$image_uri = ImageStyle::load('medium')->buildUrl($image_file->getFileUri());
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $image_uri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/image', $expected_value), "Teaser image was found (schema:image).");
|
||||
}
|
||||
|
||||
|
@ -258,10 +258,10 @@ class StandardProfileTest extends WebTestBase {
|
|||
|
||||
// @todo Once the image points to the original instead of the processed
|
||||
// image, move this to testArticleProperties().
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->imageUri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/image', $expected_value), "Article image was found (schema:image).");
|
||||
}
|
||||
|
||||
|
@ -303,10 +303,10 @@ class StandardProfileTest extends WebTestBase {
|
|||
$this->assertEqual($graph->type($this->authorUri), 'schema:Person', "User type was found (schema:Person) on user page.");
|
||||
|
||||
// User name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $this->adminUser->label(),
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->authorUri, 'http://schema.org/name', $expected_value), "User name was found (schema:name) on user page.");
|
||||
|
||||
$this->drupalLogout();
|
||||
|
@ -323,11 +323,11 @@ class StandardProfileTest extends WebTestBase {
|
|||
$this->assertEqual($graph->type($this->termUri), 'schema:Thing', "Term type was found (schema:Thing) on term page.");
|
||||
|
||||
// Term name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $this->term->getName(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->termUri, 'http://schema.org/name', $expected_value), "Term name was found (schema:name) on term page.");
|
||||
|
||||
// @todo Add test for term description once it is a field:
|
||||
|
@ -345,47 +345,47 @@ class StandardProfileTest extends WebTestBase {
|
|||
* The word to use in the test assertion message.
|
||||
*/
|
||||
protected function assertRdfaCommonNodeProperties($graph, NodeInterface $node, $message_prefix) {
|
||||
$uri = $node->url('canonical', array('absolute' => TRUE));
|
||||
$uri = $node->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
// Title.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $node->get('title')->value,
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/name', $expected_value), "$message_prefix title was found (schema:name).");
|
||||
|
||||
// Created date.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => format_date($node->get('created')->value, 'custom', 'c', 'UTC'),
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/dateCreated', $expected_value), "$message_prefix created date was found (schema:dateCreated) in teaser.");
|
||||
|
||||
// Body.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $node->get('body')->value,
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/text', $expected_value), "$message_prefix body was found (schema:text) in teaser.");
|
||||
|
||||
// Author.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->authorUri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($uri, 'http://schema.org/author', $expected_value), "$message_prefix author was found (schema:author) in teaser.");
|
||||
|
||||
// Author type.
|
||||
$this->assertEqual($graph->type($this->authorUri), 'schema:Person', "$message_prefix author type was found (schema:Person).");
|
||||
|
||||
// Author name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $this->adminUser->label(),
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->authorUri, 'http://schema.org/name', $expected_value), "$message_prefix author name was found (schema:name).");
|
||||
}
|
||||
|
||||
|
@ -399,10 +399,10 @@ class StandardProfileTest extends WebTestBase {
|
|||
*/
|
||||
protected function assertRdfaArticleProperties($graph, $message_prefix) {
|
||||
// Tags.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->termUri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/about', $expected_value), "$message_prefix tag was found (schema:about).");
|
||||
|
||||
// Tag type.
|
||||
|
@ -410,11 +410,11 @@ class StandardProfileTest extends WebTestBase {
|
|||
//$this->assertEqual($graph->type($this->termUri), 'schema:Thing', 'Tag type was found (schema:Thing).');
|
||||
|
||||
// Tag name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $this->term->getName(),
|
||||
'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).");
|
||||
}
|
||||
|
@ -427,58 +427,58 @@ class StandardProfileTest extends WebTestBase {
|
|||
*/
|
||||
protected function assertRdfaNodeCommentProperties($graph) {
|
||||
// Relationship between node and comment.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->articleCommentUri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleUri, 'http://schema.org/comment', $expected_value), 'Relationship between node and comment found (schema:comment).');
|
||||
|
||||
// Comment type.
|
||||
$this->assertEqual($graph->type($this->articleCommentUri), 'schema:Comment', 'Comment type was found (schema:Comment).');
|
||||
|
||||
// Comment title.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $this->articleComment->get('subject')->value,
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/name', $expected_value), 'Article comment title was found (schema:name).');
|
||||
|
||||
// Comment created date.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => format_date($this->articleComment->get('created')->value, 'custom', 'c', 'UTC'),
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/dateCreated', $expected_value), 'Article comment created date was found (schema:dateCreated).');
|
||||
|
||||
// Comment body.
|
||||
$text = $this->articleComment->get('comment_body')->value;
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
// There is an extra carriage return in the when parsing comments as
|
||||
// output by Bartik, so it must be added to the expected value.
|
||||
'value' => "$text
|
||||
",
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/text', $expected_value), 'Article comment body was found (schema:text).');
|
||||
|
||||
// Comment uid.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => $this->commenterUri,
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->articleCommentUri, 'http://schema.org/author', $expected_value), 'Article comment author was found (schema:author).');
|
||||
|
||||
// Comment author type.
|
||||
$this->assertEqual($graph->type($this->commenterUri), 'schema:Person', 'Comment author type was found (schema:Person).');
|
||||
|
||||
// Comment author name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $this->webUser->getUsername(),
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($this->commenterUri, 'http://schema.org/name', $expected_value), 'Comment author name was found (schema:name).');
|
||||
}
|
||||
|
||||
|
@ -499,7 +499,7 @@ class StandardProfileTest extends WebTestBase {
|
|||
* The saved comment.
|
||||
*/
|
||||
protected function saveComment($nid, $uid, $contact = NULL, $pid = 0) {
|
||||
$values = array(
|
||||
$values = [
|
||||
'entity_id' => $nid,
|
||||
'entity_type' => 'node',
|
||||
'field_name' => 'comment',
|
||||
|
@ -508,7 +508,7 @@ class StandardProfileTest extends WebTestBase {
|
|||
'subject' => $this->randomMachineName(),
|
||||
'comment_body' => $this->randomMachineName(),
|
||||
'status' => 1,
|
||||
);
|
||||
];
|
||||
if ($contact) {
|
||||
$values += $contact;
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\taxonomy\Tests\TaxonomyTestBase;
|
||||
|
||||
|
@ -16,7 +16,7 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'views');
|
||||
public static $modules = ['rdf', 'views'];
|
||||
|
||||
/**
|
||||
* Vocabulary created for testing purposes.
|
||||
|
@ -32,17 +32,17 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
|
|||
|
||||
// RDF mapping - term bundle.
|
||||
rdf_get_mapping('taxonomy_term', $this->vocabulary->id())
|
||||
->setBundleMapping(array('types' => array('skos:Concept')))
|
||||
->setFieldMapping('name', array(
|
||||
'properties' => array('rdfs:label', 'skos:prefLabel'),
|
||||
))
|
||||
->setBundleMapping(['types' => ['skos:Concept']])
|
||||
->setFieldMapping('name', [
|
||||
'properties' => ['rdfs:label', 'skos:prefLabel'],
|
||||
])
|
||||
->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a random term and ensures the RDF output is correct.
|
||||
*/
|
||||
function testTaxonomyTermRdfaAttributes() {
|
||||
public function testTaxonomyTermRdfaAttributes() {
|
||||
$term = $this->createTerm($this->vocabulary);
|
||||
$term_uri = $term->url('canonical', ['absolute' => TRUE]);
|
||||
|
||||
|
@ -54,24 +54,24 @@ class TaxonomyAttributesTest extends TaxonomyTestBase {
|
|||
|
||||
// Inspects RDF graph output.
|
||||
// Term type.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://www.w3.org/2004/02/skos/core#Concept',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'Term type found in RDF output (skos:Concept).');
|
||||
// Term label.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $term->getName(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2000/01/rdf-schema#label', $expected_value), 'Term label found in RDF output (rdfs:label).');
|
||||
// Term label.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $term->getName(),
|
||||
'lang' => 'en',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($term_uri, 'http://www.w3.org/2004/02/skos/core#prefLabel', $expected_value), 'Term label found in RDF output (skos:prefLabel).');
|
||||
|
||||
// @todo Add test for term description once it is a field:
|
|
@ -1,32 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\rdf\Tests;
|
||||
namespace Drupal\Tests\rdf\Functional;
|
||||
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the RDFa markup of Users.
|
||||
*
|
||||
* @group rdf
|
||||
*/
|
||||
class UserAttributesTest extends WebTestBase {
|
||||
class UserAttributesTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf', 'node');
|
||||
public static $modules = ['rdf', 'node'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
rdf_get_mapping('user', 'user')
|
||||
->setBundleMapping(array(
|
||||
'types' => array('sioc:UserAccount'),
|
||||
))
|
||||
->setFieldMapping('name', array(
|
||||
'properties' => array('foaf:name'),
|
||||
))
|
||||
->setBundleMapping([
|
||||
'types' => ['sioc:UserAccount'],
|
||||
])
|
||||
->setFieldMapping('name', [
|
||||
'properties' => ['foaf:name'],
|
||||
])
|
||||
->save();
|
||||
}
|
||||
|
||||
|
@ -36,21 +36,21 @@ class UserAttributesTest extends WebTestBase {
|
|||
* Creates a random user and ensures the default mapping for the user is
|
||||
* being used.
|
||||
*/
|
||||
function testUserAttributesInMarkup() {
|
||||
public function testUserAttributesInMarkup() {
|
||||
// Creates users that should and should not be truncated
|
||||
// by template_preprocess_username (20 characters)
|
||||
// one of these users tests right on the cusp (20).
|
||||
$user1 = $this->drupalCreateUser(array('access user profiles'));
|
||||
$user1 = $this->drupalCreateUser(['access user profiles']);
|
||||
|
||||
$authors = array(
|
||||
$this->drupalCreateUser(array(), $this->randomMachineName(30)),
|
||||
$this->drupalCreateUser(array(), $this->randomMachineName(20)),
|
||||
$this->drupalCreateUser(array(), $this->randomMachineName(5))
|
||||
);
|
||||
$authors = [
|
||||
$this->drupalCreateUser([], $this->randomMachineName(30)),
|
||||
$this->drupalCreateUser([], $this->randomMachineName(20)),
|
||||
$this->drupalCreateUser([], $this->randomMachineName(5))
|
||||
];
|
||||
|
||||
$this->drupalLogin($user1);
|
||||
|
||||
$this->drupalCreateContentType(array('type' => 'article'));
|
||||
$this->drupalCreateContentType(['type' => 'article']);
|
||||
|
||||
/** @var \Drupal\user\UserInterface[] $authors */
|
||||
foreach ($authors as $author) {
|
||||
|
@ -65,21 +65,21 @@ class UserAttributesTest extends WebTestBase {
|
|||
|
||||
// Inspects RDF graph output.
|
||||
// User type.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://rdfs.org/sioc/ns#UserAccount',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).');
|
||||
// User name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $author->getUsername(),
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
|
||||
|
||||
// User creates a node.
|
||||
$this->drupalLogin($author);
|
||||
$node = $this->drupalCreateNode(array('type' => 'article', 'promote' => 1));
|
||||
$node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1]);
|
||||
$this->drupalLogin($user1);
|
||||
|
||||
// Parses the node created by the user.
|
||||
|
@ -90,16 +90,16 @@ class UserAttributesTest extends WebTestBase {
|
|||
|
||||
// Ensures the default bundle mapping for user is used on the Authored By
|
||||
// information on the node.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'uri',
|
||||
'value' => 'http://rdfs.org/sioc/ns#UserAccount',
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($account_uri, 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type', $expected_value), 'User type found in RDF output (sioc:UserAccount).');
|
||||
// User name.
|
||||
$expected_value = array(
|
||||
$expected_value = [
|
||||
'type' => 'literal',
|
||||
'value' => $author->getUsername(),
|
||||
);
|
||||
];
|
||||
$this->assertTrue($graph->hasProperty($account_uri, 'http://xmlns.com/foaf/0.1/name', $expected_value), 'User name found in RDF output (foaf:name).');
|
||||
|
||||
}
|
|
@ -16,7 +16,7 @@ class CrudTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('entity_test', 'rdf', 'system');
|
||||
public static $modules = ['entity_test', 'rdf', 'system'];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -42,7 +42,7 @@ class CrudTest extends KernelTestBase {
|
|||
/**
|
||||
* Tests creation of RDF mapping.
|
||||
*/
|
||||
function testMappingCreation() {
|
||||
public function testMappingCreation() {
|
||||
$mapping_config_name = "{$this->prefix}.{$this->entityType}.{$this->bundle}";
|
||||
|
||||
// Save bundle mapping config.
|
||||
|
@ -55,20 +55,20 @@ class CrudTest extends KernelTestBase {
|
|||
/**
|
||||
* Test the handling of bundle mappings.
|
||||
*/
|
||||
function testBundleMapping() {
|
||||
public function testBundleMapping() {
|
||||
// Test that the bundle mapping can be saved.
|
||||
$types = array('sioc:Post', 'foaf:Document');
|
||||
$types = ['sioc:Post', 'foaf:Document'];
|
||||
rdf_get_mapping($this->entityType, $this->bundle)
|
||||
->setBundleMapping(array('types' => $types))
|
||||
->setBundleMapping(['types' => $types])
|
||||
->save();
|
||||
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
|
||||
->getBundleMapping();
|
||||
$this->assertEqual($types, $bundle_mapping['types'], 'Bundle mapping saved.');
|
||||
|
||||
// Test that the bundle mapping can be edited.
|
||||
$types = array('schema:BlogPosting');
|
||||
$types = ['schema:BlogPosting'];
|
||||
rdf_get_mapping($this->entityType, $this->bundle)
|
||||
->setBundleMapping(array('types' => $types))
|
||||
->setBundleMapping(['types' => $types])
|
||||
->save();
|
||||
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
|
||||
->getBundleMapping();
|
||||
|
@ -78,15 +78,15 @@ class CrudTest extends KernelTestBase {
|
|||
/**
|
||||
* Test the handling of field mappings.
|
||||
*/
|
||||
function testFieldMapping() {
|
||||
public function testFieldMapping() {
|
||||
$field_name = 'created';
|
||||
|
||||
// Test that the field mapping can be saved.
|
||||
$mapping = array(
|
||||
'properties' => array('dc:created'),
|
||||
$mapping = [
|
||||
'properties' => ['dc:created'],
|
||||
'datatype' => 'xsd:dateTime',
|
||||
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
|
||||
);
|
||||
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
|
||||
];
|
||||
rdf_get_mapping($this->entityType, $this->bundle)
|
||||
->setFieldMapping($field_name, $mapping)
|
||||
->save();
|
||||
|
@ -95,11 +95,11 @@ class CrudTest extends KernelTestBase {
|
|||
$this->assertEqual($mapping, $field_mapping, 'Field mapping saved.');
|
||||
|
||||
// Test that the field mapping can be edited.
|
||||
$mapping = array(
|
||||
'properties' => array('dc:date'),
|
||||
$mapping = [
|
||||
'properties' => ['dc:date'],
|
||||
'datatype' => 'foo:bar',
|
||||
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
|
||||
);
|
||||
'datatype_callback' => ['callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'],
|
||||
];
|
||||
rdf_get_mapping($this->entityType, $this->bundle)
|
||||
->setFieldMapping($field_name, $mapping)
|
||||
->save();
|
||||
|
|
|
@ -26,7 +26,7 @@ class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('datetime');
|
||||
public static $modules = ['datetime'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -35,12 +35,12 @@ class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
|
|||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:dateCreated'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:dateCreated'],
|
||||
])->save();
|
||||
|
||||
// Set up test entity.
|
||||
$this->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->value = $this->testValue;
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ class DateTimeFieldRdfaTest extends FieldRdfaTestBase {
|
|||
* Tests the default formatter.
|
||||
*/
|
||||
public function testDefaultFormatter() {
|
||||
$this->assertFormatterRdfa(array('type' => 'datetime_default'), 'http://schema.org/dateCreated', array('value' => $this->testValue . 'Z', 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'));
|
||||
$this->assertFormatterRdfa(['type' => 'datetime_default'], 'http://schema.org/dateCreated', ['value' => $this->testValue . 'Z', 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('text');
|
||||
public static $modules = ['text'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -28,13 +28,13 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
|
|||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:email'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:email'],
|
||||
])->save();
|
||||
|
||||
// Set up test values.
|
||||
$this->testValue = 'test@example.com';
|
||||
$this->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->value = $this->testValue;
|
||||
}
|
||||
|
||||
|
@ -43,9 +43,9 @@ class EmailFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testAllFormatters() {
|
||||
// Test the plain formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'string'), 'http://schema.org/email', array('value' => $this->testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'string'], 'http://schema.org/email', ['value' => $this->testValue]);
|
||||
// Test the mailto formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'email_mailto'), 'http://schema.org/email', array('value' => $this->testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'email_mailto'], 'http://schema.org/email', ['value' => $this->testValue]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
|
|||
$this->installEntitySchema('entity_test_rev');
|
||||
|
||||
// Give anonymous users permission to view test entities.
|
||||
$this->installConfig(array('user'));
|
||||
$this->installConfig(['user']);
|
||||
Role::load(RoleInterface::ANONYMOUS_ID)
|
||||
->grantPermission('view test entity')
|
||||
->save();
|
||||
|
@ -61,20 +61,20 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
|
|||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:knows'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:knows'],
|
||||
])->save();
|
||||
|
||||
// Create the entity to be referenced.
|
||||
$this->targetEntity = $this->container->get('entity_type.manager')
|
||||
->getStorage($this->entityType)
|
||||
->create(array('name' => $this->randomMachineName()));
|
||||
->create(['name' => $this->randomMachineName()]);
|
||||
$this->targetEntity->save();
|
||||
|
||||
// Create the entity that will have the entity reference field.
|
||||
$this->entity = $this->container->get('entity_type.manager')
|
||||
->getStorage($this->entityType)
|
||||
->create(array('name' => $this->randomMachineName()));
|
||||
->create(['name' => $this->randomMachineName()]);
|
||||
$this->entity->save();
|
||||
$this->entity->{$this->fieldName}->entity = $this->targetEntity;
|
||||
$this->uri = $this->getAbsoluteUri($this->entity);
|
||||
|
@ -87,9 +87,9 @@ class EntityReferenceRdfaTest extends FieldRdfaTestBase {
|
|||
$entity_uri = $this->getAbsoluteUri($this->targetEntity);
|
||||
|
||||
// Tests the label formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'entity_reference_label'), 'http://schema.org/knows', array('value' => $entity_uri, 'type' => 'uri'));
|
||||
$this->assertFormatterRdfa(['type' => 'entity_reference_label'], 'http://schema.org/knows', ['value' => $entity_uri, 'type' => 'uri']);
|
||||
// Tests the entity formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'entity_reference_entity_view'), 'http://schema.org/knows', array('value' => $entity_uri, 'type' => 'uri'));
|
||||
$this->assertFormatterRdfa(['type' => 'entity_reference_entity_view'], 'http://schema.org/knows', ['value' => $entity_uri, 'type' => 'uri']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,23 +19,23 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('text', 'filter');
|
||||
public static $modules = ['text', 'filter'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->createTestField();
|
||||
|
||||
$this->installConfig(array('filter'));
|
||||
$this->installConfig(['filter']);
|
||||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:interactionCount'),
|
||||
'datatype_callback' => array(
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:interactionCount'],
|
||||
'datatype_callback' => [
|
||||
'callable' => 'Drupal\rdf\Tests\Field\TestDataConverter::convertFoo',
|
||||
),
|
||||
))->save();
|
||||
],
|
||||
])->save();
|
||||
|
||||
// Set up test values.
|
||||
$this->testValue = $this->randomMachineName();
|
||||
|
@ -51,7 +51,7 @@ class FieldRdfaDatatypeCallbackTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testDefaultFormatter() {
|
||||
// Expected value is the output of the datatype callback, not the raw value.
|
||||
$this->assertFormatterRdfa(array('type' => 'text_default'), 'http://schema.org/interactionCount', array('value' => 'foo' . $this->testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'text_default'], 'http://schema.org/interactionCount', ['value' => 'foo' . $this->testValue]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf');
|
||||
public static $modules = ['rdf'];
|
||||
|
||||
/**
|
||||
* @var string
|
||||
|
@ -83,7 +83,7 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
|
|||
* - datatype: (optional) The datatype of the value (e.g. xsd:dateTime).
|
||||
*/
|
||||
protected function assertFormatterRdfa($formatter, $property, $expected_rdf_value) {
|
||||
$expected_rdf_value += array('type' => 'literal');
|
||||
$expected_rdf_value += ['type' => 'literal'];
|
||||
|
||||
// The field formatter will be rendered inside the entity. Set the field
|
||||
// formatter in the entity display options before rendering the entity.
|
||||
|
@ -111,12 +111,12 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
|
|||
* @param array $field_settings
|
||||
* (optional) An array of field settings.
|
||||
*/
|
||||
protected function createTestField($field_settings = array()) {
|
||||
FieldStorageConfig::create(array(
|
||||
protected function createTestField($field_settings = []) {
|
||||
FieldStorageConfig::create([
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => $this->fieldType,
|
||||
))->save();
|
||||
])->save();
|
||||
FieldConfig::create([
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => $this->fieldName,
|
||||
|
@ -135,7 +135,7 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
|
|||
* The absolute URI.
|
||||
*/
|
||||
protected function getAbsoluteUri($entity) {
|
||||
return $entity->url('canonical', array('absolute' => TRUE));
|
||||
return $entity->url('canonical', ['absolute' => TRUE]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -172,14 +172,14 @@ abstract class FieldRdfaTestBase extends FieldKernelTestBase {
|
|||
* format and return values see the SimpleXML documentation,
|
||||
* http://php.net/manual/function.simplexml-element-xpath.php.
|
||||
*/
|
||||
protected function xpathContent($content, $xpath, array $arguments = array()) {
|
||||
protected function xpathContent($content, $xpath, array $arguments = []) {
|
||||
if ($elements = $this->parseContent($content)) {
|
||||
$xpath = $this->buildXPathQuery($xpath, $arguments);
|
||||
$result = $elements->xpath($xpath);
|
||||
// Some combinations of PHP / libxml versions return an empty array
|
||||
// instead of the documented FALSE. Forcefully convert any falsish values
|
||||
// to an empty array to allow foreach(...) constructions.
|
||||
return $result ? $result : array();
|
||||
return $result ? $result : [];
|
||||
}
|
||||
else {
|
||||
return FALSE;
|
||||
|
|
|
@ -19,7 +19,7 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('link', 'text');
|
||||
public static $modules = ['link', 'text'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -31,9 +31,9 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
|
|||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:link'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:link'],
|
||||
])->save();
|
||||
|
||||
}
|
||||
|
||||
|
@ -43,14 +43,14 @@ 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->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->uri = $this->testValue;
|
||||
|
||||
// Set up the expected result.
|
||||
$expected_rdf = array(
|
||||
$expected_rdf = [
|
||||
'value' => $this->testValue,
|
||||
'type' => 'uri',
|
||||
);
|
||||
];
|
||||
|
||||
$this->runTestAllFormatters($expected_rdf, 'external');
|
||||
}
|
||||
|
@ -61,15 +61,15 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
|
|||
public function testAllFormattersInternal() {
|
||||
// Set up test values.
|
||||
$this->testValue = 'admin';
|
||||
$this->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->uri = 'internal:/admin';
|
||||
|
||||
// Set up the expected result.
|
||||
// AssertFormatterRdfa looks for a full path.
|
||||
$expected_rdf = array(
|
||||
$expected_rdf = [
|
||||
'value' => $this->uri . '/' . $this->testValue,
|
||||
'type' => 'uri',
|
||||
);
|
||||
];
|
||||
|
||||
$this->runTestAllFormatters($expected_rdf, 'internal');
|
||||
}
|
||||
|
@ -80,14 +80,14 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
|
|||
public function testAllFormattersFront() {
|
||||
// Set up test values.
|
||||
$this->testValue = '/';
|
||||
$this->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->uri = 'internal:/';
|
||||
|
||||
// Set up the expected result.
|
||||
$expected_rdf = array(
|
||||
$expected_rdf = [
|
||||
'value' => $this->uri . '/',
|
||||
'type' => 'uri',
|
||||
);
|
||||
];
|
||||
|
||||
$this->runTestAllFormatters($expected_rdf, 'front');
|
||||
}
|
||||
|
@ -98,86 +98,86 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
|
|||
public function runTestAllFormatters($expected_rdf, $type = NULL) {
|
||||
|
||||
// Test the link formatter: trim at 80, no other settings.
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'link',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'trim_length' => 80,
|
||||
'url_only' => FALSE,
|
||||
'url_plain' => FALSE,
|
||||
'rel' => '',
|
||||
'target' => '',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
|
||||
|
||||
// Test the link formatter: trim at 40, nofollow, new window.
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'link',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'trim_length' => 40,
|
||||
'url_only' => FALSE,
|
||||
'url_plain' => FALSE,
|
||||
'rel' => 'nofollow',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
|
||||
|
||||
// Test the link formatter: trim at 40, URL only (not plaintext) nofollow,
|
||||
// new window.
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'link',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'trim_length' => 40,
|
||||
'url_only' => TRUE,
|
||||
'url_plain' => FALSE,
|
||||
'rel' => 'nofollow',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
|
||||
|
||||
// Test the link_separate formatter: trim at 40, nofollow, new window.
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'link_separate',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'trim_length' => 40,
|
||||
'rel' => 'nofollow',
|
||||
'target' => '_blank',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
|
||||
|
||||
// Change the expected value here to literal. When formatted as plaintext
|
||||
// then the RDF is expecting a 'literal' not a 'uri'.
|
||||
$expected_rdf = array(
|
||||
$expected_rdf = [
|
||||
'value' => $this->testValue,
|
||||
'type' => 'literal',
|
||||
);
|
||||
];
|
||||
// Test the link formatter: trim at 20, url only (as plaintext.)
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'link',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'trim_length' => 20,
|
||||
'url_only' => TRUE,
|
||||
'url_plain' => TRUE,
|
||||
'rel' => '0',
|
||||
'target' => '0',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
|
||||
|
||||
// Test the link formatter: do not trim, url only (as plaintext.)
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'link',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'trim_length' => 0,
|
||||
'url_only' => TRUE,
|
||||
'url_plain' => TRUE,
|
||||
'rel' => '0',
|
||||
'target' => '0',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/link', $expected_rdf);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
$testValue = 3;
|
||||
$this->createTestField();
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa(array('type' => 'number_integer'), 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'number_integer'], 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is not created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
|
||||
|
@ -31,26 +31,26 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testIntegerFormatterWithSettings() {
|
||||
\Drupal::service('theme_handler')->install(['classy']);
|
||||
\Drupal::service('theme_handler')->setDefault('classy');
|
||||
$this->config('system.theme')->set('default', 'classy')->save();
|
||||
$this->fieldType = 'integer';
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'number_integer',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'thousand_separator' => '.',
|
||||
'prefix_suffix' => TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$testValue = 3333333.33;
|
||||
$field_settings = array(
|
||||
$field_settings = [
|
||||
'prefix' => '#',
|
||||
'suffix' => ' llamas.',
|
||||
);
|
||||
];
|
||||
$this->createTestField($field_settings);
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
$testValue = 3.33;
|
||||
$this->createTestField();
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa(array('type' => 'number_unformatted'), 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'number_unformatted'], 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is not created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
|
||||
|
@ -74,27 +74,27 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testFloatFormatterWithSettings() {
|
||||
\Drupal::service('theme_handler')->install(['classy']);
|
||||
\Drupal::service('theme_handler')->setDefault('classy');
|
||||
$this->config('system.theme')->set('default', 'classy')->save();
|
||||
$this->fieldType = 'float';
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'number_decimal',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'thousand_separator' => '.',
|
||||
'decimal_separator' => ',',
|
||||
'prefix_suffix' => TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$testValue = 3333333.33;
|
||||
$field_settings = array(
|
||||
$field_settings = [
|
||||
'prefix' => '$',
|
||||
'suffix' => ' more.',
|
||||
);
|
||||
];
|
||||
$this->createTestField($field_settings);
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -103,16 +103,16 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testFloatFormatterWithScale() {
|
||||
$this->fieldType = 'float';
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'number_decimal',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'scale' => 5,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$testValue = 3.33;
|
||||
$this->createTestField();
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is not created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
|
||||
|
@ -124,21 +124,21 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testFloatFormatterWithScaleExercised() {
|
||||
\Drupal::service('theme_handler')->install(['classy']);
|
||||
\Drupal::service('theme_handler')->setDefault('classy');
|
||||
$this->config('system.theme')->set('default', 'classy')->save();
|
||||
$this->fieldType = 'float';
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'number_decimal',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'scale' => 5,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$testValue = 3.1234567;
|
||||
$this->createTestField();
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
$testValue = 3.33;
|
||||
$this->createTestField();
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa(array('type' => 'number_decimal'), 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'number_decimal'], 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is not created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__items") and @content]');
|
||||
|
@ -162,27 +162,27 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testDecimalFormatterWithSettings() {
|
||||
\Drupal::service('theme_handler')->install(['classy']);
|
||||
\Drupal::service('theme_handler')->setDefault('classy');
|
||||
$this->config('system.theme')->set('default', 'classy')->save();
|
||||
$this->fieldType = 'decimal';
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'number_decimal',
|
||||
'settings' => array(
|
||||
'settings' => [
|
||||
'thousand_separator' => 't',
|
||||
'decimal_separator' => '#',
|
||||
'prefix_suffix' => TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
$testValue = 3333333.33;
|
||||
$field_settings = array(
|
||||
$field_settings = [
|
||||
'prefix' => '$',
|
||||
'suffix' => ' more.',
|
||||
);
|
||||
];
|
||||
$this->createTestField($field_settings);
|
||||
$this->createTestEntity($testValue);
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', array('value' => $testValue));
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/baseSalary', ['value' => $testValue]);
|
||||
|
||||
// Test that the content attribute is created.
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', array(':testValue' => $testValue));
|
||||
$result = $this->xpathContent($this->getRawContent(), '//div[contains(@class, "field__item") and @content=:testValue]', [':testValue' => $testValue]);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -192,12 +192,12 @@ class NumberFieldRdfaTest extends FieldRdfaTestBase {
|
|||
protected function createTestEntity($testValue) {
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:baseSalary'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:baseSalary'],
|
||||
])->save();
|
||||
|
||||
// Set up test entity.
|
||||
$this->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->value = $testValue;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,9 +37,9 @@ class StringFieldRdfaTest extends FieldRdfaTestBase {
|
|||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:text'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:text'],
|
||||
])->save();
|
||||
|
||||
// Set up test entity.
|
||||
$this->entity = EntityTest::create();
|
||||
|
@ -52,7 +52,7 @@ class StringFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testStringFormatters() {
|
||||
// Tests the string formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'string'), 'http://schema.org/text', array('value' => $this->testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'string'], 'http://schema.org/text', ['value' => $this->testValue]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('telephone', 'text');
|
||||
public static $modules = ['telephone', 'text'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
@ -35,13 +35,13 @@ class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
|
|||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:telephone'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:telephone'],
|
||||
])->save();
|
||||
|
||||
// Set up test values.
|
||||
$this->testValue = '555-555-5555';
|
||||
$this->entity = EntityTest::create(array());
|
||||
$this->entity = EntityTest::create([]);
|
||||
$this->entity->{$this->fieldName}->value = $this->testValue;
|
||||
}
|
||||
|
||||
|
@ -50,18 +50,18 @@ class TelephoneFieldRdfaTest extends FieldRdfaTestBase {
|
|||
*/
|
||||
public function testAllFormatters() {
|
||||
// Tests the plain formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'string'), 'http://schema.org/telephone', array('value' => $this->testValue));
|
||||
$this->assertFormatterRdfa(['type' => 'string'], 'http://schema.org/telephone', ['value' => $this->testValue]);
|
||||
// Tests the telephone link formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'telephone_link'), 'http://schema.org/telephone', array('value' => 'tel:' . $this->testValue, 'type' => 'uri'));
|
||||
$this->assertFormatterRdfa(['type' => 'telephone_link'], 'http://schema.org/telephone', ['value' => 'tel:' . $this->testValue, 'type' => 'uri']);
|
||||
|
||||
$formatter = array(
|
||||
$formatter = [
|
||||
'type' => 'telephone_link',
|
||||
'settings' => array('title' => 'Contact us'),
|
||||
);
|
||||
$expected_rdf_value = array(
|
||||
'settings' => ['title' => 'Contact us'],
|
||||
];
|
||||
$expected_rdf_value = [
|
||||
'value' => 'tel:' . $this->testValue,
|
||||
'type' => 'uri',
|
||||
);
|
||||
];
|
||||
// Tests the telephone link formatter with custom title.
|
||||
$this->assertFormatterRdfa($formatter, 'http://schema.org/telephone', $expected_rdf_value);
|
||||
}
|
||||
|
|
|
@ -33,20 +33,20 @@ class TextFieldRdfaTest extends FieldRdfaTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('text', 'filter');
|
||||
public static $modules = ['text', 'filter'];
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(array('filter'));
|
||||
$this->installConfig(['filter']);
|
||||
|
||||
$this->createTestField();
|
||||
|
||||
// Add the mapping.
|
||||
$mapping = rdf_get_mapping('entity_test', 'entity_test');
|
||||
$mapping->setFieldMapping($this->fieldName, array(
|
||||
'properties' => array('schema:text'),
|
||||
))->save();
|
||||
$mapping->setFieldMapping($this->fieldName, [
|
||||
'properties' => ['schema:text'],
|
||||
])->save();
|
||||
|
||||
// Set up test entity.
|
||||
$this->entity = EntityTest::create();
|
||||
|
@ -63,11 +63,11 @@ class TextFieldRdfaTest extends FieldRdfaTestBase {
|
|||
$formatted_value = strip_tags($this->entity->{$this->fieldName}->processed);
|
||||
|
||||
// Tests the default formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'text_default'), 'http://schema.org/text', array('value' => $formatted_value));
|
||||
$this->assertFormatterRdfa(['type' => 'text_default'], 'http://schema.org/text', ['value' => $formatted_value]);
|
||||
// Tests the summary formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'text_summary_or_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
|
||||
$this->assertFormatterRdfa(['type' => 'text_summary_or_trimmed'], 'http://schema.org/text', ['value' => $formatted_value]);
|
||||
// Tests the trimmed formatter.
|
||||
$this->assertFormatterRdfa(array('type' => 'text_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
|
||||
$this->assertFormatterRdfa(['type' => 'text_trimmed'], 'http://schema.org/text', ['value' => $formatted_value]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,16 +16,16 @@ class RdfaAttributesTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('rdf');
|
||||
public static $modules = ['rdf'];
|
||||
|
||||
/**
|
||||
* Test attribute creation for mappings which use 'property'.
|
||||
*/
|
||||
function testProperty() {
|
||||
$properties = array('dc:title');
|
||||
public function testProperty() {
|
||||
$properties = ['dc:title'];
|
||||
|
||||
$mapping = array('properties' => $properties);
|
||||
$expected_attributes = array('property' => $properties);
|
||||
$mapping = ['properties' => $properties];
|
||||
$expected_attributes = ['property' => $properties];
|
||||
|
||||
$this->_testAttributes($expected_attributes, $mapping);
|
||||
}
|
||||
|
@ -33,18 +33,18 @@ class RdfaAttributesTest extends KernelTestBase {
|
|||
/**
|
||||
* Test attribute creation for mappings which use 'datatype'.
|
||||
*/
|
||||
function testDatatype() {
|
||||
$properties = array('foo:bar1');
|
||||
public function testDatatype() {
|
||||
$properties = ['foo:bar1'];
|
||||
$datatype = 'foo:bar1type';
|
||||
|
||||
$mapping = array(
|
||||
$mapping = [
|
||||
'datatype' => $datatype,
|
||||
'properties' => $properties,
|
||||
);
|
||||
$expected_attributes = array(
|
||||
];
|
||||
$expected_attributes = [
|
||||
'datatype' => $datatype,
|
||||
'property' => $properties,
|
||||
);
|
||||
];
|
||||
|
||||
$this->_testAttributes($expected_attributes, $mapping);
|
||||
}
|
||||
|
@ -52,23 +52,23 @@ class RdfaAttributesTest extends KernelTestBase {
|
|||
/**
|
||||
* Test attribute creation for mappings which override human-readable content.
|
||||
*/
|
||||
function testDatatypeCallback() {
|
||||
$properties = array('dc:created');
|
||||
public function testDatatypeCallback() {
|
||||
$properties = ['dc:created'];
|
||||
$datatype = 'xsd:dateTime';
|
||||
|
||||
$date = 1252750327;
|
||||
$iso_date = date('c', $date);
|
||||
|
||||
$mapping = array(
|
||||
$mapping = [
|
||||
'datatype' => $datatype,
|
||||
'properties' => $properties,
|
||||
'datatype_callback' => array('callable' => 'date_iso8601'),
|
||||
);
|
||||
$expected_attributes = array(
|
||||
'datatype_callback' => ['callable' => 'date_iso8601'],
|
||||
];
|
||||
$expected_attributes = [
|
||||
'datatype' => $datatype,
|
||||
'property' => $properties,
|
||||
'content' => $iso_date,
|
||||
);
|
||||
];
|
||||
|
||||
$this->_testAttributes($expected_attributes, $mapping, $date);
|
||||
}
|
||||
|
@ -77,23 +77,23 @@ class RdfaAttributesTest extends KernelTestBase {
|
|||
/**
|
||||
* Test attribute creation for mappings which use data converters.
|
||||
*/
|
||||
function testDatatypeCallbackWithConverter() {
|
||||
$properties = array('schema:interactionCount');
|
||||
public function testDatatypeCallbackWithConverter() {
|
||||
$properties = ['schema:interactionCount'];
|
||||
|
||||
$data = "23";
|
||||
$content = "UserComments:23";
|
||||
|
||||
$mapping = array(
|
||||
$mapping = [
|
||||
'properties' => $properties,
|
||||
'datatype_callback' => array(
|
||||
'datatype_callback' => [
|
||||
'callable' => 'Drupal\rdf\SchemaOrgDataConverter::interactionCount',
|
||||
'arguments' => array('interaction_type' => 'UserComments'),
|
||||
),
|
||||
);
|
||||
$expected_attributes = array(
|
||||
'arguments' => ['interaction_type' => 'UserComments'],
|
||||
],
|
||||
];
|
||||
$expected_attributes = [
|
||||
'property' => $properties,
|
||||
'content' => $content,
|
||||
);
|
||||
];
|
||||
|
||||
$this->_testAttributes($expected_attributes, $mapping, $data);
|
||||
}
|
||||
|
@ -101,14 +101,14 @@ class RdfaAttributesTest extends KernelTestBase {
|
|||
/**
|
||||
* Test attribute creation for mappings which use 'rel'.
|
||||
*/
|
||||
function testRel() {
|
||||
$properties = array('sioc:has_creator', 'dc:creator');
|
||||
public function testRel() {
|
||||
$properties = ['sioc:has_creator', 'dc:creator'];
|
||||
|
||||
$mapping = array(
|
||||
$mapping = [
|
||||
'properties' => $properties,
|
||||
'mapping_type' => 'rel',
|
||||
);
|
||||
$expected_attributes = array('rel' => $properties);
|
||||
];
|
||||
$expected_attributes = ['rel' => $properties];
|
||||
|
||||
$this->_testAttributes($expected_attributes, $mapping);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
$target_entity_type->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('test_module'));
|
||||
$values = array('targetEntityType' => $target_entity_type_id);
|
||||
$values = ['targetEntityType' => $target_entity_type_id];
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getBundleEntityType')
|
||||
->will($this->returnValue(NULL));
|
||||
|
@ -99,23 +99,23 @@ class RdfMappingConfigEntityUnitTest extends UnitTestCase {
|
|||
$target_entity_type_id = $this->randomMachineName(16);
|
||||
$target_entity_type = $this->getMock('\Drupal\Core\Entity\EntityTypeInterface');
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('test_module'));
|
||||
->method('getProvider')
|
||||
->will($this->returnValue('test_module'));
|
||||
$bundle_id = $this->randomMachineName(10);
|
||||
$values = array('targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id);
|
||||
$values = ['targetEntityType' => $target_entity_type_id , 'bundle' => $bundle_id];
|
||||
|
||||
$target_entity_type->expects($this->any())
|
||||
->method('getBundleConfigDependency')
|
||||
->will($this->returnValue(array('type' => 'config', 'name' => 'test_module.type.' . $bundle_id)));
|
||||
->will($this->returnValue(['type' => 'config', 'name' => 'test_module.type.' . $bundle_id]));
|
||||
|
||||
$this->entityManager->expects($this->at(0))
|
||||
->method('getDefinition')
|
||||
->with($target_entity_type_id)
|
||||
->will($this->returnValue($target_entity_type));
|
||||
->method('getDefinition')
|
||||
->with($target_entity_type_id)
|
||||
->will($this->returnValue($target_entity_type));
|
||||
$this->entityManager->expects($this->at(1))
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
->method('getDefinition')
|
||||
->with($this->entityTypeId)
|
||||
->will($this->returnValue($this->entityType));
|
||||
|
||||
$entity = new RdfMapping($values, $this->entityTypeId);
|
||||
$dependencies = $entity->calculateDependencies()->getDependencies();
|
||||
|
|
Reference in a new issue