You are here

public function MobileNumberFieldTestCase::submitNodeForm in Mobile Number 7

Submit node form.

1 call to MobileNumberFieldTestCase::submitNodeForm()
MobileNumberFieldTestCase::createMobileNumberNode in tests/mobile_number.field.test
Create node with mobile number(s).

File

tests/mobile_number.field.test, line 162

Class

MobileNumberFieldTestCase
Class for testing mobile_number field.

Code

public function submitNodeForm($node_type, $values, $number) {

  // Load the required includes for drupal_form_submit.
  module_load_include('inc', 'node', 'node.pages');
  $values += array(
    'body' => array(
      LANGUAGE_NONE => array(
        array(),
      ),
    ),
    'title' => $this
      ->randomName(8),
    'comment' => 2,
    'changed' => REQUEST_TIME,
    'moderate' => 0,
    'promote' => 0,
    'revision' => 1,
    'log' => '',
    'status' => 1,
    'sticky' => 0,
    'type' => $node_type,
    'revisions' => NULL,
    'language' => LANGUAGE_NONE,
  );
  $node = $values;
  $stub_node = (object) array_intersect_key($node, array_flip(array(
    'type',
    'language',
  )));
  $stub_form_state = array(
    'no_cache' => TRUE,
    'build_info' => array(
      'args' => array(
        (object) $stub_node,
      ),
    ),
  );

  // Setup form_state.
  $form_state = array();
  $form_state['values'] = $values;
  $form_state['values']['op'] = t('Save');
  $form_state['programmed_bypass_access_check'] = TRUE;
  $form_state['no_cache'] = TRUE;
  $stub_form = drupal_build_form($node_type . '_node_form', $stub_form_state);
  $form_state['triggering_element'] = $stub_form['actions']['submit'];
  drupal_form_submit($node_type . '_node_form', $form_state, (object) $node);
  unset($_SESSION['mobile_number_verification'][$number]['verified']);
  return form_get_errors();
}