SvnTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Composer\Test\Util;
  3. use Composer\IO\NullIO;
  4. use Composer\Util\Svn;
  5. class SvnTest
  6. {
  7. /**
  8. * Provide some examples for {@self::testCredentials()}.
  9. *
  10. * @return array
  11. */
  12. public function urlProvider()
  13. {
  14. return array(
  15. array('http://till:test@svn.example.org/', $this->getCmd(" --no-auth-cache --username 'till' --password 'test' ")),
  16. array('http://svn.apache.org/', ''),
  17. array('svn://johndoe@example.org', $this->getCmd(" --no-auth-cache --username 'johndoe' --password '' ")),
  18. );
  19. }
  20. /**
  21. * Test the credential string.
  22. *
  23. * @param string $url The SVN url.
  24. * @param string $expect The expectation for the test.
  25. *
  26. * @dataProvider urlProvider
  27. */
  28. public function testCredentials($url, $expect)
  29. {
  30. $svn = new Svn($url, new NullIO);
  31. $this->assertEquals($expect, $svn->getCredentialString());
  32. }
  33. public function testInteractiveString()
  34. {
  35. $url = 'http://svn.example.org';
  36. $svn = new Svn($url, new NullIO());
  37. $this->assertEquals(
  38. "svn ls --non-interactive 'http://svn.example.org'",
  39. $svn->getCommand('svn ls', $url)
  40. );
  41. }
  42. }