From 09d5118e9b1a9e00e6c5fffae32ce94c652bfdb7 Mon Sep 17 00:00:00 2001 From: Andre Herrmann Date: Fri, 19 May 2017 13:48:49 +0200 Subject: [PATCH 1/2] OXID-123: Simplified handling of fetching ratepayprofiles --- application/models/fcporatepay.php | 11 ++++------- lib/fcpohelper.php | 14 +++++++------- .../application/models/fcporatepayTest.php | 5 ++++- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/application/models/fcporatepay.php b/application/models/fcporatepay.php index 66fbff46..339e196c 100644 --- a/application/models/fcporatepay.php +++ b/application/models/fcporatepay.php @@ -77,6 +77,7 @@ public function fcpoInsertProfile($sOxid, $aRatePayData) */ public function fcpoGetRatePayProfiles($sPaymentId = null) { + $oDb = $this->_oFcpoHelper->fcpoGetDb(true); $aReturn = array(); $sFilterPaymentId = ""; @@ -85,15 +86,11 @@ public function fcpoGetRatePayProfiles($sPaymentId = null) } $sQuery = "SELECT * FROM fcporatepay {$sFilterPaymentId}"; - $aRatePayProfiles = $this->_oFcpoDb->getAll($sQuery); - $aFields = $this->fcpoGetFields(); + $aRatePayProfiles = $oDb->getAll($sQuery); foreach ($aRatePayProfiles as $aRatePayProfile) { - $sOxid = $aRatePayProfile[0]; - foreach ($aRatePayProfile as $iIndex=>$sValue) { - $aRow[$aFields[$iIndex][0]] = $sValue; - } - $aReturn[$sOxid] = $aRow; + $sOxid = $aRatePayProfile['OXID']; + $aReturn[$sOxid] = $aRatePayProfile; } return $aReturn; } diff --git a/lib/fcpohelper.php b/lib/fcpohelper.php index 3593d5e9..6daf9777 100644 --- a/lib/fcpohelper.php +++ b/lib/fcpohelper.php @@ -203,9 +203,9 @@ public function fcpoGetSession() public function fcpoGetDb($blAssoc = false) { if ($blAssoc) { - return ( $this->_fcUseDeprecatedInstantiation ) ? oxDb::getDb(true) : oxDb::getDb(oxDB::FETCH_MODE_ASSOC); + return ($this->_fcUseDeprecatedInstantiation()) ? oxDb::getDb(true) : oxDb::getDb(oxDB::FETCH_MODE_ASSOC); } else { - return ( $this->_fcUseDeprecatedInstantiation ) ? oxDb::getDb() : oxDb::getDb(oxDb::FETCH_MODE_NUM); + return ($this->_fcUseDeprecatedInstantiation()) ? oxDb::getDb() : oxDb::getDb(oxDb::FETCH_MODE_NUM); } } @@ -507,7 +507,7 @@ public function fcpoGetPayoneStatusList() 'vsettlement', 'transfer', 'invoice', - ); + ); } /** @@ -540,10 +540,10 @@ public function fcpoGetIntegratorId() protected function _fcUseDeprecatedInstantiation() { $oConfig = $this->getConfig(); - if (( version_compare($oConfig->getVersion(), "4.8.0") < 1 && $oConfig->getEdition() == "CE" ) - || ( version_compare($oConfig->getVersion(), "4.8.0") < 1 && $oConfig->getEdition() == "PE" ) - || ( version_compare($oConfig->getVersion(), "5.1.0") < 1 && $oConfig->getEdition() == "EE" ) - ) { + if ((version_compare($oConfig->getVersion(), "4.8.0") < 1 && $oConfig->getEdition() == "CE") + || (version_compare($oConfig->getVersion(), "4.8.0") < 1 && $oConfig->getEdition() == "PE") + || (version_compare($oConfig->getVersion(), "5.1.0") < 1 && $oConfig->getEdition() == "EE") + ) { return true; } else { return false; diff --git a/tests/unit/fcPayOne/application/models/fcporatepayTest.php b/tests/unit/fcPayOne/application/models/fcporatepayTest.php index 67e6608e..5aac9743 100644 --- a/tests/unit/fcPayOne/application/models/fcporatepayTest.php +++ b/tests/unit/fcPayOne/application/models/fcporatepayTest.php @@ -127,7 +127,10 @@ public function test_fcpoGetRatePayProfiles_Coverage() $oMockDatabase = $this->getMock('oxDb', array('getAll', 'quote')); $oMockDatabase->expects($this->atLeastOnce())->method('getAll')->will($this->returnValue($aMockResult)); $oMockDatabase->expects($this->any())->method('quote')->will($this->returnValue(null)); - $this->invokeSetAttribute($oTestObject, '_oFcpoDb', $oMockDatabase); + + $oHelper = $this->getMockBuilder('fcpohelper')->disableOriginalConstructor()->getMock(); + $oHelper->expects($this->any())->method('fcpoGetDb')->will($this->returnValue($oMockDatabase)); + $this->invokeSetAttribute($oTestObject, '_oFcpoHelper', $oHelper); $aExpect = array( 'someValue' => array(''=>'someValue'), From 72d38e26cf5639d8c4a5f784da534c31014abbc6 Mon Sep 17 00:00:00 2001 From: Florian Bender Date: Fri, 19 May 2017 14:19:42 +0200 Subject: [PATCH 2/2] Version bump --- lib/fcpohelper.php | 4 ++-- lib/fcporequest.php | 2 +- metadata.php | 2 +- version.txt | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/fcpohelper.php b/lib/fcpohelper.php index 6daf9777..9caee29a 100644 --- a/lib/fcpohelper.php +++ b/lib/fcpohelper.php @@ -355,7 +355,7 @@ public function fcpoGetUtilsDate() */ public static function fcpoGetStaticModuleVersion() { - return '1.0.0'; + return '1.0.1'; } /** @@ -366,7 +366,7 @@ public static function fcpoGetStaticModuleVersion() */ public function fcpoGetModuleVersion() { - return '1.0.0'; + return '1.0.1'; } /** diff --git a/lib/fcporequest.php b/lib/fcporequest.php index b910af07..8b00f8fb 100644 --- a/lib/fcporequest.php +++ b/lib/fcporequest.php @@ -149,7 +149,7 @@ public function __construct() $this->addParameter('integrator_version', $this->_oFcpoHelper->fcpoGetIntegratorVersion()); $this->addParameter('solution_name', 'fatchip'); // $this->addParameter('solution_version', $this->_oFcpoHelper->fcpoGetModuleVersion()); - $this->addParameter('solution_version', '2.0.10'); + $this->addParameter('solution_version', '1.0.1'); } /** diff --git a/metadata.php b/metadata.php index 7b008ef1..a9320575 100644 --- a/metadata.php +++ b/metadata.php @@ -32,7 +32,7 @@ https://www.payone.de ', 'thumbnail' => 'picture.gif', - 'version' => '1.0.0', + 'version' => '1.0.1', 'author' => 'FATCHIP GmbH', 'email' => 'kontakt@fatchip.de', 'url' => 'http://wiki.fatchip.de/fc/mod_oxid_payone/start', diff --git a/version.txt b/version.txt index 3eefcb9d..7dea76ed 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.0 +1.0.1