TestingPerforce.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. * Created by JetBrains PhpStorm.
  4. * User: matt.whittom
  5. * Date: 7/31/13
  6. * Time: 2:37 PM
  7. * To change this template use File | Settings | File Templates.
  8. */
  9. namespace Composer\Test\Util;
  10. use Composer\Util\Perforce;
  11. use org\bovigo\vfs\vfsStream;
  12. class TestingPerforce extends Perforce {
  13. public $windows_flag;
  14. public function __construct($repoConfig, $port, $path, $process=null){
  15. parent::__construct($repoConfig, $port, $path, $process);
  16. $this->windows_flag = false;
  17. }
  18. /*
  19. * Override functions
  20. */
  21. protected function getRandomValue() {
  22. return "TEST";
  23. }
  24. protected function isWindows(){
  25. return $this->windows_flag;
  26. }
  27. // protected function executeCommand($command) {
  28. // $this->previousCommand = $this->lastCommand;
  29. // $this->lastCommand = $command;
  30. // $result = $this->commandReturnValue;
  31. // $this->commandReturnValue = $this->nextCommandReturnValue;
  32. // $this->nextCommandReturnValue = null;
  33. // return $result;
  34. // }
  35. public function writeP4ClientSpec() {
  36. $spec = fopen(vfsStream::url($this->getP4ClientSpec()), 'w');
  37. $this->writeClientSpecToFile($spec);
  38. fclose($spec);
  39. }
  40. /*
  41. * Test Helper functions
  42. */
  43. public function setDepotType($depotType) {
  44. $this->p4depotType = $depotType;
  45. $this->p4stream = NULL;
  46. }
  47. /*
  48. * Functions to expose protected methods for testing:
  49. */
  50. public function setP4User($p4user){
  51. $this->p4user = $p4user;
  52. }
  53. public function setP4Password($password){
  54. $this->p4password = $password;
  55. }
  56. public function testGetClient() {
  57. return $this->getClient();
  58. }
  59. public function testGetStream() {
  60. return $this->getStream();
  61. }
  62. public function testGetStreamWithoutLabel() {
  63. return $this->getStreamWithoutLabel();
  64. }
  65. public function testGetClientSpec() {
  66. return $this->getP4ClientSpec();
  67. }
  68. public function testGenerateP4Command($command, $useClient = TRUE) {
  69. return $this->generateP4Command($command, $useClient);
  70. }
  71. public function testIsLoggedIn()
  72. {
  73. return $this->isLoggedIn();
  74. }
  75. public function testIsStream()
  76. {
  77. return $this->isStream();
  78. }
  79. public function testGetP4Variable($name)
  80. {
  81. return $this->testGetP4Variable($name);
  82. }
  83. public function testQueryP4Password($io)
  84. {
  85. return $this->queryP4Password($io);
  86. }
  87. }