You are here

public function StateFlowWebTestCase::testOfFieldValidation in State Machine 7.3

Verify that two node objects are not saved.

File

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

Class

StateFlowWebTestCase
Unit tests for the StateFlow revision state machine.

Code

public function testOfFieldValidation() {

  // Add the text integer field.
  $this
    ->_addintegerfield();

  // Test validate of the integer field within a node form.
  $edit = array();
  $edit['event'] = 'keep in draft';
  $edit['event_comment'] = $this
    ->randomName(8);
  $edit['field_sfhe_integer[und][0][value]'] = rand(11, 9999);
  $edit['title'] = $title = $this
    ->randomName(8);
  $this
    ->drupalPost("node/add/article", $edit, t('Save'));
  $this
    ->assertText('Test integer: the value may be no greater than 10.', t('The integer fields shows the correct error message when set to a value greater than 10'));

  // Post again with a legal integer value.
  $edit['field_sfhe_integer[und][0][value]'] = rand(1, 10);
  $this
    ->drupalPost("node/add/article", $edit, t('Save'));

  // Go to the mini form and test validation there too.
  $this
    ->drupalGet("node/1/revisions/1/workflow/publish");
  $this
    ->assertResponse('200', 'Publish tab responds with a 200');

  // Post with an illegal integer value.
  $edit = array();
  $edit['event_comment'] = $this
    ->randomName(8);
  $edit['field_sfhe_integer[und][0][value]'] = rand(11, 9999);
  $this
    ->drupalPost("node/1/revisions/1/workflow/publish", $edit, t('Update State'));
  $this
    ->assertText('Test integer: the value may be no greater than 10.', t('The integer fields shows the correct error message when set to a value greater than 10'));

  // Post again with a legal integer value.
  $edit['field_sfhe_integer[und][0][value]'] = rand(1, 10);
  $this
    ->drupalPost("node/1/revisions/1/workflow/publish", $edit, t('Update State'));

  // Confirm that the node actually published.
  $this
    ->drupalLogout();
  $this
    ->drupalGet("node/1");
  $this
    ->assertText($title, t('After publishing, anonymous user can see node title.'));
}