diff --git a/src/Composer/Package/Loader/ArrayLoader.php b/src/Composer/Package/Loader/ArrayLoader.php index 10ad4376a..e86df0a45 100644 --- a/src/Composer/Package/Loader/ArrayLoader.php +++ b/src/Composer/Package/Loader/ArrayLoader.php @@ -29,7 +29,7 @@ class ArrayLoader implements LoaderInterface protected $versionParser; protected $loadOptions; - public function __construct(SemverVersionParser $parser = null, $loadOptions = false) + public function __construct(SemverVersionParser $parser = null, $loadOptions = true) { if (!$parser) { $parser = new VersionParser; diff --git a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php index 10963b55b..25bf7b28c 100644 --- a/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php +++ b/tests/Composer/Test/Package/Loader/ArrayLoaderTest.php @@ -24,7 +24,7 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->loader = new ArrayLoader(null, true); + $this->loader = new ArrayLoader(null); } public function testSelfVersion() @@ -82,9 +82,9 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase $this->assertEquals('1.2.3.4', $package->getVersion()); } - public function testParseDump() + public function testParseDumpProvider() { - $config = array( + $validConfig = array( 'name' => 'A/B', 'version' => '1.2.3', 'version_normalized' => '1.2.3.0', @@ -126,9 +126,55 @@ class ArrayLoaderTest extends \PHPUnit_Framework_TestCase 'abandoned' => 'foo/bar', ); + $validTestArguments = array($validConfig); + $argumentsToProvide = array($validTestArguments); + + return $argumentsToProvide; + } + + protected function fixConfigWhenLoadConfigIsFalse($config) + { + $expectedConfig = $config; + unset($expectedConfig['transport-options']); + return $expectedConfig; + } + + /** + * The default parser should default to loading the config as this + * allows require-dev libraries to have transport options included. + * + * @dataProvider testParseDumpProvider + */ + public function testParseDumpDefaultLoadConfig($config) + { $package = $this->loader->load($config); $dumper = new ArrayDumper; - $this->assertEquals($config, $dumper->dump($package)); + $expectedConfig = $config; + $this->assertEquals($expectedConfig, $dumper->dump($package)); + } + + /** + * @dataProvider testParseDumpProvider + */ + public function testParseDumpTrueLoadConfig($config) + { + $loader = new ArrayLoader(null, true); + $package = $loader->load($config); + $dumper = new ArrayDumper; + $expectedConfig = $config; + $this->assertEquals($expectedConfig, $dumper->dump($package)); + } + + /** + * @dataProvider testParseDumpProvider + */ + public function testParseDumpFalseLoadConfig($config) + { + $loader = new ArrayLoader(null, false); + $package = $loader->load($config); + $dumper = new ArrayDumper; + $expectedConfig = $this->fixConfigWhenLoadConfigIsFalse($config); + $this->assertEquals($expectedConfig, $dumper->dump($package)); } public function testPackageWithBranchAlias()