From 143980b6dab8ad87c44518e5b7befb614fb83b85 Mon Sep 17 00:00:00 2001 From: wei <> Date: Fri, 14 Jul 2006 06:56:16 +0000 Subject: Add time-tracker sample and docs. (Incomplete) --- .../tests/unit/CreateNewProjectTestCase.php | 90 ++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 demos/time-tracker/tests/unit/CreateNewProjectTestCase.php (limited to 'demos/time-tracker/tests/unit/CreateNewProjectTestCase.php') diff --git a/demos/time-tracker/tests/unit/CreateNewProjectTestCase.php b/demos/time-tracker/tests/unit/CreateNewProjectTestCase.php new file mode 100644 index 00000000..0aa67405 --- /dev/null +++ b/demos/time-tracker/tests/unit/CreateNewProjectTestCase.php @@ -0,0 +1,90 @@ +createNewTestProject(); + + if(($conn = $this->connection) instanceof MockTSqlMapper) + { + $this->setupMockConnectionFor($project); + $conn->expectMinimumCallCount('queryForObject', 3); + $conn->expectAtLeastOnce('insert'); + } + + $this->assertProjectCreated($project); + } + + function testProjectExistsException() + { + $project = $this->createNewTestProject(); + + if(($conn = $this->connection) instanceof MockTSqlMapper) + { + //make the project exist + $conn->setReturnValue('queryForObject', + $project, array('GetProjectByName', 'Project 1')); + $this->setupMockConnectionFor($project); + } + + try + { + $this->assertProjectCreated($project); + $this->fail(); + } + catch(TimeTrackerException $e) + { + $this->pass(); + } + } + function testProjectCustomerNotExistsException() + { + $project = $this->createNewTestProject(); + + if(($conn = $this->connection) instanceof MockTSqlMapper) + { + //customer does not exist + $conn->setReturnValue('queryForObject', + null, array('GetUserByName', 'Customer A')); + $this->setupMockConnectionFor($project); + } + + try + { + $this->assertProjectCreated($project); + $this->fail(); + } + catch(TimeTrackerException $e) + { + $this->pass(); + } + } + + function testProjectManagerNotExistsException() + { + $project = $this->createNewTestProject(); + + if(($conn = $this->connection) instanceof MockTSqlMapper) + { + //manager does not exist + $conn->setReturnValue('queryForObject', + null, array('GetUserByName', 'Manager A')); + $this->setupMockConnectionFor($project); + } + + try + { + $this->assertProjectCreated($project); + $this->fail(); + } + catch(TimeTrackerException $e) + { + $this->pass(); + } + } +} + +?> \ No newline at end of file -- cgit v1.2.3