mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
Extend nativestream tests
This commit is contained in:
parent
dd983282a6
commit
0cf2fa0904
2 changed files with 30 additions and 2 deletions
|
|
@ -31,14 +31,14 @@ class NativeStream {
|
||||||
if (isset($context['nativesmb'])) {
|
if (isset($context['nativesmb'])) {
|
||||||
$context = $context['nativesmb'];
|
$context = $context['nativesmb'];
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('Invalid context');
|
throw new Exception('Invalid context');
|
||||||
}
|
}
|
||||||
if (isset($context['state']) and isset($context['handle'])) {
|
if (isset($context['state']) and isset($context['handle'])) {
|
||||||
$this->state = $context['state'];
|
$this->state = $context['state'];
|
||||||
$this->handle = $context['handle'];
|
$this->handle = $context['handle'];
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
throw new \Exception('Invalid context');
|
throw new Exception('Invalid context');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -79,6 +79,15 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
|
||||||
unlink($tmpFile1);
|
unlink($tmpFile1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStat() {
|
||||||
|
$sourceFile = $this->getTextFile();
|
||||||
|
$this->share->put($sourceFile, $this->root . '/foobar');
|
||||||
|
$fh = $this->share->read($this->root . '/foobar');
|
||||||
|
$stat = fstat($fh);
|
||||||
|
$this->assertEquals(filesize($sourceFile), $stat['size']);
|
||||||
|
unlink($sourceFile);
|
||||||
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
if ($this->share) {
|
if ($this->share) {
|
||||||
$this->cleanDir($this->root);
|
$this->cleanDir($this->root);
|
||||||
|
|
@ -97,4 +106,23 @@ class NativeStream extends \PHPUnit_Framework_TestCase {
|
||||||
}
|
}
|
||||||
$this->share->rmdir($dir);
|
$this->share->rmdir($dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Icewind\SMB\Exception
|
||||||
|
*/
|
||||||
|
public function testNoContext() {
|
||||||
|
return fopen('nativesmb://dummy', 'r');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException \Icewind\SMB\Exception
|
||||||
|
*/
|
||||||
|
public function testInvalidContext() {
|
||||||
|
$context = stream_context_create(array(
|
||||||
|
'nativesmb' => array(
|
||||||
|
'foo' => 'bar'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
return fopen('nativesmb://dummy', 'r', false, $context);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue