Completed
Push — develop ( a1f82e...6f4353 )
by Adam
15:09 queued 12s
created

BuilderTest::testWithLearningOptOut()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace IBM\Watson\Common\tests\HttpClient;
4
5
use Http\Client\Common\Plugin;
6
use Http\Client\Common\PluginClient;
7
use Http\Client\HttpClient;
8
use Http\Message\MessageFactory;
9
use Http\Message\UriFactory;
10
use IBM\Watson\Common\HttpClient\Builder;
11
use PHPUnit\Framework\TestCase;
12
use Mockery as m;
13
14
class BuilderTest extends TestCase
15
{
16
    private $httpClient;
17
    private $messageFactory;
18
    private $uriFactory;
19
20
    public function setUp()
21
    {
22
        $this->httpClient = m::mock(HttpClient::class);
23
        $this->messageFactory = m::mock(MessageFactory::class);
24
        $this->uriFactory = m::mock(UriFactory::class);
25
    }
26
27
    public function testCreateConfiguredClient()
28
    {
29
        $client = (new Builder())->createConfiguredClient();
30
31
        $this->assertInstanceOf(PluginClient::class, $client);
32
    }
33
34
    public function testWithEndpoint()
35
    {
36
        $client = (new Builder())->withEndpoint('https://mockurl.test')->createConfiguredClient();
37
38
        $this->assertInstanceOf(PluginClient::class, $client);
39
    }
40
41
    public function testWithCredentials()
42
    {
43
        $client = (new Builder())
44
            ->withCredentials('adam', 'password')
45
            ->createConfiguredClient();
46
47
        $this->assertInstanceOf(PluginClient::class, $client);
48
    }
49
50 View Code Duplication
    public function testAppendPlugin()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
51
    {
52
        $plugin1 = m::mock(Plugin::class);
53
        $plugin2 = m::mock(Plugin::class);
54
        $plugin3 = m::mock(Plugin::class);
55
56
        $client = (new Builder())->appendPlugin($plugin1, $plugin2, $plugin3)->createConfiguredClient();
57
58
        $this->assertInstanceOf(PluginClient::class, $client);
59
    }
60
61 View Code Duplication
    public function testPrependPlugin()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
62
    {
63
        $plugin1 = m::mock(Plugin::class);
64
        $plugin2 = m::mock(Plugin::class);
65
        $plugin3 = m::mock(Plugin::class);
66
67
        $client = (new Builder())->prependPlugin($plugin1, $plugin2, $plugin3)->createConfiguredClient();
68
69
        $this->assertInstanceOf(PluginClient::class, $client);
70
    }
71
72
    public function testWithLearningOptOut()
73
    {
74
        $client = (new Builder())->withLearningOptOut()->createConfiguredClient();
75
76
        $this->assertInstanceOf(PluginClient::class, $client);
77
    }
78
}
79