PerforceDriverTest.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * Contributor: matt-whittom
  9. * Date: 7/17/13
  10. *
  11. * For the full copyright and license information, please view the LICENSE
  12. * file that was distributed with this source code.
  13. */
  14. namespace Composer\Test\Repository\Vcs;
  15. #use Composer\Downloader\TransportException;
  16. use Composer\Repository\Vcs\PerforceDriver;
  17. use Composer\Util\Filesystem;
  18. use Composer\Config;
  19. use Composer\IO\ConsoleIO;
  20. use Symfony\Component\Console\Input\ArrayInput;
  21. use Symfony\Component\Console\Output\ConsoleOutput;
  22. use Symfony\Component\Console\Helper\HelperSet;
  23. class PerforceDriverTest extends \PHPUnit_Framework_TestCase
  24. {
  25. private $config;
  26. private $io;
  27. public function setUp()
  28. {
  29. $this->config = new Config();
  30. $this->config->merge(array(
  31. 'config' => array(
  32. 'home' => sys_get_temp_dir() . '/composer-test',
  33. ),
  34. ));
  35. $inputParameters = array();
  36. $input = new ArrayInput($inputParameters);
  37. $output = new ConsoleOutput();
  38. $helperSet = new HelperSet();
  39. $this->io = new ConsoleIO($input, $output, $helperSet);
  40. }
  41. public function tearDown()
  42. {
  43. $fs = new Filesystem;
  44. $fs->removeDirectory(sys_get_temp_dir() . '/composer-test');
  45. }
  46. public function testPrivateRepository()
  47. {
  48. $repo_config = array(
  49. 'url' => "perforce.vuhl.root.mrc.local:3710",
  50. 'depot' => "lighthouse"
  51. );
  52. $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
  53. $result = $vcs->initialize();
  54. $this->assertTrue($result);
  55. }
  56. public function testGetTags()
  57. {
  58. $repo_config = array(
  59. 'url' => "perforce.vuhl.root.mrc.local:3710",
  60. 'depot' => "lighthouse"
  61. );
  62. $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
  63. $result = $vcs->initialize();
  64. $this->assertTrue($result);
  65. $tags = $vcs->getTags();
  66. $this->assertTrue(empty($tags));
  67. }
  68. public function testGetSource()
  69. {
  70. $repo_config = array(
  71. 'url' => "perforce.vuhl.root.mrc.local:3710",
  72. 'depot' => "lighthouse"
  73. );
  74. $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
  75. $result = $vcs->initialize();
  76. $this->assertTrue($result);
  77. $identifier = $vcs->getRootIdentifier();
  78. $source = $vcs->getSource($identifier);
  79. $this->assertEquals($source['type'], "perforce");
  80. $this->assertEquals($source['reference'], $identifier);
  81. }
  82. public function testGetDist()
  83. {
  84. $repo_config = array(
  85. 'url' => "perforce.vuhl.root.mrc.local:3710",
  86. 'depot' => "lighthouse"
  87. );
  88. $vcs = new PerforceDriver($repo_config, $this->io, $this->config);
  89. $result = $vcs->initialize();
  90. $this->assertTrue($result);
  91. $identifier = $vcs->getRootIdentifier();
  92. $dist = $vcs->getDist($identifier);
  93. $this->assertNull($dist);
  94. }
  95. }