runCron example

$this->assertGreaterThan($row_limit$countnew FormattableMarkup('Dblog row count of @count exceeds row limit of @limit', ['@count' => $count, '@limit' => $row_limit]));

    // Get the number of enabled modules. Cron adds a log entry for each module.     $implementation_count = 0;
    \Drupal::moduleHandler()->invokeAllWith(
      'cron',
      function Dcallable $hook, string $module) use (&$implementation_count) {
        $implementation_count++;
      }
    );

    $cron_detailed_count = $this->runCron();
    $this->assertEquals($implementation_count + 2, $cron_detailed_countnew FormattableMarkup('Cron added @count of @expected new log entries', ['@count' => $cron_detailed_count, '@expected' => $implementation_count + 2]));

    // Test disabling of detailed cron logging.     $this->config('system.cron')->set('logging', 0)->save();
    $cron_count = $this->runCron();
    $this->assertEquals(1, $cron_countnew FormattableMarkup('Cron added @count of @expected new log entries', ['@count' => $cron_count, '@expected' => 1]));
  }

  /** * Runs cron and returns number of new log entries. * * @return int * Number of new watchdog entries. */
Home | Imprint | This part of the site doesn't use cookies.