Merge pull request #10393 from JMAConsulting/exportBatch
[civicrm-core.git] / tests / phpunit / api / v3 / CaseTest.php
index 0e34acd9a70ca176a91bd0d5d87003c8fb796796..c5518050cb7a4411fc688db659dbe77b0bead073 100644 (file)
@@ -158,6 +158,35 @@ class api_v3_CaseTest extends CiviCaseTestCase {
     $this->assertEquals($result['values'][$id]['subject'], $params['subject']);
   }
 
+  /**
+   * Test create function with resolved status.
+   */
+  public function testCaseCreateWithResolvedStatus() {
+    $params = $this->_params;
+    // Test using label instead of value.
+    unset($params['case_type_id']);
+    $params['case_type'] = $this->caseType;
+    $params['status_id'] = 'Closed';
+    $result = $this->callAPISuccess('case', 'create', $params);
+    $id = $result['id'];
+
+    // Check result
+    $result = $this->callAPISuccess('case', 'get', array('id' => $id));
+    $this->assertEquals($result['values'][$id]['id'], $id);
+    $this->assertEquals($result['values'][$id]['case_type_id'], $this->caseTypeId);
+    $this->assertEquals($result['values'][$id]['subject'], $params['subject']);
+    $this->assertEquals($result['values'][$id]['end_date'], date('Y-m-d'));
+
+    //Check all relationship end dates are set to case end date.
+    $relationships = $this->callAPISuccess('Relationship', 'get', array(
+      'sequential' => 1,
+      'case_id' => $id,
+    ));
+    foreach ($relationships['values'] as $key => $values) {
+      $this->assertEquals($values['end_date'], date('Y-m-d'));
+    }
+  }
+
   /**
    * Test case create with valid parameters and custom data.
    */