SvnDriverTest.php 2.3 KB

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