* API result
*/
function civicrm_api3_extension_get($params) {
- $keys = (array) $params['key'];
+ $keys = isset($params['key']) ? (array) $params['key'] : NULL;
$statuses = CRM_Extension_System::singleton()->getManager()->getStatuses();
$mapper = CRM_Extension_System::singleton()->getMapper();
$result = array();
$result[] = $info;
}
}
- $returnFields = !empty($params['return']) ? (array) $params['return'] : array();
+ $options = _civicrm_api3_get_options_from_params($params);
+ $returnFields = !empty($options['return']) ? $options['return'] : array();
return _civicrm_api3_basic_array_get('Extension', $params, $result, 'id', $returnFields);
}
}
/**
- * Test retunging a single extension
+ * Test getting a single extension
+ * CRM-20532
*/
- public function testSingleExtesnionGet() {
+ public function testExtesnionGetSingleExtension() {
$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']);
}
/**
- * Test single get with specific fields in return
+ * Test single Extension get with specific fields in return
+ * CRM-20532
*/
public function testSingleExtesnionGetWithReturnFields() {
$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->assertNull($result['values'][$result['id']]['type']);
+ $this->assertFalse(isset($result['values'][$result['id']]['type']));
$this->assertEquals('test_extension_manager_moduletest', $result['values'][$result['id']]['name']);
$this->assertEquals('uninstalled', $result['values'][$result['id']]['status']);
}
/**
* Test Extension Get resturns detailed information
+ * CRM-20532
*/
- public function testeExtesnionGet() {
+ public function testExtesnionGet() {
$result = $this->callAPISuccess('extension', 'get', array());
- $angularResult = $this->callAPISuccess('extension', 'get', array('key' => 'org.civicrm.angularprofiles'));
- $this->assertNotNull($result['values'][$angularResult['id']]['comments']);
+ $testExtensionResult = $this->callAPISuccess('extension', 'get', array('key' => 'test.extension.manager.paymenttest'));
+ $this->assertNotNull($result['values'][$testExtensionResult['id']]['typeInfo']);
$this->assertEquals(11, $result['count']);
}