|
|
@ -5,9 +5,6 @@
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* (c) Nils Adermann <naderman@naderman.de>
|
|
|
|
* Jordi Boggiano <j.boggiano@seld.be>
|
|
|
|
* 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
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -21,18 +18,26 @@ use Composer\Util\ProcessExecutor;
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @author Matt Whittom <Matt.Whittom@veteransunited.com>
|
|
|
|
* @author Matt Whittom <Matt.Whittom@veteransunited.com>
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
protected $perforce;
|
|
|
|
protected $perforce;
|
|
|
|
protected $processExecutor;
|
|
|
|
protected $processExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
public function setUp()
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
|
|
|
$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);
|
|
|
|
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetClientWithoutStream() {
|
|
|
|
public function testGetClientWithoutStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$client = $this->perforce->getClient();
|
|
|
|
$client = $this->perforce->getClient();
|
|
|
|
$hostname = gethostname();
|
|
|
|
$hostname = gethostname();
|
|
|
|
$timestamp = time();
|
|
|
|
$timestamp = time();
|
|
|
@ -41,7 +46,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertEquals($expected, $client);
|
|
|
|
$this->assertEquals($expected, $client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetClientFromStream() {
|
|
|
|
public function testGetClientFromStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->setPerforceToStream();
|
|
|
|
$this->setPerforceToStream();
|
|
|
|
|
|
|
|
|
|
|
|
$client = $this->perforce->getClient();
|
|
|
|
$client = $this->perforce->getClient();
|
|
|
@ -50,12 +56,14 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertEquals($expected, $client);
|
|
|
|
$this->assertEquals($expected, $client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetStreamWithoutStream() {
|
|
|
|
public function testGetStreamWithoutStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$stream = $this->perforce->getStream();
|
|
|
|
$stream = $this->perforce->getStream();
|
|
|
|
$this->assertEquals("//depot", $stream);
|
|
|
|
$this->assertEquals("//depot", $stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetStreamWithStream() {
|
|
|
|
public function testGetStreamWithStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->setPerforceToStream();
|
|
|
|
$this->setPerforceToStream();
|
|
|
|
|
|
|
|
|
|
|
|
$stream = $this->perforce->getStream();
|
|
|
|
$stream = $this->perforce->getStream();
|
|
|
@ -63,41 +71,47 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testQueryP4UserWithUserAlreadySet(){
|
|
|
|
public function testQueryP4UserWithUserAlreadySet()
|
|
|
|
|
|
|
|
{
|
|
|
|
$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');
|
|
|
@ -105,14 +119,22 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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($this->returnCallback(function($command, &$output) {$output = "P4USER=TEST_P4VARIABLE_USER\n"; return true;}));
|
|
|
|
->will(
|
|
|
|
|
|
|
|
$this->returnCallback(
|
|
|
|
|
|
|
|
function ($command, &$output) {
|
|
|
|
|
|
|
|
$output = "P4USER=TEST_P4VARIABLE_USER\n";
|
|
|
|
|
|
|
|
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');
|
|
|
@ -120,14 +142,22 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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($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->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:";
|
|
|
@ -140,8 +170,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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');
|
|
|
@ -159,8 +190,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->perforce->queryP4user($io);
|
|
|
|
$this->perforce->queryP4user($io);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
@ -178,8 +210,14 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->perforce->queryP4user($io);
|
|
|
|
$this->perforce->queryP4user($io);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testQueryP4PasswordWithPasswordAlreadySet(){
|
|
|
|
public function testQueryP4PasswordWithPasswordAlreadySet()
|
|
|
|
$repoConfig = array("depot"=>"depot", "branch"=>"branch", "p4user"=>"user", "p4password"=>"TEST_PASSWORD");
|
|
|
|
{
|
|
|
|
|
|
|
|
$repoConfig = array(
|
|
|
|
|
|
|
|
"depot" => "depot",
|
|
|
|
|
|
|
|
"branch" => "branch",
|
|
|
|
|
|
|
|
"p4user" => "user",
|
|
|
|
|
|
|
|
"p4password" => "TEST_PASSWORD"
|
|
|
|
|
|
|
|
);
|
|
|
|
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
|
|
|
$this->perforce = new Perforce($repoConfig, "port", "path", $this->processExecutor, false, "TEST");
|
|
|
|
$io = $this->getMock('Composer\IO\IOInterface');
|
|
|
|
$io = $this->getMock('Composer\IO\IOInterface');
|
|
|
|
|
|
|
|
|
|
|
@ -187,21 +225,30 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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($this->returnCallback(function($command, &$output) {$output = "P4PASSWD=TEST_P4VARIABLE_PASSWORD\n"; return true;}));
|
|
|
|
->will(
|
|
|
|
|
|
|
|
$this->returnCallback(
|
|
|
|
|
|
|
|
function ($command, &$output) {
|
|
|
|
|
|
|
|
$output = "P4PASSWD=TEST_P4VARIABLE_PASSWORD\n";
|
|
|
|
|
|
|
|
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');
|
|
|
@ -209,13 +256,21 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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($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);
|
|
|
|
$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))
|
|
|
@ -227,12 +282,13 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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) {
|
|
|
|
$this->assertStringStartsWith($expected, fgets($stream));
|
|
|
|
$this->assertStringStartsWith($expected, fgets($stream));
|
|
|
@ -245,14 +301,15 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
fclose($stream);
|
|
|
|
fclose($stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
$expectedArray = $this->getExpectedClientSpec(TRUE);
|
|
|
|
$expectedArray = $this->getExpectedClientSpec(true);
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
foreach ($expectedArray as $expected) {
|
|
|
|
foreach ($expectedArray as $expected) {
|
|
|
|
$this->assertStringStartsWith($expected, fgets($stream));
|
|
|
|
$this->assertStringStartsWith($expected, fgets($stream));
|
|
|
@ -265,7 +322,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
fclose($stream);
|
|
|
|
fclose($stream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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')
|
|
|
@ -275,7 +333,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->perforce->isLoggedIn();
|
|
|
|
$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";
|
|
|
|
$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')
|
|
|
@ -285,70 +344,112 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->perforce->connectClient();
|
|
|
|
$this->perforce->connectClient();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetBranchesWithStream() {
|
|
|
|
public function testGetBranchesWithStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$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($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();
|
|
|
|
$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($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();
|
|
|
|
$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($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();
|
|
|
|
$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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testCheckStreamWithStream() {
|
|
|
|
public function testCheckStreamWithStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->processExecutor->expects($this->any())->method('execute')
|
|
|
|
$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");
|
|
|
|
$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))
|
|
|
|
->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");
|
|
|
|
$result = $this->perforce->getComposerInformation("//depot");
|
|
|
|
$expected = array(
|
|
|
|
$expected = array(
|
|
|
@ -360,18 +461,33 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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($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";
|
|
|
|
$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))
|
|
|
|
->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");
|
|
|
|
$result = $this->perforce->getComposerInformation("//depot@0.0.1");
|
|
|
|
|
|
|
|
|
|
|
@ -384,14 +500,22 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testGetComposerInformationWithoutLabelWithStream() {
|
|
|
|
public function testGetComposerInformationWithoutLabelWithStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$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))
|
|
|
|
->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");
|
|
|
|
$result = $this->perforce->getComposerInformation("//depot/branch");
|
|
|
|
|
|
|
|
|
|
|
@ -404,19 +528,34 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
$this->assertEquals($expected, $result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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($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";
|
|
|
|
$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))
|
|
|
|
->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");
|
|
|
|
$result = $this->perforce->getComposerInformation("//depot/branch@0.0.1");
|
|
|
|
|
|
|
|
|
|
|
@ -429,7 +568,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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')
|
|
|
@ -439,7 +579,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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))
|
|
|
@ -450,7 +591,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$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";
|
|
|
@ -463,7 +605,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertTrue($result);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function testCheckServerExistsWithFailure() {
|
|
|
|
public function testCheckServerExistsWithFailure()
|
|
|
|
|
|
|
|
{
|
|
|
|
$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";
|
|
|
@ -476,7 +619,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
$this->assertTrue($result);
|
|
|
|
$this->assertTrue($result);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static function getComposerJson() {
|
|
|
|
public static function getComposerJson()
|
|
|
|
|
|
|
|
{
|
|
|
|
$composer_json = array(
|
|
|
|
$composer_json = array(
|
|
|
|
'{',
|
|
|
|
'{',
|
|
|
|
'"name": "test/perforce",',
|
|
|
|
'"name": "test/perforce",',
|
|
|
@ -492,7 +636,8 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
return implode($composer_json);
|
|
|
|
return implode($composer_json);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function getExpectedClientSpec($withStream) {
|
|
|
|
private function getExpectedClientSpec($withStream)
|
|
|
|
|
|
|
|
{
|
|
|
|
$expectedArray = array(
|
|
|
|
$expectedArray = array(
|
|
|
|
"Client: composer_perforce_TEST_depot",
|
|
|
|
"Client: composer_perforce_TEST_depot",
|
|
|
|
"\n",
|
|
|
|
"\n",
|
|
|
@ -516,15 +661,15 @@ class PerforceTest extends \PHPUnit_Framework_TestCase {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private function setPerforceToStream(){
|
|
|
|
private function setPerforceToStream()
|
|
|
|
|
|
|
|
{
|
|
|
|
$this->perforce->setStream("//depot/branch");
|
|
|
|
$this->perforce->setStream("//depot/branch");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|