You are here

public function TaxonomyContainerTestCase::checkSelectList in Taxonomy container 7

Check select list.

Open node/add/article page and verify that all given optgroups and options are present in the select list.

1 call to TaxonomyContainerTestCase::checkSelectList()
TaxonomyContainerTestCase::testWidget in ./taxonomy_container.test
Test taxonomy container widget.

File

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

Class

TaxonomyContainerTestCase
Base class for all taxonomy container test cases.

Code

public function checkSelectList($required = FALSE) {
  $this
    ->drupalGet('node/add/article');
  $widgets = $this
    ->xpath('//select[@id="edit-taxonomy-container-test-field-und"]');
  if ($this
    ->assert(isset($widgets[0]), t('Widget found.'))) {

    // Regression test for #1281662.
    $none_exists = isset($widgets[0]->option[0]) && $widgets[0]->option[0] == t('- None -');
    if ($required) {
      $this
        ->assertTrue($none_exists, t('"!none" exists in select list', array(
        '!none' => t('- None -'),
      )));
    }
    else {
      $this
        ->assertFalse($none_exists, t('"!none" doesn\'t exist in select list', array(
        '!none' => t('- None -'),
      )));
    }
    for ($i = 0; $i < 3; $i++) {
      $options = $widgets[0]->optgroup[$i]->option;
      $this
        ->assert(count($options) == 2 && preg_match('#^\\+ .*#', $options[0]) && preg_match('#^\\+\\+ .*#', $options[1]), 'Test optgroup №' . ($i + 1));
    }
  }
}