]> gitweb.fluxo.info Git - semanticscuttle.git/commitdiff
fix a test that failed when using a base URL without protocol
authorChristian Weiske <cweiske@cweiske.de>
Thu, 12 May 2011 17:09:30 +0000 (19:09 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 12 May 2011 17:09:30 +0000 (19:09 +0200)
tests/Api/OpenSearchTest.php
tests/TestBaseApi.php

index 050713b85efdd5feeec9e2af43abbae42417ec73..f438b468ed4493483d6b4bb0adcc8723424c4f44 100644 (file)
@@ -27,7 +27,7 @@ class Api_OpenSearchTest extends TestBaseApi
             1, count($arElements),
             'OpenSearch link in HTML is missing'
         );
-        $searchDescUrl = (string)$arElements[0]['href'];
+        $searchDescUrl = $this->completeUrl((string)$arElements[0]['href']);
         $this->assertNotNull($searchDescUrl, 'Search description URL is empty');
 
         $req = new HTTP_Request2($searchDescUrl);
index 8ed41cd984682dec7d8e6bc93e6d86b38bbbcc07..036ab6bcace817576370fcc1f1fc778ca6256a8b 100644 (file)
@@ -92,6 +92,23 @@ class TestBaseApi extends TestBase
     }
 
 
+    /**
+     * Completes an URL that's missing the protocol.
+     * Useful when re-using URLs extracted from HTML
+     *
+     * @param string $url Potentially partial URL
+     *
+     * @return string Full URL
+     */
+    protected function completeUrl($url)
+    {
+        if (substr($url, 0, 2) == '//') {
+            $url = 'http:' . $url;
+        }
+        return $url;
+    }
+
+
 
     /**
      * Creates a user and a HTTP request object and prepares