silverstripe-framework/tests/dev/SSLogTest.php
Sean Harvey 2cca0b0a7b API CHANGE Added SSLogFileWriter to replace Debug::log_errors_to() and Debug::log_error_if_necessary() - the existing formatting for the Debug deprecation functions is now wrapped into SSLogErrorFileFormatter
MINOR Moved SSErrorLogTest to SSLogTest
MINOR Documentation updates for SSLog and other bits and pieces



git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@84828 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-08-19 21:55:03 +00:00

36 lines
1.0 KiB
PHP

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