6 class CRM_Activity_Page_AJAXTest
extends CiviUnitTestCase
{
8 public function setUp() {
11 $this->loadAllFixtures();
13 CRM_Core_BAO_ConfigSetting
::enableComponent('CiviCase');
15 $this->loggedInUser
= $this->createLoggedInUser();
16 $this->target
= $this->individualCreate();
20 * Test the underlying function that implements file-on-case.
22 * The UI is a quickform but it's only realized as a popup ajax form that
23 * doesn't have its own postProcess. Instead the values are ultimately
24 * passed to the function this test is testing. So there's no form or ajax
25 * being tested here, just the final act of filing the activity.
27 public function testConvertToCaseActivity() {
28 $activity = $this->callAPISuccess('Activity', 'create', [
29 'source_contact_id' => $this->loggedInUser
,
30 'activity_type_id' => 'Meeting',
31 'subject' => 'test file on case',
32 'status_id' => 'Completed',
33 'target_id' => $this->target
,
36 $case = $this->callAPISuccess('Case', 'create', [
37 'contact_id' => $this->target
,
38 'case_type_id' => 'housing_support',
39 'subject' => 'Needs housing',
43 'activityID' => $activity['id'],
44 'caseID' => $case['id'],
46 'targetContactIds' => $this->target
,
48 $result = CRM_Activity_Page_AJAX
::_convertToCaseActivity($params);
50 $this->assertEmpty($result['error_msg']);
51 $newActivityId = $result['newId'];
53 $caseActivities = $this->callAPISuccess('Activity', 'get', [
54 'case_id' => $case['id'],
56 $this->assertEquals('test file on case', $caseActivities[$newActivityId]['subject']);
57 // This should be a different physical activity, not the same db record as the original.
58 $this->assertNotEquals($activity['id'], $caseActivities[$newActivityId]['id']);