root = vfsStream::setup('logs'); Configuration::getInstance()->logfile_location = $this->root->url(); Configuration::getInstance()->logger_level = 'info'; $this->logger = new RotatingFileLogger; # Shitty hack to get the filename to expect. Format: eseye-2018-05-06.log $this->logfile_name = 'eseye-' . date('Y-m-d') . '.log'; } public function testFileLoggerWritesLogInfo() { $this->logger->log('foo'); $logfile_content = $this->root->getChild($this->logfile_name)->getContent(); $this->assertContains('eseye.INFO: foo', $logfile_content); } public function testFileLoggerSkipWritesLogDebugWithoutRequiredLevel() { $this->logger->debug('foo'); $logfile_content = $this->root->getChild($this->logfile_name); $this->assertNull($logfile_content); } public function testFileLoggerWritesLogDebug() { Configuration::getInstance()->logger_level = Logger::DEBUG; // Init a new logger with the updated config $logger = new RotatingFileLogger; $logger->debug('foo'); $logfile_content = $this->root->getChild($this->logfile_name)->getContent(); $this->assertContains('eseye.DEBUG: foo', $logfile_content); } public function testFileLoggerWritesLogWarning() { $this->logger->warning('foo'); $logfile_content = $this->root->getChild($this->logfile_name)->getContent(); $this->assertContains('eseye.WARNING: foo', $logfile_content); } public function testFileLoggerWritesLogError() { $this->logger->error('foo'); $logfile_content = $this->root->getChild($this->logfile_name)->getContent(); $this->assertContains('eseye.ERROR: foo', $logfile_content); } }