summaryrefslogtreecommitdiff
path: root/demos/time-tracker/tests/unit/AddUserToProjectTestCase.php
blob: 36defc570a15c153e151132d45669a87fc0fcc3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

require_once(dirname(__FILE__).'/ProjectDaoTestCase.php');

class AddUserToProjectTestCase extends ProjectDaoTestCase
{		
	function testCanAddNewUserToProject()
	{
		$project = $this->createNewTestProject();
		
		$user = new TimeTrackerUser();
		$user->ID = 3;
		$user->Name = "test user 1";
		
		if(($conn = $this->connection) instanceof MockTSqlMapper)
		{
			$this->setupMockConnectionFor($project);
			$conn->setReturnReference('queryForObject', $user, array('GetUserByName', $user->Name));
			$conn->setReturnValue('queryForList', array(), array('GetProjectMembers', $project));
			
			$param['project'] = $project;
			$param['user'] = $user;
			
			$conn->setReturnValue('insert', true, array('AddNewUserToProject', $param));
			
			$conn->expectAtLeastOnce('insert');
			$conn->expectAtLeastOnce('queryForList'); 
		}
		
		$this->assertTrue($this->dao->createNewProject($project));
		$this->assertTrue($this->dao->addUserToProject($project, $user));
	}
}

?>