using theirs
parent
bab10dd9f8
commit
1019c014e5
|
@ -30,7 +30,8 @@
|
|||
"symfony/process": "~2.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~3.7.10"
|
||||
"phpunit/phpunit": "~3.7.10",
|
||||
"mikey179/vfsStream" : "1.2.*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-zip": "Enabling the zip extension allows you to unzip archives, and allows gzip compression of all internet traffic",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"This file locks the dependencies of your project to a known state",
|
||||
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||
],
|
||||
"hash": "370b764a9317165e8ea7a2e1623e031b",
|
||||
"hash": "6203fdb419c10ffd84f85611fc9eec61",
|
||||
"packages": [
|
||||
{
|
||||
"name": "justinrainbow/json-schema",
|
||||
|
@ -79,17 +79,17 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/console",
|
||||
"version": "v2.3.3",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Symfony/Component/Console",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Console.git",
|
||||
"reference": "v2.3.3"
|
||||
"reference": "872a494b88fba2f62be85e0bc8441e7946bb6ba6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/v2.3.3",
|
||||
"reference": "v2.3.3",
|
||||
"url": "https://api.github.com/repos/symfony/Console/zipball/872a494b88fba2f62be85e0bc8441e7946bb6ba6",
|
||||
"reference": "872a494b88fba2f62be85e0bc8441e7946bb6ba6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -104,7 +104,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -128,7 +128,7 @@
|
|||
],
|
||||
"description": "Symfony Console Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-07-21 12:12:18"
|
||||
"time": "2013-08-09 06:00:31"
|
||||
},
|
||||
{
|
||||
"name": "symfony/finder",
|
||||
|
@ -179,17 +179,17 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/process",
|
||||
"version": "v2.3.3",
|
||||
"version": "dev-master",
|
||||
"target-dir": "Symfony/Component/Process",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/Process.git",
|
||||
"reference": "v2.3.3"
|
||||
"reference": "723fe405fcc878ae75469babcb9507d292797ece"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.3",
|
||||
"reference": "v2.3.3",
|
||||
"url": "https://api.github.com/repos/symfony/Process/zipball/723fe405fcc878ae75469babcb9507d292797ece",
|
||||
"reference": "723fe405fcc878ae75469babcb9507d292797ece",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -198,7 +198,7 @@
|
|||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.3-dev"
|
||||
"dev-master": "2.4-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
|
@ -222,10 +222,40 @@
|
|||
],
|
||||
"description": "Symfony Process Component",
|
||||
"homepage": "http://symfony.com",
|
||||
"time": "2013-08-02 21:51:01"
|
||||
"time": "2013-08-09 07:03:52"
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "mikey179/vfsStream",
|
||||
"version": "v1.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/mikey179/vfsStream.git",
|
||||
"reference": "v1.2.0"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/mikey179/vfsStream/zipball/v1.2.0",
|
||||
"reference": "v1.2.0",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"org\\bovigo\\vfs\\": "src/main/php"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD"
|
||||
],
|
||||
"homepage": "http://vfs.bovigo.org/",
|
||||
"time": "2013-04-01 10:41:02"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
"version": "1.2.12",
|
||||
|
@ -645,9 +675,10 @@
|
|||
|
||||
],
|
||||
"minimum-stability": "stable",
|
||||
"stability-flags": [
|
||||
|
||||
],
|
||||
"stability-flags": {
|
||||
"symfony/console": 20,
|
||||
"symfony/process": 20
|
||||
},
|
||||
"platform": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
namespace Composer\Downloader;
|
||||
|
||||
use Composer\Package\PackageInterface;
|
||||
use Composer\Repository\VcsRepository;
|
||||
use Composer\Util\Perforce;
|
||||
|
||||
/**
|
||||
|
@ -20,6 +21,8 @@ use Composer\Util\Perforce;
|
|||
*/
|
||||
class PerforceDownloader extends VcsDownloader
|
||||
{
|
||||
protected $perforce;
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -28,30 +31,29 @@ class PerforceDownloader extends VcsDownloader
|
|||
$ref = $package->getSourceReference();
|
||||
$label = $package->getPrettyVersion();
|
||||
|
||||
$this->initPerforce($package, $path);
|
||||
$this->perforce->setStream($ref);
|
||||
$this->perforce->queryP4User($this->io);
|
||||
$this->perforce->writeP4ClientSpec();
|
||||
$this->perforce->connectClient();
|
||||
$this->perforce->syncCodeBase($label);
|
||||
}
|
||||
|
||||
private function initPerforce($package, $path){
|
||||
if (isset($this->perforce)){
|
||||
return;
|
||||
}
|
||||
$repository = $package->getRepository();
|
||||
//assume repository is a Perforce Repository
|
||||
$repoConfig = $this->getRepoConfig($repository);
|
||||
$this->perforce = new Perforce($repoConfig, $package->getSourceUrl(), $path);
|
||||
}
|
||||
|
||||
$reflector = new \ReflectionClass($repository);
|
||||
$repoConfigProperty = $reflector->getProperty("repoConfig");
|
||||
$repoConfigProperty->setAccessible(true);
|
||||
$repoConfig = $repoConfigProperty->getValue($repository);
|
||||
public function injectPerforce($perforce){
|
||||
$this->perforce = $perforce;
|
||||
}
|
||||
|
||||
$p4user = "";
|
||||
if (isset($repoConfig['p4user'])) {
|
||||
$p4user = $repoConfig['p4user'];
|
||||
}
|
||||
$p4password = "";
|
||||
if (isset($repoConfig['p4password'])) {
|
||||
$p4password = $repoConfig['p4password'];
|
||||
}
|
||||
|
||||
// print("Perforce Downloader:doDownload - repoConfig:" . var_dump($repoConfig, true) . "\n\n");
|
||||
$perforce = new Perforce("", "", $package->getSourceUrl(), $path, null, $p4user, $p4password);
|
||||
$perforce->setStream($ref);
|
||||
$perforce->queryP4User($this->io);
|
||||
$perforce->writeP4ClientSpec();
|
||||
$perforce->connectClient();
|
||||
$perforce->syncCodeBase($label);
|
||||
private function getRepoConfig(VcsRepository $repository){
|
||||
return $repository->getRepoConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -32,25 +32,13 @@ class PerforceDriver extends VcsDriver {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
public function initialize() {
|
||||
$this->depot = $this->repoConfig['depot'];
|
||||
$this->depot = $this->repoConfig['depot'];
|
||||
$this->branch = "";
|
||||
if (isset($this->repoConfig['branch'])) {
|
||||
$this->branch = $this->repoConfig['branch'];
|
||||
}
|
||||
$p4user = "";
|
||||
if (isset($this->repoConfig['p4user'])) {
|
||||
$p4user = $this->repoConfig['p4user'];
|
||||
}
|
||||
$p4password = "";
|
||||
if (isset($this->repoConfig['p4password'])) {
|
||||
$p4password = $this->repoConfig['p4password'];
|
||||
}
|
||||
|
||||
$repoDir = $this->config->get('cache-vcs-dir') . "/$this->depot";
|
||||
if (!isset($this->perforce)) {
|
||||
$this->perforce = new Perforce($this->depot, $this->branch, $this->getUrl(), $repoDir, $this->process, $p4user, $p4password);
|
||||
}
|
||||
|
||||
$this->initPerforce();
|
||||
$this->perforce->p4Login($this->io);
|
||||
$this->perforce->checkStream($this->depot);
|
||||
|
||||
|
@ -60,6 +48,15 @@ class PerforceDriver extends VcsDriver {
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
private function initPerforce() {
|
||||
if (isset($this->perforce)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$repoDir = $this->config->get('cache-vcs-dir') . "/$this->depot";
|
||||
$this->perforce = new Perforce($this->repoConfig, $this->getUrl(), $repoDir, $this->process);
|
||||
}
|
||||
|
||||
public function injectPerforce(Perforce $perforce) {
|
||||
$this->perforce = $perforce;
|
||||
}
|
||||
|
@ -95,6 +92,7 @@ class PerforceDriver extends VcsDriver {
|
|||
*/
|
||||
public function getTags() {
|
||||
$tags = $this->perforce->getTags();
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,11 @@ class VcsRepository extends ArrayRepository
|
|||
$this->repoConfig = $repoConfig;
|
||||
}
|
||||
|
||||
public function getRepoConfig()
|
||||
{
|
||||
return $this->repoConfig;
|
||||
}
|
||||
|
||||
public function setLoader(LoaderInterface $loader)
|
||||
{
|
||||
$this->loader = $loader;
|
||||
|
|
|
@ -25,21 +25,27 @@ class Perforce {
|
|||
protected $p4branch;
|
||||
protected $process;
|
||||
|
||||
public function __construct($depot, $branch, $port, $path, ProcessExecutor $process = null, $p4user = null, $p4password = null) {
|
||||
$this->p4depot = $depot;
|
||||
$this->p4branch = $branch;
|
||||
public function __construct($repoConfig, $port, $path, ProcessExecutor $process = NULL) {
|
||||
$this->p4port = $port;
|
||||
$this->path = $path;
|
||||
$this->process = $process ? : new ProcessExecutor;
|
||||
$fs = new Filesystem();
|
||||
$fs->ensureDirectoryExists($path);
|
||||
if (isset($p4user)){
|
||||
$this->p4user = $p4user;
|
||||
} else {
|
||||
|
||||
if (isset($repoConfig['depot'])) {
|
||||
$this->p4depot = $repoConfig['depot'];
|
||||
}
|
||||
if (isset($repoConfig['branch'])) {
|
||||
$this->p4branch = $repoConfig['branch'];
|
||||
}
|
||||
if (isset($repoConfig['p4user'])) {
|
||||
$this->p4user = $repoConfig['p4user'];
|
||||
}
|
||||
else {
|
||||
$this->p4user = $this->getP4variable("P4USER");
|
||||
}
|
||||
if (isset($p4password)){
|
||||
$this->p4password = $p4password;
|
||||
if (isset($repoConfig['p4password'])) {
|
||||
$this->p4password = $repoConfig['p4password'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +53,10 @@ class Perforce {
|
|||
return mt_rand(1000, 9999);
|
||||
}
|
||||
|
||||
protected function isWindows(){
|
||||
return defined('PHP_WINDOWS_VERSION_BUILD');
|
||||
}
|
||||
|
||||
protected function executeCommand($command) {
|
||||
$result = "";
|
||||
$this->process->execute($command, $result);
|
||||
|
@ -72,6 +82,10 @@ class Perforce {
|
|||
return $this->p4port;
|
||||
}
|
||||
|
||||
protected function isStream() {
|
||||
return (strcmp($this->p4depotType, "stream") === 0);
|
||||
}
|
||||
|
||||
protected function getStream() {
|
||||
if (!isset($this->p4stream)) {
|
||||
if ($this->isStream()) {
|
||||
|
@ -107,45 +121,54 @@ class Perforce {
|
|||
|
||||
public function queryP4User(IOInterface $io) {
|
||||
$this->getUser();
|
||||
if (strlen($this->p4user) <= 0) {
|
||||
$this->p4user = $io->ask("Enter P4 User:");
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
$command = "p4 set P4USER=$this->p4user";
|
||||
} else {
|
||||
$command = "export P4USER=$this->p4user";
|
||||
}
|
||||
$result = $this->executeCommand($command);
|
||||
if (strlen($this->p4user) > 0) {
|
||||
return;
|
||||
}
|
||||
$this->p4user = $this->getP4variable("P4USER");
|
||||
if (strlen($this->p4user) > 0) {
|
||||
return;
|
||||
}
|
||||
$this->p4user = $io->ask("Enter P4 User:");
|
||||
if ($this->isWindows()) {
|
||||
$command = "p4 set P4USER=$this->p4user";
|
||||
}
|
||||
else {
|
||||
$command = "export P4USER=$this->p4user";
|
||||
}
|
||||
$result = $this->executeCommand($command);
|
||||
}
|
||||
|
||||
protected function getP4variable($name){
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
protected function getP4variable($name) {
|
||||
if ($this->isWindows()) {
|
||||
$command = "p4 set";
|
||||
$result = $this->executeCommand($command);
|
||||
$resArray = explode("\n", $result);
|
||||
foreach ($resArray as $line) {
|
||||
$fields = explode("=", $line);
|
||||
if (strcmp($name, $fields[0]) == 0){
|
||||
if (strcmp($name, $fields[0]) == 0) {
|
||||
$index = strpos($fields[1], " ");
|
||||
if ($index === false){
|
||||
if ($index === FALSE) {
|
||||
$value = $fields[1];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$value = substr($fields[1], 0, $index);
|
||||
}
|
||||
$value = trim($value);
|
||||
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$command = 'echo $' . $name;
|
||||
$result = trim($this->executeCommand($command));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function queryP4Password(IOInterface $io) {
|
||||
if (isset($this->p4password)){
|
||||
if (isset($this->p4password)) {
|
||||
return $this->p4password;
|
||||
}
|
||||
$password = $this->getP4variable("P4PASSWD");
|
||||
|
@ -153,11 +176,8 @@ class Perforce {
|
|||
$password = $io->askAndHideAnswer("Enter password for Perforce user " . $this->getUser() . ": ");
|
||||
}
|
||||
$this->p4password = $password;
|
||||
return $password;
|
||||
}
|
||||
|
||||
protected function isStream() {
|
||||
return (strcmp($this->p4depotType, "stream") === 0);
|
||||
return $password;
|
||||
}
|
||||
|
||||
protected function generateP4Command($command, $useClient = TRUE) {
|
||||
|
@ -179,6 +199,7 @@ class Perforce {
|
|||
if ($index === FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -245,18 +266,19 @@ class Perforce {
|
|||
}
|
||||
|
||||
|
||||
protected function read($pipe, $name){
|
||||
protected function read($pipe, $name) {
|
||||
if (feof($pipe)) {
|
||||
return;
|
||||
}
|
||||
$line = fgets($pipe);
|
||||
while ($line != false){
|
||||
while ($line != FALSE) {
|
||||
$line = fgets($pipe);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function windowsLogin($password){
|
||||
public function windowsLogin($password) {
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"),
|
||||
1 => array("pipe", "w"),
|
||||
|
@ -264,8 +286,8 @@ class Perforce {
|
|||
);
|
||||
$command = $this->generateP4Command(" login -a");
|
||||
$process = proc_open($command, $descriptorspec, $pipes);
|
||||
if (!is_resource($process)){
|
||||
return false;
|
||||
if (!is_resource($process)) {
|
||||
return FALSE;
|
||||
}
|
||||
fwrite($pipes[0], $password);
|
||||
fclose($pipes[0]);
|
||||
|
@ -286,10 +308,11 @@ class Perforce {
|
|||
$this->queryP4User($io);
|
||||
if (!$this->isLoggedIn()) {
|
||||
$password = $this->queryP4Password($io);
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
if ($this->isWindows()) {
|
||||
$this->windowsLogin($password);
|
||||
} else {
|
||||
$command = "echo $password | ".$this->generateP4Command(" login -a", false);
|
||||
}
|
||||
else {
|
||||
$command = "echo $password | " . $this->generateP4Command(" login -a", FALSE);
|
||||
$this->executeCommand($command);
|
||||
}
|
||||
}
|
||||
|
@ -392,6 +415,7 @@ class Perforce {
|
|||
$tags[$fields[1]] = $this->getStream() . "@" . $fields[1];
|
||||
}
|
||||
}
|
||||
|
||||
return $tags;
|
||||
}
|
||||
|
||||
|
|
|
@ -14,97 +14,103 @@
|
|||
|
||||
namespace Composer\Test\Repository\Vcs;
|
||||
|
||||
#use Composer\Downloader\TransportException;
|
||||
|
||||
use Composer\Repository\Vcs\PerforceDriver;
|
||||
use Composer\Util\Filesystem;
|
||||
use Composer\Config;
|
||||
use Composer\IO\ConsoleIO;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\ConsoleOutput;
|
||||
use Symfony\Component\Console\Helper\HelperSet;
|
||||
|
||||
|
||||
class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
class PerforceDriverTest extends \PHPUnit_Framework_TestCase {
|
||||
private $config;
|
||||
private $io;
|
||||
private $process;
|
||||
private $remoteFileSystem;
|
||||
private $testPath;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
public function setUp() {
|
||||
$this->testPath = sys_get_temp_dir() . '/composer-test';
|
||||
$this->config = new Config();
|
||||
$this->config->merge(array(
|
||||
'config' => array(
|
||||
'home' => sys_get_temp_dir() . '/composer-test',
|
||||
),
|
||||
));
|
||||
$inputParameters = array();
|
||||
$input = new ArrayInput($inputParameters);
|
||||
$output = new ConsoleOutput();
|
||||
$helperSet = new HelperSet();
|
||||
$this->io = new ConsoleIO($input, $output, $helperSet);
|
||||
$this->config->merge(
|
||||
array(
|
||||
'config' => array(
|
||||
'home' => $this->testPath,
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
$this->io = $this->getMock('Composer\IO\IOInterface');
|
||||
$this->process = $this->getMock('Composer\Util\ProcessExecutor');
|
||||
$this->remoteFileSystem = $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
public function tearDown() {
|
||||
$fs = new Filesystem;
|
||||
$fs->removeDirectory(sys_get_temp_dir() . '/composer-test');
|
||||
$fs->removeDirectory($this->testPath);
|
||||
}
|
||||
|
||||
public function testPrivateRepository()
|
||||
{
|
||||
$repo_config = array(
|
||||
'url' => "perforce.vuhl.root.mrc.local:3710",
|
||||
'depot' => "lighthouse"
|
||||
);
|
||||
//Test:
|
||||
//hasComposerFile
|
||||
|
||||
$vcs = new PerforceDriver($repo_config, $this->io, $this->config);
|
||||
$result = $vcs->initialize();
|
||||
$this->assertTrue($result);
|
||||
public function testInitializeCapturesVariablesFromRepoConfig() {
|
||||
$this->setUp();
|
||||
$repo_config = array(
|
||||
'url' => 'TEST_PERFORCE_URL',
|
||||
'depot' => 'TEST_DEPOT_CONFIG',
|
||||
'branch' => 'TEST_BRANCH_CONFIG'
|
||||
);
|
||||
$driver = new TestingPerforceDriver($repo_config, $this->io, $this->config, $this->process, $this->remoteFileSystem);
|
||||
$arguments = array(array('depot'=>'TEST_DEPOT', 'branch'=>'TEST_BRANCH'), 'port'=>'TEST_PORT', 'path'=>$this->testPath);
|
||||
$perforce = $this->getMock('Composer\Util\Perforce', null, $arguments);
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->initialize();
|
||||
$this->assertEquals("TEST_PERFORCE_URL", $driver->getUrl());
|
||||
$this->assertEquals("TEST_DEPOT_CONFIG", $driver->getDepot());
|
||||
$this->assertEquals("TEST_BRANCH_CONFIG", $driver->getBranch());
|
||||
}
|
||||
|
||||
public function testGetTags()
|
||||
{
|
||||
public function testInitializeLogsInAndConnectsClient() {
|
||||
$this->setUp();
|
||||
$repo_config = array(
|
||||
'url' => "perforce.vuhl.root.mrc.local:3710",
|
||||
'depot' => "lighthouse"
|
||||
'url' => 'TEST_PERFORCE_URL',
|
||||
'depot' => 'TEST_DEPOT_CONFIG',
|
||||
'branch' => 'TEST_BRANCH_CONFIG'
|
||||
);
|
||||
$driver = new TestingPerforceDriver($repo_config, $this->io, $this->config, $this->process, $this->remoteFileSystem);
|
||||
$perforce = $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
|
||||
$perforce->expects($this->at(0))
|
||||
->method('p4Login')
|
||||
->with($this->io);
|
||||
$perforce->expects($this->at(1))
|
||||
->method('checkStream')
|
||||
->with($this->equalTo("TEST_DEPOT_CONFIG"));
|
||||
$perforce->expects($this->at(2))
|
||||
->method('writeP4ClientSpec');
|
||||
$perforce->expects($this->at(3))
|
||||
->method('connectClient');
|
||||
|
||||
$vcs = new PerforceDriver($repo_config, $this->io, $this->config);
|
||||
$result = $vcs->initialize();
|
||||
$this->assertTrue($result);
|
||||
$tags = $vcs->getTags();
|
||||
$this->assertTrue(empty($tags));
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->initialize();
|
||||
}
|
||||
|
||||
public function testGetSource()
|
||||
{
|
||||
public function testHasComposerFile() {
|
||||
$this->setUp();
|
||||
$repo_config = array(
|
||||
'url' => "perforce.vuhl.root.mrc.local:3710",
|
||||
'depot' => "lighthouse"
|
||||
'url' => 'TEST_PERFORCE_URL',
|
||||
'depot' => 'TEST_DEPOT_CONFIG',
|
||||
'branch' => 'TEST_BRANCH_CONFIG'
|
||||
);
|
||||
|
||||
$vcs = new PerforceDriver($repo_config, $this->io, $this->config);
|
||||
$result = $vcs->initialize();
|
||||
$driver = new TestingPerforceDriver($repo_config, $this->io, $this->config, $this->process, $this->remoteFileSystem);
|
||||
$arguments = array(array('depot'=>'TEST_DEPOT', 'branch'=>'TEST_BRANCH'), 'port'=>'TEST_PORT', 'path'=>$this->testPath);
|
||||
$perforce = $this->getMock('Composer\Util\Perforce', array('getComposerInformation'), $arguments);
|
||||
$perforce->expects($this->at(0))
|
||||
->method('getComposerInformation')
|
||||
->with($this->equalTo("//TEST_DEPOT_CONFIG/TEST_IDENTIFIER"))
|
||||
->will($this->returnValue("Some json stuff"));
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->initialize();
|
||||
$identifier = "TEST_IDENTIFIER";
|
||||
$result = $driver->hasComposerFile($identifier);
|
||||
$this->assertTrue($result);
|
||||
$identifier = $vcs->getRootIdentifier();
|
||||
$source = $vcs->getSource($identifier);
|
||||
$this->assertEquals($source['type'], "perforce");
|
||||
$this->assertEquals($source['reference'], $identifier);
|
||||
}
|
||||
|
||||
public function testGetDist()
|
||||
{
|
||||
$repo_config = array(
|
||||
'url' => "perforce.vuhl.root.mrc.local:3710",
|
||||
'depot' => "lighthouse"
|
||||
);
|
||||
|
||||
$vcs = new PerforceDriver($repo_config, $this->io, $this->config);
|
||||
$result = $vcs->initialize();
|
||||
$this->assertTrue($result);
|
||||
$identifier = $vcs->getRootIdentifier();
|
||||
$dist = $vcs->getDist($identifier);
|
||||
$this->assertNull($dist);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue