/** * test the parseSearchData function */ public function testParseSearchData() { $extractor = new EXTRACTOR_ViewList(); // No parameters - default settings $get = array(); $post = array(); $searchObj = $extractor->parseSearchData($post, $get); $expected = $this->_getDefaultSearchObject(); $this->assertEquals($expected, $searchObj); // With search parameters $post = array('pageNO' => '2', 'captureState' => 'SearchMode', 'loc_code' => '2', 'loc_name' => 'XYZ'); $searchObj = $extractor->parseSearchData($post, $get); $expected = $this->_getDefaultSearchObject(); $expected->setPageNumber(2); $expected->setSearchField(2); $expected->setSearchString('XYZ'); $this->assertEquals($expected, $searchObj); // with sort parameters $post = array('pageNO' => '3'); $get = array('sortField' => 2, 'sortOrder2' => 'DESC'); $searchObj = $extractor->parseSearchData($post, $get); $expected = $this->_getDefaultSearchObject(); $expected->setPageNumber(3); $expected->setSortField(2); $expected->setSortOrder(SearchObject::SORT_ORDER_DESC); $this->assertEquals($expected, $searchObj); // with search and sort parameters $post = array('pageNO' => '2', 'captureState' => 'SearchMode', 'loc_code' => '2', 'loc_name' => 'XYZ'); $get = array('sortField' => 2, 'sortOrder2' => 'DESC'); $searchObj = $extractor->parseSearchData($post, $get); $expected = $this->_getDefaultSearchObject(); $expected->setPageNumber(2); $expected->setSearchField(2); $expected->setSearchString('XYZ'); $expected->setSortField(2); $expected->setSortOrder(SearchObject::SORT_ORDER_DESC); $this->assertEquals($expected, $searchObj); }
/** * Handle incoming requests * @param String code Recruit code */ public function handleRequest($code) { if (empty($code) || !isset($_GET['action'])) { trigger_error("Invalid Action " . $_GET['action'], E_USER_NOTICE); return; } switch ($code) { case 'Vacancy': $viewListExtractor = new EXTRACTOR_ViewList(); switch ($_GET['action']) { case 'List': $searchObject = $viewListExtractor->parseSearchData($_POST, $_GET); $this->_viewVacancies($searchObject); break; case 'View': $id = isset($_GET['id']) ? $_GET['id'] : null; $this->_viewVacancy($id); break; case 'ViewAdd': $this->_viewAddVacancy(); break; case 'Add': $extractor = new EXTRACTOR_JobVacancy(); $vacancy = $extractor->parseData($_POST); $this->_addVacancy($vacancy); break; case 'Update': $extractor = new EXTRACTOR_JobVacancy(); $vacancy = $extractor->parseData($_POST); $this->_updateVacancy($vacancy); break; case 'Delete': $ids = $_POST['chkID']; $this->_deleteVacancies($ids); break; } break; case 'Application': $id = isset($_GET['id']) ? $_GET['id'] : null; switch ($_GET['action']) { case 'List': $this->_viewApplicationList(); break; case 'ConfirmReject': $this->_confirmAction($id, JobApplication::ACTION_REJECT); break; case 'Reject': $eventExtractor = new EXTRACTOR_JobApplicationEvent(); $event = $eventExtractor->parseAddData($_POST); $this->_rejectApplication($event); break; case 'ConfirmFirstInterview': $this->_scheduleFirstInterview($id); break; case 'FirstInterview': $interviewExtractor = new EXTRACTOR_ScheduleInterview(); $event = $interviewExtractor->parseAddData($_POST); $this->_saveFirstInterview($event); break; case 'ConfirmSecondInterview': $this->_scheduleSecondInterview($id); break; case 'SecondInterview': $interviewExtractor = new EXTRACTOR_ScheduleInterview(); $event = $interviewExtractor->parseAddData($_POST); $this->_saveSecondInterview($event); break; case 'ConfirmOfferJob': $this->_confirmAction($id, JobApplication::ACTION_OFFER_JOB); break; case 'OfferJob': $eventExtractor = new EXTRACTOR_JobApplicationEvent(); $event = $eventExtractor->parseAddData($_POST); $this->_offerJob($event); break; case 'ConfirmMarkDeclined': $this->_confirmAction($id, JobApplication::ACTION_MARK_OFFER_DECLINED); break; case 'MarkDeclined': $eventExtractor = new EXTRACTOR_JobApplicationEvent(); $event = $eventExtractor->parseAddData($_POST); $this->_markDeclined($event); break; case 'ConfirmSeekApproval': $this->_confirmSeekApproval($id); break; case 'SeekApproval': $eventExtractor = new EXTRACTOR_JobApplicationEvent(); $event = $eventExtractor->parseSeekApprovalData($_POST); $this->_seekApproval($event); break; case 'ConfirmApprove': $this->_confirmAction($id, JobApplication::ACTION_APPROVE); break; case 'Approve': $eventExtractor = new EXTRACTOR_JobApplicationEvent(); $event = $eventExtractor->parseAddData($_POST); $this->_approve($event); break; case 'ViewDetails': $this->_viewApplicationDetails($id); break; case 'ViewHistory': $this->_viewApplicationHistory($id); break; case 'EditEvent': $eventExtractor = new EXTRACTOR_JobApplicationEvent(); $object = $eventExtractor->parseUpdateData($_POST); $this->_editEvent($object); break; } break; } }