You are here

cleaner_cache.test in Cleaner 7

Test Clearing Caches.

File

tests/cleaner_cache.test
View source
<?php

/**
 * @file
 * Test Clearing Caches.
 */

/**
 * Class CleanerTestCacheClearing.
 *
 * Check is cache are successfully cleared.
 */
class CleanerTestCacheClearing extends CleanerTestBase {

  /**
   * Setting a test info.
   *
   * @return array
   *   An array with an info data.
   */
  public static function getInfo() {
    return array(
      'name' => 'Cleaner test clearing caches.',
      'description' => 'Check is cache are successfully cleared.',
      'group' => 'Cleaner',
    );
  }

  /**
   * Required setup processes before run a tests.
   */
  public function setUp() {
    $this
      ->cleanerAdminSetUp();
  }

  /**
   * Test clearing caches.
   */
  public function testCacheClearing() {

    // Prepare a Cleaner settings.
    $this
      ->cleanerSettings(array(
      'cleaner_clear_cache' => 1,
    ));

    // Create cache.
    $dummy_cache_set = $this
      ->cleanerSaveDummyCache('cleaner_test_variable');

    // Run cleaner.
    $this
      ->cleanerExecute();

    // Get cache after clean.
    $dummy_cache_get = $this
      ->cleanerGetDummyCache('cleaner_test_variable');

    // Check if cache has been cleared.
    $this
      ->assertNotEqual($dummy_cache_set, $dummy_cache_get, 'Cache has been cleared.');

    // Get logs.
    $this
      ->cleanerGetLog();

    // Check if cache clearing has been successfully written to the log.
    $this
      ->assertText('Cleared caches by Cleaner.', 'Cleared cache log OK.');
  }

}

Classes

Namesort descending Description
CleanerTestCacheClearing Class CleanerTestCacheClearing.