diff --git a/.github/workflows/phpcs.yml b/.github/workflows/phpcs.yml new file mode 100644 index 0000000..8122fbd --- /dev/null +++ b/.github/workflows/phpcs.yml @@ -0,0 +1,30 @@ +name: PHP Code Style + +on: + push: + branches: [ "b-6.1.x" ] + pull_request: + branches: [ "b-6.1.x" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Validate composer.json + run: composer validate --strict + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Setup IDE helper + run: php ./ide-helper.php + + - name: Check code styling + run: composer run-script style-check \ No newline at end of file diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml new file mode 100644 index 0000000..3c5cf48 --- /dev/null +++ b/.github/workflows/phpstan.yml @@ -0,0 +1,27 @@ +name: PHP Stan check + +on: + push: + branches: [ "b-6.1.x" ] + pull_request: + branches: [ "b-6.1.x" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Setup IDE helper + run: php ./ide-helper.php + + - name: phpstan check + run: php ./vendor/bin/phpstan --no-progress \ No newline at end of file diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..ad9da61 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,27 @@ +name: PHP Unit Test + +on: + push: + branches: [ "b-6.1.x" ] + pull_request: + branches: [ "b-6.1.x" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction + + - name: Setup IDE helper + run: php ./ide-helper.php + + - name: Unit tests + run: php ./vendor/bin/phpunit \ No newline at end of file diff --git a/.gitignore b/.gitignore index 65b2e08..2830b47 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,37 @@ /tests/reports/ +/source +/var +/build +composer.lock +.phpunit.result.cache +.php-cs-fixer.cache +# phpstorm project files +.idea + +# netbeans project files +nbproject + +# zend studio for eclipse project files +.buildpath +.project +.settings + +# windows thumbnail cache +Thumbs.db + +# composer vendor dir +/vendor + +# composer itself is not needed +composer.phar + +# Mac DS_Store Files +.DS_Store + +# phpunit itself is not needed +phpunit.phar + +# vagrant runtime +/.vagrant +/.phpstorm.meta.php/oxid.meta.php +/.ide-helper.php \ No newline at end of file diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..4c204fa --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,32 @@ +in(__DIR__) + ->ignoreVCSIgnored(true) + ->exclude('Application/views') + ->exclude('metadata.php') + ->exclude('source'); + +/** + * This file is part of OXID eSales AG EasyCredit module + * Copyright © OXID eSales AG. All rights reserved. + * + * Licensed under the GNU GPL v3 - See the file LICENSE for details. + */ +return (new PhpCsFixer\Config()) + ->setRules([ + '@PER-CS' => true, + '@PSR12' => true, + '@PHP74Migration' => true, + 'header_comment' => ['header' => <<<'EOF' + This file is part of OXID eSales AG EasyCredit module + Copyright © OXID eSales AG. All rights reserved. + + Licensed under the GNU GPL v3 - See the file LICENSE for details. + EOF], + 'numeric_literal_separator' => true, + ]) + ->setFinder($finder); \ No newline at end of file diff --git a/Application/Component/Widget/EasyCreditExampleCalculation.php b/Application/Component/Widget/EasyCreditExampleCalculation.php index 5c2fe31..7fc2137 100644 --- a/Application/Component/Widget/EasyCreditExampleCalculation.php +++ b/Application/Component/Widget/EasyCreditExampleCalculation.php @@ -1,14 +1,10 @@ getExampleCalulation(); + return (bool) $this->getExampleCalulation(); } /** @@ -121,7 +117,7 @@ protected function getBasket() /** * Load example calculation from ec service. * - * @return false|\stdClass + * @return false|\stdClass|void * @throws SystemComponentException */ protected function getExampleCalculationResponse() @@ -132,8 +128,8 @@ protected function getExampleCalculationResponse() if ( !$price || - (int)$price->getBruttoPrice() < (int)$payment->getFieldData('oxfromamount') || - (int)$price->getBruttoPrice() > (int)$payment->getFieldData('oxtoamount') + (int) $price->getBruttoPrice() < (int) $payment->getFieldData('oxfromamount') || + (int) $price->getBruttoPrice() > (int) $payment->getFieldData('oxtoamount') ) { return false; } @@ -145,8 +141,9 @@ protected function getExampleCalculationResponse() $webServiceClient = EasyCreditWebServiceClientFactory::getWebServiceClient( EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_MODELLRECHNUNG_GUENSTIGSTER_RATENPLAN, $dic, - array(), - array(EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_FINANZIERUNGSBETRAG => $price->getBruttoPrice())); + [], + [EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_FINANZIERUNGSBETRAG => $price->getBruttoPrice()] + ); return $webServiceClient->execute(); } catch (\Exception $ex) { $this->getDic()->getLogging()->log($ex->getMessage()); @@ -196,4 +193,4 @@ public function isAjax() { return (Registry::getConfig()->getRequestParameter('ajax') == 1); } -} \ No newline at end of file +} diff --git a/Application/Component/Widget/EasyCreditExampleCalculationPopup.php b/Application/Component/Widget/EasyCreditExampleCalculationPopup.php index bcd4e6e..4f04b0c 100644 --- a/Application/Component/Widget/EasyCreditExampleCalculationPopup.php +++ b/Application/Component/Widget/EasyCreditExampleCalculationPopup.php @@ -1,14 +1,10 @@ getDic()->getApiConfig()->getWebShopId(); } -} \ No newline at end of file +} diff --git a/Application/Controller/Admin/EasyCreditOrderAddressController.php b/Application/Controller/Admin/EasyCreditOrderAddressController.php index 7c29da3..1c28d17 100644 --- a/Application/Controller/Admin/EasyCreditOrderAddressController.php +++ b/Application/Controller/Admin/EasyCreditOrderAddressController.php @@ -1,14 +1,10 @@ _aViewData["oxid"] = $this->getEditObjectId(); - if ($soxId != "-1" && isset($soxId)) { + if ($soxId != "-1") { // load object $oOrder = oxNew(Order::class); $oOrder->load($soxId); diff --git a/Application/Controller/Admin/EasyCreditOrderArticleController.php b/Application/Controller/Admin/EasyCreditOrderArticleController.php index 0cb4994..d602762 100644 --- a/Application/Controller/Admin/EasyCreditOrderArticleController.php +++ b/Application/Controller/Admin/EasyCreditOrderArticleController.php @@ -1,14 +1,10 @@ translateString('OXPS_EASY_CREDIT_ADMIN_REVERSAL_SUCCESS'); $this->addTplParam('reversalsuccess', $reversalSuccess); } catch (EasyCreditException $e) { - if( 0 < $e->getCode()) { + if (0 < $e->getCode()) { $reversalError = Registry::getLang()->translateString('OXPS_EASY_CREDIT_ADMIN_REVERSAL_ERROR_AMOUNT'); } else { @@ -115,7 +111,7 @@ public function sendReversal() protected function getOrder() { $soxId = $this->getEditObjectId(); - if ($this->order === false && isset($soxId) && $soxId != '-1') { + if ($this->order === false && $soxId != '-1') { $this->order = oxNew(Order::class); $this->order->load($soxId); } @@ -223,8 +219,8 @@ protected function validateInput(array $request) # match reversal amount to max open amount $service = $this->getService(); $orderData = $service->getOrderData(); - $maxReversalAmount = (float)$orderData[0]->bestellwertAktuell; - $requestReversalAmount = (float)$request['amount']; + $maxReversalAmount = (float) $orderData[0]->bestellwertAktuell; + $requestReversalAmount = (float) $request['amount']; if ($requestReversalAmount > $maxReversalAmount || 0 >= $requestReversalAmount) { throw new EasyCreditException("Requested reversal greater than actual amount", 10); } @@ -247,4 +243,4 @@ private function sendReversalToEc(array $request) $service = $this->getService(); $service->sendReversal($amount, $reason); } -} \ No newline at end of file +} diff --git a/Application/Controller/Admin/EasyCreditOrderListController.php b/Application/Controller/Admin/EasyCreditOrderListController.php index 0a3d2f7..4671a21 100644 --- a/Application/Controller/Admin/EasyCreditOrderListController.php +++ b/Application/Controller/Admin/EasyCreditOrderListController.php @@ -1,17 +1,13 @@ save(); } -} \ No newline at end of file +} diff --git a/Application/Controller/EasyCreditDispatcherController.php b/Application/Controller/EasyCreditDispatcherController.php index f452633..83325a4 100644 --- a/Application/Controller/EasyCreditDispatcherController.php +++ b/Application/Controller/EasyCreditDispatcherController.php @@ -1,14 +1,10 @@ getCurrentInitializationData(); $currentPaymentHash = EasyCreditInitializeRequestBuilder::generatePaymentHash($currentInitData); - if(!$this->isInitialized($currentPaymentHash) ) { + if (!$this->isInitialized($currentPaymentHash)) { $this->initialize($currentPaymentHash, $currentInitData); } $this->redirectToEasyCredit(); - } - catch(\Exception $ex) { + } catch (\Exception $ex) { $this->handleException($ex); } return "payment"; @@ -81,8 +76,7 @@ public function getEasyCreditDetails() try { $this->processEasyCreditDetails(); return "order"; - } - catch(\Exception $ex) { + } catch (\Exception $ex) { $this->getDicSession()->clearStorage(); $this->getBasket()->setPayment(null); $this->handleUserException($ex->getMessage()); @@ -95,7 +89,8 @@ public function getEasyCreditDetails() * * @return string */ - protected function processEasyCreditDetails() { + protected function processEasyCreditDetails() + { $this->checkInitialization(); @@ -127,16 +122,16 @@ protected function redirectToEasyCredit() protected function isInitialized($newPaymentHash) { $storage = $this->getInstalmentStorage(); - if( empty($storage) ) { + if (empty($storage)) { return false; } - if(!$storage->getTbVorgangskennung() ) { + if (!$storage->getTbVorgangskennung()) { return false; } $basketPrice = $this->getBasketPrice(); - if( $storage->getAuthorizationHash() !== $newPaymentHash || $storage->getAuthorizedAmount() !== $basketPrice) { + if ($storage->getAuthorizationHash() !== $newPaymentHash || $storage->getAuthorizedAmount() !== $basketPrice) { return false; } return true; @@ -152,12 +147,10 @@ protected function initialize($authorizationHash, $data) { $this->getDicSession()->clearStorage(); - $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_VORGANG - , array() - , array() - , $data); + $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_VORGANG, [], [], $data); - $storage = oxNew(EasyCreditStorage::class, + $storage = oxNew( + EasyCreditStorage::class, $response->tbVorgangskennung, $response->fachlicheVorgangskennung, $authorizationHash, @@ -220,9 +213,7 @@ protected function calculateBasket($paymentId, $basket, $excludeCosts = false) */ protected function getInstalmentDecision() { - $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_DECISION - , array($this->getTbVorgangskennung()) - , array()); + $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_DECISION, [$this->getTbVorgangskennung()], []); if (!isset($response->entscheidung->entscheidungsergebnis)) { return null; @@ -265,7 +256,8 @@ protected function getShippingAddress() * Returns url to easyCredit payment page * @return string */ - public function getRedirectUrl() { + public function getRedirectUrl() + { $storage = $this->getInstalmentStorage(); $url = sprintf($this->getApiConfig()->getRedirectUrl(), $storage->getTbVorgangskennung()); @@ -301,7 +293,7 @@ protected function checkInitialization() //check payment hash again $data = $this->getCurrentInitializationData(); $paymentHash = EasyCreditInitializeRequestBuilder::generatePaymentHash($data); - if(!$this->isInitialized($paymentHash)) { + if (!$this->isInitialized($paymentHash)) { throw new EasyCreditException("OXPS_EASY_CREDIT_ERROR_INITIALIZATION_FAILED"); } } @@ -327,7 +319,7 @@ protected function checkAuthorization() protected function getTbVorgangskennung() { $storage = $this->getInstalmentStorage(); - if( $storage ) { + if ($storage) { return $storage->getTbVorgangskennung(); } throw new EasyCreditException("OXPS_EASY_CREDIT_ERROR_MISSING_VORGANGSKENNUNG"); @@ -351,15 +343,15 @@ protected function setEasyCreditInstalmentAsCurrentPayment() protected function loadEasyCreditFinancialInformation() { $storage = $this->getInstalmentStorage(); - if( $storage == null ) { + if ($storage == null) { throw new EasyCreditException("OXPS_EASY_CREDIT_ERROR_EXPIRED"); } - $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_FINANCIAL_INFORMATION, array($storage->getTbVorgangskennung())); + $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_FINANCIAL_INFORMATION, [$storage->getTbVorgangskennung()]); $allgemeineVorgangsdaten = $response->allgemeineVorgangsdaten; $tilgungsplanText = $response->tilgungsplanText; - $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_FINANZIERUNG, array($storage->getTbVorgangskennung())); + $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_FINANZIERUNG, [$storage->getTbVorgangskennung()]); $paymentPlan = $response->ratenplan; $paymentPlanTxt = $this->getFormattedPaymentPlan($paymentPlan->zahlungsplan); @@ -400,10 +392,11 @@ protected function getFormattedPaymentPlan($paymentPlan) * @param $paymentPlan \stdClass * @return string */ - protected function getInterestAmount($paymentPlan) { + protected function getInterestAmount($paymentPlan) + { - $interestAmount = (float)$paymentPlan->zinsen->anfallendeZinsen; - if( empty($interestAmount) || $interestAmount < 0.0 ) { + $interestAmount = (float) $paymentPlan->zinsen->anfallendeZinsen; + if (empty($interestAmount) || $interestAmount < 0.0) { $interestAmount = 0.0; } return $interestAmount; @@ -429,13 +422,9 @@ protected function getInitializationRequestBuilder() * @return string response of webservice * @throws \Exception if something happened */ - protected function call($endpoint, $additionalArguments = array(), $queryArguments = array(), $data = null) + protected function call($endpoint, $additionalArguments = [], $queryArguments = [], $data = null) { - $webServiceClient = EasyCreditWebServiceClientFactory::getWebServiceClient($endpoint - , $this->getDic() - , $additionalArguments - , $queryArguments - , true); + $webServiceClient = EasyCreditWebServiceClientFactory::getWebServiceClient($endpoint, $this->getDic(), $additionalArguments, $queryArguments, true); return $webServiceClient->execute($data); } @@ -470,7 +459,7 @@ protected function handleUserException($i18nMessage) */ protected function getDic() { - if(!$this->dic) { + if (!$this->dic) { $this->dic = EasyCreditDicFactory::getDic(); } @@ -484,7 +473,7 @@ protected function getDic() */ protected function getApiConfig() { - if(!$this->apiConfig ) { + if (!$this->apiConfig) { $this->apiConfig = $this->getDic()->getApiConfig(); } return $this->apiConfig; @@ -499,4 +488,4 @@ protected function getDicSession() { return $this->getDic()->getSession(); } -} \ No newline at end of file +} diff --git a/Application/Controller/EasyCreditOrderController.php b/Application/Controller/EasyCreditOrderController.php index a82c5d6..652e0db 100644 --- a/Application/Controller/EasyCreditOrderController.php +++ b/Application/Controller/EasyCreditOrderController.php @@ -1,14 +1,10 @@ checkStorage(); $this->appendInstalmentRatesToPaymentDescription($payment); - } - else { + } else { $this->_oPayment = $payment; } } @@ -77,11 +71,10 @@ protected function getEasyCreditLogoUrl() /** @var $viewConfig ViewConfig */ $viewConfig = $this->getViewConfig(); $logoFile = $viewConfig->getModulePath('oxpseasycredit', "out" . DIRECTORY_SEPARATOR . "pictures" . DIRECTORY_SEPARATOR . "eclogo.png"); - if( file_exists($logoFile)) { + if (file_exists($logoFile)) { return $viewConfig->getModuleUrl('oxpseasycredit') . 'out/pictures/eclogo.png'; } - } - catch (\Exception $ex) { + } catch (\Exception $ex) { //that's expected, do nothing else } return null; @@ -95,7 +88,7 @@ protected function getEasyCreditLogoUrl() public function getTilgungsplanText() { $storage = $this->getDicSession()->getStorage(); - if( $storage ) { + if ($storage) { return $storage->getTilgungsplanTxt(); } return null; @@ -109,7 +102,7 @@ public function getTilgungsplanText() protected function getAllgemeineVorgangsdaten() { $storage = $this->getDicSession()->getStorage(); - if( $storage ) { + if ($storage) { return $storage->getAllgemeineVorgangsdaten(); } return null; @@ -123,7 +116,7 @@ protected function getAllgemeineVorgangsdaten() public function getUrlVorvertraglicheInformationen() { $allgemeineVorgangsdaten = $this->getAllgemeineVorgangsdaten(); - if( $allgemeineVorgangsdaten ) { + if ($allgemeineVorgangsdaten) { return $allgemeineVorgangsdaten->urlVorvertraglicheInformationen; } return null; @@ -137,7 +130,7 @@ public function getUrlVorvertraglicheInformationen() public function getPaymentPlanTxt() { $storage = $this->getDicSession()->getStorage(); - if( $storage ) { + if ($storage) { return $storage->getRatenplanTxt(); } return null; @@ -182,7 +175,7 @@ protected function getDicSession() */ protected function getDic() { - if(!$this->dic) { + if (!$this->dic) { $this->dic = EasyCreditDicFactory::getDic(); } diff --git a/Application/Controller/EasyCreditPaymentController.php b/Application/Controller/EasyCreditPaymentController.php index 21c0a36..d4d5b8a 100644 --- a/Application/Controller/EasyCreditPaymentController.php +++ b/Application/Controller/EasyCreditPaymentController.php @@ -1,14 +1,10 @@ getAgreementTxt(); - if( empty($agreements)) { + if (empty($agreements)) { $this->errorMessages[] = Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_NO_AGREEMENTS'); $this->easyCreditPossible = false; } @@ -197,7 +193,8 @@ protected function getExampleCalulation() * @return bool|\stdClass * @throws SystemComponentException */ - protected function getExampleCalculationResponse() { + protected function getExampleCalculationResponse() + { $price = $this->getPrice(); $payment = oxNew(Payment::class); @@ -205,16 +202,14 @@ protected function getExampleCalculationResponse() { if ( !$price || - (int)$price->getBruttoPrice() < (int)$payment->getFieldData('oxfromamount') || - (int)$price->getBruttoPrice() > (int)$payment->getFieldData('oxtoamount') + (int) $price->getBruttoPrice() < (int) $payment->getFieldData('oxfromamount') || + (int) $price->getBruttoPrice() > (int) $payment->getFieldData('oxtoamount') ) { return false; } try { - return $this->call( EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_MODELLRECHNUNG_GUENSTIGSTER_RATENPLAN - , array() - , array(EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_FINANZIERUNGSBETRAG => $price->getBruttoPrice())); + return $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_MODELLRECHNUNG_GUENSTIGSTER_RATENPLAN, [], [EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_FINANZIERUNGSBETRAG => $price->getBruttoPrice()]); } catch (\Exception $ex) { return $ex->getMessage(); } @@ -236,7 +231,7 @@ protected function getPrice() * * @param string $articleId * - * @return Price + * @return Price|void * @throws SystemComponentException */ public function getExampleCalculationPrice($articleId) @@ -404,15 +399,14 @@ protected function validateEasyCreditPayment($sPaymentId, $session) { if ($sPaymentId == $this->getApiConfig()->getEasyCreditInstalmentPaymentId()) { - if(!$this->isEasyCreditPossible()) { + if (!$this->isEasyCreditPossible()) { $session->deleteVariable('paymentid'); return; } try { $this->addProfileData(); - } - catch(\Exception $ex) { + } catch (\Exception $ex) { $this->handleUserException($ex->getMessage()); return; } @@ -435,19 +429,19 @@ protected function addProfileData() $hasChanged = false; $dateOfBirth = $this->getValidatedDateOfBirth($profileData, $user); - if( $dateOfBirth ) { + if ($dateOfBirth) { $user->oxuser__oxbirthdate = new Field($dateOfBirth, Field::T_RAW); $hasChanged = true; } $salutation = $this->getValidatedSalutation($profileData); - if( $salutation ) { + if ($salutation) { $user->oxuser__oxsal = new Field($salutation, Field::T_RAW); $hasChanged = true; } - if( $hasChanged ) { + if ($hasChanged) { $user->save(); } } @@ -459,7 +453,7 @@ protected function addProfileData() */ public function getAgreementTxt() { - if( $this->agreementTxt === false ) { + if ($this->agreementTxt === false) { $this->agreementTxt = $this->loadAgreementTxt(); } return $this->agreementTxt; @@ -473,10 +467,10 @@ public function getAgreementTxt() protected function loadAgreementTxt() { try { - $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_ZUSTIMMUNGSTEXTE, array($this->getWebshopId())); + $response = $this->call(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_ZUSTIMMUNGSTEXTE, [$this->getWebshopId()]); return $response->zustimmungDatenuebertragungPaymentPage; + } catch (\Exception $ex) { } - catch(\Exception $ex) {} return null; } @@ -489,13 +483,10 @@ protected function loadAgreementTxt() * @return string response * @throws \Exception if something happened */ - protected function call($endpoint, $additionalArguments = array(), $queryArguments = array()) + protected function call($endpoint, $additionalArguments = [], $queryArguments = []) { try { - $webServiceClient = EasyCreditWebServiceClientFactory::getWebServiceClient($endpoint - , $this->getDic() - , $additionalArguments - , $queryArguments); + $webServiceClient = EasyCreditWebServiceClientFactory::getWebServiceClient($endpoint, $this->getDic(), $additionalArguments, $queryArguments); return $webServiceClient->execute(); } catch (\Exception $ex) { $this->handleException($ex); @@ -583,7 +574,7 @@ protected function getApiConfig() */ protected function getValidatedDateOfBirth($requestData, $user) { - $birthday = $requestData["oxuser__oxbirthdate"]; + $birthday = $requestData["oxuser__oxbirthdate"] ?? null; if (!empty($birthday) && is_array($birthday)) { $convertedBirthday = $user->convertBirthday($birthday); if ($convertedBirthday) { @@ -624,4 +615,4 @@ protected function handleUserException($i18nMessage) $oEx->setMessage($i18nMessage); Registry::get("oxUtilsView")->addErrorToDisplay($oEx); } -} \ No newline at end of file +} diff --git a/Application/Model/EasyCreditTradingApiAccess.php b/Application/Model/EasyCreditTradingApiAccess.php index 9a86a02..3d0a8d3 100644 --- a/Application/Model/EasyCreditTradingApiAccess.php +++ b/Application/Model/EasyCreditTradingApiAccess.php @@ -1,14 +1,10 @@ execute([ - 'datum' => date('Y-m-d'), - 'grund' => $reason, - 'betrag' => $amount, - ]); + 'datum' => date('Y-m-d'), + 'grund' => $reason, + 'betrag' => $amount, + ]); } /** @@ -227,4 +228,4 @@ protected function assignShopOrderData(array $ecorderdata) return $results; } -} \ No newline at end of file +} diff --git a/Application/translations/de/oxpseasycredit_de_lang.php b/Application/translations/de/oxpseasycredit_de_lang.php index 9ffb5bc..3bbe48e 100644 --- a/Application/translations/de/oxpseasycredit_de_lang.php +++ b/Application/translations/de/oxpseasycredit_de_lang.php @@ -1,22 +1,15 @@ 'UTF-8', 'OXPS_EASY_CREDIT_FINANCE_FROM' => 'Finanzieren ab', @@ -47,13 +40,13 @@ 'OXPS_EASY_CREDIT_PAYMENT_PROFILEDATA_CAPTION' => 'Für eine optimale Ratenentscheidung vervollständigen Sie bitte diese Profildaten', 'OXPS_EASY_CREDIT_VALIDATION_ERROR' => 'Es ist ein Fehler aufgetreten.', - 'OXPS_EASY_CREDIT_ADMIN_DELIVERY_STATE_LIEFERUNG_MELDEN' => 'Lieferung melden', + 'OXPS_EASY_CREDIT_ADMIN_DELIVERY_STATE_LIEFERUNG_MELDEN' => 'Lieferung melden', - 'OXPS_EASY_CREDIT_ORDER_INFO'=>'Bestellinformation', - 'OXPS_EASY_CREDIT_ORDER_'=>'', - 'OXPS_EASY_CREDIT_ORDER_'=>'', - 'OXPS_EASY_CREDIT_ORDER_'=>'', - 'OXPS_EASY_CREDIT_ORDER_'=>'', - 'OXPS_EASY_CREDIT_ORDER_'=>'', - 'OXPS_EASY_CREDIT_ORDER_'=>'', -); \ No newline at end of file + 'OXPS_EASY_CREDIT_ORDER_INFO' => 'Bestellinformation', + 'OXPS_EASY_CREDIT_ERROR_FNAME_SMALL' => 'Der Vorname muss beim easyCredit-Ratenkauf mindestens zwei Zeichen lang sein.', + 'OXPS_EASY_CREDIT_ERROR_FNAME_LONG' => 'Der Vorname darf bei easyCredit-Ratenkäufen maximal 27 Zeichen lang sein.', + 'OXPS_EASY_CREDIT_ERROR_LNAME_SMALL' => 'Der Nachname muss beim easyCredit-Ratenkauf mindestens zwei Zeichen lang sein.', + 'OXPS_EASY_CREDIT_ERROR_LNAME_LONG' => 'Der Nachname darf bei easyCredit-Ratenkäufen maximmal 27 Zeichen lang sein.', + 'OXPS_EASY_CREDIT_ERROR_FNAME_CONTAINS_INVALID_CHAR' => 'Ungültige Zeichen im Vornamensfeld beim easyCredit-Ratenkauf: %s', + 'OXPS_EASY_CREDIT_ERROR_LNAME_CONTAINS_INVALID_CHAR' => 'Ungültige Zeichen im Nachnamensfeld beim easyCredit-Ratenkauf: %s', +]; diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..71d1e35 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,80 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [Unreleased] + +### Added + +- GitHub actions for building project +- Validation on first and last name according to EasyCredit model +- autoload-dev to composer file for OXID devs to test locally +- phpstan checks +- phpcs checks and fixes + +### Removed + +- Change log removed from README.md +- Static call in [EasyCreditPayment](Core/Domain/EasyCreditPayment.php) + +### Fixed + +- Undefined variable for PHP 8+ warnings +- Undefined object in PHP 8+ + +## 3.0.8 - 2022-09-08 +- Rebranding easyCredit-Ratenkauf + +## 3.0.7 +- Bugfix-release + +### 3.0.6 +- Improve Backwards-compatibility to PHP7.2 +- Calculate Rateplan only in Payment-Pricerange (by default 200 < x < 10000) + +## 3.0.5 +- Remove Payment-Costs in Checkout +- Add better default-values for payment + +## 3.0.4 +- Transfer OrderNr to EasyCredit +- Remove Ankaufsobergrenze + +## 3.0.3 +- Bugfixes + +## 3.0.2 +- Bugfixes + +## 3.0.1 +- Bugfixes + +## 3.0.0 +- Introduce Namespaces +- No more support for OXID <= v6.0 +- Integrate new API für dealer gateway +- Transaction-Overview in Backend +- Storno in Backend + +## 2.0.6 +- Fix: Elimination of malfunctions in other payment modules + +## 2.0.5 +- Birthday is not required +- Possibility to use own jqueryUI-Lib in Frontend + +## 2.0.4 +- Function-Check for OXID 6.2.3 +- easyCredit Orders are not changable (Discounts, add Articles...) in OXID-Backend + +## 2.0.0 +- Version for OXID6 installable via Composer + +## 1.0.0 +- Version for OXID4 installable via FTP + + +[unreleased]: https://github.com/OXIDprojects/easycredit-module/compare/v3.0.8...HEAD \ No newline at end of file diff --git a/Core/Api/EasyCreditCurlException.php b/Core/Api/EasyCreditCurlException.php index 24cdafc..e5a6def 100644 --- a/Core/Api/EasyCreditCurlException.php +++ b/Core/Api/EasyCreditCurlException.php @@ -1,15 +1,12 @@ _handle, CURLOPT_POSTFIELDS, $data); @@ -246,4 +242,4 @@ protected function catchRequestError() throw new EasyCreditCurlException(curl_error($this->_handle), curl_errno($this->_handle)); } } -} \ No newline at end of file +} diff --git a/Core/Api/EasyCreditResponseValidator.php b/Core/Api/EasyCreditResponseValidator.php index 8fab7d8..e67faab 100644 --- a/Core/Api/EasyCreditResponseValidator.php +++ b/Core/Api/EasyCreditResponseValidator.php @@ -1,14 +1,10 @@ dic) { + if (!$this->dic) { $this->dic = EasyCreditDicFactory::getDic(); } diff --git a/Core/Api/EasyCreditValidationException.php b/Core/Api/EasyCreditValidationException.php index ecb2857..d4858a5 100644 --- a/Core/Api/EasyCreditValidationException.php +++ b/Core/Api/EasyCreditValidationException.php @@ -1,14 +1,10 @@ getWebshopId(), - "tbk-rk-token: " . $apiConfig->getWebShopToken() - ); + "tbk-rk-token: " . $apiConfig->getWebShopToken(), + ]; $client->setRequestHeaders($headers); } return $client; } -} \ No newline at end of file +} diff --git a/Core/CrossCutting/EasyCreditLogging.php b/Core/CrossCutting/EasyCreditLogging.php index 249520c..05570b9 100644 --- a/Core/CrossCutting/EasyCreditLogging.php +++ b/Core/CrossCutting/EasyCreditLogging.php @@ -1,24 +1,20 @@ buildPrettyJsonString($encodedResponse); } - $result .= 'took ' . round($duration * 1000) . ' milliseconds' . PHP_EOL; + $result .= 'took ' . round($duration * 1_000) . ' milliseconds' . PHP_EOL; $result .= str_repeat('=', 60) . PHP_EOL . PHP_EOL; @@ -121,4 +117,4 @@ protected function isLogEnabled() { return (isset($this->logConfig[self::LOG_CONFIG_LOG_ENABLED]) && $this->logConfig[self::LOG_CONFIG_LOG_ENABLED]); } -} \ No newline at end of file +} diff --git a/Core/Di/EasyCreditApiConfig.php b/Core/Di/EasyCreditApiConfig.php index fd5561c..21b4854 100644 --- a/Core/Di/EasyCreditApiConfig.php +++ b/Core/Di/EasyCreditApiConfig.php @@ -1,19 +1,14 @@ config[$key]) ? $this->config[$key] : false; + return $this->config[$key] ?? false; } /** @@ -169,7 +164,7 @@ public function getServiceRestFunctionArguments($serviceName) // TODO may be extend for other services? switch ($serviceName) { default: - return array(self::API_CONFIG_SERVICE_REST_ARGUMENT_WEBSHOP_ID => $this->getWebShopId()); + return [self::API_CONFIG_SERVICE_REST_ARGUMENT_WEBSHOP_ID => $this->getWebShopId()]; } } @@ -179,7 +174,7 @@ public function getBaseUrl($serviceName = null) $urlIdent = self::API_CONFIG_CREDENTIAL_BASE_URL; if ($serviceName) { $service = $this->getService($serviceName); - if($service[self::API_CONFIG_SERVICE_ENDPOINT_TYPE] == self::API_CONFIG_SERVICE_ENDPOINT_TYPE_DEALER_INTERFACE) { + if ($service[self::API_CONFIG_SERVICE_ENDPOINT_TYPE] == self::API_CONFIG_SERVICE_ENDPOINT_TYPE_DEALER_INTERFACE) { $urlIdent = self::API_CONFIG_CREDENTIAL_APP_URL; } } @@ -211,7 +206,7 @@ protected function getValidationSchemes() public function getValidationScheme($serviceName) { $schemes = $this->getValidationSchemes(); - return isset($schemes[$serviceName]) ? $schemes[$serviceName] : false; + return $schemes[$serviceName] ?? false; } public function getRedirectUrl() @@ -228,4 +223,4 @@ public function getEasyCreditModuleId() { return self::API_CONFIG_EASYCREDIT_MODULE_ID; } -} \ No newline at end of file +} diff --git a/Core/Di/EasyCreditConfigException.php b/Core/Di/EasyCreditConfigException.php index 51f172d..5ae731f 100644 --- a/Core/Di/EasyCreditConfigException.php +++ b/Core/Di/EasyCreditConfigException.php @@ -1,17 +1,13 @@ config->saveShopConfVar($sVarType, $sVarName, $sVarVal, $sShopId, $sModule); } -} \ No newline at end of file +} diff --git a/Core/Di/EasyCreditDicConfigInterface.php b/Core/Di/EasyCreditDicConfigInterface.php index 0eb4597..164be0f 100644 --- a/Core/Di/EasyCreditDicConfigInterface.php +++ b/Core/Di/EasyCreditDicConfigInterface.php @@ -1,14 +1,10 @@ array( + return [ + EasyCreditApiConfig::API_CONFIG_CREDENTIALS => [ EasyCreditApiConfig::API_CONFIG_CREDENTIAL_BASE_URL => $config->getConfigParam('oxpsECBaseUrl'), EasyCreditApiConfig::API_CONFIG_CREDENTIAL_APP_URL => $config->getConfigParam('oxpsECDealerInterfaceUrl'), EasyCreditApiConfig::API_CONFIG_CREDENTIAL_WEBSHOP_ID => $config->getConfigParam('oxpsECWebshopId'), EasyCreditApiConfig::API_CONFIG_CREDENTIAL_WEBSHOP_TOKEN => $config->getConfigParam('oxpsECWebshopToken'), - ), + ], EasyCreditApiConfig::API_CONFIG_SERVICES => $services, - EasyCreditApiConfig::API_CONFIG_VALIDATION_SCHEMES => $validationSchemes - ); + EasyCreditApiConfig::API_CONFIG_VALIDATION_SCHEMES => $validationSchemes, + ]; } private static function getLoggingConfigArray() { $config = Registry::getConfig(); - return array( + return [ EasyCreditLogging::LOG_CONFIG_LOG_DIR => $config->getLogsDir(), EasyCreditLogging::LOG_CONFIG_LOG_ENABLED => $config->getConfigParam('oxpsECLogging'), - ); + ]; } private static function getJsonFromFile($filepath) { $json = file_get_contents($filepath); - return json_decode($json,true); + return json_decode($json, true); } private static function getServices() diff --git a/Core/Di/EasyCreditDicSession.php b/Core/Di/EasyCreditDicSession.php index ce83df3..06213e7 100644 --- a/Core/Di/EasyCreditDicSession.php +++ b/Core/Di/EasyCreditDicSession.php @@ -1,14 +1,10 @@ session->getStorage(); } @@ -117,8 +115,9 @@ public function getStorage() { /** * Clears storage for easyCredit information */ - public function clearStorage() { + public function clearStorage() + { $this->session->clearStorage(); } -} \ No newline at end of file +} diff --git a/Core/Di/EasyCreditDicSessionInterface.php b/Core/Di/EasyCreditDicSessionInterface.php index 201db45..758c6c6 100644 --- a/Core/Di/EasyCreditDicSessionInterface.php +++ b/Core/Di/EasyCreditDicSessionInterface.php @@ -1,14 +1,10 @@ getPaymentId())) { + if (EasyCreditHelper::isEasyCreditInstallmentById($this->getPaymentId())) { $storage = $this->getDic()->getSession()->getStorage(); - if( $storage ) { + if ($storage) { return $storage->getInterestAmount(); } } @@ -75,7 +71,7 @@ protected function getDic() public function setCost($sCostName, $oPrice = null) { parent::setCost($sCostName, $oPrice); - if(!$this->excludeInstalmentsCosts && $sCostName == "oxpayment") { + if (!$this->excludeInstalmentsCosts && $sCostName == "oxpayment") { $this->setCost('easycredit_interests', $this->calcInterestsCost()); } } @@ -85,7 +81,8 @@ public function setCost($sCostName, $oPrice = null) * * @return Price */ - public function calcInterestsCost() { + public function calcInterestsCost() + { /** @var $interestsPrice Price */ $interestsPrice = oxNew(Price::class); diff --git a/Core/Domain/EasyCreditOrder.php b/Core/Domain/EasyCreditOrder.php index 39a5f26..4d67889 100644 --- a/Core/Domain/EasyCreditOrder.php +++ b/Core/Domain/EasyCreditOrder.php @@ -1,14 +1,10 @@ isEasyCreditInstalmentPayment($oBasket->getPaymentId())) { + if (!$this->isEasyCreditInstalmentPayment($oBasket->getPaymentId())) { return parent::finalizeOrder($oBasket, $oUser, $blRecalculatingOrder); } $result = false; try { $result = $this->finalizeEasyCreditOrder($oBasket, $oUser, $blRecalculatingOrder); - } - catch(EasyCreditInitializationFailedException $iex) { + } catch (EasyCreditInitializationFailedException $iex) { $this->handleUserException($iex->getMessage()); Registry::getUtils()->redirect($this->getConfig()->getShopCurrentURL() . '&cl=payment', true, 302); - } - catch(\Exception $ex) { + } catch (\Exception $ex) { $this->handleException($ex); } @@ -83,7 +77,7 @@ protected function _loadFromBasket(Basket $oBasket) { parent::_loadFromBasket($oBasket); - if( $this->isEasyCreditInstalmentPayment($oBasket->getPaymentId()) ) { + if ($this->isEasyCreditInstalmentPayment($oBasket->getPaymentId())) { $storage = $this->getInstalmentStorage(); if ($storage) { $this->oxorder__ecredinterestsvalue = new Field($oBasket->getInterestsAmount()); @@ -131,7 +125,8 @@ protected function finalizeEasyCreditOrder(Basket $oBasket, $oUser, $blRecalcula * * @return mixed */ - protected function confirmOrder($result) { + protected function confirmOrder($result) + { try { $response = $this->getConfirmResponse(); @@ -141,13 +136,12 @@ protected function confirmOrder($result) { $this->oxorder__ecredconfirmresponse = new Field(base64_encode(serialize($response)), Field::T_RAW); $this->oxorder__ecredpaymentstatus = new Field($this->getPaymentStatus($isConfirmed), Field::T_RAW); - if(!$isConfirmed) { + if (!$isConfirmed) { $this->oxorder__oxtransstatus = new Field('ERROR', Field::T_RAW); $this->handleUserException("OXPS_EASY_CREDIT_ERROR_BESTAETIGEN_FAILED"); } $this->save(); - } - catch(\Exception $ex) { + } catch (\Exception $ex) { $this->handleException($ex); } @@ -164,29 +158,29 @@ protected function confirmOrder($result) { protected function isConfirmed($response) { $validateResponse = $this->getConfig()->getConfigParam('oxpsECCheckoutValidConfirm'); - if(!$validateResponse) { + if (!$validateResponse) { return true; } - if( empty($response) || !is_object($response) ) { + if (empty($response) || !is_object($response)) { return false; } $wsMessages = $response->wsMessages; - if( empty($wsMessages) || !is_object($wsMessages) ) { + if (empty($wsMessages) || !is_object($wsMessages)) { return false; } $messages = $wsMessages->messages; - if( empty($messages) || !is_array($messages) ) { + if (empty($messages) || !is_array($messages)) { return false; } $firstMessage = $messages[0]; - if(!is_object($firstMessage)) { + if (!is_object($firstMessage)) { return false; } - if($firstMessage->key != self::EASYCREDIT_BESTELLUNG_BESTAETIGT) { + if ($firstMessage->key != self::EASYCREDIT_BESTELLUNG_BESTAETIGT) { return false; } return true; @@ -204,27 +198,27 @@ protected function checkStorageDataIsComplete() $storage = $this->getInstalmentStorage(); $tbVorgangskennung = $storage->getTbVorgangskennung(); - if(!$tbVorgangskennung) { + if (!$tbVorgangskennung) { throw new EasyCreditInitializationFailedException("OXPS_EASY_CREDIT_ERROR_PROCESS_ID_MISSING"); } $fachlicheVorgangskennung = $storage->getFachlicheVorgangskennung(); - if(!$fachlicheVorgangskennung) { + if (!$fachlicheVorgangskennung) { throw new EasyCreditInitializationFailedException("OXPS_EASY_CREDIT_ERROR_FUNC_PROCESS_ID_MISSING"); } $allgemeineVorgangsdaten = $storage->getAllgemeineVorgangsdaten(); - if(!$allgemeineVorgangsdaten) { + if (!$allgemeineVorgangsdaten) { throw new EasyCreditInitializationFailedException("OXPS_EASY_CREDIT_ERROR_FUNC_PROCESSDATA_MISSING"); } $tilgungsplanTxt = $storage->getTilgungsplanTxt(); - if(!$tilgungsplanTxt) { + if (!$tilgungsplanTxt) { throw new EasyCreditInitializationFailedException("OXPS_EASY_CREDIT_ERROR_FUNC_REDEMPTIONPLAN_MISSING"); } $ratenplanTxt = $storage->getRatenplanTxt(); - if(!$ratenplanTxt) { + if (!$ratenplanTxt) { throw new EasyCreditInitializationFailedException("OXPS_EASY_CREDIT_ERROR_FUNC_PAYMENTPLAN_MISSING"); } } @@ -249,7 +243,7 @@ protected function checkInitialization($oUser, $oBasket) $isInitialized = $this->isInitialized($paymentHash, $oBasket); $this->calculateBasket($oBasket); - if(!$isInitialized) { + if (!$isInitialized) { throw new EasyCreditInitializationFailedException(); } } @@ -290,12 +284,12 @@ protected function getCurrentInitializationData($oUser, $oBasket) protected function isInitialized($newPaymentHash, $basket) { $storage = $this->getInstalmentStorage(); - if( empty($storage) ) { + if (empty($storage)) { return false; } $basketPrice = $basket->getPrice()->getPrice(); - if( $storage->getAuthorizationHash() !== $newPaymentHash || $storage->getAuthorizedAmount() !== $basketPrice) { + if ($storage->getAuthorizationHash() !== $newPaymentHash || $storage->getAuthorizedAmount() !== $basketPrice) { return false; } return true; @@ -320,7 +314,7 @@ protected function getShippingAddress() */ protected function getDic() { - if(!$this->dic) { + if (!$this->dic) { $this->dic = EasyCreditDicFactory::getDic(); } @@ -373,7 +367,7 @@ protected function calculateBasket($oBasket, $excludeInstalmentsCosts = false) /** * Returns easycredit processdata * - * @return EasyCreditStorage + * @return EasyCreditStorage|null * @throws SystemComponentException */ protected function getInstalmentStorage() @@ -401,7 +395,7 @@ protected function isEasyCreditInstalmentPayment($paymentId) public function getTilgungsplanTxt() { $storage = $this->getInstalmentStorage(); - if( $storage ) { + if ($storage) { return $storage->getTilgungsplanTxt(); } return null; @@ -414,8 +408,12 @@ public function getTilgungsplanTxt() */ public function getFInterestsValue() { + if (!isset($this->oxorder__ecredinterestsvalue) || !is_object($this->oxorder__ecredinterestsvalue)) { + return null; + } + $interestsValue = $this->oxorder__ecredinterestsvalue->value; - if( $interestsValue ) { + if ($interestsValue) { return Registry::getLang()->formatCurrency($interestsValue, $this->getOrderCurrency()); } return null; @@ -429,7 +427,7 @@ public function getFInterestsValue() protected function getPaymentStatus($isConfirmed) { $paymentStatus = "failed"; - if( $isConfirmed ) { + if ($isConfirmed) { $paymentStatus = "completed"; } return $paymentStatus; @@ -445,16 +443,17 @@ protected function getConfirmResponse() $processId = $this->getInstalmentStorage()->getTbVorgangskennung(); $this->getDic()->getSession()->clearStorage(); - $requestData = array( - 'shopVorgangskennung' => $this->oxorder__oxordernr->value - ); + $requestData = [ + 'shopVorgangskennung' => $this->oxorder__oxordernr->value, + ]; $wsClient = EasyCreditWebServiceClientFactory::getWebServiceClient( - EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_BESTAETIGEN - , $this->getDic() - , array($processId) - , array() - , true); + EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_BESTAETIGEN, + $this->getDic(), + [$processId], + [], + true + ); return $wsClient->execute($requestData); } diff --git a/Core/Domain/EasyCreditPayment.php b/Core/Domain/EasyCreditPayment.php index 3ee9351..dd3af14 100644 --- a/Core/Domain/EasyCreditPayment.php +++ b/Core/Domain/EasyCreditPayment.php @@ -1,14 +1,10 @@ getId()); } -} \ No newline at end of file +} diff --git a/Core/Domain/EasyCreditSession.php b/Core/Domain/EasyCreditSession.php index a2156d9..1d54f57 100644 --- a/Core/Domain/EasyCreditSession.php +++ b/Core/Domain/EasyCreditSession.php @@ -1,14 +1,10 @@ deleteVariable(self::API_CONFIG_STORAGE); - } - else { + } else { $this->setVariable(self::API_CONFIG_STORAGE, serialize($storage)); } } @@ -47,8 +42,8 @@ public function setStorage($storage) public function getStorage() { /** @var $storage EasyCreditStorage */ - $storage = unserialize((string)$this->getVariable(self::API_CONFIG_STORAGE)); - if(!empty($storage) && $storage->hasExpired()) { + $storage = unserialize((string) $this->getVariable(self::API_CONFIG_STORAGE)); + if (!empty($storage) && $storage->hasExpired()) { $this->clearStorage(); $storage = null; } @@ -62,4 +57,4 @@ public function clearStorage() { $this->setStorage(null); } -} \ No newline at end of file +} diff --git a/Core/Dto/EasyCreditStorage.php b/Core/Dto/EasyCreditStorage.php index 65bc076..db3444f 100644 --- a/Core/Dto/EasyCreditStorage.php +++ b/Core/Dto/EasyCreditStorage.php @@ -1,14 +1,10 @@ tbVorgangskennung = $tbVorgangskennung; $this->fachlicheVorgangskennung = $fachlicheVorgangskennung; @@ -74,12 +72,13 @@ protected function getStorageExpiredTimeRange() * * @return bool */ - public function hasExpired() { + public function hasExpired() + { - if( empty($this->lastUpdate) ) { + if (empty($this->lastUpdate)) { return true; } - if (time() > ($this->lastUpdate + $this->getStorageExpiredTimeRange()) ) { + if (time() > ($this->lastUpdate + $this->getStorageExpiredTimeRange())) { return true; } return false; @@ -204,4 +203,4 @@ public function setRatenplanTxt($ratenplanTxt) { $this->ratenplanTxt = $ratenplanTxt; } -} \ No newline at end of file +} diff --git a/Core/Events.php b/Core/Events.php index e5fc7c3..5b98e98 100644 --- a/Core/Events.php +++ b/Core/Events.php @@ -1,14 +1,10 @@ fieldExists($columnData["colname"], $tableName)) { $addColumnSql = sprintf( - "ALTER TABLE %s ADD COLUMN %s %s %s COMMENT %s" - , $tableName - , $columnData["colname"] - , $columnData["coltype"] - , $columnData["colnullable"] - , $oDb->quote($columnData["comment"]) + "ALTER TABLE %s ADD COLUMN %s %s %s COMMENT %s", + $tableName, + $columnData["colname"], + $columnData["coltype"], + $columnData["colnullable"], + $oDb->quote($columnData["comment"]) ); DatabaseProvider::getDb()->execute($addColumnSql); } diff --git a/Core/Exception/EasyCreditException.php b/Core/Exception/EasyCreditException.php index b41f62d..d46ae6e 100644 --- a/Core/Exception/EasyCreditException.php +++ b/Core/Exception/EasyCreditException.php @@ -1,14 +1,10 @@ "HERR", "MRS" => "FRAU", - ); + ]; /** * Builds and gets request body content for VorgangInitialisierenRequest @@ -82,7 +80,7 @@ class EasyCreditInitializeRequestBuilder implements EasyCreditInitializeRequestB */ public function getInitializationData() { - $initRequest = array( + $initRequest = [ 'integrationsart' => self::INTEGRATIONSART, 'shopKennung' => $this->getWebshopId(), 'bestellwert' => $this->getBasketPrice(), @@ -96,8 +94,8 @@ public function getInitializationData() 'risikorelevanteAngaben' => $this->getRiscs(), 'warenkorbinfos' => array_filter($this->getBasketInfo()), 'technischeShopparameter' => array_filter($this->getTechnicals()), - 'VorgangskennungShop' => $this->getOrderNr() - ); + 'VorgangskennungShop' => $this->getOrderNr(), + ]; return array_filter($initRequest); } @@ -129,11 +127,11 @@ protected function getModuleVersion() */ protected function getBasketInfo() { - $basketInfo = array(); + $basketInfo = []; $basketitemlist = $this->getBasket()->getBasketArticles(); $basketContents = $this->getBasket()->getContents(); - if( empty($basketContents) ) { + if (empty($basketContents)) { return $basketInfo; } @@ -170,18 +168,17 @@ protected function getRiscs() $user = $this->getUser(); $isGuestOrder = empty($user->oxuser__oxpassword->value); - if( $isGuestOrder) { + if ($isGuestOrder) { $registerDate = ""; $customerStatus = self::RISCS_NEUKUNDE; - } - else { //registered user + } else { //registered user $registerDate = $this->getDate($user->oxuser__oxregister->value); $customerStatus = $this->getRegisteredCustomerStatus($user); } $basket = $this->getBasket(); - return array( + return [ "bestellungErfolgtUeberLogin" => !$isGuestOrder, "kundeSeit" => $registerDate, "anzahlBestellungen" => $user->getOrderCount(), @@ -189,8 +186,8 @@ protected function getRiscs() "anzahlProdukteImWarenkorb" => $basket->getItemsCount(), "negativeZahlungsinformation" => self::RISCS_NO_INFO, "risikoartikelImWarenkorb" => false, - "logistikDienstleister" => "" - ); + "logistikDienstleister" => "", + ]; } protected function getRegisteredCustomerStatus($user) @@ -200,7 +197,7 @@ protected function getRegisteredCustomerStatus($user) if (count($userGroups)) { /** @var $userGroup Groups */ foreach ($userGroups as $userGroup) { - if( $userGroup->getId() == "oxidnotyetordered" ) { + if ($userGroup->getId() == "oxidnotyetordered") { return self::RISCS_NEUKUNDE; } } @@ -212,10 +209,11 @@ protected function getRegisteredCustomerStatus($user) * * @return string|null */ - protected function getSalutation() { + protected function getSalutation() + { $salutation = $this->getUser()->oxuser__oxsal->value; - if( $salutation ) { - if( key_exists($salutation, $this->salutationMapping) ) { + if ($salutation) { + if (key_exists($salutation, $this->salutationMapping)) { return $this->salutationMapping[$salutation]; } } @@ -227,9 +225,10 @@ protected function getSalutation() { * * @return false|null|string */ - protected function convertBirthday() { + protected function convertBirthday() + { $birthday = $this->getUser()->oxuser__oxbirthdate->value; - if( $birthday && $birthday != "0000-00-00" ) { + if ($birthday && $birthday != "0000-00-00") { return $this->getDate($birthday); } return null; @@ -240,20 +239,21 @@ protected function convertBirthday() { * * @return array */ - protected function getBillingAddress() { + protected function getBillingAddress() + { $user = $this->getUser(); $countryIso2 = $this->getBillingCountryIso2($user->oxuser__oxcountryid->value); $fullStreet = $this->getFullStreet($user->oxuser__oxstreet->value, $user->oxuser__oxstreetnr->value); - $address = array( + $address = [ "strasseHausNr" => $fullStreet, "adresszusatz" => $user->oxuser__oxaddinfo->value, "plz" => $user->oxuser__oxzip->value, "ort" => $user->oxuser__oxcity->value, - "land" => $countryIso2 - ); + "land" => $countryIso2, + ]; return $address; } @@ -263,22 +263,23 @@ protected function getBillingAddress() { * * @return array */ - protected function convertShippingAddress() { + protected function convertShippingAddress() + { $user = $this->getUser(); - $address = array( + $address = [ "vorname" => $user->oxuser__oxfname->value, "nachname" => $user->oxuser__oxlname->value, - "packstation" => false - ); + "packstation" => false, + ]; $delivadr = $this->getShippingAddress(); - if( $delivadr ) { + if ($delivadr) { $countryIso2 = $this->getShippingCountryIso($delivadr->oxaddress__oxcountryid->value); $street = $delivadr->oxaddress__oxstreet->value; $streetNr = $delivadr->oxaddress__oxstreetnr->value; $fullStreet = $this->getFullStreet($street, $streetNr); - $address = array( + $address = [ "vorname" => $delivadr->oxaddress__oxfname->value, "nachname" => $delivadr->oxaddress__oxlname->value, "strasseHausNr" => $fullStreet, @@ -286,10 +287,9 @@ protected function convertShippingAddress() { "plz" => $delivadr->oxaddress__oxzip->value, "ort" => $delivadr->oxaddress__oxcity->value, "land" => $countryIso2, - "packstation" => EasyCreditHelper::hasPackstationFormat($street, $streetNr) - ); - } - else { + "packstation" => EasyCreditHelper::hasPackstationFormat($street, $streetNr), + ]; + } else { $address = array_merge($address, $this->getBillingAddress()); } @@ -304,7 +304,7 @@ protected function convertShippingAddress() { */ protected function getBillingCountryIso2($countryId) { - if(!$this->billingCountryIso ) { + if (!$this->billingCountryIso) { $this->billingCountryIso = $this->getCountryIso2ByCountryId($countryId); } return $this->billingCountryIso; @@ -318,7 +318,7 @@ protected function getBillingCountryIso2($countryId) */ protected function getShippingCountryIso($countryId) { - if(!$this->shippingCountryIso ) { + if (!$this->shippingCountryIso) { $this->shippingCountryIso = $this->getCountryIso2ByCountryId($countryId); } return $this->shippingCountryIso; @@ -393,7 +393,8 @@ protected function getBaseUrl() * * @return Session */ - protected function getSession() { + protected function getSession() + { $session = $this->getDic()->getSession(); return $session; @@ -404,7 +405,8 @@ protected function getSession() { * * @return Config */ - protected function getConfig() { + protected function getConfig() + { $config = $this->getDic()->getConfig(); return $config; @@ -425,7 +427,8 @@ protected function getWebshopId() * * @return int */ - protected function getInstalmentTime() { + protected function getInstalmentTime() + { return self::DEFAULT_INSTALMENT_TIME; } @@ -435,7 +438,8 @@ protected function getInstalmentTime() { * * @return Basket */ - protected function getBasket() { + protected function getBasket() + { return $this->basket; } @@ -455,9 +459,10 @@ protected function convertBillingAddress() * * @return object oxaddress */ - protected function getShippingAddress() { + protected function getShippingAddress() + { - return $this->shippingAddress; + return $this->shippingAddress; } /** @@ -465,7 +470,8 @@ protected function getShippingAddress() { * * @return User */ - protected function getUser() { + protected function getUser() + { return $this->user; } @@ -475,7 +481,8 @@ protected function getUser() { * * @param string $shopEdition */ - public function setShopEdition($shopEdition) { + public function setShopEdition($shopEdition) + { $this->shopEdition = $shopEdition; } @@ -542,7 +549,7 @@ public function setModuleVersion($moduleVersion) private function getCountryIso2ByCountryId($countryId) { $country = oxNew(Country::class); - if($country->load($countryId)) { + if ($country->load($countryId)) { return $country->oxcountry__oxisoalpha2->value; } return ""; @@ -555,11 +562,11 @@ private function getCountryIso2ByCountryId($countryId) */ protected function getResponseUrls() { - return array( + return [ 'urlAbbruch' => $this->getAbortUrl(), 'urlErfolg' => $this->getSuccessUrl(), - 'urlAblehnung' => $this->getRejectUrl() - ); + 'urlAblehnung' => $this->getRejectUrl(), + ]; } /** @@ -570,12 +577,54 @@ protected function getResponseUrls() protected function getPersonals() { $user = $this->getUser(); - return array( + $this->validateUser($user); + return [ 'anrede' => $this->getSalutation(), 'vorname' => $user->oxuser__oxfname->value, 'nachname' => $user->oxuser__oxlname->value, - 'geburtsdatum' => $this->convertBirthday() - ); + 'geburtsdatum' => $this->convertBirthday(), + ]; + } + + private function validateUser($user) + { + $fname = $user->oxuser__oxfname->value; + $lname = $user->oxuser__oxlname->value; + $fnameLength = strlen($fname); + $lnameLength = strlen($lname); + + if ($fnameLength < 2) { + throw new EasyCreditException('OXPS_EASY_CREDIT_ERROR_FNAME_SMALL'); + } + + if ($fnameLength > 27) { + throw new EasyCreditException('OXPS_EASY_CREDIT_ERROR_FNAME_LONG'); + } + + if ($lnameLength < 2) { + throw new EasyCreditException('OXPS_EASY_CREDIT_ERROR_LNAME_SMALL'); + } + + if ($lnameLength > 27) { + throw new EasyCreditException('OXPS_EASY_CREDIT_ERROR_LNAME_LONG'); + } + + // Define the allowed character set + $pattern = '/[^-a-zÀ-žA-ZäüößÄÖÜěščřžůďťňĎŇŤŠČŘŽŮĚO\'\.\, ]/'; + + // Check for invalid characters in first name + if (preg_match_all($pattern, $fname, $matches)) { + $invalidChars = implode(', ', array_unique($matches[0])); + $exceptionMessage = Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_FNAME_CONTAINS_INVALID_CHAR'); + throw new EasyCreditException(sprintf($exceptionMessage, $invalidChars)); + } + + // Check for invalid characters in last name + if (preg_match_all($pattern, $lname, $matches)) { + $invalidChars = implode(', ', array_unique($matches[0])); + $exceptionMessage = Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_LNAME_CONTAINS_INVALID_CHAR'); + throw new EasyCreditException(sprintf($exceptionMessage, $invalidChars)); + } } /** @@ -586,11 +635,11 @@ protected function getPersonals() protected function getContacts() { $customer = $this->getUser(); - $contacts = array( - 'email' => $customer->oxuser__oxusername->value - ); + $contacts = [ + 'email' => $customer->oxuser__oxusername->value, + ]; $phoneNumber = $customer->oxuser__oxfon->value; - if( $this->isValidPhoneNumber($phoneNumber) ) { + if ($this->isValidPhoneNumber($phoneNumber)) { $contacts["mobilfunknummer"] = $phoneNumber; $contacts["pruefungMobilfunknummerUebergehen"] = true; } @@ -606,7 +655,7 @@ protected function getContacts() */ protected function isValidPhoneNumber($phoneNumber) { - if( empty($phoneNumber) ) { + if (empty($phoneNumber)) { return false; } return preg_match('/^[\+]?[\d \- ]+$/', $phoneNumber); //leading +, then numbers, minus and spaces @@ -620,9 +669,9 @@ protected function isValidPhoneNumber($phoneNumber) protected function getFurtherCustomerInfo() { $customer = $this->getUser(); - return array( + return [ 'telefonnummer' => $customer->oxuser__oxfon->value, - ); + ]; } /** @@ -632,10 +681,10 @@ protected function getFurtherCustomerInfo() */ protected function getTechnicals() { - return array( + return [ 'shopSystemHersteller' => "OXID eShop " . $this->getShopSystem(), - 'shopSystemModulversion' => $this->getModuleVersion() - ); + 'shopSystemModulversion' => $this->getModuleVersion(), + ]; } /** @@ -682,19 +731,19 @@ protected function getBasketPositionInfo($basketitem, $basketproduct) $price = $unitPrice->getPrice(); } - return array( + return [ "produktbezeichnung" => $basketitem->getTitle(), "menge" => $basketitem->getAmount(), "preis" => $price, "hersteller" => $manufacturerTitle, "produktkategorie" => $categoryTitle, - "artikelnummern" => array( - array( + "artikelnummern" => [ + [ "nummerntyp" => self::ARTICLE_GTIN, "nummer" => $basketproduct->oxarticles__oxartnum->value, - ) - ) - ); + ], + ], + ]; } /** @@ -705,11 +754,11 @@ protected function getBasketPositionInfo($basketitem, $basketproduct) */ protected function getDate($date) { - if( empty($date) || $date < 1 ) { + if (empty($date) || $date < 1) { return ""; } - if( strtotime($date) === false ) { + if (strtotime($date) === false) { return ""; } @@ -767,4 +816,4 @@ public static function generatePaymentHash($initializationData) $paymentHash = md5(json_encode($initializationData)); return $paymentHash; } -} \ No newline at end of file +} diff --git a/Core/Helper/EasyCreditInitializeRequestBuilderInterface.php b/Core/Helper/EasyCreditInitializeRequestBuilderInterface.php index 04a586f..39dbebc 100644 --- a/Core/Helper/EasyCreditInitializeRequestBuilderInterface.php +++ b/Core/Helper/EasyCreditInitializeRequestBuilderInterface.php @@ -1,14 +1,10 @@ . +. \ No newline at end of file diff --git a/README.md b/README.md index 9588f6c..d38c900 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # OXID Solution Catalyst easyCredit-Ratenkauf Module -# Version 3.0.8 +![latest build](https://github.com/OXIDprojects/easycredit-module/actions/workflows/phpunit.yml/badge.svg) ## Description @@ -29,76 +29,10 @@ Run Composer again to remove Module from vendor composer update ``` -## Changelog +## Bugs and Issues -### Version 1.0.0 +If you experience any bugs or issues, please report them in the section **module Easy Credit** of https://bugs.oxid-esales.com. -* Version for OXID4 installable via FTP +## License -### Version 2.0.0 - -* Version for OXID6 installable via Composer - -### Version 2.0.4 - -* Function-Check for OXID 6.2.3 -* easyCredit Orders are not changable (Discounts, add Articles...) in OXID-Backend - -### Version 2.0.5 - -* Birthday is not required -* Possiblility to use own jqueryUI-Lib in Frontend - -### Version 2.0.6 - -* Fix: Elimination of malfunctions in other payment modules - -### Version 3.0.0 - -* Introduce Namespaces -* No more support for OXID <= v6.0 -* Integrate new API für dealer gateway -* Transaction-Overview in Backend -* Storno in Backend - -### Version 3.0.1 - -* Bugfixes - -### Version 3.0.2 - -* Bugfixes - -### Version 3.0.3 - -* Bugfixes - -### Version 3.0.4 - -* transfer OrderNr to EasyCredit -* remove Ankaufsobergrenze - -### Version 3.0.5 - -* remove Payment-Costs in Checkout -* add better default-values for payment - -### Version 3.0.6 - -* improve Backwards-compatiblity to PHP7.2 -* calculate Rateplan only in Payment-Pricerange (by default 200 < x < 10000) - -### Version 3.0.7 - -* bugfix-release - -### Version 3.0.8 - -* Rebranding easyCredit-Ratenkauf - -### Version 3.0.9 - -## Fix - -* [0007754](https://bugs.oxid-esales.com/view.php?id=7754): fix ModuleChainGenerator that has issue loading EasyCreditPayment - \ No newline at end of file +[GNU GPLv3](https://choosealicense.com/licenses/gpl-3.0/) \ No newline at end of file diff --git a/Tests/.phpunit.result.cache b/Tests/.phpunit.result.cache deleted file mode 100644 index b6b45d4..0000000 --- a/Tests/.phpunit.result.cache +++ /dev/null @@ -1 +0,0 @@ -C:37:"PHPUnit\Runner\DefaultTestResultCache":37047:{a:2:{s:7:"defects";a:64:{s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testInitializeandredirect";i:1;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testInitialize";i:1;s:117:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentNoEasyCredit";i:1;s:114:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentNoStorage";i:3;s:130:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testValidatePaymentEasyCreditPossible";i:3;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testGetNonExisting";i:6;s:108:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testGetExisting";i:6;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testSet";i:6;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testDelete";i:6;s:107:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testProcessUrl";i:6;s:102:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testGetId";i:6;s:104:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testStorage";i:6;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededNoUpdate";i:5;s:148:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededNoUpdateInvalidInterval";i:5;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededUpdateNoLastUpdate";i:5;s:145:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededUpdateWithLastUpdate";i:5;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderFailure";i:1;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testCalculateBasket";i:5;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderInvalidPayment";i:1;s:106:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderNoStorage";i:1;s:123:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithStorageNotInitializing";i:1;s:113:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithEmptyStorage";i:1;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithStorageInitialized";i:1;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderStateOkWithConfirmException";i:1;s:104:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderStateOk";i:1;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoValidate";i:1;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoResponse";i:1;s:120:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoWsMessages";i:1;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoMessages";i:1;s:122:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoFirstMessage";i:1;s:129:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedFirstMessageConfirmed";i:1;s:126:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutStorageVorgangskennung";i:1;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutFachlicheVorgangskennung";i:1;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutAllgemeineVorgangsdaten";i:1;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutTilgungsplanTxt";i:1;s:116:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutRatenplanTxt";i:1;s:107:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testTilgunsplanTxtNoStorage";i:1;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testgetFInterestsValueWithInterestValue";i:1;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetModuleVersionOk";i:3;s:139:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithBasketItems";i:3;s:152:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithRegisteredUserWithGroups";i:3;s:145:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithSalutationMapping";i:3;s:136:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithBirthday";i:3;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithInvalidBirthday";i:3;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithDeliveryAddress";i:3;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithCountry";i:3;s:144:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithValidPhoneNumber";i:3;s:132:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithDeps";i:3;s:131:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationPopupTest::testGetIFrameUrl";i:3;s:113:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetApiConfigValue";i:3;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetServiceRestFunction";i:3;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testRenderWithEditObjectId";i:4;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateNoEasyCreditOrder";i:3;s:160:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithInAccount";i:3;s:165:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithReportDelivery";i:3;s:168:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithReportDeliveryEnd";i:3;s:157:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithEnding";i:3;s:160:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithAccounted";i:3;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #1";i:4;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #2";i:4;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #3";i:4;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #4";i:4;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #5";i:3;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #0";i:4;}s:5:"times";a:196:{s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testInitializeandredirect";d:0.046;s:120:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetEasyCreditDetails";d:0.05;s:129:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetEasyCreditDetailsException";d:0.178;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetEasyCreditDetailsDeps";d:1.003;s:125:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testIsInitializedEmptyStorage";d:0.242;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testIsInitializedEmptyVorgangskennung";d:0.232;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testIsInitializedInvalidHash";d:0.228;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testInitialize";d:0.005;s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetInstalmentDecision";d:0.223;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetTbVorgangskennungNull";d:0.226;s:148:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testLoadEasyCreditFinancialInformationWithoutStorage";d:0.227;s:123:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetFormattedPaymentPlan";d:0.251;s:104:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testCall";d:0.682;s:106:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditDispatcherTest::testGetDic";d:0.08;s:117:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentNoEasyCredit";d:0.005;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentEasyCreditWithoutPaymentPlan";d:0.061;s:115:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentEasyCredit";d:0.055;s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentEasyCreditNoLogo";d:0.059;s:114:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentNoStorage";d:0.048;s:114:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetTilgungsplanText";d:0.048;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetTilgungsplanTextEmpty";d:0.048;s:129:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetUrlVorvertraglicheInformationen";d:0.065;s:134:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetUrlVorvertraglicheInformationenEmpty";d:0.033;s:112:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentPlanTxt";d:0.039;s:117:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentPlanTxtEmpty";d:0.036;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditOrderTest::testGetPaymentPlanTxtEmptyStandardDic";d:0.041;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetDic";d:0.057;s:106:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetBasket";d:0.054;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsEasyCreditPermittedNoFrontend";d:0.073;s:117:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsEasyCreditPossible";d:0.474;s:129:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsEasyCreditPossibleNotPermitted";d:0.427;s:132:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsEasyCreditPossibleAddressMismatch";d:0.46;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsEasyCreditPossibleExampleCalculation";d:0.275;s:126:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetExampleCalculationResponse";d:0.023;s:123:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetExampleCalculationPrice";d:0.043;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsAddressMismatchWithDelAddress";d:0.057;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsAddressMismatchWithDelAddressAndUser";d:0.009;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsForeignAddressWithDelAddress";d:0.044;s:130:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsForeignAddressWithoutDelAddress";d:0.041;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsPackstationWithDelAddress";d:0.042;s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsPackstationWithDelUser";d:0.043;s:112:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testValidatePayment";d:0.057;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testValidatePaymentEasyCreditNotPossible";d:0.471;s:130:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testValidatePaymentEasyCreditPossible";d:0.055;s:153:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testValidatePaymentEasyCreditPossibleAddProfileDataException";d:0.039;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testAddProfileDataWithBirthDate";d:0.052;s:125:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testAddProfileDataWithSalutation";d:0.081;s:113:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testLoadAgreementTxt";d:0.043;s:117:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testIsProfileDataMissing";d:0.037;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testHasSalutation";d:0.036;s:120:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetValidatedDateOfBirth";d:0.034;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetValidatedDateOfBirthInFuture";d:0.04;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\EasyCreditPaymentTest::testGetValidatedSalutation";d:0.033;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteJsonRequestWithoutHttpMethod";d:0.022;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteJsonRequestWithoutServiceUrl";d:0.02;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteJsonRequestWithData";d:0.026;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteHttpRequestWithoutHttpMethod";d:0.021;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteHttpRequestWithWrongHttpMethod";d:0.021;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteHttpRequestWithoutServiceUrl";d:0.021;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditHttpClientTest::testExecuteHttpRequestWithData";d:0.021;s:126:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditResponseValidatorTest::testValidateMissingScheme";d:0.021;s:138:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditResponseValidatorTest::testValidateWithValidationSchemeValid";d:0.02;s:140:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditResponseValidatorTest::testValidateWithValidationSchemeInvalid";d:0.045;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditWebServiceClientTest::testSetFunctionOnlyFunction";d:0.02;s:130:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditWebServiceClientTest::testSetFunctionWithSprintfArgs";d:0.018;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Api\EasyCreditWebServiceClientTest::testSetFunctionWithEmptySprintfArgs";d:0.019;s:107:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\CrossCutting\EasyCreditLoggingTest::testLog";d:0.023;s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\CrossCutting\EasyCreditLoggingTest::testLogRequestEnabled";d:0.023;s:122:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\CrossCutting\EasyCreditLoggingTest::testLogRequestDisabled";d:0.02;s:113:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetApiConfigValue";d:0.026;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetServiceHttpMethodExisting";d:0.021;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetServiceHttpMethodNonExisting";d:0.026;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetServiceRestFunction";d:0.02;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetServiceRestFunctionArguments";d:0.02;s:106:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetBaseUrl";d:0.02;s:108:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetWebShopId";d:0.022;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetWebShopToken";d:0.022;s:115:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetValidationScheme";d:0.02;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetRedirectUrl";d:0.022;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetEasyCreditInstalmentPaymentId";d:0.02;s:117:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditApiConfigTest::testGetEasyCreditModuleId";d:0.022;s:105:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicConfigTest::testGetShopId";d:0.025;s:109:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicConfigTest::testGetSslShopUrl";d:0.026;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicConfigTest::testGetConfigParam";d:0.024;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicConfigTest::testSetConfigParam";d:0.024;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicConfigTest::testSaveShopConfVar";d:0.023;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testGetNonExisting";d:0.026;s:108:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testGetExisting";d:0.024;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testSet";d:0.024;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testDelete";d:0.028;s:107:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testProcessUrl";d:0.026;s:102:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testGetId";d:0.023;s:104:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Core\Di\EasyCreditDicSessionTest::testStorage";d:0.024;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededNoUpdate";d:0.042;s:148:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededNoUpdateInvalidInterval";d:0.065;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededUpdateNoLastUpdate";d:0.07;s:145:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderIfNeededUpdateWithLastUpdate";d:0.071;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testUpdateAquisitionBorderFailure";d:0.019;s:130:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testGetCurrentAquisitionBorderValueNull";d:0.042;s:126:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testGetCurrentAquisitionBorderValue";d:0.064;s:113:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditAquisitionBorderTest::testConsiderInFrontend";d:0.062;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testHasInterestsAmount";d:0.021;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testGetInterestsAmount";d:0.026;s:112:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testGetInterestsAmountNoStorage";d:0.022;s:99:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testSetCostExclude";d:0.023;s:99:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testSetCostInclude";d:0.027;s:102:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testCalcInterestsCost";d:0.03;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditBasketTest::testCalculateBasket";d:0.081;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderInvalidPayment";d:0.005;s:106:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderNoStorage";d:0.002;s:123:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithStorageNotInitializing";d:0.002;s:113:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithEmptyStorage";d:0.002;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithStorageInitialized";d:0.002;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderStateOkWithConfirmException";d:0.002;s:104:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderStateOk";d:0.002;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoValidate";d:0.002;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoResponse";d:0.002;s:120:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoWsMessages";d:0.002;s:118:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoMessages";d:0.002;s:122:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedNoFirstMessage";d:0.002;s:129:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderIsConfirmedFirstMessageConfirmed";d:0.002;s:126:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutStorageVorgangskennung";d:0.003;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutFachlicheVorgangskennung";d:0.003;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutAllgemeineVorgangsdaten";d:0.003;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutTilgungsplanTxt";d:0.003;s:116:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testFinalizeOrderWithoutRatenplanTxt";d:0.002;s:107:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testTilgunsplanTxtNoStorage";d:0.003;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOrderTest::testgetFInterestsValueWithInterestValue";d:0.002;s:115:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testIsEasyCreditInstallmentTrue";d:0.027;s:116:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testIsEasyCreditInstallmentFalse";d:0.029;s:119:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testIsEasyCreditInstallmentByIdTrue";d:0.006;s:120:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testIsEasyCreditInstallmentByIdFalse";d:0.003;s:122:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testGetEasyCreditAquisitionBorderValue";d:0.026;s:123:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testGetFEasyCreditAquisitionBorderValue";d:0.029;s:130:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testGetFEasyCreditAquisitionBorderValueNoValue";d:0.03;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testGetFEasyCreditAquisitionBorderLastUpdate";d:0.029;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testGetEasyCreditAquisitionBorderLastUpdate";d:0.026;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxPaymentTest::testGetEasyCreditAquisitionBorderLastUpdateNoTime";d:0.027;s:107:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxSessionTest::testGetStorageNoStorage";d:0.021;s:112:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Domain\EasyCreditOxSessionTest::testGetStorageExpiredStorage";d:0.023;s:106:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Dto\EasyCreditStorageTest::testHasExpiredAfterCreation";d:0.005;s:110:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Dto\EasyCreditStorageTest::testHasExpiredExpiredLastUpdate";d:2.023;s:121:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetExampleCalculationPriceFromBasket";d:0.03;s:111:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testHasPackstationFormatNormal";d:0.006;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testHasPackstationFormatNumericNoNumericPackStation1";d:0.002;s:133:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testHasPackstationFormatNumericNoNumericPackStation2";d:0.002;s:123:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testHasPackstationFormatNumericPackStation";d:0.002;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testHasPackstationFormatNonNumericPackStation1";d:0.002;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testHasPackstationFormatNonNumericPackStation2";d:0.002;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetShopSystemCE";d:0.024;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetShopSystemPE";d:0.028;s:100:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetShopSystemEE";d:0.028;s:103:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetModuleVersionOk";d:0.038;s:114:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditHelperTest::testGetModuleVersionWrongModuleId";d:0.037;s:139:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithBasketItems";d:0.181;s:152:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithRegisteredUserWithGroups";d:0.116;s:145:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithSalutationMapping";d:0.11;s:136:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithBirthday";d:0.111;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithInvalidBirthday";d:0.094;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithDeliveryAddress";d:0.111;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithCountry";d:0.092;s:144:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithValidPhoneNumber";d:0.097;s:132:"OxidProfessionalServices\EasyCredit\Tests\Unit\Core\Helper\EasyCreditInitializeRequestBuilderTest::testGetInitializationDataWithDeps";d:0.132;s:144:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationPopupTest::testGetExampleCalculationRate";d:0.052;s:128:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationPopupTest::testGetBasket";d:0.057;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationPopupTest::testGetPrice";d:0.057;s:131:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationPopupTest::testGetIFrameUrl";d:0.078;s:139:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testGetExampleCalculationRate";d:0.24;s:160:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testGetExampleCalculationRateHasExampleCalculation";d:0.237;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testHasExampleCalculation";d:0.24;s:134:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testGetExampleCalulation";d:0.02;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testGetExampleCalculationResponse";d:0.02;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testGetAjaxUrl";d:0.022;s:129:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testGetPopupAjaxUrl";d:0.042;s:120:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Component\Widget\EasyCreditExampleCalculationTest::testIsAjax";d:0.022;s:124:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderAddressControllerTest::testRender";d:0.095;s:140:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderAddressControllerTest::testRenderWithEditObjectId";d:0.071;s:127:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testRender";d:0.048;s:143:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testRenderWithEditObjectId";d:0.054;s:154:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditConfirmationResponse";d:0.055;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateNoEasyCreditOrder";d:0.096;s:160:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithInAccount";d:0.094;s:165:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithReportDelivery";d:0.095;s:168:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithReportDeliveryEnd";d:0.093;s:157:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithEnding";d:0.098;s:160:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryStateWithAccounted";d:0.093;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #0";d:0.036;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #1";d:0.032;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #2";d:0.033;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #3";d:0.034;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #4";d:0.038;s:164:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderEasyCreditControllerTest::testGetEasyCreditDeliveryState with data set #5";d:0.097;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderOverviewControllerTest::testGetDeliveryState";d:0.073;s:135:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderOverviewControllerTest::testSendOrderNoOrder";d:0.055;s:137:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderOverviewControllerTest::testSendOrderWithOrder";d:0.061;s:137:"OxidProfessionalServices\EasyCredit\Tests\Unit\Application\Controller\Admin\EasyCreditOrderOverviewControllerTest::testSendOrderNoECOrder";d:0.059;}}} \ No newline at end of file diff --git a/Tests/Config/services.json b/Tests/Config/services.json deleted file mode 100644 index 26f6261..0000000 --- a/Tests/Config/services.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "v1_modellrechnung_durchfuehren": { - "httpMethod": "get", - "restFunction": "/v1/modellrechnung/durchfuehren" - }, - "v1_modellrechnung_guenstigsterRatenplan": { - "httpMethod": "get", - "restFunction": "/v1/modellrechnung/guenstigsterRatenplan" - }, - "not_existing_endpoint": { - "httpMethod": "get", - "restFunction": "/v1/not_existing_endpoint" - }, - "v1_texte_zustimmung": { - "httpMethod": "get", - "restFunction": "/v1/texte/zustimmung/%s" - }, - "v1_vorgang": { - "httpMethod": "post", - "restFunction": "/v1/vorgang" - }, - "v1_decision": { - "httpMethod": "get", - "restFunction": "/v1/vorgang/%s/entscheidung" - } -} diff --git a/Tests/Config/validation.json b/Tests/Config/validation.json deleted file mode 100644 index 74fbc93..0000000 --- a/Tests/Config/validation.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "v1_modellrechnung_durchfuehren": [ - { - "fieldname": "ergebnis", - "required": true - } - ], - "not_existing_endpoint": [ - { - "fieldname": "ergebnis", - "required": true - } - ], - "v1_texte_zustimmung": [ - { - "fieldname": "zustimmungDatenuebertragungPaymentPage", - "required": true - } - ], - "v1_vorgang": [ - { - "fieldname": "tbVorgangskennung", - "required": true - } - ] -} diff --git a/Tests/Unit/Application/Component/Widget/EasyCreditExampleCalculationPopupTest.php b/Tests/Unit/Application/Component/Widget/EasyCreditExampleCalculationPopupTest.php deleted file mode 100644 index 3fddcaa..0000000 --- a/Tests/Unit/Application/Component/Widget/EasyCreditExampleCalculationPopupTest.php +++ /dev/null @@ -1,64 +0,0 @@ -shopkennung = Registry::getConfig()->getConfigParam('oxpsECWebshopId'); - } - - /** - * Tear down test environment - * - */ - public function tearDown(): void - { - parent::tearDown(); - } - - public function testGetExampleCalculationRate(): void - { - $popup = oxNew(EasyCreditExampleCalculationPopup::class); - $this->assertNotNull($popup->getDic()); - } - - public function testGetBasket(): void - { - $popup = oxNew(EasyCreditExampleCalculationPopup::class); - $basket = $popup->getBasket(); - $this->assertNotNull($basket); - $price = $basket->getPrice(); - $this->assertNotNull($price); - $this->assertEquals(0.0, $price->getPrice()); - } - - public function testGetPrice(): void - { - $popup = oxNew(EasyCreditExampleCalculationPopup::class); - $price = $popup->getPrice(); - $this->assertNotNull($price); - $this->assertEquals(0.0, $price->getPrice()); - } - - public function testGetIFrameUrl(): void - { - $popup = oxNew(EasyCreditExampleCalculationPopup::class); - $this->assertEquals('https://ratenkauf.easycredit.de/ratenkauf/content/intern/paymentPageBeispielrechnung.jsf?shopKennung='. $this->shopkennung .'&bestellwert=0', $popup->getIFrameUrl()); - } -} diff --git a/Tests/Unit/Application/Component/Widget/EasyCreditExampleCalculationTest.php b/Tests/Unit/Application/Component/Widget/EasyCreditExampleCalculationTest.php deleted file mode 100644 index 7e68c98..0000000 --- a/Tests/Unit/Application/Component/Widget/EasyCreditExampleCalculationTest.php +++ /dev/null @@ -1,93 +0,0 @@ -assertNull($calculation->getExampleCalculationRate()); - } - - public function testGetExampleCalculationRateHasExampleCalculation(): void - { - $calculation = $this->getMock(EasyCreditExampleCalculation::class, ['hasExampleCalculation']); - $calculation->expects($this->any())->method('hasExampleCalculation')->willReturn(true); - - $this->assertEquals('0,00', $calculation->getExampleCalculationRate()); - } - - public function testHasExampleCalculation(): void - { - $calculation = oxNew(EasyCreditExampleCalculation::class); - - $this->assertFalse($calculation->hasExampleCalculation()); - } - - public function testGetExampleCalulation(): void - { - $response = "dummy"; - - $calculation = $this->getMock(EasyCreditExampleCalculation::class, ['getExampleCalculationResponse']); - $calculation->expects($this->any())->method('getExampleCalculationResponse')->willReturn($response); - - $this->assertEquals($response, $calculation->getExampleCalulation()); - } - - public function testGetExampleCalculationResponse(): void - { - $calculation = $this->getMock(EasyCreditExampleCalculation::class, ['getPrice']); - $calculation->expects($this->any())->method('getPrice')->willReturn(false); - - $this->assertFalse($calculation->getExampleCalculationResponse()); - } - - public function testGetAjaxUrl(): void - { - $calculation = oxNew(EasyCreditExampleCalculation::class); - - $this->assertStringEndsWith('index.php?cl=easycreditexamplecalculation&placeholderId=&ajax=1', $calculation->getAjaxUrl()); - } - - public function testGetPopupAjaxUrl(): void - { - $calculation = oxNew(EasyCreditExampleCalculation::class); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $this->assertEquals($sslShopUrl . 'index.php?cl=easycreditexamplecalculationpopup&ajax=1', $calculation->getPopupAjaxUrl()); - } - - public function testIsAjax(): void - { - $calculation = oxNew(EasyCreditExampleCalculation::class); - - $this->assertFalse($calculation->isAjax()); - } -} diff --git a/Tests/Unit/Application/Controller/Admin/EasyCreditOrderAddressControllerTest.php b/Tests/Unit/Application/Controller/Admin/EasyCreditOrderAddressControllerTest.php deleted file mode 100644 index 0427c35..0000000 --- a/Tests/Unit/Application/Controller/Admin/EasyCreditOrderAddressControllerTest.php +++ /dev/null @@ -1,44 +0,0 @@ -assertEquals('order_address.tpl', $controller->render()); - } - - public function testRenderWithEditObjectId(): void - { - $controller = $this->getMock(EasyCreditOrderAddressController::class, ['getEditObjectId']); - $controller->expects($this->any())->method('getEditObjectId')->willReturn('1'); - - $this->assertEquals('order_address.tpl', $controller->render()); - } -} diff --git a/Tests/Unit/Application/Controller/Admin/EasyCreditOrderEasyCreditControllerTest.php b/Tests/Unit/Application/Controller/Admin/EasyCreditOrderEasyCreditControllerTest.php deleted file mode 100644 index 0dcfc2f..0000000 --- a/Tests/Unit/Application/Controller/Admin/EasyCreditOrderEasyCreditControllerTest.php +++ /dev/null @@ -1,123 +0,0 @@ -assertEquals('oxpseasycredit_order_easycredit.tpl', $controller->render()); - } - - public function testRenderWithEditObjectId(): void - { - $controller = $this->getMockBuilder(EasyCreditOrderEasyCreditController::class) - ->onlyMethods(['getEditObjectId', 'hasEasyCreditPayment', 'getEasyCreditDeliveryState']) - ->getMock(); - $controller->expects($this->any())->method('getEditObjectId')->willReturn('1'); - $controller->expects($this->any())->method('hasEasyCreditPayment')->willReturn(true); - $controller->expects($this->any())->method('getEasyCreditDeliveryState')->willReturn('text'); - - $this->assertEquals('oxpseasycredit_order_easycredit.tpl', $controller->render()); - } - - public function testGetEasyCreditConfirmationResponse(): void - { - $response = new \stdClass(); - $response->result = 'test'; - - $order = oxNew(Order::class); - $order->oxorder__ecredconfirmresponse = new Field(base64_encode(serialize($response))); - - $controller = $this->getMockBuilder(EasyCreditOrderEasyCreditController::class)->onlyMethods(['getOrder'])->getMock(); - $controller->expects($this->any())->method('getOrder')->willReturn($order); - - $this->assertEquals('{ - "result": "test" -}', $controller->getEasyCreditConfirmationResponse()); - } - - public function deliveryStateDataProvider() - { - $response1 = []; - $expected1 = 'Der Händlerstatus konnte nicht abgefragt werden'; - - $stdClass2 = new \stdClass(); - $stdClass2->haendlerstatusV2 = 'IN_ABRECHNUNG'; - $response2 = [0 => $stdClass2]; - $expected2 = 'In Abrechnung'; - - $stdClass3 = new \stdClass(); - $stdClass3->haendlerstatusV2 = 'LIEFERUNG_MELDEN'; - $response3 = [0 => $stdClass3]; - $expected3 = 'Lieferung melden'; - - $stdClass4 = new \stdClass(); - $stdClass4->haendlerstatusV2 = 'LIEFERUNG_MELDEN_AUSLAUFEND'; - $response4 = [0 => $stdClass4]; - $expected4 = 'Lieferung melden (auslaufend)'; - - $expected5 = 'Auslaufend'; - $stdClass5 = new \stdClass(); - $stdClass5->haendlerstatusV2 = 'AUSLAUFEND'; - $response5 = [0 => $stdClass5]; - - return [ - [$response1, $expected1], - [$response2, $expected2], - [$response3, $expected3], - [$response4, $expected4], - [$response5, $expected5], - ]; - } - - /** - * @dataProvider deliveryStateDataProvider - * @throws \OxidEsales\Eshop\Core\Exception\SystemComponentException - */ - public function testGetEasyCreditDeliveryState($response, $expected) - { - $tradingApiService = $this->getMockBuilder(EasyCreditTradingApiAccess::class)->onlyMethods(['getOrderData'])->getMock(); - $tradingApiService->expects($this->once())->method('getOrderData')->with(false)->willReturn($response); - - $controller = $this->getMockBuilder(EasyCreditOrderEasyCreditController::class) - ->onlyMethods(['getService']) - ->getMock(); - $controller->expects($this->once())->method('getService') - ->willReturn($tradingApiService); - - $this->assertEquals($expected, - $controller->getEasyCreditDeliveryState()); - } -} diff --git a/Tests/Unit/Application/Controller/Admin/EasyCreditOrderOverviewControllerTest.php b/Tests/Unit/Application/Controller/Admin/EasyCreditOrderOverviewControllerTest.php deleted file mode 100644 index b52fede..0000000 --- a/Tests/Unit/Application/Controller/Admin/EasyCreditOrderOverviewControllerTest.php +++ /dev/null @@ -1,105 +0,0 @@ -oxorder__functionalid = new Field('functionalId'); - $tradingApiService = $this->getMockBuilder(EasyCreditTradingApiAccess::class) - ->onlyMethods(['getOrderState']) - ->setConstructorArgs([$order]) - ->getMock(); - $tradingApiService->expects($this->once())->method('getOrderState')->willReturn($result); - - $controller = $this->getMockBuilder(EasyCreditOrderOverviewController::class) - ->onlyMethods(['getService'])->getMock(); - $controller->expects($this->once()) - ->method('getService') - ->willReturn($tradingApiService); - $this->assertEquals($result, $controller->getDeliveryState($order)); - } - - public function testSendOrderNoOrder() - { - $controller = $this->getMockBuilder(EasyCreditOrderOverviewController::class) - ->onlyMethods(['getService', 'getEditObjectId'])->getMock(); - $controller->expects($this->never()) - ->method('getService'); - $controller->expects($this->exactly(2)) - ->method('getEditObjectId') - ->willReturn(null); - $this->assertNull($controller->sendOrder()); - } - - public function testSendOrderWithOrder() - { - $order = oxNew(Order::class); - $order->oxorder__functionalid = new Field('functionalId'); - - $orderData = new \stdClass(); - $orderData->haendlerstatusV2 = 'returnstate'; - $state = [0 => $orderData]; - - $tradingApiService = $this->getMockBuilder(EasyCreditTradingApiAccess::class) - ->setConstructorArgs([$order]) - ->onlyMethods(['setOrderDeliveredState', 'getOrderData']) - ->getMock(); - $tradingApiService->expects($this->once())->method('setOrderDeliveredState')->willReturn(null); - $tradingApiService->expects($this->once())->method('getOrderData')->willReturn($state); - $controller = $this->getMockBuilder(EasyCreditOrderOverviewController::class) - ->onlyMethods(['getService','loadFunctionalIdFromOrder','loadOrder'])->getMock(); - $controller->expects($this->once()) - ->method('loadOrder') - ->willReturn($order); - $controller->expects($this->once()) - ->method('loadFunctionalIdFromOrder') - ->willReturn('functionalId'); - $controller->expects($this->once())->method('getService')->willReturn($tradingApiService); - - $controller->sendOrder(); - } - - public function testSendOrderNoECOrder() - { - $order = oxNew(Order::class); - - $tradingApiService = $this->getMockBuilder(EasyCreditTradingApiAccess::class) - ->setConstructorArgs([$order]) - ->onlyMethods(['setOrderDeliveredState']) - ->getMock(); - $tradingApiService->expects($this->never())->method('setOrderDeliveredState'); - - $controller = $this->getMockBuilder(EasyCreditOrderOverviewController::class) - ->onlyMethods(['getService','loadFunctionalIdFromOrder'])->getMock(); - $controller->expects($this->once()) - ->method('loadFunctionalIdFromOrder') - ->willReturn(null); - - $controller->expects($this->never())->method('getService'); - - $controller->sendOrder(); - } -} \ No newline at end of file diff --git a/Tests/Unit/Application/Controller/EasyCreditDispatcherTest.php b/Tests/Unit/Application/Controller/EasyCreditDispatcherTest.php deleted file mode 100644 index bb843dc..0000000 --- a/Tests/Unit/Application/Controller/EasyCreditDispatcherTest.php +++ /dev/null @@ -1,438 +0,0 @@ -getMock('oxConfig', [], []); - - $session = oxNew(EasyCreditDicSession::class, $oxSession); - $mockApiConfig = oxNew(EasyCreditApiConfig::class, EasyCreditDicFactory::getApiConfigArray()); - $mockLogging = $this->getMock(EasyCreditLogging::class, [], [[]]); - $mockPayloadFactory = $this->getMock(EasyCreditPayloadFactory::class, [], []); - $mockDicConfig = $this->getMock(EasyCreditDicConfig::class, [], [$mockOxConfig]); - - $mockDic = oxNew( - EasyCreditDic::class, - $session, - $mockApiConfig, - $mockPayloadFactory, - $mockLogging, - $mockDicConfig - ); - - return $mockDic; - } - - public function testInitializeandredirect(): void - { - $this->markTestSkipped('Does not run, investigate and fix'); - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['isInitialized', 'initialize', 'getDic']); - $dispatcher->expects($this->any())->method('isInitialized')->willReturn(false); - $dispatcher->expects($this->any())->method('initialize')->willReturn(null); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - $dispatcher->setUser($user); - - $this->assertEquals('payment', $dispatcher->initializeandredirect()); - } - - public function testGetEasyCreditDetails(): void - { - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['processEasyCreditDetails']); - $dispatcher->expects($this->any())->method('processEasyCreditDetails')->willReturn(null); - - $this->assertEquals('order', $dispatcher->getEasyCreditDetails()); - } - - public function testGetEasyCreditDetailsException(): void - { - $dic = $this->buildDic(oxNew(EasyCreditSession::class)); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic', 'processEasyCreditDetails']); - $dispatcher->expects($this->any())->method('processEasyCreditDetails')->willThrowException(new \Exception('test')); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testGetEasyCreditDetailsDeps(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew('oxprice'); - $price->setPrice(0.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $user = oxNew(User::class); - - $paymentHash = $this->getPaymentHash($user, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic', 'call']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $response = new \stdClass(); - $entscheidung = new \stdClass(); - $entscheidung->entscheidungsergebnis = EasyCreditDispatcherController::INSTALMENT_DECISION_OK; - $response->entscheidung = $entscheidung; - $dispatcher->expects($this->any())->method('call')->willReturn($response); - - $dispatcher->setUser($user); - - - $this->assertEquals('order', $dispatcher->getEasyCreditDetails()); - } - - public function testIsInitializedEmptyStorage(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testIsInitializedEmptyVorgangskennung(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - null, - null, - null, - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testIsInitializedInvalidHash(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'dummy', - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testInitialize(): void - { - $this->markTestSkipped('Does not run, investigate and fix'); - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['isInitialized', 'getDic', 'call']); - $dispatcher->expects($this->any())->method('isInitialized')->willReturn(false); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $response = new \stdClass(); - $response->tbVorgangskennung = 'tbVorgangskennung'; - $response->fachlicheVorgangskennung = 'fachlicheVorgangskennung'; - $dispatcher->expects($this->any())->method('call')->willReturn($response); - - $dispatcher->setUser($user); - - $this->assertEquals('payment', $dispatcher->initializeandredirect()); - } - - public function testGetInstalmentDecision(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic', 'call']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $response = new \stdClass(); - $dispatcher->expects($this->any())->method('call')->willReturn($response); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testGetTbVorgangskennungNull(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['isInitialized', 'getDic', 'call']); - $dispatcher->expects($this->any())->method('isInitialized')->willReturn(true); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - - $response = new \stdClass(); - $dispatcher->expects($this->any())->method('call')->willReturn($response); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testLoadEasyCreditFinancialInformationWithoutStorage(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic', 'call', 'isInitialized', 'getTbVorgangskennung']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - $dispatcher->expects($this->any())->method('isInitialized')->willReturn(true); - $dispatcher->expects($this->any())->method('getTbVorgangskennung')->willReturn('dummy'); - - $response = new \stdClass(); - $entscheidung = new \stdClass(); - $entscheidung->entscheidungsergebnis = EasyCreditDispatcherController::INSTALMENT_DECISION_OK; - $response->entscheidung = $entscheidung; - $dispatcher->expects($this->any())->method('call')->willReturn($response); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testGetFormattedPaymentPlan(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic', 'call', 'isInitialized']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - $dispatcher->expects($this->any())->method('isInitialized')->willReturn(true); - - $dispatcher->expects($this->any())->method('call')->willReturnCallback( - function($endpoint) { - switch ($endpoint) { - case EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_DECISION: - $decisionResponse = new \stdClass(); - $entscheidung = new \stdClass(); - $entscheidung->entscheidungsergebnis = EasyCreditDispatcherController::INSTALMENT_DECISION_OK; - $decisionResponse->entscheidung = $entscheidung; - return $decisionResponse; - - case EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_VORGANG: - $vorgangResponse = new \stdClass(); - $vorgangResponse->allgemeineVorgangsdaten = 'allgemeineVorgangsdaten'; - $vorgangResponse->tilgungsplanText = 'tilgungsplanText'; - return $vorgangResponse; - - case EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_FINANCIAL_INFORMATION: - $vorgangResponse = new \stdClass(); - $vorgangResponse->allgemeineVorgangsdaten = 'allgemeineVorgangsdaten'; - $vorgangResponse->tilgungsplanText = 'tilgungsplanText'; - return $vorgangResponse; - - case EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_FINANZIERUNG: - $ratenPlanResponse = new \stdClass(); - $paymentPlan = new \stdClass(); - $paymentPlan->zahlungsplan = new \stdClass(); - $ratenPlanResponse->ratenplan = $paymentPlan; - return $ratenPlanResponse; - } - } - ); - - $dispatcher->setUser($user); - - - $this->assertEquals('order', $dispatcher->getEasyCreditDetails()); - } - - public function testCall(): void - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $user = oxNew(User::class); - - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['getDic', 'isInitialized', 'getInstalmentDecision']); - $dispatcher->expects($this->any())->method('getDic')->willReturn($dic); - $dispatcher->expects($this->any())->method('isInitialized')->willReturn(true); - $dispatcher->expects($this->any())->method('getInstalmentDecision')->willReturn(EasyCreditDispatcherController::INSTALMENT_DECISION_OK); - - $dispatcher->setUser($user); - - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - public function testGetDic(): void - { - $dispatcher = $this->getMock(EasyCreditDispatcherController::class, ['processEasyCreditDetails']); - $dispatcher->expects($this->any())->method('processEasyCreditDetails')->willThrowException(new \Exception('test')); - - $this->assertEquals('payment', $dispatcher->getEasyCreditDetails()); - } - - protected function getPaymentHash($oxUser, $oxBasket, $dic): string - { - return md5(json_encode($this->getCurrentInitializationData($oxUser, $oxBasket, $dic))); - } - - protected function getCurrentInitializationData($oUser, $oBasket, $dic) - { - $requestBuilder = oxNew(EasyCreditInitializeRequestBuilder::class); - - $requestBuilder->setUser($oUser); - $requestBuilder->setBasket($oBasket); - $requestBuilder->setShippingAddress($this->getShippingAddress()); - - $shopEdition = EasyCreditHelper::getShopSystem($this->getConfig()->getActiveShop()); - $requestBuilder->setShopEdition($shopEdition); - - $moduleVersion = EasyCreditHelper::getModuleVersion($dic); - $requestBuilder->setModuleVersion($moduleVersion); - - $requestBuilder->setBaseLanguage(Registry::getLang()->getBaseLanguage()); - - return $requestBuilder->getInitializationData(); - } - - protected function getShippingAddress() - { - /** @var $oOrder Order */ - $oOrder = oxNew(Order::class); - return $oOrder->getDelAddressInfo(); - } -} diff --git a/Tests/Unit/Application/Controller/EasyCreditOrderTest.php b/Tests/Unit/Application/Controller/EasyCreditOrderTest.php deleted file mode 100644 index 3da2fc6..0000000 --- a/Tests/Unit/Application/Controller/EasyCreditOrderTest.php +++ /dev/null @@ -1,284 +0,0 @@ -getMock(Config::class, [], []); - - $session = oxNew(EasyCreditDicSession::class, $oxSession); - $mockApiConfig = oxNew(EasyCreditApiConfig::class, EasyCreditDicFactory::getApiConfigArray()); - $mockLogging = $this->getMock(EasyCreditLogging::class, [], [[]]); - $mockPayloadFactory = $this->getMock(EasyCreditPayloadFactory::class, [], []); - $mockDicConfig = $this->getMock(EasyCreditDicConfig::class, [], [$mockOxConfig]); - - $mockDic = oxNew( - EasyCreditDic::class, - $session, - $mockApiConfig, - $mockPayloadFactory, - $mockLogging, - $mockDicConfig - ); - - return $mockDic; - } - - public function testGetPaymentNoEasyCredit() - { - $this->markTestSkipped('Empty order has no initialized payment'); - $order = oxNew(Order::class); - $this->assertNotNull($order->getPayment()); - } - - public function testGetPaymentEasyCreditWithoutPaymentPlan() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $payment = oxNew(Payment::class); - $payment->setId(EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $order = $this->getMock(EasyCreditOrder::class, ['getDic', 'parentGetPayment']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - $order->expects($this->any())->method('parentGetPayment')->willReturn($payment); - - $this->assertNull($order->getPayment()); - } - - public function testGetPaymentEasyCredit() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $text = 'payment plan'; - $storage->setRatenplanTxt($text); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $payment = oxNew(Payment::class); - $payment->oxpayments__oxdesc = new Field('test payment'); - $payment->setId(EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $order = $this->getMock(EasyCreditOrder::class, ['getDic', 'parentGetPayment']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - $order->expects($this->any())->method('parentGetPayment')->willReturn($payment); - - $this->assertNull($order->getPayment()); - } - - public function testGetPaymentEasyCreditNoLogo() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $text = 'payment plan'; - $storage->setRatenplanTxt($text); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $payment = oxNew(Payment::class); - $payment->oxpayments__oxdesc = new Field('test payment'); - $payment->setId(EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $viewConfig = $this->getMock(ViewConfig::class, ['getModulePath']); - $viewConfig->expects($this->any())->method('getModulePath')->willThrowException(new \Exception('TEST')); - - $order = $this->getMock(EasyCreditOrder::class, ['getDic', 'parentGetPayment', 'getViewConfig']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - $order->expects($this->any())->method('parentGetPayment')->willReturn($payment); - $order->expects($this->any())->method('getViewConfig')->willReturn($viewConfig); - - $this->assertNull($order->getPayment()); - } - - public function testGetPaymentNoStorage() - { - //$this->expectException(PHPUnit_Framework_Error_Warning::class); - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $payment = oxNew(Payment::class); - $payment->oxpayments__oxdesc = new Field('test payment'); - $payment->setId(EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $order = $this->getMock(EasyCreditOrder::class, ['getDic', 'parentGetPayment']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - $order->expects($this->any())->method('parentGetPayment')->willReturn($payment); - - $this->assertNull($order->getPayment()); - } - - public function testGetTilgungsplanText() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $tilgungsplanTxt = 'TilgungsplanText'; - $storage->setTilgungsplanTxt($tilgungsplanTxt); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $order = $this->getMock(EasyCreditOrder::class, ['getDic']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertEquals($tilgungsplanTxt, $order->getTilgungsplanTxt()); - } - - public function testGetTilgungsplanTextEmpty() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $order = $this->getMock(EasyCreditOrder::class, ['getDic']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertNull($order->getTilgungsplanTxt()); - } - - public function testGetUrlVorvertraglicheInformationen() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $url = 'https://test.url'; - $allgemeineVorgangsdaten = new \stdClass(); - $allgemeineVorgangsdaten->urlVorvertraglicheInformationen = $url; - $storage->setAllgemeineVorgangsdaten($allgemeineVorgangsdaten); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $order = $this->getMock(EasyCreditOrderController::class, ['getDic']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertEquals($url, $order->getUrlVorvertraglicheInformationen()); - } - - public function testGetUrlVorvertraglicheInformationenEmpty() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $order = $this->getMock(EasyCreditOrderController::class, ['getDic']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertNull($order->getUrlVorvertraglicheInformationen()); - } - - public function testGetPaymentPlanTxt() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'b8d01510bbbf5fe767f068122ba0b0c4', - 0.0 - ); - $text = 'payment plan'; - $storage->setRatenplanTxt($text); - $session->setVariable(EasyCreditSession::API_CONFIG_STORAGE, serialize($storage)); - - $order = $this->getMock(EasyCreditOrderController::class, ['getDic']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertEquals($text, $order->getPaymentPlanTxt()); - } - - public function testGetPaymentPlanTxtEmpty() - { - $session = oxNew(EasyCreditSession::class); - $dic = $this->buildDic($session); - - $order = $this->getMock(EasyCreditOrderController::class, ['getDic']); - $order->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertNull($order->getPaymentPlanTxt()); - } - - public function testGetPaymentPlanTxtEmptyStandardDic() - { - $order = oxNew(OrderController::class); - $this->assertNull($order->getPaymentPlanTxt()); - } -} \ No newline at end of file diff --git a/Tests/Unit/Application/Controller/EasyCreditPaymentTest.php b/Tests/Unit/Application/Controller/EasyCreditPaymentTest.php deleted file mode 100644 index 160c310..0000000 --- a/Tests/Unit/Application/Controller/EasyCreditPaymentTest.php +++ /dev/null @@ -1,303 +0,0 @@ -getMock('oxConfig', [], []); - - $session = oxNew(EasyCreditDicSession::class, $oxSession); - $mockApiConfig = oxNew(EasyCreditApiConfig::class, EasyCreditDicFactory::getApiConfigArray()); - $mockLogging = $this->getMock(EasyCreditLogging::class, [], [[]]); - $mockPayloadFactory = $this->getMock(EasyCreditPayloadFactory::class, [], []); - $mockDicConfig = $this->getMock(EasyCreditDicConfig::class, [], [$mockOxConfig]); - - $mockDic = oxNew( - EasyCreditDic::class, - $session, - $mockApiConfig, - $mockPayloadFactory, - $mockLogging, - $mockDicConfig - ); - - return $mockDic; - } - - public function testGetDic() - { - $payment = oxNew(PaymentController::class); - $this->assertNotNull($payment->getDic()); - } - - public function testGetBasket() - { - $payment = oxNew(PaymentController::class); - $this->assertNotNull($payment->getBasket()); - } - - public function testIsEasyCreditPossible() - { - $payment = oxNew(PaymentController::class); - $this->assertFalse($payment->isEasyCreditPossible()); - } - - public function testIsEasyCreditPossibleAddressMismatch() - { - $payment = $this->getMock(EasyCreditPaymentController::class, ['isAddressMismatch']); - $payment->expects($this->any())->method('isAddressMismatch')->willReturn(true); - - $this->assertFalse($payment->isEasyCreditPossible()); - } - - public function testIsEasyCreditPossibleExampleCalculation() - { - $payment = $this->getMock(EasyCreditPaymentController::class, ['getExampleCalulation']); - $payment->expects($this->any())->method('getExampleCalulation')->willReturn(false); - - $this->assertFalse($payment->isEasyCreditPossible()); - } - - public function testGetExampleCalculationResponse() - { - $payment = $this->getMock(EasyCreditPaymentController::class, ['getPrice']); - $payment->expects($this->any())->method('getPrice')->willReturn(false); - - $this->assertFalse($payment->getExampleCalculationResponse()); - } - - public function testGetExampleCalculationPrice() - { - $payment = oxNew(PaymentController::class); - $this->assertNull($payment->getExampleCalculationPrice('dummy')); - } - - public function testIsAddressMismatchWithDelAddress() - { - $delAddress = oxNew(Address::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getDelAddress']); - $payment->expects($this->any())->method('getDelAddress')->willReturn($delAddress); - - $this->assertTrue($payment->isAddressMismatch()); - } - - public function testIsAddressMismatchWithDelAddressAndUser() - { - $delAddress = oxNew(Address::class); - $user = oxNew(User::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getDelAddress', 'getUser']); - $payment->expects($this->any())->method('getDelAddress')->willReturn($delAddress); - $payment->expects($this->any())->method('getUser')->willReturn($user); - - $this->assertFalse($payment->isAddressMismatch()); - } - - public function testIsForeignAddressWithDelAddress() - { - $delAddress = oxNew(Address::class); - $user = oxNew(User::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getDelAddress', 'getUser']); - $payment->expects($this->any())->method('getDelAddress')->willReturn($delAddress); - $payment->expects($this->any())->method('getUser')->willReturn($user); - - $this->assertTrue($payment->isForeignAddress()); - } - - public function testIsForeignAddressWithoutDelAddress() - { - $user = oxNew(User::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getUser']); - $payment->expects($this->any())->method('getUser')->willReturn($user); - - $this->assertTrue($payment->isForeignAddress()); - } - - public function testIsPackstationWithDelAddress() - { - $delAddress = oxNew(Address::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getDelAddress']); - $payment->expects($this->any())->method('getDelAddress')->willReturn($delAddress); - - $this->assertFalse($payment->isPackstation()); - } - - public function testIsPackstationWithDelUser() - { - $user = oxNew(User::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getUser']); - $payment->expects($this->any())->method('getUser')->willReturn($user); - - $this->assertFalse($payment->isPackstation()); - } - - public function testValidatePayment() - { - $payment = oxNew(PaymentController::class); - $this->assertNull($payment->validatePayment()); - } - - public function testValidatePaymentEasyCreditNotPossible() - { - Registry::getSession()->setVariable('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $payment = oxNew(PaymentController::class); - $this->assertNull($payment->validatePayment()); - } - - public function testValidatePaymentEasyCreditPossible() - { - Registry::getSession()->setVariable('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['isEasyCreditPossible']); - $payment->expects($this->any())->method('isEasyCreditPossible')->willReturn(true); - - $this->assertEquals('EasyCreditDispatcher?fnc=initializeandredirect', $payment->validatePayment()); - } - - public function testValidatePaymentEasyCreditPossibleAddProfileDataException() - { - Registry::getSession()->setVariable('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['isEasyCreditPossible', 'addProfileData']); - $payment->expects($this->any())->method('isEasyCreditPossible')->willReturn(true); - $payment->expects($this->any())->method('addProfileData')->willThrowException(new \Exception('TEST')); - - $this->assertNull($payment->validatePayment()); - } - - public function testAddProfileDataWithBirthDate() - { - $user = oxNew(User::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getValidatedDateOfBirth', 'getUser']); - $payment->expects($this->any())->method('getValidatedDateOfBirth')->willReturn('1980-05-25'); - $payment->expects($this->any())->method('getUser')->willReturn($user); - - $this->assertNull($payment->addProfileData()); - } - - public function testAddProfileDataWithSalutation() - { - $user = oxNew(User::class); - - $payment = $this->getMock(EasyCreditPaymentController::class, ['getValidatedSalutation', 'getUser']); - $payment->expects($this->any())->method('getValidatedSalutation')->willReturn('MR'); - $payment->expects($this->any())->method('getUser')->willReturn($user); - - $this->assertNull($payment->addProfileData()); - } - - public function testLoadAgreementTxt() - { - $response = new \stdClass(); - $response->zustimmungDatenuebertragungPaymentPage = 'dummy'; - - $payment = $this->getMock(EasyCreditPaymentController::class, ['call']); - $payment->expects($this->any())->method('call')->willReturn($response); - - $this->assertEquals('dummy', $payment->loadAgreementTxt()); - } - - public function testIsProfileDataMissing() - { - $payment = oxNew(PaymentController::class); - $this->assertTrue($payment->isProfileDataMissing()); - } - - public function testHasSalutation() - { - $payment = oxNew(PaymentController::class); - $this->assertFalse($payment->hasSalutation()); - } - - public function testGetValidatedDateOfBirth() - { - $requestData = [ - 'oxuser__oxbirthdate' => [ - 'year' => 2018, - 'month' => 6, - 'day' => 15, - ] - ]; - - $user = oxNew(User::class); - - $payment = oxNew(PaymentController::class); - $this->assertEquals('2018-06-15', $payment->getValidatedDateOfBirth($requestData, $user)); - } - - public function testGetValidatedDateOfBirthInFuture() - { - $this->expectExceptionMessage(OXPS_EASY_CREDIT_ERROR_DATEOFBIRTH_INVALID); - $this->expectException(EasyCreditException::class); - $requestData = [ - 'oxuser__oxbirthdate' => [ - 'year' => 2100, - 'month' => 1, - 'day' => 1, - ] - ]; - - $user = oxNew(User::class); - - $payment = oxNew(PaymentController::class); - $payment->getValidatedDateOfBirth($requestData, $user); - } - - public function testGetValidatedSalutation() - { - $requestData = [ - 'oxuser__oxsal' => "MR" - ]; - - $user = oxNew(User::class); - - $payment = oxNew(PaymentController::class); - $this->assertEquals('MR', $payment->getValidatedSalutation($requestData)); - } -} \ No newline at end of file diff --git a/Tests/Unit/Application/Model/EasyCreditTradingApiAccessTest.php b/Tests/Unit/Application/Model/EasyCreditTradingApiAccessTest.php deleted file mode 100644 index 90faa6f..0000000 --- a/Tests/Unit/Application/Model/EasyCreditTradingApiAccessTest.php +++ /dev/null @@ -1,85 +0,0 @@ -haendlerstatusV2 = "IN_ABRECHNUNG"; - $order = oxNew(Order::class); - $order->oxorder__ecredfunctionalid = new Field('functionalId'); - - $dic = EasyCreditDicFactory::getDic(); - - $wsc = $this->getMockBuilder(EasyCreditWebServiceClient::class) - ->disableOriginalConstructor() - ->disableOriginalClone()->onlyMethods(['execute']) - ->getMock(); - $wsc->expects($this->once())->method('execute')->willReturn($return); - - $model = $this->getMockBuilder(EasyCreditTradingApiAccess::class) - ->setConstructorArgs([$order]) - ->onlyMethods(['getService']) - ->getMock(); - - $model->expects($this->once())->method('getService') - ->with( - EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V2_DELIVERY_STATE, - $dic, - ['functionalId'], - [], - true - )->willReturn($wsc); - - $this->assertEquals( [$expected], $model->getOrderData()); - } - - public function testGetOrderStateErrorState() - { - $model = $this->getMockBuilder(EasyCreditTradingApiAccess::class) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->onlyMethods(['getOrderData'])->getMock(); - $model->expects($this->once())->method('getOrderData')->willReturn([]); - - $this->assertEquals('OXPS_EASY_CREDIT_ADMIN_DELIVERY_STATE_ERROR', $model->getOrderState()); - } - - public function testGetOrderStateValidState() - { - $return = new \stdClass(); - $return->haendlerstatusV2 = "IN_ABRECHNUNG"; - - $model = $this->getMockBuilder(EasyCreditTradingApiAccess::class) - ->disableOriginalConstructor() - ->disableOriginalClone() - ->onlyMethods(['getOrderData'])->getMock(); - $model->expects($this->once())->method('getOrderData')->willReturn([$return]); - - $this->assertEquals('OXPS_EASY_CREDIT_ADMIN_DELIVERY_STATE_IN_ABRECHNUNG', $model->getOrderState()); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/Api/EasyCreditHttpClientTest.php b/Tests/Unit/Core/Api/EasyCreditHttpClientTest.php deleted file mode 100644 index 316c7c3..0000000 --- a/Tests/Unit/Core/Api/EasyCreditHttpClientTest.php +++ /dev/null @@ -1,91 +0,0 @@ -expectException(EasyCreditCurlException::class); - $client = oxNew(EasyCreditHttpClient::class); - $client->executeJsonRequest(null, null); - } - - public function testExecuteJsonRequestWithoutServiceUrl() - { - $this->expectException(EasyCreditCurlException::class); - $client = oxNew(EasyCreditHttpClient::class); - $client->executeJsonRequest('GET', null); - } - - public function testExecuteJsonRequestWithData() - { - $client = $this->getMock(EasyCreditHttpClient::class, ['executeHttpRequest']); - $client->expects($this->any())->method('executeHttpRequest')->willReturn('{"success": true}'); - - $logging = oxNew(EasyCreditLogging::class, []); - $client->setLogging($logging); - - $expected = new \stdClass(); - $expected->success = true; - $this->assertEquals($expected, $client->executeJsonRequest('GET', 'https://test.url', new \stdClass())); - } - - public function testExecuteHttpRequestWithoutHttpMethod() - { - $this->expectException(EasyCreditCurlException::class); - $client = oxNew(EasyCreditHttpClient::class); - $client->executeHttpRequest(null, null); - } - - public function testExecuteHttpRequestWithWrongHttpMethod() - { - $this->expectException(EasyCreditCurlException::class); - $client = oxNew(EasyCreditHttpClient::class); - $client->executeHttpRequest('PUT', 'https://test.url'); // PUT is not supported by EasyCreditHttpClient - } - - public function testExecuteHttpRequestWithoutServiceUrl() - { - $this->expectException(EasyCreditCurlException::class); - $client = oxNew(EasyCreditHttpClient::class); - $client->executeHttpRequest('GET', null); - } - - public function testExecuteHttpRequestWithData() - { - $expected = '{"success": true}'; - - $client = $this->getMock(EasyCreditHttpClient::class, ['curl_exec']); - $client->expects($this->any())->method('curl_exec')->willReturn($expected); - - $this->assertEquals($expected, $client->executeHttpRequest('POST', 'https://test.url', new \stdClass())); - } - -} \ No newline at end of file diff --git a/Tests/Unit/Core/Api/EasyCreditResponseValidatorTest.php b/Tests/Unit/Core/Api/EasyCreditResponseValidatorTest.php deleted file mode 100644 index 55d6d67..0000000 --- a/Tests/Unit/Core/Api/EasyCreditResponseValidatorTest.php +++ /dev/null @@ -1,72 +0,0 @@ -assertNull($validator->validate(new \stdClass())); - } - - public function testValidateWithValidationSchemeValid() - { - $scheme = [ - [ - "fieldname" => "ergebnis", - "required" => true, - "requiredValue" => "success" - ] - ]; - - $response = new \stdClass(); - $response->ergebnis = 'success'; - - $validator = oxNew(EasyCreditResponseValidator::class, $scheme); - $this->assertNull($validator->validate($response)); - } - - public function testValidateWithValidationSchemeInvalid() - { - $this->expectException(EasyCreditValidationException::class); - $scheme = [ - [ - "fieldname" => "ergebnis", - "required" => true, - "requiredValue" => success - ] - ]; - - $response = new \stdClass(); - $response->ergebnis = 'failure'; - - $validator = oxNew(EasyCreditResponseValidator::class, $scheme); - $validator->validate($response); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/Api/EasyCreditWebServiceClientTest.php b/Tests/Unit/Core/Api/EasyCreditWebServiceClientTest.php deleted file mode 100644 index 5f311a2..0000000 --- a/Tests/Unit/Core/Api/EasyCreditWebServiceClientTest.php +++ /dev/null @@ -1,61 +0,0 @@ -assertNull($client->setFunction('test')); - } - - public function testSetFunctionWithSprintfArgs() - { - $sprintfArgs = [ - 'p1' => 'v1', - 'p2' => 'v2' - ]; - - $client = oxNew(EasyCreditWebServiceClient::class); - $this->assertNull($client->setFunction('test', $sprintfArgs)); - } - - public function testSetFunctionWithEmptySprintfArgs() - { - $this->expectExceptionMessage("Parameter p2 for curl function test was empty"); - $this->expectException(EasyCreditCurlException::class); - $sprintfArgs = [ - 'p1' => 'v1', - 'p2' => null - ]; - - $client = oxNew(EasyCreditWebServiceClient::class); - $client->setFunction('test', $sprintfArgs); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/CrossCutting/EasyCreditLoggingTest.php b/Tests/Unit/Core/CrossCutting/EasyCreditLoggingTest.php deleted file mode 100644 index d5249df..0000000 --- a/Tests/Unit/Core/CrossCutting/EasyCreditLoggingTest.php +++ /dev/null @@ -1,67 +0,0 @@ -assertEquals(26, $logging->log('TEST')); - } - - public function testLogRequestEnabled() - { - $logConfig = [ - EasyCreditLogging::LOG_CONFIG_LOG_ENABLED => true, - EasyCreditLogging::LOG_CONFIG_LOG_DIR => 'test' - ]; - - /** @var EasyCreditLogging $logging */ - $logging = oxNew(EasyCreditLogging::class, $logConfig); - - // 377 characters output expected - $this->assertEquals(377, $logging->logRestRequest('TestRequest', 'TestResponse', 'https://test.url', 350)); - } - - public function testLogRequestDisabled() - { - $logConfig = [ - EasyCreditLogging::LOG_CONFIG_LOG_ENABLED => false, - EasyCreditLogging::LOG_CONFIG_LOG_DIR => 'test' - ]; - - /** @var EasyCreditLogging $logging */ - $logging = oxNew(EasyCreditLogging::class, $logConfig); - - // 377 characters output expected - $this->assertNull($logging->logRestRequest('TestRequest', 'TestResponse', 'https://test.url', 350)); - } -} diff --git a/Tests/Unit/Core/Di/EasyCreditApiConfigTest.php b/Tests/Unit/Core/Di/EasyCreditApiConfigTest.php deleted file mode 100644 index 50c494c..0000000 --- a/Tests/Unit/Core/Di/EasyCreditApiConfigTest.php +++ /dev/null @@ -1,132 +0,0 @@ -apiConfig = oxNew(EasyCreditApiConfig::class, $apiConfigArray); - } - - /** - * Tear down test environment - * - */ - public function tearDown(): void - { - parent::tearDown(); - } - - public function testGetApiConfigValue() - { - $services = $this->apiConfig->getApiConfigValue(EasyCreditApiConfig::API_CONFIG_SERVICES); - $this->assertNotNull($services); - $this->assertIsArray($services); - - $sampleService = $services[EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_MODELLRECHNUNG_GUENSTIGSTER_RATENPLAN]; - $this->assertNotNull($sampleService); - $this->assertIsArray($sampleService); - $this->assertEquals('get', $sampleService['httpMethod']); - $this->assertEquals('/v2/modellrechnung/guenstigsterRatenplan', $sampleService['restFunction']); - } - - public function testGetServiceHttpMethodExisting() - { - $this->assertEquals('get', $this->apiConfig->getServiceHttpMethod(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_ZUSTIMMUNGSTEXTE)); - } - - public function testGetServiceHttpMethodNonExisting() - { - $this->expectExceptionMessage("Service name 'non existing service' is not configured."); - $this->expectException(EasyCreditConfigException::class); - $this->assertEquals('get', $this->apiConfig->getServiceHttpMethod('non existing service')); - } - - public function testGetServiceRestFunction() - { - $this->assertEquals('/v2/texte/zustimmung/%s', $this->apiConfig->getServiceRestFunction(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_ZUSTIMMUNGSTEXTE)); - } - - public function testGetServiceRestFunctionArguments() - { - $expected = [EasyCreditApiConfig::API_CONFIG_SERVICE_REST_ARGUMENT_WEBSHOP_ID => self::WEBSHOP_ID]; - $this->assertEquals($expected, $this->apiConfig->getServiceRestFunctionArguments(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_ZUSTIMMUNGSTEXTE)); - } - - public function testGetBaseUrl() - { - $this->assertEquals('https://ratenkauf.easycredit.de/ratenkauf-ws/rest', $this->apiConfig->getBaseUrl()); - } - - public function testGetWebShopId() - { - $this->assertEquals(self::WEBSHOP_ID, $this->apiConfig->getWebShopId()); - } - - public function testGetWebShopToken() - { - $this->assertEquals(self::WEBSHOP_TOKEN, $this->apiConfig->getWebShopToken()); - } - - public function testGetValidationScheme() - { - $validationScheme = $this->apiConfig->getValidationScheme(EasyCreditApiConfig::API_CONFIG_SERVICE_NAME_V1_VORGANG); - - $this->assertNotNull($validationScheme); - $this->assertIsArray($validationScheme); - - $validationSchemeValues = $validationScheme[0]; - $this->assertNotNull($validationSchemeValues); - $this->assertIsArray($validationSchemeValues); - $this->assertEquals('tbVorgangskennung', $validationSchemeValues[EasyCreditResponseValidator::VALIDATION_KEY_FIELDNAME]); - $this->assertEquals(1, $validationSchemeValues[EasyCreditResponseValidator::VALIDATION_KEY_REQUIRED]); - } - - public function testGetRedirectUrl() - { - $this->assertEquals('https://ratenkauf.easycredit.de/ratenkauf/content/intern/einstieg.jsf?vorgangskennung=%s', $this->apiConfig->getRedirectUrl()); - } - - public function testGetEasyCreditInstalmentPaymentId() - { - $this->assertEquals('easycreditinstallment', $this->apiConfig->getEasyCreditInstalmentPaymentId()); - } - - public function testGetEasyCreditModuleId() - { - $this->assertEquals('oxpseasycredit', $this->apiConfig->getEasyCreditModuleId()); - } -} diff --git a/Tests/Unit/Core/Di/EasyCreditDicConfigTest.php b/Tests/Unit/Core/Di/EasyCreditDicConfigTest.php deleted file mode 100644 index a18cbea..0000000 --- a/Tests/Unit/Core/Di/EasyCreditDicConfigTest.php +++ /dev/null @@ -1,132 +0,0 @@ -configStore = []; - $this->configStore[self::CONFIG_GET_PARAM_NAME] = self::CONFIG_GET_PARAM_VALUE; - - $oxConfig = $this->getMock( - Config::class, - ['getShopId', 'getSslShopUrl', 'getConfigParam', 'setConfigParam', 'saveShopConfVar'] - ); - - $oxConfig->expects($this->any())->method('getShopId')->willReturn(self::SHOP_ID); - $oxConfig->expects($this->any())->method('getSslShopUrl')->willReturn(self::SSL_SHOP_URL); - - $oxConfig->expects($this->any())->method('getConfigParam')->willReturnCallback( - function($key) { - return $this->configStore[$key]; - } - ); - - $oxConfig->expects($this->any())->method('setConfigParam')->willReturnCallback( - function($key, $value) { - $this->configStore[$key] = $value; - } - ); - - $oxConfig->expects($this->any())->method('saveShopConfVar')->willReturnCallback( - function($sVarType, $sVarName, $sVarVal, $sShopId, $sModule) { - $this->sVarType = $sVarType; - $this->sVarName = $sVarName; - $this->sVarVal = $sVarVal; - $this->sShopId = $sShopId; - $this->sModule = $sModule; - } - ); - - $this->dicConfig = oxNew(EasyCreditDicConfig::class, $oxConfig); - } - - /** - * Tear down test environment - * - */ - public function tearDown(): void - { - parent::tearDown(); - } - - public function testGetShopId() - { - $this->assertEquals(self::SHOP_ID, $this->dicConfig->getShopId()); - } - - public function testGetSslShopUrl() - { - $this->assertEquals(self::SSL_SHOP_URL, $this->dicConfig->getSslShopUrl()); - } - - public function testGetConfigParam() - { - $this->assertEquals(self::CONFIG_GET_PARAM_VALUE, $this->dicConfig->getConfigParam(self::CONFIG_GET_PARAM_NAME)); - } - - public function testSetConfigParam() - { - $this->assertNull($this->dicConfig->getConfigParam(self::CONFIG_SET_PARAM_NAME)); - $this->dicConfig->setConfigParam(self::CONFIG_SET_PARAM_NAME, self::CONFIG_SET_PARAM_VALUE); - $this->assertEquals(self::CONFIG_SET_PARAM_VALUE, $this->dicConfig->getConfigParam(self::CONFIG_SET_PARAM_NAME)); - } - - public function testSaveShopConfVar() - { - $sVarType = 'str'; - $sVarName = 'oxpsEasyCreditTest'; - $sVarVal = 'TEST'; - $sShopId = '3'; - $sModule = 'module:oxpseasycredit'; - - $this->dicConfig->saveShopConfVar( - $sVarType, $sVarName, $sVarVal, $sShopId, $sModule - ); - - $this->assertEquals($sVarType, $this->sVarType); - $this->assertEquals($sVarName, $this->sVarName); - $this->assertEquals($sVarVal, $this->sVarVal); - $this->assertEquals($sShopId, $this->sShopId); - $this->assertEquals($sModule, $this->sModule); - } -} diff --git a/Tests/Unit/Core/Di/EasyCreditDicSessionTest.php b/Tests/Unit/Core/Di/EasyCreditDicSessionTest.php deleted file mode 100644 index 6f866dd..0000000 --- a/Tests/Unit/Core/Di/EasyCreditDicSessionTest.php +++ /dev/null @@ -1,169 +0,0 @@ -sessionStore = []; - $this->sessionStore[self::GET_KEY] = self::GET_VALUE; - - $oxSession = $this->getMock( - Session::class, - [ - 'getVariable', - 'setVariable', - 'deleteVariable', - 'processUrl', - 'getId', - 'setStorage', - 'getStorage', - 'clearStorage' - ] - ); - - $oxSession->expects($this->any())->method('getVariable')->willReturnCallback( - function ($key) { - return $this->sessionStore[$key]; - } - ); - - $oxSession->expects($this->any())->method('setVariable')->willReturnCallback( - function ($key, $value) { - $this->sessionStore[$key] = $value; - } - ); - - $oxSession->expects($this->any())->method('deleteVariable')->willReturnCallback( - function ($key) { - unset($this->sessionStore[$key]); - } - ); - - $oxSession->expects($this->any())->method('processUrl')->willReturnCallback( - function ($url) { - return $url . '-test'; - } - ); - - $oxSession->expects($this->any())->method('getId')->willReturn(self::SESSION_ID); - - $oxSession->expects($this->any())->method('setStorage')->willReturnCallback( - function ($storage) { - $this->storage = $storage; - } - ); - - $oxSession->expects($this->any())->method('getStorage')->willReturnCallback( - function () { - return $this->storage; - } - ); - - $oxSession->expects($this->any())->method('clearStorage')->willReturnCallback( - function () { - unset($this->storage); - } - ); - - $this->dicSession = oxNew(EasyCreditDicSession::class, $oxSession); - } - - /** - * Tear down test environment - * - */ - public function tearDown(): void - { - parent::tearDown(); - } - - public function testGetNonExisting() - { - $this->assertNull($this->dicSession->get('xyz')); - } - - public function testGetExisting() - { - $this->assertEquals(self::GET_VALUE, $this->dicSession->get(self::GET_KEY)); - } - - public function testSet() - { - $this->assertNull($this->dicSession->get(self::SET_KEY)); - $this->dicSession->set(self::SET_KEY, self::SET_VALUE); - $this->assertEquals(self::SET_VALUE, $this->dicSession->get(self::SET_KEY)); - } - - public function testDelete() - { - $this->assertNull($this->dicSession->get(self::DELETE_KEY)); - $this->dicSession->set(self::DELETE_KEY, self::DELETE_VALUE); - $this->assertEquals(self::DELETE_VALUE, $this->dicSession->get(self::DELETE_KEY)); - - $this->dicSession->delete(self::DELETE_KEY); - $this->assertNull($this->dicSession->get(self::DELETE_KEY)); - } - - public function testProcessUrl() - { - $url = 'https://test.url'; - $this->assertEquals($url . '-test', $this->dicSession->processUrl($url)); - } - - public function testGetId() - { - $this->assertEquals(self::SESSION_ID, $this->dicSession->getId()); - } - - public function testStorage() - { - $this->dicSession->clearStorage(); - $this->assertNull($this->dicSession->getStorage()); - - $storage = new EasyCreditStorage('Vorgangskennung', - 'fachlicheVorgangskennung', - 'authorizationHash', - '$authorizedAmount'); - $this->dicSession->setStorage($storage); - $this->assertEquals($storage, $this->dicSession->getStorage()); - } -} diff --git a/Tests/Unit/Core/Domain/EasyCreditBasketTest.php b/Tests/Unit/Core/Domain/EasyCreditBasketTest.php deleted file mode 100644 index ff26373..0000000 --- a/Tests/Unit/Core/Domain/EasyCreditBasketTest.php +++ /dev/null @@ -1,166 +0,0 @@ -assertNotTrue($oxBasket->hasInterestsAmount()); - } - - public function testGetInterestsAmount(): void - { - $session = oxNew(EasyCreditSession::class); - $session->setVariable('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $dic = $this->getMock( - EasyCreditDic::class, - ['getSession'], - [null, null, null, null, null] - ); - $dic->expects($this->any())->method('getSession')->willReturn($session); - - $storage = oxNew(EasyCreditStorage::class, "TEST", "TEST", "TEST", 500.0); - $storage->setInterestAmount(20.7); - $dic->getSession()->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertEquals(20.7, $oxBasket->getInterestsAmount()); - } - - public function testGetInterestsAmountNoStorage(): void - { - $session = oxNew(EasyCreditSession::class); - $session->setVariable('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $dic = $this->getMock( - EasyCreditDic::class, - ['getSession'], - [null, null, null, null, null] - ); - $dic->expects($this->any())->method('getSession')->willReturn($session); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertNull($oxBasket->getInterestsAmount()); - } - - public function testSetCostExclude(): void - { - $costName = 'oxpayment'; - - $price = oxNew(Price::class); - $price->setPrice(10.4); - - $oxBasket = oxNew(Basket::class); - $oxBasket->setExcludeInstalmentsCosts(true); - $oxBasket->setCost($costName, $price); - - $costs = $oxBasket->getCosts(); - $this->assertNotNull($costs); - $this->assertIsArray($costs); - $this->assertTrue(isset($costs[$costName])); - - $p = $costs[$costName]; - $this->assertEquals(10.4, $p->getPrice()); - } - - public function testSetCostInclude(): void - { - $costName = 'oxpayment'; - - $price = oxNew(Price::class); - $price->setPrice(10.4); - - $oxBasket = oxNew(Basket::class); - $oxBasket->setCost($costName, $price); - - $costs = $oxBasket->getCosts(); - $this->assertNotNull($costs); - $this->assertIsArray($costs); - $this->assertTrue(isset($costs[$costName])); - - $p = $costs[$costName]; - $this->assertEquals(10.4, $p->getPrice()); - } - - public function testCalcInterestsCost(): void - { - $session = oxNew(EasyCreditSession::class); - $session->setVariable('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $dic = $this->getMock( - EasyCreditDic::class, - ['getSession'], - [null, null, null, null, null] - ); - $dic->expects($this->any())->method('getSession')->willReturn($session); - - $storage = oxNew(EasyCreditStorage::class, "TEST", "TEST", "TEST", 500.0); - $storage->setInterestAmount(20.7); - $dic->getSession()->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $interestCost = $oxBasket->calcInterestsCost(); - $this->assertNotNull($interestCost); - $this->assertEquals(20.7, $interestCost->getPrice()); - } - - public function testCalculateBasket(): void - { - // calling calculateBasket to test _calcTotalPrice - $oxBasket = oxNew(Basket::class); - $oxBasket->calculateBasket(); - } -} diff --git a/Tests/Unit/Core/Domain/EasyCreditOrderTest.php b/Tests/Unit/Core/Domain/EasyCreditOrderTest.php deleted file mode 100644 index 388ecd6..0000000 --- a/Tests/Unit/Core/Domain/EasyCreditOrderTest.php +++ /dev/null @@ -1,936 +0,0 @@ -markTestSkipped(); - } - - /** - * Tear down test environment - * - */ - public function tearDown(): void - { - parent::tearDown(); - } - - public function testFinalizeOrderInvalidPayment(): void - { - $oxBasket = oxNew(Basket::class); - - $oxUser = oxNew(User::class); - - $oxOrder = oxNew(Order::class); - $this->assertEquals(Order::ORDER_STATE_INVALIDPAYMENT, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - */ - public function testFinalizeOrderNoStorage(): void - { - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getPaymentId']); - $oxBasket->expects($this->any())->method('getPaymentId')->willReturn(EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxUser = oxNew(User::class); - - $oxOrder = oxNew(Order::class); - $this->assertFalse($oxOrder->finalizeOrder($oxBasket, $oxUser)); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - */ - public function testFinalizeOrderWithStorageNotInitializing(): void - { - $dic = $this->getMockedDic(); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - $dicSession->setStorage( - oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'authorizationHash', - 1000.0 - ) - ); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $oxUser = oxNew(User::class); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - */ - public function testFinalizeOrderWithEmptyStorage(): void - { - $dic = $this->getMockedDic(); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - $dicSession->setStorage(null); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = oxNew(User::class); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - public function testFinalizeOrderWithStorageInitialized(): void - { - $dic = $this->getMockedDic(); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = oxNew(User::class); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validatePayment']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validatePayment')->willReturn(Order::ORDER_STATE_INVALIDPAYMENT); - - $this->assertEquals(Order::ORDER_STATE_INVALIDPAYMENT, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - } - - public function testFinalizeOrderStateOkWithConfirmException(): void - { - $dic = $this->getMockedDic(); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - } - - public function testFinalizeOrderStateOk(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - } - - public function testFinalizeOrderIsConfirmedNoValidate(): void - { - Registry::getConfig()->setConfigParam('oxpsECCheckoutValidConfirm', false); - - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - } - - public function testFinalizeOrderIsConfirmedNoResponse(): void - { - Registry::getConfig()->setConfigParam('oxpsECCheckoutValidConfirm', true); - - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn(null); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - - $errors = Registry::getSession()->getVariable('Errors'); - $this->assertNotNull($errors); - $this->assertIsArray($errors); - $this->assertCount(1, $errors); - $this->assertTrue(isset($errors['default'])); - - $defaultErrors = $errors['default']; - $this->assertIsArray($defaultErrors); - $this->assertCount(2, $defaultErrors); - - $errorMessages = array_map(function ($error) { - return unserialize($error)->getOxMessage(); - }, $defaultErrors); - - $this->assertEquals(Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_BESTAETIGEN_FAILED'), - $errorMessages[0]); - $this->assertEquals('Es ist ein Fehler aufgetreten.', $errorMessages[1]); - } - - public function testFinalizeOrderIsConfirmedNoWsMessages(): void - { - Registry::getConfig()->setConfigParam('oxpsECCheckoutValidConfirm', true); - - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - - $errors = Registry::getSession()->getVariable('Errors'); - $this->assertNotNull($errors); - $this->assertIsArray($errors); - $this->assertCount(1, $errors); - $this->assertTrue(isset($errors['default'])); - - $defaultErrors = $errors['default']; - $this->assertIsArray($defaultErrors); - $this->assertCount(2, $defaultErrors); - - $errorMessages = array_map(function ($error) { - return unserialize($error)->getOxMessage(); - }, $defaultErrors); - - $this->assertEquals(Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_BESTAETIGEN_FAILED'), - $errorMessages[0]); - $this->assertEquals('Es ist ein Fehler aufgetreten.', $errorMessages[1]); - } - - public function testFinalizeOrderIsConfirmedNoMessages(): void - { - Registry::getConfig()->setConfigParam('oxpsECCheckoutValidConfirm', true); - - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - - $errors = Registry::getSession()->getVariable('Errors'); - $this->assertNotNull($errors); - $this->assertIsArray($errors); - $this->assertCount(1, $errors); - $this->assertTrue(isset($errors['default'])); - - $defaultErrors = $errors['default']; - $this->assertIsArray($defaultErrors); - $this->assertCount(2, $defaultErrors); - - $errorMessages = array_map(function ($error) { - return unserialize($error)->getOxMessage(); - }, $defaultErrors); - - $this->assertEquals(Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_BESTAETIGEN_FAILED'), - $errorMessages[0]); - $this->assertEquals('Es ist ein Fehler aufgetreten.', $errorMessages[1]); - } - - public function testFinalizeOrderIsConfirmedNoFirstMessage(): void - { - Registry::getConfig()->setConfigParam('oxpsECCheckoutValidConfirm', true); - - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $messages = ['xyz']; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - - $errors = Registry::getSession()->getVariable('Errors'); - $this->assertNotNull($errors); - $this->assertIsArray($errors); - $this->assertCount(1, $errors); - $this->assertTrue(isset($errors['default'])); - - $defaultErrors = $errors['default']; - $this->assertIsArray($defaultErrors); - $this->assertCount(2, $defaultErrors); - - $errorMessages = array_map(function ($error) { - return unserialize($error)->getOxMessage(); - }, $defaultErrors); - - $this->assertEquals(Registry::getLang()->translateString('OXPS_EASY_CREDIT_ERROR_BESTAETIGEN_FAILED'), - $errorMessages[0]); - $this->assertEquals('Es ist ein Fehler aufgetreten.', $errorMessages[1]); - } - - public function testFinalizeOrderIsConfirmedFirstMessageConfirmed(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $paymentHash = $this->getPaymentHash($oxUser, $oxBasket, $dic); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - $paymentHash, - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $firstMessage = new \stdClass(); - $firstMessage->key = EasyCreditOrder::EASYCREDIT_BESTELLUNG_BESTAETIGT; - $messages = [$firstMessage]; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $this->assertEquals(oxorder::ORDER_STATE_OK, $oxOrder->finalizeOrder($oxBasket, $oxUser)); - - $errors = Registry::getSession()->getVariable('Errors'); - $this->assertNotNull($errors); - $this->assertIsArray($errors); - $this->assertCount(1, $errors); - $this->assertTrue(isset($errors['default'])); - - $defaultErrors = $errors['default']; - $this->assertIsArray($defaultErrors); - $this->assertCount(1, $defaultErrors); - - $errorMessages = array_map(function ($error) { - return unserialize($error)->getOxMessage(); - }, $defaultErrors); - - $this->assertEquals('Es ist ein Fehler aufgetreten.', $errorMessages[0]); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - * @throws oxSystemComponentException - */ - public function testFinalizeOrderWithoutStorageVorgangskennung(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $storage = oxNew( - EasyCreditStorage::class, - null, - 'fachlicheVorgangskennung', - '3faa449deae074523887722643ca8796', - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $firstMessage = new \stdClass(); - $firstMessage->key = EasyCreditOrder::EASYCREDIT_BESTELLUNG_BESTAETIGT; - $messages = [$firstMessage]; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - * @throws oxSystemComponentException - */ - public function testFinalizeOrderWithoutFachlicheVorgangskennung(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - null, - '3faa449deae074523887722643ca8796', - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $firstMessage = new \stdClass(); - $firstMessage->key = EasyCreditOrder::EASYCREDIT_BESTELLUNG_BESTAETIGT; - $messages = [$firstMessage]; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - * @throws oxSystemComponentException - */ - public function testFinalizeOrderWithoutAllgemeineVorgangsdaten(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - '3faa449deae074523887722643ca8796', - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten(null); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $firstMessage = new \stdClass(); - $firstMessage->key = EasyCreditOrder::EASYCREDIT_BESTELLUNG_BESTAETIGT; - $messages = [$firstMessage]; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - * @throws oxSystemComponentException - */ - public function testFinalizeOrderWithoutTilgungsplanTxt(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - '3faa449deae074523887722643ca8796', - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt(null); - $storage->setRatenplanTxt('paymentPlanTxt'); - $dicSession->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $firstMessage = new \stdClass(); - $firstMessage->key = EasyCreditOrder::EASYCREDIT_BESTELLUNG_BESTAETIGT; - $messages = [$firstMessage]; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - /** - * @expectedException PHPUnit_Framework_Error_Warning - * @throws oxSystemComponentException - */ - public function testFinalizeOrderWithoutRatenplanTxt(): void - { - $dic = $this->getMockedDic(true); - - $dicSession = $dic->getSession(); - $dicSession->set('paymentid', EasyCreditHelper::EASYCREDIT_PAYMENTID); - - $storage = oxNew( - EasyCreditStorage::class, - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - '3faa449deae074523887722643ca8796', - 1000.0 - ); - $storage->setAllgemeineVorgangsdaten('allgemeineVorgangsdaten'); - $storage->setTilgungsplanTxt('tilgungsplanText'); - $storage->setRatenplanTxt(null); - $dicSession->setStorage($storage); - - $oxBasket = $this->getMock(EasyCreditBasket::class, ['getDic', 'getPrice']); - $oxBasket->expects($this->any())->method('getDic')->willReturn($dic); - - $price = oxNew(Price::class); - $price->setPrice(1000.0); - $oxBasket->expects($this->any())->method('getPrice')->willReturn($price); - - $oxUser = $this->buildUser(); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - $oxOrder->expects($this->any())->method('validateOrder')->willReturn(false); - - $response = new \stdClass(); - $wsMessages = new \stdClass(); - $firstMessage = new \stdClass(); - $firstMessage->key = EasyCreditOrder::EASYCREDIT_BESTELLUNG_BESTAETIGT; - $messages = [$firstMessage]; - $wsMessages->messages = $messages; - $response->wsMessages = $wsMessages; - $oxOrder->expects($this->any())->method('getConfirmResponse')->willReturn($response); - - $oxOrder->finalizeOrder($oxBasket, $oxUser); - } - - public function testTilgunsplanTxtNoStorage(): void - { - $dic = $this->getMockedDic(true); - - $oxOrder = $this->getMock(EasyCreditOrder::class, ['getDic', 'validateOrder', 'getConfirmResponse']); - $oxOrder->expects($this->any())->method('getDic')->willReturn($dic); - - $this->assertNull($oxOrder->getTilgungsplanTxt()); - } - - public function testgetFInterestsValueWithInterestValue(): void - { - $oxOrder = oxNew(Order::class); - $oxOrder->oxorder__ecredinterestsvalue = new Field(2.5); - $this->assertNotNull($oxOrder->getFInterestsValue()); - $this->assertEquals('2,50', $oxOrder->getFInterestsValue()); - } - - private function getMockedDic($apiConfigured = false) - { - return oxNew( - EasyCreditDic::class, - oxNew(EasyCreditDicSession::class, oxNew(EasyCreditSession::class)), - oxNew(EasyCreditApiConfig::class, $apiConfigured ? EasyCreditDicFactory::getApiConfigArray() : []), - oxNew(EasyCreditPayloadFactory::class), - oxNew(EasyCreditLogging::class, []), - oxNew(EasyCreditDicConfig::class, Registry::getConfig()) - ); - } - - private function buildUser(): User - { - $user = oxNew(User::class); - - $user->oxuser__oxid = new Field('1234'); - - // bill address - $user->oxuser__oxcompany = new Field('oxcompany'); - $user->oxuser__oxusername = new Field('test@test.net'); - $user->oxuser__oxfname = new Field('oxfname'); - $user->oxuser__oxlname = new Field('oxlname'); - $user->oxuser__oxstreet = new Field('oxstreet'); - $user->oxuser__oxstreetnr = new Field('oxstreetnr'); - $user->oxuser__oxaddinfo = new Field('oxaddinfo'); - $user->oxuser__oxustid = new Field('oxustid'); - $user->oxuser__oxcity = new Field('oxcity'); - $user->oxuser__oxcountryid = new Field('oxcountryid'); - $user->oxuser__oxstateid = new Field('oxstateid'); - $user->oxuser__oxzip = new Field('oxzip'); - $user->oxuser__oxfon = new Field('oxfon'); - $user->oxuser__oxfax = new Field('oxfax'); - $user->oxuser__oxsal = new Field('oxsal'); - $user->oxuser__oxustidstatus = new Field('oxustidstatus'); - - return $user; - } - - protected function getPaymentHash($oxUser, $oxBasket, $dic) - { - return md5(json_encode($this->getCurrentInitializationData($oxUser, $oxBasket, $dic))); - } - - protected function getCurrentInitializationData($oUser, $oBasket, $dic) - { - $requestBuilder = oxNew(EasyCreditInitializeRequestBuilder::class); - - $requestBuilder->setUser($oUser); - $requestBuilder->setBasket($oBasket); - $requestBuilder->setShippingAddress($this->getShippingAddress()); - - $shopEdition = EasyCreditHelper::getShopSystem($this->getConfig()->getActiveShop()); - $requestBuilder->setShopEdition($shopEdition); - - $moduleVersion = EasyCreditHelper::getModuleVersion($dic); - $requestBuilder->setModuleVersion($moduleVersion); - - $requestBuilder->setBaseLanguage(Registry::getLang()->getBaseLanguage()); - - $data = $requestBuilder->getInitializationData(); - return $data; - } - - protected function getShippingAddress(): Address - { - $oOrder = oxNew(Order::class); - return $oOrder->getDelAddressInfo(); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/Domain/EasyCreditPaymentTest.php b/Tests/Unit/Core/Domain/EasyCreditPaymentTest.php deleted file mode 100644 index ac3af48..0000000 --- a/Tests/Unit/Core/Domain/EasyCreditPaymentTest.php +++ /dev/null @@ -1,69 +0,0 @@ -setId(EasyCreditHelper::EASYCREDIT_PAYMENTID); - $this->assertTrue($payment->isEasyCreditInstallment()); - } - - public function testIsEasyCreditInstallmentFalse(): void - { - $payment = oxNew(Payment::class); - $payment->setId('something'); - $this->assertFalse($payment->isEasyCreditInstallment()); - } - - public function testIsEasyCreditInstallmentByIdTrue(): void - { - $this->assertTrue(EasyCreditHelper::isEasyCreditInstallmentById(EasyCreditHelper::EASYCREDIT_PAYMENTID)); - } - - public function testIsEasyCreditInstallmentByIdFalse(): void - { - $this->assertFalse(EasyCreditHelper::isEasyCreditInstallmentById('something')); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/Domain/EasyCreditSessionTest.php b/Tests/Unit/Core/Domain/EasyCreditSessionTest.php deleted file mode 100644 index 6155daf..0000000 --- a/Tests/Unit/Core/Domain/EasyCreditSessionTest.php +++ /dev/null @@ -1,72 +0,0 @@ -assertNotTrue($session->getStorage()); - } - - public function testGetStorageExpiredStorage(): void - { - $session = oxNew(Session::class); - - $storage = $this->getMock( - EasyCreditStorage::class, - ['hasExpired'], - [ - 'EasyCreditStorage', - 'tbVorgangskennung', - 'fachlicheVorgangskennung', - 'authorizationHash', - 500.50 - ] - ); - $storage->expects($this->any())->method('hasExpired')->willReturn(true); - $session->setStorage($storage); - - $this->assertNull($session->getStorage()); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/Dto/EasyCreditStorageTest.php b/Tests/Unit/Core/Dto/EasyCreditStorageTest.php deleted file mode 100644 index 5107b87..0000000 --- a/Tests/Unit/Core/Dto/EasyCreditStorageTest.php +++ /dev/null @@ -1,70 +0,0 @@ -assertFalse($oTest->hasExpired()); - } - - public function testHasExpiredExpiredLastUpdate(): void - { - $oTest = $this->getMock( - EasyCreditStorage::class, - ['getStorageExpiredTimeRange'], - ['TEST', 'TEST', 'TEST', 450.0] - ); - - sleep(2); - - $oTest->expects($this->any())->method('getStorageExpiredTimeRange')->willReturn(0); - - $this->assertTrue($oTest->hasExpired()); - } -} diff --git a/Tests/Unit/Core/Helper/EasyCreditHelperTest.php b/Tests/Unit/Core/Helper/EasyCreditHelperTest.php deleted file mode 100644 index 1bb154c..0000000 --- a/Tests/Unit/Core/Helper/EasyCreditHelperTest.php +++ /dev/null @@ -1,132 +0,0 @@ -setPrice(450.99); - - $basket = $this->getMock(Basket::class); - $basket->expects($this->any())->method('getPrice')->willReturn($price); - - $this->assertEquals($price, EasyCreditHelper::getExampleCalculationPrice(null, $basket)); - } - - public function testHasPackstationFormatNormal(): void - { - $this->assertFalse(EasyCreditHelper::hasPackstationFormat('Teststraße', '7')); - } - - public function testHasPackstationFormatNumericNoNumericPackStation1(): void - { - $this->assertFalse(EasyCreditHelper::hasPackstationFormat('014', '')); - } - - public function testHasPackstationFormatNumericNoNumericPackStation2(): void - { - $this->assertFalse(EasyCreditHelper::hasPackstationFormat('', '014')); - } - - public function testHasPackstationFormatNumericPackStation(): void - { - $this->assertTrue(EasyCreditHelper::hasPackstationFormat('014', '4711')); - } - - public function testHasPackstationFormatNonNumericPackStation1(): void - { - $this->assertTrue(EasyCreditHelper::hasPackstationFormat('Packstation 014', '')); - } - - public function testHasPackstationFormatNonNumericPackStation2(): void - { - $this->assertTrue(EasyCreditHelper::hasPackstationFormat('', 'Packstation 4711')); - } - - public function testGetShopSystemCE(): void - { - $shop = oxNew(Shop::class); - $shop->oxshops__oxedition = new Field('CE'); - - $this->assertEquals('Community Edition', EasyCreditHelper::getShopSystem($shop)); - } - - public function testGetShopSystemPE(): void - { - $shop = oxNew(Shop::class); - $shop->oxshops__oxedition = new Field('PE'); - - $this->assertEquals('Professional Edition', EasyCreditHelper::getShopSystem($shop)); - } - - public function testGetShopSystemEE(): void - { - $shop = oxNew(Shop::class); - $shop->oxshops__oxedition = new Field('EE'); - - $this->assertEquals('Enterprise Edition', EasyCreditHelper::getShopSystem($shop)); - } - - public function testGetModuleVersionOk(): void - { - $apiConfig = oxNew(EasyCreditApiConfig::class, []); - $dic = oxNew(EasyCreditDic::class, null, $apiConfig, null, null, null); - - $this->assertEquals('3.0.0-dev', EasyCreditHelper::getModuleVersion($dic)); - } - - public function testGetModuleVersionWrongModuleId(): void - { - $apiConfig = $this->getMock(EasyCreditApiConfig::class, ['getEasyCreditModuleId'], [[]]); - $apiConfig->expects($this->any())->method('getEasyCreditModuleId')->willReturn('dummy'); - $dic = oxNew(EasyCreditDic::class, null, $apiConfig, null, null, null); - - $this->assertEquals('', EasyCreditHelper::getModuleVersion($dic)); - } -} \ No newline at end of file diff --git a/Tests/Unit/Core/Helper/EasyCreditInitializeRequestBuilderTest.php b/Tests/Unit/Core/Helper/EasyCreditInitializeRequestBuilderTest.php deleted file mode 100644 index e947e97..0000000 --- a/Tests/Unit/Core/Helper/EasyCreditInitializeRequestBuilderTest.php +++ /dev/null @@ -1,573 +0,0 @@ -shopkennung = Registry::getConfig()->getConfigParam('oxpsECWebshopId'); - } - - /** - * Tear down test environment - * - */ - public function tearDown(): void - { - parent::tearDown(); - } - - public function testGetInitializationDataWithBasketItems(): void - { - $articleIds = ['1000', '2000']; - $articles = [ - oxNew(Article::class), - oxNew(Article::class) - ]; - - $basketContents = []; - foreach ($articles as $i => $article) { - $id = $articleIds[$i]; - $article->setId($id); - - $basketItem = $this->getMock(BasketItem::class, ['getArticle']); - $basketItem->expects($this->any())->method('getArticle')->willReturn($article); - $basketContents[$id] = $basketItem; - } - - $basket = $this->getMock(Basket::class, ['getBasketArticles', 'getContents']); - $basket->expects($this->any())->method('getBasketArticles')->willReturn($basketContents); - $basket->expects($this->any())->method('getContents')->willReturn($basketContents); - - $user = oxNew(User::class); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ], - 'warenkorbinfos' => [ - 0 => [ - 'produktbezeichnung' => null, - 'menge' => 0.0, - 'preis' => '', - 'hersteller' => '', - 'produktkategorie' => 'Bindungen', - 'artikelnummern' => [ - 0 => [ - 'nummerntyp' => 'GTIN', - 'nummer' => null - ] - ] - ], - 1 => [ - 'produktbezeichnung' => null, - 'menge' => 0.0, - 'preis' => '', - 'hersteller' => '', - 'produktkategorie' => 'Bindungen', - 'artikelnummern' => [ - 0 => [ - 'nummerntyp' => 'GTIN', - 'nummer' => null - ] - ] - ] - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithRegisteredUserWithGroups(): void - { - $basket = oxNew(Basket::class); - - $groupIds = ['dummy', 'oxidnotyetordered']; - $groups = []; - foreach ($groupIds as $groupId) { - $group = oxNew(Groups::class); - $group->setId($groupId); - $groups[$groupId] = $group; - } - - $user = $this->getMock(User::class, ['getUserGroups']); - $user->expects($this->any())->method('getUserGroups')->willReturn($groups); - $user->oxuser__oxpassword = new Field('password'); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => true, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithSalutationMapping(): void - { - $basket = oxNew(Basket::class); - - $user = $this->getMock(User::class, ['getUserGroups']); - $user->oxuser__oxsal = new Field('MRS'); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'personendaten' => [ - 'anrede' => 'FRAU' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithBirthday(): void - { - $basket = oxNew(Basket::class); - - $user = $this->getMock(User::class, ['getUserGroups']); - $user->oxuser__oxbirthdate = new Field('1985-07-13'); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'personendaten' => [ - 'geburtsdatum' => '1985-07-13' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithInvalidBirthday(): void - { - $basket = oxNew(Basket::class); - - $user = $this->getMock('oxUser', ['getUserGroups']); - $user->oxuser__oxbirthdate = new Field('12345'); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithDeliveryAddress(): void - { - $basket = oxNew(Basket::class); - - $user = $this->getMock('oxUser', ['getUserGroups']); - - $deliveryAddress = oxNew(Address::class); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - $rb->setShippingAddress($deliveryAddress); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithCountry(): void - { - $basket = oxNew(Basket::class); - - $user = $this->getMock(User::class, ['getUserGroups']); - $user->oxuser__oxcountryid = new Field('a7c40f631fc920687.20179984'); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ], - 'rechnungsadresse' => [ - 'land' => 'DE' - ], - 'lieferadresse' => [ - 'land' => 'DE' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithValidPhoneNumber(): void - { - $basket = oxNew(Basket::class); - - $user = $this->getMock(User::class, ['getUserGroups']); - $user->oxuser__oxfon = new Field('+49 123-1234'); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null, - 'mobilfunknummer' => '+49 123-1234', - 'pruefungMobilfunknummerUebergehen' => true - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ], - 'weitereKaeuferangaben' => [ - 'telefonnummer' => '+49 123-1234' - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } - - public function testGetInitializationDataWithDeps(): void - { - $manufacturer = oxNew(Manufacturer::class); - $manufacturer->setId('1000'); - $manufacturer->oxmanufacturer__oxtitle = new Field('testmanufacturer'); - - $category = oxNew('oxcategory'); - $category->setId('1000'); - $category->oxcategories__oxtitle = new Field('testcategory'); - - $unitPrice = oxNew(Price::class); - $unitPrice->setPrice(250.72); - - $articleIds = ['1000', '2000']; - - $basketContents = []; - foreach ($articleIds as $i => $articleId) { - $article = $this->getMock(Article::class, ['getManufacturer', 'getCategory']); - $article->expects($this->any())->method('getManufacturer')->willReturn($manufacturer); - $article->expects($this->any())->method('getCategory')->willReturn($category); - $article->setId($articleId); - - $basketItem = $this->getMock(BasketItem::class, ['getArticle', 'getUnitPrice']); - $basketItem->expects($this->any())->method('getArticle')->willReturn($article); - $basketItem->expects($this->any())->method('getUnitPrice')->willReturn($unitPrice); - $basketContents[$articleId] = $basketItem; - } - - $basket = $this->getMock(Basket::class, ['getBasketArticles', 'getContents']); - $basket->expects($this->any())->method('getBasketArticles')->willReturn($basketContents); - $basket->expects($this->any())->method('getContents')->willReturn($basketContents); - - $user = oxNew(User::class); - - $rb = oxNew(EasyCreditInitializeRequestBuilder::class); - $rb->setBasket($basket); - $rb->setUser($user); - - $config = Registry::getConfig(); - - $sslShopUrl = EasyCreditDicFactory::getDic()->getConfig()->getSslShopUrl(); - $expected = [ - 'integrationsart' => 'PAYMENT_PAGE', - 'shopKennung' => $this->shopkennung, - 'laufzeit' => 36, - 'ruecksprungadressen' => [ - 'urlAbbruch' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment', - 'urlErfolg' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=EasyCreditDispatcher&fnc=getEasyCreditDetails', - 'urlAblehnung' => $sslShopUrl . 'index.php?lang=&sid=&shp=' . $config->getBaseShopId() . '&cl=payment' - ], - 'kontakt' => [ - 'email' => null - ], - 'risikorelevanteAngaben' => [ - 'bestellungErfolgtUeberLogin' => false, - 'kundeSeit' => '', - 'anzahlBestellungen' => 0, - 'kundenstatus' => 'NEUKUNDE', - 'anzahlProdukteImWarenkorb' => 0, - 'negativeZahlungsinformation' => 'KEINE_INFORMATION', - 'risikoartikelImWarenkorb' => false, - 'logistikDienstleister' => '' - ], - 'technischeShopparameter' => [ - 'shopSystemHersteller' => 'OXID eShop ' - ], - 'warenkorbinfos' => [ - 0 => [ - 'produktbezeichnung' => null, - 'menge' => 0.0, - 'preis' => 250.72, - 'hersteller' => null, - 'produktkategorie' => 'testcategory', - 'artikelnummern' => [ - 0 => [ - 'nummerntyp' => 'GTIN', - 'nummer' => null - ] - ] - ], - 1 => [ - 'produktbezeichnung' => null, - 'menge' => 0.0, - 'preis' => 250.72, - 'hersteller' => null, - 'produktkategorie' => 'testcategory', - 'artikelnummern' => [ - 0 => [ - 'nummerntyp' => 'GTIN', - 'nummer' => null - ] - ] - ] - ] - ]; - $this->assertEquals($expected, $rb->getInitializationData()); - } -} diff --git a/Tests/phpunit.xml b/Tests/phpunit.xml deleted file mode 100644 index 16e0939..0000000 --- a/Tests/phpunit.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - ./tests - - - - - ./unit - - - - - ../ - - ../Tests/ - ../translations/ - ../views/ - ../out/ - ../docs/ - ../metadata.php - - - - - diff --git a/composer.json b/composer.json index e79a9df..42846bc 100644 --- a/composer.json +++ b/composer.json @@ -1,27 +1,71 @@ { - "name": "oxid-professional-services/easycredit-module", - "description": "The payment module by EasyCredit.", - "type": "oxideshop-module", - "keywords": ["oxid", "modules", "eShop"], - "homepage": "https://www.oxid-esales.com/en/home.html", - "license": [ - "GPL-3.0-only", - "proprietary" - ], - "extra": { - "oxideshop": { - "blacklist-filter": [ - "documentation/**/*.*" - ], - "target-directory": "oxps/easycredit" - } - }, - "require": { - "oxid-esales/oxideshop-ce": ">=v6.3" + "name": "oxid-professional-services/easycredit-module", + "description": "The payment module by EasyCredit.", + "type": "oxideshop-module", + "keywords": [ + "oxid", + "modules", + "eShop" + ], + "homepage": "https://www.oxid-esales.com/en/home.html", + "license": "GPL-3.0-only", + "authors": [ + { + "name": "Mario Lorenz", + "homepage": "https://www.oxid-esales.com/", + "role": "Developer" }, - "autoload": { - "psr-4": { - "OxidProfessionalServices\\EasyCredit\\": "../../../source/modules/oxps/easycredit" - } + { + "name": "Chris Smith", + "homepage": "https://www.mount7.com", + "role": "Developer" + } + ], + "extra": { + "oxideshop": { + "target-directory": "oxps/easycredit" + } + }, + "require": { + "php": ">= 7.4", + "oxid-esales/oxideshop-ce": "v6.*" + }, + "require-dev": { + "phpunit/phpunit": "^9", + "phpstan/phpstan": "^2.1", + "oxid-esales/oxideshop-ide-helper": "^6.2", + "friendsofphp/php-cs-fixer": "^3.68" + }, + "autoload": { + "psr-4": { + "OxidProfessionalServices\\EasyCredit\\": "../../../source/modules/oxps/easycredit" } + }, + "autoload-dev": { + "psr-4": { + "OxidProfessionalServices\\EasyCredit\\Application\\": "./Application", + "OxidProfessionalServices\\EasyCredit\\Core\\": "./Core" + } + }, + "config": { + "lock": false, + "allow-plugins": { + "oxid-esales/oxideshop-unified-namespace-generator": true, + "oxid-esales/oxideshop-composer-plugin": true + } + }, + "scripts": { + "test": [ + "@php ide-helper.php", + "@php ./vendor/bin/php-cs-fixer check --config .php-cs-fixer.dist.php", + "@php ./vendor/bin/phpunit", + "@php ./vendor/bin/phpstan --no-progress" + ], + "style": [ + "@php ./vendor/bin/php-cs-fixer fix --config .php-cs-fixer.dist.php" + ], + "style-check": [ + "@php ./vendor/bin/php-cs-fixer check --config .php-cs-fixer.dist.php" + ] + } } diff --git a/documentation/Changelog.md b/documentation/Changelog.md deleted file mode 100644 index 1c47173..0000000 --- a/documentation/Changelog.md +++ /dev/null @@ -1,8 +0,0 @@ -## Version 2.0.0 installable via composer, tested on OXId6.2 - -## Version 1.0.2 fix, allow complete checkout without mailsending to customer - -## Version 1.0.1 (still in progress) - -## Version 1.0.0 (Mo, July 07 2018) -* Initial development version \ No newline at end of file diff --git a/documentation/README.txt b/documentation/README.txt deleted file mode 100644 index d49ec06..0000000 --- a/documentation/README.txt +++ /dev/null @@ -1,36 +0,0 @@ -==Title== -OXPS Easy Credit - -==Author== -OXID Professional Services - -==Prefix== -oxps - -==Shop Version== -4.9.x/6.0.x/6.1.x/6.2.x/ - -==Version== -2.0.0 - -==Link== -http://www.oxid-esales.com - -==Mail== -info@oxid-esales.com - -==Description== -OXPS Easy Credit Module - -==Installation== -Activate the module in administration area. - -==Extend== - * payment - -==Modules== - -==Modified original templates== - -==Uninstall== -Disable the module in administration area and delete module folder. \ No newline at end of file diff --git a/ide-helper.php b/ide-helper.php new file mode 100644 index 0000000..a0aa415 --- /dev/null +++ b/ide-helper.php @@ -0,0 +1,50 @@ +getFacts(), + $helpFactory->getUnifiedNameSpaceClassMapProvider(), + $helpFactory->getBackwardsCompatibilityClassMapProvider(), + $moduleExtendClassMapProvider + ); + $generator->generate(); + +} catch (\Exception $exception) { + $message = $exception->getMessage(); + $code = $exception->getCode(); + $traceString = $exception->getTraceAsString(); + + echo $message . PHP_EOL; + echo "error code: $code" . PHP_EOL; + echo "stack trace:" . PHP_EOL; + echo $traceString . PHP_EOL; + exit(1); +} diff --git a/metadata.php b/metadata.php index 9d72bca..eb97b07 100644 --- a/metadata.php +++ b/metadata.php @@ -1,22 +1,41 @@ 'Use easyCredit-Ratenkauf for purchases in OXID', ], 'thumbnail' => 'out/pictures/picture.png', - 'version' => '3.0.9-rc.1', + 'version' => '3.0.9', 'author' => 'OXID Solution Catalysts', 'url' => 'https://www.oxid-esales.com', 'email' => 'info@oxid-esales.com', 'controllers' => [ - 'EasyCreditDispatcher' => \OxidProfessionalServices\EasyCredit\Application\Controller\EasyCreditDispatcherController::class, + 'EasyCreditDispatcher' => EasyCreditDispatcherController::class, # Admin - 'EasyCreditOrderEasyCredit' => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOrderEasyCreditController::class, + 'EasyCreditOrderEasyCredit' => EasyCreditOrderEasyCreditController::class, # Widgets - 'easycreditexamplecalculation' => \OxidProfessionalServices\EasyCredit\Application\Component\Widget\EasyCreditExampleCalculation::class, - 'easycreditexamplecalculationpopup' => \OxidProfessionalServices\EasyCredit\Application\Component\Widget\EasyCreditExampleCalculationPopup::class, - - // To delete - 'easycreditoverview' => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOverviewController::class, - 'easycreditoverview_list' => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOverviewListController::class, - 'easycreditoverview_main' => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOverviewMainController::class, - + 'easycreditexamplecalculation' => EasyCreditExampleCalculation::class, + 'easycreditexamplecalculationpopup' => EasyCreditExampleCalculationPopup::class, ], 'extend' => [ # extended controller - \OxidEsales\Eshop\Application\Controller\PaymentController::class => \OxidProfessionalServices\EasyCredit\Application\Controller\EasyCreditPaymentController::class, - \OxidEsales\Eshop\Application\Controller\OrderController::class => \OxidProfessionalServices\EasyCredit\Application\Controller\EasyCreditOrderController::class, + PaymentController::class => EasyCreditPaymentController::class, + OrderController::class => EasyCreditOrderController::class, # Extended admin controller - \OxidEsales\Eshop\Application\Controller\Admin\OrderAddress::class => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOrderAddressController::class, - \OxidEsales\Eshop\Application\Controller\Admin\OrderArticle::class => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOrderArticleController::class, - \OxidEsales\Eshop\Application\Controller\Admin\OrderOverview::class => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOrderOverviewController::class, - \OxidEsales\Eshop\Application\Controller\Admin\OrderList::class => \OxidProfessionalServices\EasyCredit\Application\Controller\Admin\EasyCreditOrderListController::class, + OrderAddress::class => EasyCreditOrderAddressController::class, + OrderArticle::class => EasyCreditOrderArticleController::class, + OrderOverview::class => EasyCreditOrderOverviewController::class, + OrderList::class => EasyCreditOrderListController::class, # Extending core classes - \OxidEsales\Eshop\Core\Session::class => \OxidProfessionalServices\EasyCredit\Core\Domain\EasyCreditSession::class, - \OxidEsales\Eshop\Application\Model\Payment::class => \OxidProfessionalServices\EasyCredit\Core\Domain\EasyCreditPayment::class, - \OxidEsales\Eshop\Application\Model\Basket::class => \OxidProfessionalServices\EasyCredit\Core\Domain\EasyCreditBasket::class, - \OxidEsales\Eshop\Application\Model\Order::class => \OxidProfessionalServices\EasyCredit\Core\Domain\EasyCreditOrder::class + Session::class => EasyCreditSession::class, + \OxidEsales\Eshop\Application\Model\Payment::class => EasyCreditPayment::class, + \OxidEsales\Eshop\Application\Model\Basket::class => EasyCreditBasket::class, + \OxidEsales\Eshop\Application\Model\Order::class => EasyCreditOrder::class, ], 'templates' => [ 'page/checkout/inc/payment_easycreditinstallment.tpl' => 'oxps/easycredit/Application/views/page/checkout/inc/oxpseasycredit_payment_easycreditinstallment.tpl', @@ -194,7 +207,7 @@ 'template' => 'order_main.tpl', 'block' => 'admin_order_main_form_details', 'file' => 'Application/views/blocks/admin/oxpseasycredit_order_main_form_details.tpl', - ] + ], ], 'settings' => [ [ @@ -256,7 +269,7 @@ 'name' => 'oxpsECLogging', 'type' => 'bool', 'value' => false, - ] + ], ], 'events' => [ 'onActivate' => '\OxidProfessionalServices\EasyCredit\Core\Events::onActivate', diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..dca3584 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,11 @@ +parameters: + paths: + - Application + - Core + scanDirectories: + - ./source # for OXID dependencies + - ./.phpstorm.meta.php # for _parent class definitions + level: 1 + ignoreErrors: + - '#::\$oxorder__#' + - '#Call to static method getDb\(\)#' \ No newline at end of file diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..256e4a4 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + ./tests + + + ./tests/Unit + + + + + Application + Core + + + + + + \ No newline at end of file diff --git a/tests/Unit/Core/Dto/EasyCreditStorageTest.php b/tests/Unit/Core/Dto/EasyCreditStorageTest.php new file mode 100644 index 0000000..e3733a8 --- /dev/null +++ b/tests/Unit/Core/Dto/EasyCreditStorageTest.php @@ -0,0 +1,104 @@ +assertEquals(60 * 29, $this->invokeMethod($easyCreditStorage, 'getStorageExpiredTimeRange')); + } + + /** + * Invoke protected/private method of a class. + * + * @param object $object Instantiated object that we will run method on. + * @param string $methodName Method name to call + * @param array $parameters Array of parameters to pass into method. + * + * @return mixed Method return. + */ + public function invokeMethod(&$object, $methodName, array $parameters = []) + { + $reflection = new \ReflectionClass(get_class($object)); + $method = $reflection->getMethod($methodName); + $method->setAccessible(true); + + return $method->invokeArgs($object, $parameters); + } + public function testHasExpiredAfterCreation(): void + { + $oTest = new EasyCreditStorage( + 'TEST', + 'TEST', + 'TEST', + 450.0 + ); + + $this->assertFalse($oTest->hasExpired()); + } + + /** + * Verify that hasExpired correctly returns true if and only if + * the last update occurred longer than the storage expiration range ago. + */ + public function testHasExpired(): void + { + $easyCreditStorage = new EasyCreditStorage('tbVorgangskennung', 'fachlicheVorgangskennung', 'authorizationHash', 100.0); + $lastUpdateProperty = (new \ReflectionClass($easyCreditStorage))->getProperty('lastUpdate'); + $lastUpdateProperty->setAccessible(true); + + // Test when lastUpdate is exactly at the expired time + $lastUpdateProperty->setValue($easyCreditStorage, time() - $this->invokeMethod($easyCreditStorage, 'getStorageExpiredTimeRange')); + $this->assertFalse($easyCreditStorage->hasExpired()); + + // Test when lastUpdate is just before the expired time + $lastUpdateProperty->setValue($easyCreditStorage, time() - $this->invokeMethod($easyCreditStorage, 'getStorageExpiredTimeRange') + 1); + $this->assertFalse($easyCreditStorage->hasExpired()); + + // Test when lastUpdate is just after the expired time + $lastUpdateProperty->setValue($easyCreditStorage, time() - $this->invokeMethod($easyCreditStorage, 'getStorageExpiredTimeRange') - 1); + $this->assertTrue($easyCreditStorage->hasExpired()); + + // Test when lastUpdate is not set + $lastUpdateProperty->setValue($easyCreditStorage, null); + $this->assertTrue($easyCreditStorage->hasExpired()); + } + public function testUserSetLastNameSuccessful() + { + $easyCreditStorage = new EasyCreditStorage( + 'TEST', + 'TEST', + 'TEST', + 450.0 + ); + $easyCreditStorage->setInterestAmount(100.01); + $easyCreditStorage->setAllgemeineVorgangsdaten('TEST'); + $easyCreditStorage->setRatenplanTxt('TEST'); + $easyCreditStorage->setTilgungsplanTxt('TEST'); + $this->assertEquals(100.01, $easyCreditStorage->getInterestAmount()); + $this->assertEquals('TEST', $easyCreditStorage->getAllgemeineVorgangsdaten()); + $this->assertEquals('TEST', $easyCreditStorage->getRatenplanTxt()); + $this->assertEquals('TEST', $easyCreditStorage->getTilgungsplanTxt()); + $this->assertEquals(450.0, $easyCreditStorage->getAuthorizedAmount()); + $this->assertEquals('TEST', $easyCreditStorage->getAuthorizationHash()); + $this->assertEquals('TEST', $easyCreditStorage->getTbVorgangskennung()); + $this->assertEquals('TEST', $easyCreditStorage->getFachlicheVorgangskennung()); + } +}