Browse Source

Updated to match psr-2 spec, fixed header comments

mwhittom 11 years ago
parent
commit
774a55befd

+ 10 - 12
src/Composer/Downloader/PerforceDownloader.php

@@ -6,9 +6,6 @@
  * (c) Nils Adermann <naderman@naderman.de>
  *     Jordi Boggiano <j.boggiano@seld.be>
  *
- *  Contributor: Matt Whittom <Matt.Whittom@veteransunited.com>
- *  Date: 7/17/13
- *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
@@ -36,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);
@@ -46,19 +43,21 @@ class PerforceDownloader extends VcsDownloader
         $this->perforce->cleanupClientSpec();
     }
 
-    private function initPerforce($package, $path, $ref){
-        if ($this->perforceInjected){
+    private function initPerforce($package, $path, $ref)
+    {
+        if ($this->perforceInjected) {
             return;
         }
         $repository = $package->getRepository();
         $repoConfig = null;
-        if ($repository instanceof VcsRepository){
+        if ($repository instanceof VcsRepository) {
             $repoConfig = $this->getRepoConfig($repository);
         }
         $this->perforce = Perforce::createPerforce($repoConfig, $package->getSourceUrl(), $path);
     }
 
-    private function getRepoConfig(VcsRepository $repository){
+    private function getRepoConfig(VcsRepository $repository)
+    {
         return $repository->getRepoConfig();
     }
 
@@ -75,7 +74,7 @@ class PerforceDownloader extends VcsDownloader
      */
     public function getLocalChanges(PackageInterface $package, $path)
     {
-        print ("Perforce driver does not check for local changes before overriding\n");
+        $this->io->write("Perforce driver does not check for local changes before overriding", true);
         return;
     }
 
@@ -89,10 +88,9 @@ class PerforceDownloader extends VcsDownloader
         return $commitLogs;
     }
 
-    public function injectPerforce($perforce){
+    public function injectPerforce($perforce)
+    {
         $this->perforce = $perforce;
         $this->perforceInjected = true;
     }
-
-
 }

+ 10 - 13
src/Composer/Repository/Vcs/PerforceDriver.php

@@ -6,9 +6,6 @@
  * (c) Nils Adermann <naderman@naderman.de>
  *     Jordi Boggiano <j.boggiano@seld.be>
  *
- *  Contributor: Matt Whittom <Matt.Whittom@veteransunited.com>
- *  Date: 7/17/13
- *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
@@ -24,7 +21,8 @@ use Composer\Util\Perforce;
 /**
  * @author Matt Whittom <Matt.Whittom@veteransunited.com>
  */
-class PerforceDriver extends VcsDriver {
+class PerforceDriver extends VcsDriver
+{
     protected $depot;
     protected $branch;
     protected $perforce;
@@ -49,7 +47,7 @@ class PerforceDriver extends VcsDriver {
         $this->perforce->writeP4ClientSpec();
         $this->perforce->connectClient();
 
-        return TRUE;
+        return true;
     }
 
     private function initPerforce($repoConfig)
@@ -67,9 +65,8 @@ class PerforceDriver extends VcsDriver {
      */
     public function getComposerInformation($identifier)
     {
-        if (isset($this->composer_info_identifier)){
-            if (strcmp($identifier, $this->composer_info_identifier) === 0 )
-            {
+        if (isset($this->composer_info_identifier)) {
+            if (strcmp($identifier, $this->composer_info_identifier) === 0) {
                 return $this->composer_info;
             }
         }
@@ -111,7 +108,7 @@ class PerforceDriver extends VcsDriver {
      */
     public function getDist($identifier)
     {
-        return NULL;
+        return null;
     }
 
     /**
@@ -123,7 +120,7 @@ class PerforceDriver extends VcsDriver {
             'type'      => 'perforce',
             'url'       => $this->repoConfig['url'],
             'reference' => $identifier,
-            'p4user' => $this->perforce->getUser()
+            'p4user'    => $this->perforce->getUser()
         );
 
         return $source;
@@ -145,7 +142,7 @@ class PerforceDriver extends VcsDriver {
         $this->composer_info = $this->perforce->getComposerInformation("//$this->depot/$identifier");
         $this->composer_info_identifier = $identifier;
         $result = false;
-        if (isset($this->composer_info)){
+        if (isset($this->composer_info)) {
             $result = count($this->composer_info) > 0;
         }
         return $result;
@@ -156,13 +153,13 @@ class PerforceDriver extends VcsDriver {
      */
     public function getContents($url)
     {
-        return FALSE;
+        return false;
     }
 
     /**
      * {@inheritDoc}
      */
-    public static function supports(IOInterface $io, $url, $deep = FALSE)
+    public static function supports(IOInterface $io, $url, $deep = false)
     {
         return Perforce::checkServerExists($url, new ProcessExecutor);
     }

+ 125 - 95
src/Composer/Util/Perforce.php

@@ -5,9 +5,6 @@
  * (c) Nils Adermann <naderman@naderman.de>
  *     Jordi Boggiano <j.boggiano@seld.be>
  *
- *  Contributor: Matt Whittom <Matt.Whittom@veteransunited.com>
- *  Date: 7/17/13
- *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
@@ -20,7 +17,8 @@ use Composer\IO\IOInterface;
 /**
  * @author Matt Whittom <Matt.Whittom@veteransunited.com>
  */
-class Perforce {
+class Perforce
+{
 
     protected $path;
     protected $p4Depot;
@@ -37,8 +35,9 @@ class Perforce {
     protected $windowsFlag;
 
 
-    public static function createPerforce($repoConfig, $port, $path, ProcessExecutor $process = NULL) {
-        if (!isset($process)){
+    public static function createPerforce($repoConfig, $port, $path, ProcessExecutor $process = null)
+    {
+        if (!isset($process)) {
             $process = new ProcessExecutor;
         }
         $isWindows = defined('PHP_WINDOWS_VERSION_BUILD');
@@ -47,7 +46,8 @@ class Perforce {
         return $perforce;
     }
 
-    public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows) {
+    public function __construct($repoConfig, $port, $path, ProcessExecutor $process, $isWindows)
+    {
         $this->windowsFlag = $isWindows;
         $this->p4Port = $port;
         $this->path = $path;
@@ -57,25 +57,25 @@ class Perforce {
         $this->initialize($repoConfig);
     }
 
-    public function initialize($repoConfig){
+    public function initialize($repoConfig)
+    {
         $this->unique_perforce_client_name = $this->generateUniquePerforceClientName();
-        if (!isset ($repoConfig)){
+        if (!isset ($repoConfig)) {
             return;
         }
-        if (isset($repoConfig['unique_perforce_client_name'])){
+        if (isset($repoConfig['unique_perforce_client_name'])) {
             $this->unique_perforce_client_name = $repoConfig['unique_perforce_client_name'];
         }
 
-        if (isset($repoConfig['depot'])){
+        if (isset($repoConfig['depot'])) {
             $this->p4Depot = $repoConfig['depot'];
         }
-        if (isset($repoConfig['branch'])){
+        if (isset($repoConfig['branch'])) {
             $this->p4Branch = $repoConfig['branch'];
         }
         if (isset($repoConfig['p4user'])) {
             $this->p4User = $repoConfig['p4user'];
-        }
-        else {
+        } else {
             $this->p4User = $this->getP4variable("P4USER");
         }
         if (isset($repoConfig['p4password'])) {
@@ -83,7 +83,8 @@ class Perforce {
         }
     }
 
-    public function initializeDepotAndBranch($depot, $branch){
+    public function initializeDepotAndBranch($depot, $branch)
+    {
         if (isset($depot)) {
             $this->p4Depot = $depot;
         }
@@ -92,11 +93,13 @@ class Perforce {
         }
     }
 
-    public function generateUniquePerforceClientName(){
-            return gethostname() . "_" . time();
+    public function generateUniquePerforceClientName()
+    {
+        return gethostname() . "_" . time();
     }
 
-    public function cleanupClientSpec(){
+    public function cleanupClientSpec()
+    {
         $client = $this->getClient();
         $command = "p4 client -d $client";
         $this->executeCommand($command);
@@ -105,14 +108,16 @@ class Perforce {
         $fileSystem->remove($clientSpec);
     }
 
-    protected function executeCommand($command) {
+    protected function executeCommand($command)
+    {
         $result = "";
         $this->process->execute($command, $result);
 
         return $result;
     }
 
-    public function getClient() {
+    public function getClient()
+    {
         if (!isset($this->p4Client)) {
             $clean_stream_name = str_replace("@", "", str_replace("/", "_", str_replace("//", "", $this->getStream())));
             $this->p4Client = "composer_perforce_" . $this->unique_perforce_client_name . "_" . $clean_stream_name;
@@ -121,59 +126,67 @@ class Perforce {
         return $this->p4Client;
     }
 
-    protected function getPath() {
+    protected function getPath()
+    {
         return $this->path;
     }
 
-    protected function getPort() {
+    protected function getPort()
+    {
         return $this->p4Port;
     }
 
-    public function setStream($stream) {
+    public function setStream($stream)
+    {
         $this->p4Stream = $stream;
         $index = strrpos($stream, "/");
         //Stream format is //depot/stream, while non-streaming depot is //depot
-        if ($index > 2){
+        if ($index > 2) {
             $this->p4DepotType = "stream";
         }
     }
 
-    public function isStream() {
+    public function isStream()
+    {
         return (strcmp($this->p4DepotType, "stream") === 0);
     }
 
-    public function getStream() {
+    public function getStream()
+    {
         if (!isset($this->p4Stream)) {
             if ($this->isStream()) {
                 $this->p4Stream = "//$this->p4Depot/$this->p4Branch";
-            }
-            else {
+            } else {
                 $this->p4Stream = "//$this->p4Depot";
             }
         }
         return $this->p4Stream;
     }
 
-    public function getStreamWithoutLabel($stream) {
+    public function getStreamWithoutLabel($stream)
+    {
         $index = strpos($stream, "@");
-        if ($index === FALSE) {
+        if ($index === false) {
             return $stream;
         }
 
         return substr($stream, 0, $index);
     }
 
-    public function getP4ClientSpec() {
+    public function getP4ClientSpec()
+    {
         $p4clientSpec = $this->path . "/" . $this->getClient() . ".p4.spec";
 
         return $p4clientSpec;
     }
 
-    public function getUser() {
+    public function getUser()
+    {
         return $this->p4User;
     }
 
-    public function queryP4User(IOInterface $io) {
+    public function queryP4User(IOInterface $io)
+    {
         $this->getUser();
         if (strlen($this->p4User) > 0) {
             return;
@@ -185,14 +198,14 @@ class Perforce {
         $this->p4User = $io->ask("Enter P4 User:");
         if ($this->windowsFlag) {
             $command = "p4 set P4USER=$this->p4User";
-        }
-        else {
+        } else {
             $command = "export P4USER=$this->p4User";
         }
         $result = $this->executeCommand($command);
     }
 
-    protected function getP4variable($name) {
+    protected function getP4variable($name)
+    {
         if ($this->windowsFlag) {
             $command = "p4 set";
             $result = $this->executeCommand($command);
@@ -201,10 +214,9 @@ class Perforce {
                 $fields = explode("=", $line);
                 if (strcmp($name, $fields[0]) == 0) {
                     $index = strpos($fields[1], " ");
-                    if ($index === FALSE) {
+                    if ($index === false) {
                         $value = $fields[1];
-                    }
-                    else {
+                    } else {
                         $value = substr($fields[1], 0, $index);
                     }
                     $value = trim($value);
@@ -212,8 +224,7 @@ class Perforce {
                     return $value;
                 }
             }
-        }
-        else {
+        } else {
             $command = 'echo $' . $name;
             $result = trim($this->executeCommand($command));
 
@@ -221,7 +232,8 @@ class Perforce {
         }
     }
 
-    public function queryP4Password(IOInterface $io) {
+    public function queryP4Password(IOInterface $io)
+    {
         if (isset($this->p4Password)) {
             return $this->p4Password;
         }
@@ -234,7 +246,8 @@ class Perforce {
         return $password;
     }
 
-    public function generateP4Command($command, $useClient = TRUE) {
+    public function generateP4Command($command, $useClient = true)
+    {
         $p4Command = "p4 ";
         $p4Command = $p4Command . "-u " . $this->getUser() . " ";
         if ($useClient) {
@@ -246,22 +259,25 @@ class Perforce {
         return $p4Command;
     }
 
-    public function isLoggedIn() {
-        $command = $this->generateP4Command("login -s", FALSE);
+    public function isLoggedIn()
+    {
+        $command = $this->generateP4Command("login -s", false);
         $result = trim($this->executeCommand($command));
         $index = strpos($result, $this->getUser());
-        if ($index === FALSE) {
-            return FALSE;
+        if ($index === false) {
+            return false;
         }
-        return TRUE;
+        return true;
     }
 
-    public function connectClient() {
+    public function connectClient()
+    {
         $p4CreateClientCommand = $this->generateP4Command("client -i < " . $this->getP4ClientSpec());
         $this->executeCommand($p4CreateClientCommand);
     }
 
-    public function syncCodeBase($label) {
+    public function syncCodeBase($label)
+    {
         $prevDir = getcwd();
         chdir($this->path);
 
@@ -278,7 +294,8 @@ class Perforce {
         chdir($prevDir);
     }
 
-    public function writeClientSpecToFile($spec) {
+    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");
@@ -292,17 +309,20 @@ class Perforce {
         if ($this->isStream()) {
             fwrite($spec, "Stream:\n");
             fwrite($spec, "  " . $this->getStreamWithoutLabel($this->p4Stream) . "\n");
-        }
-        else {
+        } else {
             fwrite(
-                $spec, "View:  " . $this->getStream() . "/...  //" . $this->getClient() . "/" . str_replace(
-                         "//", "", $this->getStream()
-                     ) . "/... \n"
+                $spec,
+                "View:  " . $this->getStream() . "/...  //" . $this->getClient() . "/" . str_replace(
+                    "//",
+                    "",
+                    $this->getStream()
+                ) . "/... \n"
             );
         }
     }
 
-    public function writeP4ClientSpec() {
+    public function writeP4ClientSpec()
+    {
         $clientSpec = $this->getP4ClientSpec();
         $spec = fopen($clientSpec, 'w');
         try {
@@ -315,19 +335,21 @@ class Perforce {
     }
 
 
-    protected function read($pipe, $name) {
+    protected function read($pipe, $name)
+    {
         if (feof($pipe)) {
             return;
         }
         $line = fgets($pipe);
-        while ($line != FALSE) {
+        while ($line != false) {
             $line = fgets($pipe);
         }
 
         return;
     }
 
-    public function windowsLogin($password) {
+    public function windowsLogin($password)
+    {
         $descriptorspec = array(
             0 => array("pipe", "r"),
             1 => array("pipe", "w"),
@@ -336,7 +358,7 @@ class Perforce {
         $command = $this->generateP4Command(" login -a");
         $process = proc_open($command, $descriptorspec, $pipes);
         if (!is_resource($process)) {
-            return FALSE;
+            return false;
         }
         fwrite($pipes[0], $password);
         fclose($pipes[0]);
@@ -353,54 +375,56 @@ class Perforce {
     }
 
 
-    public function p4Login(IOInterface $io) {
+    public function p4Login(IOInterface $io)
+    {
         $this->queryP4User($io);
         if (!$this->isLoggedIn()) {
             $password = $this->queryP4Password($io);
             if ($this->windowsFlag) {
                 $this->windowsLogin($password);
-            }
-            else {
-                $command = "echo $password | " . $this->generateP4Command(" login -a", FALSE);
+            } else {
+                $command = "echo $password | " . $this->generateP4Command(" login -a", false);
                 $this->executeCommand($command);
             }
         }
     }
 
-    public static function checkServerExists($url, ProcessExecutor $process_executor) {
+    public static function checkServerExists($url, ProcessExecutor $process_executor)
+    {
         $process = $process_executor ? : new ProcessExecutor;
         $result = "";
         $process->execute("p4 -p $url info -s", $result);
         $index = strpos($result, "error");
-        if ($index === FALSE) {
-            return TRUE;
+        if ($index === false) {
+            return true;
         }
 
-        return FALSE;
+        return false;
     }
 
-    public function getComposerInformation($identifier) {
+    public function getComposerInformation($identifier)
+    {
         $index = strpos($identifier, "@");
-        if ($index === FALSE) {
+        if ($index === false) {
             $composer_json = "$identifier/composer.json";
 
             return $this->getComposerInformationFromPath($composer_json);
-        }
-        else {
+        } else {
             return $this->getComposerInformationFromLabel($identifier, $index);
         }
     }
 
-    public function getComposerInformationFromPath($composer_json) {
+    public function getComposerInformationFromPath($composer_json)
+    {
         $command = $this->generateP4Command(" print $composer_json");
         $result = $this->executeCommand($command);
         $index = strpos($result, "{");
-        if ($index === FALSE) {
+        if ($index === false) {
             return "";
         }
         if ($index >= 0) {
             $rawData = substr($result, $index);
-            $composer_info = json_decode($rawData, TRUE);
+            $composer_info = json_decode($rawData, true);
 
             return $composer_info;
         }
@@ -408,14 +432,15 @@ class Perforce {
         return "";
     }
 
-    public function getComposerInformationFromLabel($identifier, $index) {
+    public function getComposerInformationFromLabel($identifier, $index)
+    {
         $composer_json_path = substr($identifier, 0, $index) . "/composer.json" . substr($identifier, $index);
-        $command = $this->generateP4Command(" files $composer_json_path", FALSE);
+        $command = $this->generateP4Command(" files $composer_json_path", false);
         $result = $this->executeCommand($command);
         $index2 = strpos($result, "no such file(s).");
-        if ($index2 === FALSE) {
+        if ($index2 === false) {
             $index3 = strpos($result, "change");
-            if (!($index3 === FALSE)) {
+            if (!($index3 === false)) {
                 $phrase = trim(substr($result, $index3));
                 $fields = explode(" ", $phrase);
                 $id = $fields[1];
@@ -428,12 +453,12 @@ class Perforce {
         return "";
     }
 
-    public function getBranches() {
+    public function getBranches()
+    {
         $possible_branches = array();
         if (!$this->isStream()) {
             $possible_branches[$this->p4Branch] = $this->getStream();
-        }
-        else {
+        } else {
             $command = $this->generateP4Command("streams //$this->p4Depot/...");
             $result = $this->executeCommand($command);
             $resArray = explode("\n", $result);
@@ -451,14 +476,15 @@ class Perforce {
         return $branches;
     }
 
-    public function getTags() {
+    public function getTags()
+    {
         $command = $this->generateP4Command("labels");
         $result = $this->executeCommand($command);
         $resArray = explode("\n", $result);
         $tags = array();
         foreach ($resArray as $line) {
             $index = strpos($line, "Label");
-            if (!($index === FALSE)) {
+            if (!($index === false)) {
                 $fields = explode(" ", $line);
                 $tags[$fields[1]] = $this->getStream() . "@" . $fields[1];
             }
@@ -467,13 +493,14 @@ class Perforce {
         return $tags;
     }
 
-    public function checkStream() {
-        $command = $this->generateP4Command("depots", FALSE);
+    public function checkStream()
+    {
+        $command = $this->generateP4Command("depots", false);
         $result = $this->executeCommand($command);
         $resArray = explode("\n", $result);
         foreach ($resArray as $line) {
             $index = strpos($line, "Depot");
-            if (!($index === FALSE)) {
+            if (!($index === false)) {
                 $fields = explode(" ", $line);
                 if (strcmp($this->p4Depot, $fields[1]) === 0) {
                     $this->p4DepotType = $fields[3];
@@ -483,31 +510,34 @@ class Perforce {
             }
         }
 
-        return FALSE;
+        return false;
     }
 
-    protected function getChangeList($reference){
+    protected function getChangeList($reference)
+    {
         $index = strpos($reference, "@");
-        if ($index === false){
+        if ($index === false) {
             return;
         }
         $label = substr($reference, $index);
         $command = $this->generateP4Command(" changes -m1 $label");
         $changes = $this->executeCommand($command);
-        if (strpos($changes, "Change") !== 0){
+        if (strpos($changes, "Change") !== 0) {
             return;
         }
         $fields = explode(" ", $changes);
         $changeList = $fields[1];
         return $changeList;
     }
-    public function getCommitLogs($fromReference, $toReference){
+
+    public function getCommitLogs($fromReference, $toReference)
+    {
         $fromChangeList = $this->getChangeList($fromReference);
-        if ($fromChangeList == null){
+        if ($fromChangeList == null) {
             return;
         }
         $toChangeList = $this->getChangeList($toReference);
-        if ($toChangeList == null){
+        if ($toChangeList == null) {
             return;
         }
         $index = strpos($fromReference, "@");

+ 41 - 33
tests/Composer/Test/Downloader/PerforceDownloaderTest.php

@@ -5,9 +5,6 @@
  * (c) Nils Adermann <naderman@naderman.de>
  *     Jordi Boggiano <j.boggiano@seld.be>
  *
- *  Contributor: Matt Whittom <Matt.Whittom@veteransunited.com>
- *  Date: 7/17/13
- *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
@@ -22,14 +19,16 @@ use Composer\Repository\VcsRepository;
 /**
  * @author Matt Whittom <Matt.Whittom@veteransunited.com>
  */
-class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase {
+class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase
+{
 
     private $io;
     private $config;
     private $testPath;
     public static $repository;
 
-    function setUp() {
+    function setUp()
+    {
         $this->testPath = sys_get_temp_dir() . '/composer-test';
         $this->config = new Config();
         $this->config->merge(
@@ -43,58 +42,67 @@ class PerforceDownloaderTest extends \PHPUnit_Framework_TestCase {
     }
 
 
-    public function testDoDownloadGetRepoConfig() {
+    public function testDoDownloadGetRepoConfig()
+    {
         $downloader = new PerforceDownloader($this->io, $this->config);
-        $package = $this->getMock('Composer\Package\PackageInterface' );
-        $repoConfig = array('url'=>'TEST_URL','p4user'=>'TEST_USER');
-        $repository = $this->getMock('Composer\Repository\VcsRepository', array('getRepoConfig'), array($repoConfig, $this->io, $this->config));
+        $package = $this->getMock('Composer\Package\PackageInterface');
+        $repoConfig = array('url' => 'TEST_URL', 'p4user' => 'TEST_USER');
+        $repository = $this->getMock(
+            'Composer\Repository\VcsRepository',
+            array('getRepoConfig'),
+            array($repoConfig, $this->io, $this->config)
+        );
         $package->expects($this->at(0))
-            ->method('getSourceReference')
-            ->will($this->returnValue("SOURCE_REF"));
+        ->method('getSourceReference')
+        ->will($this->returnValue("SOURCE_REF"));
         $package->expects($this->at(1))
-            ->method('getPrettyVersion')
-            ->will($this->returnValue("100"));
+        ->method('getPrettyVersion')
+        ->will($this->returnValue("100"));
         $package->expects($this->at(2))
-               ->method('getRepository')
-               ->will($this->returnValue($repository));
+        ->method('getRepository')
+        ->will($this->returnValue($repository));
         $repository->expects($this->at(0))
-            ->method('getRepoConfig');
+        ->method('getRepoConfig');
         $path = $this->testPath;
         $downloader->doDownload($package, $path);
     }
 
-    public function testDoDownload() {
+    public function testDoDownload()
+    {
         $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";
         $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"));
+        $perforce = $this->getMock(
+            'Composer\Util\Perforce',
+            array('setStream', 'queryP4User', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase'),
+            array($repoConfig, $port, $path, $process, true, "TEST")
+        );
         $ref = "SOURCE_REF";
         $label = "LABEL";
         $perforce->expects($this->at(0))
-            ->method('setStream')
-            ->with($this->equalTo($ref));
+        ->method('setStream')
+        ->with($this->equalTo($ref));
         $perforce->expects($this->at(1))
-            ->method('queryP4User')
-            ->with($this->io);
+        ->method('queryP4User')
+        ->with($this->io);
         $perforce->expects($this->at(2))
-            ->method('writeP4ClientSpec');
+        ->method('writeP4ClientSpec');
         $perforce->expects($this->at(3))
-            ->method('connectClient');
+        ->method('connectClient');
         $perforce->expects($this->at(4))
-            ->method('syncCodeBase')
-            ->with($this->equalTo($label));
+        ->method('syncCodeBase')
+        ->with($this->equalTo($label));
         $downloader->injectPerforce($perforce);
-        $package = $this->getMock('Composer\Package\PackageInterface' );
+        $package = $this->getMock('Composer\Package\PackageInterface');
         $package->expects($this->at(0))
-            ->method('getSourceReference')
-            ->will($this->returnValue($ref));
+        ->method('getSourceReference')
+        ->will($this->returnValue($ref));
         $package->expects($this->at(1))
-            ->method('getPrettyVersion')
-            ->will($this->returnValue($label));
+        ->method('getPrettyVersion')
+        ->will($this->returnValue($label));
         $path = $this->testPath;
         $downloader->doDownload($package, $path);
-
     }
 }

+ 45 - 28
tests/Composer/Test/Repository/Vcs/PerforceDriverTest.php

@@ -5,9 +5,6 @@
  * (c) Nils Adermann <naderman@naderman.de>
  *     Jordi Boggiano <j.boggiano@seld.be>
  *
- *  Contributor: matt-whittom
- *  Date: 7/17/13
- *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
@@ -22,14 +19,16 @@ use Composer\Config;
 /**
  * @author Matt Whittom <Matt.Whittom@veteransunited.com>
  */
-class PerforceDriverTest extends \PHPUnit_Framework_TestCase {
+class PerforceDriverTest extends \PHPUnit_Framework_TestCase
+{
     private $config;
     private $io;
     private $process;
     private $remoteFileSystem;
     private $testPath;
 
-    public function setUp() {
+    public function setUp()
+    {
         $this->testPath = sys_get_temp_dir() . '/composer-test';
         $this->config = new Config();
         $this->config->merge(
@@ -42,24 +41,34 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase {
 
         $this->io = $this->getMock('Composer\IO\IOInterface');
         $this->process = $this->getMock('Composer\Util\ProcessExecutor');
-        $this->remoteFileSystem = $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock();
+        $this->remoteFileSystem = $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()
+                                  ->getMock();
     }
 
-    public function tearDown() {
+    public function tearDown()
+    {
         $fs = new Filesystem;
         $fs->removeDirectory($this->testPath);
     }
 
-    public function testInitializeCapturesVariablesFromRepoConfig() {
+    public function testInitializeCapturesVariablesFromRepoConfig()
+    {
         $this->setUp();
         $repo_config = array(
-            'url' => 'TEST_PERFORCE_URL',
-            'depot' => 'TEST_DEPOT_CONFIG',
+            'url'    => 'TEST_PERFORCE_URL',
+            'depot'  => 'TEST_DEPOT_CONFIG',
             'branch' => 'TEST_BRANCH_CONFIG'
         );
         $driver = new PerforceDriver($repo_config, $this->io, $this->config, $this->process, $this->remoteFileSystem);
         $process = $this->getMock('Composer\Util\ProcessExecutor');
-        $arguments = array(array('depot'=>'TEST_DEPOT', 'branch'=>'TEST_BRANCH'), 'port'=>'TEST_PORT', 'path'=>$this->testPath, $process, true, "TEST");
+        $arguments = array(
+            array('depot' => 'TEST_DEPOT', 'branch' => 'TEST_BRANCH'),
+            'port' => 'TEST_PORT',
+            'path' => $this->testPath,
+            $process,
+            true,
+            "TEST"
+        );
         $perforce = $this->getMock('Composer\Util\Perforce', null, $arguments);
         $driver->injectPerforce($perforce);
         $driver->initialize();
@@ -68,51 +77,59 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals("TEST_BRANCH_CONFIG", $driver->getBranch());
     }
 
-    public function testInitializeLogsInAndConnectsClient() {
+    public function testInitializeLogsInAndConnectsClient()
+    {
         $this->setUp();
         $repo_config = array(
-            'url' => 'TEST_PERFORCE_URL',
-            'depot' => 'TEST_DEPOT_CONFIG',
+            'url'    => 'TEST_PERFORCE_URL',
+            'depot'  => 'TEST_DEPOT_CONFIG',
             'branch' => 'TEST_BRANCH_CONFIG'
         );
         $driver = new PerforceDriver($repo_config, $this->io, $this->config, $this->process, $this->remoteFileSystem);
         $perforce = $this->getMockBuilder('Composer\Util\Perforce')->disableOriginalConstructor()->getMock();
         $perforce->expects($this->at(0))
-            ->method('p4Login')
-            ->with($this->io);
+        ->method('p4Login')
+        ->with($this->io);
         $perforce->expects($this->at(1))
-            ->method('checkStream')
-            ->with($this->equalTo("TEST_DEPOT_CONFIG"));
+        ->method('checkStream')
+        ->with($this->equalTo("TEST_DEPOT_CONFIG"));
         $perforce->expects($this->at(2))
-            ->method('writeP4ClientSpec');
+        ->method('writeP4ClientSpec');
         $perforce->expects($this->at(3))
-            ->method('connectClient');
+        ->method('connectClient');
 
         $driver->injectPerforce($perforce);
         $driver->initialize();
     }
 
-    public function testHasComposerFile() {
+    public function testHasComposerFile()
+    {
         $this->setUp();
         $repo_config = array(
-            'url' => 'TEST_PERFORCE_URL',
-            'depot' => 'TEST_DEPOT_CONFIG',
+            'url'    => 'TEST_PERFORCE_URL',
+            'depot'  => 'TEST_DEPOT_CONFIG',
             'branch' => 'TEST_BRANCH_CONFIG'
         );
         $driver = new PerforceDriver($repo_config, $this->io, $this->config, $this->process, $this->remoteFileSystem);
         $process = $this->getMock('Composer\Util\ProcessExecutor');
-        $arguments = array(array('depot'=>'TEST_DEPOT', 'branch'=>'TEST_BRANCH'), 'port'=>'TEST_PORT', 'path'=>$this->testPath, $process, true, "TEST");
+        $arguments = array(
+            array('depot' => 'TEST_DEPOT', 'branch' => 'TEST_BRANCH'),
+            'port' => 'TEST_PORT',
+            'path' => $this->testPath,
+            $process,
+            true,
+            "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"));
+        ->method('getComposerInformation')
+        ->with($this->equalTo("//TEST_DEPOT_CONFIG/TEST_IDENTIFIER"))
+        ->will($this->returnValue("Some json stuff"));
         $driver->injectPerforce($perforce);
         $driver->initialize();
         $identifier = "TEST_IDENTIFIER";
         $result = $driver->hasComposerFile($identifier);
         $this->assertTrue($result);
     }
-
 }
 

+ 245 - 100
tests/Composer/Test/Util/PerforceTest.php

@@ -5,9 +5,6 @@
  * (c) Nils Adermann <naderman@naderman.de>
  *     Jordi Boggiano <j.boggiano@seld.be>
  *
- *  Contributor: Matt Whittom <Matt.Whittom@veteransunited.com>
- *  Date: 7/17/13
- *
  * For the full copyright and license information, please view the LICENSE
  * file that was distributed with this source code.
  */
@@ -21,18 +18,26 @@ use Composer\Util\ProcessExecutor;
 /**
  * @author Matt Whittom <Matt.Whittom@veteransunited.com>
  */
-class PerforceTest extends \PHPUnit_Framework_TestCase {
+class PerforceTest extends \PHPUnit_Framework_TestCase
+{
 
     protected $perforce;
     protected $processExecutor;
 
-    public function setUp() {
+    public function setUp()
+    {
         $this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch", "p4user"=>"user", "unique_perforce_client_name" => "TEST");
+        $repoConfig = array(
+            "depot"                       => "depot",
+            "branch"                      => "branch",
+            "p4user"                      => "user",
+            "unique_perforce_client_name" => "TEST"
+        );
         $this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true);
     }
 
-    public function testGetClientWithoutStream() {
+    public function testGetClientWithoutStream()
+    {
         $client = $this->perforce->getClient();
         $hostname = gethostname();
         $timestamp = time();
@@ -41,7 +46,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals($expected, $client);
     }
 
-    public function testGetClientFromStream() {
+    public function testGetClientFromStream()
+    {
         $this->setPerforceToStream();
 
         $client = $this->perforce->getClient();
@@ -50,12 +56,14 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals($expected, $client);
     }
 
-    public function testGetStreamWithoutStream() {
+    public function testGetStreamWithoutStream()
+    {
         $stream = $this->perforce->getStream();
         $this->assertEquals("//depot", $stream);
     }
 
-    public function testGetStreamWithStream() {
+    public function testGetStreamWithStream()
+    {
         $this->setPerforceToStream();
 
         $stream = $this->perforce->getStream();
@@ -63,56 +71,70 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
     }
 
 
-    public function testGetStreamWithoutLabelWithStreamWithoutLabel(){
+    public function testGetStreamWithoutLabelWithStreamWithoutLabel()
+    {
         $stream = $this->perforce->getStreamWithoutLabel("//depot/branch");
         $this->assertEquals("//depot/branch", $stream);
     }
 
-    public function testGetStreamWithoutLabelWithStreamWithLabel(){
+    public function testGetStreamWithoutLabelWithStreamWithLabel()
+    {
         $stream = $this->perforce->getStreamWithoutLabel("//depot/branching@label");
         $this->assertEquals("//depot/branching", $stream);
     }
 
-    public function testGetClientSpec() {
+    public function testGetClientSpec()
+    {
         $clientSpec = $this->perforce->getP4ClientSpec();
         $expected = "path/composer_perforce_TEST_depot.p4.spec";
         $this->assertEquals($expected, $clientSpec);
     }
 
-    public function testGenerateP4Command() {
+    public function testGenerateP4Command()
+    {
         $command = "do something";
         $p4Command = $this->perforce->generateP4Command($command);
         $expected = "p4 -u user -c composer_perforce_TEST_depot -p port do something";
         $this->assertEquals($expected, $p4Command);
     }
 
-    public function testQueryP4UserWithUserAlreadySet(){
+    public function testQueryP4UserWithUserAlreadySet()
+    {
         $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->queryP4user($io);
         $this->assertEquals("TEST_USER", $this->perforce->getUser());
     }
 
-    public function testQueryP4UserWithUserSetInP4VariablesWithWindowsOS(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch");
+    public function testQueryP4UserWithUserSetInP4VariablesWithWindowsOS()
+    {
+        $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";
         $this->processExecutor->expects($this->at(0))
-            ->method('execute')
-            ->with($this->equalTo($expectedCommand))
-            ->will($this->returnCallback(function($command, &$output) {$output =  "P4USER=TEST_P4VARIABLE_USER\n"; return true;}));
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand))
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = "P4USER=TEST_P4VARIABLE_USER\n";
+                        return true;
+                    }
+                )
+            );
 
         $this->perforce->queryP4user($io);
         $this->assertEquals("TEST_P4VARIABLE_USER", $this->perforce->getUser());
     }
 
-    public function testQueryP4UserWithUserSetInP4VariablesNotWindowsOS(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch");
+    public function testQueryP4UserWithUserSetInP4VariablesNotWindowsOS()
+    {
+        $repoConfig = array("depot" => "depot", "branch" => "branch");
         $this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
 
         $io = $this->getMock('Composer\IO\IOInterface');
@@ -120,47 +142,57 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->processExecutor->expects($this->at(0))
         ->method('execute')
         ->with($this->equalTo($expectedCommand))
-        ->will($this->returnCallback(function($command, &$output) {$output =  "TEST_P4VARIABLE_USER\n"; return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = "TEST_P4VARIABLE_USER\n";
+                        return true;
+                    }
+                )
+            );
 
         $this->perforce->queryP4user($io);
         $this->assertEquals("TEST_P4VARIABLE_USER", $this->perforce->getUser());
     }
 
-    public function testQueryP4UserQueriesForUser(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch");
+    public function testQueryP4UserQueriesForUser()
+    {
+        $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:";
         $io->expects($this->at(0))
-            ->method('ask')
-            ->with($this->equalTo($expectedQuestion))
-            ->will($this->returnValue("TEST_QUERY_USER"));
+        ->method('ask')
+        ->with($this->equalTo($expectedQuestion))
+        ->will($this->returnValue("TEST_QUERY_USER"));
 
         $this->perforce->queryP4user($io);
         $this->assertEquals("TEST_QUERY_USER", $this->perforce->getUser());
     }
 
-    public function testQueryP4UserStoresResponseToQueryForUserWithWindows(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch");
+    public function testQueryP4UserStoresResponseToQueryForUserWithWindows()
+    {
+        $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:";
         $io->expects($this->at(0))
-            ->method('ask')
-            ->with($this->equalTo($expectedQuestion))
-            ->will($this->returnValue("TEST_QUERY_USER"));
+        ->method('ask')
+        ->with($this->equalTo($expectedQuestion))
+        ->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))
-            ->will($this->returnValue(0));
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand))
+        ->will($this->returnValue(0));
 
         $this->perforce->queryP4user($io);
     }
 
-    public function testQueryP4UserStoresResponseToQueryForUserWithoutWindows(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch");
+    public function testQueryP4UserStoresResponseToQueryForUserWithoutWindows()
+    {
+        $repoConfig = array("depot" => "depot", "branch" => "branch");
         $this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
 
         $io = $this->getMock('Composer\IO\IOInterface');
@@ -178,8 +210,14 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->perforce->queryP4user($io);
     }
 
-    public function testQueryP4PasswordWithPasswordAlreadySet(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch", "p4user"=>"user", "p4password"=>"TEST_PASSWORD");
+    public function testQueryP4PasswordWithPasswordAlreadySet()
+    {
+        $repoConfig = array(
+            "depot"      => "depot",
+            "branch"     => "branch",
+            "p4user"     => "user",
+            "p4password" => "TEST_PASSWORD"
+        );
         $this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
         $io = $this->getMock('Composer\IO\IOInterface');
 
@@ -187,21 +225,30 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals("TEST_PASSWORD", $password);
     }
 
-    public function testQueryP4PasswordWithPasswordSetInP4VariablesWithWindowsOS(){
+    public function testQueryP4PasswordWithPasswordSetInP4VariablesWithWindowsOS()
+    {
         $io = $this->getMock('Composer\IO\IOInterface');
 
         $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"; return true;}));
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand))
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = "P4PASSWD=TEST_P4VARIABLE_PASSWORD\n";
+                        return true;
+                    }
+                )
+            );
 
         $password = $this->perforce->queryP4Password($io);
         $this->assertEquals("TEST_P4VARIABLE_PASSWORD", $password);
     }
 
-    public function testQueryP4PasswordWithPasswordSetInP4VariablesNotWindowsOS(){
-        $repoConfig = array("depot"=>"depot", "branch"=>"branch", "p4user"=>"user");
+    public function testQueryP4PasswordWithPasswordSetInP4VariablesNotWindowsOS()
+    {
+        $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');
@@ -209,30 +256,39 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->processExecutor->expects($this->at(0))
         ->method('execute')
         ->with($this->equalTo($expectedCommand))
-        ->will($this->returnCallback(function($command, &$output) {$output =  "TEST_P4VARIABLE_PASSWORD\n"; return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = "TEST_P4VARIABLE_PASSWORD\n";
+                        return true;
+                    }
+                )
+            );
 
         $password = $this->perforce->queryP4Password($io);
         $this->assertEquals("TEST_P4VARIABLE_PASSWORD", $password);
     }
 
-    public function testQueryP4PasswordQueriesForPassword(){
+    public function testQueryP4PasswordQueriesForPassword()
+    {
         $io = $this->getMock('Composer\IO\IOInterface');
         $expectedQuestion = "Enter password for Perforce user user: ";
         $io->expects($this->at(0))
-            ->method('askAndHideAnswer')
-            ->with($this->equalTo($expectedQuestion))
-            ->will($this->returnValue("TEST_QUERY_PASSWORD"));
+        ->method('askAndHideAnswer')
+        ->with($this->equalTo($expectedQuestion))
+        ->will($this->returnValue("TEST_QUERY_PASSWORD"));
 
         $password = $this->perforce->queryP4Password($io);
         $this->assertEquals("TEST_QUERY_PASSWORD", $password);
     }
 
-    public function testWriteP4ClientSpecWithoutStream() {
+    public function testWriteP4ClientSpecWithoutStream()
+    {
         $stream = fopen("php://memory", 'w+');
         $this->perforce->writeClientSpecToFile($stream);
 
         rewind($stream);
-        $expectedArray = $this->getExpectedClientSpec(FALSE);
+        $expectedArray = $this->getExpectedClientSpec(false);
         try {
             foreach ($expectedArray as $expected) {
                 $this->assertStringStartsWith($expected, fgets($stream));
@@ -245,14 +301,15 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         fclose($stream);
     }
 
-    public function testWriteP4ClientSpecWithStream() {
+    public function testWriteP4ClientSpecWithStream()
+    {
         $this->setPerforceToStream();
         $stream = fopen("php://memory", 'w+');
 
         $this->perforce->writeClientSpecToFile($stream);
         rewind($stream);
 
-        $expectedArray = $this->getExpectedClientSpec(TRUE);
+        $expectedArray = $this->getExpectedClientSpec(true);
         try {
             foreach ($expectedArray as $expected) {
                 $this->assertStringStartsWith($expected, fgets($stream));
@@ -265,17 +322,19 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         fclose($stream);
     }
 
-    public function testIsLoggedIn() {
+    public function testIsLoggedIn()
+    {
         $expectedCommand = "p4 -u user -p port login -s";
         $this->processExecutor->expects($this->at(0))
-            ->method('execute')
-            ->with($this->equalTo($expectedCommand), $this->equalTo(null))
-            ->will($this->returnValue(0));
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand), $this->equalTo(null))
+        ->will($this->returnValue(0));
 
         $this->perforce->isLoggedIn();
     }
 
-    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";
         $this->processExecutor->expects($this->at(0))
         ->method('execute')
@@ -285,70 +344,112 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->perforce->connectClient();
     }
 
-    public function testGetBranchesWithStream() {
+    public function testGetBranchesWithStream()
+    {
         $this->setPerforceToStream();
 
         $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"; return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = "Stream //depot/branch mainline none 'branch'\n";
+                        return true;
+                    }
+                )
+            );
 
         $branches = $this->perforce->getBranches();
         $this->assertEquals("//depot/branch", $branches['master']);
     }
 
-    public function testGetBranchesWithoutStream() {
+    public function testGetBranchesWithoutStream()
+    {
         $branches = $this->perforce->getBranches();
         $this->assertEquals("//depot", $branches['master']);
     }
 
-    public function testGetTagsWithoutStream() {
+    public function testGetTagsWithoutStream()
+    {
         $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"; return true;}));
+        ->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";
+                        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']);
     }
 
-    public function testGetTagsWithStream() {
+    public function testGetTagsWithStream()
+    {
         $this->setPerforceToStream();
 
         $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"; return true;}));
+        ->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";
+                        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']);
     }
 
-    public function testCheckStreamWithoutStream() {
+    public function testCheckStreamWithoutStream()
+    {
         $result = $this->perforce->checkStream("depot");
         $this->assertFalse($result);
         $this->assertFalse($this->perforce->isStream());
     }
 
-    public function testCheckStreamWithStream() {
+    public function testCheckStreamWithStream()
+    {
         $this->processExecutor->expects($this->any())->method('execute')
-        ->will($this->returnCallback(function($command, &$output) {$output =  "Depot depot 2013/06/25 stream /p4/1/depots/depot/... 'Created by Me'"; return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = "Depot depot 2013/06/25 stream /p4/1/depots/depot/... 'Created by Me'";
+                        return true;
+                    }
+                )
+            );
         $result = $this->perforce->checkStream("depot");
         $this->assertTrue($result);
         $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";
         $this->processExecutor->expects($this->at(0))
         ->method('execute')
         ->with($this->equalTo($expectedCommand))
-        ->will($this->returnCallback(function($command, &$output) {$output =  PerforceTest::getComposerJson(); return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = PerforceTest::getComposerJson();
+                        return true;
+                    }
+                )
+            );
 
         $result = $this->perforce->getComposerInformation("//depot");
         $expected = array(
@@ -360,18 +461,33 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals($expected, $result);
     }
 
-    public function testGetComposerInformationWithLabelWithoutStream() {
+    public function testGetComposerInformationWithLabelWithoutStream()
+    {
         $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)"; return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $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";
         $this->processExecutor->expects($this->at(1))
         ->method('execute')
         ->with($this->equalTo($expectedCommand))
-        ->will($this->returnCallback(function($command, &$output) {$output =  PerforceTest::getComposerJson(); return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = PerforceTest::getComposerJson();
+                        return true;
+                    }
+                )
+            );
 
         $result = $this->perforce->getComposerInformation("//depot@0.0.1");
 
@@ -384,14 +500,22 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals($expected, $result);
     }
 
-    public function testGetComposerInformationWithoutLabelWithStream() {
+    public function testGetComposerInformationWithoutLabelWithStream()
+    {
         $this->setPerforceToStream();
 
         $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))
-        ->will($this->returnCallback(function($command, &$output) {$output =  PerforceTest::getComposerJson(); return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = PerforceTest::getComposerJson();
+                        return true;
+                    }
+                )
+            );
 
         $result = $this->perforce->getComposerInformation("//depot/branch");
 
@@ -404,19 +528,34 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals($expected, $result);
     }
 
-    public function testGetComposerInformationWithLabelWithStream() {
+    public function testGetComposerInformationWithLabelWithStream()
+    {
         $this->setPerforceToStream();
         $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)"; return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $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";
         $this->processExecutor->expects($this->at(1))
         ->method('execute')
         ->with($this->equalTo($expectedCommand))
-        ->will($this->returnCallback(function($command, &$output) {$output =  PerforceTest::getComposerJson(); return true;}));
+        ->will(
+                $this->returnCallback(
+                    function ($command, &$output) {
+                        $output = PerforceTest::getComposerJson();
+                        return true;
+                    }
+                )
+            );
 
         $result = $this->perforce->getComposerInformation("//depot/branch@0.0.1");
 
@@ -429,7 +568,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->assertEquals($expected, $result);
     }
 
-    public function testSyncCodeBaseWithoutStream() {
+    public function testSyncCodeBaseWithoutStream()
+    {
         $expectedCommand = "p4 -u user -c composer_perforce_TEST_depot -p port sync -f @label";
         $this->processExecutor->expects($this->at(1))
         ->method('execute')
@@ -439,44 +579,48 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         $this->perforce->syncCodeBase("label");
     }
 
-    public function testSyncCodeBaseWithStream() {
+    public function testSyncCodeBaseWithStream()
+    {
         $this->setPerforceToStream();
         $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->processExecutor->expects($this->at(1))
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand))
+        ->will($this->returnValue(0));
 
         $this->perforce->syncCodeBase("label");
     }
 
-    public function testCheckServerExists() {
+    public function testCheckServerExists()
+    {
         $processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
 
         $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));
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand), $this->equalTo(null))
+        ->will($this->returnValue(0));
 
         $result = $this->perforce->checkServerExists("perforce.does.exist:port", $processExecutor);
         $this->assertTrue($result);
     }
 
-    public function testCheckServerExistsWithFailure() {
+    public function testCheckServerExistsWithFailure()
+    {
         $processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
 
         $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:"));
+        ->method('execute')
+        ->with($this->equalTo($expectedCommand), $this->equalTo(null))
+        ->will($this->returnValue("Perforce client error:"));
 
         $result = $this->perforce->checkServerExists("perforce.does.not.exist:port", $processExecutor);
         $this->assertTrue($result);
     }
 
-    public static function getComposerJson() {
+    public static function getComposerJson()
+    {
         $composer_json = array(
             '{',
             '"name": "test/perforce",',
@@ -492,7 +636,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         return implode($composer_json);
     }
 
-    private function getExpectedClientSpec($withStream) {
+    private function getExpectedClientSpec($withStream)
+    {
         $expectedArray = array(
             "Client: composer_perforce_TEST_depot",
             "\n",
@@ -516,15 +661,15 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
         if ($withStream) {
             $expectedArray[] = "Stream:";
             $expectedArray[] = "  //depot/branch";
-        }
-        else {
+        } else {
             $expectedArray[] = "View:  //depot/...  //composer_perforce_TEST_depot/depot/...";
         }
 
         return $expectedArray;
     }
 
-    private function setPerforceToStream(){
+    private function setPerforceToStream()
+    {
         $this->perforce->setStream("//depot/branch");
     }
 }