TYPO3CMS  8
 All Classes Namespaces Files Functions Variables Pages
Functional/Log/Writer/DatabaseWriterTest.php
Go to the documentation of this file.
1 <?php
2 namespace TYPO3\CMS\Core\Tests\Functional\Log\Writer;
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 
23 
28 {
33  {
34  $logRecordData = [
35  'request_id' => Bootstrap::getInstance()->getRequestId(),
36  'time_micro' => 1469740000.0,
37  'component' => 'aComponent',
38  'level' => LogLevel::DEBUG,
39  'message' => 'aMessage',
40  'data' => ''
41  ];
42  $logRecord = new LogRecord(
43  $logRecordData['component'],
44  $logRecordData['level'],
45  $logRecordData['message'],
46  []
47  );
48  $logRecord->setCreated($logRecordData['time_micro']);
49 
50  (new DatabaseWriter())->writeLog($logRecord);
51 
52  $rowInDatabase = (new ConnectionPool())->getConnectionForTable('sys_log')
53  ->select(
54  array_keys($logRecordData),
55  'sys_log',
56  ['request_id' => $logRecordData['request_id']]
57  )
58  ->fetch();
59 
60  $this->assertEquals($logRecordData, $rowInDatabase);
61  }
62 }