47 $this->handler->setConnectionTimeout(-1);
53 $this->handler->setConnectionTimeout(10.1);
54 $this->assertEquals(10.1, $this->handler->getConnectionTimeout());
63 $this->handler->setTimeout(-1);
69 $this->handler->setTimeout(10.25);
70 $this->assertEquals(10.25, $this->handler->getTimeout());
76 $this->handler->setWritingTimeout(10.25);
77 $this->assertEquals(10.25, $this->handler->getWritingTimeout());
83 $this->handler->setChunkSize(1025);
84 $this->assertEquals(1025, $this->handler->getChunkSize());
90 $this->assertEquals(
'tcp://localhost:9090', $this->handler->getConnectionString());
99 $this->handler->expects($this->
once())
100 ->method(
'fsockopen')
101 ->will($this->returnValue(
false));
111 $this->handler->expects($this->
once())
112 ->method(
'pfsockopen')
113 ->will($this->returnValue(
false));
114 $this->handler->setPersistent(
true);
124 $this->handler->expects($this->
once())
125 ->method(
'streamSetTimeout')
126 ->will($this->returnValue(
false));
136 $this->handler->setChunkSize(8192);
137 $this->handler->expects($this->
once())
138 ->method(
'streamSetChunkSize')
139 ->will($this->returnValue(
false));
150 $callback =
function ($arg) {
159 $this->handler->expects($this->exactly(2))
161 ->will($this->returnCallback($callback));
173 $callback =
function ($arg) {
182 $this->handler->expects($this->exactly(1))
184 ->will($this->returnCallback($callback));
185 $this->handler->expects($this->exactly(1))
186 ->method(
'streamGetMetadata')
187 ->will($this->returnValue(array(
'timed_out' =>
true)));
200 $callback =
function ($string) use (
$res) {
203 return strlen(
'Hello');
206 $this->handler->expects($this->exactly(1))
208 ->will($this->returnCallback($callback));
209 $this->handler->expects($this->exactly(1))
210 ->method(
'streamGetMetadata')
211 ->will($this->returnValue(array(
'timed_out' =>
false)));
222 fseek($this->res, 0);
223 $this->assertEquals(
'test1test2test3', fread($this->res, 1024));
230 $callback =
function ($arg) {
239 $this->handler->expects($this->exactly(2))
241 ->will($this->returnCallback($callback));
250 $this->assertInternalType(
'resource', $this->res);
251 $this->handler->close();
252 $this->assertFalse(is_resource($this->res),
"Expected resource to be closed after closing handler");
258 $this->handler->setPersistent(
true);
260 $this->assertTrue(is_resource($this->res));
261 $this->handler->close();
262 $this->assertTrue(is_resource($this->res));
272 $this->handler->expects($this->any())
274 ->will($this->returnValue(0));
276 $this->handler->expects($this->any())
277 ->method(
'streamGetMetadata')
278 ->will($this->returnValue(array(
'timed_out' =>
false)));
280 $this->handler->setWritingTimeout(1);
298 $this->res =
fopen(
'php://memory',
'a');
300 $defaultMethods = array(
'fsockopen',
'pfsockopen',
'streamSetTimeout');
301 $newMethods = array_diff($methods, $defaultMethods);
303 $finalMethods = array_merge($defaultMethods, $newMethods);
305 $this->handler = $this->getMock(
306 '\Monolog\Handler\SocketHandler', $finalMethods, array(
'localhost:1234')
309 if (!in_array(
'fsockopen', $methods)) {
310 $this->handler->expects($this->any())
311 ->method(
'fsockopen')
312 ->will($this->returnValue($this->res));
315 if (!in_array(
'pfsockopen', $methods)) {
316 $this->handler->expects($this->any())
317 ->method(
'pfsockopen')
318 ->will($this->returnValue($this->res));
321 if (!in_array(
'streamSetTimeout', $methods)) {
322 $this->handler->expects($this->any())
323 ->method(
'streamSetTimeout')
324 ->will($this->returnValue(
true));
327 if (!in_array(
'streamSetChunkSize', $methods)) {
328 $this->handler->expects($this->any())
329 ->method(
'streamSetChunkSize')
330 ->will($this->returnValue(8192));
setMockHandler(array $methods=array())
testWriteWithMemoryFile()
testSetConnectionString()
Stores to any socket - uses fsockopen() or pfsockopen().
testBadConnectionTimeout()
testExceptionIsThrownIfCannotSetTimeout()
UnexpectedValueException
testWriteFailsIfStreamTimesOut()
RuntimeException
getRecord($level=Logger::WARNING, $message='test', $context=array())
testExceptionIsThrownIfCannotSetChunkSize()
UnexpectedValueException
testInvalidHostname()
UnexpectedValueException
testExceptionIsThrownOnPfsockopenError()
UnexpectedValueException
once($eventName, callable $callBack, $priority=100)
Subscribe to an event exactly once.
testSetConnectionTimeout()
const WARNING
Exceptional occurrences that are not errors.
testWriteFailsOnIncompleteWrite()
RuntimeException
testCloseDoesNotClosePersistentSocket()
testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
createHandler($connectionString)
testWriteFailsOnIfFwriteReturnsFalse()
RuntimeException
testExceptionIsThrownOnFsockopenError()
UnexpectedValueException