Adding some more commonly used SS_Log priority constants.

This commit is contained in:
Sean Harvey 2014-06-20 15:27:42 +12:00
parent 11cc27f700
commit 9c2ddd4850
2 changed files with 24 additions and 3 deletions

View File

@ -49,6 +49,8 @@ class SS_Log {
const ERR = Zend_Log::ERR;
const WARN = Zend_Log::WARN;
const NOTICE = Zend_Log::NOTICE;
const INFO = Zend_Log::INFO;
const DEBUG = Zend_Log::DEBUG;
/**
* Logger class to use.

View File

@ -49,9 +49,10 @@ class SS_LogTest extends SapphireTest {
$testEmailWriter = new SS_LogEmailWriter('test@test.com');
SS_Log::add_writer($testEmailWriter, SS_Log::ERR);
SS_Log::log('Email test', SS_LOG::ERR, array('my-string' => 'test', 'my-array' => array('one' => 1)));
SS_Log::log('Email test', SS_Log::ERR, array('my-string' => 'test', 'my-array' => array('one' => 1)));
$this->assertEmailSent('test@test.com');
$email = $this->findEmail('test@test.com');
$this->assertContains('[Error] Email test', $email['htmlContent']);
$parser = new CSSContentParser($email['htmlContent']);
$extras = $parser->getBySelector('table.extras');
$extraRows = $extras[0]->tr;
@ -64,7 +65,25 @@ class SS_LogTest extends SapphireTest {
'Serializes arrays correctly'
);
}
public function testEmailWriterDebugPriority() {
$testEmailWriter = new SS_LogEmailWriter('test@test.com');
SS_Log::add_writer($testEmailWriter, SS_Log::DEBUG);
SS_Log::log('Test something', SS_Log::DEBUG, array('my-string' => 'test', 'my-array' => array('one' => 1)));
$this->assertEmailSent('test@test.com');
$email = $this->findEmail('test@test.com');
$this->assertContains('[DEBUG] Test something', $email['htmlContent']);
}
public function testEmailWriterInfoPriority() {
$testEmailWriter = new SS_LogEmailWriter('test@test.com');
SS_Log::add_writer($testEmailWriter, SS_Log::INFO);
SS_Log::log('Test something', SS_Log::INFO, array('my-string' => 'test', 'my-array' => array('one' => 1)));
$this->assertEmailSent('test@test.com');
$email = $this->findEmail('test@test.com');
$this->assertContains('[INFO] Test something', $email['htmlContent']);
}
protected function exceptionGeneratorThrower() {
throw new Exception("thrown from SS_LogTest::testExceptionGeneratorTop");
}
@ -116,4 +135,4 @@ class SS_LogTest extends SapphireTest {
class SS_LogTest_NewLogger extends SS_Log {
protected static $logger;
}
}