commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-old / civicrm / tests / phpunit / CRM / Case / BAO / CaseTest.php
1 <?php
2 require_once 'CiviTest/CiviUnitTestCase.php';
3
4 /**
5 * Class CRM_Case_BAO_CaseTest
6 */
7 class CRM_Case_BAO_CaseTest extends CiviUnitTestCase {
8
9 public function setUp() {
10 parent::setUp();
11
12 $this->tablesToTruncate = array(
13 'civicrm_activity',
14 'civicrm_contact',
15 'civicrm_custom_group',
16 'civicrm_custom_field',
17 'civicrm_case',
18 'civicrm_case_contact',
19 'civicrm_case_activity',
20 'civicrm_case_type',
21 'civicrm_activity_contact',
22 'civicrm_managed',
23 'civicrm_relationship',
24 'civicrm_relationship_type',
25 );
26
27 $this->quickCleanup($this->tablesToTruncate);
28
29 $this->loadAllFixtures();
30
31 CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
32 }
33
34 protected function tearDown() {
35 parent::tearDown();
36 $this->quickCleanup($this->tablesToTruncate, TRUE);
37 }
38
39 public function testAddCaseToContact() {
40 $params = array(
41 'case_id' => 1,
42 'contact_id' => 17,
43 );
44 CRM_Case_BAO_Case::addCaseToContact($params);
45
46 $recent = CRM_Utils_Recent::get();
47 $this->assertEquals('Test Contact - Housing Support', $recent[0]['title']);
48 }
49
50 public function testGetCaseType() {
51 $caseTypeLabel = CRM_Case_BAO_Case::getCaseType(1);
52 $this->assertEquals('Housing Support', $caseTypeLabel);
53 }
54
55 public function testRetrieveCaseIdsByContactId() {
56 $caseIds = CRM_Case_BAO_Case::retrieveCaseIdsByContactId(3, FALSE, 'housing_support');
57 $this->assertEquals(array(1), $caseIds);
58 }
59
60 /**
61 * FIXME: need to create an activity to run this test
62 * function testGetCases() {
63 * $cases = CRM_Case_BAO_Case::getCases(TRUE, 3);
64 * $this->assertEquals('Housing Support', $cases[1]['case_type']);
65 * $this->assertEquals(1, $cases[1]['case_type_id']);
66 * }
67 */
68 public function testGetCasesSummary() {
69 $cases = CRM_Case_BAO_Case::getCasesSummary(TRUE, 3);
70 $this->assertEquals(1, $cases['rows']['Housing Support']['Ongoing']['count']);
71 }
72
73 public function testGetUnclosedCases() {
74 $params = array(
75 'case_type' => 'ousing Suppor',
76 );
77 $cases = CRM_Case_BAO_Case::getUnclosedCases($params);
78 $this->assertEquals('Housing Support', $cases[1]['case_type']);
79 }
80
81 public function testGetContactCases() {
82 $cases = CRM_Case_BAO_Case::getContactCases(3);
83 $this->assertEquals('Housing Support', $cases[1]['case_type']);
84 }
85
86 /* FIXME: requires activities
87 * function testGetRelatedCases() {
88 * }
89 */
90
91 }