* @license PHP License * @package WB * @subpackage unittest */ /** * Unit Test * * Parameter observer mock up * * @version 0.1.0 * @package WB * @subpackage unittest */ class TestCaseLogBase extends UnitTestCase { /** * log driver * */ protected $_log; /** * logger config * @var unknown_type */ protected $_config; public function __construct() { WBClass::load( 'WBLog' ); $this->_config = WBParam::Get( 'wb/log/default/driver' ); $driver = WBParam::Get( 'wb/log/default/driver' ); $level = WBParam::Get( 'wb/log/default/level' ); WBParam::Set( 'wb/log/default/driver', 'UnitTest' ); WBParam::Set( 'wb/log/default/level', 'debug' ); $this->_log = WBLog::start( __CLASS__ ); WBParam::Set( 'wb/log/default/driver', $driver ); WBParam::Set( 'wb/log/default/level', $level ); } public function __destruct() { WBParam::Set('wb/log', $this->_config); } /** * simply set parameter * */ public function testInit() { $this->assertTrue( class_exists( 'WBLog', false ) ); $this->assertTrue( is_object( $this->_log ) ); $this->assertIsA( $this->_log, 'WBLog_UnitTest' ); } /** * log something * */ public function testLog() { $this->assertTrue( $this->_log->debug( 'debug' ) ); $log = $this->_log->shift(); $this->assertEqual( $log[0], 'debug' ); $this->assertEqual( $log[1], 'debug' ); $this->assertTrue( $this->_log->notice( 'notice' ) ); $log = $this->_log->shift(); $this->assertEqual( $log[0], 'notice' ); $this->assertEqual( $log[1], 'notice' ); $this->assertTrue( $this->_log->info( 'info' ) ); $log = $this->_log->shift(); $this->assertEqual( $log[0], 'info' ); $this->assertEqual( $log[1], 'info' ); $this->assertTrue( $this->_log->warn( 'warning' ) ); $log = $this->_log->shift(); $this->assertEqual( $log[0], 'warning' ); $this->assertEqual( $log[1], 'warning' ); $this->assertTrue( $this->_log->err( 'error' ) ); $log = $this->_log->shift(); $this->assertEqual( $log[0], 'error' ); $this->assertEqual( $log[1], 'error' ); } } ?>