‪TYPO3CMS  11.5
DatabaseWriterTest.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 
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
29 class ‪DatabaseWriterTest extends FunctionalTestCase
30 {
35  {
36  $logRecordData = [
37  'request_id' => '5862c0e7838ac',
38  'time_micro' => 1469740000.0,
39  'component' => 'aComponent',
40  'level' => ‪LogLevel::normalizeLevel(LogLevel::DEBUG),
41  'message' => 'aMessage',
42  'data' => '',
43  ];
44  $logRecord = new ‪LogRecord(
45  $logRecordData['component'],
46  LogLevel::DEBUG,
47  $logRecordData['message'],
48  [],
49  $logRecordData['request_id']
50  );
51  $logRecord->setCreated($logRecordData['time_micro']);
52 
53  (new ‪DatabaseWriter())->writeLog($logRecord);
54 
55  $rowInDatabase = (new ‪ConnectionPool())->getConnectionForTable('sys_log')
56  ->select(
57  array_keys($logRecordData),
58  'sys_log',
59  ['request_id' => $logRecordData['request_id']]
60  )
61  ->fetchAssociative();
62 
63  self::assertEquals($logRecordData, $rowInDatabase);
64  }
65 }
‪TYPO3\CMS\Core\Tests\Functional\Log\Writer\DatabaseWriterTest\writeLogInsertsLogRecordWithGivenProperties
‪writeLogInsertsLogRecordWithGivenProperties()
Definition: DatabaseWriterTest.php:34
‪TYPO3\CMS\Core\Log\Writer\DatabaseWriter
Definition: DatabaseWriter.php:27
‪TYPO3\CMS\Core\Log\LogRecord
Definition: LogRecord.php:22
‪TYPO3\CMS\Core\Tests\Functional\Log\Writer\DatabaseWriterTest
Definition: DatabaseWriterTest.php:30
‪TYPO3\CMS\Core\Tests\Functional\Log\Writer
Definition: DatabaseWriterTest.php:18
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Core\Log\LogLevel\normalizeLevel
‪static int normalizeLevel($level)
Definition: LogLevel.php:94
‪TYPO3\CMS\Core\Log\LogLevel
Definition: LogLevel.php:24