Skip to content

Commit a9bbdbf

Browse files
authored
Merge pull request clue#101 from SimonFrings/tests
Run tests on PHPUnit 9
2 parents bce1fe5 + 987ca7d commit a9bbdbf

8 files changed

+36
-26
lines changed

.travis.yml

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

6-
matrix:
6+
jobs:
77
include:
88
- php: 5.3
99
dist: precise
@@ -16,21 +16,17 @@ matrix:
1616
- php: 7.3
1717
- php: 7.4
1818
- php: hhvm-3.18
19-
install:
20-
- composer require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit
2119
allow_failures:
2220
- php: hhvm-3.18
2321

2422
services:
2523
- redis-server
2624

27-
sudo: false
28-
2925
env:
3026
- REDIS_URI=localhost
3127

3228
install:
33-
- composer install --no-interaction
29+
- composer install
3430

3531
script:
3632
- vendor/bin/phpunit --coverage-text

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919
"react/promise-timer": "^1.5",
2020
"react/socket": "^1.1"
2121
},
22+
"require-dev": {
23+
"clue/block-react": "^1.1",
24+
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
25+
},
2226
"autoload": {
2327
"psr-4": { "Clue\\React\\Redis\\": "src/" }
2428
},
2529
"autoload-dev": {
2630
"psr-4": { "Clue\\Tests\\React\\Redis\\": "tests/" }
27-
},
28-
"require-dev": {
29-
"clue/block-react": "^1.1",
30-
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
3131
}
3232
}

tests/FactoryLazyClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ class FactoryLazyClientTest extends TestCase
1111
private $connector;
1212
private $factory;
1313

14-
public function setUp()
14+
/**
15+
* @before
16+
*/
17+
public function setUpFactory()
1518
{
1619
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
1720
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();

tests/FactoryStreamingClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ class FactoryStreamingClientTest extends TestCase
1212
private $connector;
1313
private $factory;
1414

15-
public function setUp()
15+
/**
16+
* @before
17+
*/
18+
public function setUpFactory()
1619
{
1720
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
1821
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();

tests/FunctionalTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ class FunctionalTest extends TestCase
1616
private $factory;
1717
private $uri;
1818

19-
public function setUp()
19+
/**
20+
* @before
21+
*/
22+
public function setUpFactory()
2023
{
2124
$this->uri = getenv('REDIS_URI');
2225
if ($this->uri === false) {

tests/LazyClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ class LazyClientTest extends TestCase
2121
private $loop;
2222
private $client;
2323

24-
public function setUp()
24+
/**
25+
* @before
26+
*/
27+
public function setUpClient()
2528
{
2629
$this->factory = $this->getMockBuilder('Clue\React\Redis\Factory')->disableOriginalConstructor()->getMock();
2730
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();

tests/StreamingClientTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ class StreamingClientTest extends TestCase
1818
private $serializer;
1919
private $client;
2020

21-
public function setUp()
21+
/**
22+
* @before
23+
*/
24+
public function setUpClient()
2225
{
2326
$this->stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock();
2427
$this->parser = $this->getMockBuilder('Clue\Redis\Protocol\Parser\ParserInterface')->getMock();

tests/TestCase.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,36 @@ class TestCase extends BaseTestCase
99
protected function expectCallableOnce()
1010
{
1111
$mock = $this->createCallableMock();
12-
$mock
13-
->expects($this->once())
14-
->method('__invoke');
12+
$mock->expects($this->once())->method('__invoke');
1513

1614
return $mock;
1715
}
1816

1917
protected function expectCallableOnceWith($argument)
2018
{
2119
$mock = $this->createCallableMock();
22-
$mock
23-
->expects($this->once())
24-
->method('__invoke')
25-
->with($argument);
20+
$mock->expects($this->once())->method('__invoke')->with($argument);
2621

2722
return $mock;
2823
}
2924

3025
protected function expectCallableNever()
3126
{
3227
$mock = $this->createCallableMock();
33-
$mock
34-
->expects($this->never())
35-
->method('__invoke');
28+
$mock->expects($this->never())->method('__invoke');
3629

3730
return $mock;
3831
}
3932

4033
protected function createCallableMock()
4134
{
42-
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
35+
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
36+
// PHPUnit 9+
37+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
38+
} else {
39+
// legacy PHPUnit 4 - PHPUnit 8
40+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
41+
}
4342
}
4443

4544
protected function expectPromiseResolve($promise)

0 commit comments

Comments
 (0)