mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Test fixes
This commit is contained in:
parent
3ca22f9ef1
commit
b4c2347b24
2 changed files with 35 additions and 22 deletions
|
@ -4,22 +4,8 @@ namespace Composer\Test\Util;
|
|||
use Composer\IO\NullIO;
|
||||
use Composer\Util\Svn;
|
||||
|
||||
class SvnTest
|
||||
class SvnTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* Provide some examples for {@self::testCredentials()}.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function urlProvider()
|
||||
{
|
||||
return array(
|
||||
array('http://till:test@svn.example.org/', $this->getCmd(" --no-auth-cache --username 'till' --password 'test' ")),
|
||||
array('http://svn.apache.org/', ''),
|
||||
array('svn://johndoe@example.org', $this->getCmd(" --no-auth-cache --username 'johndoe' --password '' ")),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the credential string.
|
||||
*
|
||||
|
@ -31,8 +17,24 @@ class SvnTest
|
|||
public function testCredentials($url, $expect)
|
||||
{
|
||||
$svn = new Svn($url, new NullIO);
|
||||
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString');
|
||||
$reflMethod->setAccessible(true);
|
||||
|
||||
$this->assertEquals($expect, $svn->getCredentialString());
|
||||
$this->assertEquals($expect, $reflMethod->invoke($svn));
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide some examples for {@self::testCredentials()}.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function urlProvider()
|
||||
{
|
||||
return array(
|
||||
array('http://till:test@svn.example.org/', $this->getCmd(" --username 'till' --password 'test' ")),
|
||||
array('http://svn.apache.org/', ''),
|
||||
array('svn://johndoe@example.org', $this->getCmd(" --username 'johndoe' --password '' ")),
|
||||
);
|
||||
}
|
||||
|
||||
public function testInteractiveString()
|
||||
|
@ -40,10 +42,21 @@ class SvnTest
|
|||
$url = 'http://svn.example.org';
|
||||
|
||||
$svn = new Svn($url, new NullIO());
|
||||
$reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCommand');
|
||||
$reflMethod->setAccessible(true);
|
||||
|
||||
$this->assertEquals(
|
||||
"svn ls --non-interactive 'http://svn.example.org'",
|
||||
$svn->getCommand('svn ls', $url)
|
||||
$this->getCmd("svn ls --non-interactive 'http://svn.example.org'"),
|
||||
$reflMethod->invokeArgs($svn, array('svn ls', $url))
|
||||
);
|
||||
}
|
||||
|
||||
private function getCmd($cmd)
|
||||
{
|
||||
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
|
||||
return strtr($cmd, "'", '"');
|
||||
}
|
||||
|
||||
return $cmd;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue