Update to Drupal 8.1.1. For more information, see https://www.drupal.org/node/2718713

This commit is contained in:
Pantheon Automation 2016-05-04 14:35:41 -07:00 committed by Greg Anderson
parent c0a0d5a94c
commit 9eae24d844
669 changed files with 3873 additions and 1553 deletions

View file

@ -0,0 +1,110 @@
<?php
namespace Drupal\Tests\rdf\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests the RDF mapping CRUD functions.
*
* @group rdf
*/
class CrudTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('entity_test', 'rdf', 'system');
/**
* @var string
*/
protected $prefix;
/**
* @var string
*/
protected $entityType;
/**
* @var string
*/
protected $bundle;
protected function setUp() {
parent::setUp();
$this->prefix = 'rdf.mapping';
$this->entityType = $this->bundle = 'entity_test';
}
/**
* Tests creation of RDF mapping.
*/
function testMappingCreation() {
$mapping_config_name = "{$this->prefix}.{$this->entityType}.{$this->bundle}";
// Save bundle mapping config.
rdf_get_mapping($this->entityType, $this->bundle)->save();
// Test that config file was saved.
$mapping_config = \Drupal::configFactory()->listAll('rdf.mapping.');
$this->assertTrue(in_array($mapping_config_name, $mapping_config), 'Rdf mapping config saved.');
}
/**
* Test the handling of bundle mappings.
*/
function testBundleMapping() {
// Test that the bundle mapping can be saved.
$types = array('sioc:Post', 'foaf:Document');
rdf_get_mapping($this->entityType, $this->bundle)
->setBundleMapping(array('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');
rdf_get_mapping($this->entityType, $this->bundle)
->setBundleMapping(array('types' => $types))
->save();
$bundle_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getBundleMapping();
$this->assertEqual($types, $bundle_mapping['types'], 'Bundle mapping updated.');
}
/**
* Test the handling of field mappings.
*/
function testFieldMapping() {
$field_name = 'created';
// Test that the field mapping can be saved.
$mapping = array(
'properties' => array('dc:created'),
'datatype' => 'xsd:dateTime',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
);
rdf_get_mapping($this->entityType, $this->bundle)
->setFieldMapping($field_name, $mapping)
->save();
$field_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getFieldMapping($field_name);
$this->assertEqual($mapping, $field_mapping, 'Field mapping saved.');
// Test that the field mapping can be edited.
$mapping = array(
'properties' => array('dc:date'),
'datatype' => 'foo:bar',
'datatype_callback' => array('callable' => 'Drupal\rdf\CommonDataConverter::dateIso8601Value'),
);
rdf_get_mapping($this->entityType, $this->bundle)
->setFieldMapping($field_name, $mapping)
->save();
$field_mapping = rdf_get_mapping($this->entityType, $this->bundle)
->getFieldMapping($field_name);
$this->assertEqual($mapping, $field_mapping, 'Field mapping updated.');
}
}

View file

@ -48,6 +48,6 @@ 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(array('type' => 'datetime_default'), 'http://schema.org/dateCreated', array('value' => $this->testValue . 'Z', 'type' => 'literal', 'datatype' => 'http://www.w3.org/2001/XMLSchema#dateTime'));
}
}

View file

@ -43,8 +43,8 @@ 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(array('type' => 'string'), 'http://schema.org/email', array('value' => $this->testValue));
// Test the mailto formatter.
$this->assertFormatterRdfa(array('type'=>'email_mailto'), 'http://schema.org/email', array('value' => $this->testValue));
$this->assertFormatterRdfa(array('type' => 'email_mailto'), 'http://schema.org/email', array('value' => $this->testValue));
}
}

View file

@ -51,8 +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(array('type' => 'text_default'), 'http://schema.org/interactionCount', array('value' => 'foo' . $this->testValue));
}
}

View file

