function Fix404RedirectCronJobTest::testRedirect404CronJobDailyCountReset in Redirect 8
Tests resetting the daily counts in the redirect_404 table.
File
- modules/
redirect_404/ tests/ src/ Kernel/ Fix404RedirectCronJobTest.php, line 121
Class
- Fix404RedirectCronJobTest
- Tests the clean up cron job for redirect_404.
Namespace
Drupal\Tests\redirect_404\KernelCode
function testRedirect404CronJobDailyCountReset() {
// Check that there are 2 rows with daily count value bigger than 0.
$result = \Drupal::database()
->query("SELECT COUNT(*) FROM {redirect_404} WHERE daily_count > 0")
->fetchField();
$this
->assertEquals(2, $result);
// Run cron to reset the daily counts in the redirect_404 test table.
redirect_404_cron();
$result = \Drupal::database()
->query("SELECT COUNT(*) FROM {redirect_404} WHERE daily_count > 0")
->fetchField();
$this
->assertEquals(0, $result);
// Add new row with daily count value.
$this
->insert404Row('/test7', 2, 2, time());
redirect_404_cron();
// Check if the row exists and the daily count isn't reset after cron run.
$this
->assert404Row('/test7');
$result = \Drupal::database()
->query("SELECT COUNT(*) FROM {redirect_404} WHERE daily_count > 0")
->fetchField();
$this
->assertEquals(1, $result);
}