當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Handler\TestHandler類代碼示例

本文整理匯總了PHP中Monolog\Handler\TestHandler的典型用法代碼示例。如果您正苦於以下問題:PHP TestHandler類的具體用法?PHP TestHandler怎麽用?PHP TestHandler使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了TestHandler類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testHandler

 /**
  * @dataProvider methodProvider
  */
 public function testHandler($method, $level)
 {
     $handler = new TestHandler();
     $record = $this->getRecord($level, 'test' . $method);
     $this->assertFalse($handler->{'has' . $method}($record), 'has' . $method);
     $this->assertFalse($handler->{'has' . $method . 'ThatContains'}('test'), 'has' . $method . 'ThatContains');
     $this->assertFalse($handler->{'has' . $method . 'ThatPasses'}(function ($rec) {
         return true;
     }), 'has' . $method . 'ThatPasses');
     $this->assertFalse($handler->{'has' . $method . 'ThatMatches'}('/test\\w+/'));
     $this->assertFalse($handler->{'has' . $method . 'Records'}(), 'has' . $method . 'Records');
     $handler->handle($record);
     $this->assertFalse($handler->{'has' . $method}('bar'), 'has' . $method);
     $this->assertTrue($handler->{'has' . $method}($record), 'has' . $method);
     $this->assertTrue($handler->{'has' . $method}('test' . $method), 'has' . $method);
     $this->assertTrue($handler->{'has' . $method . 'ThatContains'}('test'), 'has' . $method . 'ThatContains');
     $this->assertTrue($handler->{'has' . $method . 'ThatPasses'}(function ($rec) {
         return true;
     }), 'has' . $method . 'ThatPasses');
     $this->assertTrue($handler->{'has' . $method . 'ThatMatches'}('/test\\w+/'));
     $this->assertTrue($handler->{'has' . $method . 'Records'}(), 'has' . $method . 'Records');
     $records = $handler->getRecords();
     unset($records[0]['formatted']);
     $this->assertEquals(array($record), $records);
 }
開發者ID:saj696,項目名稱:pipe,代碼行數:28,代碼來源:TestHandlerTest.php

示例2: getHandler

 public function getHandler()
 {
     $processor = new IntrospectionProcessor();
     $handler = new TestHandler();
     $handler->pushProcessor($processor);
     return $handler;
 }
開發者ID:kalaspuffar,項目名稱:php-orm-benchmark,代碼行數:7,代碼來源:IntrospectionProcessorTest.php

示例3: testProcessRecord

 /**
  * @covers Monolog\Handler\AbstractProcessingHandler::processRecord
  */
 public function testProcessRecord()
 {
     $handler = new TestHandler();
     $handler->pushProcessor(new WebProcessor(array('REQUEST_URI' => '', 'REQUEST_METHOD' => '', 'REMOTE_ADDR' => '')));
     $handler->handle($this->getRecord());
     list($record) = $handler->getRecords();
     $this->assertEquals(3, count($record['extra']));
 }
開發者ID:robertowest,項目名稱:CuteFlow-V4,代碼行數:11,代碼來源:AbstractProcessingHandlerTest.php

示例4: testLoggedServerWithError

 public function testLoggedServerWithError()
 {
     $handler = new TestHandler();
     $server = new Server(new Simple\Evaluator(), new Logger('API', array($handler)), Logger::WARNING);
     $server->reply('{"jsonrpc": "2.0", "method": "math/doesNotExist", "id": 123}');
     $this->assertTrue($handler->hasRecordThatContains('Message received: {"jsonrpc": "2.0", "method": "math/doesNotExist", "id": 123}', Logger::WARNING));
     $this->assertTrue($handler->hasRecordThatContains('Sending reply: {"jsonrpc":"2.0","id":123,"error":{"code":-32601,"message":"Method not found"}}', Logger::WARNING));
 }
開發者ID:datto,項目名稱:php-json-rpc-log,代碼行數:8,代碼來源:ServerTest.php

