You are here

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

Tests Field Mapping Form and save function for unmapped content type.

File

src/Tests/RdfUiFieldMappingTest.php, line 53

Class

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

Namespace

Drupal\rdfui\Tests

Code

protected function testUnmappedTypeFieldUI() {
  echo "in first test case";
  $manage_fields = 'admin/structure/types/manage/' . $this->type;
  $rdf_mappings = $manage_fields . '/fields/rdf';
  $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:name';
  $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.");
}