Completed
Push — develop ( 9b1d71...66130e )
by Adam
03:07 queued 01:21
created

UtteranceAnalysisTest::testGetText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace IBM\Watson\ToneAnalyzer\tests\Model;
4
5
use IBM\Watson\Common\tests\Api\AbstractTestCase;
6
use IBM\Watson\ToneAnalyzer\Model\UtteranceAnalyses;
7
use IBM\Watson\ToneAnalyzer\Model\UtteranceAnalysis;
8
use PHPUnit\Framework\Constraint\IsType;
9
10
class UtteranceAnalysisTest extends AbstractTestCase
11
{
12
    private $response;
13
14
    public function setUp()
15
    {
16
        parent::setUp();
17
        $this->response = $this->getMockResponse('ToneChatResponse.json');
18
    }
19
20
21 View Code Duplication
    public function testGetError()
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...
22
    {
23
        $data = json_decode($this->response->getBody(), true);
24
25
        $utteranceAnalysis = UtteranceAnalysis::create($data[UtteranceAnalyses::KEY_TONE][0]);
26
27
        $this->assertNull($utteranceAnalysis->getError());
28
    }
29
30 View Code Duplication
    public function testGetId()
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...
31
    {
32
        $data = json_decode($this->response->getBody(), true);
33
34
        $utteranceAnalysis = UtteranceAnalysis::create($data[UtteranceAnalyses::KEY_TONE][0]);
35
36
        $this->assertSame(0, $utteranceAnalysis->getId());
37
    }
38
39 View Code Duplication
    public function testGetText()
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...
40
    {
41
        $data = json_decode($this->response->getBody(), true);
42
43
        $utteranceAnalysis = UtteranceAnalysis::create($data[UtteranceAnalyses::KEY_TONE][0]);
44
45
        $this->assertSame('Hello, I\'m having a problem with your product.', $utteranceAnalysis->getText());
46
    }
47
48 View Code Duplication
    public function testCreate()
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...
49
    {
50
        $data = json_decode($this->response->getBody(), true);
51
52
        $utteranceAnalysis = UtteranceAnalysis::create($data[UtteranceAnalyses::KEY_TONE][0]);
53
54
        $this->assertInstanceOf(UtteranceAnalysis::class, $utteranceAnalysis);
55
    }
56
57 View Code Duplication
    public function testGetTones()
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...
58
    {
59
        $data = json_decode($this->response->getBody(), true);
60
61
        $utteranceAnalysis = UtteranceAnalysis::create($data[UtteranceAnalyses::KEY_TONE][0]);
62
63
        $this->assertInternalType(IsType::TYPE_ARRAY, $utteranceAnalysis->getTones());
64
    }
65
}
66