-
Notifications
You must be signed in to change notification settings - Fork 19
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 #448 from omise/release-v3.3.1
Bump v3.3.1
- Loading branch information
Showing
10 changed files
with
250 additions
and
3 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
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
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
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
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,74 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Test\Unit; | ||
|
||
use Magento\Payment\Gateway\Data\OrderAdapterInterface; | ||
use Magento\Payment\Gateway\Data\PaymentDataObject; | ||
use Omise\Payment\Gateway\Request\APMBuilder; | ||
use Omise\Payment\Helper\OmiseHelper; | ||
use Omise\Payment\Helper\OmiseMoney; | ||
use Omise\Payment\Helper\ReturnUrlHelper; | ||
use Omise\Payment\Model\Capabilities; | ||
use Omise\Payment\Model\Config\Alipay; | ||
use Omise\Payment\Model\Config\Config; | ||
use PHPUnit\Framework\TestCase; | ||
use Omise\Payment\Test\Mock\InfoMock; | ||
|
||
class AlipayAPMBuilderTest extends TestCase | ||
{ | ||
private $builder; | ||
private $helper; | ||
private $returnUrlHelper; | ||
private $config; | ||
private $capabilities; | ||
private $orderMock; | ||
private $infoMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->helper = $this->getMockBuilder(OmiseHelper::class)->disableOriginalConstructor()->getMock(); | ||
$this->returnUrlHelper = $this->getMockBuilder(ReturnUrlHelper::class)->disableOriginalConstructor()->getMock(); | ||
$this->config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock(); | ||
$this->capabilities = $this->getMockBuilder(Capabilities::class)->disableOriginalConstructor()->getMock(); | ||
$this->orderMock = $this->getMockBuilder(OrderAdapterInterface::class)->getMock(); | ||
$this->infoMock = $this->getMockBuilder(InfoMock::class)->getMock(); | ||
} | ||
|
||
/** | ||
* @covers Omise\Payment\Gateway\Request\APMBuilder | ||
* @covers Omise\Payment\Model\Config\Alipay | ||
*/ | ||
public function testApmBuilder() | ||
{ | ||
$this->infoMock->method('getMethod')->willReturn(Alipay::CODE); | ||
$this->returnUrlHelper->method('create')->willReturn([ | ||
'url' => 'https://omise.co/complete', | ||
'token' => '1234' | ||
]); | ||
|
||
$this->builder = new APMBuilder( | ||
$this->helper, | ||
$this->returnUrlHelper, | ||
$this->config, | ||
$this->capabilities, | ||
new OmiseMoney(), | ||
); | ||
|
||
$result = $this->builder->build(['payment' => new PaymentDataObject( | ||
$this->orderMock, | ||
$this->infoMock | ||
)]); | ||
|
||
$this->assertEquals('alipay', $result['source']['type']); | ||
$this->assertEquals('https://omise.co/complete', $result['return_uri']); | ||
} | ||
|
||
/** | ||
* @covers Omise\Payment\Model\Config\Alipay | ||
*/ | ||
public function testConstants() | ||
{ | ||
$this->assertEquals('omise_offsite_alipay', Alipay::CODE); | ||
$this->assertEquals('alipay', Alipay::ID); | ||
} | ||
} |
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,75 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Test\Unit; | ||
|
||
use Omise\Payment\Gateway\Response\PaymentDetailsHandler; | ||
use Omise\Payment\Helper\OmiseHelper; | ||
use PHPUnit\Framework\TestCase; | ||
use Magento\Framework\HTTP\Client\Curl; | ||
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface; | ||
use Magento\Sales\Api\Data\OrderInterface; | ||
use Magento\Sales\Api\Data\OrderPaymentInterface; | ||
use Magento\Sales\Model\Order\Payment\Transaction\BuilderInterface; | ||
use Mockery as m; | ||
|
||
class PaymentDetailsHandlerTest extends TestCase | ||
{ | ||
|
||
private $omiseHelperMock; | ||
private $curlMock; | ||
private $builderMock; | ||
private $paymentMock; | ||
private $infoMock; | ||
private $chargeMock; | ||
private $orderMock; | ||
private $currencyMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->omiseHelperMock = m::mock(OmiseHelper::class); | ||
$this->curlMock = m::mock(Curl::class); | ||
$this->builderMock = m::mock(BuilderInterface::class); | ||
$this->paymentMock = m::mock(PaymentDataObjectInterface::class); | ||
$this->infoMock = m::mock(OrderPaymentInterface::class); | ||
$this->orderMock = m::mock(OrderInterface::class); | ||
$this->currencyMock = m::mock(); | ||
|
||
$this->chargeMock = m::mock(); | ||
$this->chargeMock->id = 'charge_xxx'; | ||
$this->chargeMock->authorize_uri = 'https://omise.co/authorized'; | ||
$this->chargeMock->expires_at = '2023-09-29T06:49:35Z'; | ||
} | ||
|
||
/** | ||
* @covers Omise\Payment\Gateway\Response\PaymentDetailsHandler | ||
*/ | ||
public function testHandler() | ||
{ | ||
$this->omiseHelperMock->shouldReceive('isPayableByImageCode')->once(); | ||
$this->builderMock->shouldReceive('setOrder')->once()->andReturn($this->builderMock); | ||
$this->builderMock->shouldReceive('setPayment')->once()->andReturn($this->builderMock); | ||
$this->builderMock->shouldReceive('setTransactionId')->once()->andReturn($this->builderMock); | ||
$this->builderMock->shouldReceive('setAdditionalInformation')->once()->andReturn($this->builderMock); | ||
$this->builderMock->shouldReceive('setFailSafe')->once()->andReturn($this->builderMock); | ||
$this->builderMock->shouldReceive('build')->once()->andReturn($this->builderMock); | ||
|
||
$this->currencyMock->shouldReceive('formatTxt')->once(); | ||
|
||
$this->orderMock->shouldReceive('getBaseCurrency')->once()->andReturn($this->currencyMock); | ||
$this->orderMock->shouldReceive('getTotalDue')->once()->andReturn(1000); | ||
|
||
$this->infoMock->shouldReceive('getMethod')->once()->andReturn('promptpay'); | ||
$this->infoMock->shouldReceive('getOrder')->once()->andReturn($this->orderMock); | ||
$this->infoMock->shouldReceive('setAdditionalInformation')->times(4); | ||
$this->infoMock->shouldReceive('prependMessage')->once(); | ||
$this->infoMock->shouldReceive('addTransactionCommentsToOrder')->once(); | ||
|
||
$this->paymentMock->shouldReceive('getPayment')->andReturn($this->infoMock); | ||
|
||
$model = new PaymentDetailsHandler($this->omiseHelperMock, $this->curlMock, $this->builderMock); | ||
$model->handle(['payment' => $this->paymentMock], [ | ||
'charge' => $this->chargeMock | ||
]); | ||
$this->expectNotToPerformAssertions(); | ||
} | ||
} |
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,65 @@ | ||
<?php | ||
|
||
namespace Omise\Payment\Test\Unit; | ||
|
||
use Magento\Sales\Model\Order; | ||
use PHPUnit\Framework\TestCase; | ||
use Magento\Checkout\Model\Session; | ||
use Magento\Framework\View\Element\Template\Context; | ||
use Omise\Payment\Block\Checkout\Onepage\Success\PromptpayAdditionalInformation; | ||
use Magento\Framework\Event\ManagerInterface; | ||
use Magento\Framework\App\Config\ScopeConfigInterface; | ||
use Magento\Backend\Block\Widget\Grid\Column\Renderer\Currency; | ||
use Mockery as m; | ||
|
||
class PromptpayAdditionalInformationTest extends TestCase | ||
{ | ||
private $contextMock; | ||
private $checkoutSessionMock; | ||
private $orderMock; | ||
private $paymentMock; | ||
private $eventManagerMock; | ||
private $scopeConfigMock; | ||
private $currencyMock; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->contextMock = m::mock(Context::class)->makePartial(); | ||
$this->checkoutSessionMock = m::mock(Session::class); | ||
$this->orderMock = m::mock(Order::class); | ||
$this->eventManagerMock = m::mock(ManagerInterface::class); | ||
$this->scopeConfigMock = m::mock(ScopeConfigInterface::class); | ||
$this->currencyMock = m::mock(Currency::class)->makePartial(); | ||
$this->paymentMock = m::mock(); | ||
} | ||
|
||
/** | ||
* @covers Omise\Payment\Block\Checkout\Onepage\Success\PromptpayAdditionalInformation | ||
* @covers Omise\Payment\Block\Checkout\Onepage\Success\AdditionalInformation | ||
*/ | ||
public function testPromptpayAdditionalInformation() | ||
{ | ||
$this->paymentMock->shouldReceive('getData')->andReturn([ | ||
"amount_ordered" => 1000, | ||
"additional_information" => [ | ||
"charge_expires_at" => "2023-09-29T06:49:35Z", | ||
"payment_type" => "promptpay" | ||
] | ||
]); | ||
$this->eventManagerMock->shouldReceive('dispatch')->times(2); | ||
$this->scopeConfigMock->shouldReceive('getValue')->once(); | ||
|
||
$this->contextMock->shouldReceive('getEventManager')->andReturn($this->eventManagerMock); | ||
$this->contextMock->shouldReceive('getScopeConfig')->andReturn($this->scopeConfigMock); | ||
|
||
$this->orderMock->shouldReceive('getPayment')->andReturn($this->paymentMock); | ||
$this->orderMock->shouldReceive('getOrderCurrency')->andReturn($this->currencyMock); | ||
$this->checkoutSessionMock->shouldReceive('getLastRealOrder')->andReturn($this->orderMock); | ||
$model = new PromptpayAdditionalInformation($this->contextMock, $this->checkoutSessionMock, []); | ||
|
||
$this->assertEquals("Sep 29, 2023 01:49 PM", $model->getChargeExpiryDate()); | ||
|
||
$html = $model->toHtml(); | ||
$this->assertNotNull($html); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
"email": "[email protected]" | ||
} | ||
], | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"minimum-stability": "stable", | ||
"type": "magento2-module", | ||
"license": "MIT", | ||
|
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
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