|
|
|
@ -26,7 +26,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
protected function setUp() |
|
|
|
|
{ |
|
|
|
|
$this->logger = new Logger(); |
|
|
|
|
$this->dispatcher = $this->getMock('yii\\log\\Dispatcher', ['dispatch']); |
|
|
|
|
$this->dispatcher = $this->getMockBuilder('yii\\log\\Dispatcher') |
|
|
|
|
->setMethods(['dispatch']) |
|
|
|
|
->getMock(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -80,7 +82,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
*/ |
|
|
|
|
public function testLogWithFlush() |
|
|
|
|
{ |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['flush']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['flush']) |
|
|
|
|
->getMock(); |
|
|
|
|
$logger->flushInterval = 1; |
|
|
|
|
$logger->expects($this->exactly(1))->method('flush'); |
|
|
|
|
$logger->log('test1', Logger::LEVEL_INFO); |
|
|
|
@ -91,7 +95,7 @@ class LoggerTest extends TestCase
|
|
|
|
|
*/ |
|
|
|
|
public function testFlushWithoutDispatcher() |
|
|
|
|
{ |
|
|
|
|
$dispatcher = $this->getMock('\stdClass'); |
|
|
|
|
$dispatcher = $this->getMockBuilder('\stdClass')->getMock(); |
|
|
|
|
$dispatcher->expects($this->never())->method($this->anything()); |
|
|
|
|
|
|
|
|
|
$this->logger->messages = ['anything']; |
|
|
|
@ -141,7 +145,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
['duration' => 30], |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['getProfiling']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['getProfiling']) |
|
|
|
|
->getMock(); |
|
|
|
|
$logger->method('getProfiling')->willReturn($timings); |
|
|
|
|
$logger->expects($this->once()) |
|
|
|
|
->method('getProfiling') |
|
|
|
@ -271,7 +277,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
{ |
|
|
|
|
$messages = ['anyData']; |
|
|
|
|
$returnValue = 'return value'; |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['calculateTimings']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['calculateTimings']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$logger->messages = $messages; |
|
|
|
|
$logger->method('calculateTimings')->willReturn($returnValue); |
|
|
|
@ -295,7 +303,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
'duration' => 5, |
|
|
|
|
] |
|
|
|
|
]; |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['calculateTimings']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['calculateTimings']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$logger->messages = $messages; |
|
|
|
|
$logger->method('calculateTimings')->willReturn($returnValue); |
|
|
|
@ -332,7 +342,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
/** |
|
|
|
|
* Matched by category name |
|
|
|
|
*/ |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['calculateTimings']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['calculateTimings']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$logger->messages = $messages; |
|
|
|
|
$logger->method('calculateTimings')->willReturn($returnValue); |
|
|
|
@ -342,7 +354,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
/** |
|
|
|
|
* Matched by prefix |
|
|
|
|
*/ |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['calculateTimings']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['calculateTimings']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$logger->messages = $messages; |
|
|
|
|
$logger->method('calculateTimings')->willReturn($returnValue); |
|
|
|
@ -388,7 +402,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
/** |
|
|
|
|
* Exclude by category name |
|
|
|
|
*/ |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['calculateTimings']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['calculateTimings']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$logger->messages = $messages; |
|
|
|
|
$logger->method('calculateTimings')->willReturn($returnValue); |
|
|
|
@ -398,7 +414,9 @@ class LoggerTest extends TestCase
|
|
|
|
|
/** |
|
|
|
|
* Exclude by category prefix |
|
|
|
|
*/ |
|
|
|
|
$logger = $this->getMock('yii\\log\\Logger', ['calculateTimings']); |
|
|
|
|
$logger = $this->getMockBuilder('yii\\log\\Logger') |
|
|
|
|
->setMethods(['calculateTimings']) |
|
|
|
|
->getMock(); |
|
|
|
|
|
|
|
|
|
$logger->messages = $messages; |
|
|
|
|
$logger->method('calculateTimings')->willReturn($returnValue); |
|
|
|
|