2015-09-01 21:45:06 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* HttpUtils' tests
|
|
|
|
*/
|
|
|
|
|
|
|
|
require_once 'application/HttpUtils.php';
|
|
|
|
|
|
|
|
/**
|
2016-01-04 10:45:54 +01:00
|
|
|
* Unitary tests for get_http_response()
|
2015-09-01 21:45:06 +02:00
|
|
|
*/
|
|
|
|
class GetHttpUrlTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Get an invalid local URL
|
|
|
|
*/
|
|
|
|
public function testGetInvalidLocalUrl()
|
|
|
|
{
|
2016-01-04 10:45:54 +01:00
|
|
|
// Local
|
|
|
|
list($headers, $content) = get_http_response('/non/existent', 1);
|
|
|
|
$this->assertEquals('Invalid HTTP Url', $headers[0]);
|
|
|
|
$this->assertFalse($content);
|
|
|
|
|
|
|
|
// Non HTTP
|
|
|
|
list($headers, $content) = get_http_response('ftp://save.tld/mysave', 1);
|
|
|
|
$this->assertEquals('Invalid HTTP Url', $headers[0]);
|
|
|
|
$this->assertFalse($content);
|
2015-09-01 21:45:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get an invalid remote URL
|
|
|
|
*/
|
|
|
|
public function testGetInvalidRemoteUrl()
|
|
|
|
{
|
2016-01-04 10:45:54 +01:00
|
|
|
list($headers, $content) = @get_http_response('http://non.existent', 1);
|
|
|
|
$this->assertFalse($headers);
|
|
|
|
$this->assertFalse($content);
|
2015-09-01 21:45:06 +02:00
|
|
|
}
|
|
|
|
}
|