CS fixes and renaming a few methods, refs #2184
parent
11a0d16ccc
commit
0fbb4cbd16
|
@ -44,15 +44,16 @@ class PerforceDownloader extends VcsDownloader
|
|||
|
||||
private function initPerforce($package, $path, $ref)
|
||||
{
|
||||
if ($this->perforceInjected) {
|
||||
if ($this->perforce) {
|
||||
return;
|
||||
}
|
||||
|
||||
$repository = $package->getRepository();
|
||||
$repoConfig = null;
|
||||
if ($repository instanceof VcsRepository) {
|
||||
$repoConfig = $this->getRepoConfig($repository);
|
||||
}
|
||||
$this->perforce = Perforce::createPerforce($repoConfig, $package->getSourceUrl(), $path);
|
||||
$this->perforce = Perforce::create($repoConfig, $package->getSourceUrl(), $path);
|
||||
}
|
||||
|
||||
private function getRepoConfig(VcsRepository $repository)
|
||||
|
@ -88,9 +89,8 @@ class PerforceDownloader extends VcsDownloader
|
|||
return $commitLogs;
|
||||
}
|
||||
|
||||
public function injectPerforce($perforce)
|
||||
public function setPerforce($perforce)
|
||||
{
|
||||
$this->perforce = $perforce;
|
||||
$this->perforceInjected = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ class PerforceDriver extends VcsDriver
|
|||
}
|
||||
|
||||
$repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
|
||||
$this->perforce = Perforce::createPerforce($repoConfig, $this->getUrl(), $repoDir, $this->process);
|
||||
$this->perforce = Perforce::create($repoConfig, $this->getUrl(), $repoDir, $this->process);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -182,7 +182,7 @@ class PerforceDriver extends VcsDriver
|
|||
return $this->branch;
|
||||
}
|
||||
|
||||
public function injectPerforce(Perforce $perforce)
|
||||
public function setPerforce(Perforce $perforce)
|
||||
{
|
||||
$this->perforce = $perforce;
|
||||
}
|
||||
|
|
|
@ -34,18 +34,6 @@ class Perforce
|
|||
protected $uniquePerforceClientName;
|
||||
protected $windowsFlag;
|
||||
|
||||
public static function createPerforce($repoConfig, $port, $path, ProcessExecutor $process = null)
|
||||
{
|
||||
if (!isset($process)) {
|
||||
$process = new ProcessExecutor;
|
||||
}
|
||||
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD');
|
||||
|
||||
$perforce = new Perforce($repoConfig, $port, $path, $process, $isWindows);
|
||||
|
||||
return $perforce;
|
||||
}
|
||||
|
||||
public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows)
|
||||
{
|
||||
$this->windowsFlag = $isWindows;
|
||||
|
@ -57,6 +45,18 @@ class Perforce
|
|||
$this->initialize($repoConfig);
|
||||
}
|
||||
|
||||
public static function create($repoConfig, $port, $path, ProcessExecutor $process = null)
|
||||
{
|
||||
if (!isset($process)) {
|
||||
$process = new ProcessExecutor;
|
||||
}
|
||||
$isWindows = defined('PHP_WINDOWS_VERSION_BUILD');
|
||||
|
||||
$perforce = new Perforce($repoConfig, $port, $path, $process, $isWindows);
|
||||
|
||||
return $perforce;
|
||||
}
|
||||
|
||||
public function initialize($repoConfig)
|
||||
{
|
||||
$this->uniquePerforceClientName = $this->generateUniquePerforceClientName();
|
||||
|
|
|
@ -21,7 +21,6 @@ use Composer\Repository\VcsRepository;
|
|||
*/
|
||||
class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
private $io;
|
||||
private $config;
|
||||
private $testPath;
|
||||
|
@ -93,7 +92,7 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
|
|||
$perforce->expects($this->at(4))
|
||||
->method('syncCodeBase')
|
||||
->with($this->equalTo($label));
|
||||
$downloader->injectPerforce($perforce);
|
||||
$downloader->setPerforce($perforce);
|
||||
$package = $this->getMock('Composer\Package\PackageInterface');
|
||||
$package->expects($this->at(0))
|
||||
->method('getSourceReference')
|
||||
|
|
|
@ -70,7 +70,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
|||
'TEST'
|
||||
);
|
||||
$perforce = $this->getMock('Composer\Util\Perforce', null, $arguments);
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->setPerforce($perforce);
|
||||
$driver->initialize();
|
||||
$this->assertEquals('TEST_PERFORCE_URL', $driver->getUrl());
|
||||
$this->assertEquals('TEST_DEPOT_CONFIG', $driver->getDepot());
|
||||
|
@ -98,7 +98,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
|||
$perforce->expects($this->at(3))
|
||||
->method('connectClient');
|
||||
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->setPerforce($perforce);
|
||||
$driver->initialize();
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
|||
->method('getComposerInformation')
|
||||
->with($this->equalTo('//TEST_DEPOT_CONFIG/TEST_IDENTIFIER'))
|
||||
->will($this->returnValue('Some json stuff'));
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->setPerforce($perforce);
|
||||
$driver->initialize();
|
||||
$identifier = 'TEST_IDENTIFIER';
|
||||
$result = $driver->hasComposerFile($identifier);
|
||||
|
|
|
@ -20,7 +20,6 @@ use Composer\Util\ProcessExecutor;
|
|||
*/
|
||||
class PerforceTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
protected $perforce;
|
||||
protected $processExecutor;
|
||||
|
||||
|
|
Loading…
Reference in New Issue