mirror of
https://github.com/composer/composer
synced 2025-05-10 17:12:51 +00:00
Add tests, refs #2017
This commit is contained in:
parent
13c7be2d7e
commit
b4c0b18896
2 changed files with 33 additions and 1 deletions
|
@ -73,7 +73,7 @@ final class StreamContextFactory
|
||||||
}
|
}
|
||||||
|
|
||||||
// add request_fulluri and authentication if we still have a proxy to connect to
|
// add request_fulluri and authentication if we still have a proxy to connect to
|
||||||
if (isset($options['http']['proxy'])) {
|
if (!empty($options['http']['proxy'])) {
|
||||||
// enabled request_fulluri unless it is explicitly disabled
|
// enabled request_fulluri unless it is explicitly disabled
|
||||||
switch (parse_url($url, PHP_URL_SCHEME)) {
|
switch (parse_url($url, PHP_URL_SCHEME)) {
|
||||||
case 'http': // default request_fulluri to true
|
case 'http': // default request_fulluri to true
|
||||||
|
|
|
@ -20,12 +20,14 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
unset($_SERVER['HTTP_PROXY']);
|
unset($_SERVER['HTTP_PROXY']);
|
||||||
unset($_SERVER['http_proxy']);
|
unset($_SERVER['http_proxy']);
|
||||||
|
unset($_SERVER['no_proxy']);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function tearDown()
|
protected function tearDown()
|
||||||
{
|
{
|
||||||
unset($_SERVER['HTTP_PROXY']);
|
unset($_SERVER['HTTP_PROXY']);
|
||||||
unset($_SERVER['http_proxy']);
|
unset($_SERVER['http_proxy']);
|
||||||
|
unset($_SERVER['no_proxy']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -73,6 +75,36 @@ class StreamContextFactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
)), $options);
|
)), $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()
|
public function testOptionsArePreserved()
|
||||||
{
|
{
|
||||||
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
|
$_SERVER['http_proxy'] = 'http://username:password@proxyserver.net:3128/';
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue