removed unneccesary PackageMock and trailing whitespaces
parent
80c2736021
commit
730f206cea
|
@ -74,7 +74,7 @@ class VersionParser
|
||||||
if (!$package->isDev() || !in_array($package->getSourceType(), array('hg', 'git'))) {
|
if (!$package->isDev() || !in_array($package->getSourceType(), array('hg', 'git'))) {
|
||||||
return $package->getPrettyVersion();
|
return $package->getPrettyVersion();
|
||||||
}
|
}
|
||||||
|
|
||||||
// if source reference is a sha1 hash -- truncate
|
// if source reference is a sha1 hash -- truncate
|
||||||
if ($truncate && self::isHash($package->getSourceReference())) {
|
if ($truncate && self::isHash($package->getSourceReference())) {
|
||||||
return $package->getPrettyVersion() . ' ' . substr($package->getSourceReference(), 0, 6);
|
return $package->getPrettyVersion() . ' ' . substr($package->getSourceReference(), 0, 6);
|
||||||
|
@ -85,7 +85,7 @@ class VersionParser
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates whether version is in form of hash.
|
* Indicates whether version is in form of hash.
|
||||||
*
|
*
|
||||||
* @param string $version
|
* @param string $version
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
|
@ -93,7 +93,7 @@ class VersionParser
|
||||||
{
|
{
|
||||||
return strlen($version) == self::$sha1Length;
|
return strlen($version) == self::$sha1Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Normalizes a version string to be able to perform comparisons on it
|
* Normalizes a version string to be able to perform comparisons on it
|
||||||
*
|
*
|
||||||
|
@ -291,5 +291,5 @@ class VersionParser
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new \UnexpectedValueException('Could not parse version constraint '.$constraint);
|
throw new \UnexpectedValueException('Could not parse version constraint '.$constraint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,239 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Composer.
|
|
||||||
*
|
|
||||||
* (c) Nils Adermann <naderman@naderman.de>
|
|
||||||
* Jordi Boggiano <j.boggiano@seld.be>
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace Composer\Test\Mock;
|
|
||||||
|
|
||||||
use Composer\Package\PackageInterface;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mock class for PackageInterface.
|
|
||||||
*
|
|
||||||
* More fields might be added if required in test cases.
|
|
||||||
*/
|
|
||||||
class PackageMock implements PackageInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
private $isDev;
|
|
||||||
private $prettyVersion;
|
|
||||||
private $sourceReference;
|
|
||||||
private $sourceType;
|
|
||||||
|
|
||||||
public function __toString()
|
|
||||||
{
|
|
||||||
return 'PackageMock';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAlias()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAutoload()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getBinaries()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getConflicts()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDevRequires()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDistReference()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDistSha1Checksum()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDistType()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDistUrl()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getExtra()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getId()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getIncludePaths()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getInstallationSource()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getNames()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrettyAlias()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrettyName()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrettyString()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getPrettyVersion()
|
|
||||||
{
|
|
||||||
return $this->prettyVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getProvides()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReleaseDate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getReplaces()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRepository()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRequires()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSourceReference()
|
|
||||||
{
|
|
||||||
return $this->sourceReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSourceType()
|
|
||||||
{
|
|
||||||
return $this->sourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSourceUrl()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getStability()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getSuggests()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTargetDir()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getType()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getUniqueName()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVersion()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isDev()
|
|
||||||
{
|
|
||||||
return $this->isDev;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setId($id)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setInstallationSource($type)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setIsDev($isDev)
|
|
||||||
{
|
|
||||||
$this->isDev = $isDev;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setPrettyVersion($prettyVersion)
|
|
||||||
{
|
|
||||||
$this->prettyVersion = $prettyVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSourceReference($sourceReference)
|
|
||||||
{
|
|
||||||
$this->sourceReference = $sourceReference;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setSourceType($sourceType)
|
|
||||||
{
|
|
||||||
$this->sourceType = $sourceType;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function setRepository(\Composer\Repository\RepositoryInterface $repository)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -16,13 +16,12 @@ use Composer\Package\Version\VersionParser;
|
||||||
use Composer\Package\LinkConstraint\MultiConstraint;
|
use Composer\Package\LinkConstraint\MultiConstraint;
|
||||||
use Composer\Package\LinkConstraint\VersionConstraint;
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
use Composer\Test\Mock\PackageMock;
|
|
||||||
|
|
||||||
class VersionParserTest extends \PHPUnit_Framework_TestCase
|
class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @dataProvider formattedVersions
|
* @dataProvider formattedVersions
|
||||||
*
|
*
|
||||||
* @param \Composer\Package\PackageInterface $package
|
* @param \Composer\Package\PackageInterface $package
|
||||||
* @param string $expected
|
* @param string $expected
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +29,7 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$this->assertSame($expected, VersionParser::formatVersion($package, $truncate));
|
$this->assertSame($expected, VersionParser::formatVersion($package, $truncate));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function formattedVersions()
|
public function formattedVersions()
|
||||||
{
|
{
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -39,20 +38,21 @@ class VersionParserTest extends \PHPUnit_Framework_TestCase
|
||||||
array('sourceReference' => 'v1.0.0', 'truncate' => false, 'expected' => 'PrettyVersion v1.0.0'),
|
array('sourceReference' => 'v1.0.0', 'truncate' => false, 'expected' => 'PrettyVersion v1.0.0'),
|
||||||
array('sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77', 'truncate' => false, 'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77'),
|
array('sourceReference' => 'bbf527a27356414bfa9bf520f018c5cb7af67c77', 'truncate' => false, 'expected' => 'PrettyVersion bbf527a27356414bfa9bf520f018c5cb7af67c77'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$createPackage = function($arr) {
|
$self = $this;
|
||||||
$package = new PackageMock();
|
$createPackage = function($arr) use ($self) {
|
||||||
$package->setIsDev(true);
|
$package = $self->getMock('\Composer\Package\PackageInterface');
|
||||||
$package->setSourceType('git');
|
$package->expects($self->once())->method('isDev')->will($self->returnValue(true));
|
||||||
$package->setPrettyVersion('PrettyVersion');
|
$package->expects($self->once())->method('getSourceType')->will($self->returnValue('git'));
|
||||||
$package->setSourceReference($arr['sourceReference']);
|
$package->expects($self->once())->method('getPrettyVersion')->will($self->returnValue('PrettyVersion'));
|
||||||
|
$package->expects($self->any())->method('getSourceReference')->will($self->returnValue($arr['sourceReference']));
|
||||||
|
|
||||||
return array($package, $arr['truncate'], $arr['expected']);
|
return array($package, $arr['truncate'], $arr['expected']);
|
||||||
};
|
};
|
||||||
|
|
||||||
return array_map($createPackage, $data);
|
return array_map($createPackage, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider successfulNormalizedVersions
|
* @dataProvider successfulNormalizedVersions
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue