You are here

private function MongoDBLogTestCase::generateLogEntries in MongoDB 7

Same name and namespace in other branches
  1. 8 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::generateLogEntries()
  2. 6 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::generateLogEntries()

Generate dblog entries.

Parameters

int $count: Number of log entries to generate.

string $type: The type of watchdog entry.

int $severity: The severity of the watchdog entry.

1 call to MongoDBLogTestCase::generateLogEntries()
MongoDBLogTestCase::ztestFilter in mongodb_watchdog/mongodb_watchdog.test
Test the dblog filter on admin/reports/dblog.

File

mongodb_watchdog/mongodb_watchdog.test, line 257
Contains \MongoDBLogTestCase.

Class

MongoDBLogTestCase

Code

private function generateLogEntries($count, $type = 'custom', $severity = WATCHDOG_NOTICE) {
  global $base_root;

  // Prepare the fields to be logged.
  $message = 'Log entry added to test the dblog row limit.';
  $log = array(
    'type' => $type,
    'message' => $message,
    'variables' => array(),
    'severity' => $severity,
    'link' => NULL,
    'user' => $this->bigUser,
    'request_uri' => $base_root . request_uri(),
    'referer' => $_SERVER['HTTP_REFERER'],
    'ip' => ip_address(),
    'timestamp' => $this->requestTime,
  );
  for ($i = 0; $i < $count; $i++) {
    $log['message'] = $this
      ->randomString();
    dblog_watchdog($log);
  }
}