1
0
Fork 0

Merge pull request #5888 from alcohol/array-default

use array as default value
pull/5927/head
Jordi Boggiano 2016-12-01 14:24:41 +01:00 committed by GitHub
commit f3f063e3e2
4 changed files with 36 additions and 10 deletions

View File

@ -49,12 +49,14 @@ abstract class BasePackage implements PackageInterface
* @var int
*/
public $id;
/** @var string */
protected $name;
/** @var string */
protected $prettyName;
/** @var RepositoryInterface */
protected $repository;
protected $transportOptions;
/** @var array */
protected $transportOptions = array();
/**
* All descendants' constructors should call this parent constructor
@ -66,7 +68,6 @@ abstract class BasePackage implements PackageInterface
$this->prettyName = $name;
$this->name = strtolower($name);
$this->id = -1;
$this->transportOptions = array();
}
/**

View File

@ -31,6 +31,7 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
{
$this->dumper = new ArrayDumper();
$this->package = $this->getMock('Composer\Package\CompletePackageInterface');
$this->packageExpects('getTransportOptions', array());
}
public function testRequiredInformation()
@ -38,7 +39,8 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
$this
->packageExpects('getPrettyName', 'foo')
->packageExpects('getPrettyVersion', '1.0')
->packageExpects('getVersion', '1.0.0.0');
->packageExpects('getVersion', '1.0.0.0')
;
$config = $this->dumper->dump($this->package);
$this->assertEquals(
@ -56,7 +58,9 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
$this->package = $this->getMock('Composer\Package\RootPackageInterface');
$this
->packageExpects('getMinimumStability', 'dev');
->packageExpects('getMinimumStability', 'dev')
->packageExpects('getTransportOptions', array())
;
$config = $this->dumper->dump($this->package);
$this->assertSame('dev', $config['minimum-stability']);
@ -87,9 +91,15 @@ class ArrayDumperTest extends \PHPUnit_Framework_TestCase
*/
public function testKeys($key, $value, $method = null, $expectedValue = null)
{
$this->package = $this->getMock('Composer\Package\RootPackageInterface');
$this->packageExpects('get'.ucfirst($method ?: $key), $value);
$this->packageExpects('isAbandoned', $value);
if ($method !== 'transportOptions') {
$this->packageExpects('getTransportOptions', array());
}
$config = $this->dumper->dump($this->package);
$this->assertSame($expectedValue ?: $value, $config[$key]);

View File

@ -118,6 +118,13 @@ class LockerTest extends \PHPUnit_Framework_TestCase
->method('getVersion')
->will($this->returnValue('0.1.10.0'));
foreach (array($package1, $package2) as $package) {
$package
->expects($this->atLeastOnce())
->method('getTransportOptions')
->will($this->returnValue(array()));
}
$contentHash = md5(trim($jsonContent));
$json

View File

@ -198,18 +198,26 @@ class VersionSelectorTest extends \PHPUnit_Framework_TestCase
$versionParser = new VersionParser();
$package = $this->getMock('\Composer\Package\PackageInterface');
$package->expects($this->any())
$package
->expects($this->any())
->method('getPrettyVersion')
->will($this->returnValue($prettyVersion));
$package->expects($this->any())
$package
->expects($this->any())
->method('getVersion')
->will($this->returnValue($versionParser->normalize($prettyVersion)));
$package->expects($this->any())
$package
->expects($this->any())
->method('isDev')
->will($this->returnValue($isDev));
$package->expects($this->any())
$package
->expects($this->any())
->method('getStability')
->will($this->returnValue($stability));
$package
->expects($this->any())
->method('getTransportOptions')
->will($this->returnValue(array()));
$branchAlias = $branchAlias === null ? array() : array('branch-alias' => array($prettyVersion => $branchAlias));
$package->expects($this->any())