Completed
Push — develop ( 86f0dd...f71342 )
by Adam
12s
created

ToneRequestTest::testSendSuccess()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\Message;
4
5
use Guzzle\Plugin\Mock\MockPlugin;
6
use GuzzleHttp\Client;
7
use IBM\Watson\Common\Tests\TestCase;
8
use IBM\Watson\ToneAnalyzer\Service;
9
use Mockery as m;
10
11
class ToneRequestTest extends TestCase
12
{
13
    protected $request;
14
15
    public function testGetData()
16
    {
17
        $this->request = m::mock('\IBM\Watson\ToneAnalyzer\Message\ToneRequest')->makePartial();
18
        $this->request->initialize([
19
            'username'  => 'adam',
20
            'password'  => 'password',
21
            'version'   => '2016-03-01',
22
            'text'      => 'Test Text',
23
        ]);
24
25
        $this->assertSame([
26
            'username'  => 'adam',
27
            'password'  => 'password',
28
            'version'   => '2016-03-01',
29
            'text'      => 'Test Text',
30
        ], $this->request->getData());
31
    }
32
33
    public function testSendSuccess()
34
    {
35
        $container = [];
36
37
        $response = $this->getMockHttpResponse('ToneRequestSuccess.txt');
38
        $httpClient = $this->getMockHttpClientWithHistoryAndResponses($container, [$response]);
39
40
        $service = new Service($httpClient);
41
        $service->initialize(['username' => 'adam', 'password' => '123']);
42
43
        $request = $service->tone(['text' => 'test text']);
44
        $request->send();
45
    }
46
}
47