You are here

public function AuthcacheP13nTestFrontcontroller::testRedirectDetection in Authenticated User Page Caching (Authcache) 7.2

Test that a watchdog message is logged when frontcontroller redirects.

File

modules/authcache_p13n/tests/authcache_p13n.frontcontroller.test, line 176
Defines tests for authcache frontcontroller for personalized requests.

Class

AuthcacheP13nTestFrontcontroller
Tests for authcache frontcontroller for personalized requests.

Code

public function testRedirectDetection() {
  $headers = array(
    'X-Authcache: 1',
  );
  $wdstub = $this->stubmod
    ->hook('watchdog');
  $params = array(
    'r' => 'test/bad',
    'q' => 'node',
    'error' => 'redirect',
  );
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(200);
  $this
    ->assertEqual($this->redirect_count, 1, 'Redirected once');
  $this
    ->assertEqual($this
    ->getUrl(), url('', array(
    'absolute' => TRUE,
  )));
  $this
    ->assertStub($wdstub, HookStub::once());
  list($invocation) = $wdstub
    ->invocations();
  list($wdrecord) = $invocation;
  $this
    ->assertEqual('Authcache P13n Front Controller', $wdrecord['type'], 'Watchdog entry has expected type');
  $this
    ->assertEqual('A redirect was triggered from within a personalization request originating from @origin', $wdrecord['message'], 'Watchdog entry has expected message');
  $this
    ->assertIdentical(0, strpos($wdrecord['variables']['@origin'], 'AuthcacheP13nTestRequestHandlerBadStub->handle()'), 'Watchdog message contains originating class/method');
}