Skip to content

Commit 465eb67

Browse files
committed
Run tests on PHPUnit 9 and simplify test matrix
1 parent 6122134 commit 465eb67

4 files changed

Lines changed: 36 additions & 26 deletions

File tree

.travis.yml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
11
language: php
22

3-
php:
4-
# - 5.3 # requires old distro
5-
# - 5.4 # requires old distro
6-
# - 5.5 # requires old distro
7-
- 5.6
8-
- 7.0
9-
- 7.1
10-
- 7.2
11-
- 7.3
12-
- 7.4
13-
143
# lock distro so new future defaults will not break the build
154
dist: xenial
165

17-
matrix:
6+
jobs:
187
include:
198
- php: 5.3
209
dist: precise
2110
- php: 5.4
2211
dist: trusty
2312
- php: 5.5
2413
dist: trusty
25-
26-
sudo: false
14+
- php: 5.6
15+
- php: 7.0
16+
- php: 7.1
17+
- php: 7.2
18+
- php: 7.3
19+
- php: 7.4
2720

2821
install:
29-
- composer install --no-interaction
22+
- composer install
3023

3124
script:
3225
- vendor/bin/phpunit --coverage-text

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"require-dev": {
2424
"clue/block-react": "^1.0",
2525
"clue/buzz-react": "^2.4",
26-
"phpunit/phpunit": "^7.0 || ^6.4 || ^5.7 || ^4.8.35",
26+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35",
2727
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3"
2828
}
2929
}

tests/QueueTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,27 +24,21 @@ public function testCtorWithNoHardLimit()
2424
$q = new Queue(1, null, function () { });
2525
}
2626

27-
/**
28-
* @expectedException InvalidArgumentException
29-
*/
3027
public function testCtorThrowsIfNotCallable()
3128
{
29+
$this->setExpectedException('InvalidArgumentException');
3230
new Queue(1, 2, null);
3331
}
3432

35-
/**
36-
* @expectedException InvalidArgumentException
37-
*/
3833
public function testCtorThrowsIfConcurrencyTooLow()
3934
{
35+
$this->setExpectedException('InvalidArgumentException');
4036
new Queue(0, 2, function () { });
4137
}
4238

43-
/**
44-
* @expectedException InvalidArgumentException
45-
*/
4639
public function testCtorThrowsIfConcurrencyAboveLiit()
4740
{
41+
$this->setExpectedException('InvalidArgumentException');
4842
new Queue(3, 2, function () { });
4943
}
5044

tests/TestCase.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,29 @@ protected function expectCallableNever()
4141

4242
protected function createCallableMock()
4343
{
44-
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
44+
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
45+
// PHPUnit 8.5+
46+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
47+
} else {
48+
// legacy PHPUnit 4 - PHPUnit 8.4
49+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
50+
}
51+
}
52+
53+
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null)
54+
{
55+
if (method_exists($this, 'expectException')) {
56+
// PHPUnit 5.2+
57+
$this->expectException($exception);
58+
if ($exceptionMessage !== '') {
59+
$this->expectExceptionMessage($exceptionMessage);
60+
}
61+
if ($exceptionCode !== null) {
62+
$this->expectExceptionCode($exceptionCode);
63+
}
64+
} else {
65+
// legacy PHPUnit 4 - PHPUnit 5.1
66+
parent::setExpectedException($exception, $exceptionMessage, $exceptionCode);
67+
}
4568
}
4669
}

0 commit comments

Comments
 (0)