public function AuthcacheViewsTest::testMarkupSubstitution in Authenticated User Page Caching (Authcache) 7.2
Ensure that markup is substituted for authcache enabled blocks.
File
- modules/
authcache_views/ authcache_views.test, line 76 - Test cases for the Authcache Views module.
Class
- AuthcacheViewsTest
- Tests for markup substitution.
Code
public function testMarkupSubstitution() {
$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);
$view = views_get_view('tracker');
$view->disabled = FALSE;
$view->display['page']->display_options['authcache'] = array(
'status' => '1',
'lifespan' => '3600',
'peruser' => '1',
'perpage' => '1',
'clients' => array(
'authcache_p13n_test' => array(
'status' => '1',
'weight' => '0',
),
),
'fallback' => 'cancel',
);
$view->display['page']->display_options['path'] = 'test-tracker';
views_save_view($view);
ctools_export_load_object_reset();
authcache_p13n_request_router_rebuild();
$this
->drupalLogin($this->member);
$this
->drupalGet('test-tracker');
$this
->assertResponse(200);
// Ensure that the panels pane was NOT rendered but the substitute markup
// instead.
$this
->assertNoText($this->nodeByAnon->title, 'Test node authored by anonymous user is not on the page');
$this
->assertNoText($this->nodeByAdmin->title, 'Test node authored by admin user is not on the page');
$this
->assertNoText('This fragment should be loaded via Ajax/ESI. Some context:');
$this
->assertText($substituted_markup);
$this
->assertStub($fragment_stub, HookStub::once());
}