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->assertEquals(
'tcp://localhost:9090', $this->handler->getConnectionString());
85 $this->handler->expects($this->once())
87 ->will($this->returnValue(
false));
97 $this->handler->expects($this->once())
98 ->method(
'pfsockopen')
99 ->will($this->returnValue(
false));
100 $this->handler->setPersistent(
true);
110 $this->handler->expects($this->once())
111 ->method(
'streamSetTimeout')
112 ->will($this->returnValue(
false));
123 $callback =
function ($arg) {
132 $this->handler->expects($this->exactly(2))
134 ->will($this->returnCallback($callback));
146 $callback =
function ($arg) {
155 $this->handler->expects($this->exactly(1))
157 ->will($this->returnCallback($callback));
158 $this->handler->expects($this->exactly(1))
159 ->method(
'streamGetMetadata')
160 ->will($this->returnValue(array(
'timed_out' =>
true)));
173 $callback =
function ($string) use (
$res) {
176 return strlen(
'Hello');
179 $this->handler->expects($this->exactly(1))
181 ->will($this->returnCallback($callback));
182 $this->handler->expects($this->exactly(1))
183 ->method(
'streamGetMetadata')
184 ->will($this->returnValue(array(
'timed_out' =>
false)));
195 fseek($this->res, 0);
196 $this->assertEquals(
'test1test2test3', fread($this->res, 1024));
203 $callback =
function ($arg) {
212 $this->handler->expects($this->exactly(2))
214 ->will($this->returnCallback($callback));
223 $this->assertInternalType(
'resource', $this->res);
224 $this->handler->close();
225 $this->assertFalse(is_resource($this->res),
"Expected resource to be closed after closing handler");
231 $this->handler->setPersistent(
true);
233 $this->assertTrue(is_resource($this->res));
234 $this->handler->close();
235 $this->assertTrue(is_resource($this->res));
251 $this->res = fopen(
'php://memory',
'a');
253 $defaultMethods = array(
'fsockopen',
'pfsockopen',
'streamSetTimeout');
254 $newMethods = array_diff($methods, $defaultMethods);
256 $finalMethods = array_merge($defaultMethods, $newMethods);
258 $this->handler = $this->getMock(
259 '\Monolog\Handler\SocketHandler', $finalMethods, array(
'localhost:1234')
262 if (!in_array(
'fsockopen', $methods)) {
263 $this->handler->expects($this->any())
264 ->method(
'fsockopen')
265 ->will($this->returnValue($this->res));
268 if (!in_array(
'pfsockopen', $methods)) {
269 $this->handler->expects($this->any())
270 ->method(
'pfsockopen')
271 ->will($this->returnValue($this->res));
274 if (!in_array(
'streamSetTimeout', $methods)) {
275 $this->handler->expects($this->any())
276 ->method(
'streamSetTimeout')
277 ->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.
testWriteFailsOnIncompleteWrite()
RuntimeException
testCloseDoesNotClosePersistentSocket()
createHandler($connectionString)
testWriteFailsOnIfFwriteReturnsFalse()
RuntimeException
testExceptionIsThrownOnFsockopenError()
UnexpectedValueException