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 |
||
8 | class AzineMailgunHetrixtoolsServiceTest extends \PHPUnit_Framework_TestCase |
||
9 | { |
||
10 | private $responseJson = '{ |
||
11 | "status": "SUCCESS", |
||
12 | "api_calls_left": 1976, |
||
13 | "blacklist_check_credits_left": 81, |
||
14 | "blacklisted_count": 3, |
||
15 | "blacklisted_on": [ |
||
16 | { |
||
17 | "rbl": "example1.com", |
||
18 | "delist": "https://1.example.com/ip/198.51.100.42" |
||
19 | }, |
||
20 | { |
||
21 | "rbl": "example2.org", |
||
22 | "delist": "https://2.example.com/query/ip/198.51.100.42" |
||
23 | }, |
||
24 | { |
||
25 | "rbl": "example3.org", |
||
26 | "delist": "https://3.example.com/query/ip/198.51.100.42" |
||
27 | } |
||
28 | ], |
||
29 | "links": { |
||
30 | "report_link": "https://3.example.com/report/blacklist/token/", |
||
31 | "whitelabel_report_link": "", |
||
32 | "api_report_link": "https://api.example.com/v1/token/report/198.51.100.42/", |
||
33 | "api_blacklist_check_link": "https://api.example.com/v2/token/blacklist-check/ipv4/198.51.100.42/" |
||
34 | } |
||
35 | }'; |
||
36 | |||
37 | /** |
||
38 | * @expectedException \InvalidArgumentException |
||
39 | */ |
||
40 | View Code Duplication | public function testIfApiKeyisNotSet() |
|
49 | |||
50 | /** |
||
51 | * @expectedException \InvalidArgumentException |
||
52 | */ |
||
53 | View Code Duplication | public function testIfEmptyIpisGiven() |
|
62 | /** |
||
63 | * @expectedException \InvalidArgumentException |
||
64 | */ |
||
65 | public function testIfInvalidIpisGiven() |
||
74 | |||
75 | public function testSuccessReponse() |
||
90 | } |