| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /* | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * This file is part of the Marlon Ogone package. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * (c) Marlon BVBA <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * For the full copyright and license information, please view the LICENSE | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  * file that was distributed with this source code. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | namespace Ogone\Tests\DirectLink; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use Ogone\DirectLink\CreateAliasResponse; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use Ogone\Tests\ShaComposer\FakeShaComposer; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | class CreateAliasResponseTest extends \PHPUnit_Framework_TestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     /** @test */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     public function CanBeVerified() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $aRequest = $this->provideRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $createAliasResponse = new CreateAliasResponse($aRequest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->assertTrue($createAliasResponse->isValid(new FakeShaComposer)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |      * @test | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |      * @expectedException InvalidArgumentException | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     public function CannotExistWithoutShaSign() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         $createAliasResponse = new CreateAliasResponse(array()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |     /** @test */ | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 38 |  | View Code Duplication |     public function ParametersCanBeRetrieved() | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $aRequest = $this->provideRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |         $createAliasResponse = new CreateAliasResponse($aRequest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |         $this->assertEquals($aRequest['orderID'], $createAliasResponse->getParam('orderid')); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |     /** @test */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     public function ChecksStatus() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |         $aRequest = $this->provideRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |         $createAliasResponse = new CreateAliasResponse($aRequest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |         $this->assertTrue($createAliasResponse->isSuccessful()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |     /** @test */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |     public function AliasIsEqual() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |         $aRequest = $this->provideRequest(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |         $createAliasResponse = new CreateAliasResponse($aRequest); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |         $alias = $createAliasResponse->getAlias(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         $this->assertEquals('customer_123', $alias->__toString()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $this->assertEquals($aRequest['CN'], $alias->getCardName()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |         $this->assertEquals($aRequest['CARDNO'], $alias->getCardNumber()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->assertEquals($aRequest['ED'], $alias->getExpiryDate()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |      * Helper method to setup a request array | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 69 |  |  |      */ | 
            
                                                        
            
                                    
            
            
                | 70 |  |  |     private function provideRequest() | 
            
                                                        
            
                                    
            
            
                | 71 |  |  |     { | 
            
                                                        
            
                                    
            
            
                | 72 |  |  |         return array( | 
            
                                                        
            
                                    
            
            
                | 73 |  |  |             'SHASIGN' => FakeShaComposer::FAKESHASTRING, | 
            
                                                        
            
                                    
            
            
                | 74 |  |  |             'UNKNOWN_PARAM' => false, /* unkown parameter, should be filtered out */ | 
            
                                                        
            
                                    
            
            
                | 75 |  |  |             'status' => 0, | 
            
                                                        
            
                                    
            
            
                | 76 |  |  |             'orderID' => '48495482424', | 
            
                                                        
            
                                    
            
            
                | 77 |  |  |             'alias' => 'customer_123', | 
            
                                                        
            
                                    
            
            
                | 78 |  |  |             'CN' => 'John Doe', | 
            
                                                        
            
                                    
            
            
                | 79 |  |  |             'CARDNO' => 'xxxxxxxxxxx4848', | 
            
                                                        
            
                                    
            
            
                | 80 |  |  |             'ED' => '1220' | 
            
                                                        
            
                                    
            
            
                | 81 |  |  |         ); | 
            
                                                        
            
                                    
            
            
                | 82 |  |  |     } | 
            
                                                        
            
                                    
            
            
                | 83 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 84 |  |  |  | 
            
                        
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.