tests/phpunit - Declare `@group headless`
[civicrm-core.git] / tests / phpunit / CRM / Case / BAO / CaseTest.php
CommitLineData
8ffdec17 1<?php
8ffdec17 2
aba1cd8b
EM
3/**
4 * Class CRM_Case_BAO_CaseTest
acb109b7 5 * @group headless
aba1cd8b 6 */
8ffdec17 7class CRM_Case_BAO_CaseTest extends CiviUnitTestCase {
8ffdec17 8
00be9182 9 public function setUp() {
8ffdec17
ARW
10 parent::setUp();
11
32f1c917
TO
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
8ffdec17
ARW
29 $this->loadAllFixtures();
30
31 CRM_Core_BAO_ConfigSetting::enableComponent('CiviCase');
32 }
33
32f1c917
TO
34 protected function tearDown() {
35 parent::tearDown();
36 $this->quickCleanup($this->tablesToTruncate, TRUE);
37 }
38
00be9182 39 public function testAddCaseToContact() {
8ffdec17
ARW
40 $params = array(
41 'case_id' => 1,
42 'contact_id' => 17,
43 );
ff9340a4 44 CRM_Case_BAO_CaseContact::create($params);
8ffdec17
ARW
45
46 $recent = CRM_Utils_Recent::get();
47 $this->assertEquals('Test Contact - Housing Support', $recent[0]['title']);
48 }
49
00be9182 50 public function testGetCaseType() {
8ffdec17
ARW
51 $caseTypeLabel = CRM_Case_BAO_Case::getCaseType(1);
52 $this->assertEquals('Housing Support', $caseTypeLabel);
53 }
54
00be9182 55 public function testRetrieveCaseIdsByContactId() {
8ffdec17
ARW
56 $caseIds = CRM_Case_BAO_Case::retrieveCaseIdsByContactId(3, FALSE, 'housing_support');
57 $this->assertEquals(array(1), $caseIds);
58 }
59
bed98343 60 /**
61 * FIXME: need to create an activity to run this test
8ffdec17
ARW
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 */
00be9182 68 public function testGetCasesSummary() {
8ffdec17
ARW
69 $cases = CRM_Case_BAO_Case::getCasesSummary(TRUE, 3);
70 $this->assertEquals(1, $cases['rows']['Housing Support']['Ongoing']['count']);
71 }
72
8ffdec17
ARW
73 /* FIXME: requires activities
74 * function testGetRelatedCases() {
75 * }
76 */
96025800 77
8ffdec17 78}