class LoggerMock in Acquia Content Hub 8.2
Mock Logger created for easy assertions of log messages.
Hierarchy
- class \Drupal\Tests\acquia_contenthub\Unit\Helpers\LoggerMock implements LoggerChannelInterface uses RfcLoggerTrait
Expanded class hierarchy of LoggerMock
2 files declare their use of LoggerMock
- ImportUpdateAssetsTest.php in tests/
src/ Kernel/ ImportUpdateAssetsTest.php - IsPathAliasForUnpublishedContentTest.php in modules/
acquia_contenthub_publisher/ tests/ src/ Unit/ EventSubscriber/ EntityEligibility/ IsPathAliasForUnpublishedContentTest.php
File
- tests/
src/ Unit/ Helpers/ LoggerMock.php, line 15
Namespace
Drupal\Tests\acquia_contenthub\Unit\HelpersView source
class LoggerMock implements LoggerChannelInterface {
use RfcLoggerTrait;
/**
* The message's placeholders parser.
*
* @var \Drupal\Core\Logger\LogMessageParserInterface
*/
protected $parser;
/**
* Constructs a LoggerMock object.
*/
public function __construct() {
$this->parser = new LogMessageParser();
}
/**
* Log messages.
*
* @var array
*/
protected $logMessages = [];
/**
* {@inheritDoc}
*/
public function log($level, $message, array $context = []) {
if (!empty($context)) {
$message_placeholders = $this->parser
->parseMessagePlaceholders($message, $context);
$message = empty($message_placeholders) ? $message : strtr($message, $message_placeholders);
}
$this->logMessages[$level][] = strip_tags($message);
}
/**
* Helper method that can be used for assertions.
*
* @return array
* Log messages.
*/
public function getLogMessages() : array {
return $this->logMessages;
}
/**
* {@inheritDoc}
*/
public function setRequestStack(RequestStack $requestStack = NULL) {
}
/**
* {@inheritDoc}
*/
public function setCurrentUser(AccountInterface $current_user = NULL) {
}
/**
* {@inheritDoc}
*/
public function setLoggers(array $loggers) {
}
/**
* {@inheritDoc}
*/
public function addLogger(LoggerInterface $logger, $priority = 0) {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LoggerMock:: |
protected | property | Log messages. | |
LoggerMock:: |
protected | property | The message's placeholders parser. | |
LoggerMock:: |
public | function |
Adds a logger. Overrides LoggerChannelInterface:: |
|
LoggerMock:: |
public | function | Helper method that can be used for assertions. | |
LoggerMock:: |
public | function |
Logs with an arbitrary level. Overrides RfcLoggerTrait:: |
|
LoggerMock:: |
public | function |
Sets the current user. Overrides LoggerChannelInterface:: |
|
LoggerMock:: |
public | function |
Sets the loggers for this channel. Overrides LoggerChannelInterface:: |
|
LoggerMock:: |
public | function |
Sets the request stack. Overrides LoggerChannelInterface:: |
|
LoggerMock:: |
public | function | Constructs a LoggerMock object. | |
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function | ||
RfcLoggerTrait:: |
public | function |