Skip to content

Commit

Permalink
Merge pull request #323 from OXID-eSales/b-6.3.x-fixes-for-1.2.2-UNZE…
Browse files Browse the repository at this point in the history
…R-513

B 6.3.x fixes for 1.2.2 unzer 513
  • Loading branch information
mariolorenz authored Dec 5, 2024
2 parents eccf945 + cc3be8a commit 2c0cf97
Show file tree
Hide file tree
Showing 70 changed files with 1,141 additions and 511 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
install_shop_with_module:
strategy:
matrix:
php: [ '7.4' ]
php: [ '7.4', '8.1' ]
runs-on: ubuntu-latest
steps:
- name: Cleanup workspace
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
unit_tests:
strategy:
matrix:
php: [ '7.4' ]
php: [ '7.4', '8.1' ]
needs: [ install_shop_with_module ]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -228,7 +228,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.4' ]
php: [ '7.4', '8.1' ]
group:
[
'PaymentAvailableTest',
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### FIXED
- [0007730](https://bugs.oxid-esales.com/view.php?id=7730): even if the credit card payment was cancelled (when entering the secure code), an order confirmation is sent
- Order of credit card data input fields optimized
- Add Descriptor for PrePayment on ThankYou-Page
- remove Option "Capture Later"-Option for ApplePay
- Save ApplePay-Certificates for Test- and Live-Mode. Fix an possible Maintenance when something was wrong before
- Fixed a problem when multiple modules were in use. If Unzer was not last in some extended classes, this could lead to a maintenance.
- [0007739](https://bugs.oxid-esales.com/view.php?id=7739): Fix that order with payment method Unzer bancontact is not created after successful payment

## [1.2.0] - 2024-09-26

Expand Down
3 changes: 2 additions & 1 deletion Tests/Codeception/Acceptance/AbortAndCancelPaymentCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public function testUserClicksBrowserBackOnPaypal(AcceptanceTester $I)
// login page
$I->makeScreenshot("before_back");
$I->waitForElement($this->loginInput);
$I->amOnPage(Configuration::config()['modules']['config']['WebDriver']['url'] . $currentUrl);

$I->amOnPage($currentUrl);
$templateString = Translator::translate('OSCUNZER_CANCEL_DURING_CHECKOUT');
$I->wait(60);
$I->makeScreenshot("after_back");
Expand Down
1 change: 0 additions & 1 deletion Tests/Codeception/Acceptance/SofortCest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ protected function getOXID(): array
public function _before(AcceptanceTester $I): void
{
parent::_before($I);
$I->resetCookie([]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Tests/Integration/Model/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace OxidSolutionCatalysts\Unzer\Tests\Integration\Model;

use OxidSolutionCatalysts\Unzer\Model\Payment;
use OxidEsales\Eshop\Application\Model\Payment;
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleSettingBridgeInterface;
use OxidEsales\TestingLibrary\UnitTestCase;
Expand Down
6 changes: 5 additions & 1 deletion Tests/Integration/Service/PaymentExtensionLoaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
use OxidEsales\Eshop\Application\Model\Payment as PaymentModel;
use OxidSolutionCatalysts\Unzer\Service\DebugHandler;
use OxidSolutionCatalysts\Unzer\Service\PaymentExtensionLoader;
use OxidSolutionCatalysts\Unzer\Service\SavedPayment\SavedPaymentSessionService;
use OxidSolutionCatalysts\Unzer\Service\TmpOrderService;
use OxidSolutionCatalysts\Unzer\Service\Unzer;
use OxidSolutionCatalysts\Unzer\Service\UnzerSDKLoader;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -39,7 +41,9 @@ public function testPaymentTypeCanBeLoaded($paymentId, $paymentClass): void
$this->getMockBuilder(Unzer::class)
->disableOriginalConstructor()
->getMock(),
$this->logger
$this->logger,
$this->createMock(SavedPaymentSessionService::class),
$this->createMock(TmpOrderService::class)
);

$loadedPaymentType = $sut->getPaymentExtension($paymentStub);
Expand Down
4 changes: 3 additions & 1 deletion Tests/Integration/Service/PaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\TestingLibrary\UnitTestCase;
use OxidSolutionCatalysts\Unzer\Service\Payment as PaymentService;
use OxidSolutionCatalysts\Unzer\Service\PaymentExtensionLoader;
use OxidSolutionCatalysts\Unzer\Service\TmpOrderService;
use OxidSolutionCatalysts\Unzer\Service\Transaction as TransactionService;
use OxidSolutionCatalysts\Unzer\Service\Translator;
use OxidSolutionCatalysts\Unzer\Service\Unzer as UnzerService;
Expand Down Expand Up @@ -40,7 +41,8 @@ public function testRemoveTemporaryOrder($sessionValue, $expectedResult): void
$this->createPartialMock(Translator::class, []),
$this->createPartialMock(UnzerService::class, []),
$this->createPartialMock(UnzerSDKLoader::class, []),
$this->createPartialMock(TransactionService::class, [])
$this->createPartialMock(TransactionService::class, []),
$this->createPartialMock(TmpOrderService::class, [])
);

$this->assertSame($expectedResult, $sut->removeTemporaryOrder());
Expand Down
2 changes: 1 addition & 1 deletion Tests/PhpMd/standard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@
</properties>
</rule>

<exclude-pattern>*OrderController.php</exclude-pattern>
<exclude-pattern>*Controller.php</exclude-pattern>
</ruleset>
21 changes: 13 additions & 8 deletions Tests/PhpStan/phpstan-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ class_alias(
\OxidSolutionCatalysts\Unzer\Controller\Admin\ModuleConfiguration_parent::class
);


class_alias(
\OxidEsales\Eshop\Application\Controller\Admin\OrderMain::class,
\OxidSolutionCatalysts\Unzer\Controller\Admin\OrderMain_parent::class
);


class_alias(
\OxidEsales\Eshop\Application\Controller\PaymentController::class,
\OxidSolutionCatalysts\Unzer\Controller\PaymentController_parent::class
);

class_alias(
\OxidEsales\Eshop\Application\Controller\Admin\OrderList::class,
\OxidSolutionCatalysts\Unzer\Controller\Admin\OrderList_parent::class
Expand All @@ -31,10 +38,6 @@ class_alias(
\OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController::class,
\OxidSolutionCatalysts\Unzer\Controller\Admin\AdminDetailsController_parent::class
);
class_alias(
\OxidEsales\Eshop\Application\Controller\PaymentController::class,
\OxidSolutionCatalysts\Unzer\Controller\PaymentController_parent::class
);

class_alias(
\OxidEsales\Eshop\Core\Config::class,
Expand All @@ -57,15 +60,17 @@ class_alias(
);

class_alias(
\OxidEsales\Eshop\Application\Model\Order::class,
\OxidSolutionCatalysts\Unzer\Model\Order_parent::class,
\OxidEsales\Eshop\Application\Model\Payment::class,
\OxidSolutionCatalysts\Unzer\Model\Payment_parent::class
);


class_alias(
\OxidEsales\Eshop\Application\Model\Payment::class,
\OxidSolutionCatalysts\Unzer\Model\Payment_parent::class
\OxidEsales\Eshop\Application\Model\Order::class,
\OxidSolutionCatalysts\Unzer\Model\Order_parent::class
);


class_alias(
\OxidEsales\Eshop\Application\Model\DiscountList::class,
\OxidSolutionCatalysts\Unzer\Model\DiscountList_parent::class
Expand Down
11 changes: 11 additions & 0 deletions Tests/PhpStan/phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,14 @@ parameters:
- ../../vendor/oxid-esales/oxideshop-ce/source/overridablefunctions.php
ignoreErrors:
- identifier: missingType.iterableValue
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::createTmpOrder\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::markUnzerOrderAsPaid\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::getUnzerInvoiceNr\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::setUnzerTransId\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Order::finalizeTmpOrder\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Payment::canCollectFully\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Payment::canCollectPartially\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Payment::canRefundFully\(\)#'

- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Payment::canRevertPartially\(\)#'
- '#Call to an undefined method OxidEsales\\Eshop\\Application\\Model\\Payment::isUnzerSecuredPayment\(\)#'
92 changes: 92 additions & 0 deletions Tests/Unit/Controller/DispatcherControllerTest.php
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;
}
}
8 changes: 7 additions & 1 deletion Tests/Unit/PaymentExtensions/UnzerPaymentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidSolutionCatalysts\Unzer\Tests\Unit\Exception;

use OxidEsales\Eshop\Application\Model\Basket as BasketModel;
use OxidEsales\Eshop\Application\Model\User as UserModel;
use OxidSolutionCatalysts\Unzer\PaymentExtensions\UnzerPayment;
use OxidSolutionCatalysts\Unzer\Service\SavedPayment\SavedPaymentSessionService;
use OxidSolutionCatalysts\Unzer\Service\TmpOrderService;
use OxidSolutionCatalysts\Unzer\Service\Unzer as UnzerService;
use PHPUnit\Framework\TestCase;
use UnzerSDK\Resources\Basket;
Expand Down Expand Up @@ -58,7 +62,9 @@ public function testDefaultExecute(): void
$unzerServiceMock,
new \OxidSolutionCatalysts\Unzer\Service\DebugHandler(
$this->createMock(\Monolog\Logger::class)
)
),
$this->createMock(SavedPaymentSessionService::class),
$this->createMock(TmpOrderService::class)
],
'',
true,
Expand Down
10 changes: 8 additions & 2 deletions Tests/Unit/PaymentExtensions/UnzerPaymentTypeObjectTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
namespace OxidSolutionCatalysts\Unzer\Tests\Unit\Exception;

use OxidSolutionCatalysts\Unzer\Service\DebugHandler;
use OxidSolutionCatalysts\Unzer\Service\SavedPayment\SavedPaymentSessionService;
use OxidSolutionCatalysts\Unzer\Service\TmpOrderService;
use OxidSolutionCatalysts\Unzer\Service\Unzer as UnzerService;
use PHPUnit\Framework\TestCase;
use UnzerSDK\Unzer;
Expand All @@ -29,7 +31,9 @@ public function testCreatePaymentTypePaymentTypeObject($extensionClass, $resourc
$this->getMockBuilder(UnzerService::class)->disableOriginalConstructor()->getMock(),
new DebugHandler(
$this->createMock(\Monolog\Logger::class)
)
),
$this->createMock(SavedPaymentSessionService::class),
$this->createMock(TmpOrderService::class)
);

$result = $sut->getUnzerPaymentTypeObject();
Expand Down Expand Up @@ -100,7 +104,9 @@ public function testFetchPaymentTypeObject($extensionClass, $resourceClass)
]),
new DebugHandler(
$this->createMock(\Monolog\Logger::class)
)
),
$this->createMock(SavedPaymentSessionService::class),
$this->createMock(TmpOrderService::class)
);

