You are here

public function StateFlowWebTestCaseInstallOnExistingSite::testStateFlowPreexistingNode in State Machine 7.3

Test adding node by the UI doesn't create NULL records.

Test that when an node is added in the UI, there are no NULL records in the state_flow_states table.

File

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

Class

StateFlowWebTestCaseInstallOnExistingSite
Tests for State Flow when nodes are created before installing state machine.

Code

public function testStateFlowPreexistingNode() {
  $node = $this
    ->drupalCreateNode();
  $unpublished_node = $this
    ->drupalCreateNode(array(
    'status' => 0,
  ));

  // @todo, Some time between Ctools 1.0 and 1.2, this module_enable() call
  // stopped working for the tests below. The UI enabling of the modules
  // works.
  // module_enable(array('state_machine', 'state_flow', 'state_flow_entity'));
  $edit = array(
    'modules[Chaos tool suite][ctools][enable]' => TRUE,
    'modules[Other][drafty][enable]' => TRUE,
    'modules[Other][entity][enable]' => TRUE,
    'modules[State Machine][state_machine][enable]' => TRUE,
    'modules[State Machine][state_flow_entity][enable]' => TRUE,
    'modules[State Machine][state_flow][enable]' => TRUE,
  );
  $this
    ->drupalPost("admin/modules", $edit, t('Save configuration'));
  $this
    ->assertText('The configuration options have been saved.', t('Required modules enabled'));
  module_list(TRUE);
  cache_clear_all();
  $this
    ->drupalGet("node/add/article");

  // For some reason clearing the static cache after the Get request works
  // better.
  drupal_static_reset();

  // /end cache clearing gymnastics.
  $machine = state_flow_entity_load_state_machine($node, 'node');
  $unpublished_machine = state_flow_entity_load_state_machine($unpublished_node, 'node');
  $this
    ->assert('published' === $machine
    ->get_current_state(), 'Nodes published before installing are considered in the "published" state.');
  $this
    ->assert('draft' === $unpublished_machine
    ->get_current_state(), 'Nodes unpublished before installing are considered in the "draft" state.');
}