1
0
Fork 0

Merge remote-tracking branch 'fabiang/preforce'

pull/2315/merge
Jordi Boggiano 2013-10-16 10:52:46 +02:00
commit a3e304028c
5 changed files with 33 additions and 12 deletions

View File

@ -151,7 +151,7 @@ to the command.
## global
The global command allows you to run other commands like `install`, `require`
or `update` as if you were running them from the [COMPOSER_HOME](#COMPOSER_HOME)
or `update` as if you were running them from the [COMPOSER_HOME](#composer-home)
directory.
This can be used to install CLI utilities globally and if you add

View File

@ -160,6 +160,10 @@ class PerforceDriver extends VcsDriver
*/
public static function supports(IOInterface $io, $url, $deep = false)
{
if (false === $deep) {
return false;
}
return Perforce::checkServerExists($url, new ProcessExecutor);
}

View File

@ -367,10 +367,7 @@ class Perforce
public static function checkServerExists($url, ProcessExecutor $processExecutor)
{
$result = '';
$processExecutor->execute('p4 -p ' . $url . ' info -s', $result);
return false === strpos($result, 'error');
return 0 === $processExecutor->execute('p4 -p ' . $url . ' info -s');
}
public function getComposerInformation($identifier)

View File

@ -131,4 +131,17 @@ class PerforceDriverTest extends \PHPUnit_Framework_TestCase
$result = $driver->hasComposerFile($identifier);
$this->assertTrue($result);
}
/**
* Test that supports() simply return false.
*
* @covers \Composer\Repository\Vcs\PerforceDriver::supports
*
* @return void
*/
public function testSupportsReturnsFalseNoDeepCheck()
{
$this->expectOutputString('');
$this->assertFalse(PerforceDriver::supports($this->io, 'existing.url'));
}
}

View File

@ -617,19 +617,26 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
$result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor);
$this->assertTrue($result);
}
public function testCheckServerExistsWithFailure()
/**
* Test if "p4" command is missing.
*
* @covers \Composer\Util\Perforce::checkServerExists
*
* @return void
*/
public function testCheckServerClientError()
{
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
$expectedCommand = 'p4 -p perforce.does.not.exist:port info -s';
$expectedCommand = 'p4 -p perforce.does.exist:port info -s';
$processExecutor->expects($this->at(0))
->method('execute')
->with($this->equalTo($expectedCommand), $this->equalTo(null))
->will($this->returnValue('Perforce client error:'));
$result = $this->perforce->checkServerExists('perforce.does.not.exist:port', $processExecutor);
$this->assertTrue($result);
->will($this->returnValue(127));
$result = $this->perforce->checkServerExists('perforce.does.exist:port', $processExecutor);
$this->assertFalse($result);
}
public static function getComposerJson()