public function testRedirectsToHomepageIfUserIsActive() { $this->user->SetStatus(AccountStatus::ACTIVE); $this->user->ChangeDefaultHomePage(2); $this->postRegistration->HandleSelfRegistration($this->user, $this->page, $this->context); $this->assertTrue($this->fakeAuth->_LoginCalled); $this->assertEquals($this->user->EmailAddress(), $this->fakeAuth->_LastLogin); $this->assertFalse($this->fakeAuth->_LastLoginContext->GetData()->Persist); $this->assertEquals(Pages::UrlFromId(2), $this->page->_RedirectDestination); }
public function testWhenActivationCodeIsValid() { $userId = 11; $homepage = Pages::CALENDAR; $user = new FakeUser($userId); $user->ChangeDefaultHomePage($homepage); $user->SetStatus(AccountStatus::AWAITING_ACTIVATION); $activationCode = uniqid(); $this->activationRepo->expects($this->once())->method('FindUserIdByCode')->with($this->equalTo($activationCode))->will($this->returnValue($userId)); $this->activationRepo->expects($this->once())->method('DeleteActivation')->with($this->equalTo($activationCode)); $this->userRepo->expects($this->once())->method('LoadById')->with($this->equalTo($userId))->will($this->returnValue($user)); $this->userRepo->expects($this->once())->method('Update')->with($this->equalTo($user)); $result = $this->activation->Activate($activationCode); $this->assertTrue($result->Activated()); $this->assertEquals($user, $result->User()); $this->assertEquals(AccountStatus::ACTIVE, $user->StatusId()); }
function setup() { parent::setup(); $this->username = '******'; $this->password = '******'; $this->id = 191; $this->fname = 'Test'; $this->lname = 'Name'; $this->email = '*****@*****.**'; $this->isAdmin = true; $this->timezone = "US/Central"; $this->lastLogin = time(); $this->homepageId = 2; $this->languageCode = 'en_us'; $this->publicId = 'public_id'; $this->scheduleId = 111; $this->groups = array(new UserGroup(999, '1'), new UserGroup(888, '2')); $this->user = new FakeUser(); $this->user->WithId($this->id); $this->user->ChangeName($this->fname, $this->lname); $this->user->ChangeEmailAddress($this->email); $this->user->ChangeTimezone($this->timezone); $this->user->ChangeDefaultHomePage($this->homepageId); $this->user->SetLanguage($this->languageCode); $this->user->WithPublicId($this->publicId); $this->user->Activate(); $this->user->WithDefaultSchedule($this->scheduleId); $this->user->WithGroups($this->groups); $this->fakePassword = new FakePassword(); $this->fakeMigration = new FakeMigration(); $this->fakeMigration->_Password = $this->fakePassword; $this->authorization = $this->getMock('IRoleService'); $this->userRepository = $this->getMock('IUserRepository'); $this->auth = new Authentication($this->authorization, $this->userRepository); $this->auth->SetMigration($this->fakeMigration); $this->loginContext = new WebLoginContext(new LoginData()); }