|
5 | 5 | use Amp\PHPUnit\AsyncTestCase; |
6 | 6 | use PHPUnit\Framework\AssertionFailedError; |
7 | 7 |
|
8 | | -class InvalidAsyncTestCaseTest extends AsyncTestCase |
9 | | -{ |
10 | | - protected function setUp() |
| 8 | +if ((new \ReflectionMethod(AsyncTestCase::class, 'setUp'))->hasReturnType()) { |
| 9 | + // PHPUnit 8+ |
| 10 | + class InvalidAsyncTestCaseTest extends AsyncTestCase |
11 | 11 | { |
12 | | - // No call to parent::setUp() |
| 12 | + protected function setUp(): void |
| 13 | + { |
| 14 | + // No call to parent::setUp() |
13 | 15 |
|
14 | | - $this->expectException(AssertionFailedError::class); |
15 | | - $this->expectExceptionMessage('without calling the parent method'); |
16 | | - } |
| 16 | + $this->expectException(AssertionFailedError::class); |
| 17 | + $this->expectExceptionMessage('without calling the parent method'); |
| 18 | + } |
17 | 19 |
|
18 | | - /** |
19 | | - * @expectedException \Error |
20 | | - * @expectedExceptionMessage without calling the parent method |
21 | | - */ |
22 | | - public function testMethod() |
| 20 | + public function testMethod() |
| 21 | + { |
| 22 | + // Test will fail because setUp() did not call the parent method |
| 23 | + } |
| 24 | + } |
| 25 | +} else { |
| 26 | + // PHPUnit 6 or 7 |
| 27 | + class InvalidAsyncTestCaseTest extends AsyncTestCase |
23 | 28 | { |
24 | | - // Test will fail because setUp() did not call the parent method |
| 29 | + protected function setUp() |
| 30 | + { |
| 31 | + // No call to parent::setUp() |
| 32 | + |
| 33 | + $this->expectException(AssertionFailedError::class); |
| 34 | + $this->expectExceptionMessage('without calling the parent method'); |
| 35 | + } |
| 36 | + |
| 37 | + public function testMethod() |
| 38 | + { |
| 39 | + // Test will fail because setUp() did not call the parent method |
| 40 | + } |
25 | 41 | } |
26 | 42 | } |
0 commit comments