Skip to content

Commit

Permalink
Minor code cleanup
Browse files Browse the repository at this point in the history
Minor fix
  • Loading branch information
seamuslee001 committed Apr 11, 2017
1 parent a903347 commit 9282fa3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
5 changes: 2 additions & 3 deletions CRM/SMS/BAO/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ public static function getProviders($selectArr = NULL, $filter = NULL, $getActiv
/**
* Create or Update an SMS provider
* @param array $params
* @param array $ids to update
* @return array saved values
*/
public static function create($params, $ids = array()) {
$id = CRM_Utils_Array::value('id', $ids, CRM_Utils_Array::value('id', $params));
public static function create(&$params) {
$id = CRM_Utils_Array::value('id', $params);

if ($id) {
CRM_Utils_Hook::pre('edit', 'SmsProvider', $id, $params);
Expand Down
9 changes: 3 additions & 6 deletions CRM/SMS/Form/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,10 @@ public function postProcess() {
$recData['is_default'] = CRM_Utils_Array::value('is_default', $recData, 0);

if ($this->_action && (CRM_Core_Action::UPDATE || CRM_Core_Action::ADD)) {
if (!empty($this->_id)) {
$ids = array('id' => $this->_id);
if ($this->_id) {
$recData['id'] = $this->_id;
}
else {
$ids = array();
}
CRM_SMS_BAO_Provider::create($recData, $ids);
CRM_SMS_BAO_Provider::create($recData);
}
}

Expand Down
7 changes: 4 additions & 3 deletions tests/phpunit/CRM/SMS/BAO/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,13 @@ public function testCreateAndUpdateProvider() {
'is_active' => 1,
'api_type' => 1,
);
CRM_SMS_BAO_Provider::create($values, array());
$this->callAPISuccess('SmsProvider', 'create', $values);
// CRM_SMS_BAO_Provider::create($values);
$provider = $this->callAPISuccess('SmsProvider', 'getsingle', array('title' => 'test SMS provider'));
$domain_id = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $provider['id'], 'domain_id');
$this->assertNull($domain_id);
$values2 = array('title' => 'Test SMS Provider2');
CRM_SMS_BAO_Provider::create($values2, array('id' => $provider['id']));
$values2 = array('title' => 'Test SMS Provider2', 'id' => $provider['id']);
CRM_SMS_BAO_Provider::create($values2);
$provider = $this->callAPISuccess('SmsProvider', 'getsingle', array('id' => $provider['id']));
$this->assertEquals('Test SMS Provider2', $provider['title']);
$domain_id = CRM_Core_DAO::getFieldValue('CRM_SMS_DAO_Provider', $provider['id'], 'domain_id');
Expand Down

0 comments on commit 9282fa3

Please sign in to comment.