You are here

public function HierarchicalSelectInternals::testAllSettingsOff in Hierarchical Select 7.3

Same name and namespace in other branches
  1. 6.3 tests/internals.test \HierarchicalSelectInternals::testAllSettingsOff()

In this test, all settings are disabled.

File

tests/internals.test, line 103
This file contains the unit tests of the internals.

Class

HierarchicalSelectInternals
Tests for the internals of Hierarchical Select.

Code

public function testAllSettingsOff() {

  // Generate form item.
  $form_item = array(
    '#required' => FALSE,
    '#config' => array(
      'module' => 'hs_smallhierarchy',
      'params' => array(
        'hierarchy' => $this->smallHierarchy,
        'id' => 'driverpack_platforms',
        'separator' => '|',
      ),
      'save_lineage' => 0,
      'enforce_deepest' => 0,
      'resizable' => 1,
      'level_labels' => array(
        'status' => 0,
      ),
      'dropbox' => array(
        'status' => 0,
        'limit' => 0,
        'reset_hs' => 1,
      ),
      'editability' => array(
        'status' => 0,
        'item_types' => array(),
        'allowed_levels' => array(),
        'allow_new_levels' => 0,
        'max_levels' => 3,
      ),
      'entity_count' => array(
        'enabled' => 0,
        'require_entity' => 0,
        'settings' => array(
          'count_children' => 0,
          'entity_types' => array(),
        ),
      ),
      'animation_delay' => 400,
      'exclusive_lineages' => array(),
      'render_flat_select' => 0,
    ),
  );

  // No selection.
  list($hierarchy, $dropbox) = $this
    ->generate($form_item, array(), array());
  $reference = new stdClass();
  $reference->lineage = array(
    0 => 'label_0',
  );
  $reference->levels = array(
    0 => array(
      'label_0' => '',
      LINEAGE_EURO => LABEL_EURO,
      LINEAGE_ASIA => LABEL_ASIA,
    ),
  );
  $reference->childinfo = array(
    0 => array(
      LINEAGE_EURO => 2,
      LINEAGE_ASIA => 2,
    ),
  );
  $this
    ->assertHierarchy($hierarchy, $reference, 'no selection');

  // Europe.
  list($hierarchy, $dropbox) = $this
    ->generate($form_item, array(
    LINEAGE_EURO,
  ), array());
  $reference->lineage = array(
    0 => LINEAGE_EURO,
    1 => 'label_1',
  );
  $reference->levels[1] = array(
    'label_1' => '',
    LINEAGE_EURO_BE => LABEL_EURO_BE,
    LINEAGE_EURO_FR => LABEL_EURO_FR,
  );
  $reference->childinfo[1] = array(
    LINEAGE_EURO_BE => 2,
    LINEAGE_EURO_FR => 0,
  );
  $this
    ->assertHierarchy($hierarchy, $reference, 'Europe');

  // Europe > France.
  list($hierarchy, $dropbox) = $this
    ->generate($form_item, array(
    LINEAGE_EURO_FR,
  ), array());
  $reference->lineage = array(
    0 => LINEAGE_EURO,
    1 => LINEAGE_EURO_FR,
  );
  $this
    ->assertHierarchy($hierarchy, $reference, 'Europe > France');

  // Europe > Belgium.
  list($hierarchy, $dropbox) = $this
    ->generate($form_item, array(
    LINEAGE_EURO_BE,
  ), array());
  $reference->lineage = array(
    0 => LINEAGE_EURO,
    1 => LINEAGE_EURO_BE,
    2 => 'label_2',
  );
  $reference->levels[1] = array(
    'label_1' => '',
    LINEAGE_EURO_BE => LABEL_EURO_BE,
    LINEAGE_EURO_FR => LABEL_EURO_FR,
  );
  $reference->levels[2] = array(
    'label_2' => '',
    LINEAGE_EURO_BE_BRU => LABEL_EURO_BE_BRU,
    LINEAGE_EURO_BE_HAS => LABEL_EURO_BE_HAS,
  );
  $reference->childinfo[1] = array(
    LINEAGE_EURO_BE => 2,
    LINEAGE_EURO_FR => 0,
  );
  $reference->childinfo[2] = array(
    LINEAGE_EURO_BE_BRU => 0,
    LINEAGE_EURO_BE_HAS => 0,
  );
  $this
    ->assertHierarchy($hierarchy, $reference, 'Europe > Belgium');

  // Asia.
  list($hierarchy, $dropbox) = $this
    ->generate($form_item, array(
    LINEAGE_ASIA,
  ), array());
  $reference->lineage = array(
    0 => LINEAGE_ASIA,
    1 => 'label_1',
  );
  $reference->levels[1] = array(
    'label_1' => '',
    LINEAGE_ASIA_CH => LABEL_ASIA_CH,
    LINEAGE_ASIA_JP => LABEL_ASIA_JP,
  );
  unset($reference->levels[2]);
  $reference->childinfo[1] = array(
    LINEAGE_ASIA_CH => 0,
    LINEAGE_ASIA_JP => 1,
  );
  unset($reference->childinfo[2]);
  $this
    ->assertHierarchy($hierarchy, $reference, 'Asia');

  // Asia > Japan > Tokyo.
  list($hierarchy, $dropbox) = $this
    ->generate($form_item, array(
    LINEAGE_ASIA_JP_TOK,
  ), array());
  $reference->lineage = array(
    0 => LINEAGE_ASIA,
    1 => LINEAGE_ASIA_JP,
    2 => LINEAGE_ASIA_JP_TOK,
  );
  $reference->levels[2] = array(
    'label_2' => '',
    LINEAGE_ASIA_JP_TOK => LABEL_ASIA_JP_TOK,
  );
  $reference->childinfo[2] = array(
    LINEAGE_ASIA_JP_TOK => 0,
  );
  $this
    ->assertHierarchy($hierarchy, $reference, 'Asia > Japan > Tokyo');
}