Test fixes

main
Jordi Boggiano 12 years ago
parent 3ca22f9ef1
commit b4c2347b24

@ -34,9 +34,9 @@ class AutoloadGeneratorTest extends TestCase
$this->fs = new Filesystem;
$that = $this;
$this->workingDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest';
$this->workingDir = realpath(sys_get_temp_dir()).DIRECTORY_SEPARATOR.'cmptest-'.md5(uniqid('', true));
$this->fs->ensureDirectoryExists($this->workingDir);
$this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload-'.md5(uniqid('', true));
$this->vendorDir = $this->workingDir.DIRECTORY_SEPARATOR.'composer-test-autoload';
$this->ensureDirectoryExistsAndClear($this->vendorDir);
$this->config = $this->getMock('Composer\Config');
@ -55,7 +55,7 @@ class AutoloadGeneratorTest extends TestCase
return $that->vendorDir;
}));
$this->dir = getcwd();
$this->origDir = getcwd();
chdir($this->workingDir);
$this->im = $this->getMockBuilder('Composer\Installer\InstallationManager')
@ -74,7 +74,7 @@ class AutoloadGeneratorTest extends TestCase
protected function tearDown()
{
chdir($this->dir);
chdir($this->origDir);
if (is_dir($this->workingDir)) {
$this->fs->removeDirectory($this->workingDir);

@ -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, $reflMethod->invoke($svn));
}
$this->assertEquals($expect, $svn->getCredentialString());
/**
* 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…
Cancel
Save