diff --git a/application/controllers/admin/fcpayone_main.php b/application/controllers/admin/fcpayone_main.php
index c25b7969..e9d8ec51 100755
--- a/application/controllers/admin/fcpayone_main.php
+++ b/application/controllers/admin/fcpayone_main.php
@@ -1155,4 +1155,13 @@ private function writeFile($filename, $content, $destinationPath)
}
}
+ public function isPayPalV2DelAddressActive()
+ {
+ $aConfBools = $this->fcpoGetConfBools();
+ $sConfigOptionName = "blFCPOPayPalV2DelAddress";
+ if (!isset($aConfBools[$sConfigOptionName]) || $aConfBools[$sConfigOptionName] === true) {
+ return true;
+ }
+ return false;
+ }
}
diff --git a/application/helper/fcpobasehelper.php b/application/helper/fcpobasehelper.php
index 9c9ad438..4597b118 100644
--- a/application/helper/fcpobasehelper.php
+++ b/application/helper/fcpobasehelper.php
@@ -1,5 +1,24 @@
.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
abstract class fcpobasehelper
{
/**
diff --git a/application/helper/fcpopaymenthelper.php b/application/helper/fcpopaymenthelper.php
index b83b7431..3e8e3ab2 100644
--- a/application/helper/fcpopaymenthelper.php
+++ b/application/helper/fcpopaymenthelper.php
@@ -1,5 +1,24 @@
.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
class fcpopaymenthelper extends fcpobasehelper
{
/**
diff --git a/application/helper/fcpopaypalhelper.php b/application/helper/fcpopaypalhelper.php
index 1c2291e7..88498537 100644
--- a/application/helper/fcpopaypalhelper.php
+++ b/application/helper/fcpopaypalhelper.php
@@ -1,5 +1,24 @@
.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
class fcpopaypalhelper extends fcpobasehelper
{
const PPE_EXPRESS = 'fcpopaypal_express';
@@ -118,7 +137,7 @@ protected function getClientId()
protected function getSupportedLocaleCode($sLocale = null)
{
if (!$sLocale || !in_array($sLocale, $this->aSupportedLocales)) {
- return 'en_US';
+ $sLocale = 'en_US';
}
return $sLocale;
}
diff --git a/application/helper/fcporedirecthelper.php b/application/helper/fcporedirecthelper.php
index 297a807c..0b272772 100644
--- a/application/helper/fcporedirecthelper.php
+++ b/application/helper/fcporedirecthelper.php
@@ -1,5 +1,24 @@
.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
class fcporedirecthelper extends fcpobasehelper
{
/**
@@ -103,26 +122,23 @@ public function getSuccessUrl($sRefNr = false, $sRedirectFunction = false, $sTok
$sAddParams .= '&refnr=' . $sRefNr;
}
- if (!empty($sRedirectFunction)) {
- $sAddParams .= '&fnc='.$sRedirectFunction;
- } else {
- $sAddParams .= '&fnc=execute';
+ if (empty($sRedirectFunction)) {
+ $sRedirectFunction = "execute";
}
+ $sAddParams .= '&fnc='.$sRedirectFunction;
-
+ if (empty($sDeliveryMD5) && $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5')) {
+ $sDeliveryMD5 = $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5');
+ }
if (!empty($sDeliveryMD5)) {
- $sAddParams .= '&sDeliveryAddressMD5=' . $sDeliveryMD5;
- } elseif ($this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5')) {
- $sAddParams .= '&sDeliveryAddressMD5=' . $this->getMainHelper()->fcpoGetRequestParameter('sDeliveryAddressMD5');
+ $sAddParams .= '&sDeliveryAddressMD5='.$sDeliveryMD5;
}
- $blDownloadableProductsAgreement = $this->getMainHelper()->fcpoGetRequestParameter('oxdownloadableproductsagreement');
- if ($blDownloadableProductsAgreement) {
+ if ($this->getMainHelper()->fcpoGetRequestParameter('oxdownloadableproductsagreement')) {
$sAddParams .= '&fcdpa=1'; // rewrite for oxdownloadableproductsagreement-param because of length-restriction
}
- $blServiceProductsAgreement = $this->getMainHelper()->fcpoGetRequestParameter('oxserviceproductsagreement');
- if ($blServiceProductsAgreement) {
+ if ($this->getMainHelper()->fcpoGetRequestParameter('oxserviceproductsagreement')) {
$sAddParams .= '&fcspa=1'; // rewrite for oxserviceproductsagreement-param because of length-restriction
}
diff --git a/application/views/admin/de/fcPayOne_lang.php b/application/views/admin/de/fcPayOne_lang.php
index ba7eb169..d6368ff3 100755
--- a/application/views/admin/de/fcPayOne_lang.php
+++ b/application/views/admin/de/fcPayOne_lang.php
@@ -270,7 +270,9 @@
'FCPO_EXPORT_CONFIG' => "Konfiguration exportieren",
'FCPO_PAYPAL_DELADDRESS' => 'Rechnungsadresse bei fehlender Lieferadresse als Lieferadresse übergeben.',
+ 'FCPO_PAYPALV2_DELADDRESS' => 'Rechnungsadresse bei fehlender Lieferadresse als Lieferadresse übergeben.',
'FCPO_HELP_PAYPAL_DELADDRESS' => 'Wird für den PayPal Verkäuferschutz benötigt.',
+ 'FCPO_HELP_PAYPALV2_DELADDRESS' => 'Wird für den PayPal Verkäuferschutz benötigt.',
'FCPO_PAYPAL_LOGOS' => 'Hier können Sie die verwendeten PayPal Express Logos hinterlegen.',
'FCPO_PAYPAL_LOGOS_ACTIVE' => 'Aktiv',
'FCPO_PAYPAL_LOGOS_LANG' => 'Sprache',
diff --git a/application/views/admin/en/fcPayOne_lang.php b/application/views/admin/en/fcPayOne_lang.php
index 202dc8b2..851fa693 100644
--- a/application/views/admin/en/fcPayOne_lang.php
+++ b/application/views/admin/en/fcPayOne_lang.php
@@ -335,7 +335,9 @@
'FCPO_EXPORT_CONFIG' => "Export configuration",
'FCPO_PAYPAL_DELADDRESS' => 'Transmit the billing-address as delivery-address if delivery-address is missing.',
+ 'FCPO_PAYPALV2_DELADDRESS' => 'Transmit the billing-address as delivery-address if delivery-address is missing.',
'FCPO_HELP_PAYPAL_DELADDRESS' => 'This is used for the PayPal seller protection.',
+ 'FCPO_HELP_PAYPALV2_DELADDRESS' => 'This is used for the PayPal seller protection.',
'FCPO_PAYPAL_LOGOS' => 'You can upload the PayPal Express logos here.',
'FCPO_PAYPAL_LOGOS_ACTIVE' => 'active',
'FCPO_PAYPAL_LOGOS_LANG' => 'language',
diff --git a/application/views/admin/tpl/fcpayone_main.tpl b/application/views/admin/tpl/fcpayone_main.tpl
index 9f690231..256e29e8 100755
--- a/application/views/admin/tpl/fcpayone_main.tpl
+++ b/application/views/admin/tpl/fcpayone_main.tpl
@@ -541,6 +541,17 @@
fcpoIsLogoAdded()}] class="exp"[{/if}]>
[{oxmultilang ident="FCPO_CONFIG_GROUP_PAYPALV2"}]
+
+ -
+
+ isPayPalV2DelAddressActive()}]checked[{/if}]>
+ [{oxinputhelp ident="FCPO_HELP_PAYPALV2_DELADDRESS"}]
+
+ -
+ [{oxmultilang ident="FCPO_PAYPALV2_DELADDRESS"}]
+
+
+
-
diff --git a/extend/application/controllers/fcPayOneOrderView.php b/extend/application/controllers/fcPayOneOrderView.php
index c539ea1e..1945efef 100755
--- a/extend/application/controllers/fcPayOneOrderView.php
+++ b/extend/application/controllers/fcPayOneOrderView.php
@@ -520,7 +520,15 @@ protected function _fcpoThrowException($sMessage)
* @param void
* @return void
*/
- protected function _handlePayPalExpressCall($sPaymentId) {
+ protected function _handlePayPalExpressCall($sPaymentId)
+ {
+ if ($this->_oFcpoHelper->fcpoGetSessionVariable('blFcpoPayonePayPalExpressRetry') === true && !empty($this->_oFcpoHelper->fcpoGetSessionVariable('blFcpoPayonePayPalSuccessUrl'))) {
+ $this->_oFcpoHelper->fcpoDeleteSessionVariable('blFcpoPayonePayPalExpressRetry');
+ $sRedirectUrl = $this->_oFcpoHelper->fcpoGetSessionVariable('blFcpoPayonePayPalSuccessUrl');
+ $this->_oFcpoHelper->fcpoDeleteSessionVariable('blFcpoPayonePayPalSuccessUrl');
+ $this->_oFcpoHelper->fcpoGetUtils()->redirect($sRedirectUrl, false);
+ }
+
$sWorkorderId = $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoWorkorderId');
if ($sWorkorderId) {
$oRequest = $this->_oFcpoHelper->getFactoryObject('fcporequest');
@@ -704,24 +712,22 @@ protected function _validateTermsAndConditions()
/**
* Splits street and number from concatenated combofield
- *
+ *
* @param string $sPayPalStreet
* @return array
*/
- protected function _fcpoSplitAddress($sPayPalStreet)
+ protected function _fcpoSplitAddress($sStreetAndStreetNr)
{
- $sStreetNr = '';
- if(preg_match('/\s\d/', $sPayPalStreet, $match)) {
- $iEndOfStreetPos = strpos($sPayPalStreet, $match[0]);
- $iStartOfStreetNrPos = $iEndOfStreetPos +1; // skip space between street and street nr
- $sStreetNr = substr($sPayPalStreet, $iStartOfStreetNrPos);
- $sPayPalStreet = substr($sPayPalStreet, 0, $iEndOfStreetPos);
+ preg_match('/^([^\d]*[^\d\s]) *(\d.*)$/', $sStreetAndStreetNr, $matches);
+ $sStreet = $sStreetAndStreetNr; // fallback for when splitting doesnt deliver results
+ $sStreetNr = "";
+ if (is_array($matches) && count($matches) >= 2) {
+ $sStreet = $matches[1];
+ $sStreetNr = $matches[2];
}
-
- return array($sPayPalStreet, $sStreetNr);
+ return array($sStreet, $sStreetNr);
}
-
/**
* Searches an existing addressid by extracting response of payone
*
diff --git a/extend/application/models/fcPayOneOrder.php b/extend/application/models/fcPayOneOrder.php
index b63152db..81ec7e8e 100755
--- a/extend/application/models/fcPayOneOrder.php
+++ b/extend/application/models/fcPayOneOrder.php
@@ -493,8 +493,6 @@ protected function _fcpoFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder) {
$this->_blFinishingSave = true;
$this->save();
- $this->_fcpoSaveAfterRedirect($blSaveAfterRedirect);
-
// deleting remark info only when order is finished
$this->_oFcpoHelper->fcpoDeleteSessionVariable('ordrem');
$this->_oFcpoHelper->fcpoDeleteSessionVariable('stsprotection');
@@ -526,6 +524,8 @@ protected function _fcpoFinalizeOrder($oBasket, $oUser, $blRecalculatingOrder) {
oxNew(\OxidEsales\Eshop\Core\Counter::class)->update($this->_getCounterIdent(), $this->oxorder__oxordernr->value);
}
+ $this->_fcpoSaveAfterRedirect($blSaveAfterRedirect);
+
$this->_oFcpoHelper->fcpoDeleteSessionVariable('fcpoordernotchecked');
$this->_oFcpoHelper->fcpoDeleteSessionVariable('fcpoWorkorderId');
@@ -960,10 +960,10 @@ protected function _fcpoFinishOrder($blRecalculatingOrder, $oUser, $oBasket, $oU
* @param bool $blSaveAfterRedirect
* @return void
*/
- protected function _fcpoSaveAfterRedirect($blSaveAfterRedirect)
+ protected function _fcpoSaveAfterRedirect($blSaveAfterRedirect)
{
- if ($blSaveAfterRedirect === true) {
- $sQuery = "UPDATE fcpotransactionstatus SET fcpo_ordernr = '{$this->oxorder__oxordernr->value}' WHERE fcpo_txid = '" . $this->_oFcpoHelper->fcpoGetSessionVariable('fcpoTxid') . "'";
+ if ($blSaveAfterRedirect === true && !empty($this->oxorder__fcpotxid->value)) {
+ $sQuery = "UPDATE fcpotransactionstatus SET fcpo_ordernr = '{$this->oxorder__oxordernr->value}' WHERE fcpo_txid = '".$this->oxorder__fcpotxid->value."'";
$this->_oFcpoDb->Execute($sQuery);
}
}
@@ -1665,8 +1665,24 @@ public function fcIsPayPalOrder()
$blReturn = false;
if (in_array($this->oxorder__oxpaymenttype->value, [
'fcpopaypal',
- 'fcpopaypalv2',
fcpopaypalhelper::PPE_EXPRESS,
+ ])) {
+ $blReturn = true;
+ }
+ return $blReturn;
+ }
+
+ /**
+ * Method checks via current paymenttype is of payone paypal V2 type
+ *
+ * @param void
+ * @return boolean
+ */
+ public function fcIsPayPalV2Order()
+ {
+ $blReturn = false;
+ if (in_array($this->oxorder__oxpaymenttype->value, [
+ 'fcpopaypalv2',
fcpopaypalhelper::PPE_V2_EXPRESS,
])) {
$blReturn = true;
@@ -1860,6 +1876,10 @@ protected function _fcpoFlagOrderPaymentAsRedirect($blFlaggedAsRedirect = true)
*/
protected function _fcpoHandleAuthorizationRedirect($aResponse, $sRefNr, $sAuthorizationType, $sMode, $blReturnRedirectUrl)
{
+ if ($aResponse['status'] == 'REDIRECT' && in_array($this->oxorder__oxpaymenttype->value, [fcpopaypalhelper::PPE_EXPRESS, fcpopaypalhelper::PPE_V2_EXPRESS])) {
+ $this->_oFcpoHelper->fcpoSetSessionVariable('blFcpoPayonePayPalExpressRetry', true);
+ }
+
$this->_fcpoFlagOrderPaymentAsRedirect();
$oConfig = $this->_oFcpoHelper->fcpoGetConfig();
$oUtils = $this->_oFcpoHelper->fcpoGetUtils();
diff --git a/lib/fcporequest.php b/lib/fcporequest.php
index 37c5d6eb..044ce3b2 100755
--- a/lib/fcporequest.php
+++ b/lib/fcporequest.php
@@ -271,8 +271,8 @@ protected function setAuthorizationParameters($oOrder, $oUser, $aDynvalue, $sRef
$blIsWalletTypePaymentWithDelAddress = (
$oOrder->oxorder__oxpaymenttype->value == 'fcpopaydirekt' ||
- $oOrder->fcIsPayPalOrder() === true &&
- $this->getConfig()->getConfigParam('blFCPOPayPalDelAddress') === true
+ ($oOrder->fcIsPayPalOrder() === true && $this->getConfig()->getConfigParam('blFCPOPayPalDelAddress') === true) ||
+ ($oOrder->fcIsPayPalV2Order() === true && $this->getConfig()->getConfigParam('blFCPOPayPalV2DelAddress') === true)
);
$blIsBNPLPayment = (
@@ -633,6 +633,10 @@ protected function setPaymentParameters($oOrder, $aDynvalue, $sRefNr, $blIsPreau
if ($blAddRedirectUrls === true) {
$this->_addRedirectUrls('payment', $sRefNr);
+
+ if (in_array($sPaymentId, [fcpopaypalhelper::PPE_EXPRESS, fcpopaypalhelper::PPE_V2_EXPRESS]) && !empty($this->getParameter('successurl'))) {
+ $this->_oFcpoHelper->fcpoSetSessionVariable('blFcpoPayonePayPalSuccessUrl', $this->getParameter('successurl'));
+ }
}
return true;
}
@@ -956,8 +960,6 @@ protected function addParametersOnlineTransaction($oOrder, $aDynvalue)
}
- # protected function addInvoicePosition($sId, $dPrice, $sItemType, $iAmount, $sDesc, $dVat, $sCategoryUrl = false)
-
protected function addInvoicePosition($iIndex, $sId, $dPrice, $sItemType, $dItemAmount, $sDesc, $dVat)
{
$this->addParameter('id[' . $iIndex . ']', $sId);
@@ -1027,7 +1029,7 @@ public function addProductInfo($oOrder, $aPositions = false, $blDebit = false)
if ($oOrder->oxorder__oxpaycost->value != 0 && ($aPositions === false || ($blDebit === false || array_key_exists('oxpaycost', $aPositions) !== false))) {
$sPayDesc = $oLang->translateString('FCPO_DEDUCTION', null, false);
if ($oOrder->oxorder__oxpaycost->value > 0) {
- $sPayDesc .= $oLang->translateString('FCPO_SURCHARGE', null, false);
+ $sPayDesc = $oLang->translateString('FCPO_SURCHARGE', null, false);
}
$sPayDesc .= ' ' . str_replace(':', '', $oLang->translateString('FCPO_PAYMENTTYPE', null, false));
@@ -1413,12 +1415,8 @@ protected function _fcpoAddRatePayParameters($oOrder, $aDynvalue)
/**
* Adding products from basket session into call
- * Adding products from basket session into call
- *
*
- * @param void
* @param string $sDeliverySetId
- * @return void
* @return object
*/
protected function _fcpoAddBasketItemsFromSession($sDeliverySetId = false)
@@ -1470,7 +1468,7 @@ protected function _fcpoAddBasketItemsFromSession($sDeliverySetId = false)
if ($sPaymentCosts != 0) {
$sPayDesc = $oLang->translateString('FCPO_DEDUCTION', null, false);
if ($sPaymentCosts > 0) {
- $sPayDesc .= $oLang->translateString('FCPO_SURCHARGE', null, false);
+ $sPayDesc = $oLang->translateString('FCPO_SURCHARGE', null, false);
}
$sPayDesc .= ' ' . str_replace(':', '', $oLang->translateString('FCPO_PAYMENTTYPE', null, false));
@@ -1541,7 +1539,7 @@ protected function _fcpoGetCentPrice($mValue)
$dBruttoPricePosSum = $oPrice->getBruttoPrice();
$dAmount = $mValue->getAmount();
$dBruttoPrice = round($dBruttoPricePosSum/$dAmount, 2);
- } else if (is_float($mValue)) {
+ } else if (is_numeric($mValue)) {
$dBruttoPrice = round($mValue, 2);
}
@@ -2397,7 +2395,11 @@ public function sendRequestGenericPayment($sPaymentType, $sWorkorderId = false)
$this->_fcpoAddBasketItemsFromSession();
}
- $this->_addRedirectUrls('basket', false, 'fcpoHandlePayPalExpress');
+ $sRedirectFuntion = 'fcpoHandlePayPalExpress';
+ if ($sPaymentType == fcpopaypalhelper::PPE_V2_EXPRESS) {
+ $sRedirectFuntion = 'fcpoHandlePayPalExpressV2';
+ }
+ $this->_addRedirectUrls('basket', false, $sRedirectFuntion);
return $this->send();
}
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index e2679cba..be6c8da3 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -15,6 +15,7 @@
../application/models
+ ../application/helper
../application/controllers
../extend
diff --git a/tests/unit/fcPayOne/application/helper/fcpopaymenthelperTest.php b/tests/unit/fcPayOne/application/helper/fcpopaymenthelperTest.php
new file mode 100644
index 00000000..765a3e0f
--- /dev/null
+++ b/tests/unit/fcPayOne/application/helper/fcpopaymenthelperTest.php
@@ -0,0 +1,74 @@
+.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
+use OxidEsales\Eshop\Core\UtilsObject;
+use OxidEsales\EshopCommunity\Application\Model\Payment;
+use OxidEsales\Eshop\Core\Field;
+
+class fcpopaymenthelperTest extends OxidTestCase
+{
+ public function testLoadPaymentMethodFalse()
+ {
+ $oPayment = $this->getMockBuilder(Payment::class)->disableOriginalConstructor()->getMock();
+ $oPayment->method('load')->willReturn(false);
+
+ UtilsObject::setClassInstance(Payment::class, $oPayment);
+
+ $oClassToTest = new fcpopaymenthelper();
+ $sResult = $oClassToTest->loadPaymentMethod('test');
+
+ $this->assertFalse($sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+
+ public function testIsPaymentMethodActive()
+ {
+ $oPayment = $this->getMockBuilder('oxpayment')->disableOriginalConstructor()->getMock();
+ $oPayment->method('load')->willReturn(true);
+ $oPayment->method('__get')->willReturn(new Field(true));
+
+ UtilsObject::setClassInstance('oxpayment', $oPayment);
+
+ $oClassToTest = new fcpopaymenthelper();
+ $sResult = $oClassToTest->isPaymentMethodActive('test');
+
+ $this->assertTrue($sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+
+ public function testIsLiveMode()
+ {
+ $oPayment = $this->getMockBuilder('oxpayment')->disableOriginalConstructor()->getMock();
+ $oPayment->method('load')->willReturn(true);
+ $oPayment->method('__get')->willReturn(new Field(true));
+
+ UtilsObject::setClassInstance('oxpayment', $oPayment);
+
+ $oClassToTest = new fcpopaymenthelper();
+ $sResult = $oClassToTest->isLiveMode('test');
+
+ $this->assertTrue($sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/fcPayOne/application/helper/fcpopaypalhelperTest.php b/tests/unit/fcPayOne/application/helper/fcpopaypalhelperTest.php
new file mode 100644
index 00000000..1a1af13a
--- /dev/null
+++ b/tests/unit/fcPayOne/application/helper/fcpopaypalhelperTest.php
@@ -0,0 +1,135 @@
+.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
+use OxidEsales\Eshop\Core\UtilsObject;
+
+class fcpopaypalhelperTest extends OxidTestCase
+{
+ public function testGetButtonColor()
+ {
+ $sExpected = "gold";
+
+ $oConfig = $this->getMockBuilder(\OxidEsales\Eshop\Core\Config::class)->disableOriginalConstructor()->getMock();
+ $oConfig->method('getConfigParam')->willReturn($sExpected);
+
+ $oHelper = $this->getMockBuilder(fcpohelper::class)->disableOriginalConstructor()->getMock();
+ $oHelper->method('fcpoGetConfig')->willReturn($oConfig);
+
+ UtilsObject::setClassInstance(fcpohelper::class, $oHelper);
+
+ $oClassToTest = new fcpopaypalhelper();
+ $sResult = $oClassToTest->getButtonColor();
+
+ $this->assertEquals($sExpected, $sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+
+ public function testGetButtonShape()
+ {
+ $sExpected = "rect";
+
+ $oConfig = $this->getMockBuilder(\OxidEsales\Eshop\Core\Config::class)->disableOriginalConstructor()->getMock();
+ $oConfig->method('getConfigParam')->willReturn($sExpected);
+
+ $oHelper = $this->getMockBuilder(fcpohelper::class)->disableOriginalConstructor()->getMock();
+ $oHelper->method('fcpoGetConfig')->willReturn($oConfig);
+
+ UtilsObject::setClassInstance(fcpohelper::class, $oHelper);
+
+ $oClassToTest = new fcpopaypalhelper();
+ $sResult = $oClassToTest->getButtonShape();
+
+ $this->assertEquals($sExpected, $sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+
+ public function testShowBNPLButton()
+ {
+ $oConfig = $this->getMockBuilder(\OxidEsales\Eshop\Core\Config::class)->disableOriginalConstructor()->getMock();
+ $oConfig->method('getConfigParam')->willReturn(true);
+
+ $oHelper = $this->getMockBuilder(fcpohelper::class)->disableOriginalConstructor()->getMock();
+ $oHelper->method('fcpoGetConfig')->willReturn($oConfig);
+
+ UtilsObject::setClassInstance(fcpohelper::class, $oHelper);
+
+ $oClassToTest = new fcpopaypalhelper();
+ $sResult = $oClassToTest->showBNPLButton();
+
+ $this->assertTrue($sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+
+ public function testGetJavascriptUrl()
+ {
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isLiveMode')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
+
+ $oCurrency = new \stdClass();
+ $oCurrency->name = "EURTEST";
+
+ $oBasket = $this->getMockBuilder(OxidEsales\Eshop\Application\Model\Basket::class)->disableOriginalConstructor()->getMock();
+ $oBasket->method('getBasketCurrency')->willReturn($oCurrency);
+
+ $oSession = $this->getMockBuilder(\OxidEsales\Eshop\Core\Session::class)->disableOriginalConstructor()->getMock();
+ $oSession->method('getBasket')->willReturn($oBasket);
+
+ $oConfig = $this->getMockBuilder(\OxidEsales\Eshop\Core\Config::class)->disableOriginalConstructor()->getMock();
+ $oConfig->method('getConfigParam')->willReturnMap([
+ ['blFCPOPayPalV2MerchantID', null, "merchantId"],
+ ['blFCPOPayPalV2BNPL', null, true],
+ ]);
+
+ $oLang = $this->getMockBuilder(\OxidEsales\Eshop\Core\Language::class)->disableOriginalConstructor()->getMock();
+ $oLang->method('translateString')->willReturn('not_found');
+
+ $oHelper = $this->getMockBuilder(fcpohelper::class)->disableOriginalConstructor()->getMock();
+ $oHelper->method('fcpoGetConfig')->willReturn($oConfig);
+ $oHelper->method('fcpoGetSession')->willReturn($oSession);
+ $oHelper->method('fcpoGetLang')->willReturn($oLang);
+
+ UtilsObject::setClassInstance(fcpohelper::class, $oHelper);
+
+ $oClassToTest = new fcpopaypalhelper();
+ $sResult = $oClassToTest->getJavascriptUrl();
+
+ $this->assertStringContainsString("FZ8jE7shhaY2mVydsWsSrjmHk0qJxmgJoWgHESqyoG35jL", $sResult);
+ $this->assertStringContainsString("merchantId", $sResult);
+ $this->assertStringContainsString("EURTEST", $sResult);
+ $this->assertStringContainsString("enable-funding=paylater", $sResult);
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
+ }
+
+ public function testGetInstance()
+ {
+ $oResult = fcpopaypalhelper::getInstance();
+ $this->assertInstanceOf(fcpopaypalhelper::class, $oResult);
+
+ fcpopaypalhelper::destroyInstance();
+ }
+}
\ No newline at end of file
diff --git a/tests/unit/fcPayOne/application/helper/fcporedirecthelperTest.php b/tests/unit/fcPayOne/application/helper/fcporedirecthelperTest.php
new file mode 100644
index 00000000..38d2f703
--- /dev/null
+++ b/tests/unit/fcPayOne/application/helper/fcporedirecthelperTest.php
@@ -0,0 +1,69 @@
+.
+ *
+ * @link http://www.payone.de
+ * @copyright (C) Payone GmbH
+ * @version OXID eShop CE
+ */
+
+use OxidEsales\Eshop\Core\UtilsObject;
+use OxidEsales\EshopCommunity\Application\Model\Payment;
+use OxidEsales\Eshop\Core\Field;
+
+class fcporedirecthelperTest extends OxidTestCase
+{
+ public function testGetErrorUrl()
+ {
+ $sExpected = 'abortTest';
+
+ $oClassToTest = new fcporedirecthelper();
+ $sResult = $oClassToTest->getErrorUrl($sExpected, true);
+
+ $this->assertStringContainsString($sExpected, $sResult);
+ $this->assertStringContainsString('fcpoamzaction=logoff', $sResult);
+ }
+
+ public function testGetSuccessUrl()
+ {
+ $oSession = $this->getMockBuilder(\OxidEsales\Eshop\Core\Session::class)->disableOriginalConstructor()->getMock();
+ $oSession->method('sid')->willReturn('sid12345');
+
+ $oConfig = $this->getMockBuilder(\OxidEsales\Eshop\Core\Config::class)->disableOriginalConstructor()->getMock();
+ $oConfig->method('getCurrentShopUrl')->willReturn('shopURL');
+
+ $oHelper = $this->getMockBuilder(fcpohelper::class)->disableOriginalConstructor()->getMock();
+ $oHelper->method('fcpoGetRequestParameter')->willReturn('testValue');
+ $oHelper->method('fcpoGetSession')->willReturn($oSession);
+ $oHelper->method('fcpoGetConfig')->willReturn($oConfig);
+
+ UtilsObject::setClassInstance(fcpohelper::class, $oHelper);
+
+ $oClassToTest = new fcporedirecthelper();
+ $sResult = $oClassToTest->getSuccessUrl('testRefNr', false, false, false);
+
+ $this->assertStringContainsString('sid12345', $sResult);
+ $this->assertStringContainsString('testValue', $sResult);
+ $this->assertStringContainsString('testRefNr', $sResult);
+ $this->assertStringContainsString('shopURL', $sResult);
+
+ UtilsObject::resetClassInstances();
+ }
+
+ public function testDestroyInstance()
+ {
+ $this->assertNull(fcporedirecthelper::destroyInstance());
+ }
+}
diff --git a/tests/unit/fcPayOne/application/models/fcpayone_ajaxTest.php b/tests/unit/fcPayOne/application/models/fcpayone_ajaxTest.php
index 78dbba09..1534ef4e 100755
--- a/tests/unit/fcPayOne/application/models/fcpayone_ajaxTest.php
+++ b/tests/unit/fcPayOne/application/models/fcpayone_ajaxTest.php
@@ -538,4 +538,46 @@ public function test__fcpoGetInsterestCaption_Coverage()
$this->assertEquals($sExpect, $sResponse);
}
+ public function testFcpoStartPayPalExpress()
+ {
+ $oTestObject = oxNew('fcpayone_ajax');
+
+ $aResponse = [
+ 'status' => 'REDIRECT',
+ 'workorderid' => '4711',
+ 'add_paydata[orderId]' => '47110815',
+ ];
+
+ $oRequest = $this->getMockBuilder(fcpoRequest::class)->disableOriginalConstructor()->getMock();
+ $oRequest->method('sendRequestGenericPayment')->willReturn($aResponse);
+
+ $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
+ $oHelper->method('getFactoryObject')->willReturn($oRequest);
+ $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
+
+ $sResult = $oTestObject->fcpoStartPayPalExpress();
+
+ $this->assertStringContainsString('47110815', $sResult);
+ }
+
+ public function testFcpoStartPayPalExpressError()
+ {
+ $oTestObject = oxNew('fcpayone_ajax');
+
+ $aResponse = [
+ 'status' => 'ERROR',
+ 'customermessage' => 'ERRORTEST',
+ ];
+
+ $oRequest = $this->getMockBuilder(fcpoRequest::class)->disableOriginalConstructor()->getMock();
+ $oRequest->method('sendRequestGenericPayment')->willReturn($aResponse);
+
+ $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
+ $oHelper->method('getFactoryObject')->willReturn($oRequest);
+ $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
+
+ $sResult = $oTestObject->fcpoStartPayPalExpress();
+
+ $this->assertStringContainsString('ERRORTEST', $sResult);
+ }
}
diff --git a/tests/unit/fcPayOne/extend/application/controllers/fcPayOneBasketViewTest.php b/tests/unit/fcPayOne/extend/application/controllers/fcPayOneBasketViewTest.php
index 6d703430..d34fb2fd 100755
--- a/tests/unit/fcPayOne/extend/application/controllers/fcPayOneBasketViewTest.php
+++ b/tests/unit/fcPayOne/extend/application/controllers/fcPayOneBasketViewTest.php
@@ -18,9 +18,11 @@
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/
+
+use OxidEsales\Eshop\Core\UtilsObject;
+
class Unit_fcPayOne_Extend_Application_Controllers_fcPayOneBasketView extends OxidTestCase
{
-
/**
* Call protected/private method of a class.
*
@@ -139,16 +141,18 @@ public function test__fcpoCheckForAmazonLogoff_Coverage() {
*/
public function test__fcpoIsPayPalExpressActive_Coverage()
{
- $oTestObject = oxNew('fcPayOneBasketView');
+ fcpopaymenthelper::destroyInstance();
- $oMockBasket = $this->getMock('oxBasket', array('fcpoIsPayPalExpressActive'));
- $oMockBasket->expects($this->any())->method('fcpoIsPayPalExpressActive')->will($this->returnValue(true));
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isPaymentMethodActive')->willReturn(true);
- $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
- $oHelper->expects($this->any())->method('getFactoryObject')->will($this->returnValue($oMockBasket));
- $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
+ $oTestObject = oxNew('fcPayOneBasketView');
$this->assertEquals(true, $oTestObject->_fcpoIsPayPalExpressActive());
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
}
/**
@@ -177,8 +181,10 @@ public function test_fcpoGetPayPalExpressPic_Coverage()
*/
public function test__fcpoGetPayPalExpressPic_Coverage()
{
- $oMockBasket = $this->getMock('oxBasket', array('fcpoGetPayPalExpressPic'));
- $oMockBasket->expects($this->any())->method('fcpoGetPayPalExpressPic')->will($this->returnValue('somePic.jpg'));
+ \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DELETE FROM fcpopayoneexpresslogos WHERE 1');
+
+ $expected = 'somePic.jpg';
+ \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('INSERT INTO fcpopayoneexpresslogos (oxid, fcpo_active, fcpo_langid, fcpo_logo, fcpo_default) VALUES ("unitTestLogo", 1, 0, "'.$expected.'", "1")');
$oMockConfig = $this->getMock('oxConfig', array('getCurrentShopUrl'));
$oMockConfig->expects($this->any())->method('getCurrentShopUrl')->will($this->returnValue('http://someurl.com/'));
@@ -187,16 +193,17 @@ public function test__fcpoGetPayPalExpressPic_Coverage()
$oTestObject->expects($this->any())->method('getConfig')->will($this->returnValue($oMockConfig));
$oHelper = $this->getMock('fcpohelper', array('getFactoryObject', 'fcpoFileExists'));
- $oHelper->expects($this->any())->method('getFactoryObject')->will($this->returnValue($oMockBasket));
$oHelper->expects($this->any())->method('fcpoFileExists')->will($this->returnValue(true));
$this->invokeSetAttribute($oTestObject, '_sPayPalExpressLogoPath', 'somePath/');
$this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
$sResponse = $this->invokeMethod($oTestObject, '_fcpoGetPayPalExpressPic');
- $sExpect = 'http://someurl.com/somePath/somePic.jpg';
+ $sExpect = 'http://someurl.com/somePath/'.$expected;
$this->assertEquals($sExpect, $sResponse);
+
+ \OxidEsales\Eshop\Core\DatabaseProvider::getDb()->execute('DELETE FROM fcpopayoneexpresslogos WHERE oxid = "unitTestLogo"');
}
/**
diff --git a/tests/unit/fcPayOne/extend/application/controllers/fcPayOneOrderViewTest.php b/tests/unit/fcPayOne/extend/application/controllers/fcPayOneOrderViewTest.php
index 8378ae65..baaaa33a 100755
--- a/tests/unit/fcPayOne/extend/application/controllers/fcPayOneOrderViewTest.php
+++ b/tests/unit/fcPayOne/extend/application/controllers/fcPayOneOrderViewTest.php
@@ -100,30 +100,30 @@ public function test_execute_Parent()
$this->assertEquals($mExpect, $mResponse);
}
-
+
/**
* Testing fcpoHandlePayPalExpress for PositiveCall
- *
+ *
* @param void
* @return void
*/
- public function test_fcpoHandlePayPalExpress_PositiveCall()
+ public function test_fcpoHandlePayPalExpress_PositiveCall()
{
$oTestObject = $this->getMock('fcPayOneOrderView', array('_handlePayPalExpressCall'));
$oTestObject->expects($this->any())->method('_handlePayPalExpressCall')->will($this->returnValue(true));
-
+
$oMockUtilsView = $this->getMock('oxUtilsView', array('addErrorToDisplay'));
$oMockUtilsView->expects($this->any())->method('addErrorToDisplay')->will($this->returnValue(null));
-
+
$oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
$oHelper->expects($this->any())->method('fcpoGetUtilsView')->will($this->returnValue($oMockUtilsView));
-
+
$this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
-
+
$this->assertEquals(null, $oTestObject->fcpoHandlePayPalExpress());
+ $this->assertEquals(null, $oTestObject->fcpoHandlePayPalExpressV2());
}
-
/**
* Testing fcpoHandlePayPalExpress for Exception
*
@@ -148,6 +148,7 @@ public function test_fcpoHandlePayPalExpress_Exception()
$sExpect = 'basket';
$this->assertEquals($sExpect, $oTestObject->fcpoHandlePayPalExpress());
+ $this->assertEquals($sExpect, $oTestObject->fcpoHandlePayPalExpressV2());
}
/**
@@ -770,7 +771,7 @@ public function test__handlePayPalExpressCall_Coverage()
$this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
- $mResponse = $mExpect = $this->invokeMethod($oTestObject, '_handlePayPalExpressCall');
+ $mResponse = $mExpect = $this->invokeMethod($oTestObject, '_handlePayPalExpressCall', [fcpopaypalhelper::PPE_EXPRESS]);
$this->assertEquals($mExpect, $mResponse);
}
diff --git a/tests/unit/fcPayOne/extend/application/controllers/fcPayonePaymentViewTest.php b/tests/unit/fcPayOne/extend/application/controllers/fcPayonePaymentViewTest.php
index 8c97cc74..f138bf76 100755
--- a/tests/unit/fcPayOne/extend/application/controllers/fcPayonePaymentViewTest.php
+++ b/tests/unit/fcPayOne/extend/application/controllers/fcPayonePaymentViewTest.php
@@ -18,6 +18,8 @@
* @version OXID eShop CE
*/
+use OxidEsales\Eshop\Core\UtilsObject;
+
class Unit_fcPayOne_Extend_Application_Controllers_fcPayOnePaymentView extends OxidTestCaseCompatibilityWrapper
{
@@ -3619,4 +3621,22 @@ public function test__fcpoGetUserFromSession_Coverage() {
$this->assertEquals($oExpect, $oTestObject->_fcpoGetUserFromSession());
}
+
+ public function testFcpoPaymentActive()
+ {
+ fcpopaymenthelper::destroyInstance();
+
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isPaymentMethodActive')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
+
+ $oTestObject = oxNew('fcPayOnePaymentView');
+ $result = $oTestObject->fcpoPaymentActive('test');
+
+ $this->assertTrue($result);
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
+ }
}
diff --git a/tests/unit/fcPayOne/extend/application/models/fcPayOneOrderTest.php b/tests/unit/fcPayOne/extend/application/models/fcPayOneOrderTest.php
index 70a4b659..ea169976 100755
--- a/tests/unit/fcPayOne/extend/application/models/fcPayOneOrderTest.php
+++ b/tests/unit/fcPayOne/extend/application/models/fcPayOneOrderTest.php
@@ -1576,11 +1576,11 @@ public function test_debitNeedsBankData_Coverage()
/**
* Testing isDetailedProductInfoNeeded for coverage
- *
+ *
* @param void
* @return void
*/
- public function test_isDetailedProductInfoNeeded_Coverage()
+ public function test_isDetailedProductInfoNeeded_Coverage()
{
$oTestObject = oxNew('fcPayOneOrder');
$oTestObject->oxorder__oxpaymenttype = new oxField('somePaymentNotOnExceptionList');
@@ -1598,6 +1598,30 @@ public function test_isDetailedProductInfoNeeded_Coverage()
$this->assertEquals(true, $oTestObject->isDetailedProductInfoNeeded());
}
+ /**
+ * Testing isDetailedProductInfoNeeded for coverage
+ *
+ * @param void
+ * @return void
+ */
+ public function test_isDetailedProductInfoNeededFalse_Coverage()
+ {
+ $oTestObject = oxNew('fcPayOneOrder');
+ $oTestObject->oxorder__oxpaymenttype = new oxField('somePaymentNotOnExceptionList');
+
+ $oMockConfig = $this->getMock('oxConfig', array('getConfigParam'));
+ $oMockConfig
+ ->expects($this->any())
+ ->method('getConfigParam')
+ ->will($this->returnValue(false));
+
+ $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
+ $oHelper->expects($this->any())->method('fcpoGetConfig')->will($this->returnValue($oMockConfig));
+ $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
+
+ $this->assertEquals(false, $oTestObject->isDetailedProductInfoNeeded());
+ }
+
/**
* Testing getSequenceNumber for coverage
*
diff --git a/tests/unit/fcPayOne/extend/core/fcPayOneViewConfTest.php b/tests/unit/fcPayOne/extend/core/fcPayOneViewConfTest.php
index 4a5fed0b..d0196c08 100755
--- a/tests/unit/fcPayOne/extend/core/fcPayOneViewConfTest.php
+++ b/tests/unit/fcPayOne/extend/core/fcPayOneViewConfTest.php
@@ -17,8 +17,9 @@
* @copyright (C) Payone GmbH
* @version OXID eShop CE
*/
-
-
+
+use OxidEsales\Eshop\Core\UtilsObject;
+
class Unit_fcPayOne_Extend_Core_fcPayOneViewConf extends OxidTestCase
{
@@ -207,16 +208,18 @@ public function test_fcpoGetLangAbbrById_Coverage()
* @throws exception
*/
public function test_fcpoCanDisplayAmazonPayButton_Coverage() {
- $oTestObject = oxNew('fcPayOneViewConf');
- $oMockPayment = $this->getMock('oxPayment', array('load'));
- $oMockPayment->expects($this->any())->method('load')->will($this->returnValue(true));
- $oMockPayment->oxpayments__oxactive = new oxField('1');
+ fcpopaymenthelper::destroyInstance();
- $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
- $oHelper->expects($this->any())->method('getFactoryObject')->will($this->returnValue($oMockPayment));
- $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isPaymentMethodActive')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
+ $oTestObject = oxNew('fcPayOneViewConf');
$this->assertEquals(true, $oTestObject->fcpoCanDisplayAmazonPayButton());
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
}
/**
@@ -227,18 +230,21 @@ public function test_fcpoCanDisplayAmazonPayButton_Coverage() {
* @throws exception
*/
public function test_fcpoGetAmazonWidgetsUrl_Coverage() {
+ fcpopaymenthelper::destroyInstance();
+
$oTestObject = oxNew('fcPayOneViewConf');
- $oMockPayment = $this->getMock('oxPayment', array('load'));
- $oMockPayment->expects($this->any())->method('load')->will($this->returnValue(true));
- $oMockPayment->oxpayments__fcpolivemode = new oxField('1');
- $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock();
- $oHelper->expects($this->any())->method('getFactoryObject')->will($this->returnValue($oMockPayment));
- $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper);
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isLiveMode')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
$sExpect = 'https://static-eu.payments-amazon.com/OffAmazonPayments/eur/lpa/js/Widgets.js';
$this->assertEquals($sExpect, $oTestObject->fcpoGetAmazonWidgetsUrl());
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
}
/**
@@ -612,4 +618,111 @@ public function test__fcpoGetExpectedButtonAmount_Coverage() {
$this->assertEquals(4, $oTestObject->_fcpoGetExpectedButtonAmount());
}
+ public function testFcpoCanDisplayPayPalExpressV2Button()
+ {
+ fcpopaymenthelper::destroyInstance();
+
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isPaymentMethodActive')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
+
+ $oTestObject = oxNew('fcPayOneViewConf');
+ $result = $oTestObject->fcpoCanDisplayPayPalExpressV2Button();
+
+ $this->assertTrue($result);
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
+ }
+
+ public function testFcpoGetPayPalExpressV2GetButtonId()
+ {
+ fcpopaypalhelper::destroyInstance();
+
+ $expected = "fcpoPayPalExpressV2PayLaterPosi";
+
+ $oPayPalHelper = $this->getMockBuilder(fcpopaypalhelper::class)->disableOriginalConstructor()->getMock();
+ $oPayPalHelper->method('showBNPLButton')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaypalhelper::class, $oPayPalHelper);
+
+ $oTestObject = oxNew('fcPayOneViewConf');
+ $result = $oTestObject->fcpoGetPayPalExpressV2GetButtonId("Posi");
+
+ $this->assertEquals($expected, $result);
+
+ UtilsObject::resetClassInstances();
+ fcpopaypalhelper::destroyInstance();
+ }
+
+ public function testFcpoGetPayPalExpressV2Values()
+ {
+ fcpopaypalhelper::destroyInstance();
+
+ $expected = "stringValue";
+
+ $oPayPalHelper = $this->getMockBuilder(fcpopaypalhelper::class)->disableOriginalConstructor()->getMock();
+ $oPayPalHelper->method('getJavascriptUrl')->willReturn($expected);
+ $oPayPalHelper->method('getButtonColor')->willReturn($expected);
+ $oPayPalHelper->method('getButtonShape')->willReturn($expected);
+
+ UtilsObject::setClassInstance(fcpopaypalhelper::class, $oPayPalHelper);
+
+ $oTestObject = oxNew('fcPayOneViewConf');
+
+ $result = $oTestObject->fcpoGetPayPalExpressV2JavascriptUrl();
+ $this->assertEquals($expected, $result);
+
+ $result = $oTestObject->fcpoGetPayPalExpressButtonColor();
+ $this->assertEquals($expected, $result);
+
+ $result = $oTestObject->fcpoGetPayPalExpressButtonShape();
+ $this->assertEquals($expected, $result);
+
+ $result = $oTestObject->fcpoGetPayPalExpressV2JavascriptUrl();
+ $this->assertEquals($expected, $result);
+
+ UtilsObject::resetClassInstances();
+ fcpopaypalhelper::destroyInstance();
+ }
+
+ public function testFcpoGetPayPalExpressSuccessUrl()
+ {
+ fcporedirecthelper::destroyInstance();
+
+ $expected = "successUrl";
+
+ $oRedirectHelper = $this->getMockBuilder(fcporedirecthelper::class)->disableOriginalConstructor()->getMock();
+ $oRedirectHelper->method('getSuccessUrl')->willReturn($expected);
+
+ UtilsObject::setClassInstance(fcporedirecthelper::class, $oRedirectHelper);
+
+ $oTestObject = oxNew('fcPayOneViewConf');
+ $result = $oTestObject->fcpoGetPayPalExpressSuccessUrl();
+ $this->assertEquals($expected, $result);
+
+ UtilsObject::resetClassInstances();
+ fcporedirecthelper::destroyInstance();
+ }
+
+ public function testFcpoGetPayoneSecureEnvironment()
+ {
+ fcpopaymenthelper::destroyInstance();
+
+ $expected = 'p';
+
+ $oPaymentHelper = $this->getMockBuilder(fcpopaymenthelper::class)->disableOriginalConstructor()->getMock();
+ $oPaymentHelper->method('isLiveMode')->willReturn(true);
+
+ UtilsObject::setClassInstance(fcpopaymenthelper::class, $oPaymentHelper);
+
+ $oTestObject = oxNew('fcPayOneViewConf');
+ $result = $oTestObject->fcpoGetPayoneSecureEnvironment('test');
+
+ $this->assertEquals($expected, $result);
+
+ UtilsObject::resetClassInstances();
+ fcpopaymenthelper::destroyInstance();
+ }
}