public function AuthcacheFlagTest::testAuthcacheFlagFlagFragmentWithoutUnflag in Authenticated User Page Caching (Authcache) 7.2
Ensure that flags are rendered propertly when user lacks unflag permission.
Covers AuthcacheFlagFlagFragment
File
- modules/
authcache_flag/ authcache_flag.test, line 447 - Test cases for the Authcache Flag module.
Class
- AuthcacheFlagTest
- Tests for markup substitution.
Code
public function testAuthcacheFlagFlagFragmentWithoutUnflag() {
$this
->drupalLogin($this->member1);
$partial = _authcache_flag_partial_id($this->nodeFlag);
$url = authcache_p13n_request_get_callback('asm/flags', array(
$partial => array(
$this->node1->nid,
$this->node2->nid,
),
));
$this
->assertTrue($url);
// Fetch (both nodes unflagged).
$result = $this
->drupalGetAJAX($GLOBALS['base_root'] . $url['path'], $url['options'], array(
'X-Authcache: 1',
));
$this
->assert(isset($result[$partial]));
$this
->assertEqual(array(
$this->node1->nid,
$this->node2->nid,
), array_keys($result[$partial]));
$this
->drupalSetContent($result[$partial][$this->node1->nid]);
$this
->assertLink('Flag this item', 0, 'The flag link appears in the first fragment.');
$this
->drupalSetContent($result[$partial][$this->node2->nid]);
$this
->assertLink('Flag this item', 0, 'The flag link appears in the second fragment.');
// Click the link to flag the second node.
$this
->clickLink(t('Flag this item'));
// Refetch (first node unflagged, second node flagged).
$result = $this
->drupalGetAJAX($GLOBALS['base_root'] . $url['path'], $url['options'], array(
'X-Authcache: 1',
));
$this
->assert(isset($result[$partial]));
$this
->assertEqual(array(
$this->node1->nid,
$this->node2->nid,
), array_keys($result[$partial]));
$this
->drupalSetContent($result[$partial][$this->node1->nid]);
$this
->assertLink('Flag this item', 0, 'The flag link appears in the first fragment.');
$this
->drupalSetContent($result[$partial][$this->node2->nid]);
$this
->assertNoLink('Flag this item', 0, 'The flag link appears in the second fragment.');
$this
->assertText('You may not unflag this item', 0, 'The unflag denied text appears on the page after flagging.');
}