| @@ 38-118 (lines=81) @@ | ||
| 35 | use Payone\Core\Test\Unit\BaseTestCase; |
|
| 36 | use Payone\Core\Model\Test\PayoneObjectManager; |
|
| 37 | ||
| 38 | class BasicTest extends BaseTestCase |
|
| 39 | { |
|
| 40 | /** |
|
| 41 | * @var ClassToTest |
|
| 42 | */ |
|
| 43 | private $classToTest; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @var ObjectManager|PayoneObjectManager |
|
| 47 | */ |
|
| 48 | private $objectManager; |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @var Info|\PHPUnit_Framework_MockObject_MockObject |
|
| 52 | */ |
|
| 53 | private $info; |
|
| 54 | ||
| 55 | protected function setUp() |
|
| 56 | { |
|
| 57 | $this->objectManager = $this->getObjectManager(); |
|
| 58 | ||
| 59 | $order = $this->getMockBuilder(Order::class) |
|
| 60 | ->disableOriginalConstructor() |
|
| 61 | ->setMethods([ |
|
| 62 | 'getPayoneTxid', |
|
| 63 | 'getPayoneClearingBankcode', |
|
| 64 | 'getPayoneClearingBankaccountholder', |
|
| 65 | 'getPayoneClearingBankaccount', |
|
| 66 | 'getPayoneClearingBankiban', |
|
| 67 | 'getPayoneClearingBankbic', |
|
| 68 | 'getPayoneClearingBankname' |
|
| 69 | ]) |
|
| 70 | ->getMock(); |
|
| 71 | $order->method('getPayoneTxid')->willReturn('12345'); |
|
| 72 | $order->method('getPayoneClearingBankcode')->willReturn('12345'); |
|
| 73 | $order->method('getPayoneClearingBankaccountholder')->willReturn('12345'); |
|
| 74 | $order->method('getPayoneClearingBankaccount')->willReturn('12345'); |
|
| 75 | $order->method('getPayoneClearingBankiban')->willReturn('12345'); |
|
| 76 | $order->method('getPayoneClearingBankbic')->willReturn('12345'); |
|
| 77 | $order->method('getPayoneClearingBankname')->willReturn('12345'); |
|
| 78 | ||
| 79 | $this->info = $this->getMockBuilder(Info::class) |
|
| 80 | ->disableOriginalConstructor() |
|
| 81 | ->setMethods(['getLastTransId', 'getOrder']) |
|
| 82 | ->getMock(); |
|
| 83 | $this->info->method('getOrder')->willReturn($order); |
|
| 84 | ||
| 85 | $transactionStatus = $this->getMockBuilder(TransactionStatus::class) |
|
| 86 | ->disableOriginalConstructor() |
|
| 87 | ->setMethods(['getClearingBankcode']) |
|
| 88 | ->getMock(); |
|
| 89 | $transactionStatus->method('getClearingBankcode')->willReturn('12345'); |
|
| 90 | ||
| 91 | $transactionStatusRepository = $this->getMockBuilder(TransactionStatusRepository::class)->disableOriginalConstructor()->getMock(); |
|
| 92 | $transactionStatusRepository->method('getAppointedByTxid')->willReturn($transactionStatus); |
|
| 93 | ||
| 94 | $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ |
|
| 95 | 'transactionStatusRepository' => $transactionStatusRepository |
|
| 96 | ]); |
|
| 97 | $this->classToTest->setInfo($this->info); |
|
| 98 | } |
|
| 99 | ||
| 100 | public function testPrepareSpecificInformation() |
|
| 101 | { |
|
| 102 | $this->info->method('getLastTransId')->willReturn('12345'); |
|
| 103 | ||
| 104 | $result = $this->classToTest->getSpecificInformation(); |
|
| 105 | $this->assertArrayHasKey('IBAN:', $result); |
|
| 106 | ||
| 107 | $result = $this->classToTest->getSpecificInformation(); |
|
| 108 | $this->assertNotEmpty($result); |
|
| 109 | } |
|
| 110 | ||
| 111 | public function testPrepareSpecificInformationNoLastTransId() |
|
| 112 | { |
|
| 113 | $this->info->method('getLastTransId')->willReturn(''); |
|
| 114 | ||
| 115 | $result = $this->classToTest->getSpecificInformation(); |
|
| 116 | $this->assertArrayHasKey('Payment has not been processed yet.', $result); |
|
| 117 | } |
|
| 118 | } |
|
| 119 | ||
| @@ 38-117 (lines=80) @@ | ||
| 35 | use Payone\Core\Test\Unit\BaseTestCase; |
|
| 36 | use Payone\Core\Model\Test\PayoneObjectManager; |
|
| 37 | ||
| 38 | class ClearingReferenceTest extends BaseTestCase |
|
| 39 | { |
|
| 40 | /** |
|
| 41 | * @var ClassToTest |
|
| 42 | */ |
|
| 43 | private $classToTest; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @var ObjectManager|PayoneObjectManager |
|
| 47 | */ |
|
| 48 | private $objectManager; |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @var Info|\PHPUnit_Framework_MockObject_MockObject |
|
| 52 | */ |
|
| 53 | private $info; |
|
| 54 | ||
| 55 | protected function setUp() |
|
| 56 | { |
|
| 57 | $this->objectManager = $this->getObjectManager(); |
|
| 58 | ||
| 59 | $order = $this->getMockBuilder(Order::class) |
|
| 60 | ->disableOriginalConstructor() |
|
| 61 | ->setMethods(['getPayoneTxid', 'getPayoneClearingReference']) |
|
| 62 | ->getMock(); |
|
| 63 | $order->method('getPayoneTxid')->willReturn('12345'); |
|
| 64 | $order->method('getPayoneClearingReference')->willReturn('REFERENCE'); |
|
| 65 | ||
| 66 | $this->info = $this->getMockBuilder(Info::class) |
|
| 67 | ->disableOriginalConstructor() |
|
| 68 | ->setMethods(['getLastTransId', 'getOrder']) |
|
| 69 | ->getMock(); |
|
| 70 | $this->info->method('getOrder')->willReturn($order); |
|
| 71 | ||
| 72 | $transactionStatus = $this->getMockBuilder(TransactionStatus::class) |
|
| 73 | ->disableOriginalConstructor() |
|
| 74 | ->setMethods([ |
|
| 75 | 'getClearingBankcode', |
|
| 76 | 'getClearingBankaccountholder', |
|
| 77 | 'getClearingBankaccount', |
|
| 78 | 'getClearingBankiban', |
|
| 79 | 'getClearingBankbic', |
|
| 80 | 'getClearingBankname' |
|
| 81 | ]) |
|
| 82 | ->getMock(); |
|
| 83 | $transactionStatus->method('getClearingBankcode')->willReturn('12345'); |
|
| 84 | $transactionStatus->method('getClearingBankaccountholder')->willReturn('12345'); |
|
| 85 | $transactionStatus->method('getClearingBankaccount')->willReturn('12345'); |
|
| 86 | $transactionStatus->method('getClearingBankiban')->willReturn('12345'); |
|
| 87 | $transactionStatus->method('getClearingBankbic')->willReturn('12345'); |
|
| 88 | $transactionStatus->method('getClearingBankname')->willReturn('12345'); |
|
| 89 | ||
| 90 | $transactionStatusRepository = $this->getMockBuilder(TransactionStatusRepository::class)->disableOriginalConstructor()->getMock(); |
|
| 91 | $transactionStatusRepository->method('getAppointedByTxid')->willReturn($transactionStatus); |
|
| 92 | ||
| 93 | $this->classToTest = $this->objectManager->getObject(ClassToTest::class, [ |
|
| 94 | 'transactionStatusRepository' => $transactionStatusRepository |
|
| 95 | ]); |
|
| 96 | $this->classToTest->setInfo($this->info); |
|
| 97 | } |
|
| 98 | ||
| 99 | public function testPrepareSpecificInformation() |
|
| 100 | { |
|
| 101 | $this->info->method('getLastTransId')->willReturn('12345'); |
|
| 102 | ||
| 103 | $result = $this->classToTest->getSpecificInformation(); |
|
| 104 | $this->assertArrayHasKey('IBAN:', $result); |
|
| 105 | ||
| 106 | $result = $this->classToTest->getSpecificInformation(); |
|
| 107 | $this->assertNotEmpty($result); |
|
| 108 | } |
|
| 109 | ||
| 110 | public function testPrepareSpecificInformationNoLastTransId() |
|
| 111 | { |
|
| 112 | $this->info->method('getLastTransId')->willReturn(''); |
|
| 113 | ||
| 114 | $result = $this->classToTest->getSpecificInformation(); |
|
| 115 | $this->assertArrayHasKey('Payment has not been processed yet.', $result); |
|
| 116 | } |
|
| 117 | } |
|
| 118 | ||