public function testRedirectsToActiveIfUserNeedsActivation() { $this->user->SetStatus(AccountStatus::AWAITING_ACTIVATION); $this->postRegistration->HandleSelfRegistration($this->user, $this->page, $this->context); $this->assertFalse($this->fakeAuth->_LoginCalled); $this->assertTrue($this->activation->_NotifyCalled); $this->assertEquals($this->user, $this->activation->_NotifiedUser); $this->assertEquals(Pages::ACTIVATION, $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()); }