‪TYPO3CMS  ‪main
LoggerAwareChannelTest.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;
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
28 
29 final class ‪LoggerAwareChannelTest extends FunctionalTestCase
30 {
31  protected array ‪$testExtensionsToLoad = [
32  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/test_logger',
33  ];
34 
36  'LOG' => [
37  'beep' => [
38  'writerConfiguration' => [
39  LogLevel::DEBUG => [
40  DummyWriter::class => [],
41  ],
42  ],
43  ],
44  ],
45  ];
46 
47  protected function ‪setUp(): void
48  {
49  parent::setUp();
50  $this->importCSVDataSet(__DIR__ . '/../Fixtures/be_users.csv');
51  $backendUser = $this->setUpBackendUser(1);
52  ‪$GLOBALS['LANG'] = $this->get(LanguageServiceFactory::class)->createFromUserPreferences($backendUser);
54  }
55 
56  protected function ‪tearDown(): void
57  {
59  parent::tearDown();
60  }
61 
62  #[Test]
63  public function ‪classLevelChannelAttributeIsRead(): void
64  {
65  $container = $this->getContainer();
66  $subject = $container->get(LoggerAwareClassAttributeChannelTester::class);
67 
68  $subject->run();
69 
70  self::assertInstanceOf(LogRecord::class, ‪DummyWriter::$logs[0]);
71  self::assertSame('beep beep', ‪DummyWriter::$logs[0]->getMessage());
72  }
73 
74  #[Test]
75  public function ‪constructorChannelAttributeIsRead(): void
76  {
77  $container = $this->getContainer();
78  $subject = $container->get(ConstructorAttributeChannelTester::class);
79 
80  $subject->run();
81 
82  self::assertInstanceOf(LogRecord::class, ‪DummyWriter::$logs[0]);
83  self::assertSame('beep beep', ‪DummyWriter::$logs[0]->getMessage());
84  }
85 }
‪TYPO3\CMS\Core\Localization\LanguageServiceFactory
Definition: LanguageServiceFactory.php:25
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest\tearDown
‪tearDown()
Definition: LoggerAwareChannelTest.php:56
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest\setUp
‪setUp()
Definition: LoggerAwareChannelTest.php:47
‪TYPO3\CMS\Core\Tests\Functional\Log
Definition: LoggerAwareChannelTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest
Definition: LoggerAwareChannelTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest\constructorChannelAttributeIsRead
‪constructorChannelAttributeIsRead()
Definition: LoggerAwareChannelTest.php:75
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: LoggerAwareChannelTest.php:31
‪TYPO3\CMS\Core\Log\LogRecord
Definition: LogRecord.php:24
‪TYPO3\CMS\Core\Tests\Functional\Fixtures\Log\DummyWriter\$logs
‪static array $logs
Definition: DummyWriter.php:26
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest\$configurationToUseInTestInstance
‪array $configurationToUseInTestInstance
Definition: LoggerAwareChannelTest.php:35
‪TYPO3Tests\TestLogger\LoggerAwareClassAttributeChannelTester
Definition: LoggerAwareClassAttributeChannelTester.php:26
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Core\Tests\Functional\Log\LoggerAwareChannelTest\classLevelChannelAttributeIsRead
‪classLevelChannelAttributeIsRead()
Definition: LoggerAwareChannelTest.php:63
‪TYPO3Tests\TestLogger\ConstructorAttributeChannelTester
Definition: ConstructorAttributeChannelTester.php:24
‪TYPO3\CMS\Core\Tests\Functional\Fixtures\Log\DummyWriter
Definition: DummyWriter.php:24