$result = $sut->getUnzerPaymentTypeObject();
Expand Down
18 changes: 13 additions & 5 deletions Tests/Unit/Service/BasketPayableServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace OxidSolutionCatalysts\Unzer\Tests\Unit\Service;

use OxidEsales\Eshop\Application\Model\Payment;
use OxidEsales\Eshop\Core\Registry;
use OxidSolutionCatalysts\Unzer\Core\UnzerDefinitions as CoreUnzerDefinitions;
use OxidSolutionCatalysts\Unzer\Model\Payment;
use OxidEsales\Eshop\Application\Model\Basket;
use OxidSolutionCatalysts\Unzer\Service\BasketPayableService;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -37,7 +37,9 @@ public function testBasketIsPayableWhenBruttoIsGreaterThanMinimalPaymentAndMinim
$minimalPayment = 50;

$this->basketMock->method('getBruttoSum')->willReturn($bruttoSum);
$this->paymentMock->method('getFieldData')->with('oxpayments__oxfromamount')->willReturn($minimalPayment);
$this->paymentMock->method('getFieldData')
->with('oxpayments__oxfromamount')
->willReturn($minimalPayment);

$this->sessionMock->method('getBasket')->willReturn($this->basketMock);

Expand All @@ -55,7 +57,9 @@ public function testBasketIsNotPayableWhenBruttoIsLessThanMinimalPayment()
$minimalPayment = 50;

