-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from mbissonho/develop
Develop
- Loading branch information
Showing
8 changed files
with
192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mbissonho\BancoInter\Test\Integration; | ||
|
||
use Magento\Framework\ObjectManagerInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Magento\Sales\Model\Order\Payment; | ||
use Magento\TestFramework\Helper\Bootstrap; | ||
use PHPUnit\Framework\TestCase; | ||
use Mbissonho\BancoInter\Model\Ui\Boleto\ConfigProvider as BoletoConfigProvider; | ||
use Magento\Sales\Model\OrderFactory; | ||
|
||
abstract class AbstractTestCase extends TestCase | ||
{ | ||
|
||
protected function getObjectManager(): ObjectManagerInterface | ||
{ | ||
return Bootstrap::getObjectManager(); | ||
} | ||
|
||
protected function getOrderWithBoletoPaymentMethod(): OrderInterface | ||
{ | ||
$order = $this->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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mbissonho\BancoInter\Test\Integration; | ||
|
||
use Magento\Payment\Model\Method\Adapter as PaymentMethodAdapter; | ||
use Magento\Quote\Api\Data\CartInterface; | ||
|
||
class BoletoPaymentMethodTest extends AbstractTestCase | ||
{ | ||
|
||
public function testBoletoMethodIsRegistered() | ||
{ | ||
$boletoPaymentMethodAdapter = $this->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'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace Mbissonho\BancoInter\Test\Integration\Gateway; | ||
|
||
use Magento\Payment\Gateway\Data\PaymentDataObjectFactoryInterface; | ||
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Mbissonho\BancoInter\Test\Integration\AbstractTestCase; | ||
|
||
abstract class AbstractGatewayTestCase extends AbstractTestCase | ||
{ | ||
|
||
protected function getNewPaymentDataObjectFromOrder(OrderInterface $order): PaymentDataObjectInterface | ||
{ | ||
/** @var PaymentDataObjectFactoryInterface $paymentDataObjectFactory */ | ||
$paymentDataObjectFactory = $this->getObjectManager()->get(PaymentDataObjectFactoryInterface::class); | ||
return $paymentDataObjectFactory->create($order->getPayment()); | ||
} | ||
|
||
} |
49 changes: 49 additions & 0 deletions
49
Test/Integration/Gateway/Boleto/Response/IssueResponseHandlerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Mbissonho\BancoInter\Test\Integration\Gateway\Boleto\Response; | ||
|
||
use Magento\Framework\DataObject; | ||
use Magento\Framework\Exception\LocalizedException; | ||
use Mbissonho\BancoInter\Gateway\Boleto\Response\IssueResponseHandler; | ||
use Mbissonho\BancoInter\Test\Integration\Gateway\AbstractGatewayTestCase; | ||
|
||
class IssueResponseHandlerTest extends AbstractGatewayTestCase | ||
{ | ||
private IssueResponseHandler $issueResponseHandler; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->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()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
<pages xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/PageObject.xsd"> | ||
<page name="AdminConfigPaymentMethodsPage" url="admin/system_config/edit/section/payment/" area="admin" module="Magento_Config"> | ||
<section name="BancoInterMbissonhoPaymentsConfigSection"/> | ||
</page> | ||
</pages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Functional Tests | ||
|
||
The Functional Test Module for **Mbissonho BancoInter** module. |
15 changes: 15 additions & 0 deletions
15
Test/Mftf/Section/BancoInterMbissonhoPaymentsConfigSection.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd"> | ||
<section name="BancoInterMbissonhoPaymentsConfigSection"> | ||
<element name="mbissonho_bancointer_payments_config_section_header" | ||
type="text" selector="#payment_us_mbissonho_bancointer-head"/> | ||
</section> | ||
</sections> |
26 changes: 26 additions & 0 deletions
26
Test/Mftf/Test/AdminConfigPaymentsSectionSeeMbissonhoBancoInterSectionTest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
--> | ||
|
||
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd"> | ||
<test name="AdminConfigPaymentsSectionSeeMbissonhoBancoInterSectionTest"> | ||
<annotations> | ||
<features value="Mbissonho_BancoInter"/> | ||
<stories value="Payment methods"/> | ||
</annotations> | ||
<after> | ||
<actionGroup ref="AdminLogoutActionGroup" stepKey="amOnLogoutPage"/> | ||
</after> | ||
|
||
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin1"/> | ||
<amOnPage url="{{AdminConfigPaymentMethodsPage.url}}" stepKey="navigateToConfigurationPage"/> | ||
<waitForPageLoad stepKey="waitForPageLoad1"/> | ||
<seeElement selector="{{BancoInterMbissonhoPaymentsConfigSection.mbissonho_bancointer_payments_config_section_header}}" | ||
stepKey="seeSection"/> | ||
</test> | ||
</tests> |