private function mockEngineMethod($method) { $engine = $this->getMock('Hyperframework\\Logging\\LoggerEngine'); Logger::setEngine($engine); return $engine->expects($this->once())->method($method); }
public function testMaxLogLength() { Config::set('hyperframework.error_handler.enable_logger', true); Config::set('hyperframework.error_handler.max_log_length', 1); ini_set('display_errors', 0); $engine = $this->getMockBuilder('Hyperframework\\Logging\\LoggerEngine')->setMethods(['handleLogRecord'])->getMock(); Logger::setEngine($engine); $engine->expects($this->once())->method('handleLogRecord')->will($this->returnCallback(function ($logRecord) { $this->assertSame(1, strlen($logRecord->getMessage())); })); $this->handleError(); }