⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hsptest.php

📁 国外的人才求职招聘最新版
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		$result = mysql_query("SELECT `total_accrued` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 2");		$resultArray = mysql_fetch_array($result);		$this->assertEquals($expectedAccrued2, $resultArray[0]);    }    public function testUpdateUsed() {		$this->assertNotNull(mysql_query("TRUNCATE `hs_hr_employee`;", $this->connection), mysql_error());        $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_payment_request`"), mysql_error());		$this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_summary`"), mysql_error());		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (1, '001', 'Arnold', 'Subasinghe', '', 'Arnold', 0, NULL, '0000-00-00 00:00:00', NULL, NULL, NULL, '', '', '', '', '0000-00-00', '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, '0000-00-00', '', Null, Null, Null, Null, Null, Null, Null, Null, Null, Null)"));		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (2, '002', 'Kalum', 'Kumara', '', 'Kal', 0, NULL, '0000-00-00 00:00:00', NULL, NULL, NULL, '', '', '', '', '0000-00-00', '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, '0000-00-00', '', Null, Null, Null, Null, Null, Null, Null, Null, Null, Null)"));		// For employee1		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (1, 1, 1, '".date('Y')."-02-01', 'Test provider', 'Tester', 'Just testing', '150', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-02',  '123552-55821-ff25', 1)"), mysql_error());	    $this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (2, 1, 1, '".date('Y')."-02-10', 'Test provider', 'Tester', 'Just testing', '100', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-11',  '123552-55821-ff25', 1)"), mysql_error());		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (3, 1, 1, '".date('Y')."-02-20', 'Test provider', 'Tester', 'Just testing', '127', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-21',  '123552-55821-ff25', 1)"), mysql_error());		// For employee2		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (4, 1, 2, '".date('Y')."-02-01', 'Test provider', 'Tester', 'Just testing', '122', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-02',  '123552-55821-ff25', 1)"), mysql_error());	    $this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (5, 1, 2, '".date('Y')."-02-10', 'Test provider', 'Tester', 'Just testing', '41', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-11',  '123552-55821-ff25', 1)"), mysql_error());		$this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(1, 1, 1, '".date('Y')."', 1, 1500, 50, 50, 0, 22)"), mysql_error());		$this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(2, 2, 1, '".date('Y')."', 1, 2500, 75, 75, 0, 0)"), mysql_error());		$this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '".(date('Y')-1)."-12-31' WHERE `key` = 'hsp_Used_last_updated'"));		$this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '1' WHERE `key` = 'hsp_current_plan'"));		Hsp::updateUsed(date('Y')); // total_used is calculated by function and should be equal to expense sum of employee1 (150+100+127) plus existed value (22)		$result = mysql_query("SELECT `total_used` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");		$resultArray = mysql_fetch_array($result);		$this->assertEquals(399, $resultArray[0]);		$result = mysql_query("SELECT `total_used` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 2");		$resultArray = mysql_fetch_array($result);		$this->assertEquals(163, $resultArray[0]); // should be 163 (122+41)    }    public function testUpdateUsedForTwoPlans() {		$this->assertNotNull(mysql_query("TRUNCATE `hs_hr_employee`;", $this->connection), mysql_error());        $this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_payment_request`"), mysql_error());		$this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_summary`"), mysql_error());		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (1, '001', 'Arnold', 'Subasinghe', '', 'Arnold', 0, NULL, '0000-00-00 00:00:00', NULL, NULL, NULL, '', '', '', '', '0000-00-00', '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, '0000-00-00', '', Null, Null, Null, Null, Null, Null, Null, Null, Null, Null)"));		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (2, '002', 'Kalum', 'Kumara', '', 'Kal', 0, NULL, '0000-00-00 00:00:00', NULL, NULL, NULL, '', '', '', '', '0000-00-00', '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, '0000-00-00', '', Null, Null, Null, Null, Null, Null, Null, Null, Null, Null)"));		// For employee1		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (1, 1, 1, '".date('Y')."-02-01', 'Test provider', 'Tester', 'Just testing', '150', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-02',  '123552-55821-ff25', 1)"), mysql_error());	    $this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (2, 3, 1, '".date('Y')."-02-10', 'Test provider', 'Tester', 'Just testing', '100', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-11',  '123552-55821-ff25', 1)"), mysql_error());		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (3, 1, 1, '".date('Y')."-02-20', 'Test provider', 'Tester', 'Just testing', '150', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-21',  '123552-55821-ff25', 1)"), mysql_error());		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` (`id`, `hsp_id`, `employee_id`, `date_incurred`," .	    							  "`provider_name`, `person_incurring_expense`, `expense_description`, `expense_amount`, `payment_made_to`," .	    							  "`third_party_account_number`, `mail_address`, `comments`, `date_paid`, `check_number`,	`status`) " .	    							  "VALUES (4, 3, 1, '".date('Y')."-02-20', 'Test provider', 'Tester', 'Just testing', '100', 'TestX', '12345GD', " .	    							  "'1231, Test Grove, Test City', 'Test', '".date('Y')."-02-21',  '123552-55821-ff25', 1)"), mysql_error());		$this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(1, 1, 1, '".date('Y')."', 1, 1500, 50, 50, 0, 22)"), mysql_error());		$this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(2, 1, 3, '".date('Y')."', 1, 2500, 75, 75, 0, 0)"), mysql_error());		$this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '".(date('Y')-1)."-12-31' WHERE `key` = 'hsp_Used_last_updated'"));		$this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '4' WHERE `key` = 'hsp_current_plan'"));		Hsp::updateUsed(date('Y')); // total_used is calculated by function and should be equal to expense sum of employee1 (150+100+127) plus existed value (22)		$result = mysql_query("SELECT `total_used` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");		$resultArray = mysql_fetch_array($result);		$this->assertEquals(322, $resultArray[0]);		$result = mysql_query("SELECT `total_used` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 2");		$resultArray = mysql_fetch_array($result);		$this->assertEquals(200, $resultArray[0]); // should be 163 (122+41)    }    public function testUpdateStatus() {		$this->assertTrue(mysql_query("TRUNCATE TABLE `hs_hr_hsp_summary`"), mysql_error());		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (1, '001', 'Arnold', 'Subasinghe', '', 'Arnold', 0, NULL, '0000-00-00 00:00:00', NULL, NULL, NULL, '', '', '', '', '0000-00-00', '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, '0000-00-00', '')"));		$this->assertNotNull(mysql_query("INSERT INTO `hs_hr_employee` VALUES (2, '002', 'Kalum', 'Kumara', '', 'Kal', 0, NULL, '0000-00-00 00:00:00', NULL, NULL, NULL, '', '', '', '', '0000-00-00', '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, '0000-00-00', '')"));		// For employee1		$this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(1, 1, 1, '".date('Y')."', 1, 1500, 50, 50, 0, 22)"), mysql_error());		$this->assertTrue(mysql_query("INSERT INTO hs_hr_hsp_summary VALUES(2, 2, 1, '".date('Y')."', 1, 2500, 75, 75, 0, 0)"), mysql_error());		$this->assertTrue(mysql_query("UPDATE `hs_hr_config` SET `value` = '".(date('Y')-1)."-12-31' WHERE `key` = 'hsp_Used_last_updated'"));		Hsp::updateStatus(1, 0);		$result = mysql_query("SELECT `hsp_plan_status` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");		$resultArray = mysql_fetch_array($result);		$this->assertEquals($resultArray[0], 0); // should be 0 (Halted)		Hsp::updateStatus(1, 1);		$result = mysql_query("SELECT `hsp_plan_status` FROM `hs_hr_hsp_summary` WHERE `summary_id` = 1");		$resultArray = mysql_fetch_array($result);		$this->assertEquals($resultArray[0], 1); // should be 1 (Active)    }}// Call HspTest::main() if this source file is executed directly.if (PHPUnit_MAIN_METHOD == 'HspTest::main') {    HspTest::main();}?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -