Ejemplo n.º 1
0
 public function testUpdateUsedForTwoPlans()
 {
     $this->assertTrue(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->assertTrue(mysql_query("INSERT INTO `hs_hr_employee` ({$this->employeeFields}) VALUES (1, '001', 'Arnold', 'Subasinghe', '', 'Arnold', 0, NULL, NULL, NULL, NULL, NULL, '', '', '', '', NULL, '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, NULL, '')"), mysql_error());
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_employee` ({$this->employeeFields}) VALUES (2, '002', 'Kalum', 'Kumara', '', 'Kal', 0, NULL, NULL, NULL, NULL, NULL, '', '', '', '', NULL, '', NULL, NULL, NULL, NULL, '', '', '', 'AF', '', '', '', '', '', '', NULL, NULL, '')"), mysql_error());
     // For employee1
     $this->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "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->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "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->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "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->assertTrue(mysql_query("INSERT INTO `hs_hr_hsp_payment_request` ({$this->paymentRequestFields}) " . "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)
 }