You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
1.7 KiB
PHTML
68 lines
1.7 KiB
PHTML
13 years ago
|
<?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.
|
||
|
*/
|
||
|
|
||
11 years ago
|
namespace Composer;
|
||
13 years ago
|
|
||
|
use Composer\Package\Version\VersionParser;
|
||
13 years ago
|
use Composer\Package\AliasPackage;
|
||
13 years ago
|
use Composer\Package\LinkConstraint\VersionConstraint;
|
||
13 years ago
|
use Composer\Util\Filesystem;
|
||
13 years ago
|
|
||
|
abstract class TestCase extends \PHPUnit_Framework_TestCase
|
||
|
{
|
||
13 years ago
|
private static $parser;
|
||
|
|
||
|
protected static function getVersionParser()
|
||
|
{
|
||
|
if (!self::$parser) {
|
||
|
self::$parser = new VersionParser();
|
||
|
}
|
||
|
|
||
|
return self::$parser;
|
||
|
}
|
||
|
|
||
13 years ago
|
protected function getVersionConstraint($operator, $version)
|
||
|
{
|
||
12 years ago
|
$constraint = new VersionConstraint(
|
||
13 years ago
|
$operator,
|
||
13 years ago
|
self::getVersionParser()->normalize($version)
|
||
13 years ago
|
);
|
||
12 years ago
|
|
||
|
$constraint->setPrettyString($operator.' '.$version);
|
||
|
|
||
|
return $constraint;
|
||
13 years ago
|
}
|
||
|
|
||
12 years ago
|
protected function getPackage($name, $version, $class = 'Composer\Package\Package')
|
||
13 years ago
|
{
|
||
13 years ago
|
$normVersion = self::getVersionParser()->normalize($version);
|
||
|
|
||
12 years ago
|
return new $class($name, $normVersion, $version);
|
||
13 years ago
|
}
|
||
13 years ago
|
|
||
13 years ago
|
protected function getAliasPackage($package, $version)
|
||
|
{
|
||
|
$normVersion = self::getVersionParser()->normalize($version);
|
||
12 years ago
|
|
||
13 years ago
|
return new AliasPackage($package, $normVersion, $version);
|
||
|
}
|
||
|
|
||
13 years ago
|
protected function ensureDirectoryExistsAndClear($directory)
|
||
|
{
|
||
|
$fs = new Filesystem();
|
||
|
if (is_dir($directory)) {
|
||
|
$fs->removeDirectory($directory);
|
||
|
}
|
||
|
mkdir($directory, 0777, true);
|
||
|
}
|
||
13 years ago
|
}
|