diff options
author | David Rothstein <drothstein@gmail.com> | 2016-02-01 23:35:16 -0500 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2016-02-01 23:35:16 -0500 |
commit | e6e00e8444caa3dce647ce46b01256084ce2048c (patch) | |
tree | a6934f13afc88567127a3b2604dc2a1ef1809d2e /modules/system/system.test | |
parent | 11e18568f951cb431b0e0e6514767f2516e0d75b (diff) | |
download | brdo-e6e00e8444caa3dce647ce46b01256084ce2048c.tar.gz brdo-e6e00e8444caa3dce647ce46b01256084ce2048c.tar.bz2 |
Issue #1191290 by klausi, David_Rothstein, Fabianx: system_cron() should not invoke hook_flush_caches() on every cron run
Diffstat (limited to 'modules/system/system.test')
-rw-r--r-- | modules/system/system.test | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/modules/system/system.test b/modules/system/system.test index 2865bbb25..bc764dde5 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -905,6 +905,29 @@ class CronRunTestCase extends DrupalWebTestCase { $result = variable_get('common_test_cron'); $this->assertEqual($result, 'success', 'Cron correctly handles exceptions thrown during hook_cron() invocations.'); } + + /** + * Tests that hook_flush_caches() is not invoked on every single cron run. + * + * @see system_cron() + */ + public function testCronCacheExpiration() { + module_enable(array('system_cron_test')); + variable_del('system_cron_test_flush_caches'); + + // Invoke cron the first time: hook_flush_caches() should be called and then + // get cached. + drupal_cron_run(); + $this->assertEqual(variable_get('system_cron_test_flush_caches'), 1, 'hook_flush_caches() was invoked the first time.'); + $cache = cache_get('system_cache_tables'); + $this->assertEqual(empty($cache), FALSE, 'Cache is filled with cache table data.'); + + // Run cron again and ensure that hook_flush_caches() is not called. + variable_del('system_cron_test_flush_caches'); + drupal_cron_run(); + $this->assertNull(variable_get('system_cron_test_flush_caches'), 'hook_flush_caches() was not invoked the second time.'); + } + } /** |