_apiversion = 3; parent::setUp(); $this->useTransaction(TRUE); } /** * Ensure that without any StatusPreference set, checkDefaultMailbox shows * up. */ public function testSystemCheckBasic() { $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } } $this->assertEquals($testedCheck['severity_id'], '3', ' in line ' . __LINE__); } /** * Permanently hushed items should never show up. */ public function testSystemCheckHushForever() { $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 7, ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__); } /** * Items hushed through tomorrow shouldn't show up. */ public function testSystemCheckHushFuture() { $tomorrow = new DateTime('tomorrow'); $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 7, 'hush_until' => $tomorrow->format('Y-m-d'), ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__);; } /** * Items hushed through today should show up. */ public function testSystemCheckHushToday() { $today = new DateTime('today'); $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 7, 'hush_until' => $today->format('Y-m-d'), ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__); } /** * Items hushed through yesterday should show up. */ public function testSystemCheckHushYesterday() { $yesterday = new DateTime('yesterday'); $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 7, 'hush_until' => $yesterday->format('Y-m-d'), ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__); } /** * Items hushed above current severity should be hidden. */ public function testSystemCheckHushAboveSeverity() { $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 4, ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__); } /** * Items hushed at current severity should be hidden. */ public function testSystemCheckHushAtSeverity() { $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 3, ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '0', 'in line ' . __LINE__); } /** * Items hushed below current severity should be shown. */ public function testSystemCheckHushBelowSeverity() { $this->_params = array( 'name' => 'checkDefaultMailbox', 'ignore_severity' => 2, ); $statusPreference = $this->callAPISuccess('StatusPreference', 'create', $this->_params); $result = $this->callAPISuccess('System', 'check', array()); foreach ($result['values'] as $check) { if ($check['name'] == 'checkDefaultMailbox') { $testedCheck = $check; break; } else { $testedCheck = array(); } } $this->assertEquals($testedCheck['is_visible'], '1', 'in line ' . __LINE__); } }