示例5: getLogger

 public function getLogger()
 {
     $logger = new Logger('foo');
     $logger->pushHandler($handler = new TestHandler());
     $logger->pushProcessor(new PsrLogMessageProcessor());
     $handler->setFormatter(new LineFormatter('%level_name% %message%'));
     $this->handler = $handler;
     return $logger;
 }
開發者ID:EnmanuelCode,項目名稱:backend-laravel,代碼行數:9,代碼來源:PsrLogCompatTest.php

示例6: testNon2XXResponsesGetLoggedAsWarning

 public function testNon2XXResponsesGetLoggedAsWarning()
 {
     $testHandler = new TestHandler();
     $logger = new Logger('test', [$testHandler]);
     $response = $this->performTestRequest($logger, new Request('GET', 'http://example.com'), new Response(300));
     $this->assertEquals(300, $response->getStatusCode());
     $this->assertCount(2, $testHandler->getRecords());
     $this->assertEquals('HTTP response 300', $testHandler->getRecords()[1]['message']);
     $this->assertEquals('WARNING', $testHandler->getRecords()[1]['level_name']);
 }
開發者ID:jberkel,項目名稱:tool,代碼行數:10,代碼來源:LoggingMiddlewareTest.php

示例7: testSesWithLoggerHandler

 /**
  * This tests that the handler pushes out exceptions
  */
 public function testSesWithLoggerHandler()
 {
     $sesMock = $this->getMock('Aws\\Ses\\SesClient', ['sendEmail'], [], '', false);
     $sesMock->expects($this->once())->method('sendEmail')->will($this->throwException(new SesException()));
     $testHandler = new TestHandler();
     $handlerLogger = new Logger('handler-logger', [$testHandler]);
     $handler = new SesHandler("test@example.com", "test", "test@example.com", $sesMock);
     $handler->setLogger($handlerLogger);
     $logger = new Logger('test', [$handler]);
     $logger->error('The error');
     $this->assertTrue($testHandler->hasErrorRecords());
 }
開發者ID:CascadeEnergy,項目名稱:monolog-aws,代碼行數:15,代碼來源:SesHandlerTest.php

示例8: testContentBadResponse

 public function testContentBadResponse()
 {
     $twitterOAuth = $this->getMockBuilder('TwitterOAuth\\TwitterOAuth')->disableOriginalConstructor()->getMock();
     $twitterOAuth->expects($this->once())->method('get')->will($this->throwException(new TwitterException()));
     $twitter = new Twitter($twitterOAuth);
     $logHandler = new TestHandler();
     $logger = new Logger('test', array($logHandler));
     $twitter->setLogger($logger);
     $twitter->match('https://twitter.com/DoerteDev/statuses/506522223860277248');
     $this->assertEmpty($twitter->getContent());
     $this->assertTrue($logHandler->hasWarning('Twitter extract failed for: 506522223860277248'), 'Warning message matched');
 }
開發者ID:pazjacket,項目名稱:j0k3r-_-f43.me,代碼行數:12,代碼來源:TwitterTest.php

示例9: testHandle

 public function testHandle()
 {
     $testHandler = new TestHandler();
     $handler = new SamplingHandler($testHandler, 2);
     for ($i = 0; $i < 10000; $i++) {
         $handler->handle($this->getRecord());
     }
     $count = count($testHandler->getRecords());
     // $count should be half of 10k, so between 4k and 6k
     $this->assertLessThan(6000, $count);
     $this->assertGreaterThan(4000, $count);
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:12,代碼來源:SamplingHandlerTest.php

示例10: testImgurFail

 public function testImgurFail()
 {
     $imgurClient = $this->getMockBuilder('Imgur\\Client')->disableOriginalConstructor()->getMock();
     $imgurClient->expects($this->any())->method('api')->will($this->throwException(new \Guzzle\Http\Exception\RequestException()));
     $imgur = new Imgur($imgurClient);
     $logHandler = new TestHandler();
     $logger = new Logger('test', array($logHandler));
     $imgur->setLogger($logger);
     $imgur->match('http://imgur.com/gallery/IoKwI7E');
     $this->assertEmpty($imgur->getContent());
     $this->assertTrue($logHandler->hasWarning('Imgur extract failed for: IoKwI7E'), 'Warning message matched');
 }
開發者ID:pazjacket,項目名稱:j0k3r-_-f43.me,代碼行數:12,代碼來源:ImgurTest.php

示例11: testHandleError

 public function testHandleError()
 {
     $logger = new Logger('test', array($handler = new TestHandler()));
     $errHandler = new ErrorHandler($logger);
     $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false);
     trigger_error('Foo', E_USER_ERROR);
     $this->assertCount(1, $handler->getRecords());
     $this->assertTrue($handler->hasErrorRecords());
     trigger_error('Foo', E_USER_NOTICE);
     $this->assertCount(2, $handler->getRecords());
     $this->assertTrue($handler->hasEmergencyRecords());
 }
