-
Notifications
You must be signed in to change notification settings - Fork 2
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 #323 from OXID-eSales/b-6.3.x-fixes-for-1.2.2-UNZE…
…R-513 B 6.3.x fixes for 1.2.2 unzer 513
- Loading branch information
Showing
70 changed files
with
1,141 additions
and
511 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
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,92 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidSolutionCatalysts\Unzer\Tests\Unit\Controller; | ||
|
||
use OxidEsales\Eshop\Application\Model\Order; | ||
use OxidSolutionCatalysts\Unzer\Service\FlexibleSerializer; | ||
use OxidSolutionCatalysts\Unzer\Service\UnzerWebhooks; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use OxidSolutionCatalysts\Unzer\Controller\DispatcherController; | ||
use OxidSolutionCatalysts\Unzer\Model\TmpOrder; | ||
use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader; | ||
use UnzerSDK\Resources\Payment as UnzerResourcePayment; | ||
|
||
class DispatcherControllerTest extends TestCase | ||
{ | ||
public function testFinalizeTmpOrderExecutesCorrectly() | ||
{ | ||
$tmpOrderMock = $this->createMock(TmpOrder::class); | ||
$tmpOrderMock->method('load')->willReturn(true); | ||
|
||
$paymentMock = $this->createMock(UnzerResourcePayment::class); | ||
|
||
$order = oxNew(Order::class); | ||
$orderId = 'testOrderId'; | ||
$order->assign(['OXID' => $orderId]); | ||
|
||
$tmpData = [ | ||
'OXID' => 'testTmpOrderId', | ||
'TMPORDER' => base64_encode(serialize(['order' => $order])) | ||
]; | ||
/** @var DispatcherController $controller */ | ||
$controller = $this->getDispatcherControllerPartialMock(); | ||
|
||
$result = $controller->finalizeTmpOrder($paymentMock, $tmpOrderMock, $tmpData, false); | ||
|
||
$this->assertEquals('success', $result); | ||
} | ||
|
||
public function testFinalizeTmpOrderReturnsErrorOnInvalidData() | ||
{ | ||
$tmpOrderMock = $this->createMock(TmpOrder::class); | ||
$tmpOrderMock->method('load')->willReturn(false); | ||
|
||
$paymentMock = $this->createMock(UnzerResourcePayment::class); | ||
|
||
$tmpData = [ | ||
'OXID' => 'testTmpOrderId', | ||
'TMPORDER' => base64_encode(serialize(['invalid_data' => 'value'])) | ||
]; | ||
|
||
$controller = $this->getDispatcherControllerPartialMock(); | ||
|
||
$result = $controller->finalizeTmpOrder($paymentMock, $tmpOrderMock, $tmpData, false); | ||
|
||
$this->assertEquals('error', $result); | ||
} | ||
|
||
private function getDispatcherControllerPartialMock(): MockObject | ||
{ | ||
$controller = $this->getMockBuilder(DispatcherController::class) | ||
->onlyMethods([ | ||
'getUnzerWebhooks', | ||
'getUnzerSdkLoader', | ||
'getFlexibleSerializer', | ||
'returnError', | ||
'returnSuccess' | ||
]) | ||
->getMock(); | ||
|
||
$unzerWebhooksMock = $this->createMock(UnzerWebhooks::class); | ||
$controller->method('getUnzerWebhooks') | ||
->willReturn($unzerWebhooksMock); | ||
|
||
$controller->method('getUnzerSdkLoader') | ||
->willReturn($this->createMock(UnzerSDKLoader::class)); | ||
|
||
$controller->method('returnError') | ||
->willReturn('error'); | ||
|
||
$controller->method('returnSuccess') | ||
->willReturn('success'); | ||
|
||
$flexibleSerializer = new FlexibleSerializer(); | ||
$controller->method('getFlexibleSerializer') | ||
->willReturn($flexibleSerializer); | ||
|
||
return $controller; | ||
} | ||
} |
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.