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 CompletePurchaseRequestTest extends TestCase |
||
17 | { |
||
18 | private $request; |
||
19 | |||
20 | private $purse = 'OK426375940'; |
||
21 | private $description = 'evo.ru-tld.ru: deposit valenp'; |
||
22 | private $transactionId = 2705801; |
||
23 | private $amount = 68.71; |
||
24 | private $currency = 'USD'; |
||
25 | private $timestamp = '2014-03-22 19:54:58'; |
||
26 | private $testMode = true; |
||
27 | |||
28 | private $data = [ |
||
|
|||
29 | 'ok_charset' => 'utf-8', |
||
30 | 'ok_receiver' => 'OK426375940', |
||
31 | 'ok_receiver_id' => '532844008', |
||
32 | 'ok_receiver_wallet' => 'OK426375940', |
||
33 | 'ok_receiver_email' => '[email protected]', |
||
34 | 'ok_txn_id' => 2705801, |
||
35 | 'ok_txn_kind' => 'payment_link', |
||
36 | 'ok_txn_payment_type' => 'instant', |
||
37 | 'ok_txn_payment_method' => 'OKB', |
||
38 | 'ok_txn_gross' => '68.71', |
||
39 | 'ok_txn_net' => '68.71', |
||
40 | 'ok_txn_fee' => '0.00', |
||
41 | 'ok_txn_currency' => 'USD', |
||
42 | 'ok_txn_datetime' => '2014-03-22 19:54:58', |
||
43 | 'ok_txn_status' => 'completed', |
||
44 | 'ok_invoice' => '', |
||
45 | 'ok_payer_status' => 'verified', |
||
46 | 'ok_payer_id' => '914126735', |
||
47 | 'ok_payer_reputation' => '0', |
||
48 | 'ok_payer_first_name' => 'Valentin', |
||
49 | 'ok_payer_last_name' => 'Perevalov', |
||
50 | 'ok_payer_email' => '[email protected]', |
||
51 | 'ok_payer_phone' => '7-9080858303', |
||
52 | 'ok_payer_country' => 'Russia', |
||
53 | 'ok_payer_city' => 'Chelyabinsk', |
||
54 | 'ok_payer_country_code' => 'RU', |
||
55 | 'ok_payer_state' => 'Chelyabinskaya obl.', |
||
56 | 'ok_payer_address_status' => 'confirmed', |
||
57 | 'ok_payer_street' => 'Truda 24-136', |
||
58 | 'ok_payer_zip' => '454006', |
||
59 | 'ok_payer_address_name' => 'Postal', |
||
60 | 'ok_items_count' => '1', |
||
61 | 'ok_item_1_name' => 'evo.ru-tld.ru: deposit valenp', |
||
62 | 'ok_item_1_type' => 'digital', |
||
63 | 'ok_item_1_quantity' => '1', |
||
64 | 'ok_item_1_gross' => '68.71', |
||
65 | 'ok_item_1_price' => '68.71', |
||
66 | 'ok_ipn_id' => '2011795', |
||
67 | ]; |
||
68 | |||
69 | public function setUp() |
||
82 | |||
83 | View Code Duplication | public function testGetData() |
|
93 | |||
94 | public function testSendData() |
||
100 | } |
||
101 | |||
109 |