mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-09 15:20:58 +00:00
Merge pull request #344 from bantu/sftp-unit-test-updates
Sftp functional test updates * bantu/sftp-unit-test-updates: SFTP: last commit had a few ommissions SFTP Functional tests: Make use of assertNotSame SFTP Functional tests: Keep story linear. SFTP: add more unit tests
This commit is contained in:
commit
4e0b3a5c3c
@ -1033,10 +1033,13 @@ class Net_SFTP extends Net_SSH2
|
||||
|
||||
$stat = $this->_stat($filename, NET_SFTP_STAT);
|
||||
if ($stat === false) {
|
||||
$this->_update_stat_cache($filename, 0);
|
||||
$this->_remove_from_stat_cache($filename);
|
||||
return false;
|
||||
}
|
||||
if (isset($stat['type'])) {
|
||||
if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) {
|
||||
$filename.= '/.';
|
||||
}
|
||||
$this->_update_stat_cache($filename, (object) $stat);
|
||||
return $stat;
|
||||
}
|
||||
@ -1047,6 +1050,9 @@ class Net_SFTP extends Net_SSH2
|
||||
NET_SFTP_TYPE_REGULAR;
|
||||
$this->pwd = $pwd;
|
||||
|
||||
if ($stat['type'] == NET_SFTP_TYPE_DIRECTORY) {
|
||||
$filename.= '/.';
|
||||
}
|
||||
$this->_update_stat_cache($filename, (object) $stat);
|
||||
|
||||
return $stat;
|
||||
@ -1084,9 +1090,13 @@ class Net_SFTP extends Net_SSH2
|
||||
|
||||
$lstat = $this->_stat($filename, NET_SFTP_LSTAT);
|
||||
if ($lstat === false) {
|
||||
$this->_remove_from_stat_cache($filename);
|
||||
return false;
|
||||
}
|
||||
if (isset($lstat['type'])) {
|
||||
if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) {
|
||||
$filename.= '/.';
|
||||
}
|
||||
$this->_update_stat_cache($filename, (object) $lstat);
|
||||
return $lstat;
|
||||
}
|
||||
@ -1105,6 +1115,9 @@ class Net_SFTP extends Net_SSH2
|
||||
NET_SFTP_TYPE_REGULAR;
|
||||
$this->pwd = $pwd;
|
||||
|
||||
if ($lstat['type'] == NET_SFTP_TYPE_DIRECTORY) {
|
||||
$filename.= '/.';
|
||||
}
|
||||
$this->_update_stat_cache($filename, (object) $lstat);
|
||||
|
||||
return $lstat;
|
||||
|
@ -19,6 +19,7 @@ class Net_SFTPFunctionalTest extends PhpseclibFunctionalTestCase
|
||||
'This test hangs on Travis CI on PHP 5.3.3 and below.'
|
||||
);
|
||||
}
|
||||
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$scratchDir = uniqid('phpseclib-sftp-scratch-');
|
||||
@ -126,6 +127,20 @@ class Net_SFTPFunctionalTest extends PhpseclibFunctionalTestCase
|
||||
/**
|
||||
* @depends testChDirScratch
|
||||
*/
|
||||
public function testStatOnDir($sftp)
|
||||
{
|
||||
$this->assertNotSame(
|
||||
array(),
|
||||
$sftp->stat('.'),
|
||||
'Failed asserting that the cwd has a non-empty stat.'
|
||||
);
|
||||
|
||||
return $sftp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testStatOnDir
|
||||
*/
|
||||
public function testPutSizeGetFile($sftp)
|
||||
{
|
||||
$this->assertTrue(
|
||||
@ -151,6 +166,19 @@ class Net_SFTPFunctionalTest extends PhpseclibFunctionalTestCase
|
||||
/**
|
||||
* @depends testPutSizeGetFile
|
||||
*/
|
||||
public function testChDirOnFile($sftp)
|
||||
{
|
||||
$this->assertFalse(
|
||||
$sftp->chdir('file1.txt'),
|
||||
'Failed to assert that the cwd cannot be changed to a file'
|
||||
);
|
||||
|
||||
return $sftp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testChDirOnFile
|
||||
*/
|
||||
public function testFileExistsIsFileIsDirFile($sftp)
|
||||
{
|
||||
$this->assertTrue(
|
||||
|
Loading…
Reference in New Issue
Block a user