You are here

public function ConditionalFieldsUITestCase::testDependencyOperations in Conditional Fields 7.3

Tests adding, editing and deleting a dependency.

File

tests/conditional_fields.test, line 295
Test Conditional Fields functionality and UI.

Class

ConditionalFieldsUITestCase

Code

public function testDependencyOperations() {

  // Add dependency.
  $dependee = field_read_instance('node', 'dependee', 'conditional_fields_test');
  $dependent = field_read_instance('node', 'dependent', 'conditional_fields_test');
  $edit = array(
    'dependee' => $dependee['id'],
    'dependent' => $dependent['id'],
  );
  $this
    ->drupalPost('admin/structure/types/manage/conditional-fields-test/dependencies', $edit, t('Add dependency'), array(), array(), 'conditional-fields-dependency-add-form-node-conditional-fields-test');

  // Edit dependency.
  $edit = array(
    'values_set' => CONDITIONAL_FIELDS_DEPENDENCY_VALUES_AND,
    'values' => 'on',
  );
  $this
    ->drupalPost(NULL, $edit, t('Save settings'), array(
    'query' => array(
      'destination' => 'admin/structure/types/manage/conditional-fields-test/dependencies',
    ),
  ));
  $this
    ->assertRaw(t('%dependent_name is !state when %dependee_name has all the values: @values.', array(
    '%dependent_name' => t('Label of the dependent field'),
    '!state' => 'visible',
    '%dependee_name' => t('Label of the dependee field'),
    '@values' => 'on',
  )), 'The dependency was updated correctly.');

  // Delete dependency.
  $this
    ->clickLink(t('delete'));
  $this
    ->drupalPost(NULL, array(), t('Delete dependency'), array(
    'query' => array(
      'destination' => 'admin/structure/types/manage/conditional-fields-test/dependencies',
    ),
  ));
  $this
    ->assertText(t('The dependency has been deleted.'));
}