public function testAuthenticate() { $authService = $this->prophesize(AuthenticationService::class); $adapter = $this->prophesize(AdapterInterface::class); $result = $this->prophesize(Result::class); $authenticator = new Authenticator($authService->reveal(), $adapter->reveal()); $eventManager = StaticEventManager::getInstance(); // event will be raised $eventManager->attach(Authenticator::class, AuthenticationEvent::EVENT_AUTH, function ($e) use($result) { $this->assertInstanceOf(AuthenticationEvent::class, $e); $e->setResult($result->reveal()); }); $returnedResult = $authenticator->authenticate(); $this->assertSame($result->reveal(), $returnedResult); }
/** * @param AdapterInterface $adapter * @return Result */ public function connect(AdapterInterface $adapter) { return $this->authService->authenticate($adapter); }