function RedirectFunctionalTest::testPageCache in Redirect 7.2
Same name and namespace in other branches
- 7 redirect.test \RedirectFunctionalTest::testPageCache()
File
- ./
redirect.test, line 243 - Unit tests for the redirect module.
Class
Code
function testPageCache() {
// Set up cache variables.
variable_set('cache', 1);
$edit = array(
'redirect_page_cache' => TRUE,
'redirect_purge_inactive' => 604800,
);
$this
->drupalPost('admin/config/search/redirect/settings', $edit, 'Save configuration');
$this
->assertText('The configuration options have been saved.');
$this
->drupalLogout();
// Add a new redirect.
$redirect = $this
->addRedirect('redirect', 'node');
$this
->assertEqual($redirect->access, 0);
$this
->assertEqual($redirect->count, 0);
$this
->assertPageNotCached('redirect');
// Perform the redirect and check that last_used
$redirect = $this
->assertRedirect($redirect);
$this
->assertEqual($redirect->count, 1);
$this
->assertTrue($redirect->access > 0);
$cache = $this
->assertPageCached('redirect');
$this
->assertHeader('Location', url('node', array(
'absolute' => TRUE,
)), $cache->data['headers']);
$this
->assertHeader('X-Redirect-ID', $redirect->rid, $cache->data['headers']);
// Set a redirect to not used in a while and disable running bootstrap
// hooks during cache page serve. Running cron to remove inactive redirects
// should not remove since they cannot be tracked.
$redirect->access = 1;
redirect_save($redirect);
variable_set('page_cache_invoke_hooks', FALSE);
$this
->cronRun();
$this
->assertRedirect($redirect);
$redirect->access = 1;
redirect_save($redirect);
variable_set('page_cache_invoke_hooks', TRUE);
$this
->cronRun();
$this
->assertNoRedirect($redirect);
}