Coding standards cleanup sprint.
[civicrm-core.git] / tests / phpunit / api / v3 / CaseTest.php
index 19935366e2fc026ec60932038607d60473a6f1af..f284369e968904cc309c107308a5585f1dddcac7 100644 (file)
@@ -4,12 +4,12 @@
  *
  *  (PHP 5)
  *
- *   @author Walt Haas <walt@dharmatech.org> (801) 534-1262
- *   @copyright Copyright CiviCRM LLC (C) 2009
- *   @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html
+ * @author Walt Haas <walt@dharmatech.org> (801) 534-1262
+ * @copyright Copyright CiviCRM LLC (C) 2009
+ * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html
  *              GNU Affero General Public License version 3
- *   @version   $Id: ActivityTest.php 31254 2010-12-15 10:09:29Z eileen $
- *   @package   CiviCRM
+ * @version   $Id: ActivityTest.php 31254 2010-12-15 10:09:29Z eileen $
+ * @package   CiviCRM
  *
  *   This file is part of CiviCRM
  *
@@ -36,12 +36,12 @@ require_once 'CiviTest/CiviCaseTestCase.php';
 /**
  *  Test APIv3 civicrm_case_* functions
  *
- *  @package CiviCRM_APIv3
+ * @package CiviCRM_APIv3
  */
 class api_v3_CaseTest extends CiviCaseTestCase {
   protected $_params;
   protected $_entity;
-  protected $_apiversion =3;
+  protected $_apiversion = 3;
   protected $followup_activity_type_value;
 
   /**
@@ -71,16 +71,16 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   }
 
   /**
-   * check with empty array
+   * Check with empty array
    */
-  function testCaseCreateEmpty() {
+  public function testCaseCreateEmpty() {
     $result = $this->callAPIFailure('case', 'create', array());
   }
 
   /**
-   * check if required fields are not passed
+   * Check if required fields are not passed
    */
-  function testCaseCreateWithoutRequired() {
+  public function testCaseCreateWithoutRequired() {
     $params = array(
       'subject' => 'this case should fail',
       'case_type_id' => 1,
@@ -92,13 +92,13 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    * Test create function with valid parameters
    */
-  function testCaseCreate() {
+  public function testCaseCreate() {
     // Create Case
     $params = $this->_params;
     // Test using label instead of value
     unset($params['case_type_id']);
-    $params['case_type'] = 'Housing Support';
-    $result = $this->callAPISuccess('case', 'create', $params);
+    $params['case_type'] = $this->caseType;
+    $result = $this->callAPIAndDocument('case', 'create', $params, __FUNCTION__, __FILE__);
     $id = $result['id'];
 
     // Check result
@@ -111,12 +111,12 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    * Test update (create with id) function with valid parameters
    */
-  function testCaseUpdate() {
+  public function testCaseUpdate() {
     // Create Case
     $params = $this->_params;
     // Test using name instead of value
     unset($params['case_type_id']);
-    $params['case_type'] = 'Housing Support';
+    $params['case_type'] = $this->caseType;
     $result = $this->callAPISuccess('case', 'create', $params);
     $id = $result['id'];
     $result = $this->callAPISuccess('case', 'get', array('id' => $id));
@@ -135,7 +135,7 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    * Test delete function with valid parameters
    */
-  function testCaseDelete() {
+  public function testCaseDelete() {
     // Create Case
     $result = $this->callAPISuccess('case', 'create', $this->_params);
 
@@ -158,7 +158,7 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    * Test get function based on activity
    */
-  function testCaseGetByActivity() {
+  public function testCaseGetByActivity() {
     // Create Case
     $result = $this->callAPISuccess('case', 'create', $this->_params);
     $id = $result['id'];
@@ -169,7 +169,10 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $activity = $case['activities'][0];
 
     // Fetch case based on an activity id
-    $result = $this->callAPISuccess('case', 'get', array('activity_id' => $activity, 'return' => 'activities,contacts'));
+    $result = $this->callAPISuccess('case', 'get', array(
+        'activity_id' => $activity,
+        'return' => 'activities,contacts'
+      ));
     $this->assertEquals(FALSE, empty($result['values'][$id]), 'in line ' . __LINE__);
     $this->assertEquals($result['values'][$id], $case, 'in line ' . __LINE__);
   }
@@ -177,7 +180,7 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    * Test get function based on contact id
    */
-  function testCaseGetByContact() {
+  public function testCaseGetByContact() {
     // Create Case
     $result = $this->callAPISuccess('case', 'create', $this->_params);
     $id = $result['id'];
@@ -186,14 +189,17 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id));
 
     // Fetch case based on client contact id
-    $result = $this->callAPISuccess('case', 'get', array('client_id' => $this->_params['contact_id'], 'return' => array('activities', 'contacts')));
+    $result = $this->callAPISuccess('case', 'get', array(
+        'client_id' => $this->_params['contact_id'],
+        'return' => array('activities', 'contacts')
+      ));
     $this->assertAPIArrayComparison($result['values'][$id], $case);
   }
 
   /**
    * Test get function based on subject
    */
-  function testCaseGetBySubject() {
+  public function testCaseGetBySubject() {
     // Create Case
     $result = $this->callAPISuccess('case', 'create', $this->_params);
     $id = $result['id'];
@@ -202,27 +208,33 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $case = $this->callAPISuccess('case', 'getsingle', array('id' => $id));
 
     // Fetch case based on client contact id
-    $result = $this->callAPISuccess('case', 'get', array('subject' => $this->_params['subject'], 'return' => array('activities', 'contacts')));
+    $result = $this->callAPISuccess('case', 'get', array(
+        'subject' => $this->_params['subject'],
+        'return' => array('activities', 'contacts')
+      ));
     $this->assertAPIArrayComparison($result['values'][$id], $case);
   }
 
   /**
    * Test get function based on wrong subject
    */
-  function testCaseGetByWrongSubject() {
+  public function testCaseGetByWrongSubject() {
     // Create Case
     $result = $this->callAPISuccess('case', 'create', $this->_params);
     $id = $result['id'];
 
     // Append 'wrong' to subject so that it is no longer the same
-    $result = $this->callAPISuccess('case', 'get', array('subject' => $this->_params['subject'] . 'wrong', 'return' => array('activities', 'contacts')));
+    $result = $this->callAPISuccess('case', 'get', array(
+        'subject' => $this->_params['subject'] . 'wrong',
+        'return' => array('activities', 'contacts')
+      ));
     $this->assertEquals(0, $result['count'], 'in line ' . __LINE__);
   }
 
   /**
    * Test get function with no criteria
    */
-  function testCaseGetNoCriteria() {
+  public function testCaseGetNoCriteria() {
     // Create Case
     $result = $this->callAPISuccess('case', 'create', $this->_params);
     $id = $result['id'];
@@ -237,7 +249,7 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    *  Test activity api create for case activities
    */
-  function testCaseActivityCreate() {
+  public function testCaseActivityCreate() {
     // Create a case first
     $params = $this->_params;
     $result = $this->callAPISuccess('case', 'create', $params);
@@ -275,7 +287,7 @@ class api_v3_CaseTest extends CiviCaseTestCase {
   /**
    *  Test activity api update for case activities
    */
-  function testCaseActivityUpdate() {
+  public function testCaseActivityUpdate() {
     // Need to create the case and activity before we can update it
     $this->testCaseActivityCreate();
 
@@ -314,7 +326,7 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     //TODO: check some more things
   }
 
-  function testCaseActivityUpdateCustom() {
+  public function testCaseActivityUpdateCustom() {
     // Create a case first
     $result = $this->callAPISuccess('case', 'create', $this->_params);