コード例 #1
0
 /**
  * Checks from the HTML of a page if authentication is requested by a grabbed page.
  *
  * @param string $html
  *
  * @return bool
  */
 public function isLoginRequired($html)
 {
     $useInternalErrors = libxml_use_internal_errors(true);
     // need to check for the login dom element ($options['not_logged_in_xpath']) in the HTML
     $doc = new \DOMDocument();
     $doc->loadHTML($html);
     $xpath = new \DOMXPath($doc);
     $result = $xpath->evaluate($this->siteConfig->getNotLoggedInXpath())->length > 0;
     libxml_use_internal_errors($useInternalErrors);
     return $result;
 }
 function it_ignores_requests_to_sites_without_config(BeforeEvent $beforeEvent, CompleteEvent $completeEvent, SiteConfig $siteConfig)
 {
     $siteConfig->requiresLogin()->willReturn(false);
     $this->loginIfRequired($beforeEvent)->shouldReturn(null);
     $this->loginIfRequested($completeEvent)->shouldReturn(null);
 }