2009-08-19 05:55:23 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class SSLogTest extends SapphireTest {
|
|
|
|
|
|
|
|
protected $testEmailWriter;
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
2009-08-19 23:55:03 +02:00
|
|
|
SSLog::clear_writers(); // this test will break if existing writers are available!
|
2009-08-19 05:55:23 +02:00
|
|
|
$this->testEmailWriter = new SSLogEmailWriter('sean@silverstripe.com');
|
2009-08-19 23:55:03 +02:00
|
|
|
$this->testFileWriter = new SSLogFileWriter('../test.log');
|
2009-08-19 05:55:23 +02:00
|
|
|
SSLog::add_writer($this->testEmailWriter, SSLog::ERR);
|
2009-08-19 23:55:03 +02:00
|
|
|
SSLog::add_writer($this->testFileWriter, SSLog::WARN);
|
2009-08-19 05:55:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function testExistingWriter() {
|
|
|
|
$writers = SSLog::get_writers();
|
|
|
|
$this->assertType('array', $writers);
|
2009-08-19 23:55:03 +02:00
|
|
|
$this->assertEquals(2, count($writers));
|
2009-08-19 05:55:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function testRemoveWriter() {
|
|
|
|
SSLog::remove_writer($this->testEmailWriter);
|
|
|
|
$writers = SSLog::get_writers();
|
|
|
|
$this->assertType('array', $writers);
|
2009-08-19 23:55:03 +02:00
|
|
|
$this->assertEquals(1, count($writers));
|
|
|
|
SSLog::remove_writer($this->testFileWriter);
|
|
|
|
$writers = SSLog::get_writers();
|
|
|
|
$this->assertType('array', $writers);
|
2009-08-19 05:55:23 +02:00
|
|
|
$this->assertEquals(0, count($writers));
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|