19 use PhpConsole\Dispatcher\Debug as DebugDispatcher;
20 use PhpConsole\Dispatcher\Errors as ErrorDispatcher;
39 if (!class_exists(
'PhpConsole\Connector')) {
40 $this->markTestSkipped(
'PHP Console library not found. See https://github.com/barbushin/php-console#installation');
45 $this->connector->setDebugDispatcher($this->debugDispatcher);
48 $this->connector->setErrorsDispatcher($this->errorDispatcher);
53 return $this->getMockBuilder(
'PhpConsole\Dispatcher\Debug')
54 ->disableOriginalConstructor()
55 ->setMethods(array(
'dispatchDebug'))
56 ->setConstructorArgs(array($connector, $connector->getDumper()))
62 return $this->getMockBuilder(
'PhpConsole\Dispatcher\Errors')
63 ->disableOriginalConstructor()
64 ->setMethods(array(
'dispatchError',
'dispatchException'))
65 ->setConstructorArgs(array($connector, $connector->getDumper()))
71 $connector = $this->getMockBuilder(
'PhpConsole\Connector')
72 ->disableOriginalConstructor()
83 'startEvalRequestsListener',
88 ->method(
'isActiveClient')
89 ->will($this->returnValue(
true));
104 return new Logger(
'test', array(
112 $this->assertEquals(spl_object_hash(Connector::getInstance()), spl_object_hash(
$handler->getConnector()));
118 $this->assertEquals(spl_object_hash($this->connector), spl_object_hash(
$handler->getConnector()));
123 $this->debugDispatcher->expects($this->
once())->method(
'dispatchDebug')->with($this->equalTo(
'test'));
133 $this->debugDispatcher->expects($this->
once())->method(
'dispatchDebug')->with(
134 $this->equalTo($expectedMessage),
142 $expectedTags = mt_rand();
143 $logger = $this->
initLogger($tagsContextKeys ? array(
'debugTagsKeysInContext' => $tagsContextKeys) : array());
144 if (!$tagsContextKeys) {
147 foreach ($tagsContextKeys as
$key) {
151 $this->equalTo($expectedTags)
154 $logger->addDebug(
'test', array($key => $expectedTags));
158 public function testError($classesPartialsTraceIgnore = null)
160 $code = E_USER_NOTICE;
164 $this->errorDispatcher->expects($this->
once())->method(
'dispatchError')->with(
165 $this->equalTo(
$code),
167 $this->equalTo($file),
168 $this->equalTo($line),
171 $errorHandler =
ErrorHandler::register($this->
initLogger($classesPartialsTraceIgnore ? array(
'classesPartialsTraceIgnore' => $classesPartialsTraceIgnore) : array()),
false);
172 $errorHandler->registerErrorHandler(array(),
false, E_USER_WARNING);
179 $this->errorDispatcher->expects($this->
once())->method(
'dispatchException')->with(
185 sprintf(
'Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()),
186 array(
'exception' => $e)
200 $this->debugDispatcher->expects($this->never())->method(
'dispatchDebug');
201 $this->
initLogger(array(
'enabled' =>
false))->addDebug(
'test');
206 $this->
testError(array(
'Class',
'Namespace\\'));
216 $this->
initLogger(array(
'useOwnErrorsHandler' =>
true,
'useOwnExceptionsHandler' =>
true));
217 $this->assertEquals(array(Handler::getInstance(),
'handleError'), set_error_handler(
function () {
219 $this->assertEquals(array(Handler::getInstance(),
'handleException'), set_exception_handler(
function () {
226 array(
'sourcesBasePath',
'setSourcesBasePath', __DIR__),
227 array(
'serverEncoding',
'setServerEncoding',
'cp1251'),
228 array(
'password',
'setPassword',
'******'),
229 array(
'enableSslOnlyMode',
'enableSslOnlyMode',
true,
false),
230 array(
'ipMasks',
'setAllowedIpMasks', array(
'127.0.0.*')),
231 array(
'headersLimit',
'setHeadersLimit', 2500),
232 array(
'enableEvalListener',
'startEvalRequestsListener',
true,
false),
241 $expectCall = $this->connector->expects($this->
once())->method($method);
243 $expectCall->with($value);
250 new PHPConsoleHandler(array(
'detectDumpTraceAndSource' =>
true), $this->connector);
251 $this->assertTrue($this->connector->getDebugDispatcher()->detectTraceAndSource);
257 array(
'dumperLevelLimit',
'levelLimit', 1001),
258 array(
'dumperItemsCountLimit',
'itemsCountLimit', 1002),
259 array(
'dumperItemSizeLimit',
'itemSizeLimit', 1003),
260 array(
'dumperDumpSizeLimit',
'dumpSizeLimit', 1004),
261 array(
'dumperDetectCallbacks',
'detectCallbacks',
true),
271 $this->assertEquals($value, $this->connector->getDumper()->$dumperProperty);
testDebugTags($tagsContextKeys=null)
const DEBUG
Detailed debug information.
testWrongOptionsThrowsException()
Exception
static provideConnectorMethodsOptionsSets()
initLogger($handlerOptions=array(), $level=Logger::DEBUG)
testDebugContextInMessage()
initDebugDispatcherMock(Connector $connector)
testError($classesPartialsTraceIgnore=null)
Monolog handler for Google Chrome extension "PHP Console".
testInitWithDefaultConnector()
testOptionCallsConnectorMethod($option, $method, $value, $isArgument=true)
provideConnectorMethodsOptionsSets
catch(Exception $e) $message
testOptionUseOwnErrorsAndExceptionsHandler()
static provideDumperOptionsValues()
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
testOptionDetectDumpTraceAndSource()
testDumperOptions($option, $dumperProperty, $value)
provideDumperOptionsValues
testOptionClassesPartialsTraceIgnore()
static register(LoggerInterface $logger, $errorLevelMap=array(), $exceptionLevel=null, $fatalLevel=null)
Registers a new ErrorHandler for a given Logger.
getHandlerDefaultOption($name)
testOptionDebugTagsKeysInContext()
if(function_exists('posix_getuid') &&posix_getuid()===0) if(!array_key_exists('t', $options)) $tag
initErrorDispatcherMock(Connector $connector)
testInitWithCustomConnector()