$this->basketMock->method('getBruttoSum')->willReturn($bruttoSum);
$this->paymentMock->method('getFieldData')->with('oxpayments__oxfromamount')->willReturn($minimalPayment);
$this->paymentMock->method('getFieldData')
->with('oxpayments__oxfromamount')
->willReturn($minimalPayment);

$this->sessionMock->method('getBasket')->willReturn($this->basketMock);

Expand All @@ -73,7 +77,9 @@ public function testBasketIsNotPayableWhenBruttoIsLessThanMinimalPayableAmount()
$minimalPayment = 1;

$this->basketMock->method('getBruttoSum')->willReturn($bruttoSum);
$this->paymentMock->method('getFieldData')->with('oxpayments__oxfromamount')->willReturn($minimalPayment);
$this->paymentMock->method('getFieldData')
->with('oxpayments__oxfromamount')
->willReturn($minimalPayment);

$this->sessionMock->method('getBasket')->willReturn($this->basketMock);

Expand All @@ -91,7 +97,9 @@ public function testBasketIsPayableWhenBruttoIsEqualToMinimalPaymentAndMinimalPa
$minimalPayment = CoreUnzerDefinitions::MINIMAL_PAYABLE_AMOUNT;

$this->basketMock->method('getBruttoSum')->willReturn($bruttoSum);
$this->paymentMock->method('getFieldData')->with('oxpayments__oxfromamount')->willReturn($minimalPayment);
$this->paymentMock->method('getFieldData')
->with('oxpayments__oxfromamount')
->willReturn($minimalPayment);

$this->sessionMock->method('getBasket')->willReturn($this->basketMock);

Expand Down
Loading

0 comments on commit 2c0cf97

Please sign in to comment.