1
0
Fork 0

try to fix test instead of guarding implementation

pull/5888/head
Rob Bast 2016-11-25 08:28:49 +01:00
parent 7d67da3ffa
commit 873f17261c
No known key found for this signature in database
GPG Key ID: 73076E35E6165F39
4 changed files with 32 additions and 7 deletions

View File

@ -118,7 +118,7 @@ class ArrayDumper
}
}
if (is_array($package->getTransportOptions()) && count($package->getTransportOptions()) > 0) {
if (count($package->getTransportOptions()) > 0) {
$data['transport-options'] = $package->getTransportOptions();
}

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())