diff --git a/src/Composer/Package/Dumper/ArrayDumper.php b/src/Composer/Package/Dumper/ArrayDumper.php index ee2a0b376..f372929b1 100644 --- a/src/Composer/Package/Dumper/ArrayDumper.php +++ b/src/Composer/Package/Dumper/ArrayDumper.php @@ -24,11 +24,16 @@ class ArrayDumper { $keys = array( 'binaries' => 'bin', + 'scripts', 'type', 'names', 'extra', 'installationSource' => 'installation-source', 'license', + 'authors', + 'description', + 'homepage', + 'keywords', 'autoload', 'repositories', ); @@ -41,6 +46,10 @@ class ArrayDumper $data['target-dir'] = $package->getTargetDir(); } + if ($package->getReleaseDate()) { + $data['time'] = $package->getReleaseDate()->format('Y-m-d H:i:s'); + } + if ($package->getSourceType()) { $data['source']['type'] = $package->getSourceType(); $data['source']['url'] = $package->getSourceUrl(); diff --git a/src/Composer/Package/MemoryPackage.php b/src/Composer/Package/MemoryPackage.php index 02222e43b..d1e63e102 100644 --- a/src/Composer/Package/MemoryPackage.php +++ b/src/Composer/Package/MemoryPackage.php @@ -438,7 +438,7 @@ class MemoryPackage extends BasePackage * * @param DateTime $releaseDate */ - public function setReleasedate(\DateTime $releaseDate) + public function setReleaseDate(\DateTime $releaseDate) { $this->releaseDate = $releaseDate; } diff --git a/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php new file mode 100644 index 000000000..eab3450bf --- /dev/null +++ b/tests/Composer/Test/Package/Dumper/ArrayDumperTest.php @@ -0,0 +1,66 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Composer\Test\Package\Dumper; + +use Composer\Package\Dumper\ArrayDumper; +use Composer\Package\MemoryPackage; + +class ArrayDumperTest extends \PHPUnit_Framework_TestCase +{ + public function setUp() + { + $this->dumper = new ArrayDumper(); + } + + public function testRequiredInformations() + { + $package = new MemoryPackage('foo', '1.0.0.0', '1.0'); + + $config = $this->dumper->dump($package); + $this->assertEquals(array('name', 'version', 'version_normalized', 'type', 'names'), array_keys($config)); + } + + /** + * @dataProvider getKeys + */ + public function testKeys($key, $value, $expectedValue = null, $method = null) + { + $package = new MemoryPackage('foo', '1.0.0.0', '1.0'); + + $setter = 'set'.ucfirst($method ?: $key); + $package->$setter($value); + + $config = $this->dumper->dump($package); + $this->assertArrayHasKey($key, $config); + + $expectedValue = $expectedValue ?: $value; + $this->assertSame($expectedValue, $config[$key]); + } + + public function getKeys() + { + return array( + array('time', new \DateTime('2012-02-01'), '2012-02-01 00:00:00', 'ReleaseDate'), + array('authors', array('Nils Adermann ', 'Jordi Boggiano ')), + array('homepage', 'http://getcomposer.org'), + array('description', 'Package Manager'), + array('keywords', array('package', 'dependency', 'autoload')), + array('bin', array('bin/composer'), null, 'binaries'), + array('license', array('MIT')), + array('autoload', array('psr-0' => array('Composer' => 'src/'))), + array('repositories', array('packagist' => false)), + array('scripts', array('post-update-cmd' => 'MyVendor\\MyClass::postUpdate')), + array('extra', array('class' => 'MyVendor\\Installer')), + ); + } +}