| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * eCoin driver for Omnipay PHP payment library | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @link      https://github.com/hiqdev/omnipay-ecoin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @package   omnipay-ecoin | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @license   MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Omnipay\eCoin\Message; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Omnipay\Tests\TestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Symfony\Component\HttpFoundation\Request as HttpRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | class CompletePurchaseRequestTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     private $request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private $purse                  = 'ec12345'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $secret                 = '*&^^&$%&(23'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     private $hash                   = '33bfff79d7eeffdca9a9ac7b34a78dfc'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private $description            = 'Test Transaction long description'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     private $transactionId          = '12345ASD67890sd'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $transactionReference   = '12345678'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $timestamp              = '1454331086'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     private $payer                  = 'ec54321'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     private $amount                 = '1465.01'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     private $testMode               = false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $httpRequest = new HttpRequest([], [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             'ECM_HASH'                  => $this->hash, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             'ECM_PURCH_DESC'            => $this->description, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'ECM_PAYER_ID'              => $this->payer, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'ECM_PAYEE_ID'              => $this->purse, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'ECM_PAYMENT_AMOUNT'        => $this->amount, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             'ECM_ITEM_COST'             => $this->amount, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             'ECM_TRANS_DATE'            => $this->timestamp, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             'ECM_INV_NO'                => $this->transactionId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             'ECM_TRANS_ID'              => $this->transactionReference, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->request = new CompletePurchaseRequest($this->getHttpClient(), $httpRequest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $this->request->initialize([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             'purse'     => $this->purse, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             'secret'    => $this->secret, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |             'testMode'  => $this->testMode, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 56 |  | View Code Duplication |     public function testGetData() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $data = $this->request->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->assertSame($this->description,   $data['ECM_PURCH_DESC']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->assertSame($this->transactionId, $data['ECM_INV_NO']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertSame($this->hash,          $data['ECM_HASH']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->assertSame($this->amount,        $data['ECM_PAYMENT_AMOUNT']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->assertSame($this->timestamp,     $data['ECM_TRANS_DATE']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |         $this->assertSame($this->payer,         $data['ECM_PAYER_ID']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $this->assertSame($this->purse,         $data['ECM_PAYEE_ID']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |     public function testSendData() | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |         $data = $this->request->getData(); | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |         $response = $this->request->sendData($data); | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |         $this->assertInstanceOf('Omnipay\eCoin\Message\CompletePurchaseResponse', $response); | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 75 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 76 |  |  |  | 
            
                        
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.