From 7e30c6782761e6fa33961b4858267fa8fc47247c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A1draic=20Brady?= Date: Sun, 23 Feb 2014 10:20:48 +0000 Subject: [PATCH] Add config.json default config option for "disable-tls" (FALSE by default) --- src/Composer/Config.php | 4 ++++ tests/Composer/Test/ConfigTest.php | 16 +++++++++++++ tests/Composer/Test/DefaultConfigTest.php | 28 +++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 tests/Composer/Test/DefaultConfigTest.php diff --git a/src/Composer/Config.php b/src/Composer/Config.php index 89f535725..fa151f8d4 100644 --- a/src/Composer/Config.php +++ b/src/Composer/Config.php @@ -39,6 +39,7 @@ class Config 'optimize-autoloader' => false, 'prepend-autoloader' => true, 'github-domains' => array('github.com'), + 'disable-tls' => false ); public static $defaultRepositories = array( @@ -210,6 +211,9 @@ class Config } return $this->config[$key]; + + case 'disable-tls': + return $this->config[$key]!== 'false' && (bool) $this->config[$key]; default: if (!isset($this->config[$key])) { diff --git a/tests/Composer/Test/ConfigTest.php b/tests/Composer/Test/ConfigTest.php index c2cf82ca7..ef6a238a3 100644 --- a/tests/Composer/Test/ConfigTest.php +++ b/tests/Composer/Test/ConfigTest.php @@ -117,4 +117,20 @@ class ConfigTest extends \PHPUnit_Framework_TestCase $this->assertEquals(array('https'), $config->get('github-protocols')); } + + /** + * @group TLS + */ + public function testDisableTlsCanBeOverridden() + { + $config = new Config; + $config->merge( + array('config' => array('disable-tls' => 'false')) + ); + $this->assertFalse($config->get('disable-tls')); + $config->merge( + array('config' => array('disable-tls' => 'true')) + ); + $this->assertTrue($config->get('disable-tls')); + } } diff --git a/tests/Composer/Test/DefaultConfigTest.php b/tests/Composer/Test/DefaultConfigTest.php new file mode 100644 index 000000000..4cca5025a --- /dev/null +++ b/tests/Composer/Test/DefaultConfigTest.php @@ -0,0 +1,28 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test; + +use Composer\Config; + +class DefaultConfigTest extends \PHPUnit_Framework_TestCase +{ + /** + * @group TLS + */ + public function testDefaultValuesAreAsExpected() + { + $config = new Config; + $this->assertFalse($config->get('disable-tls')); + } + +} \ No newline at end of file