mirror of
https://github.com/phpseclib/phpseclib.git
synced 2025-02-04 21:08:28 +00:00
Merge branch 'master' into php5
* master: Reimplement testGenerateIdentifier to fix #321
This commit is contained in:
commit
89aab25362
@ -36,38 +36,27 @@ class Unit_Net_SSH2Test extends PhpseclibTestCase
|
|||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function generateIdentifierProvider()
|
public function testGenerateIdentifier()
|
||||||
{
|
{
|
||||||
return array(
|
$identifier = $this->createSSHMock()->_generate_identifier();
|
||||||
array('SSH-2.0-phpseclib_0.3', array()),
|
$this->assertStringStartsWith('SSH-2.0-phpseclib_0.3', $identifier);
|
||||||
array('SSH-2.0-phpseclib_0.3 (gmp)', array('gmp')),
|
|
||||||
array('SSH-2.0-phpseclib_0.3 (bcmath)', array('bcmath')),
|
|
||||||
array('SSH-2.0-phpseclib_0.3 (mcrypt)', array('mcrypt')),
|
|
||||||
array('SSH-2.0-phpseclib_0.3 (mcrypt, gmp)', array('mcrypt', 'gmp')),
|
|
||||||
array('SSH-2.0-phpseclib_0.3 (mcrypt, bcmath)', array('mcrypt', 'bcmath')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
if (extension_loaded('mcrypt')) {
|
||||||
* @dataProvider generateIdentifierProvider
|
$this->assertContains('mcrypt', $identifier);
|
||||||
*/
|
} else {
|
||||||
public function testGenerateIdentifier($expected, array $requiredExtensions)
|
$this->assertNotContains('mcrypt', $identifier);
|
||||||
{
|
|
||||||
$notAllowed = array('gmp', 'bcmath', 'mcrypt', 'gmp');
|
|
||||||
foreach ($notAllowed as $notAllowedExtension) {
|
|
||||||
if (in_array($notAllowedExtension, $requiredExtensions)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (extension_loaded($notAllowedExtension)) {
|
|
||||||
$this->markTestSkipped('Extension ' . $notAllowedExtension . ' is not allowed for this data-set');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$ssh = $this->createSSHMock();
|
if (extension_loaded('gmp')) {
|
||||||
$identifier = $ssh->_generate_identifier();
|
$this->assertContains('gmp', $identifier);
|
||||||
|
$this->assertNotContains('bcmath', $identifier);
|
||||||
$this->assertEquals($expected, $identifier);
|
} else if (extension_loaded('bcmath')) {
|
||||||
|
$this->assertNotContains('gmp', $identifier);
|
||||||
|
$this->assertContains('bcmath', $identifier);
|
||||||
|
} else {
|
||||||
|
$this->assertNotContains('gmp', $identifier);
|
||||||
|
$this->assertNotContains('bcmath', $identifier);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetExitStatusIfNotConnected()
|
public function testGetExitStatusIfNotConnected()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user