You are here

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

Test whether the frontcontroller responds correctly to a valid request.

File

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

Class

AuthcacheP13nTestFrontcontroller
Tests for authcache frontcontroller for personalized requests.

Code

public function testValidRequest() {
  $headers = array(
    'X-Authcache: 1',
  );
  $params = array(
    'r' => 'test/good',
    'q' => 'node',
  );

  // Get should return serialized parameters.
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(200);
  $this
    ->assertEqual(serialize(array(
    'q' => 'node',
  )), $result);

  // Head should not return any result.
  $result = $this
    ->drupalHead($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(200);
  $this
    ->assertEqual('', $result);

  // When authcache_p13n_checkheader is set to FALSE, requests should succeed
  // even when X-Authcache header is not sent.
  variable_set('authcache_p13n_checkheader', FALSE);

  // Get should return serialized parameters.
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ));
  $this
    ->assertResponse(200);
  $this
    ->assertEqual(serialize(array(
    'q' => 'node',
  )), $result);

  // Head should not return any result.
  $result = $this
    ->drupalHead($this->fcURL, array(
    'query' => $params,
  ));
  $this
    ->assertResponse(200);
  $this
    ->assertEqual('', $result);
}