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

UtteranceAnalysisTest   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 71.43 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 3
dl 40
loc 56
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testGetError() 8 8 1
A testGetId() 8 8 1
A testGetText() 8 8 1
A testCreate() 8 8 1
A testGetTones() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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