You are here

public function WorkbenchAccessTestCase::workbenchAccessNodeForm in Workbench Access 7

Helper function for form introspection.

Forms are sensitive to the global user account, so we must reset it when using this technique.

Parameters

$uid: A user id representing the account to test.

$type: The node type of the form.

2 calls to WorkbenchAccessTestCase::workbenchAccessNodeForm()
WorkbenchAccessMenuTestCase::testWorkbenchAccessMenu in tests/workbench_access.test
WorkbenchAccessTaxonomyTestCase::testWorkbenchAccessTaxonomy in tests/workbench_access.test

File

tests/workbench_access.test, line 71
Test file for Workbench Access.

Class

WorkbenchAccessTestCase
@file Test file for Workbench Access.

Code

public function workbenchAccessNodeForm($uid, $type) {
  $temp = $GLOBALS['user'];
  $user = user_load($uid, TRUE);
  $GLOBALS['user'] = $user;
  $node = (object) array(
    'uid' => $user->uid,
    'name' => isset($user->name) ? $user->name : '',
    'type' => $type,
    'language' => LANGUAGE_NONE,
  );
  module_load_include('inc', 'node', 'node.pages');
  $form = drupal_get_form($type . '_node_form', $node);
  $GLOBALS['user'] = $temp;
  return $form;
}