Also add Share::getWrite to non native shares

This commit is contained in:
Robin Appelman 2014-07-24 01:29:54 +02:00
commit 89d73346f2
7 changed files with 112 additions and 35 deletions

View file

@ -68,17 +68,6 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
$this->assertEquals(120, ftell($fh));
}
public function testWrite() {
$fh = $this->share->write($this->root . '/foobar');
fwrite($fh, 'qwerty');
fclose($fh);
$tmpFile1 = tempnam('/tmp', 'smb_test_');
$this->share->get($this->root . '/foobar', $tmpFile1);
$this->assertEquals('qwerty', file_get_contents($tmpFile1));
unlink($tmpFile1);
}
public function testStat() {
$sourceFile = $this->getTextFile();
$this->share->put($sourceFile, $this->root . '/foobar');

View file

@ -23,7 +23,7 @@ class Share extends \PHPUnit_Framework_TestCase {
public function setUp() {
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
$this->server = new \Icewind\SMB\Server($this->config->host, $this->config->user, $this->config->password);
$this->share= new \Icewind\SMB\Share($this->server, $this->config->share);
$this->share = new \Icewind\SMB\Share($this->server, $this->config->share);
if ($this->config->root) {
$this->root = '/' . $this->config->root . '/' . uniqid();
} else {
@ -298,4 +298,17 @@ class Share extends \PHPUnit_Framework_TestCase {
$this->assertEquals(file_get_contents($sourceFile), $content);
}
public function testWriteStream() {
$fh = $this->share->write($this->root . '/foobar', 'qwerty');
fwrite($fh, 'qwerty');
fclose($fh);
// sleep(5);
$tmpFile1 = tempnam('/tmp', 'smb_test_');
$this->share->get($this->root . '/foobar', $tmpFile1);
$this->assertEquals('qwerty', file_get_contents($tmpFile1));
unlink($tmpFile1);
}
}