SvnDriverTest.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. use Composer\Test\TestCase;
  15. use Composer\Util\Filesystem;
  16. use Composer\Util\Platform;
  17. class SvnDriverTest extends TestCase
  18. {
  19. protected $home;
  20. protected $config;
  21. public function setUp()
  22. {
  23. $this->home = $this->getUniqueTmpDirectory();
  24. $this->config = new Config();
  25. $this->config->merge(array(
  26. 'config' => array(
  27. 'home' => $this->home,
  28. ),
  29. ));
  30. }
  31. public function tearDown()
  32. {
  33. $fs = new Filesystem();
  34. $fs->removeDirectory($this->home);
  35. }
  36. /**
  37. * @expectedException RuntimeException
  38. */
  39. public function testWrongCredentialsInUrl()
  40. {
  41. $console = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
  42. $httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')->disableOriginalConstructor()->getMock();
  43. $output = "svn: OPTIONS of 'https://corp.svn.local/repo':";
  44. $output .= " authorization failed: Could not authenticate to server:";
  45. $output .= " rejected Basic challenge (https://corp.svn.local/)";
  46. $process = $this->getMockBuilder('Composer\Util\ProcessExecutor')->getMock();
  47. $process->expects($this->at(1))
  48. ->method('execute')
  49. ->will($this->returnValue(1));
  50. $process->expects($this->exactly(7))
  51. ->method('getErrorOutput')
  52. ->will($this->returnValue($output));
  53. $process->expects($this->at(2))
  54. ->method('execute')
  55. ->will($this->returnValue(0));
  56. $repoConfig = array(
  57. 'url' => 'https://till:secret@corp.svn.local/repo',
  58. );
  59. $svn = new SvnDriver($repoConfig, $console, $this->config, $httpDownloader, $process);
  60. $svn->initialize();
  61. }
  62. public static function supportProvider()
  63. {
  64. return array(
  65. array('http://svn.apache.org', true),
  66. array('https://svn.sf.net', true),
  67. array('svn://example.org', true),
  68. array('svn+ssh://example.org', true),
  69. );
  70. }
  71. /**
  72. * @dataProvider supportProvider
  73. */
  74. public function testSupport($url, $assertion)
  75. {
  76. $config = new Config();
  77. $result = SvnDriver::supports($this->getMockBuilder('Composer\IO\IOInterface')->getMock(), $config, $url);
  78. $this->assertEquals($assertion, $result);
  79. }
  80. }