‪TYPO3CMS  10.4
DatabaseWriterTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
27 class ‪DatabaseWriterTest extends FunctionalTestCase
28 {
33  {
34  $logRecordData = [
35  'request_id' => '5862c0e7838ac',
36  'time_micro' => 1469740000.0,
37  'component' => 'aComponent',
38  'level' => ‪LogLevel::normalizeLevel(LogLevel::DEBUG),
39  'message' => 'aMessage',
40  'data' => ''
41  ];
42  $logRecord = new ‪LogRecord(
43  $logRecordData['component'],
44  LogLevel::DEBUG,
45  $logRecordData['message'],
46  [],
47  $logRecordData['request_id']
48  );
49  $logRecord->setCreated($logRecordData['time_micro']);
50 
51  (new ‪DatabaseWriter())->writeLog($logRecord);
52 
53  $rowInDatabase = (new ‪ConnectionPool())->getConnectionForTable('sys_log')
54  ->select(
55  array_keys($logRecordData),
56  'sys_log',
57  ['request_id' => $logRecordData['request_id']]
58  )
59  ->fetch();
60 
61  self::assertEquals($logRecordData, $rowInDatabase);
62  }
63 }
‪TYPO3\CMS\Core\Tests\Functional\Log\Writer\DatabaseWriterTest\writeLogInsertsLogRecordWithGivenProperties
‪writeLogInsertsLogRecordWithGivenProperties()
Definition: DatabaseWriterTest.php:32
‪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:28
‪TYPO3\CMS\Core\Tests\Functional\Log\Writer
Definition: DatabaseWriterTest.php:16
‪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