public function AuthcachePanelsPageManagerTest::testCustomPageManagerPageDefinedInCode in Authenticated User Page Caching (Authcache) 7.2
Test custom page manager page defined in code.
File
- modules/
authcache_panels_page_manager/ authcache_panels_page_manager.test, line 140 - Test cases for the Authcache PanelsPageManager module.
Class
- AuthcachePanelsPageManagerTest
- Tests for markup substitution.
Code
public function testCustomPageManagerPageDefinedInCode() {
// Enable test module which provides hook_default_page_manager_pages().
module_enable(array(
'authcache_panels_page_manager_test',
));
$this
->resetAll();
authcache_p13n_request_router_rebuild();
// Setup client and fragment stub.
$client_info = array(
'authcache_p13n_test' => array(
'title' => t('Test Client'),
'enabled' => TRUE,
),
);
$this->stubmod
->hook('authcache_p13n_client', $client_info);
$substituted_markup = $this
->randomName(8);
$fragment_stub = HookStub::on('theme_authcache_p13n_fragment__authcache_p13n_test', $substituted_markup);
$this
->drupalLogin($this->member);
$this
->drupalGet('node-x/' . $this->node->nid);
$this
->assertResponse(200);
// Ensure that the panels pane was NOT rendered but the substitute markup
// instead.
$this
->assertNoText('This fragment should be loaded via Ajax/ESI. Some context:');
$this
->assertText($substituted_markup);
$this
->assertStub($fragment_stub, HookStub::once());
// Try to receive the fragment. Note: pane_1 is the machine-name it is part
// of the exported stub-task.
$request_id = 'frag/panels/pane-1';
// FIXME: We should'nt need to mess around with $_GET here in order to
// restore proper context for authcache_p13n_request_get_callback.
$orig_q = $_GET['q'];
$_GET['q'] = 'node-x/' . $this->node->nid;
$url = authcache_p13n_request_get_callback($request_id, NULL);
$_GET['q'] = $orig_q;
$this
->assertTrue($url);
$this
->drupalGet($GLOBALS['base_root'] . $url['path'], $url['options'], array(
'X-Authcache: 1',
));
$this
->assertText('This fragment should be loaded via Ajax/ESI. Some context:');
$this
->assertText('Authors email: ' . $this->admin->mail);
$this
->assertText('Logged in users email: ' . $this->member->mail);
}