You are here

public function CleanerTestWatchdogClearing::testWatchdogClearing in Cleaner 7

Test clearing Watchdog logs.

File

tests/cleaner_watchdog.test, line 37
Test Clearing Watchdog logs.

Class

CleanerTestWatchdogClearing
Class CleanerTestWatchdogClearing.

Code

public function testWatchdogClearing() {

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

  // Generate a dummy watchdog logs.
  for ($i = 0; $i <= 10; $i++) {
    watchdog('Cleaner', $this
      ->randomString());
  }

  // Check if dummy logs has been generated.
  $this
    ->assertTrue(self::getWatchdogsCount() >= 10, 'Dummy logs has been generated.');

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

  // Check is watchdog logs has been cleared.
  $this
    ->assertTrue(self::getWatchdogsCount() <= 1, 'Logs has been cleared.');
}