updated to replace double-quotes with single quotes

main
mwhittom 11 years ago
parent 8207518e04
commit 2e737ac439

@ -33,7 +33,7 @@ class PerforceDownloader extends VcsDownloader
$ref = $package->getSourceReference(); $ref = $package->getSourceReference();
$label = $package->getPrettyVersion(); $label = $package->getPrettyVersion();
$this->io->write(" Cloning " . $ref); $this->io->write(' Cloning ' . $ref);
$this->initPerforce($package, $path, $ref); $this->initPerforce($package, $path, $ref);
$this->perforce->setStream($ref); $this->perforce->setStream($ref);
$this->perforce->queryP4User($this->io); $this->perforce->queryP4User($this->io);
@ -74,7 +74,7 @@ class PerforceDownloader extends VcsDownloader
*/ */
public function getLocalChanges(PackageInterface $package, $path) 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; return;
} }

@ -35,7 +35,7 @@ class PerforceDriver extends VcsDriver
public function initialize() public function initialize()
{ {
$this->depot = $this->repoConfig['depot']; $this->depot = $this->repoConfig['depot'];
$this->branch = ""; $this->branch = '';
if (isset($this->repoConfig['branch'])) { if (isset($this->repoConfig['branch'])) {
$this->branch = $this->repoConfig['branch']; $this->branch = $this->repoConfig['branch'];
} }
@ -56,7 +56,7 @@ class PerforceDriver extends VcsDriver
return; 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); $this->perforce = Perforce::createPerforce($repoConfig, $this->getUrl(), $repoDir, $this->process);
} }
@ -139,7 +139,7 @@ class PerforceDriver extends VcsDriver
*/ */
public function hasComposerFile($identifier) public function hasComposerFile($identifier)
{ {
$this->composerInfo = $this->perforce->getComposerInformation("//$this->depot/$identifier"); $this->composerInfo = $this->perforce->getComposerInformation('//' . $this->depot . '/' . $identifier);
$this->composerInfoIdentifier = $identifier; $this->composerInfoIdentifier = $identifier;
$result = false; $result = false;
if (isset($this->composerInfo)) { if (isset($this->composerInfo)) {

@ -76,7 +76,7 @@ class Perforce
if (isset($repoConfig['p4user'])) { if (isset($repoConfig['p4user'])) {
$this->p4User = $repoConfig['p4user']; $this->p4User = $repoConfig['p4user'];
} else { } else {
$this->p4User = $this->getP4variable("P4USER"); $this->p4User = $this->getP4variable('P4USER');
} }
if (isset($repoConfig['p4password'])) { if (isset($repoConfig['p4password'])) {
$this->p4Password = $repoConfig['p4password']; $this->p4Password = $repoConfig['p4password'];
@ -101,7 +101,7 @@ class Perforce
public function cleanupClientSpec() public function cleanupClientSpec()
{ {
$client = $this->getClient(); $client = $this->getClient();
$command = "p4 client -d $client"; $command = 'p4 client -d $client';
$this->executeCommand($command); $this->executeCommand($command);
$clientSpec = $this->getP4ClientSpec(); $clientSpec = $this->getP4ClientSpec();
$fileSystem = new FileSystem($this->process); $fileSystem = new FileSystem($this->process);
@ -119,8 +119,8 @@ class Perforce
public function getClient() public function getClient()
{ {
if (!isset($this->p4Client)) { if (!isset($this->p4Client)) {
$cleanStreamName = str_replace("@", "", str_replace("/", "_", str_replace("//", "", $this->getStream()))); $cleanStreamName = str_replace('@', '', str_replace('/', '_', str_replace('//', '', $this->getStream())));
$this->p4Client = "composer_perforce_" . $this->uniquePerforceClientName . "_" . $cleanStreamName; $this->p4Client = 'composer_perforce_' . $this->uniquePerforceClientName . '_' . $cleanStreamName;
} }
return $this->p4Client; return $this->p4Client;
@ -139,25 +139,25 @@ class Perforce
public function setStream($stream) public function setStream($stream)
{ {
$this->p4Stream = $stream; $this->p4Stream = $stream;
$index = strrpos($stream, "/"); $index = strrpos($stream, '/');
//Stream format is //depot/stream, while non-streaming depot is //depot //Stream format is //depot/stream, while non-streaming depot is //depot
if ($index > 2) { if ($index > 2) {
$this->p4DepotType = "stream"; $this->p4DepotType = 'stream';
} }
} }
public function isStream() public function isStream()
{ {
return (strcmp($this->p4DepotType, "stream") === 0); return (strcmp($this->p4DepotType, 'stream') === 0);
} }
public function getStream() public function getStream()
{ {
if (!isset($this->p4Stream)) { if (!isset($this->p4Stream)) {
if ($this->isStream()) { if ($this->isStream()) {
$this->p4Stream = "//$this->p4Depot/$this->p4Branch"; $this->p4Stream = '//' . $this->p4Depot . '/' . $this->p4Branch;
} else { } else {
$this->p4Stream = "//$this->p4Depot"; $this->p4Stream = '//' . $this->p4Depot;
} }
} }
return $this->p4Stream; return $this->p4Stream;
@ -165,7 +165,7 @@ class Perforce
public function getStreamWithoutLabel($stream) public function getStreamWithoutLabel($stream)
{ {
$index = strpos($stream, "@"); $index = strpos($stream, '@');
if ($index === false) { if ($index === false) {
return $stream; return $stream;
} }
@ -175,7 +175,7 @@ class Perforce
public function getP4ClientSpec() public function getP4ClientSpec()
{ {
$p4clientSpec = $this->path . "/" . $this->getClient() . ".p4.spec"; $p4clientSpec = $this->path . '/' . $this->getClient() . '.p4.spec';
return $p4clientSpec; return $p4clientSpec;
} }
@ -191,15 +191,15 @@ class Perforce
if (strlen($this->p4User) > 0) { if (strlen($this->p4User) > 0) {
return; return;
} }
$this->p4User = $this->getP4variable("P4USER"); $this->p4User = $this->getP4variable('P4USER');
if (strlen($this->p4User) > 0) { if (strlen($this->p4User) > 0) {
return; return;
} }
$this->p4User = $io->ask("Enter P4 User:"); $this->p4User = $io->ask('Enter P4 User:');
if ($this->windowsFlag) { if ($this->windowsFlag) {
$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);
} }
@ -207,13 +207,13 @@ class Perforce
protected function getP4variable($name) protected function getP4variable($name)
{ {
if ($this->windowsFlag) { if ($this->windowsFlag) {
$command = "p4 set"; $command = 'p4 set';
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
$resArray = explode("\n", $result); $resArray = explode(PHP_EOL, $result);
foreach ($resArray as $line) { foreach ($resArray as $line) {
$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 {
@ -237,9 +237,9 @@ class Perforce
if (isset($this->p4Password)) { if (isset($this->p4Password)) {
return $this->p4Password; return $this->p4Password;
} }
$password = $this->getP4variable("P4PASSWD"); $password = $this->getP4variable('P4PASSWD');
if (strlen($password) <= 0) { 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; $this->p4Password = $password;
@ -248,12 +248,12 @@ class Perforce
public function generateP4Command($command, $useClient = true) public function generateP4Command($command, $useClient = true)
{ {
$p4Command = "p4 "; $p4Command = 'p4 ';
$p4Command = $p4Command . "-u " . $this->getUser() . " "; $p4Command = $p4Command . '-u ' . $this->getUser() . ' ';
if ($useClient) { 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; $p4Command = $p4Command . $command;
return $p4Command; return $p4Command;
@ -261,7 +261,7 @@ class Perforce
public function isLoggedIn() public function isLoggedIn()
{ {
$command = $this->generateP4Command("login -s", false); $command = $this->generateP4Command('login -s', false);
$result = trim($this->executeCommand($command)); $result = trim($this->executeCommand($command));
$index = strpos($result, $this->getUser()); $index = strpos($result, $this->getUser());
if ($index === false) { if ($index === false) {
@ -272,7 +272,7 @@ class Perforce
public function connectClient() public function connectClient()
{ {
$p4CreateClientCommand = $this->generateP4Command("client -i < " . $this->getP4ClientSpec()); $p4CreateClientCommand = $this->generateP4Command('client -i < ' . $this->getP4ClientSpec());
$this->executeCommand($p4CreateClientCommand); $this->executeCommand($p4CreateClientCommand);
} }
@ -281,12 +281,12 @@ class Perforce
$prevDir = getcwd(); $prevDir = getcwd();
chdir($this->path); chdir($this->path);
$this->executeCommand("pwd"); $this->executeCommand('pwd');
$p4SyncCommand = $this->generateP4Command("sync -f "); $p4SyncCommand = $this->generateP4Command('sync -f ');
if (isset($label)) { if (isset($label)) {
if (strcmp($label, "dev-master") != 0) { if (strcmp($label, 'dev-master') != 0) {
$p4SyncCommand = $p4SyncCommand . "@" . $label; $p4SyncCommand = $p4SyncCommand . '@' . $label;
} }
} }
$this->executeCommand($p4SyncCommand); $this->executeCommand($p4SyncCommand);
@ -296,27 +296,27 @@ class Perforce
public function writeClientSpecToFile($spec) public function writeClientSpecToFile($spec)
{ {
fwrite($spec, "Client: " . $this->getClient() . "\n\n"); fwrite($spec, 'Client: ' . $this->getClient() . PHP_EOL . PHP_EOL);
fwrite($spec, "Update: " . date("Y/m/d H:i:s") . "\n\n"); fwrite($spec, 'Update: ' . date('Y/m/d H:i:s') . PHP_EOL . PHP_EOL);
fwrite($spec, "Access: " . date("Y/m/d H:i:s") . "\n"); fwrite($spec, 'Access: ' . date('Y/m/d H:i:s') . PHP_EOL );
fwrite($spec, "Owner: " . $this->getUser() . "\n\n"); fwrite($spec, 'Owner: ' . $this->getUser() . PHP_EOL . PHP_EOL);
fwrite($spec, "Description:\n"); fwrite($spec, 'Description:' . PHP_EOL);
fwrite($spec, " Created by " . $this->getUser() . " from composer.\n\n"); fwrite($spec, ' Created by ' . $this->getUser() . ' from composer.' . PHP_EOL . PHP_EOL);
fwrite($spec, "Root: " . $this->getPath() . "\n\n"); fwrite($spec, 'Root: ' . $this->getPath() . PHP_EOL . PHP_EOL);
fwrite($spec, "Options: noallwrite noclobber nocompress unlocked modtime rmdir\n\n"); fwrite($spec, 'Options: noallwrite noclobber nocompress unlocked modtime rmdir' . PHP_EOL . PHP_EOL);
fwrite($spec, "SubmitOptions: revertunchanged\n\n"); fwrite($spec, 'SubmitOptions: revertunchanged' . PHP_EOL . PHP_EOL);
fwrite($spec, "LineEnd: local\n\n"); fwrite($spec, 'LineEnd: local' . PHP_EOL . PHP_EOL);
if ($this->isStream()) { if ($this->isStream()) {
fwrite($spec, "Stream:\n"); fwrite($spec, 'Stream:' . PHP_EOL);
fwrite($spec, " " . $this->getStreamWithoutLabel($this->p4Stream) . "\n"); fwrite($spec, ' ' . $this->getStreamWithoutLabel($this->p4Stream) . PHP_EOL);
} else { } else {
fwrite( fwrite(
$spec, $spec,
"View: " . $this->getStream() . "/... //" . $this->getClient() . "/" . str_replace( 'View: ' . $this->getStream() . '/... //' . $this->getClient() . '/' . str_replace(
"//", '//',
"", '',
$this->getStream() $this->getStream()
) . "/... \n" ) . '/... ' . PHP_EOL
); );
} }
} }
@ -351,11 +351,11 @@ class Perforce
public function windowsLogin($password) public function windowsLogin($password)
{ {
$descriptorspec = array( $descriptorspec = array(
0 => array("pipe", "r"), 0 => array('pipe', 'r'),
1 => array("pipe", "w"), 1 => array('pipe', 'w'),
2 => array("pipe", "a") 2 => array('pipe', 'a')
); );
$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;
@ -363,8 +363,8 @@ class Perforce
fwrite($pipes[0], $password); fwrite($pipes[0], $password);
fclose($pipes[0]); fclose($pipes[0]);
$this->read($pipes[1], "Output"); $this->read($pipes[1], 'Output');
$this->read($pipes[2], "Error"); $this->read($pipes[2], 'Error');
fclose($pipes[1]); fclose($pipes[1]);
fclose($pipes[2]); fclose($pipes[2]);
@ -383,7 +383,7 @@ class Perforce
if ($this->windowsFlag) { if ($this->windowsFlag) {
$this->windowsLogin($password); $this->windowsLogin($password);
} else { } else {
$command = "echo $password | " . $this->generateP4Command(" login -a", false); $command = 'echo ' . $password . ' | ' . $this->generateP4Command(' login -a', false);
$this->executeCommand($command); $this->executeCommand($command);
} }
} }
@ -391,16 +391,16 @@ class Perforce
public static function checkServerExists($url, ProcessExecutor $processExecutor) public static function checkServerExists($url, ProcessExecutor $processExecutor)
{ {
$result = ""; $result = '';
$processExecutor->execute("p4 -p $url info -s", $result); $processExecutor->execute('p4 -p ' . $url . ' info -s', $result);
return false === strpos($result, "error"); return false === strpos($result, 'error');
} }
public function getComposerInformation($identifier) public function getComposerInformation($identifier)
{ {
$index = strpos($identifier, "@"); $index = strpos($identifier, '@');
if ($index === false) { if ($index === false) {
$composerJson = "$identifier/composer.json"; $composerJson = $identifier. '/composer.json';
return $this->getComposerInformationFromPath($composerJson); return $this->getComposerInformationFromPath($composerJson);
} }
@ -409,11 +409,11 @@ class Perforce
public function getComposerInformationFromPath($composerJson) public function getComposerInformationFromPath($composerJson)
{ {
$command = $this->generateP4Command(" print $composerJson"); $command = $this->generateP4Command(' print ' . $composerJson);
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
$index = strpos($result, "{"); $index = strpos($result, '{');
if ($index === false) { if ($index === false) {
return ""; return '';
} }
if ($index >= 0) { if ($index >= 0) {
$rawData = substr($result, $index); $rawData = substr($result, $index);
@ -422,22 +422,22 @@ class Perforce
return $composer_info; return $composer_info;
} }
return ""; return '';
} }
public function getComposerInformationFromLabel($identifier, $index) public function getComposerInformationFromLabel($identifier, $index)
{ {
$composerJsonPath = substr($identifier, 0, $index) . "/composer.json" . substr($identifier, $index); $composerJsonPath = substr($identifier, 0, $index) . '/composer.json' . substr($identifier, $index);
$command = $this->generateP4Command(" files $composerJsonPath", false); $command = $this->generateP4Command(' files ' . $composerJsonPath, false);
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
$index2 = strpos($result, "no such file(s)."); $index2 = strpos($result, 'no such file(s).');
if ($index2 === false) { if ($index2 === false) {
$index3 = strpos($result, "change"); $index3 = strpos($result, 'change');
if (!($index3 === false)) { if (!($index3 === false)) {
$phrase = trim(substr($result, $index3)); $phrase = trim(substr($result, $index3));
$fields = explode(" ", $phrase); $fields = explode(' ', $phrase);
$id = $fields[1]; $id = $fields[1];
$composerJson = substr($identifier, 0, $index) . "/composer.json@" . $id; $composerJson = substr($identifier, 0, $index) . '/composer.json@' . $id;
return $this->getComposerInformationFromPath($composerJson); return $this->getComposerInformationFromPath($composerJson);
} }
@ -452,13 +452,13 @@ class Perforce
if (!$this->isStream()) { if (!$this->isStream()) {
$possibleBranches[$this->p4Branch] = $this->getStream(); $possibleBranches[$this->p4Branch] = $this->getStream();
} else { } else {
$command = $this->generateP4Command("streams //$this->p4Depot/..."); $command = $this->generateP4Command('streams //' . $this->p4Depot . '/...');
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
$resArray = explode("\n", $result); $resArray = explode(PHP_EOL, $result);
foreach ($resArray as $line) { foreach ($resArray as $line) {
$resBits = explode(" ", $line); $resBits = explode(' ', $line);
if (count($resBits) > 4) { 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]; $possibleBranches[$branch] = $resBits[1];
} }
} }
@ -471,15 +471,15 @@ class Perforce
public function getTags() public function getTags()
{ {
$command = $this->generateP4Command("labels"); $command = $this->generateP4Command('labels');
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
$resArray = explode("\n", $result); $resArray = explode(PHP_EOL, $result);
$tags = array(); $tags = array();
foreach ($resArray as $line) { foreach ($resArray as $line) {
$index = strpos($line, "Label"); $index = strpos($line, 'Label');
if (!($index === false)) { if (!($index === false)) {
$fields = explode(" ", $line); $fields = explode(' ', $line);
$tags[$fields[1]] = $this->getStream() . "@" . $fields[1]; $tags[$fields[1]] = $this->getStream() . '@' . $fields[1];
} }
} }
@ -488,13 +488,13 @@ class Perforce
public function checkStream() public function checkStream()
{ {
$command = $this->generateP4Command("depots", false); $command = $this->generateP4Command('depots', false);
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
$resArray = explode("\n", $result); $resArray = explode(PHP_EOL, $result);
foreach ($resArray as $line) { foreach ($resArray as $line) {
$index = strpos($line, "Depot"); $index = strpos($line, 'Depot');
if (!($index === false)) { if (!($index === false)) {
$fields = explode(" ", $line); $fields = explode(' ', $line);
if (strcmp($this->p4Depot, $fields[1]) === 0) { if (strcmp($this->p4Depot, $fields[1]) === 0) {
$this->p4DepotType = $fields[3]; $this->p4DepotType = $fields[3];
@ -508,17 +508,17 @@ class Perforce
protected function getChangeList($reference) protected function getChangeList($reference)
{ {
$index = strpos($reference, "@"); $index = strpos($reference, '@');
if ($index === false) { if ($index === false) {
return; return;
} }
$label = substr($reference, $index); $label = substr($reference, $index);
$command = $this->generateP4Command(" changes -m1 $label"); $command = $this->generateP4Command(' changes -m1 ' . $label);
$changes = $this->executeCommand($command); $changes = $this->executeCommand($command);
if (strpos($changes, "Change") !== 0) { if (strpos($changes, 'Change') !== 0) {
return; return;
} }
$fields = explode(" ", $changes); $fields = explode(' ', $changes);
$changeList = $fields[1]; $changeList = $fields[1];
return $changeList; return $changeList;
} }
@ -533,9 +533,9 @@ class Perforce
if ($toChangeList == null) { if ($toChangeList == null) {
return; return;
} }
$index = strpos($fromReference, "@"); $index = strpos($fromReference, '@');
$main = substr($fromReference, 0, $index) . "/..."; $main = substr($fromReference, 0, $index) . '/...';
$command = $this->generateP4Command("filelog $main@$fromChangeList,$toChangeList"); $command = $this->generateP4Command('filelog ' . $main . '@' . $fromChangeList. ',' . $toChangeList);
$result = $this->executeCommand($command); $result = $this->executeCommand($command);
return $result; return $result;
} }

@ -54,10 +54,10 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
); );
$package->expects($this->at(0)) $package->expects($this->at(0))
->method('getSourceReference') ->method('getSourceReference')
->will($this->returnValue("SOURCE_REF")); ->will($this->returnValue('SOURCE_REF'));
$package->expects($this->at(1)) $package->expects($this->at(1))
->method('getPrettyVersion') ->method('getPrettyVersion')
->will($this->returnValue("100")); ->will($this->returnValue('100'));
$package->expects($this->at(2)) $package->expects($this->at(2))
->method('getRepository') ->method('getRepository')
->will($this->returnValue($repository)); ->will($this->returnValue($repository));
@ -70,17 +70,17 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
public function testDoDownload() public function testDoDownload()
{ {
$downloader = new PerforceDownloader($this->io, $this->config); $downloader = new PerforceDownloader($this->io, $this->config);
$repoConfig = array("depot" => "TEST_DEPOT", "branch" => "TEST_BRANCH", "p4user" => "TEST_USER"); $repoConfig = array('depot' => 'TEST_DEPOT', 'branch' => 'TEST_BRANCH', 'p4user' => 'TEST_USER');
$port = "TEST_PORT"; $port = 'TEST_PORT';
$path = "TEST_PATH"; $path = 'TEST_PATH';
$process = $this->getmock('Composer\Util\ProcessExecutor'); $process = $this->getmock('Composer\Util\ProcessExecutor');
$perforce = $this->getMock( $perforce = $this->getMock(
'Composer\Util\Perforce', 'Composer\Util\Perforce',
array('setStream', 'queryP4User', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase'), array('setStream', 'queryP4User', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase'),
array($repoConfig, $port, $path, $process, true, "TEST") array($repoConfig, $port, $path, $process, true, 'TEST')
); );
$ref = "SOURCE_REF"; $ref = 'SOURCE_REF';
$label = "LABEL"; $label = 'LABEL';
$perforce->expects($this->at(0)) $perforce->expects($this->at(0))
->method('setStream') ->method('setStream')
->with($this->equalTo($ref)); ->with($this->equalTo($ref));

@ -67,14 +67,14 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
'path' => $this->testPath, 'path' => $this->testPath,
$process, $process,
true, true,
"TEST" 'TEST'
); );
$perforce = $this->getMock('Composer\Util\Perforce', null, $arguments); $perforce = $this->getMock('Composer\Util\Perforce', null, $arguments);
$driver->injectPerforce($perforce); $driver->injectPerforce($perforce);
$driver->initialize(); $driver->initialize();
$this->assertEquals("TEST_PERFORCE_URL", $driver->getUrl()); $this->assertEquals('TEST_PERFORCE_URL', $driver->getUrl());
$this->assertEquals("TEST_DEPOT_CONFIG", $driver->getDepot()); $this->assertEquals('TEST_DEPOT_CONFIG', $driver->getDepot());
$this->assertEquals("TEST_BRANCH_CONFIG", $driver->getBranch()); $this->assertEquals('TEST_BRANCH_CONFIG', $driver->getBranch());
} }
public function testInitializeLogsInAndConnectsClient() public function testInitializeLogsInAndConnectsClient()
@ -92,7 +92,7 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
->with($this->io); ->with($this->io);
$perforce->expects($this->at(1)) $perforce->expects($this->at(1))
->method('checkStream') ->method('checkStream')
->with($this->equalTo("TEST_DEPOT_CONFIG")); ->with($this->equalTo('TEST_DEPOT_CONFIG'));
$perforce->expects($this->at(2)) $perforce->expects($this->at(2))
->method('writeP4ClientSpec'); ->method('writeP4ClientSpec');
$perforce->expects($this->at(3)) $perforce->expects($this->at(3))
@ -118,16 +118,16 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
'path' => $this->testPath, 'path' => $this->testPath,
$process, $process,
true, true,
"TEST" 'TEST'
); );
$perforce = $this->getMock('Composer\Util\Perforce', array('getComposerInformation'), $arguments); $perforce = $this->getMock('Composer\Util\Perforce', array('getComposerInformation'), $arguments);
$perforce->expects($this->at(0)) $perforce->expects($this->at(0))
->method('getComposerInformation') ->method('getComposerInformation')
->with($this->equalTo("//TEST_DEPOT_CONFIG/TEST_IDENTIFIER")) ->with($this->equalTo('//TEST_DEPOT_CONFIG/TEST_IDENTIFIER'))
->will($this->returnValue("Some json stuff")); ->will($this->returnValue('Some json stuff'));
$driver->injectPerforce($perforce); $driver->injectPerforce($perforce);
$driver->initialize(); $driver->initialize();
$identifier = "TEST_IDENTIFIER"; $identifier = 'TEST_IDENTIFIER';
$result = $driver->hasComposerFile($identifier); $result = $driver->hasComposerFile($identifier);
$this->assertTrue($result); $this->assertTrue($result);
} }

@ -28,12 +28,12 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
$repoConfig = array( $repoConfig = array(
"depot" => "depot", 'depot' => 'depot',
"branch" => "branch", 'branch' => 'branch',
"p4user" => "user", 'p4user' => 'user',
"unique_perforce_client_name" => "TEST" '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() public function testGetClientWithoutStream()
@ -42,7 +42,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$hostname = gethostname(); $hostname = gethostname();
$timestamp = time(); $timestamp = time();
$expected = "composer_perforce_TEST_depot"; $expected = 'composer_perforce_TEST_depot';
$this->assertEquals($expected, $client); $this->assertEquals($expected, $client);
} }
@ -52,7 +52,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$client = $this->perforce->getClient(); $client = $this->perforce->getClient();
$expected = "composer_perforce_TEST_depot_branch"; $expected = 'composer_perforce_TEST_depot_branch';
$this->assertEquals($expected, $client); $this->assertEquals($expected, $client);
} }
@ -67,34 +67,34 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$this->setPerforceToStream(); $this->setPerforceToStream();
$stream = $this->perforce->getStream(); $stream = $this->perforce->getStream();
$this->assertEquals("//depot/branch", $stream); $this->assertEquals('//depot/branch', $stream);
} }
public function testGetStreamWithoutLabelWithStreamWithoutLabel() public function testGetStreamWithoutLabelWithStreamWithoutLabel()
{ {
$stream = $this->perforce->getStreamWithoutLabel("//depot/branch"); $stream = $this->perforce->getStreamWithoutLabel('//depot/branch');
$this->assertEquals("//depot/branch", $stream); $this->assertEquals('//depot/branch', $stream);
} }
public function testGetStreamWithoutLabelWithStreamWithLabel() public function testGetStreamWithoutLabelWithStreamWithLabel()
{ {
$stream = $this->perforce->getStreamWithoutLabel("//depot/branching@label"); $stream = $this->perforce->getStreamWithoutLabel('//depot/branching@label');
$this->assertEquals("//depot/branching", $stream); $this->assertEquals('//depot/branching', $stream);
} }
public function testGetClientSpec() public function testGetClientSpec()
{ {
$clientSpec = $this->perforce->getP4ClientSpec(); $clientSpec = $this->perforce->getP4ClientSpec();
$expected = "path/composer_perforce_TEST_depot.p4.spec"; $expected = 'path/composer_perforce_TEST_depot.p4.spec';
$this->assertEquals($expected, $clientSpec); $this->assertEquals($expected, $clientSpec);
} }
public function testGenerateP4Command() public function testGenerateP4Command()
{ {
$command = "do something"; $command = 'do something';
$p4Command = $this->perforce->generateP4Command($command); $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); $this->assertEquals($expected, $p4Command);
} }
@ -102,40 +102,40 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$repoConfig = array("depot" => "depot", "branch" => "branch", "p4user" => "TEST_USER"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch', 'p4user' => 'TEST_USER');
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true, "TEST"); $this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true, 'TEST');
$this->perforce->queryP4user($io); $this->perforce->queryP4user($io);
$this->assertEquals("TEST_USER", $this->perforce->getUser()); $this->assertEquals('TEST_USER', $this->perforce->getUser());
} }
public function testQueryP4UserWithUserSetInP4VariablesWithWindowsOS() public function testQueryP4UserWithUserSetInP4VariablesWithWindowsOS()
{ {
$repoConfig = array("depot" => "depot", "branch" => "branch"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch');
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true, "TEST"); $this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true, 'TEST');
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedCommand = "p4 set"; $expectedCommand = 'p4 set';
$this->processExecutor->expects($this->at(0)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "P4USER=TEST_P4VARIABLE_USER\n"; $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL ;
return true; return true;
} }
) )
); );
$this->perforce->queryP4user($io); $this->perforce->queryP4user($io);
$this->assertEquals("TEST_P4VARIABLE_USER", $this->perforce->getUser()); $this->assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser());
} }
public function testQueryP4UserWithUserSetInP4VariablesNotWindowsOS() public function testQueryP4UserWithUserSetInP4VariablesNotWindowsOS()
{ {
$repoConfig = array("depot" => "depot", "branch" => "branch"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch');
$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'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedCommand = 'echo $P4USER'; $expectedCommand = 'echo $P4USER';
@ -145,43 +145,43 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "TEST_P4VARIABLE_USER\n"; $output = 'TEST_P4VARIABLE_USER' . PHP_EOL;
return true; return true;
} }
) )
); );
$this->perforce->queryP4user($io); $this->perforce->queryP4user($io);
$this->assertEquals("TEST_P4VARIABLE_USER", $this->perforce->getUser()); $this->assertEquals('TEST_P4VARIABLE_USER', $this->perforce->getUser());
} }
public function testQueryP4UserQueriesForUser() public function testQueryP4UserQueriesForUser()
{ {
$repoConfig = array("depot" => "depot", "branch" => "branch"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch');
$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'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedQuestion = "Enter P4 User:"; $expectedQuestion = 'Enter P4 User:';
$io->expects($this->at(0)) $io->expects($this->at(0))
->method('ask') ->method('ask')
->with($this->equalTo($expectedQuestion)) ->with($this->equalTo($expectedQuestion))
->will($this->returnValue("TEST_QUERY_USER")); ->will($this->returnValue('TEST_QUERY_USER'));
$this->perforce->queryP4user($io); $this->perforce->queryP4user($io);
$this->assertEquals("TEST_QUERY_USER", $this->perforce->getUser()); $this->assertEquals('TEST_QUERY_USER', $this->perforce->getUser());
} }
public function testQueryP4UserStoresResponseToQueryForUserWithWindows() public function testQueryP4UserStoresResponseToQueryForUserWithWindows()
{ {
$repoConfig = array("depot" => "depot", "branch" => "branch"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch');
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true, "TEST"); $this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, true, 'TEST');
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedQuestion = "Enter P4 User:"; $expectedQuestion = 'Enter P4 User:';
$io->expects($this->at(0)) $io->expects($this->at(0))
->method('ask') ->method('ask')
->with($this->equalTo($expectedQuestion)) ->with($this->equalTo($expectedQuestion))
->will($this->returnValue("TEST_QUERY_USER")); ->will($this->returnValue('TEST_QUERY_USER'));
$expectedCommand = "p4 set P4USER=TEST_QUERY_USER"; $expectedCommand = 'p4 set P4USER=TEST_QUERY_USER';
$this->processExecutor->expects($this->at(1)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -192,16 +192,16 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testQueryP4UserStoresResponseToQueryForUserWithoutWindows() public function testQueryP4UserStoresResponseToQueryForUserWithoutWindows()
{ {
$repoConfig = array("depot" => "depot", "branch" => "branch"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch');
$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'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedQuestion = "Enter P4 User:"; $expectedQuestion = 'Enter P4 User:';
$io->expects($this->at(0)) $io->expects($this->at(0))
->method('ask') ->method('ask')
->with($this->equalTo($expectedQuestion)) ->with($this->equalTo($expectedQuestion))
->will($this->returnValue("TEST_QUERY_USER")); ->will($this->returnValue('TEST_QUERY_USER'));
$expectedCommand = "export P4USER=TEST_QUERY_USER"; $expectedCommand = 'export P4USER=TEST_QUERY_USER';
$this->processExecutor->expects($this->at(1)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
@ -213,43 +213,43 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testQueryP4PasswordWithPasswordAlreadySet() public function testQueryP4PasswordWithPasswordAlreadySet()
{ {
$repoConfig = array( $repoConfig = array(
"depot" => "depot", 'depot' => 'depot',
"branch" => "branch", 'branch' => 'branch',
"p4user" => "user", 'p4user' => 'user',
"p4password" => "TEST_PASSWORD" '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'); $io = $this->getMock('Composer\IO\IOInterface');
$password = $this->perforce->queryP4Password($io); $password = $this->perforce->queryP4Password($io);
$this->assertEquals("TEST_PASSWORD", $password); $this->assertEquals('TEST_PASSWORD', $password);
} }
public function testQueryP4PasswordWithPasswordSetInP4VariablesWithWindowsOS() public function testQueryP4PasswordWithPasswordSetInP4VariablesWithWindowsOS()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedCommand = "p4 set"; $expectedCommand = 'p4 set';
$this->processExecutor->expects($this->at(0)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "P4PASSWD=TEST_P4VARIABLE_PASSWORD\n"; $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
return true; return true;
} }
) )
); );
$password = $this->perforce->queryP4Password($io); $password = $this->perforce->queryP4Password($io);
$this->assertEquals("TEST_P4VARIABLE_PASSWORD", $password); $this->assertEquals('TEST_P4VARIABLE_PASSWORD', $password);
} }
public function testQueryP4PasswordWithPasswordSetInP4VariablesNotWindowsOS() public function testQueryP4PasswordWithPasswordSetInP4VariablesNotWindowsOS()
{ {
$repoConfig = array("depot" => "depot", "branch" => "branch", "p4user" => "user"); $repoConfig = array('depot' => 'depot', 'branch' => 'branch', 'p4user' => 'user');
$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'); $io = $this->getMock('Composer\IO\IOInterface');
$expectedCommand = 'echo $P4PASSWD'; $expectedCommand = 'echo $P4PASSWD';
@ -259,35 +259,36 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "TEST_P4VARIABLE_PASSWORD\n"; $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
return true; return true;
} }
) )
); );
$password = $this->perforce->queryP4Password($io); $password = $this->perforce->queryP4Password($io);
$this->assertEquals("TEST_P4VARIABLE_PASSWORD", $password); $this->assertEquals('TEST_P4VARIABLE_PASSWORD', $password);
} }
public function testQueryP4PasswordQueriesForPassword() public function testQueryP4PasswordQueriesForPassword()
{ {
$io = $this->getMock('Composer\IO\IOInterface'); $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)) $io->expects($this->at(0))
->method('askAndHideAnswer') ->method('askAndHideAnswer')
->with($this->equalTo($expectedQuestion)) ->with($this->equalTo($expectedQuestion))
->will($this->returnValue("TEST_QUERY_PASSWORD")); ->will($this->returnValue('TEST_QUERY_PASSWORD'));
$password = $this->perforce->queryP4Password($io); $password = $this->perforce->queryP4Password($io);
$this->assertEquals("TEST_QUERY_PASSWORD", $password); $this->assertEquals('TEST_QUERY_PASSWORD', $password);
} }
public function testWriteP4ClientSpecWithoutStream() public function testWriteP4ClientSpecWithoutStream()
{ {
$stream = fopen("php://memory", 'w+'); $stream = fopen('php://memory', 'w+');
$this->perforce->writeClientSpecToFile($stream); $this->perforce->writeClientSpecToFile($stream);
rewind($stream); rewind($stream);
$expectedArray = $this->getExpectedClientSpec(false); $expectedArray = $this->getExpectedClientSpec(false);
try { try {
foreach ($expectedArray as $expected) { foreach ($expectedArray as $expected) {
@ -304,7 +305,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testWriteP4ClientSpecWithStream() public function testWriteP4ClientSpecWithStream()
{ {
$this->setPerforceToStream(); $this->setPerforceToStream();
$stream = fopen("php://memory", 'w+'); $stream = fopen('php://memory', 'w+');
$this->perforce->writeClientSpecToFile($stream); $this->perforce->writeClientSpecToFile($stream);
rewind($stream); rewind($stream);
@ -324,7 +325,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testIsLoggedIn() 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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null)) ->with($this->equalTo($expectedCommand), $this->equalTo(null))
@ -335,7 +336,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testConnectClient() 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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null)) ->with($this->equalTo($expectedCommand), $this->equalTo(null))
@ -348,74 +349,74 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$this->setPerforceToStream(); $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "Stream //depot/branch mainline none 'branch'\n"; $output = 'Stream //depot/branch mainline none \'branch\'' . PHP_EOL;
return true; return true;
} }
) )
); );
$branches = $this->perforce->getBranches(); $branches = $this->perforce->getBranches();
$this->assertEquals("//depot/branch", $branches['master']); $this->assertEquals('//depot/branch', $branches['master']);
} }
public function testGetBranchesWithoutStream() public function testGetBranchesWithoutStream()
{ {
$branches = $this->perforce->getBranches(); $branches = $this->perforce->getBranches();
$this->assertEquals("//depot", $branches['master']); $this->assertEquals('//depot', $branches['master']);
} }
public function testGetTagsWithoutStream() 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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { 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; return true;
} }
) )
); );
$tags = $this->perforce->getTags(); $tags = $this->perforce->getTags();
$this->assertEquals("//depot@0.0.1", $tags['0.0.1']); $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.2', $tags['0.0.2']);
} }
public function testGetTagsWithStream() public function testGetTagsWithStream()
{ {
$this->setPerforceToStream(); $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { 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; return true;
} }
) )
); );
$tags = $this->perforce->getTags(); $tags = $this->perforce->getTags();
$this->assertEquals("//depot/branch@0.0.1", $tags['0.0.1']); $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.2', $tags['0.0.2']);
} }
public function testCheckStreamWithoutStream() public function testCheckStreamWithoutStream()
{ {
$result = $this->perforce->checkStream("depot"); $result = $this->perforce->checkStream('depot');
$this->assertFalse($result); $this->assertFalse($result);
$this->assertFalse($this->perforce->isStream()); $this->assertFalse($this->perforce->isStream());
} }
@ -426,19 +427,19 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { 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; return true;
} }
) )
); );
$result = $this->perforce->checkStream("depot"); $result = $this->perforce->checkStream('depot');
$this->assertTrue($result); $this->assertTrue($result);
$this->assertTrue($this->perforce->isStream()); $this->assertTrue($this->perforce->isStream());
} }
public function testGetComposerInformationWithoutLabelWithoutStream() 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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->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( $expected = array(
"name" => "test/perforce", 'name' => 'test/perforce',
"description" => "Basic project for testing", 'description' => 'Basic project for testing',
"minimum-stability" => "dev", 'minimum-stability' => 'dev',
"autoload" => array("psr-0" => array()) 'autoload' => array('psr-0' => array())
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
public function testGetComposerInformationWithLabelWithoutStream() 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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "//depot/composer.json#1 - branch change 10001 (text)"; $output = '//depot/composer.json#1 - branch change 10001 (text)';
return true; 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)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->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( $expected = array(
"name" => "test/perforce", 'name' => 'test/perforce',
"description" => "Basic project for testing", 'description' => 'Basic project for testing',
"minimum-stability" => "dev", 'minimum-stability' => 'dev',
"autoload" => array("psr-0" => array()) 'autoload' => array('psr-0' => array())
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -504,7 +505,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$this->setPerforceToStream(); $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->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( $expected = array(
"name" => "test/perforce", 'name' => 'test/perforce',
"description" => "Basic project for testing", 'description' => 'Basic project for testing',
"minimum-stability" => "dev", 'minimum-stability' => 'dev',
"autoload" => array("psr-0" => array()) 'autoload' => array('psr-0' => array())
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
@ -531,20 +532,20 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
public function testGetComposerInformationWithLabelWithStream() public function testGetComposerInformationWithLabelWithStream()
{ {
$this->setPerforceToStream(); $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)) $this->processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will( ->will(
$this->returnCallback( $this->returnCallback(
function ($command, &$output) { function ($command, &$output) {
$output = "//depot/composer.json#1 - branch change 10001 (text)"; $output = '//depot/composer.json#1 - branch change 10001 (text)';
return true; 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)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->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( $expected = array(
"name" => "test/perforce", 'name' => 'test/perforce',
"description" => "Basic project for testing", 'description' => 'Basic project for testing',
"minimum-stability" => "dev", 'minimum-stability' => 'dev',
"autoload" => array("psr-0" => array()) 'autoload' => array('psr-0' => array())
); );
$this->assertEquals($expected, $result); $this->assertEquals($expected, $result);
} }
public function testSyncCodeBaseWithoutStream() 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)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null)) ->with($this->equalTo($expectedCommand), $this->equalTo(null))
->will($this->returnValue(0)); ->will($this->returnValue(0));
$this->perforce->syncCodeBase("label"); $this->perforce->syncCodeBase('label');
} }
public function testSyncCodeBaseWithStream() public function testSyncCodeBaseWithStream()
{ {
$this->setPerforceToStream(); $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)) $this->processExecutor->expects($this->at(1))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand)) ->with($this->equalTo($expectedCommand))
->will($this->returnValue(0)); ->will($this->returnValue(0));
$this->perforce->syncCodeBase("label"); $this->perforce->syncCodeBase('label');
} }
public function testCheckServerExists() public function testCheckServerExists()
{ {
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $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)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null)) ->with($this->equalTo($expectedCommand), $this->equalTo(null))
->will($this->returnValue(0)); ->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); $this->assertTrue($result);
} }
@ -609,13 +610,13 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
{ {
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor'); $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)) $processExecutor->expects($this->at(0))
->method('execute') ->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null)) ->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); $this->assertTrue($result);
} }
@ -639,30 +640,30 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
private function getExpectedClientSpec($withStream) private function getExpectedClientSpec($withStream)
{ {
$expectedArray = array( $expectedArray = array(
"Client: composer_perforce_TEST_depot", 'Client: composer_perforce_TEST_depot',
"\n", PHP_EOL,
"Update:", 'Update:',
"\n", PHP_EOL,
"Access:", 'Access:',
"Owner: user", 'Owner: user',
"\n", PHP_EOL,
"Description:", 'Description:',
" Created by user from composer.", ' Created by user from composer.',
"\n", PHP_EOL,
"Root: path", 'Root: path',
"\n", PHP_EOL,
"Options: noallwrite noclobber nocompress unlocked modtime rmdir", 'Options: noallwrite noclobber nocompress unlocked modtime rmdir',
"\n", PHP_EOL,
"SubmitOptions: revertunchanged", 'SubmitOptions: revertunchanged',
"\n", PHP_EOL,
"LineEnd: local", 'LineEnd: local',
"\n" PHP_EOL
); );
if ($withStream) { if ($withStream) {
$expectedArray[] = "Stream:"; $expectedArray[] = 'Stream:';
$expectedArray[] = " //depot/branch"; $expectedArray[] = ' //depot/branch';
} else { } else {
$expectedArray[] = "View: //depot/... //composer_perforce_TEST_depot/depot/..."; $expectedArray[] = 'View: //depot/... //composer_perforce_TEST_depot/depot/...';
} }
return $expectedArray; return $expectedArray;
@ -670,6 +671,6 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
private function setPerforceToStream() private function setPerforceToStream()
{ {
$this->perforce->setStream("//depot/branch"); $this->perforce->setStream('//depot/branch');
} }
} }

Loading…
Cancel
Save