PageRenderTime 51ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/models/recruitment/JobVacancyTest.php

https://bitbucket.org/wildanm/orangehrm
PHP | 579 lines | 334 code | 101 blank | 144 comment | 12 complexity | b38227daee7ff216dbdd0974ef987f68 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, AGPL-3.0, BSD-3-Clause, AGPL-1.0, GPL-2.0, LGPL-2.1, LGPL-3.0
  1. <?php
  2. /**
  3. * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
  4. * all the essential functionalities required for any enterprise.
  5. * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
  6. *
  7. * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
  8. * the GNU General Public License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  12. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with this program;
  16. * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA
  18. *
  19. */
  20. // Call JobVacancyTest::main() if this source file is executed directly.
  21. if (!defined("PHPUnit_MAIN_METHOD")) {
  22. define("PHPUnit_MAIN_METHOD", "JobVacancyTest::main");
  23. }
  24. require_once "PHPUnit/Framework/TestCase.php";
  25. require_once "PHPUnit/Framework/TestSuite.php";
  26. require_once "testConf.php";
  27. require_once ROOT_PATH."/lib/confs/Conf.php";
  28. require_once ROOT_PATH."/lib/confs/sysConf.php";
  29. require_once ROOT_PATH."/lib/models/recruitment/JobVacancy.php";
  30. require_once ROOT_PATH."/lib/common/UniqueIDGenerator.php";
  31. /**
  32. * Test class for JobVacancy
  33. */
  34. class JobVacancyTest extends PHPUnit_Framework_TestCase {
  35. private $jobVacancies;
  36. /**
  37. * Runs the test methods of this class.
  38. *
  39. * @access public
  40. * @static
  41. */
  42. public static function main() {
  43. require_once "PHPUnit/TextUI/TestRunner.php";
  44. $suite = new PHPUnit_Framework_TestSuite("JobVacancyTest");
  45. $result = PHPUnit_TextUI_TestRunner::run($suite);
  46. }
  47. /**
  48. * Sets up the fixture, making sure table is empty and creating database
  49. * entries needed during test.
  50. *
  51. * @access protected
  52. */
  53. protected function setUp() {
  54. $conf = new Conf();
  55. $this->connection = mysql_connect($conf->dbhost.":".$conf->dbport, $conf->dbuser, $conf->dbpass);
  56. mysql_select_db($conf->dbname);
  57. $this->_deleteTables();
  58. // Insert job titles
  59. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  60. "VALUES('JOB001', 'Manager', 'Manager job title', 'no comments', null)");
  61. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  62. "VALUES('JOB002', 'Driver', 'Driver job title', 'no comments', null)");
  63. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  64. "VALUES('JOB003', 'Typist', 'Typist job title', 'no comments', null)");
  65. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  66. "VALUES('JOB004', 'Programmer', 'Software Programmer', 'no comments', null)");
  67. // Insert employees (managers)
  68. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  69. "VALUES(11, '0011', 'Rajasinghe', 'Saman', 'Marlon', 'JOB001')");
  70. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  71. "VALUES(12, '0022', 'Jayasinghe', 'Aruna', 'Shantha', 'JOB001')");
  72. // Insert data for tests
  73. $vacancy = $this->_getJobVacancy(1, 'JOB001', 11, true, 'Job vacancy 1');
  74. $vacancy->setJobTitleName('Manager');
  75. $vacancy->setManagerName('Saman Rajasinghe');
  76. $this->jobVacancies[1] = $vacancy;
  77. $vacancy = $this->_getJobVacancy(2, 'JOB002', 11, false, 'Job vacancy 2');
  78. $vacancy->setJobTitleName('Driver');
  79. $vacancy->setManagerName('Saman Rajasinghe');
  80. $this->jobVacancies[2] = $vacancy;
  81. $vacancy = $this->_getJobVacancy(3, 'JOB003', 12, false, 'Job vacancy 3');
  82. $vacancy->setJobTitleName('Typist');
  83. $vacancy->setManagerName('Aruna Jayasinghe');
  84. $this->jobVacancies[3] = $vacancy;
  85. $vacancy = $this->_getJobVacancy(4, 'JOB004', 12, true, 'Job vacancy 4');
  86. $vacancy->setJobTitleName('Programmer');
  87. $vacancy->setManagerName('Aruna Jayasinghe');
  88. $this->jobVacancies[4] = $vacancy;
  89. $this->_createJobVacancies($this->jobVacancies);
  90. UniqueIDGenerator::getInstance()->resetIDs();
  91. }
  92. /**
  93. * Tears down the fixture, removed database entries created during test.
  94. *
  95. * @access protected
  96. */
  97. protected function tearDown() {
  98. $this->_deleteTables();
  99. UniqueIDGenerator::getInstance()->resetIDs();
  100. }
  101. private function _deleteTables() {
  102. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_vacancy`");
  103. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_title`");
  104. $this->_runQuery("TRUNCATE TABLE `hs_hr_employee`");
  105. }
  106. /**
  107. * test the JobVacancy delete function.
  108. */
  109. public function testDelete() {
  110. $before = $this->_getNumRows();
  111. // invalid params
  112. try {
  113. JobVacancy::delete(34);
  114. $this->fail("Exception not thrown");
  115. } catch (JobVacancyException $e) {
  116. }
  117. // invalid params
  118. try {
  119. JobVacancy::delete(array(1, 'w', 12));
  120. $this->fail("Exception not thrown");
  121. } catch (JobVacancyException $e) {
  122. }
  123. // empty array
  124. $res = JobVacancy::delete(array());
  125. $this->assertEquals(0, $res);
  126. $this->assertEquals($before, $this->_getNumRows());
  127. // no matches
  128. $res = JobVacancy::delete(array(12, 22));
  129. $this->assertEquals(0, $res);
  130. $this->assertEquals($before, $this->_getNumRows());
  131. // one match
  132. $res = JobVacancy::delete(array(1, 21));
  133. $this->assertEquals(1, $res);
  134. $this->assertEquals(1, $before - $this->_getNumRows());
  135. $before = $this->_getNumRows();
  136. // one more the rest
  137. $res = JobVacancy::delete(array(3));
  138. $this->assertEquals(1, $res);
  139. $this->assertEquals(1, $before - $this->_getNumRows());
  140. $before = $this->_getNumRows();
  141. // rest
  142. $res = JobVacancy::delete(array(4, 2));
  143. $this->assertEquals(2, $res);
  144. $this->assertEquals(2, $before - $this->_getNumRows());
  145. }
  146. /**
  147. * Test the save function
  148. */
  149. public function testSave() {
  150. // new
  151. $before = $this->_getNumRows();
  152. $vacancy = $this->_getJobVacancy(null, 'JOB004', 11, true, 'Job vacancy 111');
  153. $id = $vacancy->save();
  154. $this->assertEquals(($before + 1), $this->_getNumRows());
  155. $this->assertEquals(1, $this->_getNumRows("vacancy_id = {$id} AND jobtit_code = 'JOB004' AND manager_id = 11 AND active = '".JobVacancy::STATUS_ACTIVE."' AND description = 'Job vacancy 111'"));
  156. // update
  157. $before = $this->_getNumRows();
  158. $vacancy = $this->_getJobVacancy($id, 'JOB003', 12, true, 'Job vacancy 222');
  159. $newId = $vacancy->save();
  160. $this->assertEquals($id, $newId);
  161. $this->assertEquals($before, $this->_getNumRows());
  162. $this->assertEquals(1, $this->_getNumRows("vacancy_id = {$id} AND jobtit_code = 'JOB003' AND manager_id = 12 AND active = '".JobVacancy::STATUS_ACTIVE."' AND description = 'Job vacancy 222'"));
  163. }
  164. /**
  165. * Test count method
  166. */
  167. public function testCount() {
  168. // Count all
  169. $count = JobVacancy::getCount();
  170. $this->assertEquals(4, $count);
  171. // Match of ID
  172. $count = JobVacancy::getCount(2, 0);
  173. $this->assertEquals(1, $count);
  174. // ID - no match
  175. $count = JobVacancy::getCount(21, 0);
  176. $this->assertEquals(0, $count);
  177. // no match - job title name
  178. $count = JobVacancy::getCount('Administrator', 1);
  179. $this->assertEquals(0, $count);
  180. // match - job title name
  181. $vacancies[] = $this->_getJobVacancy(5, 'JOB004', 11, true, 'Job vacancy 4441');
  182. $this->_createJobVacancies($vacancies);
  183. $count = JobVacancy::getCount('Programmer', 1);
  184. $this->assertEquals(2, $count);
  185. $count = JobVacancy::getCount('Manager', 1);
  186. $this->assertEquals(1, $count);
  187. // Partial match - job title name
  188. $count = JobVacancy::getCount('Man', 1);
  189. $this->assertEquals(1, $count);
  190. // No Match of manager name
  191. $count = JobVacancy::getCount('Brown', 2);
  192. $this->assertEquals(0, $count);
  193. // Match of manager name
  194. $count = JobVacancy::getCount('Saman Rajasinghe', 2);
  195. $this->assertEquals(3, $count);
  196. // partial match of manager name
  197. $count = JobVacancy::getCount('Arun', 2);
  198. $this->assertEquals(2, $count);
  199. // Match of status
  200. $count = JobVacancy::getCount(JobVacancy::STATUS_ACTIVE, 3);
  201. $this->assertEquals(3, $count);
  202. $count = JobVacancy::getCount(JobVacancy::STATUS_INACTIVE, 3);
  203. $this->assertEquals(2, $count);
  204. // No Match of description
  205. $count = JobVacancy::getCount('XYZ', 4);
  206. $this->assertEquals(0, $count);
  207. // Match of description
  208. $count = JobVacancy::getCount('Job vacancy 1', 4);
  209. $this->assertEquals(1, $count);
  210. // Partial Match of description
  211. $count = JobVacancy::getCount('Job', 4);
  212. $this->assertEquals(5, $count);
  213. // delete all
  214. $this->_runQuery("DELETE FROM hs_hr_job_vacancy");
  215. $count = JobVacancy::getCount();
  216. $this->assertEquals(0, $count);
  217. }
  218. /**
  219. * Test the getJobVacancy function
  220. */
  221. public function testGetJobVacancy() {
  222. // unknown id
  223. $vacancy = JobVacancy::getJobVacancy(383);
  224. $this->assertNull($vacancy);
  225. // invalid id
  226. try {
  227. $vacancy = JobVacancy::getJobVacancy('7da');
  228. $this->fail('Should throw exception');
  229. } catch (JobVacancyException $e) {
  230. }
  231. // available vacancy
  232. $vacancy = JobVacancy::getJobVacancy(2);
  233. $this->assertNotNull($vacancy);
  234. $expected = $this->jobVacancies[2];
  235. $this->assertTrue($expected == $vacancy);
  236. }
  237. /**
  238. * Test the getListForView function
  239. */
  240. public function testGetListForView() {
  241. // Get all
  242. $list = JobVacancy::getListForView();
  243. $this->assertTrue(is_array($list));
  244. $this->assertEquals(4, count($list));
  245. $this->_compareVacanciesWithOrder($this->jobVacancies, $list);
  246. // Get all in reverse order by job title name
  247. $list = JobVacancy::getListForView(0, '', JobVacancy::SORT_FIELD_NONE, JobVacancy::SORT_FIELD_JOBTITLE_NAME, 'DESC');
  248. $this->assertTrue(is_array($list));
  249. $this->assertEquals(4, count($list));
  250. $expected = array($this->jobVacancies[3],$this->jobVacancies[4],$this->jobVacancies[1],$this->jobVacancies[2]);
  251. $this->_compareVacanciesWithOrder($expected, $list);
  252. // Search by job title name with exact match
  253. $list = JobVacancy::getListForView(0, 'Typist', JobVacancy::SORT_FIELD_JOBTITLE_NAME, JobVacancy::SORT_FIELD_JOBTITLE_NAME, 'DESC');
  254. $this->assertTrue(is_array($list));
  255. $this->assertEquals(1, count($list));
  256. $expected = array($this->jobVacancies[3]);
  257. $this->_compareVacanciesWithOrder($expected, $list);
  258. // Search by description with multiple matches
  259. $list = JobVacancy::getListForView(0, 'Job vacancy', JobVacancy::SORT_FIELD_DESCRIPTION, JobVacancy::SORT_FIELD_DESCRIPTION, 'DESC');
  260. $this->assertTrue(is_array($list));
  261. $this->assertEquals(4, count($list));
  262. $expected = array($this->jobVacancies[4],$this->jobVacancies[3],$this->jobVacancies[2],$this->jobVacancies[1]);
  263. $this->_compareVacanciesWithOrder($expected, $list);
  264. // Search by description with one match
  265. $list = JobVacancy::getListForView(0, 'Job vacancy 2', JobVacancy::SORT_FIELD_DESCRIPTION, JobVacancy::SORT_FIELD_DESCRIPTION, 'ASC');
  266. $this->assertTrue(is_array($list));
  267. $this->assertEquals(1, count($list));
  268. $expected = array($this->jobVacancies[2]);
  269. $this->_compareVacanciesWithOrder($expected, $list);
  270. // Search by id with one match
  271. $list = JobVacancy::getListForView(0, '3', JobVacancy::SORT_FIELD_VACANCY_ID, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  272. $this->assertTrue(is_array($list));
  273. $this->assertEquals(1, count($list));
  274. $expected = array($this->jobVacancies[3]);
  275. $this->_compareVacanciesWithOrder($expected, $list);
  276. // Search by id with no matches
  277. $list = JobVacancy::getListForView(0, '13', JobVacancy::SORT_FIELD_VACANCY_ID, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  278. $this->assertNull($list);
  279. // Search by manager name with matches
  280. $list = JobVacancy::getListForView(0, 'Aruna', JobVacancy::SORT_FIELD_MANAGER_NAME, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  281. $this->assertTrue(is_array($list));
  282. $this->assertEquals(2, count($list));
  283. $expected = array($this->jobVacancies[3], $this->jobVacancies[4]);
  284. $this->_compareVacanciesWithOrder($expected, $list);
  285. // Search by manager name with no matches
  286. $list = JobVacancy::getListForView(0, 'Kamal', JobVacancy::SORT_FIELD_MANAGER_NAME, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  287. $this->assertNull($list);
  288. // Search by active status
  289. $list = JobVacancy::getListForView(0, JobVacancy::STATUS_ACTIVE, JobVacancy::SORT_FIELD_ACTIVE, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  290. $this->assertTrue(is_array($list));
  291. $this->assertEquals(2, count($list));
  292. $expected = array($this->jobVacancies[1], $this->jobVacancies[4]);
  293. $this->_compareVacanciesWithOrder($expected, $list);
  294. $list = JobVacancy::getListForView(0, JobVacancy::STATUS_INACTIVE, JobVacancy::SORT_FIELD_ACTIVE, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  295. $this->assertTrue(is_array($list));
  296. $this->assertEquals(2, count($list));
  297. $expected = array($this->jobVacancies[2], $this->jobVacancies[3]);
  298. $this->_compareVacanciesWithOrder($expected, $list);
  299. // when no job vacancys available
  300. $this->assertTrue(mysql_query('DELETE from hs_hr_job_vacancy'), mysql_error());
  301. $list = JobVacancy::getListForView();
  302. $this->assertNull($list);
  303. // Insert data for paging tests
  304. for ($i=1; $i<251; $i++) {
  305. $inc = 100 + $i;
  306. if ($i % 2 == 0) {
  307. $desc = "Even ";
  308. $even = true;
  309. $status = true;
  310. } else {
  311. $desc = "Odd ";
  312. $even = false;
  313. $status = false;
  314. }
  315. $vacancy = $this->_getJobVacancy($i, 'JOB001', 11, $status, "$desc-$inc");
  316. $vacancy->setJobTitleName('Manager');
  317. $vacancy->setManagerName('Saman Rajasinghe');
  318. $vacancys[] = $vacancy;
  319. if ($even) {
  320. $evenVacancys[] = $vacancy;
  321. } else {
  322. $oddVacancys[] = $vacancy;
  323. }
  324. }
  325. $this->_createJobVacancies($vacancys);
  326. $sysConf = new sysConf();
  327. $pageSize = $sysConf->itemsPerPage;
  328. // check paging - without search
  329. // page 1
  330. $list = JobVacancy::getListForView(1, '', JobVacancy::SORT_FIELD_NONE, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  331. $this->assertTrue(is_array($list));
  332. $this->assertEquals($pageSize, count($list));
  333. $pages = array_chunk($vacancys, $pageSize);
  334. $this->_compareVacanciesWithOrder($pages[0], $list);
  335. // page 3
  336. $list = JobVacancy::getListForView(3, '', JobVacancy::SORT_FIELD_NONE, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  337. $this->assertTrue(is_array($list));
  338. $this->assertEquals($pageSize, count($list));
  339. $this->_compareVacanciesWithOrder($pages[2], $list);
  340. // paging with search
  341. // Separate even rows to pages
  342. $pages = array_chunk($evenVacancys, $pageSize);
  343. // Search only for even (status = active) rows and check page 1
  344. $list = JobVacancy::getListForView(1, JobVacancy::STATUS_ACTIVE, JobVacancy::SORT_FIELD_ACTIVE, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  345. $this->assertTrue(is_array($list));
  346. $this->assertEquals(count($pages[0]), count($list));
  347. $this->_compareVacanciesWithOrder($pages[0], $list);
  348. $list = JobVacancy::getListForView(3, JobVacancy::STATUS_ACTIVE, JobVacancy::SORT_FIELD_ACTIVE, JobVacancy::SORT_FIELD_VACANCY_ID, 'ASC');
  349. $this->assertTrue(is_array($list));
  350. $this->assertEquals(count($pages[2]), count($list));
  351. $this->_compareVacanciesWithOrder($pages[2], $list);
  352. }
  353. /**
  354. * test the getAll function
  355. */
  356. public function testGetAll() {
  357. // Get all
  358. $list = JobVacancy::getAll();
  359. $this->assertTrue(is_array($list));
  360. $this->assertEquals(4, count($list));
  361. $this->_compareVacancys($this->jobVacancies, $list);
  362. // when no job vacancys available
  363. $this->assertTrue(mysql_query('DELETE from hs_hr_job_vacancy'), mysql_error());
  364. $list = JobVacancy::getAll();
  365. $this->assertTrue(is_array($list));
  366. $this->assertEquals(0, count($list));
  367. }
  368. /**
  369. * test the getActive function
  370. */
  371. public function testGetActive() {
  372. // Get all active
  373. $list = JobVacancy::getActive();
  374. $this->assertTrue(is_array($list));
  375. $this->assertEquals(2, count($list));
  376. $expected = array(1=>$this->jobVacancies[1], 4=>$this->jobVacancies[4]);
  377. $this->_compareVacancys($expected, $list);
  378. // Mark all as inactive and get all
  379. $sql = 'UPDATE hs_hr_job_vacancy SET active = ' . JobVacancy::STATUS_INACTIVE;
  380. $this->_runQuery($sql);
  381. $list = JobVacancy::getActive();
  382. $this->assertTrue(is_array($list));
  383. $this->assertEquals(0, count($list));
  384. // when no job vacancies available
  385. $this->_runQuery('DELETE from hs_hr_job_vacancy');
  386. $list = JobVacancy::getActive();
  387. $this->assertTrue(is_array($list));
  388. $this->assertEquals(0, count($list));
  389. }
  390. /**
  391. * Returns the number of rows in the hs_hr_job_vacancy table
  392. *
  393. * @param string $where where clause
  394. * @return int number of rows
  395. */
  396. private function _getNumRows($where = null) {
  397. $sql = "SELECT COUNT(*) FROM hs_hr_job_vacancy";
  398. if (!empty($where)) {
  399. $sql .= " WHERE " . $where;
  400. }
  401. $result = mysql_query($sql);
  402. $row = mysql_fetch_array($result, MYSQL_NUM);
  403. $count = $row[0];
  404. return $count;
  405. }
  406. /**
  407. * Compares two array of JobVacancy objects verifing they contain the same
  408. * objects, without considering the order
  409. *
  410. * Objects in first array should be indexed by their id's
  411. *
  412. * @param array $expected Expected
  413. * @param array $result Result
  414. */
  415. private function _compareVacancys($expected, $result) {
  416. $this->assertEquals(count($expected), count($result));
  417. foreach ($result as $vacancy) {
  418. $this->assertTrue($vacancy instanceof JobVacancy, "Should return JobVacancy objects");
  419. $id = $vacancy->getId();
  420. $this->assertEquals($expected[$id], $vacancy);
  421. }
  422. }
  423. /**
  424. * Compares two array of JobVacancy objects verifing they contain the same
  425. * objects and considering the order
  426. *
  427. *
  428. * @param array $expected Expected
  429. * @param array $result Result
  430. */
  431. private function _compareVacanciesWithOrder($expected, $result) {
  432. $this->assertEquals(count($expected), count($result));
  433. $i = 0;
  434. foreach ($expected as $vacancy) {
  435. $this->assertEquals($vacancy->getId(), $result[$i][0]);
  436. $this->assertEquals($vacancy->getJobTitleName(), $result[$i][1]);
  437. $this->assertEquals($vacancy->getManagerName(), $result[$i][2]);
  438. $this->assertEquals($vacancy->isActive(), $result[$i][3] == 1);
  439. $this->assertEquals($vacancy->getDescription(), $result[$i][4]);
  440. $i++;
  441. }
  442. }
  443. /**
  444. * Create a JobVacancy object with the passed parameters
  445. */
  446. private function _getJobVacancy($id, $jobTitleCode, $managerId, $active, $description) {
  447. $vacancy = new JobVacancy($id);
  448. $vacancy->setJobTitleCode($jobTitleCode);
  449. $vacancy->setManagerId($managerId);
  450. $vacancy->setActive($active);
  451. $vacancy->setDescription($description);
  452. return $vacancy;
  453. }
  454. /**
  455. * Saves the given JobVacancy objects in the databas
  456. *
  457. * @param array $vacancies Array of JobVacancy objects to save.
  458. */
  459. private function _createJobVacancies($vacancies) {
  460. foreach ($vacancies as $vacancy) {
  461. $active = $vacancy->isActive() ? JobVacancy::STATUS_ACTIVE : JobVacancy::STATUS_INACTIVE;
  462. $sql = sprintf("INSERT INTO hs_hr_job_vacancy(vacancy_id, jobtit_code, manager_id, active, description) " .
  463. "VALUES(%d, '%s', %d, '%s', '%s')",
  464. $vacancy->getId(), $vacancy->getJobTitleCode(), $vacancy->getManagerId(),
  465. $active, $vacancy->getDescription());
  466. $this->assertTrue(mysql_query($sql), mysql_error());
  467. }
  468. UniqueIDGenerator::getInstance()->initTable();
  469. }
  470. private function _runQuery($sql) {
  471. $this->assertTrue(mysql_query($sql), mysql_error());
  472. }
  473. }
  474. // Call JobVacancyTest::main() if this source file is executed directly.
  475. if (PHPUnit_MAIN_METHOD == "JobVacancyTest::main") {
  476. JobVacancyTest::main();
  477. }
  478. ?>