Пример #1
0
 /**
  * Delete vacancies with given IDs
  * @param Array $ids Array with Vacancy ID's to delete
  */
 private function _deleteVacancies($ids)
 {
     if ($this->authorizeObj->isAdmin()) {
         try {
             $count = JobVacancy::delete($ids);
             $message = 'DELETE_SUCCESS';
         } catch (JobVacancyException $e) {
             $message = 'DELETE_FAILURE';
         }
         $this->redirect($message, '?recruitcode=Vacancy&action=List');
     } else {
         $this->_notAuthorized();
     }
 }
 /**
  * test the JobVacancy delete function.
  */
 public function testDelete()
 {
     $before = $this->_getNumRows();
     // invalid params
     try {
         JobVacancy::delete(34);
         $this->fail("Exception not thrown");
     } catch (JobVacancyException $e) {
     }
     // invalid params
     try {
         JobVacancy::delete(array(1, 'w', 12));
         $this->fail("Exception not thrown");
     } catch (JobVacancyException $e) {
     }
     // empty array
     $res = JobVacancy::delete(array());
     $this->assertEquals(0, $res);
     $this->assertEquals($before, $this->_getNumRows());
     // no matches
     $res = JobVacancy::delete(array(12, 22));
     $this->assertEquals(0, $res);
     $this->assertEquals($before, $this->_getNumRows());
     // one match
     $res = JobVacancy::delete(array(1, 21));
     $this->assertEquals(1, $res);
     $this->assertEquals(1, $before - $this->_getNumRows());
     $before = $this->_getNumRows();
     // one more the rest
     $res = JobVacancy::delete(array(3));
     $this->assertEquals(1, $res);
     $this->assertEquals(1, $before - $this->_getNumRows());
     $before = $this->_getNumRows();
     // rest
     $res = JobVacancy::delete(array(4, 2));
     $this->assertEquals(2, $res);
     $this->assertEquals(2, $before - $this->_getNumRows());
 }