@@ -23,16 +23,16 @@ class HookBootExitTest extends WebTestBase {
publicstaticfunctiongetInfo(){
returnarray(
'name'=>'Boot and exit hook invocation',
'description'=>'Test that hook_boot() and hook_exit() are called correctly.',
'name'=>'Exit hook invocation',
'description'=>'Test that hook_exit() is called correctly.',
'group'=>'Bootstrap',
);
}
/**
* Tests calling of hook_boot() and hook_exit().
* Tests calling of hook_exit().
*/
functiontestHookBootExit(){
functiontestHookExit(){
// Test with cache disabled. Boot and exit should always fire.
$config=config('system.performance');
$config->set('cache.page.enabled',0);
...
...
@@ -40,29 +40,25 @@ function testHookBootExit() {
$this->drupalGet('');
$calls=1;
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_boot'))->fetchField(),$calls,'hook_boot called with disabled cache.');
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_exit'))->fetchField(),$calls,'hook_exit called with disabled cache.');
// Test with normal cache. Boot and exit should be called.
// Test with normal cache. Exit should be called.
$config->set('cache.page.enabled',1);
$config->save();
$this->drupalGet('');
$calls++;
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_boot'))->fetchField(),$calls,'hook_boot called with normal cache.');
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_exit'))->fetchField(),$calls,'hook_exit called with normal cache.');
// Boot and exit should not fire since the page is cached.
// Exit should not fire since the page is cached.
variable_set('page_cache_invoke_hooks',FALSE);
$this->assertTrue(cache('page')->get(url('',array('absolute'=>TRUE))),'Page has been cached.');
$this->drupalGet('');
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_boot'))->fetchField(),$calls,'hook_boot not called with aggressive cache and a cached page.');
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_exit'))->fetchField(),$calls,'hook_exit not called with aggressive cache and a cached page.');
// Test with page cache cleared, boot and exit should be called.
// Test with page cache cleared, exit should be called.
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_boot'))->fetchField(),$calls,'hook_boot called with aggressive cache and no cached page.');
$this->assertEqual(db_query('SELECT COUNT(*) FROM {watchdog} WHERE type = :type AND message = :message',array(':type'=>'system_test',':message'=>'hook_exit'))->fetchField(),$calls,'hook_exit called with aggressive cache and no cached page.');