開發者ID:ngitimfoyo,項目名稱:Nyari-AppPHP,代碼行數:12,代碼來源:ErrorHandlerTest.php

示例12: testSnsWithLoggerHandler

 /**
  * This tests that the handler pushes out exceptions
  */
 public function testSnsWithLoggerHandler()
 {
     $snsMock = $this->getMock('Aws\\Sns\\SnsClient', ['publish'], [], '', false);
     $snsMock->expects($this->once())->method('publish')->will($this->throwException(new SnsException('Error', new Command('Command'))));
     $testHandler = new TestHandler();
     $handlerLogger = new Logger('handler-logger', [$testHandler]);
     $handler = new SnsHandler("arn::test", "test", $snsMock);
     $handler->setLogger($handlerLogger);
     $logger = new Logger('test', [$handler]);
     $logger->error('The error');
     $this->assertTrue($testHandler->hasErrorRecords());
 }
開發者ID:mcfedr,項目名稱:monolog-aws,代碼行數:15,代碼來源:SnsHandlerTest.php

示例13: testLoggingLevels

 public function testLoggingLevels()
 {
     $test_handler = new TestHandler();
     $this->driver->getLogger()->setHandlers(array($test_handler));
     $levels = array_map('strtoupper', (new \Buttress\Logger\Logger())->getLevels());
     foreach ($levels as $level) {
         $this->driver->log($real_level = constant(\Monolog\Logger::class . "::{$level}"), $message = 'INFO');
         $result = $test_handler->hasRecordThatPasses(function ($record) use($message) {
             return $record['message'] = $message;
         }, $real_level);
         $this->assertTrue($result, "Logger didn't output for {$level}.");
     }
 }
開發者ID:buttress,項目名稱:framework,代碼行數:13,代碼來源:MonoLogDriverTest.php

示例14: testHandleBufferLimit

 public function testHandleBufferLimit()
 {
     $test = new TestHandler();
     $handler = new BufferHandler($test, 2);
     $handler->handle($this->getRecord(Logger::DEBUG));
     $handler->handle($this->getRecord(Logger::DEBUG));
     $handler->handle($this->getRecord(Logger::INFO));
     $handler->handle($this->getRecord(Logger::WARNING));
     $handler->close();
     $this->assertTrue($test->hasWarningRecords());
     $this->assertTrue($test->hasInfoRecords());
     $this->assertFalse($test->hasDebugRecords());
 }
開發者ID:nickaggarwal,項目名稱:sample-symfony2,代碼行數:13,代碼來源:BufferHandlerTest.php

示例15: testHandleUsesProcessors

 /**
  * @covers Monolog\Handler\GroupHandler::handle
  */
 public function testHandleUsesProcessors()
 {
     $test = new TestHandler();
     $handler = new GroupHandler(array($test));
     $handler->pushProcessor(function ($record) {
         $record['extra']['foo'] = true;
         return $record;
     });
     $handler->handle($this->getRecord(Logger::WARNING));
     $this->assertTrue($test->hasWarningRecords());
     $records = $test->getRecords();
     $this->assertTrue($records[0]['extra']['foo']);
 }
開發者ID:Ceciceciceci,項目名稱:MySJSU-Class-Registration,代碼行數:16,代碼來源:GroupHandlerTest.php


注:本文中的Monolog\Handler\TestHandler類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。