Merge pull request #907 from chEbba/package-support
Add getSupport method to the PackageInterface.pull/911/head
commit
bf245ab885
|
@ -703,9 +703,7 @@ class MemoryPackage extends BasePackage
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the support information
|
* {@inheritDoc}
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function getSupport()
|
public function getSupport()
|
||||||
{
|
{
|
||||||
|
|
|
@ -363,4 +363,11 @@ interface PackageInterface
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getPrettyString();
|
public function getPrettyString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the support information
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getSupport();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,23 +13,42 @@
|
||||||
namespace Composer\Test\Package\Dumper;
|
namespace Composer\Test\Package\Dumper;
|
||||||
|
|
||||||
use Composer\Package\Dumper\ArrayDumper;
|
use Composer\Package\Dumper\ArrayDumper;
|
||||||
use Composer\Package\MemoryPackage;
|
|
||||||
use Composer\Package\Link;
|
use Composer\Package\Link;
|
||||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||||
|
|
||||||
class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var ArrayDumper
|
||||||
|
*/
|
||||||
|
private $dumper;
|
||||||
|
/**
|
||||||
|
* @var \Composer\Package\PackageInterface|\PHPUnit_Framework_MockObject_MockObject
|
||||||
|
*/
|
||||||
|
private $package;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
$this->dumper = new ArrayDumper();
|
$this->dumper = new ArrayDumper();
|
||||||
|
$this->package = $this->getMock('Composer\Package\PackageInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequiredInformations()
|
public function testRequiredInformation()
|
||||||
{
|
{
|
||||||
$package = new MemoryPackage('foo', '1.0.0.0', '1.0');
|
$this
|
||||||
|
->packageExpects('getPrettyName', 'foo')
|
||||||
|
->packageExpects('getPrettyVersion', '1.0')
|
||||||
|
->packageExpects('getVersion', '1.0.0.0');
|
||||||
|
|
||||||
$config = $this->dumper->dump($package);
|
$config = $this->dumper->dump($this->package);
|
||||||
$this->assertEquals(array('name', 'version', 'version_normalized', 'type'), array_keys($config));
|
$this->assertEquals(
|
||||||
|
array(
|
||||||
|
'name' => 'foo',
|
||||||
|
'version' => '1.0',
|
||||||
|
'version_normalized' => '1.0.0.0'
|
||||||
|
),
|
||||||
|
$config
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,21 +56,20 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
*/
|
*/
|
||||||
public function testKeys($key, $value, $method = null, $expectedValue = null)
|
public function testKeys($key, $value, $method = null, $expectedValue = null)
|
||||||
{
|
{
|
||||||
$package = new MemoryPackage('foo', '1.0.0.0', '1.0');
|
$this->packageExpects('get'.ucfirst($method ?: $key), $value);
|
||||||
|
|
||||||
$setter = 'set'.ucfirst($method ?: $key);
|
$config = $this->dumper->dump($this->package);
|
||||||
$package->$setter($value);
|
|
||||||
|
|
||||||
$config = $this->dumper->dump($package);
|
$this->assertSame($expectedValue ?: $value, $config[$key]);
|
||||||
$this->assertArrayHasKey($key, $config);
|
|
||||||
|
|
||||||
$expectedValue = $expectedValue ?: $value;
|
|
||||||
$this->assertSame($expectedValue, $config[$key]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getKeys()
|
public function getKeys()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
array(
|
||||||
|
'type',
|
||||||
|
'library'
|
||||||
|
),
|
||||||
array(
|
array(
|
||||||
'time',
|
'time',
|
||||||
new \DateTime('2012-02-01'),
|
new \DateTime('2012-02-01'),
|
||||||
|
@ -116,6 +134,20 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
|
||||||
array('foo/bar' => 'very useful package'),
|
array('foo/bar' => 'very useful package'),
|
||||||
'suggests'
|
'suggests'
|
||||||
),
|
),
|
||||||
|
array(
|
||||||
|
'support',
|
||||||
|
array('foo' => 'bar'),
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function packageExpects($method, $value)
|
||||||
|
{
|
||||||
|
$this->package
|
||||||
|
->expects($this->any())
|
||||||
|
->method($method)
|
||||||
|
->will($this->returnValue($value));
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue