diff --git a/src/Composer/Package/Dumper/ArrayDumper.php b/src/Composer/Package/Dumper/ArrayDumper.php index 47167dd23..22d62381b 100644 --- a/src/Composer/Package/Dumper/ArrayDumper.php +++ b/src/Composer/Package/Dumper/ArrayDumper.php @@ -16,6 +16,7 @@ use Composer\Package\BasePackage; use Composer\Package\PackageInterface; use Composer\Package\CompletePackageInterface; use Composer\Package\RootPackageInterface; +use Composer\Package\Link; /** * @author Konstantin Kudryashiv @@ -62,10 +63,12 @@ class ArrayDumper foreach ($links as $link) { $data[$type][$link->getTarget()] = $link->getPrettyConstraint(); } + ksort($data[$type]); } } if ($packages = $package->getSuggests()) { + ksort($packages); $data['suggest'] = $packages; } @@ -88,6 +91,10 @@ class ArrayDumper ); $data = $this->dumpValues($package, $keys, $data); + + if (isset($data['keywords']) && is_array($data['keywords'])) { + sort($data['keywords']); + } } if ($package instanceof RootPackageInterface) { diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php index e21726b09..ec80984be 100644 --- a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -101,7 +101,9 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase ), array( 'keywords', - array('package', 'dependency', 'autoload') + array('package', 'dependency', 'autoload'), + null, + array('autoload', 'dependency', 'package') ), array( 'bin', @@ -148,6 +150,42 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase array( 'support', array('foo' => 'bar'), + ), + array( + 'require', + array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')), + 'requires', + array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0') + ), + array( + 'require-dev', + array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')), + 'devRequires', + array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0') + ), + array( + 'suggest', + array('foo/bar' => 'very useful package', 'bar/baz' => 'another useful package'), + 'suggests', + array('bar/baz' => 'another useful package', 'foo/bar' => 'very useful package') + ), + array( + 'provide', + array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')), + 'provides', + array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0') + ), + array( + 'replace', + array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')), + 'replaces', + array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0') + ), + array( + 'conflict', + array(new Link('foo', 'foo/bar', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0'), new Link('bar', 'bar/baz', new VersionConstraint('=', '1.0.0.0'), 'requires', '1.0.0')), + 'conflicts', + array('bar/baz' => '1.0.0', 'foo/bar' => '1.0.0') ) ); }