public function testClear() { $instance = new History(); $this->assertTrue($instance->add('foo')); $this->assertTrue($instance->add('bar')); $this->assertTrue($instance->clear()); $this->assertEquals([], $instance->getAll()); }
private function viewItemHistory() { /* Bail out if the user doesn't have SA permissions. */ if ($this->_realAccessLevel < ACCESS_LEVEL_DEMO) { CommonErrors::fatal(COMMONERROR_PERMISSION, $this); return; //$this->fatal(ERROR_NO_PERMISSION); } /* Bail out if we don't have a valid data item type. */ if (!$this->isRequiredIDValid('dataItemType', $_GET)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid data item type.'); } /* Bail out if we don't have a valid data item ID. */ if (!$this->isRequiredIDValid('dataItemID', $_GET)) { CommonErrors::fatal(COMMONERROR_BADINDEX, $this, 'Invalid data item ID.'); } $dataItemType = $_GET['dataItemType']; $dataItemID = $_GET['dataItemID']; switch ($dataItemType) { case DATA_ITEM_CANDIDATE: $candidates = new Candidates($this->_siteID); $data = $candidates->get($dataItemID); break; case DATA_ITEM_JOBORDER: $jobOrders = new JobOrders($this->_siteID); $data = $jobOrders->get($dataItemID); break; case DATA_ITEM_COMPANY: $companies = new Companies($this->_siteID); $data = $companies->get($dataItemID); break; case DATA_ITEM_CONTACT: $contacts = new Contacts($this->_siteID); $data = $contacts->get($dataItemID); break; default: CommonErrors::fatal(COMMONERROR_BADFIELDS, $this, 'Invalid data item type.'); break; } /* Get revision information. */ $history = new History($this->_siteID); $revisionRS = $history->getAll($dataItemType, $dataItemID); $this->_template->assign('active', $this); $this->_template->assign('subActive', 'Login Activity'); $this->_template->assign('data', $data); $this->_template->assign('revisionRS', $revisionRS); $this->_template->display('./modules/settings/ItemHistory.tpl'); }