You are here

protected function RdfUiFieldMappingTest::testMappedTypeFieldUI in Schema.org configuration tool (RDF UI) 8

Tests FieldMappingForm for content type mapped to a RDF type.

File

src/Tests/RdfUiFieldMappingTest.php, line 83

Class

RdfUiFieldMappingTest
Tests the functionality of the RDF UI Field Mapping form.

Namespace

Drupal\rdfui\Tests

Code

protected function testMappedTypeFieldUI() {
  $mapping = rdf_get_mapping('node', $this->type);
  $mapping
    ->setBundleMapping(array(
    'types' => array(
      "schema:Person",
    ),
  ))
    ->save();
  $manage_fields = 'admin/structure/types/manage/' . $this->type;
  $rdf_mappings = $manage_fields . '/fields/rdf';

  // Create a field, and a node with some data for the field.
  $label = 'Test field';
  $this
    ->fieldUIAddNewField($manage_fields, 'test', $label, 'text');

  // Display the "Manage fields RDF" screen and check that the expected fields
  // are displayed.
  $this
    ->drupalGet($rdf_mappings);
  $this
    ->assertFieldByXPath('//table[@id="rdf-mapping"]//tr/td[1]', $label, 'Field is displayed in manage field RDF page.');
  $this
    ->assertFieldByXPath('//table[@id="rdf-mapping"]//tr[@id="field-test"]/td[4]', 'Unmapped', 'Status displayed correctly when field is unmapped.');

  // Add RDF property and save.
  $mapped_value = 'schema:birthDate';
  $edit = array(
    'fields[field_test][rdf-predicate]' => $mapped_value,
  );
  $this
    ->drupalPostForm($rdf_mappings, $edit, t('Save'));
  $this
    ->assertRaw(t('Your settings have been saved.'), 'Manage Field RDF page reloaded.');
  $this
    ->assertFieldByXPath('//table[@id="rdf-mapping"]//tr[@id="field-test"]/td[4]', 'Mapped', 'Status displayed correctly when field is mapped.');
  $mapping = rdf_get_mapping('node', $this->type);
  $bundle_mapping = $mapping
    ->getFieldMapping('field_test');
  $this
    ->assertEqual($bundle_mapping['properties'][0], $mapped_value, "Selected RDF mappings saved.");
}