diff --git a/src/Tests/LoggerWebTest.php b/src/Tests/LoggerWebTest.php index d69b3c3..0f0b0ef 100644 --- a/src/Tests/LoggerWebTest.php +++ b/src/Tests/LoggerWebTest.php @@ -49,6 +49,9 @@ class LoggerWebTest extends WebTestBase { * Tests that the logger handles an exception correctly. */ public function testLoggerException() { + + \Drupal::state()->set('ultimate_cron_logger_test_cron_action', 'exception'); + // Run cron to get an exception from ultimate_cron_logger_test module. $this->cronRun(); @@ -96,6 +99,20 @@ class LoggerWebTest extends WebTestBase { $this->assertRaw('This is a warning message'); } + + /** + * Tests that the logger handles an exception correctly. + */ + public function testLoggerNormal() { + // Run cron to get an exception from ultimate_cron_logger_test module. + $this->cronRun(); + + // Check that the error message is displayed in its log page. + $this->drupalGet('admin/config/system/cron/jobs/logs/ultimate_cron_logger_test_cron'); + $this->assertRaw('/core/misc/icons/73b355/check.svg'); + $this->assertText('Launched in thread 1'); + } + /** * Reads headers and registers errors received from the tested site. * diff --git a/tests/ultimate_cron_logger_test/ultimate_cron_logger_test.module b/tests/ultimate_cron_logger_test/ultimate_cron_logger_test.module index 8ce1f85..137da88 100644 --- a/tests/ultimate_cron_logger_test/ultimate_cron_logger_test.module +++ b/tests/ultimate_cron_logger_test/ultimate_cron_logger_test.module @@ -8,7 +8,7 @@ * Implements hook_cron(). */ function ultimate_cron_logger_test_cron() { - $action = \Drupal::state()->get('ultimate_cron_logger_test_cron_action', 'exception'); + $action = \Drupal::state()->get('ultimate_cron_logger_test_cron_action'); if ($action == 'exception') { throw new Exception('Test cron exception');