public function AuthcacheEsiTestCase::testEsiSetting in Authenticated User Page Caching (Authcache) 7.2
Cover theme_authcache_p13n_setting__authcache_esi().
File
- modules/
authcache_esi/ tests/ authcache_esi.test, line 85 - Tests for ESI markup generator
Class
- AuthcacheEsiTestCase
- Test authcache esi
Code
public function testEsiSetting() {
$page = array(
'#theme' => 'authcache_p13n_setting',
'#setting' => 'esi-test-setting',
'#fallback' => 'cancel',
);
// Test whether fallback markup is rendered on the page.
$stub = $this->stubmod
->hook('page', $page);
$this
->drupalGet('authcache-esi-test-page');
$this
->assertStub($stub, HookStub::once());
$this
->assertFalse($this
->drupalGetHeader('X-Authcache-Do-ESI'), t('Header %header must be absent when fallback markup is rendered', array(
'%header' => 'X-Authcache-Do-ESI',
)));
$elements = $this
->xpath('//iframe/*[local-name(.) = "include"]');
$this
->assertEqual(0, count($elements));
// Test whether <span> placeholder tag is rendered on page.
$stub = $this->stubmod
->hook('page', $page);
$this
->drupalGet('authcache-esi-test-page', array(), array(
'X-Authcache-Do-ESI: 1',
));
$this
->assertStub($stub, HookStub::once());
$this
->assertTrue($this
->drupalGetHeader('X-Authcache-Do-ESI'), t('Header %header must be present when ESI tag is rendered', array(
'%header' => 'X-Authcache-Do-ESI',
)));
$elements = $this
->xpath('//iframe/*[local-name(.) = "include"]');
$this
->assertEqual(1, count($elements));
}