SvnDriverTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. return array(
  29. array(
  30. 'http://till:test@svn.example.org/',
  31. " --no-auth-cache --username 'till' --password 'test' ",
  32. '\Composer\IO\NullIO',
  33. ),
  34. array(
  35. 'http://svn.apache.org/',
  36. '',
  37. '\Composer\IO\NullIO',
  38. ),
  39. array(
  40. 'svn://johndoe@example.org',
  41. " --no-auth-cache --username 'johndoe' --password '' ",
  42. '\Composer\IO\NullIO',
  43. ),
  44. array(
  45. 'https://till:secret@corp.svn.local/project1',
  46. " --username 'till' --password 'secret' ",
  47. '\Composer\IO\ConsoleIO',
  48. ),
  49. );
  50. }
  51. /**
  52. * Test the credential string.
  53. *
  54. * @param string $url The SVN url.
  55. * @param string $expect The expectation for the test.
  56. * @param string $ioClass The IO interface.
  57. *
  58. * @dataProvider urlProvider
  59. */
  60. public function testCredentials($url, $expect, $ioClass)
  61. {
  62. $io = new \Composer\IO\NullIO;
  63. $svn = new SvnDriver($url, $io);
  64. $this->assertEquals($expect, $svn->getSvnCredentialString());
  65. }
  66. public function testInteractiveString()
  67. {
  68. $url = 'http://svn.example.org';
  69. $io = new \Composer\IO\NullIO; // non-interactive by design
  70. $svn = new SvnDriver($url, $io);
  71. $this->assertEquals(
  72. "svn ls --non-interactive 'http://svn.example.org'",
  73. $svn->getSvnCommand('svn ls', $url)
  74. );
  75. }
  76. }