3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2018 |
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
38 class api_v3_SystemCheckTest
extends CiviUnitTestCase
{
39 protected $_apiversion;
40 protected $_contactID;
41 protected $_locationType;
45 public function setUp() {
46 $this->_apiversion
= 3;
48 $this->useTransaction(TRUE);
52 * Ensure that without any StatusPreference set, checkDefaultMailbox shows
55 public function testSystemCheckBasic() {
56 $result = $this->callAPISuccess('System', 'check', array());
57 foreach ($result['values'] as $check) {
58 if ($check['name'] == 'checkDefaultMailbox') {
59 $testedCheck = $check;
63 $this->assertEquals($testedCheck['severity_id'], '3', ' in line ' . __LINE__
);
67 * Permanently hushed items should never show up.
69 public function testSystemCheckHushForever() {
70 $this->_params
= array(
71 'name' => 'checkDefaultMailbox',
72 'ignore_severity' => 7,
74 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
75 $result = $this->callAPISuccess('System', 'check', array());
76 foreach ($result['values'] as $check) {
77 if ($check['name'] == 'checkDefaultMailbox') {
78 $testedCheck = $check;
82 $testedCheck = array();
85 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
89 * Items hushed through tomorrow shouldn't show up.
91 public function testSystemCheckHushFuture() {
92 $tomorrow = new DateTime('tomorrow');
93 $this->_params
= array(
94 'name' => 'checkDefaultMailbox',
95 'ignore_severity' => 7,
96 'hush_until' => $tomorrow->format('Y-m-d'),
98 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
99 $result = $this->callAPISuccess('System', 'check', array());
100 foreach ($result['values'] as $check) {
101 if ($check['name'] == 'checkDefaultMailbox') {
102 $testedCheck = $check;
106 $testedCheck = array();
109 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);;
113 * Items hushed through today should show up.
115 public function testSystemCheckHushToday() {
116 $today = new DateTime('today');
117 $this->_params
= array(
118 'name' => 'checkDefaultMailbox',
119 'ignore_severity' => 7,
120 'hush_until' => $today->format('Y-m-d'),
122 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
123 $result = $this->callAPISuccess('System', 'check', array());
124 foreach ($result['values'] as $check) {
125 if ($check['name'] == 'checkDefaultMailbox') {
126 $testedCheck = $check;
130 $testedCheck = array();
133 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);
137 * Items hushed through yesterday should show up.
139 public function testSystemCheckHushYesterday() {
140 $yesterday = new DateTime('yesterday');
141 $this->_params
= array(
142 'name' => 'checkDefaultMailbox',
143 'ignore_severity' => 7,
144 'hush_until' => $yesterday->format('Y-m-d'),
146 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
147 $result = $this->callAPISuccess('System', 'check', array());
148 foreach ($result['values'] as $check) {
149 if ($check['name'] == 'checkDefaultMailbox') {
150 $testedCheck = $check;
154 $testedCheck = array();
157 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);
161 * Items hushed above current severity should be hidden.
163 public function testSystemCheckHushAboveSeverity() {
164 $this->_params
= array(
165 'name' => 'checkDefaultMailbox',
166 'ignore_severity' => 4,
168 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
169 $result = $this->callAPISuccess('System', 'check', array());
170 foreach ($result['values'] as $check) {
171 if ($check['name'] == 'checkDefaultMailbox') {
172 $testedCheck = $check;
176 $testedCheck = array();
179 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
183 * Items hushed at current severity should be hidden.
185 public function testSystemCheckHushAtSeverity() {
186 $this->_params
= array(
187 'name' => 'checkDefaultMailbox',
188 'ignore_severity' => 3,
190 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
191 $result = $this->callAPISuccess('System', 'check', array());
192 foreach ($result['values'] as $check) {
193 if ($check['name'] == 'checkDefaultMailbox') {
194 $testedCheck = $check;
198 $testedCheck = array();
201 $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__
);
205 * Items hushed below current severity should be shown.
207 public function testSystemCheckHushBelowSeverity() {
208 $this->_params
= array(
209 'name' => 'checkDefaultMailbox',
210 'ignore_severity' => 2,
212 $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params
);
213 $result = $this->callAPISuccess('System', 'check', array());
214 foreach ($result['values'] as $check) {
215 if ($check['name'] == 'checkDefaultMailbox') {
216 $testedCheck = $check;
220 $testedCheck = array();
223 $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__
);