SvnDriverTest.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. * @return array
  23. */
  24. public function urlProvider()
  25. {
  26. return array(
  27. array('http://till:test@svn.example.org/', $this->getCmd(" --no-auth-cache --username 'till' --password 'test' ")),
  28. array('http://svn.apache.org/', ''),
  29. array('svn://johndoe@example.org', $this->getCmd(" --no-auth-cache --username 'johndoe' --password '' ")),
  30. );
  31. }
  32. /**
  33. * @dataProvider urlProvider
  34. */
  35. public function testCredentials($url, $expect)
  36. {
  37. $io = new \Composer\IO\NullIO;
  38. $svn = new SvnDriver($url, $io);
  39. $this->assertEquals($expect, $svn->getSvnCredentialString());
  40. }
  41. private function getCmd($cmd)
  42. {
  43. if (defined('PHP_WINDOWS_VERSION_BUILD')) {
  44. return strtr($cmd, "'", '"');
  45. }
  46. return $cmd;
  47. }
  48. }