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

📄 projectreporttest.php

📁 国外的人才求职招聘最新版
💻 PHP
📖 第 1 页 / 共 3 页
字号:
<?php// Call ProjectReportTest::main() if this source file is executed directly.if (!defined("PHPUnit_MAIN_METHOD")) {    define("PHPUnit_MAIN_METHOD", "ProjectReportTest::main");}require_once "PHPUnit/Framework/TestCase.php";require_once "PHPUnit/Framework/TestSuite.php";require_once "testConf.php";require_once ROOT_PATH.'/lib/dao/DMLFunctions.php';require_once ROOT_PATH.'/lib/dao/SQLQBuilder.php';require_once ROOT_PATH.'/lib/confs/sysConf.php';require_once ROOT_PATH.'/lib/models/eimadmin/ProjectActivity.php';require_once ROOT_PATH.'/lib/models/time/Timesheet.php';require_once ROOT_PATH.'/lib/models/time/ProjectActivityTime.php';require_once ROOT_PATH.'/lib/models/time/EmployeeActivityTime.php';require_once ROOT_PATH.'/lib/models/time/ProjectReport.php';/** * Test class for ProjectReport. * Generated by PHPUnit_Util_Skeleton on 2007-07-16 at 19:32:46. */class ProjectReportTest extends PHPUnit_Framework_TestCase {	private $projects;	private $customerId;	private $customerName;	private $activities;	private $connection;    /**     * 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("ProjectReportTest");        $result = PHPUnit_TextUI_TestRunner::run($suite);    }    /**     * Sets up the fixture, for example, open 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);		$this->_truncateTables();		// Insert a customer and projects for use in the test		$this->customerId = 1;		$this->customerName = "OrangeHRM";		$this->projects = array( 1 => "Project A", 2 => "Project B");		$this->_addCustomer();		$this->_addProjects();		// Insert activities		$this->_addActivity(1, "Programming");		$this->_addActivity(1, "QA");		//$this->_addActivity(1, "Misc");		$this->_addActivity(1, "Support");		$this->_addActivity(2, "Programming");		$this->_addActivity(2, "QA");		$this->_addActivity(2, "Support");		//$this->_addActivity(2, "Misc");		// Insert deleted activities		$this->_addActivity(1, "Deleted Activity", true);		$this->_addActivity(2, "Deleted Activity", true);		// Add employees		$this->_addEmployee(1, "001",  "Rajasinghe", "John");		$this->_addEmployee(2, "002",  "Wickramasinghe", "Ravi");		$this->_addEmployee(3, "003",  "Kumarasinghe", "Rasanga");    }    /**     * Tears down the fixture, removed database entries created during test.     *     * @access protected     */    protected function tearDown() {		$this->_truncateTables();    }    /**     * test method getProjectActivityTime()     */    public function testGetProjectActivityTimeWithNoEvents() {    	$report = new ProjectReport();    	// With no events - no days specified    	$projectId = 1;    	$results = $report->getProjectActivityTime($projectId);    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(0, 0, 0));    	$this->assertTrue($res);    	//  With no events - with start date specified    	$results = $report->getProjectActivityTime($projectId, "2001-01-01");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(0, 0, 0));		$this->assertTrue($res);    	//  With no events - with start date and end date specified    	$results = $report->getProjectActivityTime($projectId, "2001-01-01", "2007-01-01");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(0, 0, 0));		$this->assertTrue($res);    }    /**     * test method getProjectActivityTime()     */    public function testGetProjectActivityTimeWithOneEvent() {    	$report = new ProjectReport();		// Add one event.    	$projectId = 1;		$this->_addEvent(1, 1, "Programming", "2007-07-12 10:00", 60);    	$results = $report->getProjectActivityTime($projectId, "2007-07-12", "2007-07-12");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(60, 0, 0));    	$this->assertTrue($res);    	$results = $report->getProjectActivityTime($projectId, "2007-07-1", "2007-07-13");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(60, 0, 0));    	$this->assertTrue($res);    }    /**     * test method getProjectActivityTime()     */    public function testGetProjectActivityTimeWithSpanningEvent() {    	$report = new ProjectReport();		// Add one event.    	$projectId = 1;		$this->_addEvent(1, 1, "QA", "2007-07-12 23:00", 95);    	$results = $report->getProjectActivityTime($projectId, "2007-07-12", "2007-07-12");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(0, 60, 0));    	$this->assertTrue($res);    	$results = $report->getProjectActivityTime($projectId, "2007-07-12", "2007-07-13");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(0, 95, 0));    	$this->assertTrue($res);    	$results = $report->getProjectActivityTime($projectId, "2007-07-1", "2007-07-13");    	$res = $this->_verifyActivityTime($results, $projectId, array("Programming", "QA", "Support"), array(0, 95, 0));    	$this->assertTrue($res);    }    /**     * test method getProjectActivityTime()     */    public function testGetProjectActivityTimeWithDeletedActivity() {    	$report = new ProjectReport();		// Add one event.    	$projectId = 1;		$this->_addEvent(1, 1, "Deleted Activity", "2007-07-12 13:20", 15);    	$results = $report->getProjectActivityTime($projectId, "2007-07-12", "2007-07-12");    	$res = $this->_verifyActivityTime($results, $projectId,               array("Programming", "QA", "Support", "Deleted Activity"), array(0, 0, 0, 15));    	$this->assertTrue($res);    	$results = $report->getProjectActivityTime($projectId, "2007-07-1", "2007-07-13");    	$res = $this->_verifyActivityTime($results, $projectId,               array("Programming", "QA", "Support", "Deleted Activity"), array(0, 0, 0, 15));    	$this->assertTrue($res);    }    /**     * test method getProjectActivityTime()     */    public function testGetProjectActivityTimeWithMultipleActivities() {    	$report = new ProjectReport();    	// QA - Employee 1		$this->_addEvent(1, 1, "QA", "2007-07-05  09:25", 70);		$this->_addEvent(1, 1, "QA", "2007-07-07  08:12", 33); // 33 min		$this->_addEvent(1, 1, "QA", "2007-07-10  09:25", 8 * 60 + 30); // 510 min    	// QA - Employee 2		$this->_addEvent(1, 2, "QA", "2007-07-05  09:25", 70); // 70 min		$this->_addEvent(1, 2, "QA", "2007-07-12  11:25", 4 * 60 + 10); // 250 min		$this->_addEvent(1, 2, "QA", "2007-07-11  06:25", 4 * 60 + 10); // 250 min		// QA Events for different project		$this->_addEvent(2, 1, "QA", "2007-07-05  07:25", 8 * 60 + 10); // 490 min		$this->_addEvent(2, 2, "QA", "2007-07-05  09:25", 5 * 60); // 300 min		// Programming - Employee 1		$this->_addEvent(1, 1, "Programming", "2007-07-05  09:25", 80);		$this->_addEvent(1, 1, "Programming", "2007-07-07  08:12", 70);		$this->_addEvent(1, 1, "Programming", "2007-07-10  09:25", 210);		// Programming - Employee 2		$this->_addEvent(1, 2, "Programming", "2007-07-05  09:25", 230);		$this->_addEvent(1, 2, "Programming", "2007-07-12  11:25", 450);		$this->_addEvent(1, 2, "Programming", "2007-07-11  06:25", 900);		// Programming for different project		$this->_addEvent(2, 1, "Programming", "2007-07-05  05:25", 800);		$this->_addEvent(2, 2, "Programming", "2007-07-12  15:25", 450);		// Event spanning more than one day		$this->_addEvent(1, 1, "Programming", "2007-07-19 18:00", 600);		$this->_addEvent(1, 2, "Programming", "2007-07-18 21:25", 500);		// Deleted activity for project 2		$this->_addEvent(2, 1, "Deleted Activity", "2007-07-10  09:25", 400);		$this->_addEvent(2, 2, "Deleted Activity", "2007-07-11  09:25", 300);		// Check project 2 time    	$results = $report->getProjectActivityTime(2, "2007-07-05", "2007-07-25");    	$res = $this->_verifyActivityTime($results, 2, array("Programming", "QA", "Support", "Deleted Activity"),                                          array(1250, 790, 0, 700));    	$this->assertTrue($res);		// Check project 1 time    	$results = $report->getProjectActivityTime(1, "2007-07-05", "2007-07-25");    	$res = $this->_verifyActivityTime($results, 1, array("Programming", "QA", "Support"), array(3040, 1183, 0));    	$this->assertTrue($res);    	// Project 1 time for day with spanning events.    	$results = $report->getProjectActivityTime(1, "2007-07-19", "2007-07-19");    	$res = $this->_verifyActivityTime($results, 1, array("Programming", "QA", "Support"), array(360+345, 0, 0));    	$this->assertTrue($res);		// Project 1 time from 07-10    	$results = $report->getProjectActivityTime(1, "2007-07-10", "2007-07-30");    	$res = $this->_verifyActivityTime($results, 1, array("Programming", "QA", "Support"), array(2660, 1010, 0));    	$this->assertTrue($res);    }    /**     * test getEmployeeActivityTime() method     */    public function testGetEmployeeActivityTimeWithNoEvents() {    	$report = new ProjectReport();    	// With no events - no days specified    	$projectId = 1;    	$activityId = 1;    	$results = $report->getEmployeeActivityTime($projectId, $activityId);    	$this->assertTrue(is_array($results));    	$this->assertEquals(0, count($results));    	//  With no events - start date specified    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2001-01-01");    	$this->assertTrue(is_array($results));    	$this->assertEquals(0, count($results));    	//  With no events - start date and end date specified    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2001-01-01", "2007-01-01");    	$this->assertTrue(is_array($results));    	$this->assertEquals(0, count($results));    }	/**	 * test getEmployeeActivityTime() method	 */    public function testGetEmployeeActivityTimeWithOneEvent() {    	$report = new ProjectReport();		// Add one event.    	$projectId = 1;    	$employeeId = 1;    	$activityName = "Programming";		$activity = $this->activities[$projectId][$activityName];    	$activityId = $activity->getId();		$this->_addEvent($projectId, $employeeId, $activityName, "2007-07-12 10:00", 60);    	$results = $report->getEmployeeActivityTime($projectId, $activityId);    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(60));    	$this->assertTrue($res);    	//  With no events - start date specified    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2001-01-01");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(60));		$this->assertTrue($res);    	//  With no events - start date and end date specified    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2001-01-01", "2007-07-13");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(60));		$this->assertTrue($res);    }	/**	 * test getEmployeeActivityTime() method	 */	public function testGetEmployeeActivityTimeWithSpanningEvent() {    	$report = new ProjectReport();		// Add one event.    	$projectId = 1;    	$employeeId = 1;    	$activityName = "QA";		$activity = $this->activities[$projectId][$activityName];    	$activityId = $activity->getId();		$this->_addEvent($projectId, $employeeId, $activityName, "2007-07-12 23:00", 95);    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-12", "2007-07-12");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(60));    	$this->assertTrue($res);    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-12", "2007-07-13");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(95));    	$this->assertTrue($res);    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-1", "2007-07-15");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(95));    	$this->assertTrue($res);		// With only start date    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-1");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(95));    	$this->assertTrue($res);		// Without range    	$results = $report->getEmployeeActivityTime($projectId, $activityId);    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(95));    	$this->assertTrue($res);	}	/**	 * test getEmployeeActivityTime() method	 */    public function testGetEmployeeActivityTimeWithDeletedActivity() {    	$report = new ProjectReport();		// Add one event.    	$projectId = 1;    	$employeeId = 1;    	$activityName = "Deleted Activity";		$activity = $this->activities[$projectId][$activityName];    	$activityId = $activity->getId();		$this->_addEvent($projectId, $employeeId, $activityName, "2007-07-12 13:20", 15);    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-12", "2007-07-12");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(15));    	$this->assertTrue($res);    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-01", "2007-07-13");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(15));    	$this->assertTrue($res);		// With only start date    	$results = $report->getEmployeeActivityTime($projectId, $activityId, "2007-07-01");    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(15));    	$this->assertTrue($res);		// Without date range    	$results = $report->getEmployeeActivityTime($projectId, $activityId);    	$res = $this->_verifyEmployeeTime($results, $projectId, $activityId, array(1), array(15));    	$this->assertTrue($res);    }	/**	 * test getEmployeeActivityTime() method	 */    public function testGetEmployeeActivityTimeWithMultipleActivities() {    	$report = new ProjectReport();    	// QA - Employee 1		$this->_addEvent(1, 1, "QA", "2007-07-05  09:25", 70);		$this->_addEvent(1, 1, "QA", "2007-07-07  08:12", 33); // 33 min		$this->_addEvent(1, 1, "QA", "2007-07-10  09:25", 8 * 60 + 30); // 510 min    	// QA - Employee 2		$this->_addEvent(1, 2, "QA", "2007-07-05  09:25", 70); // 70 min		$this->_addEvent(1, 2, "QA", "2007-07-12  11:25", 4 * 60 + 10); // 250 min		$this->_addEvent(1, 2, "QA", "2007-07-11  06:25", 4 * 60 + 10); // 250 min		// QA Events for different project		$this->_addEvent(2, 1, "QA", "2007-07-05  07:25", 8 * 60 + 10); // 490 min		$this->_addEvent(2, 2, "QA", "2007-07-05  09:25", 5 * 60); // 300 min

⌨️ 快捷键说明

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