mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-16 02:07:09 +00:00
Remove side-effect from Net/SFTP/Stream.php.
This commit is contained in:
parent
d25d115747
commit
970c55d6cc
@ -138,8 +138,7 @@ class Net_SFTP_Stream
|
||||
if (in_array($protocol, stream_get_wrappers(), true)) {
|
||||
return false;
|
||||
}
|
||||
$class = function_exists('get_called_class') ? get_called_class() : __CLASS__;
|
||||
return stream_wrapper_register($protocol, $class);
|
||||
return stream_wrapper_register($protocol, get_called_class());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -798,5 +797,3 @@ class Net_SFTP_Stream
|
||||
return call_user_func_array(array($this, $name), $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
Net_SFTP_Stream::register();
|
||||
|
@ -5,29 +5,20 @@
|
||||
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
||||
*/
|
||||
|
||||
require_once 'Net/SFTP/Stream.php';
|
||||
|
||||
class Unit_Net_SFTPStreamTest extends PhpseclibTestCase
|
||||
{
|
||||
protected $protocol = 'sftptest';
|
||||
|
||||
public function setUp()
|
||||
public function testRegisterWithoutArgument()
|
||||
{
|
||||
parent::setUp();
|
||||
if (in_array($this->protocol, stream_get_wrappers())) {
|
||||
stream_wrapper_unregister($this->protocol);
|
||||
}
|
||||
}
|
||||
|
||||
public function testRegisterFromSideEffect()
|
||||
{
|
||||
// Including the file registers 'sftp' as a stream.
|
||||
$this->assertTrue(Net_SFTP_Stream::register());
|
||||
$this->assertContains('sftp', stream_get_wrappers());
|
||||
$this->assertTrue(stream_wrapper_unregister('sftp'));
|
||||
}
|
||||
|
||||
public function testRegisterWithArgument()
|
||||
{
|
||||
Net_SFTP_Stream::register($this->protocol);
|
||||
$this->assertContains($this->protocol, stream_get_wrappers());
|
||||
$protocol = 'sftptest';
|
||||
$this->assertTrue(Net_SFTP_Stream::register($protocol));
|
||||
$this->assertContains($protocol, stream_get_wrappers());
|
||||
$this->assertTrue(stream_wrapper_unregister($protocol));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user