PageRenderTime 59ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/models/recruitment/RecruitmentAuthManagerTest.php

https://bitbucket.org/wildanm/orangehrm
PHP | 1108 lines | 763 code | 211 blank | 134 comment | 3 complexity | e20e1c64db6954d0e4830bf01904c546 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

Large files files are truncated, but you can click here to view the full file

  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 RecruitmentAuthManagerTest::main() if this source file is executed directly.
  21. if (!defined("PHPUnit_MAIN_METHOD")) {
  22. define("PHPUnit_MAIN_METHOD", "RecruitmentAuthManagerTest::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/JobApplication.php";
  30. require_once ROOT_PATH."/lib/models/recruitment/JobVacancy.php";
  31. require_once ROOT_PATH."/lib/models/recruitment/RecruitmentAuthManager.php";
  32. require_once ROOT_PATH."/lib/common/UniqueIDGenerator.php";
  33. require_once ROOT_PATH."/lib/common/authorize.php";
  34. /**
  35. * Test class for RecruitmentAuthManager.
  36. */
  37. class RecruitmentAuthManagerTest extends PHPUnit_Framework_TestCase {
  38. private $jobApplications;
  39. /**
  40. * Runs the test methods of this class.
  41. *
  42. * @access public
  43. * @static
  44. */
  45. public static function main() {
  46. require_once "PHPUnit/TextUI/TestRunner.php";
  47. $suite = new PHPUnit_Framework_TestSuite("RecruitmentAuthManagerTest");
  48. $result = PHPUnit_TextUI_TestRunner::run($suite);
  49. }
  50. /**
  51. * Sets up the fixture, for example, open a network connection.
  52. * This method is called before a test is executed.
  53. *
  54. * @access protected
  55. */
  56. protected function setUp() {
  57. $conf = new Conf();
  58. $this->connection = mysql_connect($conf->dbhost.":".$conf->dbport, $conf->dbuser, $conf->dbpass);
  59. mysql_select_db($conf->dbname);
  60. $this->_deleteTables();
  61. // Insert job titles
  62. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  63. "VALUES('JOB001', 'Manager', 'Manager job title', 'no comments', null)");
  64. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  65. "VALUES('JOB002', 'Driver', 'Driver job title', 'no comments', null)");
  66. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  67. "VALUES('JOB003', 'Typist', 'Typist job title', 'no comments', null)");
  68. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  69. "VALUES('JOB004', 'Programmer', 'Software Programmer', 'no comments', null)");
  70. $this->_runQuery("INSERT INTO hs_hr_job_title(jobtit_code, jobtit_name, jobtit_desc, jobtit_comm, sal_grd_code) " .
  71. "VALUES('JOB005', 'Director', 'Company Director', 'no comments', null)");
  72. // Insert employees (managers)
  73. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  74. "VALUES(11, '0011', 'Rajasinghe', 'Saman', 'Marlon', 'JOB001')");
  75. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  76. "VALUES(12, '0022', 'Jayasinghe', 'Aruna', 'Shantha', 'JOB001')");
  77. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  78. "VALUES(13, '0042', 'Jayaweera', 'Nimal', 'T', 'JOB001')");
  79. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  80. "VALUES(14, '0044', 'Karunarathne', 'Jaya', 'S', 'JOB001')");
  81. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  82. "VALUES(15, '0054', 'Ranasinghe', 'Kamal', 'Z', 'JOB001')");
  83. // Non manager
  84. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  85. "VALUES(16, '0055', 'Karunanayake', 'Kamal', 'S', 'JOB003')");
  86. // Directors
  87. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  88. "VALUES(17, '0056', 'Ramanayake', 'Dasun', 'K', 'JOB005')");
  89. $this->_runQuery("INSERT INTO hs_hr_employee(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, job_title_code) " .
  90. "VALUES(18, '0057', 'Suraweera', 'Nuwan', 'E', 'JOB005')");
  91. // Insert to hs_hr_users table
  92. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number, is_admin) VALUES ('USR111','demo', 15, 'Yes')");
  93. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number, is_admin) VALUES ('USR112','demo2', 11, 'Yes')");
  94. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number, is_admin) VALUES ('USR113','demo3', 13, 'Yes')");
  95. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number, is_admin) VALUES ('USR114','demo4', 14, 'Yes')");
  96. $this->_runQuery("INSERT INTO `hs_hr_users`(id, user_name, emp_number, is_admin) VALUES ('USR117','demo5', 17, 'No')");
  97. // Insert Job Vacancies
  98. $this->_runQuery("INSERT INTO hs_hr_job_vacancy(vacancy_id, jobtit_code, manager_id, active, description) " .
  99. "VALUES(1, 'JOB001', 11, " . JobVacancy::STATUS_ACTIVE . ", 'Job vacancy 1')");
  100. $this->_runQuery("INSERT INTO hs_hr_job_vacancy(vacancy_id, jobtit_code, manager_id, active, description) " .
  101. "VALUES(2, 'JOB002', 11, " . JobVacancy::STATUS_INACTIVE . ", 'Job vacancy 2')");
  102. $this->_runQuery("INSERT INTO hs_hr_job_vacancy(vacancy_id, jobtit_code, manager_id, active, description) " .
  103. "VALUES(3, 'JOB003', 12, " . JobVacancy::STATUS_INACTIVE . ", 'Job vacancy 3')");
  104. // Insert Job Applications
  105. $application = $this->_getJobApplication(1, 1, 'Janaka', 'T', 'Kulathunga', '111 Main Street', 'Apt X2',
  106. 'Colombo', 'Western', '2222', 'Sri Lanka', '01121111121', '077282828282', 'janaka@example.com',
  107. 'aaa bbb', JobApplication::STATUS_SUBMITTED);
  108. $application->setHiringManagerName('Saman Rajasinghe');
  109. $application->setJobTitleName('Manager');
  110. $this->jobApplications[1] = $application;
  111. $application = $this->_getJobApplication(2, 2, 'Kamal', 'S', 'Manawarathne', '222 Sea Street', 'Suite B2',
  112. 'Kandy', 'Central', '111111', 'England', '33211121', '079982828282', 'kamal@etst.com',
  113. 'asdfasdf', JobApplication::STATUS_SUBMITTED);
  114. $application->setHiringManagerName('Saman Rajasinghe');
  115. $application->setJobTitleName('Driver');
  116. $this->jobApplications[2] = $application;
  117. $application = $this->_getJobApplication(3, 3, 'Ruwan', 'S', 'Nawarathne', '393 Hill Street', '#2',
  118. 'Nuwaraeliya', 'Central', '2333', 'Sri Lanka', '05121111121', '072282828282', 'rywab@sfmple.com',
  119. 'aaa sdf bbb', JobApplication::STATUS_SUBMITTED);
  120. $application->setHiringManagerName('Aruna Jayasinghe');
  121. $application->setJobTitleName('Typist');
  122. $this->jobApplications[3] = $application;
  123. $application = $this->_getJobApplication(4, 3, 'Ruwan', 'S', 'Nawarathne', '393 Hill Street', '#2',
  124. 'Nuwaraeliya', 'Central', '2333', 'Sri Lanka', '05121111121', '072282828282', 'rywab@sfmple.com',
  125. 'aaa sdf bbb', JobApplication::STATUS_SUBMITTED);
  126. $application->setHiringManagerName('Aruna Jayasinghe');
  127. $application->setJobTitleName('Typist');
  128. $this->jobApplications[4] = $application;
  129. $application = $this->_getJobApplication(5, 2, 'Ruwan', 'S', 'Nawarathne', '393 Hill Street', '#2',
  130. 'Nuwaraeliya', 'Central', '2333', 'Sri Lanka', '05121111121', '072282828282', 'rywab@sfmple.com',
  131. 'aaa sdf bbb', JobApplication::STATUS_PENDING_APPROVAL);
  132. $application->setHiringManagerName('Aruna Jayasinghe');
  133. $application->setJobTitleName('Typist');
  134. $this->jobApplications[5] = $application;
  135. $this->_createJobApplications($this->jobApplications);
  136. // Create job application events
  137. $createdTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT, strtotime("-1 hours"));
  138. $eventTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT, strtotime("+5 days"));
  139. // Events for first job application
  140. $this->_createEvent(1, 1, $createdTime, 'USR111', 13, $eventTime,
  141. JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_FINISHED,
  142. "1st Interview notes, here");
  143. $createdTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT, strtotime("-0.6 hours"));
  144. $eventTime = date(LocaleUtil::STANDARD_TIMESTAMP_FORMAT, strtotime("+6 days"));
  145. $this->_createEvent(2, 1, $createdTime, 'USR111', 14, $eventTime,
  146. JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED,
  147. "2nd Interview notes, here");
  148. // Events for second job application
  149. $this->_createEvent(3, 2, $createdTime, 'USR111', 14, $eventTime,
  150. JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED,
  151. "3rd Interview notes, here");
  152. // Events for 3rd job application
  153. $this->_createEvent(4, 3, $createdTime, 'USR111', 12, $eventTime,
  154. JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED,
  155. "3rd Interview notes, here");
  156. $this->_createEvent(5, 3, $createdTime, 'USR111', 12, $eventTime,
  157. JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED,
  158. "3rd Interview notes, here");
  159. // Events for 4th job application
  160. $this->_createEvent(6, 4, $createdTime, 'USR111', 13, $eventTime,
  161. JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED,
  162. "3rd Interview notes, here");
  163. $this->_createEvent(7, 4, $createdTime, 'USR111', 13, $eventTime,
  164. JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW, JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED,
  165. "3rd Interview notes, here");
  166. // Events for 5th job application
  167. $this->_createEvent(8, 5, $createdTime, 'USR111', 17, $eventTime,
  168. JobApplicationEvent::EVENT_SEEK_APPROVAL, null,
  169. "Seeking approval to hire");
  170. UniqueIDGenerator::getInstance()->resetIDs();
  171. }
  172. /**
  173. * Tears down the fixture, removed database entries created during test.
  174. *
  175. * @access protected
  176. */
  177. protected function tearDown() {
  178. $this->_deleteTables();
  179. UniqueIDGenerator::getInstance()->resetIDs();
  180. }
  181. private function _deleteTables() {
  182. $this->_runQuery("DELETE FROM `hs_hr_users` WHERE id IN ('USR111', 'USR112', 'USR113', 'USR114', 'USR117')");
  183. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_application`");
  184. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_vacancy`");
  185. $this->_runQuery("TRUNCATE TABLE `hs_hr_job_title`");
  186. $this->_runQuery("TRUNCATE TABLE `hs_hr_employee`");
  187. }
  188. /**
  189. * Test case for testGetRoleForApplication().
  190. */
  191. public function testGetRoleForApplication() {
  192. $authManager = new RecruitmentAuthManager();
  193. // Admin user
  194. $auth = new authorize(null, authorize::YES);
  195. $app = JobApplication::getJobApplication(1);
  196. $role = $authManager->getRoleForApplication($auth, $app);
  197. $this->assertEquals(RecruitmentAuthManager::ROLE_ADMIN, $role);
  198. // Hiring - manager
  199. $auth = new authorize('011', authorize::NO);
  200. $app = JobApplication::getJobApplication(1);
  201. $role = $authManager->getRoleForApplication($auth, $app);
  202. $this->assertEquals(RecruitmentAuthManager::ROLE_HIRING_MANAGER, $role);
  203. // 1st Interviewer
  204. $auth = new authorize(13, authorize::NO);
  205. $app = JobApplication::getJobApplication(1);
  206. $role = $authManager->getRoleForApplication($auth, $app);
  207. $this->assertEquals(RecruitmentAuthManager::ROLE_INTERVIEW1_MANAGER, $role);
  208. $app = JobApplication::getJobApplication(2);
  209. $auth = new authorize(14, authorize::NO);
  210. $role = $authManager->getRoleForApplication($auth, $app);
  211. $this->assertEquals(RecruitmentAuthManager::ROLE_INTERVIEW1_MANAGER, $role);
  212. // 2nd Interviewer
  213. $auth = new authorize(14, authorize::NO);
  214. $app = JobApplication::getJobApplication(1);
  215. $role = $authManager->getRoleForApplication($auth, $app);
  216. $this->assertEquals(RecruitmentAuthManager::ROLE_INTERVIEW2_MANAGER, $role);
  217. // Admin also Hiring - Manager : Should be ADMIN ROLE
  218. $auth = new authorize(11, authorize::YES);
  219. $app = JobApplication::getJobApplication(1);
  220. $role = $authManager->getRoleForApplication($auth, $app);
  221. $this->assertEquals(RecruitmentAuthManager::ROLE_ADMIN, $role);
  222. // Admin also 1st Interviewer : Should be ADMIN ROLE
  223. $auth = new authorize(13, authorize::YES);
  224. $app = JobApplication::getJobApplication(1);
  225. $role = $authManager->getRoleForApplication($auth, $app);
  226. $this->assertEquals(RecruitmentAuthManager::ROLE_ADMIN, $role);
  227. // Admin also 2nd Interviewer : Should be ADMIN ROLE
  228. $auth = new authorize(14, authorize::YES);
  229. $app = JobApplication::getJobApplication(1);
  230. $role = $authManager->getRoleForApplication($auth, $app);
  231. $this->assertEquals(RecruitmentAuthManager::ROLE_ADMIN, $role);
  232. // Hiring-Manager also 1st and 2nd Interviewer: Should be Hiring Manager
  233. $auth = new authorize(12, authorize::NO);
  234. $app = JobApplication::getJobApplication(3);
  235. $role = $authManager->getRoleForApplication($auth, $app);
  236. $this->assertEquals(RecruitmentAuthManager::ROLE_HIRING_MANAGER, $role);
  237. // 1st Interviewer also 2nd Interviewer: Should be 2nd Interviewer
  238. $auth = new authorize(13, authorize::NO);
  239. $app = JobApplication::getJobApplication(4);
  240. $role = $authManager->getRoleForApplication($auth, $app);
  241. $this->assertEquals(RecruitmentAuthManager::ROLE_INTERVIEW2_MANAGER, $role);
  242. // Other manager
  243. $auth = new authorize(15, authorize::NO);
  244. $app = JobApplication::getJobApplication(1);
  245. $role = $authManager->getRoleForApplication($auth, $app);
  246. $this->assertEquals(RecruitmentAuthManager::ROLE_OTHER_MANAGER, $role);
  247. // Other non-manager
  248. $auth = new authorize(16, authorize::NO);
  249. $app = JobApplication::getJobApplication(1);
  250. $role = $authManager->getRoleForApplication($auth, $app);
  251. $this->assertEquals(RecruitmentAuthManager::ROLE_OTHER, $role);
  252. // Director
  253. $auth = new authorize(17, authorize::NO);
  254. $app = JobApplication::getJobApplication(5);
  255. $role = $authManager->getRoleForApplication($auth, $app);
  256. $this->assertEquals(RecruitmentAuthManager::ROLE_DIRECTOR, $role);
  257. // Other Director
  258. $auth = new authorize(18, authorize::NO);
  259. $app = JobApplication::getJobApplication(5);
  260. $role = $authManager->getRoleForApplication($auth, $app);
  261. $this->assertEquals(RecruitmentAuthManager::ROLE_OTHER_DIRECTOR, $role);
  262. }
  263. /**
  264. * test testGetAllowedActions().
  265. */
  266. public function testGetAllowedActions() {
  267. $authManager = new RecruitmentAuthManager();
  268. $app = JobApplication::getJobApplication(1);
  269. $app5 = JobApplication::getJobApplication(5);
  270. // Different users
  271. $admin = new authorize(null, authorize::YES);
  272. $hiring = new authorize('011', authorize::NO);
  273. $first = new authorize(13, authorize::NO);
  274. $second = new authorize(14, authorize::NO);
  275. $manager = new authorize(15, authorize::NO);
  276. $nonManager = new authorize(16, authorize::NO);
  277. $director = new authorize(17, authorize::NO);
  278. $otherDirector = new authorize(18, authorize::NO);
  279. /* SUBMITTED */
  280. $app->setStatus(JobApplication::STATUS_SUBMITTED);
  281. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW, JobApplication::ACTION_OFFER_JOB);
  282. $actions = $authManager->getAllowedActions($admin, $app);
  283. $this->assertEquals($expected, $actions);
  284. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW, JobApplication::ACTION_OFFER_JOB);
  285. $actions = $authManager->getAllowedActions($hiring, $app);
  286. $this->assertEquals($expected, $actions);
  287. $expected = array();
  288. $actions = $authManager->getAllowedActions($first, $app);
  289. $this->assertEquals($expected, $actions);
  290. $expected = array();
  291. $actions = $authManager->getAllowedActions($second, $app);
  292. $this->assertEquals($expected, $actions);
  293. $expected = array();
  294. $actions = $authManager->getAllowedActions($manager, $app);
  295. $this->assertEquals($expected, $actions);
  296. $expected = array();
  297. $actions = $authManager->getAllowedActions($nonManager, $app);
  298. $this->assertEquals($expected, $actions);
  299. $expected = array();
  300. $actions = $authManager->getAllowedActions($director, $app);
  301. $this->assertEquals($expected, $actions);
  302. $expected = array();
  303. $actions = $authManager->getAllowedActions($otherDirector, $app);
  304. $this->assertEquals($expected, $actions);
  305. /* FIRST INTERVIEW SCHEDULED (scheduled) */
  306. $app->setStatus(JobApplication::STATUS_FIRST_INTERVIEW_SCHEDULED);
  307. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
  308. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED);
  309. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  310. $actions = $authManager->getAllowedActions($admin, $app);
  311. $this->assertEquals($expected, $actions);
  312. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  313. $actions = $authManager->getAllowedActions($hiring, $app);
  314. $this->assertEquals($expected, $actions);
  315. $expected = array(JobApplication::ACTION_REJECT);
  316. $role = $authManager->getRoleForApplication($first, $app);
  317. $this->assertEquals(RecruitmentAuthManager::ROLE_INTERVIEW1_MANAGER, $role);
  318. $actions = $authManager->getAllowedActions($first, $app);
  319. $this->assertEquals($expected, $actions);
  320. $expected = array();
  321. $actions = $authManager->getAllowedActions($second, $app);
  322. $this->assertEquals($expected, $actions);
  323. $expected = array();
  324. $actions = $authManager->getAllowedActions($manager, $app);
  325. $this->assertEquals($expected, $actions);
  326. $expected = array();
  327. $actions = $authManager->getAllowedActions($nonManager, $app);
  328. $this->assertEquals($expected, $actions);
  329. $expected = array();
  330. $actions = $authManager->getAllowedActions($director, $app);
  331. $this->assertEquals($expected, $actions);
  332. $expected = array();
  333. $actions = $authManager->getAllowedActions($otherDirector, $app);
  334. $this->assertEquals($expected, $actions);
  335. /* FIRST INTERVIEW SCHEDULED (finished) */
  336. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
  337. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_FINISHED);
  338. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW, JobApplication::ACTION_OFFER_JOB);
  339. $actions = $authManager->getAllowedActions($admin, $app);
  340. $this->assertEquals($expected, $actions);
  341. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW, JobApplication::ACTION_OFFER_JOB);
  342. $actions = $authManager->getAllowedActions($hiring, $app);
  343. $this->assertEquals($expected, $actions);
  344. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW);
  345. $actions = $authManager->getAllowedActions($first, $app);
  346. $this->assertEquals($expected, $actions);
  347. $expected = array();
  348. $actions = $authManager->getAllowedActions($second, $app);
  349. $this->assertEquals($expected, $actions);
  350. $expected = array();
  351. $actions = $authManager->getAllowedActions($manager, $app);
  352. $this->assertEquals($expected, $actions);
  353. $expected = array();
  354. $actions = $authManager->getAllowedActions($nonManager, $app);
  355. $this->assertEquals($expected, $actions);
  356. $expected = array();
  357. $actions = $authManager->getAllowedActions($director, $app);
  358. $this->assertEquals($expected, $actions);
  359. $expected = array();
  360. $actions = $authManager->getAllowedActions($otherDirector, $app);
  361. $this->assertEquals($expected, $actions);
  362. /* SECOND INTERVIEW SCHEDULED (scheduled) */
  363. $app->setStatus(JobApplication::STATUS_SECOND_INTERVIEW_SCHEDULED);
  364. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
  365. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED);
  366. $app->setEvents(array($event));
  367. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  368. $actions = $authManager->getAllowedActions($admin, $app);
  369. $this->assertEquals($expected, $actions);
  370. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  371. $actions = $authManager->getAllowedActions($hiring, $app);
  372. $this->assertEquals($expected, $actions);
  373. $expected = array();
  374. $actions = $authManager->getAllowedActions($first, $app);
  375. $this->assertEquals($expected, $actions);
  376. $expected = array(JobApplication::ACTION_REJECT);
  377. $actions = $authManager->getAllowedActions($second, $app);
  378. $this->assertEquals($expected, $actions);
  379. $expected = array();
  380. $actions = $authManager->getAllowedActions($manager, $app);
  381. $this->assertEquals($expected, $actions);
  382. $expected = array();
  383. $actions = $authManager->getAllowedActions($nonManager, $app);
  384. $this->assertEquals($expected, $actions);
  385. $expected = array();
  386. $actions = $authManager->getAllowedActions($director, $app);
  387. $this->assertEquals($expected, $actions);
  388. $expected = array();
  389. $actions = $authManager->getAllowedActions($otherDirector, $app);
  390. $this->assertEquals($expected, $actions);
  391. /* SECOND INTERVIEW SCHEDULED (finished) */
  392. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
  393. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_FINISHED);
  394. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  395. $actions = $authManager->getAllowedActions($admin, $app);
  396. $this->assertEquals($expected, $actions);
  397. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  398. $actions = $authManager->getAllowedActions($hiring, $app);
  399. $this->assertEquals($expected, $actions);
  400. $expected = array();
  401. $actions = $authManager->getAllowedActions($first, $app);
  402. $this->assertEquals($expected, $actions);
  403. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  404. $actions = $authManager->getAllowedActions($second, $app);
  405. $this->assertEquals($expected, $actions);
  406. $expected = array();
  407. $actions = $authManager->getAllowedActions($manager, $app);
  408. $this->assertEquals($expected, $actions);
  409. $expected = array();
  410. $actions = $authManager->getAllowedActions($nonManager, $app);
  411. $this->assertEquals($expected, $actions);
  412. $expected = array();
  413. $actions = $authManager->getAllowedActions($director, $app);
  414. $this->assertEquals($expected, $actions);
  415. $expected = array();
  416. $actions = $authManager->getAllowedActions($otherDirector, $app);
  417. $this->assertEquals($expected, $actions);
  418. // Job Offered
  419. $app->setStatus(JobApplication::STATUS_JOB_OFFERED);
  420. $expected = array(JobApplication::ACTION_MARK_OFFER_DECLINED, JobApplication::ACTION_SEEK_APPROVAL);
  421. $actions = $authManager->getAllowedActions($admin, $app);
  422. $this->assertEquals($expected, $actions);
  423. $expected = array(JobApplication::ACTION_MARK_OFFER_DECLINED, JobApplication::ACTION_SEEK_APPROVAL);
  424. $actions = $authManager->getAllowedActions($hiring, $app);
  425. $this->assertEquals($expected, $actions);
  426. $expected = array();
  427. $actions = $authManager->getAllowedActions($first, $app);
  428. $this->assertEquals($expected, $actions);
  429. $expected = array();
  430. $actions = $authManager->getAllowedActions($second, $app);
  431. $this->assertEquals($expected, $actions);
  432. $expected = array();
  433. $actions = $authManager->getAllowedActions($manager, $app);
  434. $this->assertEquals($expected, $actions);
  435. $expected = array();
  436. $actions = $authManager->getAllowedActions($nonManager, $app);
  437. $this->assertEquals($expected, $actions);
  438. $expected = array();
  439. $actions = $authManager->getAllowedActions($director, $app);
  440. $this->assertEquals($expected, $actions);
  441. $expected = array();
  442. $actions = $authManager->getAllowedActions($otherDirector, $app);
  443. $this->assertEquals($expected, $actions);
  444. // Offer Declined
  445. $app->setStatus(JobApplication::STATUS_OFFER_DECLINED);
  446. $expected = array();
  447. $actions = $authManager->getAllowedActions($admin, $app);
  448. $this->assertEquals($expected, $actions);
  449. $expected = array();
  450. $actions = $authManager->getAllowedActions($hiring, $app);
  451. $this->assertEquals($expected, $actions);
  452. $expected = array();
  453. $actions = $authManager->getAllowedActions($first, $app);
  454. $this->assertEquals($expected, $actions);
  455. $expected = array();
  456. $actions = $authManager->getAllowedActions($second, $app);
  457. $this->assertEquals($expected, $actions);
  458. $expected = array();
  459. $actions = $authManager->getAllowedActions($manager, $app);
  460. $this->assertEquals($expected, $actions);
  461. $expected = array();
  462. $actions = $authManager->getAllowedActions($nonManager, $app);
  463. $this->assertEquals($expected, $actions);
  464. // Pending approval
  465. $app5->setStatus(JobApplication::STATUS_PENDING_APPROVAL);
  466. $expected = array();
  467. $actions = $authManager->getAllowedActions($admin, $app5);
  468. $this->assertEquals($expected, $actions);
  469. $expected = array();
  470. $actions = $authManager->getAllowedActions($hiring, $app5);
  471. $this->assertEquals($expected, $actions);
  472. $expected = array();
  473. $actions = $authManager->getAllowedActions($first, $app5);
  474. $this->assertEquals($expected, $actions);
  475. $expected = array();
  476. $actions = $authManager->getAllowedActions($second, $app5);
  477. $this->assertEquals($expected, $actions);
  478. $expected = array();
  479. $actions = $authManager->getAllowedActions($manager, $app5);
  480. $this->assertEquals($expected, $actions);
  481. $expected = array();
  482. $actions = $authManager->getAllowedActions($nonManager, $app5);
  483. $this->assertEquals($expected, $actions);
  484. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_APPROVE);
  485. $actions = $authManager->getAllowedActions($director, $app5);
  486. $this->assertEquals($expected, $actions);
  487. $expected = array();
  488. $actions = $authManager->getAllowedActions($otherDirector, $app5);
  489. $this->assertEquals($expected, $actions);
  490. // Hired
  491. $app->setStatus(JobApplication::STATUS_HIRED);
  492. $expected = array();
  493. $actions = $authManager->getAllowedActions($admin, $app);
  494. $this->assertEquals($expected, $actions);
  495. $expected = array();
  496. $actions = $authManager->getAllowedActions($hiring, $app);
  497. $this->assertEquals($expected, $actions);
  498. $expected = array();
  499. $actions = $authManager->getAllowedActions($first, $app);
  500. $this->assertEquals($expected, $actions);
  501. $expected = array();
  502. $actions = $authManager->getAllowedActions($second, $app);
  503. $this->assertEquals($expected, $actions);
  504. $expected = array();
  505. $actions = $authManager->getAllowedActions($manager, $app);
  506. $this->assertEquals($expected, $actions);
  507. $expected = array();
  508. $actions = $authManager->getAllowedActions($nonManager, $app);
  509. $this->assertEquals($expected, $actions);
  510. $expected = array();
  511. $actions = $authManager->getAllowedActions($director, $app);
  512. $this->assertEquals($expected, $actions);
  513. $expected = array();
  514. $actions = $authManager->getAllowedActions($otherDirector, $app);
  515. $this->assertEquals($expected, $actions);
  516. // Rejected
  517. $app->setStatus(JobApplication::STATUS_REJECTED);
  518. $expected = array();
  519. $actions = $authManager->getAllowedActions($admin, $app);
  520. $this->assertEquals($expected, $actions);
  521. $expected = array();
  522. $actions = $authManager->getAllowedActions($hiring, $app);
  523. $this->assertEquals($expected, $actions);
  524. $expected = array();
  525. $actions = $authManager->getAllowedActions($first, $app);
  526. $this->assertEquals($expected, $actions);
  527. $expected = array();
  528. $actions = $authManager->getAllowedActions($second, $app);
  529. $this->assertEquals($expected, $actions);
  530. $expected = array();
  531. $actions = $authManager->getAllowedActions($manager, $app);
  532. $this->assertEquals($expected, $actions);
  533. $expected = array();
  534. $actions = $authManager->getAllowedActions($nonManager, $app);
  535. $this->assertEquals($expected, $actions);
  536. $expected = array();
  537. $actions = $authManager->getAllowedActions($director, $app);
  538. $this->assertEquals($expected, $actions);
  539. $expected = array();
  540. $actions = $authManager->getAllowedActions($otherDirector, $app);
  541. $this->assertEquals($expected, $actions);
  542. }
  543. /**
  544. * test testIsActionAllowed().
  545. */
  546. public function testIsActionAllowed() {
  547. $authManager = new RecruitmentAuthManager();
  548. $app = JobApplication::getJobApplication(1);
  549. $app5 = JobApplication::getJobApplication(5);
  550. // Different users
  551. $admin = new authorize(null, authorize::YES);
  552. $hiring = new authorize('011', authorize::NO);
  553. $first = new authorize(13, authorize::NO);
  554. $second = new authorize(14, authorize::NO);
  555. $manager = new authorize(15, authorize::NO);
  556. $nonManager = new authorize(16, authorize::NO);
  557. $director = new authorize(17, authorize::NO);
  558. $otherDirector = new authorize(18, authorize::NO);
  559. /* SUBMITTED */
  560. $app->setStatus(JobApplication::STATUS_SUBMITTED);
  561. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW));
  562. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  563. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  564. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW));
  565. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  566. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  567. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW));
  568. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  569. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  570. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  571. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  572. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  573. /* FIRST INTERVIEW SCHEDULED (scheduled) */
  574. $app->setStatus(JobApplication::STATUS_FIRST_INTERVIEW_SCHEDULED);
  575. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
  576. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED);
  577. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  578. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW));
  579. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  580. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  581. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  582. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  583. $this->assertTrue($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  584. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  585. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  586. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  587. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  588. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  589. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  590. /* FIRST INTERVIEW SCHEDULED (finished) */
  591. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_FIRST_INTERVIEW);
  592. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_FINISHED);
  593. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW);
  594. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  595. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_FIRST_INTERVIEW));
  596. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  597. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  598. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  599. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  600. $this->assertTrue($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  601. $this->assertTrue($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  602. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  603. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  604. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  605. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  606. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  607. /* SECOND INTERVIEW SCHEDULED (scheduled) */
  608. $app->setStatus(JobApplication::STATUS_SECOND_INTERVIEW_SCHEDULED);
  609. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
  610. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_SCHEDULED);
  611. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  612. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_OFFER_JOB));
  613. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  614. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  615. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  616. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  617. $this->assertTrue($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  618. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  619. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  620. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  621. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  622. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  623. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  624. /* SECOND INTERVIEW SCHEDULED (finished) */
  625. $event = $app->getEventOfType(JobApplicationEvent::EVENT_SCHEDULE_SECOND_INTERVIEW);
  626. $event->setStatus(JobApplicationEvent::STATUS_INTERVIEW_FINISHED);
  627. $expected = array(JobApplication::ACTION_REJECT, JobApplication::ACTION_OFFER_JOB);
  628. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  629. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_OFFER_JOB));
  630. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  631. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  632. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_OFFER_JOB));
  633. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  634. $this->assertTrue($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  635. $this->assertTrue($authManager->isActionAllowed($second, $app, JobApplication::ACTION_OFFER_JOB));
  636. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  637. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  638. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  639. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  640. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  641. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  642. // Job Offered
  643. $app->setStatus(JobApplication::STATUS_JOB_OFFERED);
  644. $expected = array(JobApplication::ACTION_MARK_OFFER_DECLINED, JobApplication::ACTION_SEEK_APPROVAL);
  645. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_MARK_OFFER_DECLINED));
  646. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_SEEK_APPROVAL));
  647. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_MARK_OFFER_DECLINED));
  648. $this->assertTrue($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SEEK_APPROVAL));
  649. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  650. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_MARK_OFFER_DECLINED));
  651. $this->assertTrue($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  652. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  653. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_SEEK_APPROVAL));
  654. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_MARK_OFFER_DECLINED));
  655. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  656. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  657. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  658. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  659. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  660. // Offer Declined
  661. $app->setStatus(JobApplication::STATUS_OFFER_DECLINED);
  662. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  663. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  664. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  665. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_OFFER_JOB));
  666. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  667. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  668. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_OFFER_JOB));
  669. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  670. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  671. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_OFFER_JOB));
  672. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  673. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  674. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  675. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  676. // Pending approval
  677. $app5->setStatus(JobApplication::STATUS_PENDING_APPROVAL);
  678. $this->assertFalse($authManager->isActionAllowed($otherDirector, $app5, JobApplication::ACTION_APPROVE));
  679. $this->assertFalse($authManager->isActionAllowed($otherDirector, $app5, JobApplication::ACTION_REJECT));
  680. $this->assertTrue($authManager->isActionAllowed($director, $app5, JobApplication::ACTION_APPROVE));
  681. $this->assertTrue($authManager->isActionAllowed($director, $app5, JobApplication::ACTION_REJECT));
  682. $this->assertFalse($authManager->isActionAllowed($admin, $app5, JobApplication::ACTION_REJECT));
  683. $this->assertFalse($authManager->isActionAllowed($admin, $app5, JobApplication::ACTION_OFFER_JOB));
  684. $this->assertFalse($authManager->isActionAllowed($admin, $app5, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  685. $this->assertFalse($authManager->isActionAllowed($hiring, $app5, JobApplication::ACTION_REJECT));
  686. $this->assertFalse($authManager->isActionAllowed($hiring, $app5, JobApplication::ACTION_OFFER_JOB));
  687. $this->assertFalse($authManager->isActionAllowed($hiring, $app5, JobApplication::ACTION_SEEK_APPROVAL));
  688. $this->assertFalse($authManager->isActionAllowed($second, $app5, JobApplication::ACTION_REJECT));
  689. $this->assertFalse($authManager->isActionAllowed($second, $app5, JobApplication::ACTION_OFFER_JOB));
  690. $this->assertFalse($authManager->isActionAllowed($first, $app5, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  691. $this->assertFalse($authManager->isActionAllowed($first, $app5, JobApplication::ACTION_REJECT));
  692. $this->assertFalse($authManager->isActionAllowed($manager, $app5, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  693. $this->assertFalse($authManager->isActionAllowed($nonManager, $app5, JobApplication::ACTION_SEEK_APPROVAL));
  694. // Hired
  695. $app->setStatus(JobApplication::STATUS_HIRED);
  696. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  697. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  698. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  699. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_OFFER_JOB));
  700. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  701. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  702. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_OFFER_JOB));
  703. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  704. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  705. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_OFFER_JOB));
  706. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  707. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  708. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  709. $this->assertFalse($authManager->isActionAllowed($nonManager, $app, JobApplication::ACTION_SEEK_APPROVAL));
  710. // Rejected
  711. $app->setStatus(JobApplication::STATUS_REJECTED);
  712. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_APPROVE));
  713. $this->assertFalse($authManager->isActionAllowed($director, $app, JobApplication::ACTION_REJECT));
  714. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_REJECT));
  715. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_OFFER_JOB));
  716. $this->assertFalse($authManager->isActionAllowed($admin, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  717. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_REJECT));
  718. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_OFFER_JOB));
  719. $this->assertFalse($authManager->isActionAllowed($hiring, $app, JobApplication::ACTION_SEEK_APPROVAL));
  720. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_REJECT));
  721. $this->assertFalse($authManager->isActionAllowed($second, $app, JobApplication::ACTION_OFFER_JOB));
  722. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  723. $this->assertFalse($authManager->isActionAllowed($first, $app, JobApplication::ACTION_REJECT));
  724. $this->assertFalse($authManager->isActionAllowed($manager, $app, JobApplication::ACTION_SCHEDULE_SECOND_INTERVIEW));
  725. $this->assertFalse($authMana

Large files files are truncated, but you can click here to view the full file