public function isLoggedIn(ClientInterface $guzzle) { if (($cookieJar = $guzzle->getDefaultOption('cookies')) instanceof CookieJar) { /** @var \GuzzleHttp\Cookie\SetCookie $cookie */ foreach ($cookieJar as $cookie) { // check required cookies if ($cookie->getDomain() == $this->siteConfig->getHost()) { return true; } } } return false; }
function let(SiteConfigBuilder $siteConfigBuilder, SiteConfig $siteConfig, Factory $authenticatorFactory, ClientInterface $guzzle, Emitter $emitter, BeforeEvent $beforeEvent, CompleteEvent $completeEvent, RequestInterface $request, ResponseInterface $response, Factory $authenticatorFactory) { $siteConfig->getHost()->willReturn('example.com'); $siteConfigBuilder->buildForHost('example.com')->willReturn($siteConfig); $guzzle->getEmitter()->willReturn($emitter); $request->getHost()->willReturn('example.com'); $beforeEvent->getRequest()->willReturn($request); $beforeEvent->getClient()->willReturn($guzzle); $response->getBody()->willReturn('<html></html>'); $completeEvent->getResponse()->willReturn($response); $completeEvent->getRequest()->willReturn($request); $completeEvent->getClient()->willReturn($guzzle); $this->beConstructedWith($siteConfigBuilder, $authenticatorFactory); }