+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
require_once 'CiviTest/CiviUnitTestCase.php';
/**
- * Test class for API functions
+ * Test class for API functions.
*
* @package CiviCRM_APIv3
*/
'big_rock' => '$value.api.tag.create.api.tag.create.values.0.display',
'villain' => '$value.api.tag.create.values.0.api_tag_get.display',
);
- _civicrm_api_replace_variables('Activity', 'Get', $params, $result);
+ _civicrm_api_replace_variables($params, $result);
$this->assertEquals(999, $params['number']);
$this->assertEquals(8, $params['tag_id']);
$this->assertEquals(6, $params['activity_type_id']);
$this->assertEquals('krypton', $params['big_rock']);
}
- /*
- * test that error doesn't occur for non-existant file
- */
+ /**
+ * Test that error doesn't occur for non-existent file.
+ */
public function testAPIWrapperIncludeNoFile() {
-
- $result = $this->callAPIFailure('RandomFile', 'get', array(), 'API (RandomFile,get) does not exist (join the API team and implement it!)');
+ $this->callAPIFailure(
+ 'RandomFile',
+ 'get',
+ array(),
+ 'API (RandomFile,get) does not exist (join the API team and implement it!)'
+ );
}
public function testAPIWrapperCamelCaseFunction() {
- $result = $this->callAPISuccess('OptionGroup', 'Get', array());
+ $this->callAPISuccess('OptionGroup', 'Get', array());
}
public function testAPIWrapperLcaseFunction() {
- $result = $this->callAPISuccess('OptionGroup', 'get', array());
+ $this->callAPISuccess('OptionGroup', 'get', array());
}
+ /**
+ * Test resolver.
+ */
public function testAPIResolver() {
- $oldpath = get_include_path();
- set_include_path($oldpath . PATH_SEPARATOR . dirname(__FILE__) . '/dataset/resolver');
+ $oldPath = get_include_path();
+ set_include_path($oldPath . PATH_SEPARATOR . dirname(__FILE__) . '/dataset/resolver');
$result = $this->callAPISuccess('contact', 'example_action1', array());
$this->assertEquals($result['values'][0], 'civicrm_api3_generic_example_action1 is ok');
$result = $this->callAPISuccess('test_entity', 'example_action3', array());
$this->assertEquals($result['values'][0], 'civicrm_api3_test_entity_example_action3 is ok');
- set_include_path($oldpath);
+ set_include_path($oldPath);
}
public function testFromCamel() {
'optionValue' => 'OptionValue',
'option_value' => 'OptionValue',
'UFJoin' => 'UFJoin',
- // dommage 'ufJoin' => 'UFJoin',
'uf_join' => 'UFJoin',
);
foreach ($cases as $input => $expected) {
$this->assertEquals($expected, $actual, sprintf('input=%s expected=%s actual=%s', $input, $expected, $actual));
}
}
+
/**
- * Test that calling via wrapper works
+ * Test that calling via wrapper works.
*/
public function testv3Wrapper() {
- try{
+ try {
$result = civicrm_api3('contact', 'get', array());
}
- catch (CRM_Exception $e){
+ catch (CRM_Exception $e) {
$this->fail("This should have been a success test");
}
$this->assertTrue(is_array($result));
}
/**
- * Test exception is thrown
+ * Test exception is thrown.
*/
- public function testv3WrapperException(){
- try{
- $result = civicrm_api3('contact', 'create', array('debug' => 1));
+ public function testV3WrapperException() {
+ try {
+ civicrm_api3('contact', 'create', array('debug' => 1));
}
- catch (CiviCRM_API3_Exception $e){
+ catch (CiviCRM_API3_Exception $e) {
$this->assertEquals('mandatory_missing', $e->getErrorCode());
$this->assertEquals('Mandatory key(s) missing from params array: contact_type', $e->getMessage());
$extra = $e->getExtraParams();
$this->fail('Exception was expected');
}
- public function testCreate_NoStringNullResult() {
+ /**
+ * Test result parsing for null.
+ */
+ public function testCreateNoStringNullResult() {
// create an example contact
// $contact = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage')->toArray();
$result = $this->callAPISuccess('ContributionPage', 'create', array(
'currency' => '',
));
- // check return format
+ // Check return format.
$this->assertEquals(1, $result['count']);
foreach ($result['values'] as $resultValue) {
$this->assertEquals('New title', $resultValue['title']);
- $this->assertEquals('', $resultValue['currency']); // BUG: $resultValue['location'] === 'null'
+ // BUG: $resultValue['location'] === 'null'.
+ $this->assertEquals('', $resultValue['currency']);
}
}