You are here

function SchemaorgFieldUIManageFieldsTestCase::testNodeTypeEditing in Schema.org 7

Tests that schema.org terms are saved on the content type edit form.

File

./schemaorg.test, line 64
Tests for schemaorg.module.

Class

SchemaorgFieldUIManageFieldsTestCase
Schema.org Field UI tests.

Code

function testNodeTypeEditing() {
  $admin_path = 'admin/structure/types/manage/page';
  $type_element_id = 'edit-schemaorg-ui-type';
  $type_element_name = 'schemaorg_ui_type';
  $this
    ->drupalGet($admin_path);
  $this
    ->assertFieldById($type_element_id, '', t('The schema.org type was empty.'));

  // Check that the schema.org terms are saved.
  $edit = array();
  $edit[$type_element_name] = 'WebPage';
  $this
    ->drupalPost($admin_path, $edit, t('Save content type'));
  $this
    ->assertText("The content type Basic page has been updated.", t('The form was successfully submitted.'));
  entity_info_cache_clear();
  $rdf_mapping = rdf_mapping_load('node', 'page');
  $rdf_mapping_type_expected = array(
    'schema:WebPage',
    'foaf:Document',
  );
  $this
    ->assertEqual($rdf_mapping['rdftype'], $rdf_mapping_type_expected, t('The schema.org type was correctly saved.'));

  // Check that the schema.org terms shows up in the form
  $this
    ->drupalGet($admin_path);
  $this
    ->assertFieldById($type_element_id, 'WebPage', t('The schema.org type form element was displayed with the correct value.'));

  // Check that the schema.org type can be emptied.
  $edit = array();
  $edit[$type_element_name] = '';
  $this
    ->drupalPost($admin_path, $edit, t('Save content type'));
  $this
    ->assertText("The content type Basic page has been updated.", t('The form was successfully submitted.'));
  entity_info_cache_clear();
  $rdf_mapping = rdf_mapping_load('node', 'page');
  $rdf_mapping_type_expected = array(
    1 => 'foaf:Document',
  );
  $this
    ->assertEqual($rdf_mapping['rdftype'], $rdf_mapping_type_expected, t('The schema.org type mapping was correctly saved.'));
}