10000 Add tests instructions and add PHPUnit to require-dev · SimonFrings/reactphp-shell@380d175 · GitHub
[go: up one dir, main page]

Skip to content

Commit 380d175

Browse files
committed
Add tests instructions and add PHPUnit to require-dev
1 parent 02cd3c9 commit 380d175

File tree

6 files changed

+38
-23
lines changed

6 files changed

+38
-23
lines changed

.travis.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ php:
33
- 5.3
44
- 5.6
55
- hhvm
6+
67
install:
7-
- composer install --prefer-source --no-interaction
8+
- composer install --no-interaction
9+
810
script:
9-
- phpunit --coverage-text
11+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ The recommended way to install this library is [through composer](http://getcomp
4646
}
4747
```
4848

49+
## Tests
50+
51+
To run the test suite, you first need to clone this repo and then install all
52+
dependencies [through Composer](https://getcomposer.org):
53+
54+
```bash
55+
$ composer install
56+
```
57+
58+
To run the test suite, go to the project root and run:
59+
60+
```bash
61+
$ php vendor/bin/phpunit
62+
```
63+
4964
## License
5065

5166
MIT

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,8 @@
1919
"react/child-process": "~0.3.0|~0.4.0",
2020
"react/stream": "~0.3.0|~0.4.0",
2121
"react/event-loop": "~0.3.0|~0.4.0"
22+
},
23+
"require-dev": {
24+
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8.35"
2225
}
2326
}

tests/FunctionalTest.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ public function setUp()
1414
$this->launcher = new ProcessLauncher($this->loop);
1515
}
1616

17+
/**
18+
* @doesNotPerformAssertions
19+
*/
1720
public function testEndEmptyClosesImmediately()
1821
{
1922
$shell = $this->launcher->createDeferredShell('cat');
@@ -23,6 +26,9 @@ public function testEndEmptyClosesImmediately()
2326
$this->loop->run();
2427
}
2528

29+
/**
30+
* @doesNotPerformAssertions
31+
*/
2632
public function testCloseEmpty()
2733
{
2834
$shell = $this->launcher->createDeferredShell('cat');
@@ -106,8 +112,7 @@ public function testExitingShellWillRejectAllExecutes()
106112

107113
public function testPhpShell()
108114
{
109-
// TODO: skipped for lack of compatibility with HHVM
110-
return;
115+
$this->markTestSkipped();
111116

112117
$shell = $this->launcher->createDeferredShell('php -a');
113118
$shell->setBounding('echo "{{ bounding }}";');

tests/ProcessLauncherTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ class ProcessLauncherTest extends TestCase
1010

1111
public function setUp()
1212
{
13-
$this->loop = $this->getMock('React\EventLoop\LoopInterface');
13+
$this->loop = $this->getMockBuilder('React\EventLoop\LoopInterface')->getMock();
1414
$this->processLauncher = new ProcessLauncher($this->loop);
1515
}
1616

1717
public function testProcessWillBeStarted()
1818
{
1919
$process = $this->getMockBuilder('React\ChildProcess\Process')->disableOriginalConstructor()->getMock();
20-
$process->stdout = $this->getMock('React\Stream\ReadableStreamInterface');
21-
$process->stdin = $this->getMock('React\Stream\WritableStreamInterface');
20+
$process->stdout = $this->getMockBuilder('React\Stream\ReadableStreamInterface')->getMock();
21+
$process->stdin = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
2222

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

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

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

5050
$process->expects($this->once())->method('isRunning')->will($this->returnValue(false));
5151
$process->expects($this->never())->method('terminate');

tests/bootstrap.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
error_reporting(-1);
99

10-
class TestCase extends PHPUnit_Framework_TestCase
10+
class TestCase extends PHPUnit\Framework\TestCase
1111
{
1212
protected function expectCallableOnce()
1313
{
@@ -27,7 +27,7 @@ protected function expectCallableOnceWith($value)
2727
$mock
2828
->expects($this->once())
2929
->method('__invoke')
30-
->with($this->equalTo($value));
30+
->with($value);
3131

3232
return $mock;
3333
}
@@ -44,6 +44,7 @@ protected function expectCallableNever()
4444

4545
protected function expectCallableOnceParameter($type)
4646
{
47+
throw new \BadMethodCallException();
4748
$mock = $this->createCallableMock();
4849
$mock
4950
->expects($this->once())
@@ -53,12 +54,9 @@ protected function expectCallableOnceParameter($type)
5354
return $mock;
5455
}
5556

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

6462
protected function expectPromiseResolve($promise)
@@ -106,11 +104,3 @@ protected function waitFor(PromiseInterface $promise, LoopInterface $loop)
106104
return $resolved;
107105
}
108106
}
109-
110-
class CallableStub
111-
{
112-
public function __invoke()
113-
{
114-
}
115-
}
116-

0 commit comments

Comments
 (0)
0