123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- <?php
- /*
- * This file is part of Composer.
- *
- * (c) Nils Adermann <naderman@naderman.de>
- * Jordi Boggiano <j.boggiano@seld.be>
- *
- * Contributor: matt-whittom
- * Date: 7/17/13
- *
- * For the full copyright and license information, please view the LICENSE
- * file that was distributed with this source code.
- */
- namespace Composer\Test\Repository\Vcs;
- #use Composer\Downloader\TransportException;
- use Composer\Repository\Vcs\PerforceDriver;
- use Composer\Util\Filesystem;
- use Composer\Config;
- use Composer\IO\ConsoleIO;
- use Symfony\Component\Console\Input\ArrayInput;
- use Symfony\Component\Console\Output\ConsoleOutput;
- use Symfony\Component\Console\Helper\HelperSet;
- class PerforceDriverTest extends \PHPUnit_Framework_TestCase
- {
- private $config;
- private $io;
- public function setUp()
- {
- $this->config = new Config();
- $this->config->merge(array(
- 'config' => array(
- 'home' => sys_get_temp_dir() . '/composer-test',
- ),
- ));
- $inputParameters = array();
- $input = new ArrayInput($inputParameters);
- $output = new ConsoleOutput();
- $helperSet = new HelperSet();
- $this->io = new ConsoleIO($input, $output, $helperSet);
- }
- public function tearDown()
- {
- $fs = new Filesystem;
- $fs->removeDirectory(sys_get_temp_dir() . '/composer-test');
- }
- public function testPrivateRepository()
- {
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- }
- public function testGetBranches()
- {
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- $branches = $vcs->getBranches();
- //print ("\nBranches are: " . var_export($branches, true));
- $this->assertTrue(strcmp($branches['mainline'], "//lighthouse/mainline") == 0);
- }
- public function testGetTags()
- {
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- $tags = $vcs->getTags();
- $this->assertTrue(empty($tags));
- }
- public function testGetSource()
- {
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- $identifier = $vcs->getRootIdentifier();
- $source = $vcs->getSource($identifier);
- $this->assertEquals($source['type'], "perforce");
- $this->assertEquals($source['reference'], $identifier);
- }
- public function testGetDist()
- {
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- $identifier = $vcs->getRootIdentifier();
- $dist = $vcs->getDist($identifier);
- $this->assertNull($dist);
- }
- public function testGetRootIdentifier(){
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- $rootId = $vcs->getRootIdentifier();
- $this->assertEquals("mainline", $rootId);
- }
- public function testHasComposerFile(){
- $repo_config = array(
- 'url' => "perforce.vuhl.root.mrc.local:3710",
- 'depot' => "lighthouse"
- );
- $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
- $result = $vcs->initialize();
- $this->assertTrue($result);
- $identifier = $vcs->getRootIdentifier();
- $value = $vcs->hasComposerFile($identifier);
- $this->assertTrue($value);
- }
- }
|