Task #56792
closedEnhance assertion of error log entries
0%
Description
During the action tests it might happen, that errors occur. To assert expected or unexpected error log entries in the sys_log table, this functionality shall be added to the functional testing framework.
The current implementation just checks the amount of entries, which should be "0" in most cases - which is a bit weak to be considered as complete assertion.
Peter Niederlag shared some ideas during the review process which shall be part of a separate follow-up change.
// set by freezeErrorId() and used by assertErrorLogCreated()
protected $frozenErrorId = NULL;
// freeze ErrorLog
protected freezeErrorLog() { if $this->latestErrorId !== NULL { raise Exception('errorLog already frozen, use assertErrorLogCreated() before freezing again') }
$this->latestErrorId = sqlfetchIdofLatestErrorbyTimestamp();
}
assertErrorLogsCreated($expectedCount = 1, $detailPatterns = array() ) {
// check/warning on frozenErrorId (should be called prior to this assertion)
// check if there are $expectedCount new errorLogs (id > this->frozenErrorId)
// optionally check with regex
// finally reset frozenErrorId
$this->frozenErrorId = NULL;
}
(find discussion here https://review.typo3.org/#/c/27886/2/typo3/sysext/core/Tests/Functional/DataHandling/AbstractDataHandlerActionTestCase.php,unified)