From 2570226fbac3e26b1e94896b50d1db4bc1aa3308 Mon Sep 17 00:00:00 2001 From: wei <> Date: Sun, 17 Dec 2006 22:20:50 +0000 Subject: Add TDataSourceConfig, TSqlMapConfig, TActiveRecordConfig --- .../time-tracker/tests/unit/ProjectDaoTestCase.php | 66 +++++++++++----------- 1 file changed, 33 insertions(+), 33 deletions(-) (limited to 'demos/time-tracker/tests/unit/ProjectDaoTestCase.php') diff --git a/demos/time-tracker/tests/unit/ProjectDaoTestCase.php b/demos/time-tracker/tests/unit/ProjectDaoTestCase.php index 3ee9d8b2..3ccb28e2 100644 --- a/demos/time-tracker/tests/unit/ProjectDaoTestCase.php +++ b/demos/time-tracker/tests/unit/ProjectDaoTestCase.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__).'/BaseTestCase.php'); class ProjectDaoTestCase extends BaseTestCase { protected $projectDao; - + function setup() { parent::setup(); @@ -13,8 +13,8 @@ class ProjectDaoTestCase extends BaseTestCase $this->projectDao = $app->getModule('daos')->getDao('ProjectDao'); $this->flushDatabase(); } - - + + function createNewProject() { $project = new ProjectRecord; @@ -25,7 +25,7 @@ class ProjectDaoTestCase extends BaseTestCase $project->EstimateDuration = 100.5; $project->ManagerUserName = 'manager'; $project->Name = 'Project 1'; - + return $project; } @@ -39,7 +39,7 @@ class ProjectDaoTestCase extends BaseTestCase $project->EstimateDuration = 30.5; $project->ManagerUserName = 'manager'; $project->Name = 'Project 2'; - + return $project; } @@ -53,78 +53,78 @@ class ProjectDaoTestCase extends BaseTestCase $project->EstimateDuration = 5.0; $project->ManagerUserName = 'admin'; $project->Name = 'Project 3'; - + return $project; } - + function add3Projects() { $project1 = $this->createNewProject(); $project2 = $this->createNewProject2(); $project3 = $this->createNewProject3(); - + $this->projectDao->addNewProject($project1); $this->projectDao->addNewProject($project2); $this->projectDao->addNewProject($project3); return array($project1,$project2,$project3); } - + function testCreateNewProject() { $newProject = $this->createNewProject(); $this->projectDao->addNewProject($newProject); - + $check = $this->projectDao->getProjectByID(1); - $this->assertEqual($newProject, $check); + $this->assertEqual($newProject, $check); } - + function testDeleteProject() { $newProject = $this->createNewProject(); $this->projectDao->addNewProject($newProject); - + $check = $this->projectDao->getProjectByID(1); $this->assertEqual($newProject, $check); - + $this->projectDao->deleteProject(1); $verify = $this->projectDao->getProjectByID(1); $this->assertNull($verify); } - + function testAddUserToProject() { $project = $this->createNewProject(); $this->projectDao->addNewProject($project); - + $this->projectDao->addUserToProject($project->ID, 'admin'); $this->projectDao->addUserToProject($project->ID, 'manager'); - + $members = $this->projectDao->getProjectMembers($project->ID); - + $this->assertEqual(count($members), 2); $this->assertEqual($members[0], 'admin'); $this->assertEqual($members[1], 'manager'); } - + function testAddNullUserToProject() { $project = $this->createNewProject(); $this->projectDao->addNewProject($project); try - { + { $this->projectDao->addUserToProject($project->ID, 'asd'); $this->pass(); } catch(TSqlMapQueryExecutionException $e) { - $this->fail(); + $this->fail(); } } function testGetAllProjects() { $added = $this->add3Projects(); - + $projects = $this->projectDao->getAllProjects(); $this->assertEqual(count($projects),3); @@ -136,7 +136,7 @@ class ProjectDaoTestCase extends BaseTestCase function testGetProjectsByManagerName() { $added = $this->add3Projects(); - + $projects = $this->projectDao->getProjectsByManagerName('manager'); $this->assertEqual(count($projects),2); @@ -147,12 +147,12 @@ class ProjectDaoTestCase extends BaseTestCase function testGetProjectsByUserName() { $added = $this->add3Projects(); - + $username = 'consultant'; - + $this->projectDao->addUserToProject(1, $username); $this->projectDao->addUserToProject(3, $username); - + $projects = $this->projectDao->getProjectsByUserName($username); $this->assertEqual(count($projects),2); @@ -166,16 +166,16 @@ class ProjectDaoTestCase extends BaseTestCase $this->projectDao->addUserToProject(1, 'admin'); $this->projectDao->addUserToProject(1, 'manager'); $this->projectDao->addUserToProject(1, 'consultant'); - + $members = $this->projectDao->getProjectMembers(1); $this->assertEqual(count($members), 3); $this->assertEqual($members[0], 'admin'); $this->assertEqual($members[2], 'manager'); $this->assertEqual($members[1], 'consultant'); - + $this->projectDao->removeUserFromProject(1,'admin'); - + $list = $this->projectDao->getProjectMembers(1); $this->assertEqual(count($list), 2); @@ -187,13 +187,13 @@ class ProjectDaoTestCase extends BaseTestCase { $project = $this->createNewProject(); $this->projectDao->addNewProject($project); - + $project->Description = "Project Testing 123"; - + $this->projectDao->updateProject($project); - + $check = $this->projectDao->getProjectByID(1); - $this->assertEqual($check, $project); + $this->assertEqual($check, $project); } } -- cgit v1.2.3