You are here

public function TaxonomyContainerTestCase::testWidget in Taxonomy container 7

Test taxonomy container widget.

File

./taxonomy_container.test, line 120
Tests for taxonomy_container.module.

Class

TaxonomyContainerTestCase
Base class for all taxonomy container test cases.

Code

public function testWidget() {
  $this
    ->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name);
  $this
    ->drupalGet('admin/structure/types/manage/article/fields/' . $this->fieldName . '/widget-type');
  $taxonomy_container_options = $this
    ->xpath('//select[@id="edit-widget-type"]/option[@value="taxonomy_container"]');
  $this
    ->assert(count($taxonomy_container_options) == 1, 'Taxonomy container widget is present');
  $this
    ->drupalPost(NULL, array(
    'widget_type' => 'taxonomy_container',
  ), t('Continue'));
  $this
    ->assertText(t('Changed the widget for field Taxonomy container test field.'));
  $this
    ->assertLink(t('Select list (with groups)'));

  // Check that widget is changed in database.
  $field_instance = field_read_instance('node', 'taxonomy_container_test_field', 'article');
  $this
    ->assert($field_instance['widget']['type'] == 'taxonomy_container', t('Widget is changed in database.'));
  $this
    ->checkSelectList();

  // Also we need check it when field isn't required.
  $field_instance['required'] = 0;
  field_update_instance($field_instance);
  $this
    ->checkSelectList(TRUE);
}