Skip to content

Commit d6978a2

Browse files
committed
Run tests on PHPUnit 9
1 parent e356b73 commit d6978a2

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

tests/EventSourceTest.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,24 @@
1313

1414
class EventSourceTest extends TestCase
1515
{
16-
/**
17-
* @expectedException InvalidArgumentException
18-
*/
1916
public function testConstructorThrowsIfFirstArgumentIsNotAnUri()
2017
{
2118
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
19+
$this->setExpectedException('InvalidArgumentException');
2220
new EventSource('///', $loop);
2321
}
2422

25-
/**
26-
* @expectedException InvalidArgumentException
27-
*/
2823
public function testConstructorThrowsIfUriArgumentDoesNotIncludeScheme()
2924
{
3025
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
26+
$this->setExpectedException('InvalidArgumentException');
3127
new EventSource('example.com', $loop);
3228
}
3329

34-
/**
35-
* @expectedException InvalidArgumentException
36-
*/
3730
public function testConstructorThrowsIfUriArgumentIncludesInvalidScheme()
3831
{
3932
$loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
33+
$this->setExpectedException('InvalidArgumentException');
4034
new EventSource('ftp://example.com', $loop);
4135
}
4236

@@ -620,4 +614,21 @@ public function testReconnectAfterStreamClosesUsesLastEventIdFromParsedEventStre
620614
$this->assertNotNull($timerReconnect);
621615
$timerReconnect();
622616
}
617+
618+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
619+
{
620+
if (method_exists($this, 'expectException')) {
621+
// PHPUnit 5.2+
622+
$this->expectException($exception);
623+
if ($exceptionMessage !== '') {
624+
$this->expectExceptionMessage($exceptionMessage);
625+
}
626+
if ($exceptionCode !== null) {
627+
$this->expectExceptionCode($exceptionCode);
628+
}
629+
} else {
630+
// legacy PHPUnit 4 - PHPUnit 5.1
631+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
632+
}
633+
}
623634
}

0 commit comments

Comments
 (0)