Skip to content

Commit

Permalink
Add LogTest to AllTests suite
Browse files Browse the repository at this point in the history
Fix name of mock Logger in LogTest

Fix expected dates in LoggerTest
  • Loading branch information
Josh Lockhart committed Jan 10, 2011
1 parent 96cb91f commit b72432f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions tests/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
require_once 'ResponseTest.php';
require_once 'SlimTest.php';
require_once 'LoggerTest.php';
require_once 'LogTest.php';

class AllTests {

Expand All @@ -50,6 +51,7 @@ public static function suite() {
$suite->addTestSuite('RequestTest');
$suite->addTestSuite('ResponseTest');
$suite->addTestSuite('LoggerTest');
$suite->addTestSuite('LogTest');
return $suite;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/LogTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
require_once '../slim/Log.php';
require_once 'PHPUnit/Extensions/OutputTestCase.php';

class Logger {
class MyLogger {

public function debug( $object ) {
return 'debug';
Expand Down Expand Up @@ -69,7 +69,7 @@ class LogTest extends PHPUnit_Extensions_OutputTestCase {
* Logger set as Log logger
*/
public function testSetsLogger() {
$logger = new Logger();
$logger = new MyLogger();
Log::setLogger($logger);
$this->assertSame($logger, Log::getLogger());
}
Expand All @@ -84,7 +84,7 @@ public function testSetsLogger() {
* Expected responses are returned proving Logger was called;
*/
public function testLoggerMethods() {
Log::setLogger(new Logger());
Log::setLogger(new MyLogger());
$this->assertEquals('debug', Log::debug('Test'));
$this->assertEquals('info', Log::info('Test'));
$this->assertEquals('warn', Log::warn('Test'));
Expand Down
10 changes: 5 additions & 5 deletions tests/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function testLoggerInstantiation() {
*/
public function testLogsDebug() {
$l = new TestLogger('./logs', 4);
$this->expectOutputString('[DEBUG] ' . strftime(DATE_ISO8601) . ' - ' . 'Test Info');
$this->expectOutputString('[DEBUG] ' . date('c') . ' - ' . "Test Info\r\n");
$l->debug('Test Info');
}

Expand All @@ -93,7 +93,7 @@ public function testLogsDebug() {
*/
public function testLogsInfo() {
$l = new TestLogger('./logs', 3);
$this->expectOutputString('[INFO] ' . strftime(DATE_ISO8601) . ' - ' . 'Test Info');
$this->expectOutputString('[INFO] ' . date('c') . ' - ' . "Test Info\r\n");
$l->debug('Test Info');
$l->info('Test Info');
}
Expand All @@ -103,7 +103,7 @@ public function testLogsInfo() {
*/
public function testLogsWarn() {
$l = new TestLogger('./logs', 2);
$this->expectOutputString('[WARN] ' . strftime(DATE_ISO8601) . ' - ' . 'Test Info');
$this->expectOutputString('[WARN] ' . date('c') . ' - ' . "Test Info\r\n");
$l->info('Test Info');
$l->warn('Test Info');
}
Expand All @@ -113,7 +113,7 @@ public function testLogsWarn() {
*/
public function testLogsError() {
$l = new TestLogger('./logs', 1);
$this->expectOutputString('[ERROR] ' . strftime(DATE_ISO8601) . ' - ' . 'Test Info');
$this->expectOutputString('[ERROR] ' . date('c') . ' - ' . "Test Info\r\n");
$l->warn('test Info');
$l->error('Test Info');
}
Expand All @@ -123,7 +123,7 @@ public function testLogsError() {
*/
public function testLogsFatal() {
$l = new TestLogger('./logs', 0);
$this->expectOutputString('[FATAL] ' . strftime(DATE_ISO8601) . ' - ' . 'Test Info');
$this->expectOutputString('[FATAL] ' . date('c') . ' - ' . "Test Info\r\n");
$l->error('Test Info');
$l->fatal('Test Info');
}
Expand Down

0 comments on commit b72432f

Please sign in to comment.