Skip to content
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
26 changes: 22 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
language: php

php:
- 5.3
# - 5.3 # requires old distro, see below
- 5.4
- 5.5
- 5.6
- hhvm
- 7.0
- 7.1
- 7.2
- 7.3

# lock distro so future defaults will not break the build
dist: trusty

matrix:
include:
- php: 5.3
dist: precise

sudo: false

install:
- composer install --prefer-source --no-interaction
- composer install --no-interaction

script:
- phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
36 changes: 28 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,34 @@ See also the [examples](examples):

## Install

The recommended way to install this library is [through composer](http://getcomposer.org). [New to composer?](http://getcomposer.org/doc/00-intro.md)

```JSON
{
"require": {
"clue/shell-react": "~0.2.0"
}
}
The recommended way to install this library is [through Composer](https://getcomposer.org).
[New to Composer?](https://getcomposer.org/doc/00-intro.md)

This will install the latest supported version:

```bash
$ composer require clue/shell-react:^0.2
```

See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP
extensions and supports running on legacy PHP 5.3 through current PHP 7+.
It's *highly recommended to use PHP 7+* for this project.

## Tests

To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org):

```bash
$ composer install
```

To run the test suite, go to the project root and run:

```bash
$ php vendor/bin/phpunit
```

## License
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@
"react/child-process": "~0.3.0|~0.4.0",
"react/stream": "~0.3.0|~0.4.0",
"react/event-loop": "~0.3.0|~0.4.0"
},
"require-dev": {
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
}
}
9 changes: 7 additions & 2 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public function setUp()
$this->launcher = new ProcessLauncher($this->loop);
}

/**
* @doesNotPerformAssertions
*/
public function testEndEmptyClosesImmediately()
{
$shell = $this->launcher->createDeferredShell('cat');
Expand All @@ -23,6 +26,9 @@ public function testEndEmptyClosesImmediately()
$this->loop->run();
}

/**
* @doesNotPerformAssertions
*/
public function testCloseEmpty()
{
$shell = $this->launcher->createDeferredShell('cat');
Expand Down Expand Up @@ -106,8 +112,7 @@ public function testExitingShellWillRejectAllExecutes()

public function testPhpShell()
{
// TODO: skipped for lack of compatibility with HHVM
return;
$this->markTestSkipped();

$shell = $this->launcher->createDeferredShell('php -a');
$shell->setBounding('echo "{{ bounding }}";');
Expand Down
10 changes: 5 additions & 5 deletions tests/ProcessLauncherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ class ProcessLauncherTest extends TestCase

public function setUp()
{
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
$this->processLauncher = new ProcessLauncher($this->loop);
}

public function testProcessWillBeStarted()
{
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$process->stdout = $this->getMock('React\Stream\ReadableStreamInterface');
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
$process->stdout = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
$process->stdin = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

$process->expects($this->once())->method('start');

Expand All @@ -31,7 +31,7 @@ public function testClosingStreamTerminatesRunningProcess()
{
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$process->stdout = new ReadableStream();
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
$process->stdin = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

$process->expects($this->once())->method('isRunning')->will($this->returnValue(true));
$process->expects($this->once())->method('terminate')->with($this->equalTo(SIGKILL));
Expand All @@ -45,7 +45,7 @@ public function testClosingStreamOfNonRunningProcessWillNotTerminate()
{
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
$process->stdout = new ReadableStream();
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
$process->stdin = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();

$process->expects($this->once())->method('isRunning')->will($this->returnValue(false));
$process->expects($this->never())->method('terminate');
Expand Down
18 changes: 4 additions & 14 deletions tests/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

error_reporting(-1);

class TestCase extends PHPUnit_Framework_TestCase
class TestCase extends PHPUnit\Framework\TestCase
{
protected function expectCallableOnce()
{
Expand All @@ -27,7 +27,7 @@ protected function expectCallableOnceWith($value)
$mock
->expects($this->once())
->method('__invoke')
->with($this->equalTo($value));
->with($value);

return $mock;
}
Expand All @@ -44,6 +44,7 @@ protected function expectCallableNever()

protected function expectCallableOnceParameter($type)
{
throw new \BadMethodCallException();
$mock = $this->createCallableMock();
$mock
->expects($this->once())
Expand All @@ -53,12 +54,9 @@ protected function expectCallableOnceParameter($type)
return $mock;
}

/**
* @link https://github.com/reactphp/react/blob/master/tests/React/Tests/Socket/TestCase.php (taken from reactphp/react)
*/
protected function createCallableMock()
{
return $this->getMock('CallableStub');
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
}

protected function expectPromiseResolve($promise)
Expand Down Expand Up @@ -106,11 +104,3 @@ protected function waitFor(PromiseInterface $promise, LoopInterface $loop)
return $resolved;
}
}

class CallableStub
{
public function __invoke()
{
}
}