/** * @covers \CentralApps\Authentication\Processor::attemptToLogin * @covers \CentralApps\Authentication\Processor::authenticateFromUserId */ public function testLoggingIn() { $user = new \stdClass(); $user->userId = 1; $user_gateway = $this->getMock('\\CentralApps\\Authentication\\UserGateway'); $session_provider = $this->getMock('\\CentralApps\\Authentication\\Providers\\ProviderInterface'); $session_provider->expects($this->once())->method('hasAttemptedToLoginWithProvider')->will($this->returnValue(false)); $session_provider_2 = $this->getMock('\\CentralApps\\Authentication\\Providers\\ProviderInterface'); $session_provider_2->expects($this->once())->method('hasAttemptedToLoginWithProvider')->will($this->returnValue(true)); $session_provider_2->expects($this->once())->method('processLoginAttempt')->will($this->returnValue($user)); $this->_container->insert($session_provider, 10); $this->_container->insert($session_provider_2, 0); $settings_provider = $this->getMock('\\CentralApps\\Authentication\\SettingsProviderInterface'); $settings_provider->expects($this->once())->method('getUserGateway')->will($this->returnValue($user_gateway)); $processor = new Processor($settings_provider, $this->_container); $processor->attemptToLogin(); $this->assertTrue($processor->hasAttemptedToLogin(), "It doesn't look like we tried to login the user"); $this->assertEquals($user, $processor->getUser()); }