From 8630aab93f03efd2c1e74a7e0498ed702c9a6598 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Ot=C3=A1vio=20Cobucci=20Oblonczyk?= Date: Mon, 19 Aug 2013 04:40:08 -0300 Subject: [PATCH] Package options must be a non mandatory array and should be loaded when exists --- src/Composer/Package/Loader/ArrayLoader.php | 4 ++++ src/Composer/Package/Loader/ValidatingArrayLoader.php | 1 + tests/Composer/Test/Package/Loader/ArrayLoaderTest.php | 1 + .../Test/Package/Loader/ValidatingArrayLoaderTest.php | 10 ++++++++++ 4 files changed, 16 insertions(+) diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 3940bdeb0..46e33b37d 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -193,6 +193,10 @@ class ArrayLoader implements LoaderInterface } } + if (isset($config['options'])) { + $package->setOptions($config['options']); + } + return $package; } diff --git a/src/Composer/Package/Loader/ValidatingArrayLoader.php b/src/Composer/Package/Loader/ValidatingArrayLoader.php index a5b6281a3..8e21b0e91 100644 --- a/src/Composer/Package/Loader/ValidatingArrayLoader.php +++ b/src/Composer/Package/Loader/ValidatingArrayLoader.php @@ -196,6 +196,7 @@ class ValidatingArrayLoader implements LoaderInterface // TODO validate package repositories' packages using this recursively $this->validateFlatArray('include-path'); + $this->validateArray('options'); // branch alias validation if (isset($this->config['extra']['branch-alias'])) { diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 248e251ef..474929307 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -117,6 +117,7 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase 'archive' => array( 'exclude' => array('/foo/bar', 'baz', '!/foo/bar/baz'), ), + 'options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem')) ); $package = $this->loader->load($config); diff --git a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php index 262c24bf6..b069c3e82 100644 --- a/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ValidatingArrayLoaderTest.php @@ -143,6 +143,7 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase 'bin/foo', 'bin/bar', ), + 'options' => array('ssl' => array('local_cert' => '/opt/certs/test.pem')) ), ), array( // test as array @@ -256,6 +257,15 @@ class ValidatingArrayLoaderTest extends \PHPUnit_Framework_TestCase 'autoload : invalid value (psr0), must be one of psr-0, classmap, files' ) ), + array( + array( + 'name' => 'foo/bar', + 'options' => 'test', + ), + array( + 'options : should be an array, string given' + ) + ), ); }