function CrudTest::testFieldMapping in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rdf/src/Tests/CrudTest.php \Drupal\rdf\Tests\CrudTest::testFieldMapping()
Test the handling of field mappings.
File
- core/
modules/ rdf/ src/ Tests/ CrudTest.php, line 86 - Contains \Drupal\rdf\Tests\CrudTest.
Class
- CrudTest
- Tests the RDF mapping CRUD functions.
Namespace
Drupal\rdf\TestsCode
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.');
}