1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-04 04:07:39 +02:00

Remove old SocketTest. Fix CS issues

This commit is contained in:
Pablo Belloc
2012-02-26 14:17:19 -03:00
parent cc9c02250c
commit 722cabc535
5 changed files with 92 additions and 93 deletions

View File

@@ -15,7 +15,6 @@ use Monolog\Logger;
use Monolog\Handler\SocketHandler\Exception\ConnectionException; use Monolog\Handler\SocketHandler\Exception\ConnectionException;
use Monolog\Handler\SocketHandler\Exception\WriteToSocketException; use Monolog\Handler\SocketHandler\Exception\WriteToSocketException;
/** /**
* Stores to any socket - uses fsockopen() or pfsockopen(). * Stores to any socket - uses fsockopen() or pfsockopen().
* *
@@ -24,6 +23,7 @@ use Monolog\Handler\SocketHandler\Exception\WriteToSocketException;
*/ */
class SocketHandler extends AbstractProcessingHandler class SocketHandler extends AbstractProcessingHandler
{ {
private $connectionString; private $connectionString;
private $connectionTimeout; private $connectionTimeout;
private $resource; private $resource;
@@ -39,7 +39,7 @@ class SocketHandler extends AbstractProcessingHandler
{ {
parent::__construct($level, $bubble); parent::__construct($level, $bubble);
$this->connectionString = $connectionString; $this->connectionString = $connectionString;
$this->connectionTimeout = (float)ini_get('default_socket_timeout'); $this->connectionTimeout = (float) ini_get('default_socket_timeout');
} }
/** /**
@@ -76,7 +76,7 @@ class SocketHandler extends AbstractProcessingHandler
public function setPersistent($boolean) public function setPersistent($boolean)
{ {
$this->persistent = (boolean)$boolean; $this->persistent = (boolean) $boolean;
} }
/** /**
@@ -88,7 +88,7 @@ class SocketHandler extends AbstractProcessingHandler
public function setConnectionTimeout($seconds) public function setConnectionTimeout($seconds)
{ {
$this->validateTimeout($seconds); $this->validateTimeout($seconds);
$this->connectionTimeout = (float)$seconds; $this->connectionTimeout = (float) $seconds;
} }
/** /**
@@ -100,7 +100,7 @@ class SocketHandler extends AbstractProcessingHandler
public function setTimeout($seconds) public function setTimeout($seconds)
{ {
$this->validateTimeout($seconds); $this->validateTimeout($seconds);
$this->timeout = (int)$seconds; $this->timeout = (int) $seconds;
} }
private function validateTimeout($value) private function validateTimeout($value)
@@ -123,11 +123,13 @@ class SocketHandler extends AbstractProcessingHandler
return $this->persistent; return $this->persistent;
} }
public function getConnectionTimeout() { public function getConnectionTimeout()
{
return $this->connectionTimeout; return $this->connectionTimeout;
} }
public function getTimeout() { public function getTimeout()
{
return $this->timeout; return $this->timeout;
} }
@@ -228,4 +230,5 @@ class SocketHandler extends AbstractProcessingHandler
{ {
return stream_get_meta_data($this->resource); return stream_get_meta_data($this->resource);
} }
} }

View File

@@ -13,4 +13,5 @@ namespace Monolog\Handler\SocketHandler\Exception;
class ConnectionException extends \RuntimeException class ConnectionException extends \RuntimeException
{ {
} }

View File

@@ -13,4 +13,5 @@ namespace Monolog\Handler\SocketHandler\Exception;
class WriteToSocketException extends \RuntimeException class WriteToSocketException extends \RuntimeException
{ {
} }

View File

@@ -1,8 +0,0 @@
<?php
namespace Monolog\Handler\SocketHandler;
class SocketTest extends \PHPUnit_Framework_TestCase
{
}

View File

@@ -21,6 +21,7 @@ use Monolog\Handler\SocketHandler\Exception\WriteToSocketException;
*/ */
class SocketHandlerTest extends TestCase class SocketHandlerTest extends TestCase
{ {
/** /**
* @var Monolog\Handler\SocketHandler * @var Monolog\Handler\SocketHandler
*/ */
@@ -34,7 +35,8 @@ class SocketHandlerTest extends TestCase
/** /**
* @expectedException Monolog\Handler\SocketHandler\Exception\ConnectionException * @expectedException Monolog\Handler\SocketHandler\Exception\ConnectionException
*/ */
public function testInvalidHostname() { public function testInvalidHostname()
{
$this->createHandler('garbage://here'); $this->createHandler('garbage://here');
$this->writeRecord('data'); $this->writeRecord('data');
} }
@@ -85,6 +87,7 @@ class SocketHandlerTest extends TestCase
$this->writeRecord($string); $this->writeRecord($string);
$this->fail("Shoul not connect - are you running a server on 127.0.0.1:7894 ?"); $this->fail("Shoul not connect - are you running a server on 127.0.0.1:7894 ?");
} catch (\Monolog\Handler\SocketHandler\Exception\ConnectionException $e) { } catch (\Monolog\Handler\SocketHandler\Exception\ConnectionException $e) {
} }
} }
@@ -251,10 +254,9 @@ class SocketHandlerTest extends TestCase
private function setMockHandler(array $methods) private function setMockHandler(array $methods)
{ {
$this->handler = $this->getMock( $this->handler = $this->getMock(
'\Monolog\Handler\SocketHandler', '\Monolog\Handler\SocketHandler', $methods, array('localhost:1234')
$methods,
array('localhost:1234')
); );
$this->handler->setFormatter($this->getIdentityFormatter()); $this->handler->setFormatter($this->getIdentityFormatter());
} }
} }