Skip to content

Commit

Permalink
Switch to API calls and hard code execption list
Browse files Browse the repository at this point in the history
  • Loading branch information
seamuslee001 committed Apr 11, 2017
1 parent 59248c4 commit 449fbe1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CRM/SMS/Form/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ public function postProcess() {
if ($this->_id) {
$recData['id'] = $this->_id;
}
CRM_SMS_BAO_Provider::create($recData);
civicrm_api3('SmsProvider', 'create', $recData);
}
}

Expand Down
8 changes: 8 additions & 0 deletions Civi/API/Subscriber/ChainSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,14 @@ protected function callNestedApi($apiKernel, &$params, &$result, $action, $entit
);
$subEntity = _civicrm_api_get_entity_name_from_camel($subAPI[1]);

// Hard coded list of entitys that have fields starting api_ and shouldn't be automatically
// deemed to be chained API calls
if ((($subEntity == 'type' || $subEntity == 'url') && $entity == 'SmsProvider') ||
($entity == 'Job' && ($subEntity == 'prefix' || $subEntity == 'entity' || $subEntity == 'action')) ||
($entity == 'Contact' && $subEntity == 'key')) {
continue;
}

foreach ($result['values'] as $idIndex => $parentAPIValues) {

if ($subEntity != 'contact') {
Expand Down
5 changes: 2 additions & 3 deletions tests/phpunit/CRM/SMS/BAO/ProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,11 @@ public function testCreateAndUpdateProvider() {
'api_type' => 1,
);
$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', 'id' => $provider['id']);
CRM_SMS_BAO_Provider::create($values2);
$this->callAPISuccess('SmsProvider', '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 All @@ -90,7 +89,7 @@ public function testCreateWithoutDomain() {
'is_active' => 1,
'api_type' => 1,
);
CRM_SMS_BAO_Provider::create($values);
$this->callAPISuccess('SmsProvider', '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->assertEquals(CRM_Core_Config::domainID(), $domain_id);
Expand Down

0 comments on commit 449fbe1

Please sign in to comment.