forked from docker-php/docker-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerAsyncTest.php
More file actions
42 lines (32 loc) · 1.32 KB
/
Copy pathDockerAsyncTest.php
File metadata and controls
42 lines (32 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
declare(strict_types=1);
namespace Docker\Tests;
use Amp\Loop;
use Docker\API\Model\ContainersCreatePostBody;
use Docker\DockerAsync;
class DockerAsyncTest extends \PHPUnit\Framework\TestCase
{
public function testStaticConstructor(): void
{
$this->assertInstanceOf(DockerAsync::class, DockerAsync::create());
}
public function testAsync(): void
{
Loop::run(function () {
$docker = DockerAsync::create();
$containerConfig = new ContainersCreatePostBody();
$containerConfig->setImage('busybox:latest');
$containerConfig->setCmd(['echo', '-n', 'output']);
$containerConfig->setAttachStdout(true);
$containerConfig->setLabels(new \ArrayObject(['docker-php-test' => 'true']));
$response = yield $docker->imageCreate('', [
'fromImage' => 'busybox:latest',
], [], DockerAsync::FETCH_RESPONSE);
yield $response->getBody();
$containerCreate = yield $docker->containerCreate($containerConfig);
$containerStart = yield $docker->containerStart($containerCreate->getId());
$containerInfo = yield $docker->containerInspect($containerCreate->getId());
$this->assertSame($containerCreate->getId(), $containerInfo->getId());
});
}
}