mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 09:14:06 +02:00
Add native implementation using the libsmbclient-php extensions
This commit is contained in:
parent
0520cba7dc
commit
3c67574fff
6 changed files with 460 additions and 9 deletions
29
tests/nativeshare.php
Normal file
29
tests/nativeshare.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace SMB\Test;
|
||||
|
||||
require_once 'share.php';
|
||||
|
||||
class NativeShare extends Share {
|
||||
|
||||
|
||||
/**
|
||||
* @var \Icewind\SMB\NativeShare $share
|
||||
*/
|
||||
protected $share;
|
||||
|
||||
public function setUp() {
|
||||
if (!function_exists('smbclient_state_new')) {
|
||||
$this->markTestSkipped('libsmbclient php extension not installed');
|
||||
}
|
||||
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
||||
$this->server = new \Icewind\SMB\NativeServer($this->config->host, $this->config->user, $this->config->password);
|
||||
$this->share = new \Icewind\SMB\NativeShare($this->server, $this->config->share);
|
||||
if ($this->config->root) {
|
||||
$this->root = '/' . $this->config->root . '/' . uniqid();
|
||||
} else {
|
||||
$this->root = '/' . uniqid();
|
||||
}
|
||||
$this->share->mkdir($this->root);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,24 +6,24 @@ class Share extends \PHPUnit_Framework_TestCase {
|
|||
/**
|
||||
* @var \Icewind\SMB\Server $server
|
||||
*/
|
||||
private $server;
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* @var \Icewind\SMB\Share $share
|
||||
*/
|
||||
private $share;
|
||||
protected $share;
|
||||
|
||||
/**
|
||||
* @var string $root
|
||||
*/
|
||||
private $root;
|
||||
protected $root;
|
||||
|
||||
private $config;
|
||||
protected $config;
|
||||
|
||||
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 = $this->server->getShare($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 {
|
||||
|
|
@ -243,7 +243,7 @@ class Share extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Icewind\SMB\NotFoundException
|
||||
* @expectedException \Icewind\SMB\InvalidTypeException
|
||||
*/
|
||||
public function testDelFolder() {
|
||||
$this->share->mkdir($this->root . '/foobar');
|
||||
|
|
@ -293,6 +293,7 @@ class Share extends \PHPUnit_Framework_TestCase {
|
|||
$this->share->put($sourceFile, $this->root . '/foobar');
|
||||
$fh = $this->share->read($this->root . '/foobar');
|
||||
$content = stream_get_contents($fh);
|
||||
fclose($fh);
|
||||
$this->share->del($this->root . '/foobar');
|
||||
|
||||
$this->assertEquals(file_get_contents($sourceFile), $content);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue