<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
/**
* Test class for API functions
*
- * @package CiviCRM_APIv3
+ * @package CiviCRM_APIv3
*/
class api_v3_APITest extends CiviUnitTestCase {
public $DBResetRequired = FALSE;
+ protected $_apiversion = 3;
- protected $_apiversion =3;
-
- /**
- * Sets up the fixture, for example, opens a network connection.
- * This method is called before a test is executed.
- *
- * @access protected
- */
- protected function setUp() {
- parent::setUp();
- }
-
- /**
- * Tears down the fixture, for example, closes a network connection.
- * This method is called after a test is executed.
- *
- * @access protected
- */
- protected function tearDown() {}
-
- function testAPIReplaceVariables() {
+ public function testAPIReplaceVariables() {
$result = array();
$result['testfield'] = 6;
$result['api.tag.get'] = 999;
/*
* test that error doesn't occur for non-existant file
*/
- function testAPIWrapperIncludeNoFile() {
-
+ public function testAPIWrapperIncludeNoFile() {
$result = $this->callAPIFailure('RandomFile', 'get', array(), 'API (RandomFile,get) does not exist (join the API team and implement it!)');
}
- function testAPIWrapperCamelCaseFunction() {
+ public function testAPIWrapperCamelCaseFunction() {
$result = $this->callAPISuccess('OptionGroup', 'Get', array());
}
- function testAPIWrapperLcaseFunction() {
+ public function testAPIWrapperLcaseFunction() {
$result = $this->callAPISuccess('OptionGroup', 'get', array());
}
- function testAPIResolver() {
+ public function testAPIResolver() {
$oldpath = get_include_path();
set_include_path($oldpath . PATH_SEPARATOR . dirname(__FILE__) . '/dataset/resolver');
set_include_path($oldpath);
}
- function testFromCamel() {
+ public function testFromCamel() {
$cases = array(
'Contribution' => 'contribution',
'contribution' => 'contribution',
}
}
- function testToCamel() {
+ public function testToCamel() {
$cases = array(
'Contribution' => 'Contribution',
'contribution' => 'Contribution',
$this->assertEquals($expected, $actual, sprintf('input=%s expected=%s actual=%s', $input, $expected, $actual));
}
}
-/**
- * Test that calling via wrapper works
- */
- function testv3Wrapper() {
- try{
+
+ /**
+ * Test that calling via wrapper works
+ */
+ public function testv3Wrapper() {
+ 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
*/
- function testv3WrapperException(){
- try{
+ public function testv3WrapperException() {
+ try {
$result = 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();
}
}
-