SvnDriverTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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\Config;
  14. class SvnDriverTest extends \PHPUnit_Framework_TestCase
  15. {
  16. /**
  17. * @expectedException RuntimeException
  18. */
  19. public function testWrongCredentialsInUrl()
  20. {
  21. $console = $this->getMock('Composer\IO\IOInterface');
  22. $console->expects($this->once())
  23. ->method('isInteractive')
  24. ->will($this->returnValue(true));
  25. $output = "svn: OPTIONS of 'http://corp.svn.local/repo':";
  26. $output .= " authorization failed: Could not authenticate to server:";
  27. $output .= " rejected Basic challenge (http://corp.svn.local/)";
  28. $process = $this->getMock('Composer\Util\ProcessExecutor');
  29. $process->expects($this->once())
  30. ->method('execute')
  31. ->will($this->returnValue(1));
  32. $process->expects($this->once())
  33. ->method('getErrorOutput')
  34. ->will($this->returnValue($output));
  35. $config = new Config();
  36. $config->merge(array(
  37. 'config' => array(
  38. 'home' => sys_get_temp_dir() . '/composer-test',
  39. ),
  40. ));
  41. $svn = new SvnDriver('http://till:secret@corp.svn.local/repo', $console, $config, $process);
  42. $svn->initialize();
  43. }
  44. private function getCmd($cmd)
  45. {
  46. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  47. return strtr($cmd, "'", '"');
  48. }
  49. return $cmd;
  50. }
  51. public static function supportProvider()
  52. {
  53. return array(
  54. array('http://svn.apache.org', true),
  55. array('https://svn.sf.net', true),
  56. array('svn://example.org', true),
  57. array('svn+ssh://example.org', true),
  58. );
  59. }
  60. /**
  61. * @dataProvider supportProvider
  62. */
  63. public function testSupport($url, $assertion)
  64. {
  65. if ($assertion === true) {
  66. $this->assertTrue(SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $url));
  67. } else {
  68. $this->assertFalse(SvnDriver::supports($this->getMock('Composer\IO\IOInterface'), $url));
  69. }
  70. }
  71. }