Repository navigation
Expand file tree
/
Copy pathDockerTest.php
More file actions
52 lines (41 loc) · 1.55 KB
/
Copy pathDockerTest.php
File metadata and controls
52 lines (41 loc) · 1.55 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
43
44
45
46
47
48
49
50
51
52
<?php
declare(strict_types=1);
namespace Docker\Tests;
use Docker\Docker;
use Docker\Exception\BadRequestException;
use Nyholm\Psr7\Response;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
class DockerTest extends TestCase
{
public function testCreate(): void
{
$this->assertInstanceOf(Docker::class, Docker::create());
}
public function testCreateForwardsServerPluginOption(): void
{
$httpClient = new class implements ClientInterface {
public ?RequestInterface $request = null;
public function sendRequest(RequestInterface $request): ResponseInterface
{
$this->request = $request;
return new Response(200, ['Content-Type' => 'application/json'], '{}');
}
};
$this->assertInstanceOf(Docker::class, Docker::create($httpClient, [], [], false));
$this->assertSame('/info', $httpClient->request?->getUri()->getPath());
}
public function testCreateThrowsConcreteExceptionForInvalidResponse(): void
{
$httpClient = new class implements ClientInterface {
public function sendRequest(RequestInterface $request): ResponseInterface
{
return new Response(200, ['Content-Type' => 'application/json'], 'invalid');
}
};
$this->expectException(BadRequestException::class);
$this->expectExceptionMessage('Failed to decode JSON.');
Docker::create($httpClient, [], [], false);
}
}