SvnDriverTest.php 1.9 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. /**
  15. * @author Till Klampaeckel <till@php.net>
  16. */
  17. class SvnDriverTest extends \PHPUnit_Framework_TestCase
  18. {
  19. /**
  20. * Provide some examples for {@self::testCredentials()}.
  21. *
  22. * {@link \Composer\IO\NullIO} is always non-interactive.
  23. *
  24. * @return array
  25. */
  26. public static function urlProvider()
  27. {
  28. $nullIO = new \Composer\IO\NullIO;
  29. return array(
  30. array(
  31. 'http://till:test@svn.example.org/',
  32. " --no-auth-cache --username 'till' --password 'test' ",
  33. ),
  34. array(
  35. 'http://svn.apache.org/',
  36. '',
  37. ),
  38. array(
  39. 'svn://johndoe@example.org',
  40. " --no-auth-cache --username 'johndoe' --password '' ",
  41. ),
  42. );
  43. }
  44. /**
  45. * Test the credential string.
  46. *
  47. * @param string $url The SVN url.
  48. * @param string $expect The expectation for the test.
  49. *
  50. * @dataProvider urlProvider
  51. */
  52. public function testCredentials($url, $expect)
  53. {
  54. $svn = new SvnDriver($url, new \Composer\IO\NullIO);
  55. $this->assertEquals($expect, $svn->getSvnCredentialString());
  56. }
  57. public function testInteractiveString()
  58. {
  59. $url = 'http://svn.example.org';
  60. $io = new \Composer\IO\NullIO; // non-interactive by design
  61. $svn = new SvnDriver($url, $io);
  62. $this->assertEquals(
  63. "svn ls --non-interactive 'http://svn.example.org'",
  64. $svn->getSvnCommand('svn ls', $url)
  65. );
  66. }
  67. }