1
0
Fork 0
composer/tests/Composer/Test/Util/Http/RequestProxyTest.php

62 lines
1.4 KiB
PHP
Raw Normal View History

2020-09-24 15:48:22 +00:00
<?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(
2020-11-22 13:48:56 +00:00
'basic' => array('http://proxy.com:80', false),
'secure' => array('https://proxy.com:443', true),
'none' => array('', false),
2020-09-24 15:48:22 +00:00
);
}
/**
* @dataProvider dataProxyUrl
2020-09-24 15:48:22 +00:00
*/
public function testGetFormattedUrlFormat($url, $format, $expected)
2020-09-24 15:48:22 +00:00
{
$proxy = new RequestProxy($url, array(), $url);
$message = $proxy->getFormattedUrl($format);
2020-09-24 15:48:22 +00:00
$this->assertSame($expected, $message);
}
public function dataProxyUrl()
2020-09-24 15:48:22 +00:00
{
$format = 'proxy (%s)';
// url, format, expected
return array(
array('', $format, ''),
array('http://proxy.com:80', $format, 'proxy (http://proxy.com:80)'),
);
}
}