function SchemaorgFieldUIManageFieldsTestCase::testFieldUIManageFields in Schema.org 7
Tests that schema.org property is correctly saved.
File
- ./
schemaorg.test, line 105 - Tests for schemaorg.module.
Class
- SchemaorgFieldUIManageFieldsTestCase
- Schema.org Field UI tests.
Code
function testFieldUIManageFields() {
// Create a test field and instance.
$field_name = 'test';
$field = array(
'field_name' => $field_name,
'type' => 'test_field',
);
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_title_expected = array(
'predicates' => array(
'schema:name',
),
);
$rdf_mapping_url_expected = array(
'predicates' => array(
'schema:url',
),
'type' => 'rel',
);
$rdf_mapping_field_expected = array(
'predicates' => array(
'schema:telephone',
),
);
$this
->assertEqual($rdf_mapping['title'], $rdf_mapping_title_expected, t('The schema.org title property was correctly saved.'));
$this
->assertEqual($rdf_mapping['url'], $rdf_mapping_url_expected, t('The schema.org url property was correctly saved.'));
$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_title_expected = array(
'predicates' => array(),
);
$rdf_mapping_field_expected = array(
'predicates' => array(),
);
$this
->assertEqual($rdf_mapping['title'], $rdf_mapping_title_expected, t('The schema.org title mapping was correctly saved.'));
$this
->assertTrue(!isset($rdf_mapping['url']), t('The schema.org url mapping was correctly removed.'));
$this
->assertEqual($rdf_mapping[$field_name], $rdf_mapping_field_expected, t('The schema.org property was correctly saved.'));
}