mirror of
https://github.com/danog/phpseclib.git
synced 2024-12-13 09:37:37 +01:00
ba46db1758
Various fixes to fopen mode handling in SFTP Stream * bantu/SFTPStreamTest: Explicitly set size to 0 when creating or truncating. mode[0] of 'c' is not supposed to truncate. Need to create the file when it does not exist and mode[0] is not 'r'. Add SFTPStreamTest::testFopenFcloseCreatesFile() Conflicts: tests/Functional/Net/SFTPLargeFileTest.php
39 lines
966 B
PHP
39 lines
966 B
PHP
<?php
|
|
|
|
/**
|
|
* @author Andreas Fischer <bantu@phpbb.com>
|
|
* @copyright 2015 Andreas Fischer
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
|
*/
|
|
|
|
use phpseclib\Net\SFTP\Stream;
|
|
|
|
class Functional_Net_SFTPStreamTest extends Functional_Net_SFTPTestCase
|
|
{
|
|
static public function setUpBeforeClass()
|
|
{
|
|
Stream::register();
|
|
parent::setUpBeforeClass();
|
|
}
|
|
|
|
public function testFopenFcloseCreatesFile()
|
|
{
|
|
$context = stream_context_create(array(
|
|
'sftp' => array('session' => $this->sftp),
|
|
));
|
|
$fp = fopen($this->buildUrl('fooo.txt'), 'wb', false, $context);
|
|
$this->assertTrue(is_resource($fp));
|
|
fclose($fp);
|
|
$this->assertSame(0, $this->sftp->size('fooo.txt'));
|
|
}
|
|
|
|
protected function buildUrl($suffix)
|
|
{
|
|
return sprintf(
|
|
'sftp://via-context/%s/%s',
|
|
$this->sftp->pwd(),
|
|
$suffix
|
|
);
|
|
}
|
|
}
|