17 use \org\bovigo\vfs\vfsStream;
18 use \org\bovigo\vfs\vfsStreamDirectory;
19 use \org\bovigo\vfs\vfsStreamWrapper;
39 if (!class_exists(
'org\\bovigo\\vfs\\vfsStream')) {
40 $this->markTestSkipped(
'File backend tests are not available with this phpunit version.');
42 vfsStream::setup(
'LogRoot');
52 protected function createLogger($name =
'') {
68 protected function createWriter($prependName =
'') {
77 return 'vfs://LogRoot/' . $this->logFileDirectory .
'/' . $prependName .
$this->logFileName;
85 vfsStream::newFile($this->logFileName)->at(vfsStreamWrapper::getRoot());
96 $tempFile = rtrim(sys_get_temp_dir(),
'/\\') .
'/typo3.log';
97 $writer->setLogFile($tempFile);
98 $this->assertAttributeEquals($tempFile,
'logFile', $writer);
106 $this->createWriter();
107 $this->assertTrue(vfsStreamWrapper::getRoot()->hasChild($this->logFileDirectory));
115 $this->createWriter();
116 $this->assertTrue(vfsStreamWrapper::getRoot()->getChild($this->logFileDirectory)->hasChild($this->logFileName));
126 'simple record' => array($simpleRecord, trim((
string) $simpleRecord)),
127 'record with data' => array($recordWithData, trim((
string) $recordWithData))
139 $this->createWriter()->writeLog($record);
141 $this->assertEquals($expectedResult, $logFileContents);
152 $firstWriter = $this->createWriter();
153 $secondWriter = $this->createWriter(
'second-');
155 $firstWriter->writeLog($record);
156 $secondWriter->writeLog($record);
159 $secondLogFileContents = trim(file_get_contents($this->
getDefaultFileName(
'second-')));
161 $this->assertEquals($expectedResult, $firstLogFileContents);
162 $this->assertEquals($expectedResult, $secondLogFileContents);
171 $firstWriter = $this->getMock(
'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter', array(
'dummy'));
172 $secondWriter = $this->getMock(
'TYPO3\\CMS\\Core\\Log\\Writer\\FileWriter', array(
'createLogFile'));
174 $secondWriter->expects($this->never())->method(
'createLogFile');
differentWritersLogToDifferentFiles(\TYPO3\CMS\Core\Log\LogRecord $record, $expectedResult)
logsToFile(\TYPO3\CMS\Core\Log\LogRecord $record, $expectedResult)
createsLogFileDirectory()
static makeInstance($className)
aSecondLogWriterToTheSameFileDoesNotOpenTheFileTwice()
setLogFileAcceptsAbsolutePath()
getDefaultFileName($prependName='')