‪TYPO3CMS  ‪main
AbstractProcessorTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use PHPUnit\Framework\Attributes\Test;
21 use Psr\Log\LogLevel;
29 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
30 
31 final class ‪AbstractProcessorTest extends UnitTestCase
32 {
33  #[Test]
35  {
36  $this->expectException(InvalidLogProcessorConfigurationException::class);
37  $this->expectExceptionCode(1321696151);
38 
39  $invalidConfiguration = [
40  'foo' => 'bar',
41  ];
42  GeneralUtility::makeInstance(ProcessorFixture::class, $invalidConfiguration);
43  }
44 
45  #[Test]
46  public function ‪loggerExecutesProcessors(): void
47  {
48  $logger = new ‪Logger('test.core.log');
49  $writer = new ‪NullWriter();
50  $level = LogLevel::DEBUG;
51  $logRecord = new ‪LogRecord('dummy', $level, 'message');
52  $processor = $this->getMockBuilder(ProcessorInterface::class)
53  ->onlyMethods(['processLogRecord'])
54  ->getMock();
55  $processor->expects(self::once())->method('processLogRecord')->willReturn($logRecord);
56 
57  $logger->addWriter($level, $writer);
58  $logger->addProcessor($level, $processor);
59  $logger->warning('test');
60  }
61 }
‪TYPO3\CMS\Core\Tests\Unit\Log\Processor\AbstractProcessorTest\loggerExecutesProcessors
‪loggerExecutesProcessors()
Definition: AbstractProcessorTest.php:46
‪TYPO3\CMS\Core\Log\Processor\ProcessorInterface
Definition: ProcessorInterface.php:27
‪TYPO3\CMS\Core\Tests\Unit\Log\Processor
Definition: AbstractMemoryProcessorTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Log\Processor\AbstractProcessorTest\processorRefusesInvalidConfigurationOptions
‪processorRefusesInvalidConfigurationOptions()
Definition: AbstractProcessorTest.php:34
‪TYPO3\CMS\Core\Tests\Unit\Log\Processor\AbstractProcessorTest
Definition: AbstractProcessorTest.php:32
‪TYPO3\CMS\Core\Log\LogRecord
Definition: LogRecord.php:24
‪TYPO3\CMS\Core\Tests\Unit\Log\Fixtures\ProcessorFixture
Definition: ProcessorFixture.php:27
‪TYPO3\CMS\Core\Log\Logger
Definition: Logger.php:28
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Log\Writer\NullWriter
Definition: NullWriter.php:24
‪TYPO3\CMS\Core\Log\Exception\InvalidLogProcessorConfigurationException
Definition: InvalidLogProcessorConfigurationException.php:23