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