public function isMatch($cookie, $requestUrl) { $this->requestUrl = new \webignition\Url\Url($requestUrl); $this->setCookie($cookie); if (!$this->getDomainMatcher()->isMatch($this->cookie['domain'], $this->requestUrl->getHost())) { return false; } if (!$this->getPathMatcher()->isMatch($this->cookie['path'], $this->requestUrl->getPath())) { return false; } if ($this->cookie['secure'] === true && $this->requestUrl->getScheme() != 'https') { return false; } return true; }
public function testLocalProxyContentToValidateHasModifiedStylesheetUrls() { $sourceContentToValidate = file_get_contents($this->getFixturesDataPath() . '/WebResourceContent/content-with-stylesheets.html'); $this->wrapper->getConfiguration()->setContentToValidate($sourceContentToValidate); $this->wrapper->validate(); $modifiedContentToValidate = $this->wrapper->getLocalProxyResource()->getConfiguration()->getContentToValidate(); $sourceDomLinkUrls = array(); $sourceDom = new \DOMDocument(); $sourceDom->loadHTML($sourceContentToValidate); foreach ($sourceDom->getElementsByTagName('link') as $linkElement) { $sourceDomLinkUrls[] = $linkElement->getAttribute('href'); } $modifiedDomLinkUrls = array(); $modifiedDom = new \DOMDocument(); $modifiedDom->loadHTML($modifiedContentToValidate); foreach ($modifiedDom->getElementsByTagName('link') as $linkElement) { $modifiedDomLinkUrls[] = $linkElement->getAttribute('href'); } foreach ($sourceDomLinkUrls as $sourceDomLinkUrl) { $this->assertFalse(in_array($sourceDomLinkUrl, $modifiedDomLinkUrls)); } foreach ($modifiedDomLinkUrls as $modifiedDomLinkUrl) { $this->assertFalse(in_array($modifiedDomLinkUrl, $sourceDomLinkUrls)); $url = new Url($modifiedDomLinkUrl); $this->assertEquals('file', $url->getScheme()); } }