You are here

protected function MicrodataCompoundFieldsUITestCase::subtestItemHandling in Microdata 7

Test that the compound field has item handling enabled.

1 call to MicrodataCompoundFieldsUITestCase::subtestItemHandling()
MicrodataCompoundFieldsUITestCase::testMicrodataUI in ./microdata.test
Tests the microdata UI for core fields.

File

./microdata.test, line 834
Tests for microdata.module.

Class

MicrodataCompoundFieldsUITestCase

Code

protected function subtestItemHandling($original_mapping) {
  $field_name = $this->addressfieldFieldName;
  $path = $this->field_admin . '/' . $field_name;
  $formfield_name = "microdata[fields][{$field_name}][field][is_item]";
  $itemtype_formfield_name = "microdata[fields][{$field_name}][field][item_fieldset][itemtype]";
  $itemtype = $original_mapping[$field_name]['#itemtype'][0];
  $this
    ->drupalGet($path);
  $this
    ->assertTrue($this
    ->xpath("//input[@name='{$formfield_name}' and @checked='checked']"), "Item toggle found.");
  $this
    ->assertTrue($this
    ->xpath("//input[@name='{$itemtype_formfield_name}' and @value='{$itemtype}']"), "Existing itemtype displayed.");
  $edit = array(
    $formfield_name => FALSE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save settings'));
  $this
    ->drupalGet($path);
  $this
    ->assertTrue($this
    ->xpath("//input[@name='{$formfield_name}' and not(@checked)]"), "Item toggle works.");
  $edit = array(
    $formfield_name => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Save settings'));
  $this
    ->drupalGet($path);
  $this
    ->assertTrue($this
    ->xpath("//input[@name='{$itemtype_formfield_name}' and @value='']"), "Itemtype removed from mapping after toggle.");
}