3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2015 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
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. |
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. |
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 +--------------------------------------------------------------------+
29 require_once 'CiviTest/CiviUnitTestCase.php';
33 * System.check API has many special test cases, so they have their own class.
35 * We presume that in a test environment, checkDefaultMailbox and
36 * checkDomainNameEmail always fail with a warning, and checkLastCron fails with
39 * @package CiviCRM_APIv3
41 class api_v3_SystemCheckTest
extends CiviUnitTestCase
{
42 protected $_apiversion;
43 protected $_contactID;
44 protected $_locationType;
48 public function setUp() {
49 $this->_apiversion
= 3;
51 $this->useTransaction(TRUE);
55 * Ensure that without any StatusPreference set, checkDefaultMailbox shows
58 public function testSystemCheckBasic() {
59 $result = $this->callAPISuccess('System', 'check', array());
60 foreach ($result['values'] as $check) {
61 if ($check['name'] == 'checkDefaultMailbox') {
62 $testedCheck = $check;
66 $this->assertEquals($testedCheck['severity_id'], '3', ' in line ' . __LINE__
);
70 * Permanently hushed items should never show up.
72 public function testSystemCheckHushForever() {
73 $this->_params
= array(
74 'name' => 'checkDefaultMailbox',
75 'ignore_severity' => 7,
77 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
78 $result = $this->callAPISuccess('System', 'check', array());
79 foreach ($result['values'] as $check) {
80 if ($check['name'] == 'checkDefaultMailbox') {
81 $testedCheck = $check;
85 $testedCheck = array();
88 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
92 * Items hushed through tomorrow shouldn't show up.
94 public function testSystemCheckHushFuture() {
95 $tomorrow = new DateTime('tomorrow');
96 $this->_params
= array(
97 'name' => 'checkDefaultMailbox',
98 'ignore_severity' => 7,
99 'hush_until' => $tomorrow->format('Y-m-d'),
101 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
102 $result = $this->callAPISuccess('System', 'check', array());
103 foreach ($result['values'] as $check) {
104 if ($check['name'] == 'checkDefaultMailbox') {
105 $testedCheck = $check;
109 $testedCheck = array();
112 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);;
116 * Items hushed through today should show up.
118 public function testSystemCheckHushToday() {
119 $today = new DateTime('today');
120 $this->_params
= array(
121 'name' => 'checkDefaultMailbox',
122 'ignore_severity' => 7,
123 'hush_until' => $today->format('Y-m-d'),
125 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
126 $result = $this->callAPISuccess('System', 'check', array());
127 foreach ($result['values'] as $check) {
128 if ($check['name'] == 'checkDefaultMailbox') {
129 $testedCheck = $check;
133 $testedCheck = array();
136 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);
140 * Items hushed through yesterday should show up.
142 public function testSystemCheckHushYesterday() {
143 $yesterday = new DateTime('yesterday');
144 $this->_params
= array(
145 'name' => 'checkDefaultMailbox',
146 'ignore_severity' => 7,
147 'hush_until' => $yesterday->format('Y-m-d'),
149 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
150 $result = $this->callAPISuccess('System', 'check', array());
151 foreach ($result['values'] as $check) {
152 if ($check['name'] == 'checkDefaultMailbox') {
153 $testedCheck = $check;
157 $testedCheck = array();
160 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);
164 * Items hushed above current severity should be hidden.
166 public function testSystemCheckHushAboveSeverity() {
167 $this->_params
= array(
168 'name' => 'checkDefaultMailbox',
169 'ignore_severity' => 4,
171 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
172 $result = $this->callAPISuccess('System', 'check', array());
173 foreach ($result['values'] as $check) {
174 if ($check['name'] == 'checkDefaultMailbox') {
175 $testedCheck = $check;
179 $testedCheck = array();
182 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
186 * Items hushed at current severity should be hidden.
188 public function testSystemCheckHushAtSeverity() {
189 $this->_params
= array(
190 'name' => 'checkDefaultMailbox',
191 'ignore_severity' => 3,
193 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
194 $result = $this->callAPISuccess('System', 'check', array());
195 foreach ($result['values'] as $check) {
196 if ($check['name'] == 'checkDefaultMailbox') {
197 $testedCheck = $check;
201 $testedCheck = array();
204 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
208 * Items hushed below current severity should be shown.
210 public function testSystemCheckHushBelowSeverity() {
211 $this->_params
= array(
212 'name' => 'checkDefaultMailbox',
213 'ignore_severity' => 2,
215 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
216 $result = $this->callAPISuccess('System', 'check', array());
217 foreach ($result['values'] as $check) {
218 if ($check['name'] == 'checkDefaultMailbox') {
219 $testedCheck = $check;
223 $testedCheck = array();
226 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);