Skip to content

Commit

Permalink
OXID-123: Simplified handling of fetching ratepayprofiles
Browse files Browse the repository at this point in the history
  • Loading branch information
andrefatchip committed May 19, 2017
1 parent a560fbd commit 09d5118
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
11 changes: 4 additions & 7 deletions application/models/fcporatepay.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function fcpoInsertProfile($sOxid, $aRatePayData)
*/
public function fcpoGetRatePayProfiles($sPaymentId = null)
{
$oDb = $this->_oFcpoHelper->fcpoGetDb(true);
$aReturn = array();

$sFilterPaymentId = "";
Expand All @@ -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;
}
Expand Down
14 changes: 7 additions & 7 deletions lib/fcpohelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -507,7 +507,7 @@ public function fcpoGetPayoneStatusList()
'vsettlement',
'transfer',
'invoice',
);
);
}

/**
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 4 additions & 1 deletion tests/unit/fcPayOne/application/models/fcporatepayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down

0 comments on commit 09d5118

Please sign in to comment.