| 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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class PurchaseRequestTest extends TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     private $request; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     private $purse          = '[email protected]'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     private $secret         = '22SAD#-78G888'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |     private $returnUrl      = 'https://www.foodstore.com/success'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     private $cancelUrl      = 'https://www.foodstore.com/failure'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     private $notifyUrl      = 'https://www.foodstore.com/notify'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |     private $description    = 'Test Transaction long description'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     private $transactionId  = '12345ASD67890sd'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |     private $amount         = '14.65'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     private $quantity       = '1'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     private $currency       = 'USD'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |     private $testMode       = true; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 32 |  | View Code Duplication |     public function setUp() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->request = new PurchaseRequest($this->getHttpClient(), $this->getHttpRequest()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->request->initialize([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             'purse'         => $this->purse, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             'secret'        => $this->secret, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |             'returnUrl'     => $this->returnUrl, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             'cancelUrl'     => $this->cancelUrl, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |             'notifyUrl'     => $this->notifyUrl, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             'description'   => $this->description, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |             'transactionId' => $this->transactionId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |             'amount'        => $this->amount, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             'currency'      => $this->currency, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             'testMode'      => $this->testMode, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 51 |  | View Code Duplication |     public function testGetData() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |         $data = $this->request->getData(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->assertSame($this->purse,         $data['ECM_PAYEE_ID']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->assertSame($this->returnUrl,     $data['ECM_SUCCESS_URL']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |         $this->assertSame($this->cancelUrl,     $data['ECM_FAIL_URL']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $this->assertSame($this->notifyUrl,     $data['ECM_RESULT_URL']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $this->assertSame($this->description,   $data['ECM_PURCH_DESC']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $this->assertSame($this->transactionId, $data['ECM_INV_NO']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->assertSame($this->amount,        $data['ECM_ITEM_COST']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertSame($this->quantity,      $data['ECM_QTY']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 64 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 65 |  |  |     public function testSendData() | 
            
                                                        
            
                                    
            
            
                | 66 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |         $data = $this->request->getData(); | 
            
                                                        
            
                                    
            
            
                | 68 |  |  |         $response = $this->request->sendData($data); | 
            
                                                        
            
                                    
            
            
                | 69 |  |  |         $this->assertSame('Omnipay\eCoin\Message\PurchaseResponse', get_class($response)); | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 71 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |  | 
            
                        
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.