-
Notifications
You must be signed in to change notification settings - Fork 54
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 #805 from mollie/release/2.40.1
Release/2.40.1
- Loading branch information
Showing
17 changed files
with
262 additions
and
90 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
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
76 changes: 76 additions & 0 deletions
76
Test/Integration/Service/Magento/PaymentLinkRedirectTest.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,76 @@ | ||
<?php | ||
/* | ||
* Copyright Magmodules.eu. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mollie\Payment\Test\Integration\Service\Magento; | ||
|
||
use Magento\Framework\Encryption\EncryptorInterface; | ||
use Magento\Sales\Api\OrderRepositoryInterface; | ||
use Magento\Sales\Model\Order; | ||
use Mollie\Payment\Model\Mollie; | ||
use Mollie\Payment\Service\Magento\PaymentLinkRedirect; | ||
use Mollie\Payment\Test\Integration\IntegrationTestCase; | ||
|
||
class PaymentLinkRedirectTest extends IntegrationTestCase | ||
{ | ||
public function testThrowsExceptionWhenOrderDoesNotExists(): void | ||
{ | ||
$this->expectException(\Magento\Framework\Exception\NotFoundException::class); | ||
|
||
$encryptor = $this->objectManager->get(EncryptorInterface::class); | ||
$orderId = base64_encode($encryptor->encrypt('random string')); | ||
|
||
/** @var PaymentLinkRedirect $instance */ | ||
$instance = $this->objectManager->create(PaymentLinkRedirect::class); | ||
|
||
$instance->execute($orderId); | ||
} | ||
|
||
/** | ||
* @magentoDataFixture Magento/Sales/_files/order.php | ||
* | ||
* @return void | ||
*/ | ||
public function testDoesNotRedirectWhenOrderAlreadyPaid(): void | ||
{ | ||
$order = $this->loadOrder('100000001'); | ||
$order->setState(Order::STATE_PROCESSING); | ||
|
||
$encryptor = $this->objectManager->get(EncryptorInterface::class); | ||
$orderId = base64_encode($encryptor->encrypt($order->getEntityId())); | ||
|
||
/** @var PaymentLinkRedirect $instance */ | ||
$instance = $this->objectManager->create(PaymentLinkRedirect::class); | ||
$result = $instance->execute($orderId); | ||
|
||
$this->assertTrue($result->isAlreadyPaid()); | ||
} | ||
|
||
/** | ||
* @magentoDataFixture Magento/Sales/_files/order.php | ||
* | ||
* @return void | ||
*/ | ||
public function testDoesNotRedirectWhenExpired(): void | ||
{ | ||
$orderRepository = $this->objectManager->get(OrderRepositoryInterface::class); | ||
|
||
$order = $this->loadOrder('100000001'); | ||
$order->setState(Order::STATE_PENDING_PAYMENT); | ||
$order->setCreatedAt(date('Y-m-d H:i:s', strtotime('-31 days'))); | ||
$orderRepository->save($order); | ||
|
||
$encryptor = $this->objectManager->get(EncryptorInterface::class); | ||
$orderId = base64_encode($encryptor->encrypt($order->getEntityId())); | ||
|
||
/** @var PaymentLinkRedirect $instance */ | ||
$instance = $this->objectManager->create(PaymentLinkRedirect::class); | ||
$result = $instance->execute($orderId); | ||
|
||
$this->assertTrue($result->isExpired()); | ||
} | ||
} |
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
Oops, something went wrong.