using theirs
parent
bab10dd9f8
commit
1019c014e5
|
@ -30,7 +30,8 @@
|
||||||
"symfony/process": "~2.1"
|
"symfony/process": "~2.1"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~3.7.10"
|
"phpunit/phpunit": "~3.7.10",
|
||||||
|
"mikey179/vfsStream" : "1.2.*"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-zip": "Enabling the zip extension allows you to unzip archives, and allows gzip compression of all internet traffic",
|
"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",
|
"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"
|
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
|
||||||
],
|
],
|
||||||
"hash": "370b764a9317165e8ea7a2e1623e031b",
|
"hash": "6203fdb419c10ffd84f85611fc9eec61",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "justinrainbow/json-schema",
|
"name": "justinrainbow/json-schema",
|
||||||
|
@ -79,17 +79,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/console",
|
"name": "symfony/console",
|
||||||
"version": "v2.3.3",
|
"version": "dev-master",
|
||||||
"target-dir": "Symfony/Component/Console",
|
"target-dir": "Symfony/Component/Console",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Console.git",
|
"url": "https://github.com/symfony/Console.git",
|
||||||
"reference": "v2.3.3"
|
"reference": "872a494b88fba2f62be85e0bc8441e7946bb6ba6"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Console/zipball/v2.3.3",
|
"url": "https://api.github.com/repos/symfony/Console/zipball/872a494b88fba2f62be85e0bc8441e7946bb6ba6",
|
||||||
"reference": "v2.3.3",
|
"reference": "872a494b88fba2f62be85e0bc8441e7946bb6ba6",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -104,7 +104,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev"
|
"dev-master": "2.4-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -128,7 +128,7 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Console Component",
|
"description": "Symfony Console Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2013-07-21 12:12:18"
|
"time": "2013-08-09 06:00:31"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/finder",
|
"name": "symfony/finder",
|
||||||
|
@ -179,17 +179,17 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "symfony/process",
|
"name": "symfony/process",
|
||||||
"version": "v2.3.3",
|
"version": "dev-master",
|
||||||
"target-dir": "Symfony/Component/Process",
|
"target-dir": "Symfony/Component/Process",
|
||||||
"source": {
|
"source": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/symfony/Process.git",
|
"url": "https://github.com/symfony/Process.git",
|
||||||
"reference": "v2.3.3"
|
"reference": "723fe405fcc878ae75469babcb9507d292797ece"
|
||||||
},
|
},
|
||||||
"dist": {
|
"dist": {
|
||||||
"type": "zip",
|
"type": "zip",
|
||||||
"url": "https://api.github.com/repos/symfony/Process/zipball/v2.3.3",
|
"url": "https://api.github.com/repos/symfony/Process/zipball/723fe405fcc878ae75469babcb9507d292797ece",
|
||||||
"reference": "v2.3.3",
|
"reference": "723fe405fcc878ae75469babcb9507d292797ece",
|
||||||
"shasum": ""
|
"shasum": ""
|
||||||
},
|
},
|
||||||
"require": {
|
"require": {
|
||||||
|
@ -198,7 +198,7 @@
|
||||||
"type": "library",
|
"type": "library",
|
||||||
"extra": {
|
"extra": {
|
||||||
"branch-alias": {
|
"branch-alias": {
|
||||||
"dev-master": "2.3-dev"
|
"dev-master": "2.4-dev"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
@ -222,10 +222,40 @@
|
||||||
],
|
],
|
||||||
"description": "Symfony Process Component",
|
"description": "Symfony Process Component",
|
||||||
"homepage": "http://symfony.com",
|
"homepage": "http://symfony.com",
|
||||||
"time": "2013-08-02 21:51:01"
|
"time": "2013-08-09 07:03:52"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"packages-dev": [
|
"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",
|
"name": "phpunit/php-code-coverage",
|
||||||
"version": "1.2.12",
|
"version": "1.2.12",
|
||||||
|
@ -645,9 +675,10 @@
|
||||||
|
|
||||||
],
|
],
|
||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"stability-flags": [
|
"stability-flags": {
|
||||||
|
"symfony/console": 20,
|
||||||
],
|
"symfony/process": 20
|
||||||
|
},
|
||||||
"platform": {
|
"platform": {
|
||||||
"php": ">=5.3.2"
|
"php": ">=5.3.2"
|
||||||
},
|
},
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
namespace Composer\Downloader;
|
namespace Composer\Downloader;
|
||||||
|
|
||||||
use Composer\Package\PackageInterface;
|
use Composer\Package\PackageInterface;
|
||||||
|
use Composer\Repository\VcsRepository;
|
||||||
use Composer\Util\Perforce;
|
use Composer\Util\Perforce;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +21,8 @@ use Composer\Util\Perforce;
|
||||||
*/
|
*/
|
||||||
class PerforceDownloader extends VcsDownloader
|
class PerforceDownloader extends VcsDownloader
|
||||||
{
|
{
|
||||||
|
protected $perforce;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -28,30 +31,29 @@ class PerforceDownloader extends VcsDownloader
|
||||||
$ref = $package->getSourceReference();
|
$ref = $package->getSourceReference();
|
||||||
$label = $package->getPrettyVersion();
|
$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();
|
$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);
|
|
||||||
|
|
||||||
$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");
|
public function injectPerforce($perforce){
|
||||||
$perforce = new Perforce("", "", $package->getSourceUrl(), $path, null, $p4user, $p4password);
|
$this->perforce = $perforce;
|
||||||
$perforce->setStream($ref);
|
}
|
||||||
$perforce->queryP4User($this->io);
|
|
||||||
$perforce->writeP4ClientSpec();
|
private function getRepoConfig(VcsRepository $repository){
|
||||||
$perforce->connectClient();
|
return $repository->getRepoConfig();
|
||||||
$perforce->syncCodeBase($label);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -37,20 +37,8 @@ class PerforceDriver extends VcsDriver {
|
||||||
if (isset($this->repoConfig['branch'])) {
|
if (isset($this->repoConfig['branch'])) {
|
||||||
$this->branch = $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->p4Login($this->io);
|
||||||
$this->perforce->checkStream($this->depot);
|
$this->perforce->checkStream($this->depot);
|
||||||
|
|
||||||
|
@ -60,6 +48,15 @@ class PerforceDriver extends VcsDriver {
|
||||||
return TRUE;
|
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) {
|
public function injectPerforce(Perforce $perforce) {
|
||||||
$this->perforce = $perforce;
|
$this->perforce = $perforce;
|
||||||
}
|
}
|
||||||
|
@ -95,6 +92,7 @@ class PerforceDriver extends VcsDriver {
|
||||||
*/
|
*/
|
||||||
public function getTags() {
|
public function getTags() {
|
||||||
$tags = $this->perforce->getTags();
|
$tags = $this->perforce->getTags();
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,11 @@ class VcsRepository extends ArrayRepository
|
||||||
$this->repoConfig = $repoConfig;
|
$this->repoConfig = $repoConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRepoConfig()
|
||||||
|
{
|
||||||
|
return $this->repoConfig;
|
||||||
|
}
|
||||||
|
|
||||||
public function setLoader(LoaderInterface $loader)
|
public function setLoader(LoaderInterface $loader)
|
||||||
{
|
{
|
||||||
$this->loader = $loader;
|
$this->loader = $loader;
|
||||||
|
|
|
@ -25,21 +25,27 @@ class Perforce {
|
||||||
protected $p4branch;
|
protected $p4branch;
|
||||||
protected $process;
|
protected $process;
|
||||||
|
|
||||||
public function __construct($depot, $branch, $port, $path, ProcessExecutor $process = null, $p4user = null, $p4password = null) {
|
public function __construct($repoConfig, $port, $path, ProcessExecutor $process = NULL) {
|
||||||
$this->p4depot = $depot;
|
|
||||||
$this->p4branch = $branch;
|
|
||||||
$this->p4port = $port;
|
$this->p4port = $port;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
$this->process = $process ? : new ProcessExecutor;
|
$this->process = $process ? : new ProcessExecutor;
|
||||||
$fs = new Filesystem();
|
$fs = new Filesystem();
|
||||||
$fs->ensureDirectoryExists($path);
|
$fs->ensureDirectoryExists($path);
|
||||||
if (isset($p4user)){
|
|
||||||
$this->p4user = $p4user;
|
if (isset($repoConfig['depot'])) {
|
||||||
} else {
|
$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");
|
$this->p4user = $this->getP4variable("P4USER");
|
||||||
}
|
}
|
||||||
if (isset($p4password)){
|
if (isset($repoConfig['p4password'])) {
|
||||||
$this->p4password = $p4password;
|
$this->p4password = $repoConfig['p4password'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +53,10 @@ class Perforce {
|
||||||
return mt_rand(1000, 9999);
|
return mt_rand(1000, 9999);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function isWindows(){
|
||||||
|
return defined('PHP_WINDOWS_VERSION_BUILD');
|
||||||
|
}
|
||||||
|
|
||||||
protected function executeCommand($command) {
|
protected function executeCommand($command) {
|
||||||
$result = "";
|
$result = "";
|
||||||
$this->process->execute($command, $result);
|
$this->process->execute($command, $result);
|
||||||
|
@ -72,6 +82,10 @@ class Perforce {
|
||||||
return $this->p4port;
|
return $this->p4port;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function isStream() {
|
||||||
|
return (strcmp($this->p4depotType, "stream") === 0);
|
||||||
|
}
|
||||||
|
|
||||||
protected function getStream() {
|
protected function getStream() {
|
||||||
if (!isset($this->p4stream)) {
|
if (!isset($this->p4stream)) {
|
||||||
if ($this->isStream()) {
|
if ($this->isStream()) {
|
||||||
|
@ -107,19 +121,25 @@ class Perforce {
|
||||||
|
|
||||||
public function queryP4User(IOInterface $io) {
|
public function queryP4User(IOInterface $io) {
|
||||||
$this->getUser();
|
$this->getUser();
|
||||||
if (strlen($this->p4user) <= 0) {
|
if (strlen($this->p4user) > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->p4user = $this->getP4variable("P4USER");
|
||||||
|
if (strlen($this->p4user) > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
$this->p4user = $io->ask("Enter P4 User:");
|
$this->p4user = $io->ask("Enter P4 User:");
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ($this->isWindows()) {
|
||||||
$command = "p4 set P4USER=$this->p4user";
|
$command = "p4 set P4USER=$this->p4user";
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$command = "export P4USER=$this->p4user";
|
$command = "export P4USER=$this->p4user";
|
||||||
}
|
}
|
||||||
$result = $this->executeCommand($command);
|
$result = $this->executeCommand($command);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
protected function getP4variable($name) {
|
protected function getP4variable($name) {
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ($this->isWindows()) {
|
||||||
$command = "p4 set";
|
$command = "p4 set";
|
||||||
$result = $this->executeCommand($command);
|
$result = $this->executeCommand($command);
|
||||||
$resArray = explode("\n", $result);
|
$resArray = explode("\n", $result);
|
||||||
|
@ -127,21 +147,24 @@ class Perforce {
|
||||||
$fields = explode("=", $line);
|
$fields = explode("=", $line);
|
||||||
if (strcmp($name, $fields[0]) == 0) {
|
if (strcmp($name, $fields[0]) == 0) {
|
||||||
$index = strpos($fields[1], " ");
|
$index = strpos($fields[1], " ");
|
||||||
if ($index === false){
|
if ($index === FALSE) {
|
||||||
$value = $fields[1];
|
$value = $fields[1];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$value = substr($fields[1], 0, $index);
|
$value = substr($fields[1], 0, $index);
|
||||||
}
|
}
|
||||||
$value = trim($value);
|
$value = trim($value);
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
$command = 'echo $' . $name;
|
$command = 'echo $' . $name;
|
||||||
$result = trim($this->executeCommand($command));
|
$result = trim($this->executeCommand($command));
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function queryP4Password(IOInterface $io) {
|
protected function queryP4Password(IOInterface $io) {
|
||||||
|
@ -153,11 +176,8 @@ class Perforce {
|
||||||
$password = $io->askAndHideAnswer("Enter password for Perforce user " . $this->getUser() . ": ");
|
$password = $io->askAndHideAnswer("Enter password for Perforce user " . $this->getUser() . ": ");
|
||||||
}
|
}
|
||||||
$this->p4password = $password;
|
$this->p4password = $password;
|
||||||
return $password;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function isStream() {
|
return $password;
|
||||||
return (strcmp($this->p4depotType, "stream") === 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateP4Command($command, $useClient = TRUE) {
|
protected function generateP4Command($command, $useClient = TRUE) {
|
||||||
|
@ -179,6 +199,7 @@ class Perforce {
|
||||||
if ($index === FALSE) {
|
if ($index === FALSE) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,9 +271,10 @@ class Perforce {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$line = fgets($pipe);
|
$line = fgets($pipe);
|
||||||
while ($line != false){
|
while ($line != FALSE) {
|
||||||
$line = fgets($pipe);
|
$line = fgets($pipe);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +287,7 @@ class Perforce {
|
||||||
$command = $this->generateP4Command(" login -a");
|
$command = $this->generateP4Command(" login -a");
|
||||||
$process = proc_open($command, $descriptorspec, $pipes);
|
$process = proc_open($command, $descriptorspec, $pipes);
|
||||||
if (!is_resource($process)) {
|
if (!is_resource($process)) {
|
||||||
return false;
|
return FALSE;
|
||||||
}
|
}
|
||||||
fwrite($pipes[0], $password);
|
fwrite($pipes[0], $password);
|
||||||
fclose($pipes[0]);
|
fclose($pipes[0]);
|
||||||
|
@ -286,10 +308,11 @@ class Perforce {
|
||||||
$this->queryP4User($io);
|
$this->queryP4User($io);
|
||||||
if (!$this->isLoggedIn()) {
|
if (!$this->isLoggedIn()) {
|
||||||
$password = $this->queryP4Password($io);
|
$password = $this->queryP4Password($io);
|
||||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
if ($this->isWindows()) {
|
||||||
$this->windowsLogin($password);
|
$this->windowsLogin($password);
|
||||||
} else {
|
}
|
||||||
$command = "echo $password | ".$this->generateP4Command(" login -a", false);
|
else {
|
||||||
|
$command = "echo $password | " . $this->generateP4Command(" login -a", FALSE);
|
||||||
$this->executeCommand($command);
|
$this->executeCommand($command);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,6 +415,7 @@ class Perforce {
|
||||||
$tags[$fields[1]] = $this->getStream() . "@" . $fields[1];
|
$tags[$fields[1]] = $this->getStream() . "@" . $fields[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,98 +14,104 @@
|
||||||
|
|
||||||
namespace Composer\Test\Repository\Vcs;
|
namespace Composer\Test\Repository\Vcs;
|
||||||
|
|
||||||
#use Composer\Downloader\TransportException;
|
|
||||||
use Composer\Repository\Vcs\PerforceDriver;
|
use Composer\Repository\Vcs\PerforceDriver;
|
||||||
use Composer\Util\Filesystem;
|
use Composer\Util\Filesystem;
|
||||||
use Composer\Config;
|
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 $config;
|
||||||
private $io;
|
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 = new Config();
|
||||||
$this->config->merge(array(
|
$this->config->merge(
|
||||||
|
array(
|
||||||
'config' => array(
|
'config' => array(
|
||||||
'home' => sys_get_temp_dir() . '/composer-test',
|
'home' => $this->testPath,
|
||||||
),
|
),
|
||||||
));
|
)
|
||||||
$inputParameters = array();
|
);
|
||||||
$input = new ArrayInput($inputParameters);
|
|
||||||
$output = new ConsoleOutput();
|
$this->io = $this->getMock('Composer\IO\IOInterface');
|
||||||
$helperSet = new HelperSet();
|
$this->process = $this->getMock('Composer\Util\ProcessExecutor');
|
||||||
$this->io = new ConsoleIO($input, $output, $helperSet);
|
$this->remoteFileSystem = $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown()
|
public function tearDown() {
|
||||||
{
|
|
||||||
$fs = new Filesystem;
|
$fs = new Filesystem;
|
||||||
$fs->removeDirectory(sys_get_temp_dir() . '/composer-test');
|
$fs->removeDirectory($this->testPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPrivateRepository()
|
//Test:
|
||||||
{
|
//hasComposerFile
|
||||||
$repo_config = array(
|
|
||||||
'url' => "perforce.vuhl.root.mrc.local:3710",
|
|
||||||
'depot' => "lighthouse"
|
|
||||||
);
|
|
||||||
|
|
||||||
$vcs = new PerforceDriver($repo_config, $this->io, $this->config);
|
public function testInitializeCapturesVariablesFromRepoConfig() {
|
||||||
$result = $vcs->initialize();
|
$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 testInitializeLogsInAndConnectsClient() {
|
||||||
|
$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);
|
||||||
|
$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');
|
||||||
|
|
||||||
|
$driver->injectPerforce($perforce);
|
||||||
|
$driver->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testHasComposerFile() {
|
||||||
|
$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', 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);
|
$this->assertTrue($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetTags()
|
|
||||||
{
|
|
||||||
$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);
|
|
||||||
$tags = $vcs->getTags();
|
|
||||||
$this->assertTrue(empty($tags));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetSource()
|
|
||||||
{
|
|
||||||
$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();
|
|
||||||
$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