function FlagLinkTypeConfirmTestCase::setUp in Flag 7.3
Implements setUp().
Overrides DrupalWebTestCase::setUp
File
- tests/
flag.test, line 786 - Tests for the Flag module.
Class
- FlagLinkTypeConfirmTestCase
- Test the 'confirm form' link type.
Code
function setUp() {
parent::setUp('flag');
// Create a test flag on article nodes.
// Keep the original data so we can compare strings.
$this->flag_data = array(
'entity_type' => 'node',
'name' => 'test_flag',
'title' => 'Test Flag',
'global' => 0,
'types' => array(
0 => 'article',
),
'flag_short' => 'Flag <em>this</em> item',
'flag_long' => '',
'flag_message' => 'You have flagged this item.',
'unflag_short' => 'Unflag this item',
'unflag_long' => '',
'unflag_message' => 'You have unflagged this item',
'unflag_denied_text' => 'You may not unflag this item',
'link_type' => 'confirm',
'flag_confirmation' => 'Are you sure you want to flag this item?',
'unflag_confirmation' => 'Are you sure you want to unflag this item?',
'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,
);
$this->flag = flag_flag::factory_by_array($this->flag_data);
$this->flag
->save();
// Reset our cache so our permissions show up.
drupal_static_reset('flag_get_flags');
// Reset permissions so that permissions for this flag are available.
$this
->checkPermissions(array(), TRUE);
// Create test user who can flag and unflag.
$this->flag_unflag_user = $this
->drupalCreateUser(array(
'flag test_flag',
'unflag test_flag',
));
$this
->drupalLogin($this->flag_unflag_user);
// Create an article node to flag and unflag.
$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;
}