PageRenderTime 39ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/lib/models/eimadmin/export/plugins/MilleniumPayrollExportTest.php

https://bitbucket.org/wildanm/orangehrm
PHP | 157 lines | 84 code | 23 blank | 50 comment | 4 complexity | 75b9b352f7faee4a26c2c44eff2306b1 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. // Call MilleniumPayrollExportTest::main() if this source file is executed directly.
  3. if (!defined("PHPUnit_MAIN_METHOD")) {
  4. define("PHPUnit_MAIN_METHOD", "MilleniumPayrollExportTest::main");
  5. }
  6. require_once "PHPUnit/Framework/TestCase.php";
  7. require_once "PHPUnit/Framework/TestSuite.php";
  8. require_once 'testConf.php';
  9. require_once ROOT_PATH . '/lib/confs/Conf.php';
  10. require_once 'MilleniumPayrollExport.php';
  11. require_once ROOT_PATH . '/lib/models/eimadmin/encryption/KeyHandler.php';
  12. /**
  13. * Test class for MilleniumPayrollExport.
  14. * Generated by PHPUnit_Util_Skeleton on 2007-12-13 at 20:57:42.
  15. */
  16. class MilleniumPayrollExportTest extends PHPUnit_Framework_TestCase {
  17. private $exportObj;
  18. /**
  19. * Runs the test methods of this class.
  20. *
  21. * @access public
  22. * @static
  23. */
  24. public static function main() {
  25. require_once "PHPUnit/TextUI/TestRunner.php";
  26. $suite = new PHPUnit_Framework_TestSuite("MilleniumPayrollExportTest");
  27. $result = PHPUnit_TextUI_TestRunner::run($suite);
  28. }
  29. /**
  30. * Sets up the fixture, for example, open a network connection.
  31. * This method is called before a test is executed.
  32. *
  33. * @access protected
  34. */
  35. protected function setUp() {
  36. $this->exportObj = new MilleniumPayrollExport();
  37. $conf = new Conf();
  38. $this->connection = mysql_connect($conf->dbhost.":".$conf->dbport, $conf->dbuser, $conf->dbpass);
  39. mysql_select_db($conf->dbname);
  40. $this->_truncateTables();
  41. $sql = "INSERT INTO hs_hr_employee" .
  42. "(emp_number, employee_id, emp_lastname, emp_firstname, emp_middle_name, " .
  43. "emp_nick_name, emp_smoker, ethnic_race_code, emp_birthday, nation_code, " .
  44. "emp_gender, emp_marital_status, emp_ssn_num, emp_sin_num, emp_other_id, " .
  45. "emp_dri_lice_num, emp_dri_lice_exp_date, emp_military_service, emp_status, " .
  46. "job_title_code, eeo_cat_code, work_station, " .
  47. "emp_street1, emp_street2, city_code, coun_code, provin_code, emp_zipcode, " .
  48. "emp_hm_telephone, emp_mobile, emp_work_telephone, emp_work_email, " .
  49. "sal_grd_code, joined_date, emp_oth_email) VALUES (" .
  50. "'10', 'E1921A', 'Karunadasa', 'Kamal', 'K', " .
  51. "NULL, NULL, NULL, '1974-11-20', NULL, " .
  52. "1, NULL, '987654320', '', '', " .
  53. "null, NULL, NULL, 'EST001', " .
  54. "NULL, NULL, NULL, " .
  55. "'111 Main Street', 'SUITE A29', 'Houston', 'US', 'TX', '77845', " .
  56. "'', '', '', NULL, " .
  57. "NULL, '1997-12-11', NULL)";
  58. if (KeyHandler::keyExists()) {
  59. $key = KeyHandler::readKey();
  60. $sql = str_replace("'987654320'", "AES_ENCRYPT('987654320', '$key')", $sql);
  61. }
  62. $this->assertTrue(mysql_query($sql), mysql_error());
  63. $sql = "INSERT into hs_hr_emp_us_tax(emp_number, tax_federal_status, tax_federal_exceptions, " .
  64. "tax_state, tax_state_status, tax_state_exceptions, tax_unemp_state,tax_work_state) VALUES (" .
  65. "10, 'NRA', 2, 'MD', 'NA', 3, 'VA', 'AZ')";
  66. $this->assertTrue(mysql_query($sql), mysql_error());
  67. }
  68. /**
  69. * Tears down the fixture, for example, close a network connection.
  70. * This method is called after a test is executed.
  71. *
  72. * @access protected
  73. */
  74. protected function tearDown() {
  75. $this->_truncateTables();
  76. }
  77. /**
  78. * Test getCSVData().
  79. */
  80. public function testGetCSVData() {
  81. /*$expected = "E1921A,Karunadasa,Kamal,K,111 Main Street,SUITE A29,Houston,TX,77845,M,11/20/1974," .
  82. "987654320,A,12-11-1997,CC1,CC2,CC3,CC4,CC5,,WorkState,,," .
  83. "Home Phone,Ethnicity,Base Rate,Default Hours,Salary,Pay Frequency,Auto Pay,FITW Status," .
  84. "FITW Exemptions,SITW State,SITW Status,SITW Exemptions,SITW Exemptions 2,SUI State," .
  85. "Transit,DD1 Account,DD1 Amount,DD1 Amount Code,DD1 Checking,Transit,DD2 Account," .
  86. "DD2 Amount,DD2 Amount Code,DD2 Checking";*/
  87. $expected = "E1921A,Karunadasa,Kamal,K,111 Main Street,SUITE A29,Houston,TX,77845,M,11/20/1974," .
  88. "987654320,A,12-11-1997,CC1,CC2,CC3,CC4,CC5,,'AZ',,," .
  89. "Home Phone,Ethnicity,Base Rate,Default Hours,Salary,Pay Frequency,Auto Pay,'NRA'," .
  90. "2,'MD','NA',3,,'VA'," .
  91. "Transit,DD1 Account,DD1 Amount,DD1 Amount Code,DD1 Checking,Transit,DD2 Account," .
  92. "DD2 Amount,DD2 Amount Code,DD2 Checking";
  93. $expected = "E1921A,Karunadasa,Kamal,K,111 Main Street,SUITE A29,Houston,TX,77845,M,11/20/1974," .
  94. "987654320,A,12/11/1997,,,,,,,AZ,,," .
  95. ",,,,,,,NRA," .
  96. "2,MD,NA,3,,VA," .
  97. ",,,,,,," .
  98. ",,\n";
  99. /*$expected = "E1921A,Karunadasa,Kamal,K,111 Main Street,SUITE A29,Houston,TX,77845,M,11/20/1974," .
  100. "987654320,A,12/11/1997,,,,,,,,,," .
  101. ",,,,,,,," .
  102. ",,,,,," .
  103. ",,,,,,," .
  104. ",,\n";*/
  105. $actual = $this->exportObj->getCSVData();
  106. //echo "ACTUAL=|" . $actual . "|\n";
  107. //echo "EXPECTED=|" . $expected . "|\n";
  108. $this->assertEquals($expected, $actual);
  109. }
  110. /**
  111. * Test getName().
  112. */
  113. public function testGetName() {
  114. $this->assertEquals("Millenium Payroll Export", $this->exportObj->getName());
  115. }
  116. /**
  117. * Test getHeader().
  118. */
  119. public function testGetHeader() {
  120. $expectedHeader = "ID,Last Name,First Name,Middle Name,Address 1,Address 2, City,State,Zip,Gender,Birth Date,SSN,Status,Hire Date,CC1,CC2,CC3,CC4,CC5,TaxForm,WorkState,Emp Type,Clock Number,Home Phone,Ethnicity,Base Rate,Default Hours,Salary,Pay Frequency,Auto Pay,FITW Status,FITW Exemptions,SITW State,SITW Status,SITW Exemptions,SITW Exemptions 2,SUI State,Transit,DD1 Account,DD1 Amount,DD1 Amount Code,DD1 Checking,Transit,DD2 Account,DD2 Amount,DD2 Amount Code,DD2 Checking";
  121. $this->assertEquals($expectedHeader, $this->exportObj->getHeader());
  122. }
  123. /**
  124. * Truncates tables used in test.
  125. */
  126. private function _truncateTables() {
  127. $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_employee`"), mysql_error());
  128. }
  129. }
  130. // Call MilleniumPayrollExportTest::main() if this source file is executed directly.
  131. if (PHPUnit_MAIN_METHOD == "MilleniumPayrollExportTest::main") {
  132. MilleniumPayrollExportTest::main();
  133. }
  134. ?>