SvnDriverTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Test\Repository\Vcs;
  12. use Composer\Repository\Vcs\SvnDriver;
  13. use Composer\IO\NullIO;
  14. /**
  15. * @author Till Klampaeckel <till@php.net>
  16. */
  17. class SvnDriverTest extends \PHPUnit_Framework_TestCase
  18. {
  19. /**
  20. * Test the execute method.
  21. */
  22. public function testExecute()
  23. {
  24. $this->markTestIncomplete("Currently no way to mock the output value which is passed by reference.");
  25. $console = $this->getMock('Composer\IO\IOInterface');
  26. $console->expects($this->once())
  27. ->method('isInteractive')
  28. ->will($this->returnValue(true));
  29. $output = "svn: OPTIONS of 'http://corp.svn.local/repo':";
  30. $output .= " authorization failed: Could not authenticate to server:";
  31. $output .= " rejected Basic challenge (http://corp.svn.local/)";
  32. $process = $this->getMock('Composer\Util\ProcessExecutor');
  33. $process->expects($this->once())
  34. ->method('execute')
  35. ->will($this->returnValue(1));
  36. $svn = new SvnDriver('http://till:secret@corp.svn.local/repo', $console, $process);
  37. $svn->execute('svn ls', 'http://corp.svn.local/repo');
  38. }
  39. private function getCmd($cmd)
  40. {
  41. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  42. return strtr($cmd, "'", '"');
  43. }
  44. return $cmd;
  45. }
  46. public static function supportProvider()
  47. {
  48. return array(
  49. array('http://svn.apache.org', true),
  50. array('https://svn.sf.net', true),
  51. array('svn://example.org', true),
  52. array('svn+ssh://example.org', true),
  53. array('file:///d:/repository_name/project', true),
  54. array('file:///repository_name/project', true),
  55. array('/absolute/path', true),
  56. );
  57. }
  58. /**
  59. * Nail a bug in {@link SvnDriver::support()}.
  60. *
  61. * @dataProvider supportProvider
  62. */
  63. public function testSupport($url, $assertion)
  64. {
  65. if ($assertion === true) {
  66. $this->assertTrue(SvnDriver::supports($url));
  67. } else {
  68. $this->assertFalse(SvnDriver::supports($url));
  69. }
  70. }
  71. }