Skip to content

Commit 3693360

Browse files
committed
Add tests instructions and add PHPUnit to require-dev
1 parent f356761 commit 3693360

5 files changed

Lines changed: 35 additions & 12 deletions

File tree

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ install:
1414
- composer install --no-interaction
1515

1616
script:
17-
- phpunit --coverage-text
17+
- vendor/bin/phpunit --coverage-text

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ execute arbitrary commands within isolated containers, stop running containers a
3535
* [JSON streaming](#json-streaming)
3636
* [JsonProgressException](#jsonprogressexception)
3737
* [Install](#install)
38+
* [Tests](#tests)
3839
* [License](#license)
3940

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

393+
## Tests
394+
395+
To run the test suite, you first need to clone this repo and then install all
396+
dependencies [through Composer](https://getcomposer.org):
397+
398+
```bash
399+
$ composer install
400+
```
401+
402+
To run the test suite, go to the project root and run:
403+
404+
```bash
405+
$ php vendor/bin/phpunit
406+
```
407+
392408
## License
393409

394410
MIT

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323
"clue/promise-stream-react": "^0.1"
2424
},
2525
"require-dev": {
26-
"clue/tar-react": "~0.1.0",
26+
"clue/block-react": "~0.3.0",
2727
"clue/caret-notation": "~0.2.0",
28-
"clue/block-react": "~0.3.0"
28+
"clue/tar-react": "~0.1.0",
29+
"phpunit/phpunit": "^4.8.35"
2930
}
3031
}

tests/FunctionalClientTest.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ public function testStartRunning()
8787
$this->assertNotNull($container['Id']);
8888
$this->assertNull($container['Warnings']);
8989

90-
$start = microtime(true);
91-
9290
$promise = $this->client->containerStart($container['Id']);
9391
$ret = Block\await($promise, $this->loop);
9492

@@ -177,7 +175,7 @@ public function testExecStringCommandWithOutputWhileRunning($container)
177175
*/
178176
public function testExecStreamOutputInMultipleChunksWhileRunning($container)
179177
{
180-
$promise = $this->client->execCreate($container, 'echo -n hello && sleep 0 && echo -n world');
178+
$promise = $this->client->execCreate($container, 'echo -n hello && sleep 0.2 && echo -n world');
181179
$exec = Block\await($promise, $this->loop);
182180

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

348346
// delete tag "bb:now" again
349347
$promise = $this->client->imageRemove('bb:now');
350-
$ret = Block\await($promise, $this->loop);
348+
Block\await($promise, $this->loop);
351349
}
352350

353351
public function testImageCreateStreamMissingWillEmitJsonError()
354352
{
353+
$promise = $this->client->version();
354+
$version = Block\await($promise, $this->loop);
355+
356+
// old API reports a progress with error message, newer API just returns 404 right away
357+
// https://docs.docker.com/engine/api/version-history/
358+
$old = $version['ApiVersion'] < '1.22';
359+
355360
$stream = $this->client->imageCreateStream('clue/does-not-exist');
356361

357362
// one "progress" event, but no "data" events
358-
$stream->on('progress', $this->expectCallableOnce());
363+
$old && $stream->on('progress', $this->expectCallableOnce());
364+
$old || $stream->on('progress', $this->expectCallableNever());
359365
$stream->on('data', $this->expectCallableNever());
360366

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

365372
$this->loop->run();

tests/Io/StreamingParserTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,8 @@ public function testDeferredStreamErrorEventWillRejectPromise()
109109

110110
public function testDeferredCancelingPromiseWillCloseStream()
111111
{
112-
$this->markTestIncomplete();
113-
114112
$stream = $this->getMock('React\Stream\ReadableStreamInterface');
113+
$stream->expects($this->once())->method('isReadable')->willReturn(true);
115114

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

0 commit comments

Comments
 (0)