From a379bc5050a7a808150f89e139e34c6f7061994e Mon Sep 17 00:00:00 2001 From: wujunze Date: Mon, 23 Apr 2018 15:17:44 +0800 Subject: [PATCH] implement Logger add unit test --- composer.json | 8 ++--- src/Logger.php | 30 +++++++------------ tests/LoggerTest.php | 69 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 23 deletions(-) create mode 100644 tests/LoggerTest.php diff --git a/composer.json b/composer.json index dfbcbf5..6d6cdd2 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "seasx/seaslogger", + "name": "seasx/seas-logger", "description": "An effective,fast,stable log package for PHP", "keywords": [ "log", @@ -17,19 +17,19 @@ "require": { "php": "^7.0", "psr/log": "^1.0.2", - "ext-SeasLog": "^1.8" + "ext-SeasLog": "^1.7" }, "require-dev": { "phpunit/phpunit": "^6.5" }, "autoload": { "psr-4": { - "SeasX\\Seaslogger\\": "src" + "Seasx\\SeasLogger\\": "src/" } }, "autoload-dev": { "psr-4": { - "SeasX\\Seaslogger\\Tests\\": "tests" + "Seasx\\SeasLogger\\Tests\\": "tests/" } }, "scripts": { diff --git a/src/Logger.php b/src/Logger.php index e7cbbcf..65caf6d 100644 --- a/src/Logger.php +++ b/src/Logger.php @@ -1,101 +1,93 @@ init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->emergency('[SeasLog Test]', ['level' => 'emergency']); + } + + public function testAlert() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->alert('[SeasLog Test]', ['level' => 'alert']); + } + + public function testCritical() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->critical('[SeasLog Test]', ['level' => 'critical']); + } + + public function testError() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->critical('[SeasLog Test]', ['level' => 'error']); + } + + public function testWarning() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->warning('[SeasLog Test]', ['level' => 'warning']); + } + + public function testNotice() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->notice('[SeasLog Test]', ['level' => 'notice']); + } + + public function testInfo() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->info('[SeasLog Test]', ['level' => 'info']); + } + + public function testDebug() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->debug('[SeasLog Test]', ['level' => 'debug']); + } + + public function testLog() { + $logger = $this->init(); + $this->assertInstanceOf(Logger::class, $logger); + $logger->log('debug','[SeasLog Test]', ['level' => 'log']); + } +} \ No newline at end of file