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));
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'));
131 $context =
array($tag,
'custom' => mt_rand());
132 $expectedMessage = $message .
' ' . json_encode(array_slice($context, 1));
133 $this->debugDispatcher->expects($this->once())->method(
'dispatchDebug')->with(
134 $this->equalTo($expectedMessage),
137 $this->
initLogger()->addDebug($message, $context);
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;
161 $message =
'message';
164 $this->errorDispatcher->expects($this->once())->method(
'dispatchError')->with(
165 $this->equalTo(
$code),
166 $this->equalTo($message),
167 $this->equalTo(
$file),
168 $this->equalTo($line),
172 $errorHandler->registerErrorHandler(
array(),
false, E_USER_WARNING);
173 $errorHandler->handleError(
$code, $message,
$file, $line);
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');
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);
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
if(!is_array($argv)) $options
testOptionUseOwnErrorsAndExceptionsHandler()
static provideDumperOptionsValues()
Create styles array
The data for the language used.
testOptionDetectDumpTraceAndSource()
testDumperOptions($option, $dumperProperty, $value)
provideDumperOptionsValues
if(!file_exists("$old.txt")) if($old===$new) if(file_exists("$new.txt")) $file
testOptionClassesPartialsTraceIgnore()
static register(LoggerInterface $logger, $errorLevelMap=array(), $exceptionLevel=null, $fatalLevel=null)
Registers a new ErrorHandler for a given Logger.
getHandlerDefaultOption($name)
testOptionDebugTagsKeysInContext()
initErrorDispatcherMock(Connector $connector)
testInitWithCustomConnector()