PageRenderTime 37ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/models/benefits/DefineHspTest.php

https://bitbucket.org/wildanm/orangehrm
PHP | 88 lines | 47 code | 17 blank | 24 comment | 3 complexity | d0ea11a14ebf40fb0f4778184ea782c5 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 DefineHspTest::main() if this source file is executed directly.
  3. if (!defined('PHPUnit_MAIN_METHOD')) {
  4. define('PHPUnit_MAIN_METHOD', 'DefineHspTest::main');
  5. }
  6. require_once "PHPUnit/Framework/TestCase.php";
  7. require_once "PHPUnit/Framework/TestSuite.php";
  8. require_once 'DefineHsp.php';
  9. require_once ROOT_PATH."/lib/confs/Conf.php";
  10. require_once ROOT_PATH."/lib/common/UniqueIDGenerator.php";
  11. /**
  12. * Test class for DefineHsp.
  13. * Generated by PHPUnit on 2008-02-18 at 11:42:04.
  14. */
  15. class DefineHspTest extends PHPUnit_Framework_TestCase {
  16. private $oldValues;
  17. /**
  18. * Runs the test methods of this class.
  19. *
  20. * @access public
  21. * @static
  22. */
  23. public static function main() {
  24. require_once 'PHPUnit/TextUI/TestRunner.php';
  25. $suite = new PHPUnit_Framework_TestSuite('DefineHspTest');
  26. $result = PHPUnit_TextUI_TestRunner::run($suite);
  27. }
  28. /**
  29. * Sets up the fixture, for example, opens a network connection.
  30. * This method is called before a test is executed.
  31. *
  32. * @access protected
  33. */
  34. protected function setUp() {
  35. $conf = new Conf();
  36. $this->connection = mysql_connect($conf->dbhost.":".$conf->dbport, $conf->dbuser, $conf->dbpass);
  37. mysql_select_db($conf->dbname);
  38. $result = mysql_query("SELECT * FROM hs_hr_config;");
  39. $this->oldValues = array();
  40. while($row = mysql_fetch_array($result, MYSQL_NUM)) {
  41. $this->oldValues[] = $row;
  42. }
  43. mysql_free_result($result);
  44. $this->assertTrue(mysql_query("TRUNCATE `hs_hr_config`;", $this->connection), mysql_error());
  45. $this->assertTrue(mysql_query("INSERT INTO hs_hr_config (`key`, `value`) VALUES('hsp_current_plan', '0')"), mysql_error());
  46. }
  47. /**
  48. * Tears down the fixture, for example, closes a network connection.
  49. * This method is called after a test is executed.
  50. *
  51. * @access protected
  52. */
  53. protected function tearDown() {
  54. $this->assertTrue(mysql_query("TRUNCATE `hs_hr_config`;", $this->connection), mysql_error());
  55. foreach ($this->oldValues as $row) {
  56. $query = "INSERT INTO `hs_hr_config` VALUES ('" . implode("', '", $row) . "')";
  57. $this->assertTrue(mysql_query($query));
  58. }
  59. UniqueIDGenerator::getInstance()->resetIDs();
  60. }
  61. public function testfetchHsp() {
  62. $definedHsp = DefineHsp::fetchHsp();
  63. $expected = '0';
  64. $this->assertEquals($expected, $definedHsp);
  65. }
  66. }
  67. // Call DefineHspTest::main() if this source file is executed directly.
  68. if (PHPUnit_MAIN_METHOD == 'DefineHspTest::main') {
  69. DefineHspTest::main();
  70. }
  71. ?>