@ -85,7 +85,7 @@ class LinkFieldRdfaTest extends FieldRdfaTestBase {
// Set up the expected result.
$expected_rdf = array(
'value' => $this->uri . '/',
'value' => $this->uri . '/',
'type' => 'uri',
);

View file

@ -52,6 +52,6 @@ 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(array('type' => 'string'), 'http://schema.org/text', array('value' => $this->testValue));
}
}

View file

@ -63,10 +63,10 @@ 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(array('type' => 'text_default'), 'http://schema.org/text', array('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(array('type' => 'text_summary_or_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
// Tests the trimmed formatter.
$this->assertFormatterRdfa(array('type'=>'text_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
$this->assertFormatterRdfa(array('type' => 'text_trimmed'), 'http://schema.org/text', array('value' => $formatted_value));
}
}

View file

@ -0,0 +1,136 @@
<?php
namespace Drupal\Tests\rdf\Kernel;
use Drupal\KernelTests\KernelTestBase;
/**
* Tests RDFa attribute generation from RDF mapping.
*
* @group rdf
*/
class RdfaAttributesTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('rdf');
/**
* Test attribute creation for mappings which use 'property'.
*/
function testProperty() {
$properties = array('dc:title');
$mapping = array('properties' => $properties);
$expected_attributes = array('property' => $properties);
$this->_testAttributes($expected_attributes, $mapping);
}
/**
* Test attribute creation for mappings which use 'datatype'.
*/
function testDatatype() {
$properties = array('foo:bar1');
$datatype = 'foo:bar1type';
$mapping = array(
'datatype' => $datatype,
'properties' => $properties,
);
$expected_attributes = array(
'datatype' => $datatype,
'property' => $properties,
);
$this->_testAttributes($expected_attributes, $mapping);
}
/**
* Test attribute creation for mappings which override human-readable content.
*/
function testDatatypeCallback() {
$properties = array('dc:created');
$datatype = 'xsd:dateTime';
$date = 1252750327;
$iso_date = date('c', $date);
$mapping = array(
'datatype' => $datatype,
'properties' => $properties,
'datatype_callback' => array('callable' => 'date_iso8601'),
);
$expected_attributes = array(
'datatype' => $datatype,
'property' => $properties,
'content' => $iso_date,
);
$this->_testAttributes($expected_attributes, $mapping, $date);
}
/**
* Test attribute creation for mappings which use data converters.
*/
function testDatatypeCallbackWithConverter() {
$properties = array('schema:interactionCount');
$data = "23";
$content = "UserComments:23";
$mapping = array(
'properties' => $properties,
'datatype_callback' => array(
'callable' => 'Drupal\rdf\SchemaOrgDataConverter::interactionCount',
'arguments' => array('interaction_type' => 'UserComments'),
),
);
$expected_attributes = array(
'property' => $properties,
'content' => $content,
);
$this->_testAttributes($expected_attributes, $mapping, $data);
}
/**
* Test attribute creation for mappings which use 'rel'.
*/
function testRel() {
$properties = array('sioc:has_creator', 'dc:creator');
$mapping = array(
'properties' => $properties,
'mapping_type' => 'rel',
);
$expected_attributes = array('rel' => $properties);
$this->_testAttributes($expected_attributes, $mapping);
}
/**
* Helper function to test attribute generation.
*
* @param array $expected_attributes
* The expected return of rdf_rdfa_attributes.
* @param array $field_mapping
* The field mapping to merge into the RDF mapping config.
* @param mixed $data
* The data to pass into the datatype callback, if specified.
*/
protected function _testAttributes($expected_attributes, $field_mapping, $data = NULL) {
$mapping = rdf_get_mapping('node', 'article')
->setFieldMapping('field_test', $field_mapping)
->getPreparedFieldMapping('field_test');
$attributes = rdf_rdfa_attributes($mapping, $data);
ksort($expected_attributes);
ksort($attributes);
$this->assertEqual($expected_attributes, $attributes);
}
}