mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Refactor proxy handling for Composer2
This commit is contained in:
parent
8564dd8dac
commit
d47261eb93
10 changed files with 950 additions and 85 deletions
61
tests/Composer/Test/Util/Http/RequestProxyTest.php
Normal file
61
tests/Composer/Test/Util/Http/RequestProxyTest.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Composer.
|
||||
*
|
||||
* (c) Nils Adermann <naderman@naderman.de>
|
||||
* Jordi Boggiano <j.boggiano@seld.be>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Composer\Test\Util\Http;
|
||||
|
||||
use Composer\Util\Http\RequestProxy;
|
||||
use Composer\Test\TestCase;
|
||||
|
||||
class RequestProxyTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @dataProvider dataSecure
|
||||
*/
|
||||
public function testIsSecure($url, $expectedSecure)
|
||||
{
|
||||
$proxy = new RequestProxy($url, array(), '');
|
||||
|
||||
$this->assertSame($expectedSecure, $proxy->isSecure());
|
||||
}
|
||||
|
||||
public function dataSecure()
|
||||
{
|
||||
// url, secure
|
||||
return array(
|
||||
'basic' => array('http://proxy.com:80', false),
|
||||
'secure' => array('https://proxy.com:443', true),
|
||||
'none' => array('', false),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider dataLastProxy
|
||||
*/
|
||||
public function testGetLastProxyFormat($url, $format, $expected)
|
||||
{
|
||||
$proxy = new RequestProxy($url, array(), $url);
|
||||
|
||||
$message = $proxy->getLastProxy($format);
|
||||
$this->assertSame($expected, $message);
|
||||
}
|
||||
|
||||
public function dataLastProxy()
|
||||
{
|
||||
$format = 'proxy (%s)';
|
||||
|
||||
// url, format, expected
|
||||
return array(
|
||||
array('', $format, ''),
|
||||
array('http://proxy.com:80', $format, 'proxy (http://proxy.com:80)'),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue