function CommandUnishTestCase::assertLogHasMessage

8.0.x CommandUnishTestCase.php CommandUnishTestCase::assertLogHasMessage($log, $message, $logType = FALSE)
master CommandUnishTestCase.php CommandUnishTestCase::assertLogHasMessage($log, $message, $logType = FALSE)

Ensure that an expected log message appears in the Drush log.

$this->drush('command', array(), array('backend' => NULL)); $parsed = $this->parse_backend_output($this->getOutput()); $this->assertLogHasMessage($parsed['log'], "Expected message", 'debug')

Parameters

$log Parsed log entries from backend invoke:

$message The expected message that must be contained in: some log entry's 'message' field. Substrings will match.

$logType The type of log message to look for; all other: types are ignored. If FALSE (the default), then all log types will be searched.

1 call to CommandUnishTestCase::assertLogHasMessage()

File

tests/Unish/CommandUnishTestCase.php, line 386

Namespace

Unish

Class

CommandUnishTestCase

Code

function assertLogHasMessage($log, $message, $logType = FALSE) {
  foreach ($log as $entry) {
    if (!$logType || ($entry['type'] == $logType)) {
      if (strpos($entry['message'], $message) !== FALSE) {
        return TRUE;
      }
    }
  }
  $this->fail("Could not find expected message in log: " . $message);
}