function SchemaorgFieldUIManageFieldsTestCase::testFieldUIManageFieldsReference in Schema.org 7
Tests that schema.org property is correctly saved for advanced fields where the object is a resource (image, file, reference).
File
- ./
schemaorg.test, line 177 - Tests for schemaorg.module.
Class
- SchemaorgFieldUIManageFieldsTestCase
- Schema.org Field UI tests.
Code
function testFieldUIManageFieldsReference() {
// Create a test field and instance.
$field_name = 'test';
$field = array(
'field_name' => $field_name,
'type' => 'taxonomy_term_reference',
);
field_create_field($field);
$instance = array(
'field_name' => $field_name,
'entity_type' => 'node',
'bundle' => $this->type,
);
field_create_instance($instance);
$langcode = LANGUAGE_NONE;
$admin_path = 'admin/structure/types/manage/' . $this->hyphen_type . '/fields/' . $field_name;
$element_id = 'edit-schemaorg-ui-field-property';
$element_name = 'schemaorg_ui_field_property';
$this
->drupalGet($admin_path);
$this
->assertFieldById($element_id, '', t('The schema.org property was empty.'));
// Check that the schema.org property is saved.
$edit = array(
$element_name => 'telephone',
);
$this
->drupalPost($admin_path, $edit, t('Save settings'));
$this
->assertText("Saved {$field_name} configuration", t('The form was successfully submitted.'));
$rdf_mapping = rdf_mapping_load('node', $this->type);
$rdf_mapping_field_expected = array(
'predicates' => array(
'schema:telephone',
),
'type' => 'rel',
);
$this
->assertEqual($rdf_mapping[$field_name], $rdf_mapping_field_expected, t('The schema.org property was correctly saved.'));
// Check that the schema.org property shows up in the form
$this
->drupalGet($admin_path);
$this
->assertFieldById($element_id, 'telephone', t('The schema.org property form element was displayed with the correct value.'));
// Check that the schema.org property can be emptied.
$edit = array(
$element_name => '',
);
$this
->drupalPost($admin_path, $edit, t('Save settings'));
$this
->assertText("Saved {$field_name} configuration", t('The form was successfully submitted.'));
entity_info_cache_clear();
$rdf_mapping = rdf_mapping_load('node', $this->type);
$rdf_mapping_field_expected = array(
'predicates' => array(),
'type' => 'rel',
);
$this
->assertEqual($rdf_mapping[$field_name], $rdf_mapping_field_expected, t('The schema.org property was correctly saved.'));
}