From 9c2ddd4850b32384b7f84c4b9138438c97329c3a Mon Sep 17 00:00:00 2001 From: Sean Harvey Date: Fri, 20 Jun 2014 15:27:42 +1200 Subject: [PATCH] Adding some more commonly used SS_Log priority constants. --- dev/Log.php | 2 ++ tests/dev/LogTest.php | 25 ++++++++++++++++++++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/dev/Log.php b/dev/Log.php index ade21604e..f14ac4d48 100644 --- a/dev/Log.php +++ b/dev/Log.php @@ -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. diff --git a/tests/dev/LogTest.php b/tests/dev/LogTest.php index b41a436ab..2bed25666 100644 --- a/tests/dev/LogTest.php +++ b/tests/dev/LogTest.php @@ -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; -} \ No newline at end of file +}