You are here

function ReferenceOptionLimitEntityreferenceTestCase::testNodeCreateForm in Reference field option limit 7

Test the functionality on a node create form.

File

tests/reference_option_limit.test, line 259
Contains tests for the Reference option limit module.

Class

ReferenceOptionLimitEntityreferenceTestCase
Test use of the module with entityreference fields.

Code

function testNodeCreateForm() {

  // In order to test every combination of settings, we define the different
  // orthogonal settings and their ranges.
  $ranges = array(
    // The field cardinality for the matching field.
    'cardinality' => array(
      1,
      FIELD_CARDINALITY_UNLIMITED,
    ),
    // The field widget for the matching field.
    'widget' => array(
      'options_buttons',
      'options_select',
    ),
    // The default value for the matching field, as an entity label.
    'default' => array(
      array(),
      array(
        'Britain',
      ),
    ),
    // If TRUE, a limited field shows no options if the matching field is
    // initially empty.
    'empty_behaviour' => array(
      FALSE,
      TRUE,
    ),
  );

  // Work over all the combinations of settings.
  foreach ($ranges['cardinality'] as $cardinality) {
    foreach ($ranges['widget'] as $widget) {
      foreach ($ranges['default'] as $default) {
        foreach ($ranges['empty_behaviour'] as $empty_behaviour) {

          // Make the settings changes to the field and instance.
          $this
            ->changeFieldSettings(array(
            'cardinality' => $cardinality,
            'widget' => $widget,
            'default' => $default,
            'empty_behaviour' => $empty_behaviour,
          ));

          // Test the functionality.
          $this
            ->helperTestNodeCreateForm(array(
            'cardinality' => $cardinality,
            'widget' => $widget,
            'default' => $default,
            'empty_behaviour' => $empty_behaviour,
          ));
        }
      }
    }
  }
}