Skip to content

Commit cfd151e

Browse files
authored
Merge pull request #15 from SimonFrings/tests
Run tests on PHPUnit 9
2 parents a6d56ea + 3b5325b commit cfd151e

File tree

5 files changed

+21
-16
lines changed

5 files changed

+21
-16
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: php
33
# lock distro so future defaults will not break the build
44
dist: trusty
55

6-
matrix:
6+
jobs:
77
include:
88
- php: 5.3
99
dist: precise
@@ -17,7 +17,7 @@ matrix:
1717
- php: 7.4
1818

1919
install:
20-
- composer install --no-interaction
20+
- composer install
2121

2222
script:
2323
- vendor/bin/phpunit --coverage-text

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"require-dev": {
1818
"clue/hexdump": "~0.2.0",
1919
"react/event-loop": "^1.0 || ^0.5 || ^0.4 || ^0.3",
20-
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
20+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
2121
},
2222
"autoload": {
2323
"psr-4": { "Clue\\React\\Tar\\": "src/" }

tests/DecoderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class DecoderTest extends TestCase
1010
{
1111
private $decoder;
1212

13-
public function setUp()
13+
/**
14+
* @before
15+
*/
16+
public function setUpDecoder()
1417
{
1518
$this->decoder = new Decoder();
1619
}

tests/FunctionalDecoderTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ class FunctionDecoderTest extends TestCase
1010
{
1111
private $decoder;
1212

13-
public function setUp()
13+
/**
14+
* @before
15+
*/
16+
public function setUpDecoderAndLoop()
1417
{
1518
$this->decoder = new Decoder();
1619
$this->loop = Factory::create();

tests/TestCase.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,35 @@ class TestCase extends \PHPUnit\Framework\TestCase
77
protected function expectCallableOnce()
88
{
99
$mock = $this->createCallableMock();
10-
$mock
11-
->expects($this->once())
12-
->method('__invoke');
10+
$mock->expects($this->once())->method('__invoke');
1311

1412
return $mock;
1513
}
1614

1715
protected function expectCallableOnceWith($value)
1816
{
1917
$mock = $this->createCallableMock();
20-
$mock
21-
->expects($this->once())
22-
->method('__invoke')
23-
->with($value);
18+
$mock->expects($this->once())->method('__invoke')->with($value);
2419

2520
return $mock;
2621
}
2722

2823
protected function expectCallableNever()
2924
{
3025
$mock = $this->createCallableMock();
31-
$mock
32-
->expects($this->never())
33-
->method('__invoke');
26+
$mock->expects($this->never())->method('__invoke');
3427

3528
return $mock;
3629
}
3730

3831
protected function createCallableMock()
3932
{
40-
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
33+
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
34+
// PHPUnit 9+
35+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
36+
} else {
37+
// legacy PHPUnit 4 - PHPUnit 8
38+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
39+
}
4140
}
4241
}

0 commit comments

Comments
 (0)