Merge pull request #358 from bantu/ticket/321

Reimplement testGenerateIdentifier

* bantu/ticket/321:
  Reimplement testGenerateIdentifier to fix #321
This commit is contained in:
Andreas Fischer 2014-06-01 22:00:08 +02:00
commit c7d4fd937e

View File

@ -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')), if (extension_loaded('mcrypt')) {
array('SSH-2.0-phpseclib_0.3 (mcrypt)', array('mcrypt')), $this->assertContains('mcrypt', $identifier);
array('SSH-2.0-phpseclib_0.3 (mcrypt, gmp)', array('mcrypt', 'gmp')), } else {
array('SSH-2.0-phpseclib_0.3 (mcrypt, bcmath)', array('mcrypt', 'bcmath')), $this->assertNotContains('mcrypt', $identifier);
);
} }
/** if (extension_loaded('gmp')) {
* @dataProvider generateIdentifierProvider $this->assertContains('gmp', $identifier);
*/ $this->assertNotContains('bcmath', $identifier);
public function testGenerateIdentifier($expected, array $requiredExtensions) } else if (extension_loaded('bcmath')) {
{ $this->assertNotContains('gmp', $identifier);
$notAllowed = array('gmp', 'bcmath', 'mcrypt', 'gmp'); $this->assertContains('bcmath', $identifier);
foreach ($notAllowed as $notAllowedExtension) { } else {
if (in_array($notAllowedExtension, $requiredExtensions)) { $this->assertNotContains('gmp', $identifier);
continue; $this->assertNotContains('bcmath', $identifier);
} }
if (extension_loaded($notAllowedExtension)) {
$this->markTestSkipped('Extension ' . $notAllowedExtension . ' is not allowed for this data-set');
}
}
$ssh = $this->createSSHMock();
$identifier = $ssh->_generate_identifier();
$this->assertEquals($expected, $identifier);
} }
public function testGetExitStatusIfNotConnected() public function testGetExitStatusIfNotConnected()