|
@@ -24,12 +24,12 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
protected $processExecutor;
|
|
|
protected $io;
|
|
|
|
|
|
- const TEST_DEPOT = 'depot';
|
|
|
- const TEST_BRANCH = 'branch';
|
|
|
- const TEST_P4USER = 'user';
|
|
|
+ const TEST_DEPOT = 'depot';
|
|
|
+ const TEST_BRANCH = 'branch';
|
|
|
+ const TEST_P4USER = 'user';
|
|
|
const TEST_CLIENT_NAME = 'TEST';
|
|
|
- const TEST_PORT = 'port';
|
|
|
- const TEST_PATH = 'path';
|
|
|
+ const TEST_PORT = 'port';
|
|
|
+ const TEST_PATH = 'path';
|
|
|
|
|
|
protected function setUp()
|
|
|
{
|
|
@@ -41,18 +41,18 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
protected function tearDown()
|
|
|
{
|
|
|
- $this->perforce = null;
|
|
|
- $this->io = null;
|
|
|
- $this->repoConfig = null;
|
|
|
+ $this->perforce = null;
|
|
|
+ $this->io = null;
|
|
|
+ $this->repoConfig = null;
|
|
|
$this->processExecutor = null;
|
|
|
}
|
|
|
|
|
|
public function getTestRepoConfig()
|
|
|
{
|
|
|
return array(
|
|
|
- 'depot' => self::TEST_DEPOT,
|
|
|
- 'branch' => self::TEST_BRANCH,
|
|
|
- 'p4user' => self::TEST_P4USER,
|
|
|
+ 'depot' => self::TEST_DEPOT,
|
|
|
+ 'branch' => self::TEST_BRANCH,
|
|
|
+ 'p4user' => self::TEST_P4USER,
|
|
|
'unique_perforce_client_name' => self::TEST_CLIENT_NAME,
|
|
|
);
|
|
|
}
|
|
@@ -140,10 +140,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->perforce->setUser(null);
|
|
|
$expectedCommand = 'p4 set';
|
|
|
$callback = function ($command, &$output) {
|
|
|
- $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL;
|
|
|
+ $output = 'P4USER=TEST_P4VARIABLE_USER' . PHP_EOL;
|
|
|
|
|
|
- return true;
|
|
|
- };
|
|
|
+ return true;
|
|
|
+ };
|
|
|
$this->processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedCommand))
|
|
@@ -158,10 +158,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->perforce->setUser(null);
|
|
|
$expectedCommand = 'echo $P4USER';
|
|
|
$callback = function ($command, &$output) {
|
|
|
- $output = 'TEST_P4VARIABLE_USER' . PHP_EOL;
|
|
|
+ $output = 'TEST_P4VARIABLE_USER' . PHP_EOL;
|
|
|
|
|
|
- return true;
|
|
|
- };
|
|
|
+ return true;
|
|
|
+ };
|
|
|
$this->processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedCommand))
|
|
@@ -187,7 +187,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->createNewPerforceWithWindowsFlag(true);
|
|
|
$this->perforce->setUser(null);
|
|
|
$expectedQuestion = 'Enter P4 User:';
|
|
|
- $expectedCommand = 'p4 set P4USER=TEST_QUERY_USER';
|
|
|
+ $expectedCommand = 'p4 set P4USER=TEST_QUERY_USER';
|
|
|
$this->io->expects($this->at(0))
|
|
|
->method('ask')
|
|
|
->with($this->equalTo($expectedQuestion))
|
|
@@ -204,7 +204,7 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->createNewPerforceWithWindowsFlag(false);
|
|
|
$this->perforce->setUser(null);
|
|
|
$expectedQuestion = 'Enter P4 User:';
|
|
|
- $expectedCommand = 'export P4USER=TEST_QUERY_USER';
|
|
|
+ $expectedCommand = 'export P4USER=TEST_QUERY_USER';
|
|
|
$this->io->expects($this->at(0))
|
|
|
->method('ask')
|
|
|
->with($this->equalTo($expectedQuestion))
|
|
@@ -219,9 +219,9 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
public function testQueryP4PasswordWithPasswordAlreadySet()
|
|
|
{
|
|
|
$repoConfig = array(
|
|
|
- 'depot' => 'depot',
|
|
|
- 'branch' => 'branch',
|
|
|
- 'p4user' => 'user',
|
|
|
+ 'depot' => 'depot',
|
|
|
+ 'branch' => 'branch',
|
|
|
+ 'p4user' => 'user',
|
|
|
'p4password' => 'TEST_PASSWORD',
|
|
|
);
|
|
|
$this->perforce = new Perforce($repoConfig, 'port', 'path', $this->processExecutor, false, $this->getMockIOInterface(), 'TEST');
|
|
@@ -234,10 +234,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->createNewPerforceWithWindowsFlag(true);
|
|
|
$expectedCommand = 'p4 set';
|
|
|
$callback = function ($command, &$output) {
|
|
|
- $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
|
|
|
+ $output = 'P4PASSWD=TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
|
|
|
|
|
|
- return true;
|
|
|
- };
|
|
|
+ return true;
|
|
|
+ };
|
|
|
$this->processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedCommand))
|
|
@@ -251,10 +251,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$this->createNewPerforceWithWindowsFlag(false);
|
|
|
$expectedCommand = 'echo $P4PASSWD';
|
|
|
$callback = function ($command, &$output) {
|
|
|
- $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
|
|
|
+ $output = 'TEST_P4VARIABLE_PASSWORD' . PHP_EOL;
|
|
|
|
|
|
- return true;
|
|
|
- };
|
|
|
+ return true;
|
|
|
+ };
|
|
|
$this->processExecutor->expects($this->at(0))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedCommand))
|
|
@@ -358,10 +358,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
);
|
|
|
$expectedCommand2 = 'p4 -u user -p port changes //depot/branch/...';
|
|
|
$expectedCallback = function ($command, &$output) {
|
|
|
- $output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
|
|
|
+ $output = 'Change 1234 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
|
|
|
|
|
|
- return true;
|
|
|
- };
|
|
|
+ return true;
|
|
|
+ };
|
|
|
$this->processExecutor->expects($this->at(1))
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedCommand2))
|
|
@@ -375,10 +375,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
{
|
|
|
$expectedCommand = 'p4 -u user -p port changes //depot/...';
|
|
|
$expectedCallback = function ($command, &$output) {
|
|
|
- $output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
|
|
|
+ $output = 'Change 5678 on 2014/03/19 by Clark.Stuth@Clark.Stuth_test_client \'test changelist\'';
|
|
|
|
|
|
- return true;
|
|
|
- };
|
|
|
+ return true;
|
|
|
+ };
|
|
|
$this->processExecutor->expects($this->once())
|
|
|
->method('execute')
|
|
|
->with($this->equalTo($expectedCommand))
|
|
@@ -473,10 +473,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
|
|
|
$result = $this->perforce->getComposerInformation('//depot');
|
|
|
$expected = array(
|
|
|
- 'name' => 'test/perforce',
|
|
|
- 'description' => 'Basic project for testing',
|
|
|
+ 'name' => 'test/perforce',
|
|
|
+ 'description' => 'Basic project for testing',
|
|
|
'minimum-stability' => 'dev',
|
|
|
- 'autoload' => array('psr-0' => array()),
|
|
|
+ 'autoload' => array('psr-0' => array()),
|
|
|
);
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
@@ -514,10 +514,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$result = $this->perforce->getComposerInformation('//depot@0.0.1');
|
|
|
|
|
|
$expected = array(
|
|
|
- 'name' => 'test/perforce',
|
|
|
- 'description' => 'Basic project for testing',
|
|
|
+ 'name' => 'test/perforce',
|
|
|
+ 'description' => 'Basic project for testing',
|
|
|
'minimum-stability' => 'dev',
|
|
|
- 'autoload' => array('psr-0' => array()),
|
|
|
+ 'autoload' => array('psr-0' => array()),
|
|
|
);
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
@@ -543,10 +543,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$result = $this->perforce->getComposerInformation('//depot/branch');
|
|
|
|
|
|
$expected = array(
|
|
|
- 'name' => 'test/perforce',
|
|
|
- 'description' => 'Basic project for testing',
|
|
|
+ 'name' => 'test/perforce',
|
|
|
+ 'description' => 'Basic project for testing',
|
|
|
'minimum-stability' => 'dev',
|
|
|
- 'autoload' => array('psr-0' => array()),
|
|
|
+ 'autoload' => array('psr-0' => array()),
|
|
|
);
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|
|
@@ -585,10 +585,10 @@ class PerforceTest extends \PHPUnit_Framework_TestCase
|
|
|
$result = $this->perforce->getComposerInformation('//depot/branch@0.0.1');
|
|
|
|
|
|
$expected = array(
|
|
|
- 'name' => 'test/perforce',
|
|
|
- 'description' => 'Basic project for testing',
|
|
|
+ 'name' => 'test/perforce',
|
|
|
+ 'description' => 'Basic project for testing',
|
|
|
'minimum-stability' => 'dev',
|
|
|
- 'autoload' => array('psr-0' => array()),
|
|
|
+ 'autoload' => array('psr-0' => array()),
|
|
|
);
|
|
|
$this->assertEquals($expected, $result);
|
|
|
}
|