SvnDriverTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. use Composer\Config;
  15. class SvnDriverTest extends \PHPUnit_Framework_TestCase
  16. {
  17. /**
  18. * @expectedException RuntimeException
  19. */
  20. public function testWrongCredentialsInUrl()
  21. {
  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. $process->expects($this->once())
  34. ->method('getErrorOutput')
  35. ->will($this->returnValue($output));
  36. $svn = new SvnDriver('http://till:secret@corp.svn.local/repo', $console, new Config(), $process);
  37. $svn->initialize();
  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. );
  54. }
  55. /**
  56. * @dataProvider supportProvider
  57. */
  58. public function testSupport($url, $assertion)
  59. {
  60. if ($assertion === true) {
  61. $this->assertTrue(SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $url));
  62. } else {
  63. $this->assertFalse(SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $url));
  64. }
  65. }
  66. }