\Horde_Test_Log

Provides utilities to test for log output.

Copyright 2011-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
getMockSkipConstructor()
getConfig()
getLogger()
assertLogCount()
assertLogContains()
assertLogRegExp()
getLogOutput()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
$_logHandler
N/A

Properties

$_logHandler

$_logHandler : \Horde_Log_Handler_Base

The log handler.

Type

\Horde_Log_Handler_Base

Methods

getMockSkipConstructor()

getMockSkipConstructor(  $className, array  $methods = array(), array  $arguments = array(),   $mockClassName = '') 

Useful shorthand if you are mocking a class with a private constructor

Parameters

$className
array $methods
array $arguments
$mockClassName

getConfig()

getConfig(string  $env, string  $path = null, array  $default = array()) : mixed

Helper method for loading test configuration from a file.

The configuration can be specified by an environment variable. If the variable content is a file name, the configuration is loaded from the file. Otherwise it's assumed to be a json encoded configuration hash. If the environment variable is not set, the method tries to load a conf.php file from the same directory as the test case.

Parameters

string $env

An environment variable name.

string $path

The path to use.

array $default

Some default values that are merged into the configuration if specified as a json hash.

Returns

mixed —

The value of the configuration file's $conf variable, or null.

getLogger()

getLogger() : \Horde_Log_Logger

Returns a log handler.

Returns

\Horde_Log_Logger

assertLogCount()

assertLogCount(integer  $count) : \Horde_Log_Logger

Asserts that the log contains the given number of messages.

You MUST fetch the logger via $this->getLogger() before using this method. This will store a reference to an internal mock log handler that will later be used to analyze the log events.

Parameters

integer $count

The expected number of messages.

Returns

\Horde_Log_Logger

assertLogContains()

assertLogContains(string  $message) : \Horde_Log_Logger

Asserts that the log contains at least one message matching the provided string.

You MUST fetch the logger via $this->getLogger() before using this method. This will store a reference to an internal mock log handler that will later be used to analyze the log events.

Parameters

string $message

The expected log message.

Returns

\Horde_Log_Logger

assertLogRegExp()

assertLogRegExp(string  $regular_expression) : \Horde_Log_Logger

Asserts that the log contains at least one message matching the provided regular_expression.

You MUST fetch the logger via $this->getLogger() before using this method. This will store a reference to an internal mock log handler that will later be used to analyze the log events.

Parameters

string $regular_expression

The expected regular expression.

Returns

\Horde_Log_Logger

getLogOutput()

getLogOutput() : array

Utility function to return the array of logged events.

Returns

array