mirror of
https://github.com/Seldaek/monolog.git
synced 2025-08-20 11:51:32 +02:00
Add property types to all properties where possible
This commit is contained in:
@@ -20,10 +20,7 @@ use PHPUnit\Framework\MockObject\MockObject;
|
||||
*/
|
||||
class SocketHandlerTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Monolog\Handler\SocketHandler|MockObject
|
||||
*/
|
||||
private $handler;
|
||||
private SocketHandler&MockObject $handler;
|
||||
|
||||
/**
|
||||
* @var resource
|
||||
@@ -34,58 +31,58 @@ class SocketHandlerTest extends TestCase
|
||||
{
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
|
||||
$this->createHandler('garbage://here');
|
||||
$this->writeRecord('data');
|
||||
$handler = $this->createHandler('garbage://here');
|
||||
$handler->handle($this->getRecord(Level::Warning, 'data'));
|
||||
}
|
||||
|
||||
public function testBadConnectionTimeout()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->createHandler('localhost:1234');
|
||||
$this->handler->setConnectionTimeout(-1);
|
||||
$handler = $this->createHandler('localhost:1234');
|
||||
$handler->setConnectionTimeout(-1);
|
||||
}
|
||||
|
||||
public function testSetConnectionTimeout()
|
||||
{
|
||||
$this->createHandler('localhost:1234');
|
||||
$this->handler->setConnectionTimeout(10.1);
|
||||
$this->assertEquals(10.1, $this->handler->getConnectionTimeout());
|
||||
$handler = $this->createHandler('localhost:1234');
|
||||
$handler->setConnectionTimeout(10.1);
|
||||
$this->assertEquals(10.1, $handler->getConnectionTimeout());
|
||||
}
|
||||
|
||||
public function testBadTimeout()
|
||||
{
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->createHandler('localhost:1234');
|
||||
$this->handler->setTimeout(-1);
|
||||
$handler = $this->createHandler('localhost:1234');
|
||||
$handler->setTimeout(-1);
|
||||
}
|
||||
|
||||
public function testSetTimeout()
|
||||
{
|
||||
$this->createHandler('localhost:1234');
|
||||
$this->handler->setTimeout(10.25);
|
||||
$this->assertEquals(10.25, $this->handler->getTimeout());
|
||||
$handler = $this->createHandler('localhost:1234');
|
||||
$handler->setTimeout(10.25);
|
||||
$this->assertEquals(10.25, $handler->getTimeout());
|
||||
}
|
||||
|
||||
public function testSetWritingTimeout()
|
||||
{
|
||||
$this->createHandler('localhost:1234');
|
||||
$this->handler->setWritingTimeout(10.25);
|
||||
$this->assertEquals(10.25, $this->handler->getWritingTimeout());
|
||||
$handler = $this->createHandler('localhost:1234');
|
||||
$handler->setWritingTimeout(10.25);
|
||||
$this->assertEquals(10.25, $handler->getWritingTimeout());
|
||||
}
|
||||
|
||||
public function testSetChunkSize()
|
||||
{
|
||||
$this->createHandler('localhost:1234');
|
||||
$this->handler->setChunkSize(1025);
|
||||
$this->assertEquals(1025, $this->handler->getChunkSize());
|
||||
$handler = $this->createHandler('localhost:1234');
|
||||
$handler->setChunkSize(1025);
|
||||
$this->assertEquals(1025, $handler->getChunkSize());
|
||||
}
|
||||
|
||||
public function testSetConnectionString()
|
||||
{
|
||||
$this->createHandler('tcp://localhost:9090');
|
||||
$this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
|
||||
$handler = $this->createHandler('tcp://localhost:9090');
|
||||
$this->assertEquals('tcp://localhost:9090', $handler->getConnectionString());
|
||||
}
|
||||
|
||||
public function testExceptionIsThrownOnFsockopenError()
|
||||
@@ -277,10 +274,12 @@ class SocketHandlerTest extends TestCase
|
||||
$this->writeRecord('Hello world');
|
||||
}
|
||||
|
||||
private function createHandler($connectionString)
|
||||
private function createHandler(string $connectionString): SocketHandler
|
||||
{
|
||||
$this->handler = new SocketHandler($connectionString);
|
||||
$this->handler->setFormatter($this->getIdentityFormatter());
|
||||
$handler = new SocketHandler($connectionString);
|
||||
$handler->setFormatter($this->getIdentityFormatter());
|
||||
|
||||
return $handler;
|
||||
}
|
||||
|
||||
private function writeRecord($string)
|
||||
|
Reference in New Issue
Block a user