1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-07-31 10:20:14 +02:00

Upgrade PHPUnit to v8

This commit is contained in:
Mario Blažek
2019-08-12 15:20:00 +02:00
parent 2e3c369667
commit 37900f9268
46 changed files with 154 additions and 166 deletions

View File

@@ -30,20 +30,18 @@ class SocketHandlerTest extends TestCase
*/
private $res;
/**
* @expectedException UnexpectedValueException
*/
public function testInvalidHostname()
{
$this->expectException(\UnexpectedValueException::class);
$this->createHandler('garbage://here');
$this->writeRecord('data');
}
/**
* @expectedException \InvalidArgumentException
*/
public function testBadConnectionTimeout()
{
$this->expectException(\InvalidArgumentException::class);
$this->createHandler('localhost:1234');
$this->handler->setConnectionTimeout(-1);
}
@@ -55,11 +53,10 @@ class SocketHandlerTest extends TestCase
$this->assertEquals(10.1, $this->handler->getConnectionTimeout());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testBadTimeout()
{
$this->expectException(\InvalidArgumentException::class);
$this->createHandler('localhost:1234');
$this->handler->setTimeout(-1);
}
@@ -91,11 +88,10 @@ class SocketHandlerTest extends TestCase
$this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString());
}
/**
* @expectedException UnexpectedValueException
*/
public function testExceptionIsThrownOnFsockopenError()
{
$this->expectException(\UnexpectedValueException::class);
$this->setMockHandler(['fsockopen']);
$this->handler->expects($this->once())
->method('fsockopen')
@@ -103,11 +99,10 @@ class SocketHandlerTest extends TestCase
$this->writeRecord('Hello world');
}
/**
* @expectedException UnexpectedValueException
*/
public function testExceptionIsThrownOnPfsockopenError()
{
$this->expectException(\UnexpectedValueException::class);
$this->setMockHandler(['pfsockopen']);
$this->handler->expects($this->once())
->method('pfsockopen')
@@ -116,11 +111,10 @@ class SocketHandlerTest extends TestCase
$this->writeRecord('Hello world');
}
/**
* @expectedException UnexpectedValueException
*/
public function testExceptionIsThrownIfCannotSetTimeout()
{
$this->expectException(\UnexpectedValueException::class);
$this->setMockHandler(['streamSetTimeout']);
$this->handler->expects($this->once())
->method('streamSetTimeout')
@@ -128,11 +122,10 @@ class SocketHandlerTest extends TestCase
$this->writeRecord('Hello world');
}
/**
* @expectedException UnexpectedValueException
*/
public function testExceptionIsThrownIfCannotSetChunkSize()
{
$this->expectException(\UnexpectedValueException::class);
$this->setMockHandler(array('streamSetChunkSize'));
$this->handler->setChunkSize(8192);
$this->handler->expects($this->once())
@@ -141,11 +134,10 @@ class SocketHandlerTest extends TestCase
$this->writeRecord('Hello world');
}
/**
* @expectedException RuntimeException
*/
public function testWriteFailsOnIfFwriteReturnsFalse()
{
$this->expectException(\RuntimeException::class);
$this->setMockHandler(['fwrite']);
$callback = function ($arg) {
@@ -164,11 +156,10 @@ class SocketHandlerTest extends TestCase
$this->writeRecord('Hello world');
}
/**
* @expectedException RuntimeException
*/
public function testWriteFailsIfStreamTimesOut()
{
$this->expectException(\RuntimeException::class);
$this->setMockHandler(['fwrite', 'streamGetMetadata']);
$callback = function ($arg) {
@@ -190,11 +181,10 @@ class SocketHandlerTest extends TestCase
$this->writeRecord('Hello world');
}
/**
* @expectedException RuntimeException
*/
public function testWriteFailsOnIncompleteWrite()
{
$this->expectException(\RuntimeException::class);
$this->setMockHandler(['fwrite', 'streamGetMetadata']);
$res = $this->res;
@@ -263,11 +253,10 @@ class SocketHandlerTest extends TestCase
$this->assertTrue(is_resource($this->res));
}
/**
* @expectedException \RuntimeException
*/
public function testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds()
{
$this->expectException(\RuntimeException::class);
$this->setMockHandler(['fwrite', 'streamGetMetadata']);
$this->handler->expects($this->any())