You are here

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

Fc should respond with appropriate result codes when errors occure.

File

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

Class

AuthcacheP13nTestFrontcontroller
Tests for authcache frontcontroller for personalized requests.

Code

public function testExceptions() {
  $headers = array(
    'X-Authcache: 1',
  );
  $params = array(
    'r' => 'test/bad',
    'q' => 'node',
    'error' => 'not_found',
  );
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(404);
  $this
    ->assertEqual('', $result);
  $params = array(
    'r' => 'test/bad',
    'q' => 'node',
    'error' => 'invalid_input',
  );
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(400);
  $this
    ->assertEqual('', $result);
  $params = array(
    'r' => 'test/bad',
    'q' => 'node',
    'error' => 'access_denied',
  );
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(403);
  $this
    ->assertEqual('', $result);
  $params = array(
    'r' => 'test/bad',
    'q' => 'node',
    'error' => 'server_error',
  );
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(500);
  $this
    ->assertEqual('', $result);
  $params = array(
    'r' => 'test/bad',
    'q' => 'node',
    'error' => 'unhandled_exception',
  );
  $result = $this
    ->drupalGet($this->fcURL, array(
    'query' => $params,
  ), $headers);
  $this
    ->assertResponse(500);
  $this
    ->assertEqual('', $result);
}