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->assertEquals(
'tcp://localhost:9090', $this->handler->getConnectionString());
92 $this->handler->expects($this->once())
94 ->will($this->returnValue(
false));
104 $this->handler->expects($this->once())
105 ->method(
'pfsockopen')
106 ->will($this->returnValue(
false));
107 $this->handler->setPersistent(
true);
117 $this->handler->expects($this->once())
118 ->method(
'streamSetTimeout')
119 ->will($this->returnValue(
false));
130 $callback =
function ($arg) {
139 $this->handler->expects($this->exactly(2))
141 ->will($this->returnCallback($callback));
153 $callback =
function ($arg) {
162 $this->handler->expects($this->exactly(1))
164 ->will($this->returnCallback($callback));
165 $this->handler->expects($this->exactly(1))
166 ->method(
'streamGetMetadata')
167 ->will($this->returnValue(
array(
'timed_out' =>
true)));
180 $callback =
function ($string) use (
$res) {
183 return strlen(
'Hello');
186 $this->handler->expects($this->exactly(1))
188 ->will($this->returnCallback($callback));
189 $this->handler->expects($this->exactly(1))
190 ->method(
'streamGetMetadata')
191 ->will($this->returnValue(
array(
'timed_out' =>
false)));
202 fseek($this->res, 0);
203 $this->assertEquals(
'test1test2test3', fread($this->res, 1024));
210 $callback =
function ($arg) {
219 $this->handler->expects($this->exactly(2))
221 ->will($this->returnCallback($callback));
230 $this->assertInternalType(
'resource', $this->res);
231 $this->handler->close();
232 $this->assertFalse(is_resource($this->res),
"Expected resource to be closed after closing handler");
238 $this->handler->setPersistent(
true);
240 $this->assertTrue(is_resource($this->res));
241 $this->handler->close();
242 $this->assertTrue(is_resource($this->res));
252 $this->handler->expects($this->any())
254 ->will($this->returnValue(0));
256 $this->handler->expects($this->any())
257 ->method(
'streamGetMetadata')
258 ->will($this->returnValue(
array(
'timed_out' =>
false)));
260 $this->handler->setWritingTimeout(1);
278 $this->res = fopen(
'php://memory',
'a');
280 $defaultMethods =
array(
'fsockopen',
'pfsockopen',
'streamSetTimeout');
281 $newMethods = array_diff($methods, $defaultMethods);
283 $finalMethods = array_merge($defaultMethods, $newMethods);
285 $this->handler = $this->getMock(
286 '\Monolog\Handler\SocketHandler', $finalMethods,
array(
'localhost:1234')
289 if (!in_array(
'fsockopen', $methods)) {
290 $this->handler->expects($this->any())
291 ->method(
'fsockopen')
292 ->will($this->returnValue($this->res));
295 if (!in_array(
'pfsockopen', $methods)) {
296 $this->handler->expects($this->any())
297 ->method(
'pfsockopen')
298 ->will($this->returnValue($this->res));
301 if (!in_array(
'streamSetTimeout', $methods)) {
302 $this->handler->expects($this->any())
303 ->method(
'streamSetTimeout')
304 ->will($this->returnValue(
true));
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())
testInvalidHostname()
UnexpectedValueException
testExceptionIsThrownOnPfsockopenError()
UnexpectedValueException
testSetConnectionTimeout()
const WARNING
Exceptional occurrences that are not errors.
Create styles array
The data for the language used.
testWriteFailsOnIncompleteWrite()
RuntimeException
testCloseDoesNotClosePersistentSocket()
testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
createHandler($connectionString)
testWriteFailsOnIfFwriteReturnsFalse()
RuntimeException
testExceptionIsThrownOnFsockopenError()
UnexpectedValueException