Commit bb17d386 authored by Taddeus Kroes's avatar Taddeus Kroes

Added unit test for Logger::save().

parent 9b2c2614
...@@ -5,6 +5,7 @@ use WebBasics\Logger; ...@@ -5,6 +5,7 @@ use WebBasics\Logger;
define('NAME', 'Testlogger'); define('NAME', 'Testlogger');
define('FORMAT', '%(level): %(message)'); define('FORMAT', '%(level): %(message)');
define('LOGFILE', 'build/temp.log');
class LoggerTest extends PHPUnit_Extensions_OutputTestCase { class LoggerTest extends PHPUnit_Extensions_OutputTestCase {
function setUp() { function setUp() {
...@@ -108,6 +109,16 @@ class LoggerTest extends PHPUnit_Extensions_OutputTestCase { ...@@ -108,6 +109,16 @@ class LoggerTest extends PHPUnit_Extensions_OutputTestCase {
$this->logger->handle_exception(new Exception('test message')); $this->logger->handle_exception(new Exception('test message'));
$this->assertNotEquals($this->logger->dumps(), ''); $this->assertNotEquals($this->logger->dumps(), '');
} }
function test_save() {
$this->logger->warning('test message');
$this->logger->save(LOGFILE);
$this->assertStringEqualsFile(LOGFILE, 'WARNING: test message');
$this->logger->warning('another test message');
$this->logger->save(LOGFILE);
$this->assertStringEqualsFile(LOGFILE, "WARNING: test message\nWARNING: another test message");
file_exists(LOGFILE) && unlink(LOGFILE);
}
} }
?> ?>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment