Merge pull request #10946 from mattwire/CRM-21037_activity_sendsms_unittests
[civicrm-core.git] / tests / phpunit / api / v3 / CaseContactTest.php
index 6e8782699e9a24b8cdd0a59fb2cdeac2f48d5b57..cdfb5c0ed30062ca733eea762b135596a306c21b 100644 (file)
@@ -9,6 +9,7 @@ class api_v3_CaseContactTest extends CiviCaseTestCase {
   protected $_params;
   protected $_entity;
   protected $_cid;
+  protected $_cid2;
   /**
    * Activity ID of created case.
    *
@@ -28,12 +29,18 @@ class api_v3_CaseContactTest extends CiviCaseTestCase {
     parent::setUp();
 
     $this->_cid = $this->individualCreate();
+    $this->_cid2 = $this->individualCreate(array(), 1);
 
     $this->_case = $this->callAPISuccess('case', 'create', array(
       'case_type_id' => $this->caseTypeId,
       'subject' => __CLASS__,
       'contact_id' => $this->_cid,
     ));
+
+    $this->_params = array(
+      'case_id' => $this->_case['id'],
+      'contact_id' => $this->_cid2,
+    );
   }
 
   public function testCaseContactGet() {
@@ -43,4 +50,18 @@ class api_v3_CaseContactTest extends CiviCaseTestCase {
     $this->assertEquals($this->_case['id'], $result['id']);
   }
 
+  /**
+   * Test create function with valid parameters.
+   */
+  public function testCaseContactCreate() {
+    $params = $this->_params;
+    $result = $this->callAPIAndDocument('CaseContact', 'create', $params, __FUNCTION__, __FILE__);
+    $id = $result['id'];
+
+    // Check result
+    $result = $this->callAPISuccess('CaseContact', 'get', array('id' => $id));
+    $this->assertEquals($result['values'][$id]['case_id'], $params['case_id']);
+    $this->assertEquals($result['values'][$id]['contact_id'], $params['contact_id']);
+  }
+
 }