You are here

function FlagHookFlagAccessTestCase::setUp in Flag 7.3

Implements setUp().

Overrides DrupalWebTestCase::setUp

File

tests/flag.test, line 931
Tests for the Flag module.

Class

FlagHookFlagAccessTestCase
Verifies the implementation of hook_flag_access().

Code

function setUp() {
  parent::setUp('flag');
  $success = module_enable(array(
    'flagaccesstest',
  ), FALSE);

  // Create a test flag on article nodes.
  $flag_data = array(
    'entity_type' => 'node',
    'name' => 'test_flag',
    'title' => 'Test Flag',
    'global' => 0,
    'types' => array(
      0 => 'article',
    ),
    'flag_short' => 'Flag this item',
    'flag_long' => '',
    'flag_message' => '',
    'unflag_short' => 'Unflag this item',
    'unflag_long' => '',
    'unflag_message' => '',
    'unflag_denied_text' => 'You may not unflag this item',
    // Use the normal link type as it involves no intermediary page loads.
    'link_type' => 'normal',
    'weight' => 0,
    'show_on_form' => 0,
    'access_author' => '',
    'show_contextual_link' => 0,
    'show_in_links' => array(
      'full' => 1,
      'teaser' => 1,
    ),
    'i18n' => 0,
    'api_version' => 3,
  );
  $flag = $this
    ->createFlag($flag_data);

  // Create an article node that various users will try to flag.
  $title = $this
    ->randomName(8);
  $node = array(
    'title' => $title,
    'body' => array(
      LANGUAGE_NONE => array(
        array(
          'value' => $this
            ->randomName(32),
        ),
      ),
    ),
    'uid' => 1,
    'type' => 'article',
    'is_new' => TRUE,
  );
  $node = node_submit((object) $node);
  node_save($node);
  $this->nid = $node->nid;
}