forked from ashleyhood/php-lxd
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathClientTest.php
More file actions
80 lines (59 loc) · 1.72 KB
/
ClientTest.php
File metadata and controls
80 lines (59 loc) · 1.72 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
namespace Opensaucesystems\Lxd\Tests;
use Mockery;
use Opensaucesystems\Lxd\Client;
use PHPUnit\Framework\TestCase;
class ClientTest extends TestCase
{
protected function tearDown(): void
{
Mockery::close();
}
/**
* testInstanceOf
*
*/
public function testInstanceWithoutHttpClientPassInConstructor()
{
$client = new Client();
$this->assertInstanceOf('\Http\Client\HttpClient', $client->getHttpClient());
}
/**
* testInstanceOf
*
*/
public function testInstanceWithHttpClientPassInConstructor()
{
$httpClient = Mockery::mock('\Http\Client\HttpClient');
$client = new Client($httpClient);
$this->assertInstanceOf('\Http\Client\HttpClient', $client->getHttpClient());
}
/**
* @test
*/
public function testSetHttpClient()
{
$client = new Client(Mockery::mock('\Http\Client\HttpClient'));
$httpClient = new \Http\Mock\Client();
$client->setHttpClient($httpClient);
$this->assertInstanceOf('\Http\Client\HttpClient', $client->getHttpClient());
}
/**
* @test
*/
public function testSetUrl()
{
$url = 'https://lxd.example.com:8443';
$httpClient = Mockery::mock('\Http\Client\HttpClient');
$client = new Client($httpClient);
$client->setUrl($url);
$this->assertEquals($url, $client->getUrl());
}
public function testInvalidEndpointException()
{
$httpClient = Mockery::mock('\Http\Client\HttpClient');
$client = new Client($httpClient);
$this->expectException(\Opensaucesystems\Lxd\Exception\InvalidEndpointException::class);
$client->nonEndpoint;
}
}