Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
39de6fd5 | 4 | | CiviCRM version 4.6 | |
6a488035 | 5 | +--------------------------------------------------------------------+ |
06a1bc01 | 6 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | | |
9 | | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | | |
11 | | under the terms of the GNU Affero General Public License | | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | | |
13 | | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | | |
17 | | See the GNU Affero General Public License for more details. | | |
18 | | | | |
19 | | You should have received a copy of the GNU Affero General Public | | |
20 | | License and the CiviCRM Licensing Exception along | | |
21 | | with this program; if not, contact CiviCRM LLC | | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | | |
25 | +--------------------------------------------------------------------+ | |
d25dd0ee | 26 | */ |
6a488035 TO |
27 | |
28 | ||
29 | require_once 'CiviTest/CiviUnitTestCase.php'; | |
30 | ||
31 | /** | |
32 | * Test class for CRM_Activity_BAO_ActivityAssignment BAO | |
33 | * | |
6c6e6187 | 34 | * @package CiviCRM |
6a488035 TO |
35 | */ |
36 | class CRM_Activity_BAO_ActivityAssignmentTest extends CiviUnitTestCase { | |
37 | ||
38 | /** | |
39 | * Sets up the fixture, for example, opens a network connection. | |
40 | * This method is called before a test is executed. | |
6a488035 TO |
41 | */ |
42 | protected function setUp() { | |
43 | parent::setUp(); | |
44 | } | |
45 | ||
46 | /** | |
47 | * Tears down the fixture, for example, closes a network connection. | |
48 | * This method is called after a test is executed. | |
6a488035 | 49 | */ |
6c6e6187 TO |
50 | protected function tearDown() { |
51 | } | |
6a488035 TO |
52 | |
53 | /** | |
54 | * Pass zero as an id and make sure no Assignees are retrieved | |
55 | */ | |
00be9182 | 56 | public function testRetrieveAssigneeIdsByActivityIdNoId() { |
6a488035 TO |
57 | $activity = $this->activityCreate(); |
58 | $activityId = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId(0); | |
59 | ||
60 | $this->assertEquals(count($activityId), 0, '0 assignees retrieved'); | |
61 | } | |
62 | ||
63 | /** | |
64 | * Pass null as an id and make sure no Assignees are retrieved | |
65 | */ | |
00be9182 | 66 | public function testRetrieveAssigneeIdsByActivityIdNullId() { |
6a488035 | 67 | $activity = $this->activityCreate(); |
6c6e6187 | 68 | $activityId = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId(NULL); |
6a488035 TO |
69 | |
70 | $this->assertEquals(count($activityId), 0, '0 assignees retrieved using null'); | |
71 | } | |
72 | ||
73 | /** | |
74 | * Pass a string as an id and make sure no Assignees are retrieved | |
75 | */ | |
00be9182 | 76 | public function testRetrieveAssigneeIdsByActivityIdString() { |
6a488035 TO |
77 | $activity = $this->activityCreate(); |
78 | $activityId = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId('test'); | |
79 | ||
80 | $this->assertEquals(count($activityId), 0, '0 assignees retrieved using string'); | |
81 | } | |
82 | ||
83 | /** | |
84 | * Pass a known activity id as an id and make sure 1 Assignees is retrieved | |
85 | */ | |
00be9182 | 86 | public function testRetrieveAssigneeIdsByActivityIdOneId() { |
6a488035 TO |
87 | $activity = $this->activityCreate(); |
88 | $activityId = CRM_Activity_BAO_ActivityAssignment::retrieveAssigneeIdsByActivityId($activity['id']); | |
89 | ||
90 | $this->assertEquals(count($activityId), 1, 'One record retrieved'); | |
91 | } | |
92 | ||
93 | /** | |
94 | * Pass zero as an id and make sure no Assignees are retrieved | |
95 | */ | |
00be9182 | 96 | public function testGetAssigneeNamesNoId() { |
6a488035 TO |
97 | $activity = $this->activityCreate(); |
98 | $assignees = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(0); | |
99 | ||
100 | $this->assertEquals(count($assignees), 0, '0 assignee names retrieved'); | |
101 | } | |
102 | ||
103 | /** | |
104 | * Pass Null as an id and make sure no Assignees are retrieved | |
105 | */ | |
00be9182 | 106 | public function testGetAssigneeNamesNullId() { |
6a488035 | 107 | $activity = $this->activityCreate(); |
6c6e6187 | 108 | $assignees = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(NULL); |
6a488035 TO |
109 | |
110 | $this->assertEquals(count($assignees), 0, '0 assignee names retrieved'); | |
111 | } | |
112 | ||
113 | /** | |
114 | * Pass a known activity id as an id and make sure 1 Assignees is retrieved | |
115 | */ | |
00be9182 | 116 | public function testGetAssigneeNamesOneId() { |
6a488035 | 117 | $activity = $this->activityCreate(); |
e6638d31 | 118 | $assignees = CRM_Activity_BAO_ActivityAssignment::getAssigneeNames(array($activity['id'])); |
6a488035 TO |
119 | $this->assertEquals(count($assignees), 1, '1 assignee names retrieved'); |
120 | } | |
96025800 | 121 | |
6a488035 | 122 | } |