You are here

public function RequiredByRoleCommonWebTestCase::DotestNoneRemovedInOptionsWhenFieldIsRequired in Required by role 7

Checks that the _none option is not present in options fields when the field is required_by_role.

1 call to RequiredByRoleCommonWebTestCase::DotestNoneRemovedInOptionsWhenFieldIsRequired()
RequiredByRoleCommonWebTestCase::testCommonBehaviors in tests/required_by_role_test/RequiredByRoleCommonWebTestCase.test
Group the tests for better performance.

File

tests/required_by_role_test/RequiredByRoleCommonWebTestCase.test, line 228
Tests for the common cases.

Class

RequiredByRoleCommonWebTestCase
@file Tests for the common cases.

Code

public function DotestNoneRemovedInOptionsWhenFieldIsRequired() {

  // Display form.
  $this
    ->drupalGet('node/add/' . $this->entity_bundle);
  $langcode = LANGUAGE_NONE;
  $xpath = '//select[@id=:id]//option[@value="_none" and text()=:label]';
  $id = drupal_html_id('edit-options_field-' . $langcode);
  $arguments = array(
    ':id' => $id,
    ':label' => t('- Select -'),
  );
  $element = $this
    ->xpath($xpath, $arguments);
  $this
    ->assertFalse($element, 'A required select list should not has a "- Select -" option.');
  $arguments = array(
    ':id' => $id,
    ':label' => t('- None -'),
  );
  $element = $this
    ->xpath($xpath, $arguments);
  $this
    ->assertTrue($element, 'A required select list should not has a "- None -" option.');
}