You are here

public function StateFlowWebTestCase::_testOfDuplicateStates in State Machine 7.3

Helper function to check that there are no duplicate states.

1 call to StateFlowWebTestCase::_testOfDuplicateStates()
StateFlowWebTestCase::testStateFlowStateMachine in modules/state_flow/tests/state_flow.test
Test basic state changes and forward revisions.

File

modules/state_flow/tests/state_flow.test, line 319
state_flow.test

Class

StateFlowWebTestCase
Unit tests for the StateFlow revision state machine.

Code

public function _testOfDuplicateStates() {
  $states = db_select('state_flow_states')
    ->fields('state_flow_states', array())
    ->execute()
    ->fetchAll();
  $hids = array();
  $duplicates = FALSE;
  foreach ($states as $state) {
    if (!empty($state->hid)) {
      if (empty($hids[$state->hid])) {
        $hids[$state->hid][] = $state;
      }
      else {
        $duplicates = TRUE;
      }
    }
  }
  $this
    ->assertFalse($duplicates, t('There are no duplicate records in State Flow States'));

  // If there are duplicates, set a default message.
  if ($duplicates) {
    debug($states);
  }
}