| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * InterKassa driver for the Omnipay PHP payment processing library | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @link      https://github.com/hiqdev/omnipay-interkassa | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @package   omnipay-interkassa | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @license   MIT | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Omnipay\InterKassa\Tests; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Omnipay\InterKassa\Gateway; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Omnipay\Tests\GatewayTestCase; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 16 |  |  | class GatewayTest extends GatewayTestCase | 
            
                                                                        
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 18 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 19 |  |  |      * @var Gateway | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  |     public $gateway; | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     protected $purse = '887ac1234c1eeee1488b156b'; | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     protected $signKey = 'Zp2zfdSJzbS61L32'; | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     protected $testKey = 'W0b98idvHeKY2h3w'; | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     protected $transactionId = 'ID_123456'; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |     protected $description = 'Test completePurchase description'; | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |     protected $currency = 'USD'; | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |     protected $amount = '12.46'; | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     public function setUp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         parent::setUp(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $this->gateway = new Gateway($this->getHttpClient(), $this->getHttpRequest()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         $this->gateway->setPurse($this->purse); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         $this->gateway->setSignKey($this->signKey); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |         $this->gateway->setTestKey($this->testKey); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 39 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |     public function testGateway() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->assertSame($this->purse, $this->gateway->getPurse()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |         $this->assertSame($this->signKey, $this->gateway->getSignKey()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |         $this->assertSame($this->testKey, $this->gateway->getTestKey()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 46 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     public function testCompletePurchase() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |         $request = $this->gateway->completePurchase([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             'transactionId' => $this->transactionId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |         $this->assertSame($this->purse, $request->getPurse()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |         $this->assertSame($this->signKey, $request->getSignKey()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->assertSame($this->transactionId, $request->getTransactionId()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |     public function testPurchase() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $request = $this->gateway->purchase([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             'transactionId' => $this->transactionId, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |             'description' => $this->description, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |             'currency' => $this->currency, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             'amount' => $this->amount, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         $this->assertSame($this->transactionId, $request->getTransactionId()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |         $this->assertSame($this->description, $request->getDescription()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |         $this->assertSame($this->currency, $request->getCurrency()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |         $this->assertSame($this->amount, $request->getAmount()); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 73 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |  |