| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace Genkgo\TestCamt\Unit\Decoder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Genkgo\Camt\Decoder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Genkgo\Camt\DTO; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Genkgo\TestCamt\AbstractTestCase; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use PHPUnit\Framework; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use SimpleXMLElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class EntryTest extends AbstractTestCase | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |      * @var Decoder\EntryTransactionDetail&Framework\MockObject\MockObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     private $mockedEntryTransactionDetailDecoder; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |      * @var Decoder\Entry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |     private $decoder; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 24 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     protected function setUp(): void | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         $this->mockedEntryTransactionDetailDecoder = $this->createMock(Decoder\EntryTransactionDetail::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         $this->decoder = new Decoder\Entry($this->mockedEntryTransactionDetailDecoder); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |     public function testItDoesNotAddTransactionDetailsIfThereIsNoneInXml(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $entry = $this->createMock(DTO\Entry::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $entry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             ->expects(self::never()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             ->method('addTransactionDetail') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |             ->with(self::anything()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |         $xmlEntry = new SimpleXMLElement('<content></content>'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |         $this->decoder->addTransactionDetails($entry, $xmlEntry); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |     public function testItAddsTransactionDetailsIfThereArePresentInXml(): void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |         $entry = $this->createMock(DTO\Entry::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |             ->method('addReference') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                 self::isInstanceOf(SimpleXMLElement::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |             ->method('addRelatedParties') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |             ->method('addRelatedAgents') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |             ->method('addRemittanceInformation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |             ->method('addRelatedDates') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             ->method('addReturnInformation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             ->method('addAdditionalTransactionInformation') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |             ->method('addBankTransactionCode') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |             ->method('addCharges') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             ->method('addAmountDetails') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         $this->mockedEntryTransactionDetailDecoder | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             ->method('addAmount') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |             ->with( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |                 self::isInstanceOf(DTO\EntryTransactionDetail::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |                 self::isInstanceOf(SimpleXMLElement::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |         $entry | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |             ->expects(self::once()) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             ->method('addTransactionDetail') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |             ->with(self::isInstanceOf(DTO\EntryTransactionDetail::class)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |         $this->decoder->addTransactionDetails($entry, $this->getXmlEntry()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     private function getXmlEntry(): SimpleXMLElement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |         $xmlContent = <<<XML | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  | <content> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     <NtryDtls> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |         <TxDtls> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |             <EndToEndId>000000001</EndToEndId> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         </TxDtls> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |     </NtryDtls> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  | </content> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  | XML; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |         return new SimpleXMLElement($xmlContent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 159 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 160 |  |  |  |