Skip to content

Commit b6e2fc4

Browse files
committed
Run tests on PHPUnit 9
1 parent 156a3c3 commit b6e2fc4

File tree

5 files changed

+30
-19
lines changed

5 files changed

+30
-19
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
},
1515
"require-dev": {
1616
"clue/block-react": "^1.2",
17-
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
17+
"phpunit/phpunit": "^9.3 || ^6.0 || ^5.0 || ^4.8.35"
1818
},
1919
"autoload": {
2020
"psr-4": {

tests/BaseTestCase.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,21 @@ protected function expectCallableNever()
7777

7878
return $mock;
7979
}
80+
81+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
82+
{
83+
if (method_exists($this, 'expectException')) {
84+
// PHPUnit 5.2+
85+
$this->expectException($exception);
86+
if ($exceptionMessage !== '') {
87+
$this->expectExceptionMessage($exceptionMessage);
88+
}
89+
if ($exceptionCode !== null) {
90+
$this->expectExceptionCode($exceptionCode);
91+
}
92+
} else {
93+
// legacy PHPUnit 4 - PHPUnit 5.1
94+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
95+
}
96+
}
8097
}

tests/Io/BufferTest.php

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
namespace React\Tests\MySQL\Io;
44

5-
use PHPUnit\Framework\TestCase;
65
use React\MySQL\Io\Buffer;
6+
use React\Tests\MySQL\BaseTestCase;
77

8-
class BufferTest extends TestCase
8+
class BufferTest extends BaseTestCase
99
{
1010
public function testAppendAndReadBinary()
1111
{
@@ -16,15 +16,13 @@ public function testAppendAndReadBinary()
1616
$this->assertSame('hello', $buffer->read(5));
1717
}
1818

19-
/**
20-
* @expectedException LogicException
21-
*/
2219
public function testReadBeyondLimitThrows()
2320
{
2421
$buffer = new Buffer();
2522

2623
$buffer->append('hi');
2724

25+
$this->setExpectedException('LogicException');
2826
$buffer->read(3);
2927
}
3028

@@ -38,27 +36,23 @@ public function testReadAfterSkipOne()
3836
$this->assertSame('i', $buffer->read(1));
3937
}
4038

41-
/**
42-
* @expectedException LogicException
43-
*/
4439
public function testSkipZeroThrows()
4540
{
4641
$buffer = new Buffer();
4742

4843
$buffer->append('hi');
4944

45+
$this->setExpectedException('LogicException');
5046
$buffer->skip(0);
5147
}
5248

53-
/**
54-
* @expectedException LogicException
55-
*/
5649
public function testSkipBeyondLimitThrows()
5750
{
5851
$buffer = new Buffer();
5952

6053
$buffer->append('hi');
6154

55+
$this->setExpectedException('LogicException');
6256
$buffer->skip(3);
6357
}
6458

@@ -203,14 +197,12 @@ public function testParseStringNullCharacterTwice()
203197
$this->assertEquals('world', $buffer->readStringNull());
204198
}
205199

206-
/**
207-
* @expectedException LogicException
208-
*/
209200
public function testParseStringNullCharacterThrowsIfNullNotFound()
210201
{
211202
$buffer = new Buffer();
212203
$buffer->append("hello");
213204

205+
$this->setExpectedException('LogicException');
214206
$buffer->readStringNull();
215207
}
216208
}

tests/Io/LazyConnectionTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -795,9 +795,6 @@ public function testQueryReturnsRejectedPromiseAfterConnectionIsClosed()
795795
$ret->then($this->expectCallableNever(), $this->expectCallableOnce());
796796
}
797797

798-
/**
799-
* @expectedException React\MySQL\Exception
800-
*/
801798
public function testQueryStreamThrowsAfterConnectionIsClosed()
802799
{
803800
$factory = $this->getMockBuilder('React\MySQL\Factory')->disableOriginalConstructor()->getMock();
@@ -806,6 +803,8 @@ public function testQueryStreamThrowsAfterConnectionIsClosed()
806803
$connection = new LazyConnection($factory, '', $loop);
807804

808805
$connection->close();
806+
807+
$this->setExpectedException('React\MySQL\Exception');
809808
$connection->queryStream('SELECT 1');
810809
}
811810

tests/NoResultQueryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77

88
class NoResultQueryTest extends BaseTestCase
99
{
10-
public function setUp()
10+
/**
11+
* @before
12+
*/
13+
public function setUpDataTable()
1114
{
1215
$connection = $this->createConnection(Loop::get());
1316

0 commit comments

Comments
 (0)