Skip to content

Commit 41e8a04

Browse files
committed
Make sure test pass on phpunit 5.7
1 parent a90e79d commit 41e8a04

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Tests/Unit/Collector/StackPluginTest.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Http\HttplugBundle\Collector\StackPlugin;
1212
use Http\Promise\FulfilledPromise;
1313
use Http\Promise\RejectedPromise;
14-
use PHPUnit\Framework\Error\Warning;
1514
use PHPUnit\Framework\TestCase;
1615
use Psr\Http\Message\RequestInterface;
1716
use Psr\Http\Message\ResponseInterface;
@@ -188,8 +187,17 @@ public function testOnError()
188187
$this->markTestSkipped();
189188
}
190189

191-
//PHPUnit wrap any \Error into a \PHPUnit\Framework\Error\Warning.
192-
$this->expectException(Warning::class);
190+
/*
191+
* Use the correct PHPUnit version
192+
* PHPUnit wrap any \Error into a \PHPUnit_Framework_Error. So we are expecting the
193+
*/
194+
if (class_exists('PHPUnit_Framework_Error')) {
195+
// PHPUnit 5.7
196+
$this->setExpectedException(\PHPUnit_Framework_Error::class);
197+
} else {
198+
// PHPUnit 6.0 and above
199+
$this->expectException(\PHPUnit\Framework\Error\Warning::class);
200+
}
193201

194202
$this->collector
195203
->expects($this->once())

0 commit comments

Comments
 (0)