updated to replace double-quotes with single quotes
parent
8207518e04
commit
2e737ac439
|
@ -33,7 +33,7 @@ class PerforceDownloader extends VcsDownloader
|
|||
$ref = $package->getSourceReference();
|
||||
$label = $package->getPrettyVersion();
|
||||
|
||||
$this->io->write(" Cloning " . $ref);
|
||||
$this->io->write(' Cloning ' . $ref);
|
||||
$this->initPerforce($package, $path, $ref);
|
||||
$this->perforce->setStream($ref);
|
||||
$this->perforce->queryP4User($this->io);
|
||||
|
@ -74,7 +74,7 @@ class PerforceDownloader extends VcsDownloader
|
|||
*/
|
||||
public function getLocalChanges(PackageInterface $package, $path)
|
||||
{
|
||||
$this->io->write("Perforce driver does not check for local changes before overriding", true);
|
||||
$this->io->write('Perforce driver does not check for local changes before overriding', true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ class PerforceDriver extends VcsDriver
|
|||
public function initialize()
|
||||
{
|
||||
$this->depot = $this->repoConfig['depot'];
|
||||
$this->branch = "";
|
||||
$this->branch = '';
|
||||
if (isset($this->repoConfig['branch'])) {
|
||||
$this->branch = $this->repoConfig['branch'];
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ class PerforceDriver extends VcsDriver
|
|||
return;
|
||||
}
|
||||
|
||||
$repoDir = $this->config->get('cache-vcs-dir') . "/$this->depot";
|
||||
$repoDir = $this->config->get('cache-vcs-dir') . '/' . $this->depot;
|
||||
$this->perforce = Perforce::createPerforce($repoConfig, $this->getUrl(), $repoDir, $this->process);
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class PerforceDriver extends VcsDriver
|
|||
*/
|
||||
public function hasComposerFile($identifier)
|
||||
{
|
||||
$this->composerInfo = $this->perforce->getComposerInformation("//$this->depot/$identifier");
|
||||
$this->composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
|
||||
$this->composerInfoIdentifier = $identifier;
|
||||
$result = false;
|
||||
if (isset($this->composerInfo)) {
|
||||
|
|
|
@ -76,7 +76,7 @@ class Perforce
|
|||
if (isset($repoConfig['p4user'])) {
|
||||
$this->p4User = $repoConfig['p4user'];
|
||||
} else {
|
||||
$this->p4User = $this->getP4variable("P4USER");
|
||||
$this->p4User = $this->getP4variable('P4USER');
|
||||
}
|
||||
if (isset($repoConfig['p4password'])) {
|
||||
$this->p4Password = $repoConfig['p4password'];
|
||||
|
@ -101,7 +101,7 @@ class Perforce
|
|||
public function cleanupClientSpec()
|
||||
{
|
||||
$client = $this->getClient();
|
||||
$command = "p4 client -d $client";
|
||||
$command = 'p4 client -d $client';
|
||||
$this->executeCommand($command);
|
||||
$clientSpec = $this->getP4ClientSpec();
|
||||
$fileSystem = new FileSystem($this->process);
|
||||
|
@ -119,8 +119,8 @@ class Perforce
|
|||
public function getClient()
|
||||
{
|
||||
if (!isset($this->p4Client)) {
|
||||
$cleanStreamName = str_replace("@", "", str_replace("/", "_", str_replace("//", "", $this->getStream())));
|
||||
$this->p4Client = "composer_perforce_" . $this->uniquePerforceClientName . "_" . $cleanStreamName;
|
||||
$cleanStreamName = str_replace('@', '', str_replace('/', '_', str_replace('//', '', $this->getStream())));
|
||||
$this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
|
||||
}
|
||||
|
||||
return $this->p4Client;
|
||||
|
@ -139,25 +139,25 @@ class Perforce
|
|||
public function setStream($stream)
|
||||
{
|
||||
$this->p4Stream = $stream;
|
||||
$index = strrpos($stream, "/");
|
||||
$index = strrpos($stream, '/');
|
||||
//Stream format is //depot/stream, while non-streaming depot is //depot
|
||||
if ($index > 2) {
|
||||
$this->p4DepotType = "stream";
|
||||
$this->p4DepotType = 'stream';
|
||||
}
|
||||
}
|
||||
|
||||
public function isStream()
|
||||
{
|
||||
return (strcmp($this->p4DepotType, "stream") === 0);
|
||||
return (strcmp($this->p4DepotType, 'stream') === 0);
|
||||
}
|
||||
|
||||
public function getStream()
|
||||
{
|
||||
if (!isset($this->p4Stream)) {
|
||||
if ($this->isStream()) {
|
||||
$this->p4Stream = "//$this->p4Depot/$this->p4Branch";
|
||||
$this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
|
||||
} else {
|
||||
$this->p4Stream = "//$this->p4Depot";
|
||||
$this->p4Stream = '//' . $this->p4Depot;
|
||||
}
|
||||
}
|
||||
return $this->p4Stream;
|
||||
|
@ -165,7 +165,7 @@ class Perforce
|
|||
|
||||
public function getStreamWithoutLabel($stream)
|
||||
{
|
||||
$index = strpos($stream, "@");
|
||||
$index = strpos($stream, '@');
|
||||
if ($index === false) {
|
||||
return $stream;
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ class Perforce
|
|||
|
||||
public function getP4ClientSpec()
|
||||
{
|
||||
$p4clientSpec = $this->path . "/" . $this->getClient() . ".p4.spec";
|
||||
$p4clientSpec = $this->path . '/' . $this->getClient() . '.p4.spec';
|
||||
|
||||
return $p4clientSpec;
|
||||
}
|
||||
|
@ -191,15 +191,15 @@ class Perforce
|
|||
if (strlen($this->p4User) > 0) {
|
||||
return;
|
||||
}
|
||||
$this->p4User = $this->getP4variable("P4USER");
|
||||
$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 ($this->windowsFlag) {
|
||||
$command = "p4 set P4USER=$this->p4User";
|
||||
$command = 'p4 set P4USER=' . $this->p4User;
|
||||
} else {
|
||||
$command = "export P4USER=$this->p4User";
|
||||
$command = 'export P4USER=' . $this->p4User;
|
||||
}
|
||||
$result = $this->executeCommand($command);
|
||||
}
|
||||
|
@ -207,13 +207,13 @@ class Perforce
|
|||
protected function getP4variable($name)
|
||||
{
|
||||
if ($this->windowsFlag) {
|
||||
$command = "p4 set";
|
||||
$command = 'p4 set';
|
||||
$result = $this->executeCommand($command);
|
||||
$resArray = explode("\n", $result);
|
||||
$resArray = explode(PHP_EOL, $result);
|
||||
foreach ($resArray as $line) {
|
||||
$fields = explode("=", $line);
|
||||
$fields = explode('=', $line);
|
||||
if (strcmp($name, $fields[0]) == 0) {
|
||||
$index = strpos($fields[1], " ");
|
||||
$index = strpos($fields[1], ' ');
|
||||
if ($index === false) {
|
||||
$value = $fields[1];
|
||||
} else {
|
||||
|
@ -237,9 +237,9 @@ class Perforce
|
|||
if (isset($this->p4Password)) {
|
||||
return $this->p4Password;
|
||||
}
|
||||
$password = $this->getP4variable("P4PASSWD");
|
||||
$password = $this->getP4variable('P4PASSWD');
|
||||
if (strlen($password) <= 0) {
|
||||
$password = $io->askAndHideAnswer("Enter password for Perforce user " . $this->getUser() . ": ");
|
||||
$password = $io->askAndHideAnswer('Enter password for Perforce user ' . $this->getUser() . ': ');
|
||||
}
|
||||
$this->p4Password = $password;
|
||||
|
||||
|
@ -248,12 +248,12 @@ class Perforce
|
|||
|
||||
public function generateP4Command($command, $useClient = true)
|
||||
{
|
||||
$p4Command = "p4 ";
|
||||
$p4Command = $p4Command . "-u " . $this->getUser() . " ";
|
||||
$p4Command = 'p4 ';
|
||||
$p4Command = $p4Command . '-u ' . $this->getUser() . ' ';
|
||||
if ($useClient) {
|
||||
$p4Command = $p4Command . "-c " . $this->getClient() . " ";
|
||||
$p4Command = $p4Command . '-c ' . $this->getClient() . ' ';
|
||||
}
|
||||
$p4Command = $p4Command . "-p " . $this->getPort() . " ";
|
||||
$p4Command = $p4Command . '-p ' . $this->getPort() . ' ';
|
||||
$p4Command = $p4Command . $command;
|
||||
|
||||
return $p4Command;
|
||||
|
@ -261,7 +261,7 @@ class Perforce
|
|||
|
||||
public function isLoggedIn()
|
||||
{
|
||||
$command = $this->generateP4Command("login -s", false);
|
||||
$command = $this->generateP4Command('login -s', false);
|
||||
$result = trim($this->executeCommand($command));
|
||||
$index = strpos($result, $this->getUser());
|
||||
if ($index === false) {
|
||||
|
@ -272,7 +272,7 @@ class Perforce
|
|||
|
||||
public function connectClient()
|
||||
{
|
||||
$p4CreateClientCommand = $this->generateP4Command("client -i < " . $this->getP4ClientSpec());
|
||||
$p4CreateClientCommand = $this->generateP4Command('client -i < ' . $this->getP4ClientSpec());
|
||||
$this->executeCommand($p4CreateClientCommand);
|
||||
}
|
||||
|
||||
|
@ -281,12 +281,12 @@ class Perforce
|
|||
$prevDir = getcwd();
|
||||
chdir($this->path);
|
||||
|
||||
$this->executeCommand("pwd");
|
||||
$this->executeCommand('pwd');
|
||||
|
||||
$p4SyncCommand = $this->generateP4Command("sync -f ");
|
||||
$p4SyncCommand = $this->generateP4Command('sync -f ');
|
||||
if (isset($label)) {
|
||||
if (strcmp($label, "dev-master") != 0) {
|
||||
$p4SyncCommand = $p4SyncCommand . "@" . $label;
|
||||
if (strcmp($label, 'dev-master') != 0) {
|
||||
$p4SyncCommand = $p4SyncCommand . '@' . $label;
|
||||
}
|
||||
}
|
||||
$this->executeCommand($p4SyncCommand);
|
||||
|
@ -296,27 +296,27 @@ class Perforce
|
|||
|
||||
public function writeClientSpecToFile($spec)
|
||||
{
|
||||
fwrite($spec, "Client: " . $this->getClient() . "\n\n");
|
||||
fwrite($spec, "Update: " . date("Y/m/d H:i:s") . "\n\n");
|
||||
fwrite($spec, "Access: " . date("Y/m/d H:i:s") . "\n");
|
||||
fwrite($spec, "Owner: " . $this->getUser() . "\n\n");
|
||||
fwrite($spec, "Description:\n");
|
||||
fwrite($spec, " Created by " . $this->getUser() . " from composer.\n\n");
|
||||
fwrite($spec, "Root: " . $this->getPath() . "\n\n");
|
||||
fwrite($spec, "Options: noallwrite noclobber nocompress unlocked modtime rmdir\n\n");
|
||||
fwrite($spec, "SubmitOptions: revertunchanged\n\n");
|
||||
fwrite($spec, "LineEnd: local\n\n");
|
||||
fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL );
|
||||
fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'Description:' . PHP_EOL);
|
||||
fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
|
||||
fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
|
||||
if ($this->isStream()) {
|
||||
fwrite($spec, "Stream:\n");
|
||||
fwrite($spec, " " . $this->getStreamWithoutLabel($this->p4Stream) . "\n");
|
||||
fwrite($spec, 'Stream:' . PHP_EOL);
|
||||
fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
|
||||
} else {
|
||||
fwrite(
|
||||
$spec,
|
||||
"View: " . $this->getStream() . "/... //" . $this->getClient() . "/" . str_replace(
|
||||
"//",
|
||||
"",
|
||||
'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/' . str_replace(
|
||||
'//',
|
||||
'',
|
||||
$this->getStream()
|
||||
) . "/... \n"
|
||||
) . '/... ' . PHP_EOL
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -351,11 +351,11 @@ class Perforce
|
|||
public function windowsLogin($password)
|
||||
{
|
||||
$descriptorspec = array(
|
||||
0 => array("pipe", "r"),
|
||||
1 => array("pipe", "w"),
|
||||
2 => array("pipe", "a")
|
||||
0 => array('pipe', 'r'),
|
||||
1 => array('pipe', 'w'),
|
||||
2 => array('pipe', 'a')
|
||||
);
|
||||
$command = $this->generateP4Command(" login -a");
|
||||
$command = $this->generateP4Command(' login -a');
|
||||
$process = proc_open($command, $descriptorspec, $pipes);
|
||||
if (!is_resource($process)) {
|
||||
return false;
|
||||
|
@ -363,8 +363,8 @@ class Perforce
|
|||
fwrite($pipes[0], $password);
|
||||
fclose($pipes[0]);
|
||||
|
||||
$this->read($pipes[1], "Output");
|
||||
$this->read($pipes[2], "Error");
|
||||
$this->read($pipes[1], 'Output');
|
||||
$this->read($pipes[2], 'Error');
|
||||
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
|
@ -383,7 +383,7 @@ class Perforce
|
|||
if ($this->windowsFlag) {
|
||||
$this->windowsLogin($password);
|
||||
} else {
|
||||
$command = "echo $password | " . $this->generateP4Command(" login -a", false);
|
||||
$command = 'echo ' . $password . ' | ' . $this->generateP4Command(' login -a', false);
|
||||
$this->executeCommand($command);
|
||||
}
|
||||
}
|
||||
|
@ -391,16 +391,16 @@ class Perforce
|
|||
|
||||
public static function checkServerExists($url, ProcessExecutor $processExecutor)
|
||||
{
|
||||
$result = "";
|
||||
$processExecutor->execute("p4 -p $url info -s", $result);
|
||||
return false === strpos($result, "error");
|
||||
$result = '';
|
||||
$processExecutor->execute('p4 -p ' . $url . ' info -s', $result);
|
||||
return false === strpos($result, 'error');
|
||||
}
|
||||
|
||||
public function getComposerInformation($identifier)
|
||||
{
|
||||
$index = strpos($identifier, "@");
|
||||
$index = strpos($identifier, '@');
|
||||
if ($index === false) {
|
||||
$composerJson = "$identifier/composer.json";
|
||||
$composerJson = $identifier. '/composer.json';
|
||||
|
||||
return $this->getComposerInformationFromPath($composerJson);
|
||||
}
|
||||
|
@ -409,11 +409,11 @@ class Perforce
|
|||
|
||||
public function getComposerInformationFromPath($composerJson)
|
||||
{
|
||||
$command = $this->generateP4Command(" print $composerJson");
|
||||
$command = $this->generateP4Command(' print ' . $composerJson);
|
||||
$result = $this->executeCommand($command);
|
||||
$index = strpos($result, "{");
|
||||
$index = strpos($result, '{');
|
||||
if ($index === false) {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
if ($index >= 0) {
|
||||
$rawData = substr($result, $index);
|
||||
|
@ -422,22 +422,22 @@ class Perforce
|
|||
return $composer_info;
|
||||
}
|
||||
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
public function getComposerInformationFromLabel($identifier, $index)
|
||||
{
|
||||
$composerJsonPath = substr($identifier, 0, $index) . "/composer.json" . substr($identifier, $index);
|
||||
$command = $this->generateP4Command(" files $composerJsonPath", false);
|
||||
$composerJsonPath = substr($identifier, 0, $index) . '/composer.json' . substr($identifier, $index);
|
||||
$command = $this->generateP4Command(' files ' . $composerJsonPath, false);
|
||||
$result = $this->executeCommand($command);
|
||||
$index2 = strpos($result, "no such file(s).");
|
||||
$index2 = strpos($result, 'no such file(s).');
|
||||
if ($index2 === false) {
|
||||
$index3 = strpos($result, "change");
|
||||
$index3 = strpos($result, 'change');
|
||||
if (!($index3 === false)) {
|
||||
$phrase = trim(substr($result, $index3));
|
||||
$fields = explode(" ", $phrase);
|
||||
$fields = explode(' ', $phrase);
|
||||
$id = $fields[1];
|
||||
$composerJson = substr($identifier, 0, $index) . "/composer.json@" . $id;
|
||||
$composerJson = substr($identifier, 0, $index) . '/composer.json@' . $id;
|
||||
|
||||
return $this->getComposerInformationFromPath($composerJson);
|
||||
}
|
||||
|
@ -452,13 +452,13 @@ class Perforce
|
|||
if (!$this->isStream()) {
|
||||
$possibleBranches[$this->p4Branch] = $this->getStream();
|
||||
} else {
|
||||
$command = $this->generateP4Command("streams //$this->p4Depot/...");
|
||||
$command = $this->generateP4Command('streams //' . $this->p4Depot . '/...');
|
||||
$result = $this->executeCommand($command);
|
||||
$resArray = explode("\n", $result);
|
||||
$resArray = explode(PHP_EOL, $result);
|
||||
foreach ($resArray as $line) {
|
||||
$resBits = explode(" ", $line);
|
||||
$resBits = explode(' ', $line);
|
||||
if (count($resBits) > 4) {
|
||||
$branch = preg_replace("/[^A-Za-z0-9 ]/", '', $resBits[4]);
|
||||
$branch = preg_replace('/[^A-Za-z0-9 ]/', '', $resBits[4]);
|
||||
$possibleBranches[$branch] = $resBits[1];
|
||||
}
|
||||
}
|
||||
|
@ -471,15 +471,15 @@ class Perforce
|
|||
|
||||
public function getTags()
|
||||
{
|
||||
$command = $this->generateP4Command("labels");
|
||||
$command = $this->generateP4Command('labels');
|
||||
$result = $this->executeCommand($command);
|
||||
$resArray = explode("\n", $result);
|
||||
$resArray = explode(PHP_EOL, $result);
|
||||
$tags = array();
|
||||
foreach ($resArray as $line) {
|
||||
$index = strpos($line, "Label");
|
||||
$index = strpos($line, 'Label');
|
||||
if (!($index === false)) {
|
||||
$fields = explode(" ", $line);
|
||||
$tags[$fields[1]] = $this->getStream() . "@" . $fields[1];
|
||||
$fields = explode(' ', $line);
|
||||
$tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -488,13 +488,13 @@ class Perforce
|
|||
|
||||
public function checkStream()
|
||||
{
|
||||
$command = $this->generateP4Command("depots", false);
|
||||
$command = $this->generateP4Command('depots', false);
|
||||
$result = $this->executeCommand($command);
|
||||
$resArray = explode("\n", $result);
|
||||
$resArray = explode(PHP_EOL, $result);
|
||||
foreach ($resArray as $line) {
|
||||
$index = strpos($line, "Depot");
|
||||
$index = strpos($line, 'Depot');
|
||||
if (!($index === false)) {
|
||||
$fields = explode(" ", $line);
|
||||
$fields = explode(' ', $line);
|
||||
if (strcmp($this->p4Depot, $fields[1]) === 0) {
|
||||
$this->p4DepotType = $fields[3];
|
||||
|
||||
|
@ -508,17 +508,17 @@ class Perforce
|
|||
|
||||
protected function getChangeList($reference)
|
||||
{
|
||||
$index = strpos($reference, "@");
|
||||
$index = strpos($reference, '@');
|
||||
if ($index === false) {
|
||||
return;
|
||||
}
|
||||
$label = substr($reference, $index);
|
||||
$command = $this->generateP4Command(" changes -m1 $label");
|
||||
$command = $this->generateP4Command(' changes -m1 ' . $label);
|
||||
$changes = $this->executeCommand($command);
|
||||
if (strpos($changes, "Change") !== 0) {
|
||||
if (strpos($changes, 'Change') !== 0) {
|
||||
return;
|
||||
}
|
||||
$fields = explode(" ", $changes);
|
||||
$fields = explode(' ', $changes);
|
||||
$changeList = $fields[1];
|
||||
return $changeList;
|
||||
}
|
||||
|
@ -533,9 +533,9 @@ class Perforce
|
|||
if ($toChangeList == null) {
|
||||
return;
|
||||
}
|
||||
$index = strpos($fromReference, "@");
|
||||
$main = substr($fromReference, 0, $index) . "/...";
|
||||
$command = $this->generateP4Command("filelog $main@$fromChangeList,$toChangeList");
|
||||
$index = strpos($fromReference, '@');
|
||||
$main = substr($fromReference, 0, $index) . '/...';
|
||||
$command = $this->generateP4Command('filelog ' . $main . '@' . $fromChangeList. ',' . $toChangeList);
|
||||
$result = $this->executeCommand($command);
|
||||
return $result;
|
||||
}
|
||||
|
|
|
@ -54,10 +54,10 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
|
|||
);
|
||||
$package->expects($this->at(0))
|
||||
->method('getSourceReference')
|
||||
->will($this->returnValue("SOURCE_REF"));
|
||||
->will($this->returnValue('SOURCE_REF'));
|
||||
$package->expects($this->at(1))
|
||||
->method('getPrettyVersion')
|
||||
->will($this->returnValue("100"));
|
||||
->will($this->returnValue('100'));
|
||||
$package->expects($this->at(2))
|
||||
->method('getRepository')
|
||||
->will($this->returnValue($repository));
|
||||
|
@ -70,17 +70,17 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
|
|||
public function testDoDownload()
|
||||
{
|
||||
$downloader = new PerforceDownloader($this->io, $this->config);
|
||||
$repoConfig = array("depot" => "TEST_DEPOT", "branch" => "TEST_BRANCH", "p4user" => "TEST_USER");
|
||||
$port = "TEST_PORT";
|
||||
$path = "TEST_PATH";
|
||||
$repoConfig = array('depot' => 'TEST_DEPOT', 'branch' => 'TEST_BRANCH', 'p4user' => 'TEST_USER');
|
||||
$port = 'TEST_PORT';
|
||||
$path = 'TEST_PATH';
|
||||
$process = $this->getmock('Composer\Util\ProcessExecutor');
|
||||
$perforce = $this->getMock(
|
||||
'Composer\Util\Perforce',
|
||||
array('setStream', 'queryP4User', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase'),
|
||||
array($repoConfig, $port, $path, $process, true, "TEST")
|
||||
array($repoConfig, $port, $path, $process, true, 'TEST')
|
||||
);
|
||||
$ref = "SOURCE_REF";
|
||||
$label = "LABEL";
|
||||
$ref = 'SOURCE_REF';
|
||||
$label = 'LABEL';
|
||||
$perforce->expects($this->at(0))
|
||||
->method('setStream')
|
||||
->with($this->equalTo($ref));
|
||||
|
|
|
@ -67,14 +67,14 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
|||
'path' => $this->testPath,
|
||||
$process,
|
||||
true,
|
||||
"TEST"
|
||||
'TEST'
|
||||
);
|
||||
$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());
|
||||
$this->assertEquals('TEST_PERFORCE_URL', $driver->getUrl());
|
||||
$this->assertEquals('TEST_DEPOT_CONFIG', $driver->getDepot());
|
||||
$this->assertEquals('TEST_BRANCH_CONFIG', $driver->getBranch());
|
||||
}
|
||||
|
||||
public function testInitializeLogsInAndConnectsClient()
|
||||
|
@ -92,7 +92,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
|||
->with($this->io);
|
||||
$perforce->expects($this->at(1))
|
||||
->method('checkStream')
|
||||
->with($this->equalTo("TEST_DEPOT_CONFIG"));
|
||||
->with($this->equalTo('TEST_DEPOT_CONFIG'));
|
||||
$perforce->expects($this->at(2))
|
||||
->method('writeP4ClientSpec');
|
||||
$perforce->expects($this->at(3))
|
||||
|
@ -118,16 +118,16 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
|
|||
'path' => $this->testPath,
|
||||
$process,
|
||||
true,
|
||||
"TEST"
|
||||
'TEST'
|
||||
);
|
||||
$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"));
|
||||
->with($this->equalTo('//TEST_DEPOT_CONFIG/TEST_IDENTIFIER'))
|
||||
->will($this->returnValue('Some json stuff'));
|
||||
$driver->injectPerforce($perforce);
|
||||
$driver->initialize();
|
||||
$identifier = "TEST_IDENTIFIER";
|
||||
$identifier = 'TEST_IDENTIFIER';
|
||||
$result = $driver->hasComposerFile($identifier);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
|
|
@ -28,12 +28,12 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||
$repoConfig = array(
|
||||
"depot" => "depot",
|
||||
"branch" => "branch",
|
||||
"p4user" => "user",
|
||||
"unique_perforce_client_name" => "TEST"
|
||||
'depot' => 'depot',
|
||||
'branch' => 'branch',
|
||||
'p4user' => 'user',
|
||||
'unique_perforce_client_name' => 'TEST'
|
||||
);
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true);
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true);
|
||||
}
|
||||
|
||||
public function testGetClientWithoutStream()
|
||||
|
@ -42,7 +42,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
$hostname = gethostname();
|
||||
$timestamp = time();
|
||||
|
||||
$expected = "composer_perforce_TEST_depot";
|
||||
$expected = 'composer_perforce_TEST_depot';
|
||||
$this->assertEquals($expected, $client);
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
$client = $this->perforce->getClient();
|
||||
|
||||
$expected = "composer_perforce_TEST_depot_branch";
|
||||
$expected = 'composer_perforce_TEST_depot_branch';
|
||||
$this->assertEquals($expected, $client);
|
||||
}
|
||||
|
||||
|
@ -67,34 +67,34 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
$this->setPerforceToStream();
|
||||
|
||||
$stream = $this->perforce->getStream();
|
||||
$this->assertEquals("//depot/branch", $stream);
|
||||
$this->assertEquals('//depot/branch', $stream);
|
||||
}
|
||||
|
||||
|
||||
public function testGetStreamWithoutLabelWithStreamWithoutLabel()
|
||||
{
|
||||
$stream = $this->perforce->getStreamWithoutLabel("//depot/branch");
|
||||
$this->assertEquals("//depot/branch", $stream);
|
||||
$stream = $this->perforce->getStreamWithoutLabel('//depot/branch');
|
||||
$this->assertEquals('//depot/branch', $stream);
|
||||
}
|
||||
|
||||
public function testGetStreamWithoutLabelWithStreamWithLabel()
|
||||
{
|
||||
$stream = $this->perforce->getStreamWithoutLabel("//depot/branching@label");
|
||||
$this->assertEquals("//depot/branching", $stream);
|
||||
$stream = $this->perforce->getStreamWithoutLabel('//depot/branching@label');
|
||||
$this->assertEquals('//depot/branching', $stream);
|
||||
}
|
||||
|
||||
public function testGetClientSpec()
|
||||
{
|
||||
$clientSpec = $this->perforce->getP4ClientSpec();
|
||||
$expected = "path/composer_perforce_TEST_depot.p4.spec";
|
||||
$expected = 'path/composer_perforce_TEST_depot.p4.spec';
|
||||
$this->assertEquals($expected, $clientSpec);
|
||||
}
|
||||
|
||||
public function testGenerateP4Command()
|
||||
{
|
||||
$command = "do something";
|
||||
$command = 'do something';
|
||||
$p4Command = $this->perforce->generateP4Command($command);
|
||||
$expected = "p4 -u user -c composer_perforce_TEST_depot -p port do something";
|
||||
$expected = 'p4 -u user -c composer_perforce_TEST_depot -p port do something';
|
||||
$this->assertEquals($expected, $p4Command);
|
||||
}
|
||||
|
||||
|
@ -102,40 +102,40 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch", "p4user" => "TEST_USER");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch', 'p4user' => 'TEST_USER');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true, 'TEST');
|
||||
|
||||
$this->perforce->queryP4user($io);
|
||||
$this->assertEquals("TEST_USER", $this->perforce->getUser());
|
||||
$this->assertEquals('TEST_USER', $this->perforce->getUser());
|
||||
}
|
||||
|
||||
public function testQueryP4UserWithUserSetInP4VariablesWithWindowsOS()
|
||||
{
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true, 'TEST');
|
||||
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedCommand = "p4 set";
|
||||
$expectedCommand = 'p4 set';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "P4USER=TEST_P4VARIABLE_USER\n";
|
||||
$output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL ;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$this->perforce->queryP4user($io);
|
||||
$this->assertEquals("TEST_P4VARIABLE_USER", $this->perforce->getUser());
|
||||
$this->assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser());
|
||||
}
|
||||
|
||||
public function testQueryP4UserWithUserSetInP4VariablesNotWindowsOS()
|
||||
{
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, 'TEST');
|
||||
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedCommand = 'echo $P4USER';
|
||||
|
@ -145,43 +145,43 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "TEST_P4VARIABLE_USER\n";
|
||||
$output = 'TEST_P4VARIABLE_USER' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$this->perforce->queryP4user($io);
|
||||
$this->assertEquals("TEST_P4VARIABLE_USER", $this->perforce->getUser());
|
||||
$this->assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser());
|
||||
}
|
||||
|
||||
public function testQueryP4UserQueriesForUser()
|
||||
{
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, 'TEST');
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedQuestion = "Enter P4 User:";
|
||||
$expectedQuestion = 'Enter P4 User:';
|
||||
$io->expects($this->at(0))
|
||||
->method('ask')
|
||||
->with($this->equalTo($expectedQuestion))
|
||||
->will($this->returnValue("TEST_QUERY_USER"));
|
||||
->will($this->returnValue('TEST_QUERY_USER'));
|
||||
|
||||
$this->perforce->queryP4user($io);
|
||||
$this->assertEquals("TEST_QUERY_USER", $this->perforce->getUser());
|
||||
$this->assertEquals('TEST_QUERY_USER', $this->perforce->getUser());
|
||||
}
|
||||
|
||||
public function testQueryP4UserStoresResponseToQueryForUserWithWindows()
|
||||
{
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true, 'TEST');
|
||||
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedQuestion = "Enter P4 User:";
|
||||
$expectedQuestion = 'Enter P4 User:';
|
||||
$io->expects($this->at(0))
|
||||
->method('ask')
|
||||
->with($this->equalTo($expectedQuestion))
|
||||
->will($this->returnValue("TEST_QUERY_USER"));
|
||||
$expectedCommand = "p4 set P4USER=TEST_QUERY_USER";
|
||||
->will($this->returnValue('TEST_QUERY_USER'));
|
||||
$expectedCommand = 'p4 set P4USER=TEST_QUERY_USER';
|
||||
$this->processExecutor->expects($this->at(1))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
|
@ -192,16 +192,16 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testQueryP4UserStoresResponseToQueryForUserWithoutWindows()
|
||||
{
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, 'TEST');
|
||||
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedQuestion = "Enter P4 User:";
|
||||
$expectedQuestion = 'Enter P4 User:';
|
||||
$io->expects($this->at(0))
|
||||
->method('ask')
|
||||
->with($this->equalTo($expectedQuestion))
|
||||
->will($this->returnValue("TEST_QUERY_USER"));
|
||||
$expectedCommand = "export P4USER=TEST_QUERY_USER";
|
||||
->will($this->returnValue('TEST_QUERY_USER'));
|
||||
$expectedCommand = 'export P4USER=TEST_QUERY_USER';
|
||||
$this->processExecutor->expects($this->at(1))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
|
@ -213,43 +213,43 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
public function testQueryP4PasswordWithPasswordAlreadySet()
|
||||
{
|
||||
$repoConfig = array(
|
||||
"depot" => "depot",
|
||||
"branch" => "branch",
|
||||
"p4user" => "user",
|
||||
"p4password" => "TEST_PASSWORD"
|
||||
'depot' => 'depot',
|
||||
'branch' => 'branch',
|
||||
'p4user' => 'user',
|
||||
'p4password' => 'TEST_PASSWORD'
|
||||
);
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, 'TEST');
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
|
||||
$password = $this->perforce->queryP4Password($io);
|
||||
$this->assertEquals("TEST_PASSWORD", $password);
|
||||
$this->assertEquals('TEST_PASSWORD', $password);
|
||||
}
|
||||
|
||||
public function testQueryP4PasswordWithPasswordSetInP4VariablesWithWindowsOS()
|
||||
{
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
|
||||
$expectedCommand = "p4 set";
|
||||
$expectedCommand = 'p4 set';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "P4PASSWD=TEST_P4VARIABLE_PASSWORD\n";
|
||||
$output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$password = $this->perforce->queryP4Password($io);
|
||||
$this->assertEquals("TEST_P4VARIABLE_PASSWORD", $password);
|
||||
$this->assertEquals('TEST_P4VARIABLE_PASSWORD', $password);
|
||||
}
|
||||
|
||||
public function testQueryP4PasswordWithPasswordSetInP4VariablesNotWindowsOS()
|
||||
{
|
||||
$repoConfig = array("depot" => "depot", "branch" => "branch", "p4user" => "user");
|
||||
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
||||
$repoConfig = array('depot' => 'depot', 'branch' => 'branch', 'p4user' => 'user');
|
||||
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, 'TEST');
|
||||
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedCommand = 'echo $P4PASSWD';
|
||||
|
@ -259,35 +259,36 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "TEST_P4VARIABLE_PASSWORD\n";
|
||||
$output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$password = $this->perforce->queryP4Password($io);
|
||||
$this->assertEquals("TEST_P4VARIABLE_PASSWORD", $password);
|
||||
$this->assertEquals('TEST_P4VARIABLE_PASSWORD', $password);
|
||||
}
|
||||
|
||||
public function testQueryP4PasswordQueriesForPassword()
|
||||
{
|
||||
$io = $this->getMock('Composer\IO\IOInterface');
|
||||
$expectedQuestion = "Enter password for Perforce user user: ";
|
||||
$expectedQuestion = 'Enter password for Perforce user user: ';
|
||||
$io->expects($this->at(0))
|
||||
->method('askAndHideAnswer')
|
||||
->with($this->equalTo($expectedQuestion))
|
||||
->will($this->returnValue("TEST_QUERY_PASSWORD"));
|
||||
->will($this->returnValue('TEST_QUERY_PASSWORD'));
|
||||
|
||||
$password = $this->perforce->queryP4Password($io);
|
||||
$this->assertEquals("TEST_QUERY_PASSWORD", $password);
|
||||
$this->assertEquals('TEST_QUERY_PASSWORD', $password);
|
||||
}
|
||||
|
||||
public function testWriteP4ClientSpecWithoutStream()
|
||||
{
|
||||
$stream = fopen("php://memory", 'w+');
|
||||
$stream = fopen('php://memory', 'w+');
|
||||
$this->perforce->writeClientSpecToFile($stream);
|
||||
|
||||
rewind($stream);
|
||||
|
||||
$expectedArray = $this->getExpectedClientSpec(false);
|
||||
try {
|
||||
foreach ($expectedArray as $expected) {
|
||||
|
@ -304,7 +305,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
public function testWriteP4ClientSpecWithStream()
|
||||
{
|
||||
$this->setPerforceToStream();
|
||||
$stream = fopen("php://memory", 'w+');
|
||||
$stream = fopen('php://memory', 'w+');
|
||||
|
||||
$this->perforce->writeClientSpecToFile($stream);
|
||||
rewind($stream);
|
||||
|
@ -324,7 +325,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testIsLoggedIn()
|
||||
{
|
||||
$expectedCommand = "p4 -u user -p port login -s";
|
||||
$expectedCommand = 'p4 -u user -p port login -s';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand), $this->equalTo(null))
|
||||
|
@ -335,7 +336,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
public function testConnectClient()
|
||||
{
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot -p port client -i < path/composer_perforce_TEST_depot.p4.spec";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port client -i < path/composer_perforce_TEST_depot.p4.spec';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand), $this->equalTo(null))
|
||||
|
@ -348,74 +349,74 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->setPerforceToStream();
|
||||
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot_branch -p port streams //depot/...";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port streams //depot/...';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "Stream //depot/branch mainline none 'branch'\n";
|
||||
$output = 'Stream //depot/branch mainline none \'branch\'' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$branches = $this->perforce->getBranches();
|
||||
$this->assertEquals("//depot/branch", $branches['master']);
|
||||
$this->assertEquals('//depot/branch', $branches['master']);
|
||||
}
|
||||
|
||||
public function testGetBranchesWithoutStream()
|
||||
{
|
||||
$branches = $this->perforce->getBranches();
|
||||
$this->assertEquals("//depot", $branches['master']);
|
||||
$this->assertEquals('//depot', $branches['master']);
|
||||
}
|
||||
|
||||
public function testGetTagsWithoutStream()
|
||||
{
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot -p port labels";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port labels';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "Label 0.0.1 2013/07/31 'First Label!'\nLabel 0.0.2 2013/08/01 'Second Label!'\n";
|
||||
$output = 'Label 0.0.1 2013/07/31 \'First Label!\'' . PHP_EOL . 'Label 0.0.2 2013/08/01 \'Second Label!\'' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$tags = $this->perforce->getTags();
|
||||
$this->assertEquals("//depot@0.0.1", $tags['0.0.1']);
|
||||
$this->assertEquals("//depot@0.0.2", $tags['0.0.2']);
|
||||
$this->assertEquals('//depot@0.0.1', $tags['0.0.1']);
|
||||
$this->assertEquals('//depot@0.0.2', $tags['0.0.2']);
|
||||
}
|
||||
|
||||
public function testGetTagsWithStream()
|
||||
{
|
||||
$this->setPerforceToStream();
|
||||
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot_branch -p port labels";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port labels';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "Label 0.0.1 2013/07/31 'First Label!'\nLabel 0.0.2 2013/08/01 'Second Label!'\n";
|
||||
$output = 'Label 0.0.1 2013/07/31 \'First Label!\'' . PHP_EOL . 'Label 0.0.2 2013/08/01 \'Second Label!\'' . PHP_EOL;
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$tags = $this->perforce->getTags();
|
||||
$this->assertEquals("//depot/branch@0.0.1", $tags['0.0.1']);
|
||||
$this->assertEquals("//depot/branch@0.0.2", $tags['0.0.2']);
|
||||
$this->assertEquals('//depot/branch@0.0.1', $tags['0.0.1']);
|
||||
$this->assertEquals('//depot/branch@0.0.2', $tags['0.0.2']);
|
||||
}
|
||||
|
||||
public function testCheckStreamWithoutStream()
|
||||
{
|
||||
$result = $this->perforce->checkStream("depot");
|
||||
$result = $this->perforce->checkStream('depot');
|
||||
$this->assertFalse($result);
|
||||
$this->assertFalse($this->perforce->isStream());
|
||||
}
|
||||
|
@ -426,19 +427,19 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "Depot depot 2013/06/25 stream /p4/1/depots/depot/... 'Created by Me'";
|
||||
$output = 'Depot depot 2013/06/25 stream /p4/1/depots/depot/... \'Created by Me\'';
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
$result = $this->perforce->checkStream("depot");
|
||||
$result = $this->perforce->checkStream('depot');
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue($this->perforce->isStream());
|
||||
}
|
||||
|
||||
public function testGetComposerInformationWithoutLabelWithoutStream()
|
||||
{
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot -p port print //depot/composer.json";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port print //depot/composer.json';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
|
@ -451,32 +452,32 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
)
|
||||
);
|
||||
|
||||
$result = $this->perforce->getComposerInformation("//depot");
|
||||
$result = $this->perforce->getComposerInformation('//depot');
|
||||
$expected = array(
|
||||
"name" => "test/perforce",
|
||||
"description" => "Basic project for testing",
|
||||
"minimum-stability" => "dev",
|
||||
"autoload" => array("psr-0" => array())
|
||||
'name' => 'test/perforce',
|
||||
'description' => 'Basic project for testing',
|
||||
'minimum-stability' => 'dev',
|
||||
'autoload' => array('psr-0' => array())
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testGetComposerInformationWithLabelWithoutStream()
|
||||
{
|
||||
$expectedCommand = "p4 -u user -p port files //depot/composer.json@0.0.1";
|
||||
$expectedCommand = 'p4 -u user -p port files //depot/composer.json@0.0.1';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "//depot/composer.json#1 - branch change 10001 (text)";
|
||||
$output = '//depot/composer.json#1 - branch change 10001 (text)';
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot -p port print //depot/composer.json@10001";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port print //depot/composer.json@10001';
|
||||
$this->processExecutor->expects($this->at(1))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
|
@ -489,13 +490,13 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
)
|
||||
);
|
||||
|
||||
$result = $this->perforce->getComposerInformation("//depot@0.0.1");
|
||||
$result = $this->perforce->getComposerInformation('//depot@0.0.1');
|
||||
|
||||
$expected = array(
|
||||
"name" => "test/perforce",
|
||||
"description" => "Basic project for testing",
|
||||
"minimum-stability" => "dev",
|
||||
"autoload" => array("psr-0" => array())
|
||||
'name' => 'test/perforce',
|
||||
'description' => 'Basic project for testing',
|
||||
'minimum-stability' => 'dev',
|
||||
'autoload' => array('psr-0' => array())
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
@ -504,7 +505,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$this->setPerforceToStream();
|
||||
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot_branch -p port print //depot/branch/composer.json";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port print //depot/branch/composer.json';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
|
@ -517,13 +518,13 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
)
|
||||
);
|
||||
|
||||
$result = $this->perforce->getComposerInformation("//depot/branch");
|
||||
$result = $this->perforce->getComposerInformation('//depot/branch');
|
||||
|
||||
$expected = array(
|
||||
"name" => "test/perforce",
|
||||
"description" => "Basic project for testing",
|
||||
"minimum-stability" => "dev",
|
||||
"autoload" => array("psr-0" => array())
|
||||
'name' => 'test/perforce',
|
||||
'description' => 'Basic project for testing',
|
||||
'minimum-stability' => 'dev',
|
||||
'autoload' => array('psr-0' => array())
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
@ -531,20 +532,20 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
public function testGetComposerInformationWithLabelWithStream()
|
||||
{
|
||||
$this->setPerforceToStream();
|
||||
$expectedCommand = "p4 -u user -p port files //depot/branch/composer.json@0.0.1";
|
||||
$expectedCommand = 'p4 -u user -p port files //depot/branch/composer.json@0.0.1';
|
||||
$this->processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will(
|
||||
$this->returnCallback(
|
||||
function ($command, &$output) {
|
||||
$output = "//depot/composer.json#1 - branch change 10001 (text)";
|
||||
$output = '//depot/composer.json#1 - branch change 10001 (text)';
|
||||
return true;
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot_branch -p port print //depot/branch/composer.json@10001";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port print //depot/branch/composer.json@10001';
|
||||
$this->processExecutor->expects($this->at(1))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
|
@ -557,51 +558,51 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
)
|
||||
);
|
||||
|
||||
$result = $this->perforce->getComposerInformation("//depot/branch@0.0.1");
|
||||
$result = $this->perforce->getComposerInformation('//depot/branch@0.0.1');
|
||||
|
||||
$expected = array(
|
||||
"name" => "test/perforce",
|
||||
"description" => "Basic project for testing",
|
||||
"minimum-stability" => "dev",
|
||||
"autoload" => array("psr-0" => array())
|
||||
'name' => 'test/perforce',
|
||||
'description' => 'Basic project for testing',
|
||||
'minimum-stability' => 'dev',
|
||||
'autoload' => array('psr-0' => array())
|
||||
);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
||||
public function testSyncCodeBaseWithoutStream()
|
||||
{
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot -p port sync -f @label";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot -p port sync -f @label';
|
||||
$this->processExecutor->expects($this->at(1))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand), $this->equalTo(null))
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$this->perforce->syncCodeBase("label");
|
||||
$this->perforce->syncCodeBase('label');
|
||||
}
|
||||
|
||||
public function testSyncCodeBaseWithStream()
|
||||
{
|
||||
$this->setPerforceToStream();
|
||||
$expectedCommand = "p4 -u user -c composer_perforce_TEST_depot_branch -p port sync -f @label";
|
||||
$expectedCommand = 'p4 -u user -c composer_perforce_TEST_depot_branch -p port sync -f @label';
|
||||
$this->processExecutor->expects($this->at(1))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand))
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$this->perforce->syncCodeBase("label");
|
||||
$this->perforce->syncCodeBase('label');
|
||||
}
|
||||
|
||||
public function testCheckServerExists()
|
||||
{
|
||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||
|
||||
$expectedCommand = "p4 -p perforce.does.exist:port info -s";
|
||||
$expectedCommand = 'p4 -p perforce.does.exist:port info -s';
|
||||
$processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand), $this->equalTo(null))
|
||||
->will($this->returnValue(0));
|
||||
|
||||
$result = $this->perforce->checkServerExists("perforce.does.exist:port", $processExecutor);
|
||||
$result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -609,13 +610,13 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
{
|
||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||
|
||||
$expectedCommand = "p4 -p perforce.does.not.exist:port info -s";
|
||||
$expectedCommand = 'p4 -p perforce.does.not.exist:port info -s';
|
||||
$processExecutor->expects($this->at(0))
|
||||
->method('execute')
|
||||
->with($this->equalTo($expectedCommand), $this->equalTo(null))
|
||||
->will($this->returnValue("Perforce client error:"));
|
||||
->will($this->returnValue('Perforce client error:'));
|
||||
|
||||
$result = $this->perforce->checkServerExists("perforce.does.not.exist:port", $processExecutor);
|
||||
$result = $this->perforce->checkServerExists('perforce.does.not.exist:port', $processExecutor);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
|
@ -639,30 +640,30 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
private function getExpectedClientSpec($withStream)
|
||||
{
|
||||
$expectedArray = array(
|
||||
"Client: composer_perforce_TEST_depot",
|
||||
"\n",
|
||||
"Update:",
|
||||
"\n",
|
||||
"Access:",
|
||||
"Owner: user",
|
||||
"\n",
|
||||
"Description:",
|
||||
" Created by user from composer.",
|
||||
"\n",
|
||||
"Root: path",
|
||||
"\n",
|
||||
"Options: noallwrite noclobber nocompress unlocked modtime rmdir",
|
||||
"\n",
|
||||
"SubmitOptions: revertunchanged",
|
||||
"\n",
|
||||
"LineEnd: local",
|
||||
"\n"
|
||||
'Client: composer_perforce_TEST_depot',
|
||||
PHP_EOL,
|
||||
'Update:',
|
||||
PHP_EOL,
|
||||
'Access:',
|
||||
'Owner: user',
|
||||
PHP_EOL,
|
||||
'Description:',
|
||||
' Created by user from composer.',
|
||||
PHP_EOL,
|
||||
'Root: path',
|
||||
PHP_EOL,
|
||||
'Options: noallwrite noclobber nocompress unlocked modtime rmdir',
|
||||
PHP_EOL,
|
||||
'SubmitOptions: revertunchanged',
|
||||
PHP_EOL,
|
||||
'LineEnd: local',
|
||||
PHP_EOL
|
||||
);
|
||||
if ($withStream) {
|
||||
$expectedArray[] = "Stream:";
|
||||
$expectedArray[] = " //depot/branch";
|
||||
$expectedArray[] = 'Stream:';
|
||||
$expectedArray[] = ' //depot/branch';
|
||||
} else {
|
||||
$expectedArray[] = "View: //depot/... //composer_perforce_TEST_depot/depot/...";
|
||||
$expectedArray[] = 'View: //depot/... //composer_perforce_TEST_depot/depot/...';
|
||||
}
|
||||
|
||||
return $expectedArray;
|
||||
|
@ -670,6 +671,6 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|||
|
||||
private function setPerforceToStream()
|
||||
{
|
||||
$this->perforce->setStream("//depot/branch");
|
||||
$this->perforce->setStream('//depot/branch');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue