You are here

public function AuthcacheAjaxTestCase::testAjaxSetting in Authenticated User Page Caching (Authcache) 7.2

Cover theme_authcache_p13n_setting__authcache_ajax().

File

modules/authcache_ajax/tests/authcache_ajax.test, line 89
Tests for Ajax markup generator

Class

AuthcacheAjaxTestCase
Test authcache ajax

Code

public function testAjaxSetting() {
  $page = array(
    '#theme' => 'authcache_p13n_setting',
    '#setting' => 'ajax-test-setting',
    '#fallback' => 'cancel',
  );

  // Make sure JavaScript is turned off in simpletest browser.
  $this
    ->drupalGet('authcache-ajax-test-set-has-js/0');

  // Test whether fallback markup is rendered on the page.
  $stub = $this->stubmod
    ->hook('page', $page);
  $this
    ->drupalGet('authcache-ajax-test-page');
  $this
    ->assertStub($stub, HookStub::once());
  $settings = $this
    ->drupalGetSettings();
  $this
    ->assertFalse(isset($settings['authcacheP13nAjaxSettings']));

  // Make sure JavaScript is turned on in simpletest browser.
  $this
    ->drupalGet('authcache-ajax-test-set-has-js/1');

  // Test whether <span> placeholder tag is rendered on page.
  $stub = $this->stubmod
    ->hook('page', $page);
  $this
    ->drupalGet('authcache-ajax-test-page');
  $this
    ->assertStub($stub, HookStub::once());
  $settings = $this
    ->drupalGetSettings();
  $this
    ->assertTrue(isset($settings['authcacheP13nAjaxSettings']));
}