public function testUserAlreadyLinkedTo() { $identity = new \Application\Users\Row(); $identity->id = 2; $userProfile = new \Hybrid_User_Profile(); $userProfile->identifier = 112233; $this->authAdapterMock->method('getUserProfile')->willReturn($userProfile); $this->hybridAuthMock->method('authenticate')->willReturn(new \Hybrid_Provider_Adapter()); $this->assertInstanceOf('\\Hybrid_Auth', $this->hybridAuthMock); $provider = new AuthProvider('Facebook'); $provider->setResponse($this->getApp()); $provider->setIdentity($identity); $provider->setHybridauth($this->hybridAuthMock); $provider->setAuthAdapter($this->authAdapterMock); try { $provider->authProcess(); } catch (RedirectException $red) { } catch (\Exception $e) { } $message = Messages::pop(); $this->assertEquals("You have already linked to Facebook", $message->text); }
<?php /** * Auth controllers * * @author yuklia * @created 05.05.15 17:30 */ namespace Application; use Bluz\Proxy\Messages; use Application\Auth\AuthProvider; return function ($provider = '') { /** * @var Bootstrap $this */ try { $auth = new AuthProvider($provider); $auth->setResponse($this); $auth->setIdentity($this->user()); $auth->authProcess(); } catch (Exception $e) { Messages::addError($e->getMessage()); } return function () { return false; }; };