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