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());
     }
 }
Esempio n. 2
0
 public function testToStringWithConvertIdnToUtf8Enabled()
 {
     $source = 'http://artesan.xn--a-iga.com/';
     $expectedUrl = 'http://artesan.ía.com/';
     $url = new Url($source);
     $url->getConfiguration()->enableConvertIdnToUtf8();
     $this->assertEquals($expectedUrl, (string) $url);
 }
Esempio n. 3
0
 /**
  *
  * @return \webignition\NormalisedUrl\Normaliser
  */
 private function normaliser()
 {
     if (is_null($this->normaliser)) {
         $this->normaliser = new \webignition\NormalisedUrl\Normaliser(parent::parts());
     }
     return $this->normaliser;
 }
 /**
  * Derive the path for a cookie from the request URL
  * 
  * As defined in RFC6265:
  *   2.  If the uri-path is empty or if the first character of the uri-
  *       path is not a %x2F ("/") character, output %x2F ("/") and skip
  *       the remaining steps.
  * 
  *   3.  If the uri-path contains no more than one %x2F ("/") character,
  *       output %x2F ("/") and skip the remaining step.
  * 
  *   4.  Output the characters of the uri-path from the first character up
  *       to, but not including, the right-most %x2F ("/").
  * 
  * @return string
  */
 private function deriveCookiePathFromRequestUrl()
 {
     $path = $this->requestUrl->getPath();
     if ($path->get() == '' || substr((string) $path, 0, 1) != '/') {
         return '/';
     }
     if (substr_count((string) $path, '/') === 1) {
         return '/';
     }
     return substr((string) $path, 0, strrpos((string) $path, '/'));
 }
 /**
  * 
  * @param \webignition\CssValidatorOutput\Message\Message $message
  * @return boolean
  */
 private function hasRefDomainToIgnore(Message $message)
 {
     if (!$message->isError()) {
         return false;
     }
     /* @var $message \webignition\CssValidatorOutput\Message\Error */
     if ($message->getRef() == '') {
         return false;
     }
     $messageRefUrl = new Url($message->getRef());
     foreach ($this->getConfiguration()->getRefDomainsToIgnore() as $refDomainToIgnore) {
         if ($messageRefUrl->hasHost() && $messageRefUrl->getHost()->isEquivalentTo(new \webignition\Url\Host\Host($refDomainToIgnore))) {
             return true;
         }
     }
     return false;
 }
Esempio n. 6
0
 public function testClearWhenFragmentIsNotEmtpy()
 {
     $url = new Url('http://example.com#foo');
     $url->setFragment(null);
     $this->assertEquals('http://example.com', (string) $url);
 }
Esempio n. 7
0
 public function testSetPathOnUrlWithPlusesInQuery()
 {
     $url = new Url('example.html?foo=++');
     $url->setPath('/example.html');
     $this->assertEquals('/example.html?foo=%2B%2B', (string) $url);
 }