2012-08-24 08:57:38 +00:00
|
|
|
<?php
|
2012-08-23 19:35:17 +00:00
|
|
|
|
2012-08-24 08:57:38 +00:00
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2012-08-27 07:33:04 +00:00
|
|
|
namespace Composer\Test\Package\Archiver;
|
2012-08-24 08:57:38 +00:00
|
|
|
|
|
|
|
use Composer\Util\Filesystem;
|
|
|
|
use Composer\Util\ProcessExecutor;
|
2012-08-27 08:00:31 +00:00
|
|
|
use Composer\Package\Package;
|
2012-08-24 08:57:38 +00:00
|
|
|
|
2012-08-27 07:33:04 +00:00
|
|
|
abstract class ArchiverTest extends \PHPUnit_Framework_TestCase
|
2012-08-24 08:57:38 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \Composer\Util\Filesystem
|
|
|
|
*/
|
2012-08-23 19:35:17 +00:00
|
|
|
protected $filesystem;
|
2012-08-24 08:57:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Composer\Util\ProcessExecutor
|
|
|
|
*/
|
|
|
|
protected $process;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
2012-08-23 19:35:17 +00:00
|
|
|
protected $testDir;
|
2012-08-24 08:57:38 +00:00
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
2012-08-23 19:35:17 +00:00
|
|
|
$this->filesystem = new Filesystem();
|
|
|
|
$this->process = new ProcessExecutor();
|
2012-10-21 16:23:35 +00:00
|
|
|
$this->testDir = sys_get_temp_dir().'/composer_archiver_test_'.mt_rand();
|
2012-08-23 19:35:17 +00:00
|
|
|
$this->filesystem->ensureDirectoryExists($this->testDir);
|
2012-08-24 08:57:38 +00:00
|
|
|
}
|
|
|
|
|
2012-10-21 16:23:35 +00:00
|
|
|
public function tearDown()
|
2012-08-24 08:57:38 +00:00
|
|
|
{
|
2012-08-23 19:35:17 +00:00
|
|
|
$this->filesystem->removeDirectory($this->testDir);
|
2012-08-24 08:57:38 +00:00
|
|
|
}
|
|
|
|
|
2012-10-21 16:23:35 +00:00
|
|
|
/**
|
|
|
|
* Util method to quickly setup a package using the source path built.
|
|
|
|
*
|
|
|
|
* @return \Composer\Package\Package
|
|
|
|
*/
|
2012-08-24 08:57:38 +00:00
|
|
|
protected function setupPackage()
|
|
|
|
{
|
2012-08-27 08:00:31 +00:00
|
|
|
$package = new Package('archivertest/archivertest', 'master', 'master');
|
2012-08-23 19:35:17 +00:00
|
|
|
$package->setSourceUrl(realpath($this->testDir));
|
2012-08-24 08:57:38 +00:00
|
|
|
$package->setSourceReference('master');
|
|
|
|
$package->setSourceType('git');
|
|
|
|
|
2012-08-23 19:35:17 +00:00
|
|
|
return $package;
|
2012-08-24 08:57:38 +00:00
|
|
|
}
|
|
|
|
}
|