PHP Classes

File: Tests/PlainLoggerTest.php

Recommend this page to a friend!
  Classes of Joseluis Laso   Simple Logger   Tests/PlainLoggerTest.php   Download  
File: Tests/PlainLoggerTest.php
Role: Class source
Content type: text/plain
Description: Class source
Class: Simple Logger
Log messages and view log filtered files
Author: By
Last change: Update of Tests/PlainLoggerTest.php
Date: 1 year ago
Size: 848 bytes
 

Contents

Class file image Download
<?php

namespace JLaso\SimpleLogger\Tests;

use
JLaso\SimpleLogger\PlainFileLogger;

class
PlainLoggerTest extends AbstractTestCase
{
    public function
testLogWrite()
    {
       
$readConfig = PlainFileLogger::getInstance()->getConfig();

       
$this->assertEquals(
           
$this->testConfig['logger']['path'],
           
$readConfig['logger']['path']
        );

       
$data = 'This is a logged text';
       
PlainFileLogger::log('error', $data);

       
$loggedText = file_get_contents($this->loggerFile);

       
$this->assertRegExp("/$data$/", $loggedText);

       
unlink($this->loggerFile);

       
// info level is not logged, so this text wont be in the logger file

       
$data = 'This is a logged text';
       
PlainFileLogger::log('info', $data);

       
$this->assertFalse(file_exists($this->loggerFile));
    }
}