fix a test that failed when using a base URL without protocol
This commit is contained in:
parent
f647c48477
commit
aea9c9ddbb
2 changed files with 18 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue