Trait LogTestTrait
Make assertions on logs
Method Summary
-
_expectLogMessage() protected
-
assertLogAbsent() public
Ensure that no log messages of a given level were captured by test loggers.
-
assertLogMessage() public
-
assertLogMessageContains() public
-
cleanupLog() public
Reset log configs
-
setupLog() public
Method Detail
_expectLogMessage() ¶ protected
_expectLogMessage(string $level, string $expectedMessage, string|null $scope, string $failMsg = '', bool $contains = false): void
Parameters
-
string
$level The level which should receive a log message
-
string
$expectedMessage The message which should be inside the log engine
-
string|null
$scope The scope of the expected message. If a message has multiple scopes, the provided scope must be within the message's set.
-
string
$failMsg optional The error message if the message was not in the log engine
-
bool
$contains optional Flag to decide if the expectedMessage can only be part of the logged message
Returns
void
assertLogAbsent() ¶ public
assertLogAbsent(string $level, string $failMsg = ''): void
Ensure that no log messages of a given level were captured by test loggers.
Parameters
-
string
$level The level of the expected message
-
string
$failMsg optional The error message if the message was not in the log engine
Returns
void
assertLogMessage() ¶ public
assertLogMessage(string $level, string $expectedMessage, string|null $scope = null, string $failMsg = ''): void
Parameters
-
string
$level The level of the expected message
-
string
$expectedMessage The message which should be inside the log engine
-
string|null
$scope optional The scope of the expected message. If a message has multiple scopes, the provided scope must be within the message's set.
-
string
$failMsg optional The error message if the message was not in the log engine
Returns
void
assertLogMessageContains() ¶ public
assertLogMessageContains(string $level, string $expectedMessage, string|null $scope = null, string $failMsg = ''): void
Parameters
-
string
$level The level which should receive a log message
-
string
$expectedMessage The message which should be inside the log engine
-
string|null
$scope optional The scope of the expected message. If a message has multiple scopes, the provided scope must be within the message's set.
-
string
$failMsg optional The error message if the message was not in the log engine
Returns
void
setupLog() ¶ public
setupLog(array|string $levels): void
Parameters
-
array|string
$levels The levels(s) which should receive a log message
Returns
void