css_cache.test 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /**
  3. * Tests the custom CSS cache handler.
  4. */
  5. class CtoolsCSSObjectCache extends DrupalWebTestCase {
  6. /**
  7. * {@inheritdoc}
  8. */
  9. public static function getInfo() {
  10. return array(
  11. 'name' => 'CSS cache',
  12. 'description' => 'Tests the custom CSS cache handler.',
  13. 'group' => 'ctools',
  14. 'dependencies' => array('ctools'),
  15. );
  16. }
  17. /**
  18. * {@inheritdoc}
  19. */
  20. public function setUp(array $modules = array()) {
  21. $modules[] = 'ctools';
  22. parent::setUp($modules);
  23. }
  24. /**
  25. * Tests the custom CSS cache handler.
  26. *
  27. * @see https://drupal.org/node/1313368
  28. */
  29. public function testCssCache() {
  30. // Create a CSS cache entry.
  31. $filename = ctools_css_cache('body { color: red; }');
  32. // Perform a cron run. The CSS cache entry should not be removed.
  33. $this->cronRun();
  34. $this->assertTrue(file_exists($filename), 'The CSS cache is not cleared after performing a cron run.');
  35. // Manually clear the caches. The CSS cache entry should be removed.
  36. drupal_flush_all_caches();
  37. $this->assertFalse(file_exists($filename), 'The CSS cache is cleared after clearing all caches.');
  38. }
  39. }