extend tests a bit

This commit is contained in:
Robin Appelman 2021-03-10 14:53:02 +01:00
commit d218982775
4 changed files with 50 additions and 13 deletions

View file

@ -7,6 +7,7 @@
namespace Icewind\SMB\Test; namespace Icewind\SMB\Test;
use Icewind\SMB\ACL;
use Icewind\SMB\Exception\AlreadyExistsException; use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\FileInUseException; use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidPathException; use Icewind\SMB\Exception\InvalidPathException;
@ -698,4 +699,25 @@ abstract class AbstractShareTest extends TestCase {
$this->share->mkdir($this->root . '/folder'); $this->share->mkdir($this->root . '/folder');
$this->share->rename($this->root . '/folder', $this->root . '/folder/subfolder'); $this->share->rename($this->root . '/folder', $this->root . '/folder/subfolder');
} }
public function testDirACL() {
$this->share->mkdir($this->root . "/test");
$listing = $this->share->dir($this->root);
$this->assertCount(1, $listing);
$acls = $listing[0]->getAcls();
$acl = $acls['Everyone'];
$this->assertEquals($acl->getType(), ACL::TYPE_ALLOW);
$this->assertEquals(ACL::MASK_READ, $acl->getMask() & ACL::MASK_READ);
}
public function testStatACL() {
$this->share->mkdir($this->root . "/test");
$info = $this->share->stat($this->root);
$acls = $info->getAcls();
$acl = $acls['Everyone'];
$this->assertEquals($acl->getType(), ACL::TYPE_ALLOW);
$this->assertEquals(ACL::MASK_READ, $acl->getMask() & ACL::MASK_READ);
}
} }

View file

@ -82,15 +82,4 @@ class NativeShareTest extends AbstractShareTest {
); );
$server->listShares(); $server->listShares();
} }
public function testACL() {
$this->share->mkdir($this->root . "/test");
$listing = $this->share->dir($this->root);
$this->assertCount(1, $listing);
$acls = $listing[0]->getAcls();
$acl = $acls['Everyone'];
$this->assertEquals($acl->getType(), ACL::TYPE_ALLOW);
$this->assertEquals(ACL::MASK_READ, $acl->getMask() & ACL::MASK_READ);
}
} }

View file

@ -10,6 +10,7 @@ namespace Icewind\SMB\Test;
use Icewind\SMB\BasicAuth; use Icewind\SMB\BasicAuth;
use Icewind\SMB\Change; use Icewind\SMB\Change;
use Icewind\SMB\Exception\AlreadyExistsException; use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\RevisionMismatchException; use Icewind\SMB\Exception\RevisionMismatchException;
use Icewind\SMB\INotifyHandler; use Icewind\SMB\INotifyHandler;
use Icewind\SMB\IShare; use Icewind\SMB\IShare;
@ -186,4 +187,29 @@ class NotifyHandlerTest extends TestCase {
}); });
$this->assertNotNull($results); $this->assertNotNull($results);
} }
public function testNoStdBuf(): void {
$this->requireBackendEnv('smbclient');
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
$system = $this->getMockBuilder(System::class)
->onlyMethods(['getStdBufPath'])
->getMock();
$system->method('getStdBufPath')
->willReturn(null);
$server = new Server(
$this->config->host,
new BasicAuth(
$this->config->user,
'test',
$this->config->password
),
$system,
new TimeZoneProvider(new System()),
new Options()
);
$share = $server->getShare($this->config->share);
$this->expectException(Exception::class);
$share->notify('');
}
} }

View file

@ -42,7 +42,7 @@ class ServerFactoryTest extends TestCase {
public function testSmbClient() { public function testSmbClient() {
$this->requireBackendEnv('smbclient'); $this->requireBackendEnv('smbclient');
$system = $this->getMockBuilder(System::class) $system = $this->getMockBuilder(System::class)
->setMethods(['libSmbclientAvailable']) ->onlyMethods(['libSmbclientAvailable'])
->getMock(); ->getMock();
$system->expects($this->any()) $system->expects($this->any())
->method('libSmbclientAvailable') ->method('libSmbclientAvailable')