Skip to content

Run tests on PHPUnit 9 #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: php
# lock distro so new future defaults will not break the build
dist: trusty

matrix:
jobs:
include:
- php: 5.3
dist: precise
Expand All @@ -16,21 +16,17 @@ matrix:
- php: 7.3
- php: 7.4
- php: hhvm-3.18
install:
- composer require phpunit/phpunit:^5 --dev --no-interaction # requires legacy phpunit
allow_failures:
- php: hhvm-3.18

services:
- redis-server

sudo: false

env:
- REDIS_URI=localhost

install:
- composer install --no-interaction
- composer install

script:
- vendor/bin/phpunit --coverage-text
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
"react/promise-timer": "^1.5",
"react/socket": "^1.1"
},
"require-dev": {
"clue/block-react": "^1.1",
"phpunit/phpunit": "^9.0 || ^5.7 || ^4.8.35"
},
"autoload": {
"psr-4": { "Clue\\React\\Redis\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Clue\\Tests\\React\\Redis\\": "tests/" }
},
"require-dev": {
"clue/block-react": "^1.1",
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
}
}
5 changes: 4 additions & 1 deletion tests/FactoryLazyClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ class FactoryLazyClientTest extends TestCase
private $connector;
private $factory;

public function setUp()
/**
* @before
*/
public function setUpFactory()
{
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
Expand Down
5 changes: 4 additions & 1 deletion tests/FactoryStreamingClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ class FactoryStreamingClientTest extends TestCase
private $connector;
private $factory;

public function setUp()
/**
* @before
*/
public function setUpFactory()
{
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$this->connector = $this->getMockBuilder('React\Socket\ConnectorInterface')->getMock();
Expand Down
5 changes: 4 additions & 1 deletion tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ class FunctionalTest extends TestCase
private $factory;
private $uri;

public function setUp()
/**
* @before
*/
public function setUpFactory()
{
$this->uri = getenv('REDIS_URI');
if ($this->uri === false) {
Expand Down
5 changes: 4 additions & 1 deletion tests/LazyClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ class LazyClientTest extends TestCase
private $loop;
private $client;

public function setUp()
/**
* @before
*/
public function setUpClient()
{
$this->factory = $this->getMockBuilder('Clue\React\Redis\Factory')->disableOriginalConstructor()->getMock();
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
Expand Down
5 changes: 4 additions & 1 deletion tests/StreamingClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ class StreamingClientTest extends TestCase
private $serializer;
private $client;

public function setUp()
/**
* @before
*/
public function setUpClient()
{
$this->stream = $this->getMockBuilder('React\Stream\DuplexStreamInterface')->getMock();
$this->parser = $this->getMockBuilder('Clue\Redis\Protocol\Parser\ParserInterface')->getMock();
Expand Down
21 changes: 10 additions & 11 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,37 +9,36 @@ class TestCase extends BaseTestCase
protected function expectCallableOnce()
{
$mock = $this->createCallableMock();
$mock
->expects($this->once())
->method('__invoke');
$mock->expects($this->once())->method('__invoke');

return $mock;
}

protected function expectCallableOnceWith($argument)
{
$mock = $this->createCallableMock();
$mock
->expects($this->once())
->method('__invoke')
->with($argument);
$mock->expects($this->once())->method('__invoke')->with($argument);

return $mock;
}

protected function expectCallableNever()
{
$mock = $this->createCallableMock();
$mock
->expects($this->never())
->method('__invoke');
$mock->expects($this->never())->method('__invoke');

return $mock;
}

protected function createCallableMock()
{
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) {
// PHPUnit 9+
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock();
} else {
// legacy PHPUnit 4 - PHPUnit 8
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
}
}

protected function expectPromiseResolve($promise)
Expand Down