Visitar URL original
Improve test suite by adding PHPUnit to `require-dev`, support PHPUnit 7 - legacy PHPUnit 4 and test against legacy PHP 5.3 through PHP 7.3 by clue · Pull Request #46 · clue/reactphp-docker · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add tests instructions and add PHPUnit to require-dev
  • Loading branch information
clue committed Sep 5, 2019
commit 3693360e4bb9455c505f005184d4fd0347db38ea
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ install:
- composer install --no-interaction

script:
- phpunit --coverage-text
- vendor/bin/phpunit --coverage-text
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ execute arbitrary commands within isolated containers, stop running containers a
* [JSON streaming](#json-streaming)
* [JsonProgressException](#jsonprogressexception)
* [Install](#install)
* [Tests](#tests)
* [License](#license)

## Quickstart example
Expand Down Expand Up @@ -389,6 +390,21 @@ The recommended way to install this library is [through composer](http://getcomp
}
```

## 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

MIT
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
"clue/promise-stream-react": "^0.1"
},
"require-dev": {
"clue/tar-react": "~0.1.0",
"clue/block-react": "~0.3.0",
"clue/caret-notation": "~0.2.0",
"clue/block-react": "~0.3.0"
"clue/tar-react": "~0.1.0",
"phpunit/phpunit": "^4.8.35"
}
}
21 changes: 14 additions & 7 deletions tests/FunctionalClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ public function testStartRunning()
$this->assertNotNull($container['Id']);
$this->assertNull($container['Warnings']);

$start = microtime(true);

$promise = $this->client->containerStart($container['Id']);
$ret = Block\await($promise, $this->loop);

Expand Down Expand Up @@ -177,7 +175,7 @@ public function testExecStringCommandWithOutputWhileRunning($container)
*/
public function testExecStreamOutputInMultipleChunksWhileRunning($container)
{
$promise = $this->client->execCreate($container, 'echo -n hello && sleep 0 && echo -n world');
$promise = $this->client->execCreate($container, 'echo -n hello && sleep 0.2 && echo -n world');
$exec = Block\await($promise, $this->loop);

$this->assertTrue(is_array($exec));
Expand Down Expand Up @@ -343,23 +341,32 @@ public function testImageTag()
{
// create new tag "bb:now" on "busybox:latest"
$promise = $this->client->imageTag('busybox', 'bb', 'now');
$ret = Block\await($promise, $this->loop);
Block\await($promise, $this->loop);

// delete tag "bb:now" again
$promise = $this->client->imageRemove('bb:now');
$ret = Block\await($promise, $this->loop);
Block\await($promise, $this->loop);
}

public function testImageCreateStreamMissingWillEmitJsonError()
{
$promise = $this->client->version();
$version = Block\await($promise, $this->loop);

// old API reports a progress with error message, newer API just returns 404 right away
// https://docs.docker.com/engine/api/version-history/
$old = $version['ApiVersion'] < '1.22';

$stream = $this->client->imageCreateStream('clue/does-not-exist');

// one "progress" event, but no "data" events
$stream->on('progress', $this->expectCallableOnce());
$old && $stream->on('progress', $this->expectCallableOnce());
$old || $stream->on('progress', $this->expectCallableNever());
$stream->on('data', $this->expectCallableNever());

// will emit "error" with JsonProgressException and close
$stream->on('error', $this->expectCallableOnceParameter('Clue\React\Docker\Io\JsonProgressException'));
$old && $stream->on('error', $this->expectCallableOnceParameter('Clue\React\Docker\Io\JsonProgressException'));
$old || $stream->on('error', $this->expectCallableOnceParameter('Clue\React\Buzz\Message\ResponseException'));
$stream->on('close', $this->expectCallableOnce());

$this->loop->run();
Expand Down
3 changes: 1 addition & 2 deletions tests/Io/StreamingParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,8 @@ public function testDeferredStreamErrorEventWillRejectPromise()

public function testDeferredCancelingPromiseWillCloseStream()
{
$this->markTestIncomplete();

$stream = $this->getMock('React\Stream\ReadableStreamInterface');
$stream->expects($this->once())->method('isReadable')->willReturn(true);

$promise = $this->parser->deferredStream($stream, 'anything');
if (!($promise instanceof CancellablePromiseInterface)) {
Expand Down