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