public function testDoDownload()
 {
     $downloader = new PerforceDownloader($this->io, $this->config);
     $repoConfig = array('depot' => 'TEST_DEPOT', 'branch' => 'TEST_BRANCH', 'p4user' => 'TEST_USER');
     $port = 'TEST_PORT';
     $path = 'TEST_PATH';
     $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'));
     $ref = 'SOURCE_REF';
     $label = 'LABEL';
     $perforce->expects($this->at(0))->method('setStream')->with($this->equalTo($ref));
     $perforce->expects($this->at(1))->method('queryP4User')->with($this->io);
     $perforce->expects($this->at(2))->method('writeP4ClientSpec');
     $perforce->expects($this->at(3))->method('connectClient');
     $perforce->expects($this->at(4))->method('syncCodeBase')->with($this->equalTo($label));
     $downloader->setPerforce($perforce);
     $package = $this->getMock('Composer\\Package\\PackageInterface');
     $package->expects($this->at(0))->method('getSourceReference')->will($this->returnValue($ref));
     $package->expects($this->at(1))->method('getPrettyVersion')->will($this->returnValue($label));
     $path = $this->testPath;
     $downloader->doDownload($package, $path);
 }
 /**
  * @depends testInitPerforceInstantiatesANewPerforceObject
  * @depends testInitPerforceDoesNothingIfPerforceAlreadySet
  */
 public function testDoDownloadWithNoTag()
 {
     $ref = 'SOURCE_REF';
     $label = null;
     $this->package->expects($this->once())->method('getSourceReference')->will($this->returnValue($ref));
     $this->io->expects($this->once())->method('writeError')->with($this->stringContains('Cloning ' . $ref));
     $perforceMethods = array('setStream', 'p4Login', 'writeP4ClientSpec', 'connectClient', 'syncCodeBase', 'cleanupClientSpec');
     $perforce = $this->getMockBuilder('Composer\\Util\\Perforce', $perforceMethods)->disableOriginalConstructor()->getMock();
     $perforce->expects($this->at(0))->method('initializePath')->with($this->equalTo($this->testPath));
     $perforce->expects($this->at(1))->method('setStream')->with($this->equalTo($ref));
     $perforce->expects($this->at(2))->method('p4Login');
     $perforce->expects($this->at(3))->method('writeP4ClientSpec');
     $perforce->expects($this->at(4))->method('connectClient');
     $perforce->expects($this->at(5))->method('syncCodeBase')->with($label);
     $perforce->expects($this->at(6))->method('cleanupClientSpec');
     $this->downloader->setPerforce($perforce);
     $this->downloader->doDownload($this->package, $this->testPath, 'url');
 }