public function testLogFunction() { $logger = new \FakeLogger(); $config = array(array('path' => '\\', 'level' => \Logger\Log::INFO, 'class' => $logger)); \Logger\Log::init($config); _log('func'); $this->assert->array($logger->array)->hasSize(1)->string($logger->array[0][0])->isEqualTo('func'); }
$test = new Test(); _log ('general'); \Logger\Log::getInstance ()->log('general_class'); */ class FakeLogger implements Logger\ILogger { public static $array = array(); public function log($pMessage, $pLevel, array $pInfos) { self::$array[] = array($pMessage, $pLevel); var_dump($pMessage, $pLevel); } public function __construct(array $pParams = array()) { } } require_once './ILogger.php'; require_once './Log.php'; require_once './LogProfile.php'; $config = array(array('path' => '\\Logger', 'level' => \Logger\Log::INFO, 'class' => new \FakeLogger())); \Logger\Log::init($config); \FakeLogger::$array = array(); \test\logg(); } namespace test { function logg() { \Logger\Log::getInstance()->fatal('fatal'); } }
public function testLevel() { $logger = new \FakeLogger(); $config = array(array('path' => '\\Logger', 'level' => \Logger\Log::FATAL, 'class' => $logger)); \Logger\Log::init($config); $this->_launchAllLevel(); $this->assert->array($logger->array)->hasSize(1)->string($logger->array[0][0])->isEqualTo('fatal'); $logger = new \FakeLogger(); $config = array(array('path' => '\\Logger', 'level' => \Logger\Log::ERROR, 'class' => $logger)); \Logger\Log::init($config); $this->_launchAllLevel(); $this->assert->array($logger->array)->hasSize(2)->string($logger->array[0][0])->isEqualTo('fatal')->string($logger->array[1][0])->isEqualTo('error'); $logger = new \FakeLogger(); $config = array(array('path' => '\\Logger', 'level' => \Logger\Log::WARN, 'class' => $logger)); \Logger\Log::init($config); $this->_launchAllLevel(); $this->assert->array($logger->array)->hasSize(3)->string($logger->array[0][0])->isEqualTo('fatal')->string($logger->array[1][0])->isEqualTo('error')->string($logger->array[2][0])->isEqualTo('warn'); $logger = new \FakeLogger(); $config = array(array('path' => '\\Logger', 'level' => \Logger\Log::INFO, 'class' => $logger)); \Logger\Log::init($config); $this->_launchAllLevel(); $this->assert->array($logger->array)->hasSize(4)->string($logger->array[0][0])->isEqualTo('fatal')->string($logger->array[1][0])->isEqualTo('error')->string($logger->array[2][0])->isEqualTo('warn')->string($logger->array[3][0])->isEqualTo('info'); $logger = new \FakeLogger(); $config = array(array('path' => '\\Logger', 'level' => \Logger\Log::DEBUG, 'class' => $logger)); \Logger\Log::init($config); $this->_launchAllLevel(); $this->assert->array($logger->array)->hasSize(5)->string($logger->array[0][0])->isEqualTo('fatal')->string($logger->array[1][0])->isEqualTo('error')->string($logger->array[2][0])->isEqualTo('warn')->string($logger->array[3][0])->isEqualTo('info')->string($logger->array[4][0])->isEqualTo('debug'); }