You are here

private function MongoDBLogTestCase::generateLogEntries in MongoDB 6

Same name and namespace in other branches
  1. 8 mongodb_watchdog/mongodb_watchdog.test \MongoDBLogTestCase::generateLogEntries()
  2. 7 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.

File

mongodb_watchdog/mongodb_watchdog.test, line 235
Test class for MongoDB_watchdog.

Class

MongoDBLogTestCase
Test the behaviour of watchdog() mongodb_watchdog, not dblog.

Code

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

  // Prepare the fields to be logged.
  $log = array(
    'type' => $type,
    'message' => 'Log entry added to test the dblog row limit.',
    '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);
  }
}