Skip to content

Commit

Permalink
CRM-20993 - API - Extention get - Fix filtering by ID
Browse files Browse the repository at this point in the history
----------------------------------------
* CRM-20993: API - Extension get - Cannot filter by ID anymore
  https://issues.civicrm.org/jira/browse/CRM-20993
  • Loading branch information
tschuettler committed Aug 3, 2017
1 parent d7b136b commit 34239e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion api/v3/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ function civicrm_api3_extension_get($params) {
}
}
$options = _civicrm_api3_get_options_from_params($params);
$returnFields = !empty($options['return']) ? $options['return'] : array();
$returnFields = !empty($options['return']) ? $options['return'] : array('id');
return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', $returnFields);
}

Expand Down
16 changes: 12 additions & 4 deletions tests/phpunit/api/v3/ExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function testGetremote() {
* Test getting a single extension
* CRM-20532
*/
public function testExtesnionGetSingleExtension() {
public function testExtensionGetSingleExtension() {
$result = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.moduletest'));
$this->assertEquals('test.extension.manager.moduletest', $result['values'][$result['id']]['key']);
$this->assertEquals('module', $result['values'][$result['id']]['type']);
Expand All @@ -72,7 +72,7 @@ public function testExtesnionGetSingleExtension() {
* Test single Extension get with specific fields in return
* CRM-20532
*/
public function testSingleExtesnionGetWithReturnFields() {
public function testSingleExtensionGetWithReturnFields() {
$result = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.moduletest', 'return' => array('name', 'status', 'key')));
$this->assertEquals('test.extension.manager.moduletest', $result['values'][$result['id']]['key']);
$this->assertFalse(isset($result['values'][$result['id']]['type']));
Expand All @@ -81,11 +81,11 @@ public function testSingleExtesnionGetWithReturnFields() {
}

/**
* Test Extension Get resturns detailed information
* Test Extension Get returns detailed information
* Note that this is likely to fail locally but will work on Jenkins due to the result count check
* CRM-20532
*/
public function testExtesnionGet() {
public function testExtensionGet() {
$result = $this->callAPISuccess('extension', 'get', array());
$testExtensionResult = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.paymenttest'));
$this->assertNotNull($result['values'][$testExtensionResult['id']]['typeInfo']);
Expand All @@ -105,4 +105,12 @@ public function testGetMultipleExtensionsApiExplorer() {
$this->assertEquals(2, $result['count']);
}

/**
* Test that extension get can be filtered by id.
*/
public function testGetExtensionByID() {
$result = $this->callAPISuccess('extension', 'get', array('id' => 2));
$this->assertEquals(1, $result['count']);
}

}

0 comments on commit 34239e8

Please sign in to comment.