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 * System.check API has many special test cases, so they have their own class.
31 * We presume that in a test environment, checkDefaultMailbox and
32 * checkDomainNameEmail always fail with a warning, and checkLastCron fails with
35 * @package CiviCRM_APIv3
37 class api_v3_SystemCheckTest
extends CiviUnitTestCase
{
38 protected $_apiversion;
39 protected $_contactID;
40 protected $_locationType;
44 public function setUp() {
45 $this->_apiversion
= 3;
47 $this->useTransaction(TRUE);
51 * Ensure that without any StatusPreference set, checkDefaultMailbox shows
54 public function testSystemCheckBasic() {
55 $result = $this->callAPISuccess('System', 'check', array());
56 foreach ($result['values'] as $check) {
57 if ($check['name'] == 'checkDefaultMailbox') {
58 $testedCheck = $check;
62 $this->assertEquals($testedCheck['severity_id'], '3', ' in line ' . __LINE__
);
66 * Permanently hushed items should never show up.
68 public function testSystemCheckHushForever() {
69 $this->_params
= array(
70 'name' => 'checkDefaultMailbox',
71 'ignore_severity' => 7,
73 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
74 $result = $this->callAPISuccess('System', 'check', array());
75 foreach ($result['values'] as $check) {
76 if ($check['name'] == 'checkDefaultMailbox') {
77 $testedCheck = $check;
81 $testedCheck = array();
84 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
88 * Items hushed through tomorrow shouldn't show up.
90 public function testSystemCheckHushFuture() {
91 $tomorrow = new DateTime('tomorrow');
92 $this->_params
= array(
93 'name' => 'checkDefaultMailbox',
94 'ignore_severity' => 7,
95 'hush_until' => $tomorrow->format('Y-m-d'),
97 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
98 $result = $this->callAPISuccess('System', 'check', array());
99 foreach ($result['values'] as $check) {
100 if ($check['name'] == 'checkDefaultMailbox') {
101 $testedCheck = $check;
105 $testedCheck = array();
108 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);;
112 * Items hushed through today should show up.
114 public function testSystemCheckHushToday() {
115 $today = new DateTime('today');
116 $this->_params
= array(
117 'name' => 'checkDefaultMailbox',
118 'ignore_severity' => 7,
119 'hush_until' => $today->format('Y-m-d'),
121 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
122 $result = $this->callAPISuccess('System', 'check', array());
123 foreach ($result['values'] as $check) {
124 if ($check['name'] == 'checkDefaultMailbox') {
125 $testedCheck = $check;
129 $testedCheck = array();
132 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);
136 * Items hushed through yesterday should show up.
138 public function testSystemCheckHushYesterday() {
139 $yesterday = new DateTime('yesterday');
140 $this->_params
= array(
141 'name' => 'checkDefaultMailbox',
142 'ignore_severity' => 7,
143 'hush_until' => $yesterday->format('Y-m-d'),
145 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
146 $result = $this->callAPISuccess('System', 'check', array());
147 foreach ($result['values'] as $check) {
148 if ($check['name'] == 'checkDefaultMailbox') {
149 $testedCheck = $check;
153 $testedCheck = array();
156 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);
160 * Items hushed above current severity should be hidden.
162 public function testSystemCheckHushAboveSeverity() {
163 $this->_params
= array(
164 'name' => 'checkDefaultMailbox',
165 'ignore_severity' => 4,
167 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
168 $result = $this->callAPISuccess('System', 'check', array());
169 foreach ($result['values'] as $check) {
170 if ($check['name'] == 'checkDefaultMailbox') {
171 $testedCheck = $check;
175 $testedCheck = array();
178 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
182 * Items hushed at current severity should be hidden.
184 public function testSystemCheckHushAtSeverity() {
185 $this->_params
= array(
186 'name' => 'checkDefaultMailbox',
187 'ignore_severity' => 3,
189 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
190 $result = $this->callAPISuccess('System', 'check', array());
191 foreach ($result['values'] as $check) {
192 if ($check['name'] == 'checkDefaultMailbox') {
193 $testedCheck = $check;
197 $testedCheck = array();
200 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
204 * Items hushed below current severity should be shown.
206 public function testSystemCheckHushBelowSeverity() {
207 $this->_params
= array(
208 'name' => 'checkDefaultMailbox',
209 'ignore_severity' => 2,
211 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
212 $result = $this->callAPISuccess('System', 'check', array());
213 foreach ($result['values'] as $check) {
214 if ($check['name'] == 'checkDefaultMailbox') {
215 $testedCheck = $check;
219 $testedCheck = array();
222 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);