mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
Add negative tests for stat and rename
This commit is contained in:
parent
125bc445f7
commit
9068418528
3 changed files with 28 additions and 2 deletions
|
|
@ -39,11 +39,13 @@ class NativeFileInfo implements IFileInfo {
|
|||
* @param \Icewind\SMB\NativeShare $share
|
||||
* @param string $path
|
||||
* @param string $name
|
||||
* @param array $stat
|
||||
*/
|
||||
public function __construct($share, $path, $name) {
|
||||
public function __construct($share, $path, $name, $stat = null) {
|
||||
$this->share = $share;
|
||||
$this->path = $path;
|
||||
$this->name = $name;
|
||||
$this->statCache = $stat;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ class NativeShare implements IShare {
|
|||
* @return \Icewind\SMB\IFileInfo[]
|
||||
*/
|
||||
public function stat($path) {
|
||||
return new NativeFileInfo($this, $path, basename($path));
|
||||
return new NativeFileInfo($this, $path, basename($path), $this->getStat($path));
|
||||
}
|
||||
|
||||
public function getStat($path) {
|
||||
|
|
|
|||
|
|
@ -303,6 +303,23 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
|
|||
$this->share->rmdir('/foobar/asd');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icewind\SMB\NotFoundException
|
||||
*/
|
||||
public function testRenameNonExisting() {
|
||||
$this->share->rename('/foobar/asd', '/foobar/bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icewind\SMB\NotFoundException
|
||||
*/
|
||||
public function testRenameTargetNonExisting() {
|
||||
$txt= $this->getTextFile();
|
||||
$this->share->put($txt, $this->root . '/foo.txt');
|
||||
unlink($txt);
|
||||
$this->share->rename($this->root . '/foo.txt', $this->root . '/bar/foo.txt');
|
||||
}
|
||||
|
||||
public function testModifiedDate() {
|
||||
$now = time();
|
||||
$this->share->put($this->getTextFile(), $this->root . '/foo.txt');
|
||||
|
|
@ -387,6 +404,13 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
|
|||
$this->assertEquals($size, $info->getSize());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icewind\SMB\NotFoundException
|
||||
*/
|
||||
public function testStatNonExisting() {
|
||||
$this->share->stat($this->root . '/fo.txt');
|
||||
}
|
||||
|
||||
/**
|
||||
* note setting archive and system bit is not supported
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue