public function testAddsUser() { $fname = 'f'; $lname = 'l'; $username = '******'; $email = '*****@*****.**'; $timezone = 'America/Chicago'; $lang = 'foo'; $password = '******'; $attributeId = 1; $attributeValue = 'value'; $attributeFormElements = array(new AttributeFormElement($attributeId, $attributeValue)); $userId = 1090; $groupId = 111; $user = new FakeUser($userId); $group = new Group($groupId, 'name'); $group->AddUser($userId); $this->fakeConfig->SetKey(ConfigKeys::LANGUAGE, $lang); $this->page->expects($this->once())->method('GetFirstName')->will($this->returnValue($fname)); $this->page->expects($this->once())->method('GetLastName')->will($this->returnValue($lname)); $this->page->expects($this->once())->method('GetUserName')->will($this->returnValue($username)); $this->page->expects($this->once())->method('GetEmail')->will($this->returnValue($email)); $this->page->expects($this->once())->method('GetTimezone')->will($this->returnValue($timezone)); $this->page->expects($this->once())->method('GetPassword')->will($this->returnValue($password)); $this->page->expects($this->once())->method('GetAttributes')->will($this->returnValue($attributeFormElements)); $this->page->expects($this->once())->method('GetUserGroup')->will($this->returnValue($groupId)); $this->manageUsersService->expects($this->once())->method('AddUser')->with($this->equalTo($username), $this->equalTo($email), $this->equalTo($fname), $this->equalTo($lname), $this->equalTo($password), $this->equalTo($timezone), $this->equalTo($lang), $this->equalTo(Pages::DEFAULT_HOMEPAGE_ID), $this->equalTo(array()), $this->equalTo(array(new AttributeValue($attributeId, $attributeValue))))->will($this->returnValue($user)); $this->groupRepository->expects($this->once())->method('LoadById')->with($this->equalTo($groupId))->will($this->returnValue($group)); $this->groupRepository->expects($this->once())->method('Update')->with($this->equalTo($group)); $this->presenter->AddUser(); }
public function testDeletesUser() { $userId = 99; $session = new FakeWebServiceUserSession(123); $this->manageUserServiceFactory->expects($this->once())->method('CreateAdmin')->will($this->returnValue($this->manageUsersService)); $this->manageUsersService->expects($this->once())->method('DeleteUser')->with($this->equalTo($userId)); $result = $this->controller->Delete($userId, $session); $this->assertTrue($result->WasSuccessful()); }