orangehrm /lib/models/benefits/DefineHspTest.php

Language PHP Lines 89
MD5 Hash d0ea11a14ebf40fb0f4778184ea782c5 Estimated Cost $1,041 (why?)
Repository https://bitbucket.org/wildanm/orangehrm View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php
// Call DefineHspTest::main() if this source file is executed directly.
if (!defined('PHPUnit_MAIN_METHOD')) {
    define('PHPUnit_MAIN_METHOD', 'DefineHspTest::main');
}

require_once "PHPUnit/Framework/TestCase.php";
require_once "PHPUnit/Framework/TestSuite.php";

require_once 'DefineHsp.php';

require_once ROOT_PATH."/lib/confs/Conf.php";
require_once ROOT_PATH."/lib/common/UniqueIDGenerator.php";

/**
 * Test class for DefineHsp.
 * Generated by PHPUnit on 2008-02-18 at 11:42:04.
 */
class DefineHspTest extends PHPUnit_Framework_TestCase {
	private $oldValues;
	
    /**
     * Runs the test methods of this class.
     *
     * @access public
     * @static
     */
    public static function main() {
        require_once 'PHPUnit/TextUI/TestRunner.php';

        $suite  = new PHPUnit_Framework_TestSuite('DefineHspTest');
        $result = PHPUnit_TextUI_TestRunner::run($suite);
    }

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     *
     * @access protected
     */
    protected function setUp() {
    	$conf = new Conf();
    	$this->connection = mysql_connect($conf->dbhost.":".$conf->dbport, $conf->dbuser, $conf->dbpass);
        mysql_select_db($conf->dbname);
        
        $result = mysql_query("SELECT * FROM hs_hr_config;");
        $this->oldValues = array();
        
        while($row = mysql_fetch_array($result, MYSQL_NUM)) {
			$this->oldValues[] = $row;         	
        }
        
        mysql_free_result($result);
        
		$this->assertTrue(mysql_query("TRUNCATE `hs_hr_config`;", $this->connection), mysql_error());
		$this->assertTrue(mysql_query("INSERT INTO hs_hr_config (`key`, `value`) VALUES('hsp_current_plan', '0')"), mysql_error());
    }

    /**
     * Tears down the fixture, for example, closes a network connection.
     * This method is called after a test is executed.
     *
     * @access protected
     */
    protected function tearDown() {
    	$this->assertTrue(mysql_query("TRUNCATE `hs_hr_config`;", $this->connection), mysql_error());
    	
    	foreach ($this->oldValues as $row) {
    		$query = "INSERT INTO `hs_hr_config` VALUES ('" . implode("', '", $row) . "')";
    		$this->assertTrue(mysql_query($query));
    	}

    	UniqueIDGenerator::getInstance()->resetIDs();
    }

    public function testfetchHsp() {
		$definedHsp = DefineHsp::fetchHsp();
		$expected = '0';

		$this->assertEquals($expected, $definedHsp);
    }
}

// Call DefineHspTest::main() if this source file is executed directly.
if (PHPUnit_MAIN_METHOD == 'DefineHspTest::main') {
    DefineHspTest::main();
}
?>
Back to Top