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 |
||
16 | class GetClassifierRequestTest extends Base |
||
17 | { |
||
18 | /** @var Client */ |
||
19 | private $client; |
||
20 | private $config; |
||
21 | private $username = 'username'; |
||
22 | private $password = 'password'; |
||
23 | private $version = '2015-12-02'; |
||
24 | private $classifierId = 'Magenta'; |
||
25 | |||
26 | View Code Duplication | public function setUp() |
|
37 | |||
38 | /** |
||
39 | * Test that params are as expected |
||
40 | */ |
||
41 | View Code Duplication | public function testGetData() |
|
42 | { |
||
43 | /** @var GetClassifierRequest $request */ |
||
44 | $request = $this->client->getClassifier(['classifier_id' => $this->classifierId]); |
||
45 | |||
46 | $this->assertEquals(array_merge($this->config, ['classifier_id' => $this->classifierId]), $request->getData()); |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * Test the getClassifier function HTTP request |
||
51 | */ |
||
52 | public function testGetClassifier() |
||
88 | |||
89 | /** |
||
90 | * Test getClassifier failed auth is handled appropriately |
||
91 | * |
||
92 | * @expectedException \Bobbyshaw\WatsonVisualRecognition\Exceptions\AuthException |
||
93 | */ |
||
94 | View Code Duplication | public function testGetClassifierFailedAuthResponse() |
|
107 | } |
||
108 |