Fix unit tests for VcsRepository
parent
1139b5c306
commit
610f15a768
|
@ -235,6 +235,7 @@ class GitHubDriver extends VcsDriver
|
|||
$this->gitDriver = new GitDriver(
|
||||
$this->generateSshUrl(),
|
||||
$this->io,
|
||||
$this->config,
|
||||
$this->process,
|
||||
$this->remoteFilesystem
|
||||
);
|
||||
|
|
|
@ -33,7 +33,7 @@ class SvnDriver extends VcsDriver
|
|||
/**
|
||||
* @var \Composer\Util\Svn
|
||||
*/
|
||||
protected $util;
|
||||
private $util;
|
||||
|
||||
/**
|
||||
* Execute an SVN command and try to fix up the process with credentials
|
||||
|
@ -46,6 +46,10 @@ class SvnDriver extends VcsDriver
|
|||
*/
|
||||
protected function execute($command, $url)
|
||||
{
|
||||
if (null === $this->util) {
|
||||
$this->util = new SvnUtil($this->baseUrl, $this->io, $this->process);
|
||||
}
|
||||
|
||||
try {
|
||||
return $this->util->execute($command, $url);
|
||||
} catch (\RuntimeException $e) {
|
||||
|
@ -65,7 +69,6 @@ class SvnDriver extends VcsDriver
|
|||
if (false !== ($pos = strrpos($this->url, '/trunk'))) {
|
||||
$this->baseUrl = substr($this->url, 0, $pos);
|
||||
}
|
||||
$this->util = new SvnUtil($this->baseUrl, $this->io, $this->process);
|
||||
|
||||
$this->getBranches();
|
||||
$this->getTags();
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace Composer\Test\Repository\Vcs;
|
|||
use Composer\Downloader\TransportException;
|
||||
use Composer\Repository\Vcs\GitHubDriver;
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Config;
|
||||
|
||||
/**
|
||||
* @author Beau Simensen <beau@dflydev.com>
|
||||
|
@ -64,7 +65,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
|||
->with($this->equalTo($repoUrl), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
||||
->will($this->returnValue('{"master_branch": "test_master"}'));
|
||||
|
||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, null, $remoteFilesystem);
|
||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, new Config(), null, $remoteFilesystem);
|
||||
$gitHubDriver->initialize();
|
||||
$this->setAttribute($gitHubDriver, 'tags', array($identifier => $sha));
|
||||
|
||||
|
@ -114,7 +115,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
|||
->with($this->equalTo($repoUrl), $this->equalTo($repoApiUrl), $this->equalTo(false))
|
||||
->will($this->returnValue('{"master_branch": "test_master"}'));
|
||||
|
||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, null, $remoteFilesystem);
|
||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, new Config(), null, $remoteFilesystem);
|
||||
$gitHubDriver->initialize();
|
||||
$this->setAttribute($gitHubDriver, 'tags', array($identifier => $sha));
|
||||
|
||||
|
@ -171,7 +172,14 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
// clean local clone if present
|
||||
$fs = new Filesystem();
|
||||
$fs->removeDirectory(sys_get_temp_dir() . '/composer-' . preg_replace('{[^a-z0-9.]}i', '-', $repoSshUrl) . '/');
|
||||
$fs->removeDirectory(sys_get_temp_dir() . '/composer-test');
|
||||
|
||||
$config = new Config();
|
||||
$config->merge(array(
|
||||
'config' => array(
|
||||
'home' => sys_get_temp_dir() . '/composer-test',
|
||||
),
|
||||
));
|
||||
|
||||
$process->expects($this->at(0))
|
||||
->method('execute')
|
||||
|
@ -202,7 +210,7 @@ class GitHubDriverTest extends \PHPUnit_Framework_TestCase
|
|||
->method('splitLines')
|
||||
->will($this->returnValue(array('* test_master')));
|
||||
|
||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, $process, $remoteFilesystem);
|
||||
$gitHubDriver = new GitHubDriver($repoUrl, $io, $config, $process, $remoteFilesystem);
|
||||
$gitHubDriver->initialize();
|
||||
|
||||
$this->assertEquals('test_master', $gitHubDriver->getRootIdentifier());
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Composer\Test\Repository\Vcs;
|
|||
|
||||
use Composer\Repository\Vcs\SvnDriver;
|
||||
use Composer\IO\NullIO;
|
||||
use Composer\Config;
|
||||
|
||||
class SvnDriverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -39,7 +40,7 @@ class SvnDriverTest extends \PHPUnit_Framework_TestCase
|
|||
->method('getErrorOutput')
|
||||
->will($this->returnValue($output));
|
||||
|
||||
$svn = new SvnDriver('http://till:secret@corp.svn.local/repo', $console, $process);
|
||||
$svn = new SvnDriver('http://till:secret@corp.svn.local/repo', $console, new Config(), $process);
|
||||
$svn->getTags();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ use Composer\Repository\Vcs\GitDriver;
|
|||
use Composer\Util\Filesystem;
|
||||
use Composer\Util\ProcessExecutor;
|
||||
use Composer\IO\NullIO;
|
||||
use Composer\Config;
|
||||
|
||||
class VcsRepositoryTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
@ -123,7 +124,7 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase
|
|||
'dev-master' => true,
|
||||
);
|
||||
|
||||
$repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO);
|
||||
$repo = new VcsRepository(array('url' => self::$gitRepo, 'type' => 'vcs'), new NullIO, new Config());
|
||||
$packages = $repo->getPackages();
|
||||
$dumper = new ArrayDumper();
|
||||
|
||||
|
|
Loading…
Reference in New Issue