|
|
|
@ -20,12 +20,14 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
{
|
|
|
|
|
unset($_SERVER['HTTP_PROXY']);
|
|
|
|
|
unset($_SERVER['http_proxy']);
|
|
|
|
|
unset($_SERVER['no_proxy']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function tearDown()
|
|
|
|
|
{
|
|
|
|
|
unset($_SERVER['HTTP_PROXY']);
|
|
|
|
|
unset($_SERVER['http_proxy']);
|
|
|
|
|
unset($_SERVER['no_proxy']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -73,6 +75,36 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
)), $options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testHttpProxyWithNoProxy()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
|
|
|
|
|
$_SERVER['no_proxy'] = 'foo,example.org';
|
|
|
|
|
|
|
|
|
|
$context = StreamContextFactory::getContext('http://example.org', array('http' => array('method' => 'GET')));
|
|
|
|
|
$options = stream_context_get_options($context);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(array('http' => array(
|
|
|
|
|
'method' => 'GET',
|
|
|
|
|
'max_redirects' => 20,
|
|
|
|
|
'follow_location' => 1,
|
|
|
|
|
)), $options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testHttpProxyWithNoProxyWildcard()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
|
|
|
|
|
$_SERVER['no_proxy'] = '*';
|
|
|
|
|
|
|
|
|
|
$context = StreamContextFactory::getContext('http://example.org', array('http' => array('method' => 'GET')));
|
|
|
|
|
$options = stream_context_get_options($context);
|
|
|
|
|
|
|
|
|
|
$this->assertEquals(array('http' => array(
|
|
|
|
|
'method' => 'GET',
|
|
|
|
|
'max_redirects' => 20,
|
|
|
|
|
'follow_location' => 1,
|
|
|
|
|
)), $options);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testOptionsArePreserved()
|
|
|
|
|
{
|
|
|
|
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
|
|
|
|
|