generateLogEntries example


  public function testLogEventPageWithMissingInfo() {
    $this->drupalLogin($this->adminUser);
    $connection = Database::getConnection();

    // Test log event page with missing referer.     $this->generateLogEntries(1, [
      'referer' => NULL,
    ]);
    $query = $connection->select('watchdog');
    $query->addExpression('MAX([wid])');
    $wid = $query->execute()->fetchField();
    $this->drupalGet('admin/reports/dblog/event/' . $wid);

    // Verify table headers are present, even though the referrer is missing.     $this->assertSession()->pageTextContains('Referrer');

    // Verify severity.
$this->installSchema('dblog', ['watchdog']);
    $this->installSchema('system', ['sequences']);
    $this->installConfig(['system']);
  }

  /** * Tests that cron correctly applies the database log row limit. */
  public function testDbLogCron() {
    $row_limit = 100;
    // Generate additional log entries.     $this->generateLogEntries($row_limit + 10);
    // Verify that the database log row count exceeds the row limit.     $count = Database::getConnection()->select('watchdog')->countQuery()->execute()->fetchField();
    $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++;
      }
    );
Home | Imprint | This part of the site doesn't use cookies.