SvnDriverTest.php 2.4 KB

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