diff --git a/Test/Integration/AbstractTestCase.php b/Test/Integration/AbstractTestCase.php new file mode 100644 index 0000000..c9d260c --- /dev/null +++ b/Test/Integration/AbstractTestCase.php @@ -0,0 +1,37 @@ +getObjectManager()->get(OrderFactory::class)->create() + ->loadByIncrementId('100000001'); + /** @var Payment $payment */ + $payment = $this->getObjectManager()->create(Payment::class); + $payment->setMethod(BoletoConfigProvider::CODE);; + $payment->setOrder($order); + $order->setPayment($payment); + $order->save(); + + return $order; + } + +} diff --git a/Test/Integration/BoletoPaymentMethodTest.php b/Test/Integration/BoletoPaymentMethodTest.php new file mode 100644 index 0000000..720cca5 --- /dev/null +++ b/Test/Integration/BoletoPaymentMethodTest.php @@ -0,0 +1,30 @@ +getPaymentMethodAdapter(); + $this->assertSame('mbissonho_bancointer_boleto', $boletoPaymentMethodAdapter->getCode()); + + /** @var CartInterface $quote */ + $quote = $this->createMock(CartInterface::class); + $quote->method('getStoreId')->willReturn(0); + $this->assertFalse($boletoPaymentMethodAdapter->isAvailable($quote)); + $this->assertTrue($boletoPaymentMethodAdapter->canUseCheckout()); + } + + private function getPaymentMethodAdapter(): PaymentMethodAdapter + { + return $this->getObjectManager()->get('BancoInterBoletoRemoteMethodAdapter'); + } + +} diff --git a/Test/Integration/Gateway/AbstractGatewayTestCase.php b/Test/Integration/Gateway/AbstractGatewayTestCase.php new file mode 100644 index 0000000..148d610 --- /dev/null +++ b/Test/Integration/Gateway/AbstractGatewayTestCase.php @@ -0,0 +1,20 @@ +getObjectManager()->get(PaymentDataObjectFactoryInterface::class); + return $paymentDataObjectFactory->create($order->getPayment()); + } + +} diff --git a/Test/Integration/Gateway/Boleto/Response/IssueResponseHandlerTest.php b/Test/Integration/Gateway/Boleto/Response/IssueResponseHandlerTest.php new file mode 100644 index 0000000..e5536ea --- /dev/null +++ b/Test/Integration/Gateway/Boleto/Response/IssueResponseHandlerTest.php @@ -0,0 +1,49 @@ +issueResponseHandler = $this->getObjectManager()->get(IssueResponseHandler::class); + } + + /** + * @magentoDataFixture Magento/Sales/_files/order.php + * @throws LocalizedException + */ + public function testThatValidGatewayResponseCausesCorrectEffects() + { + $order = $this->getOrderWithBoletoPaymentMethod(); + + $this->issueResponseHandler->handle( + [ + 'payment' => $this->getNewPaymentDataObjectFromOrder($order), + 'stateObject' => new DataObject + ], + [ + 'body' => json_encode([ + "seuNumero" => "1234", + "nossoNumero" => "98754", + "codigoBarras" => "5555555555555555554", + "linhaDigitavel" => "444444444444444445", + ]), + ] + ); + + $payment = $order->getPayment(); + + self::assertEquals("98754", $payment->getTransactionId()); + self::assertFalse($payment->getIsTransactionClosed()); + } + +} diff --git a/Test/Mftf/Page/AdminConfigPaymentMethodsPage.xml b/Test/Mftf/Page/AdminConfigPaymentMethodsPage.xml new file mode 100644 index 0000000..6aeca0d --- /dev/null +++ b/Test/Mftf/Page/AdminConfigPaymentMethodsPage.xml @@ -0,0 +1,12 @@ + + + + +
+ + diff --git a/Test/Mftf/README.md b/Test/Mftf/README.md new file mode 100644 index 0000000..ae7aef6 --- /dev/null +++ b/Test/Mftf/README.md @@ -0,0 +1,3 @@ +# Functional Tests + +The Functional Test Module for **Mbissonho BancoInter** module. diff --git a/Test/Mftf/Section/BancoInterMbissonhoPaymentsConfigSection.xml b/Test/Mftf/Section/BancoInterMbissonhoPaymentsConfigSection.xml new file mode 100644 index 0000000..466adbf --- /dev/null +++ b/Test/Mftf/Section/BancoInterMbissonhoPaymentsConfigSection.xml @@ -0,0 +1,15 @@ + + + + +
+ +
+
diff --git a/Test/Mftf/Test/AdminConfigPaymentsSectionSeeMbissonhoBancoInterSectionTest.xml b/Test/Mftf/Test/AdminConfigPaymentsSectionSeeMbissonhoBancoInterSectionTest.xml new file mode 100644 index 0000000..1b59474 --- /dev/null +++ b/Test/Mftf/Test/AdminConfigPaymentsSectionSeeMbissonhoBancoInterSectionTest.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + +