mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-03 17:24:07 +02:00
update tests to new phpunit
This commit is contained in:
parent
743a7bf353
commit
58f6df3807
11 changed files with 59 additions and 101 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -4,3 +4,4 @@ composer.lock
|
||||||
.php_cs.cache
|
.php_cs.cache
|
||||||
listen.php
|
listen.php
|
||||||
test.php
|
test.php
|
||||||
|
*.cache
|
||||||
|
|
@ -2,10 +2,9 @@ dist: bionic
|
||||||
sudo: required
|
sudo: required
|
||||||
language: php
|
language: php
|
||||||
php:
|
php:
|
||||||
- 7.1
|
|
||||||
- 7.2
|
|
||||||
- 7.3
|
- 7.3
|
||||||
- 7.4
|
- 7.4
|
||||||
|
- 8.0
|
||||||
|
|
||||||
addons:
|
addons:
|
||||||
apt:
|
apt:
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,12 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require" : {
|
"require" : {
|
||||||
"php": ">=7.1",
|
"php": ">=7.3",
|
||||||
"icewind/streams": ">=0.2.0"
|
"icewind/streams": ">=0.7.0"
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^7.0",
|
"phpunit/phpunit": "^9.3.8",
|
||||||
"friendsofphp/php-cs-fixer": "^2.13"
|
"friendsofphp/php-cs-fixer": "^2.16"
|
||||||
},
|
},
|
||||||
"autoload" : {
|
"autoload" : {
|
||||||
"psr-4": {
|
"psr-4": {
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,12 @@
|
||||||
|
|
||||||
namespace Icewind\SMB\Test;
|
namespace Icewind\SMB\Test;
|
||||||
|
|
||||||
|
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;
|
||||||
|
use Icewind\SMB\Exception\InvalidResourceException;
|
||||||
|
use Icewind\SMB\Exception\InvalidTypeException;
|
||||||
|
use Icewind\SMB\Exception\NotEmptyException;
|
||||||
use Icewind\SMB\Exception\NotFoundException;
|
use Icewind\SMB\Exception\NotFoundException;
|
||||||
use Icewind\SMB\FileInfo;
|
use Icewind\SMB\FileInfo;
|
||||||
use Icewind\SMB\IFileInfo;
|
use Icewind\SMB\IFileInfo;
|
||||||
|
|
@ -32,7 +36,7 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown(): void {
|
||||||
try {
|
try {
|
||||||
if ($this->share) {
|
if ($this->share) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -142,9 +146,9 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testMkdirInvalidPath($name) {
|
public function testMkdirInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->mkdir($this->root . '/' . $name);
|
$this->share->mkdir($this->root . '/' . $name);
|
||||||
$dirs = $this->share->dir($this->root);
|
$dirs = $this->share->dir($this->root);
|
||||||
$this->assertCount(1, $dirs);
|
$this->assertCount(1, $dirs);
|
||||||
|
|
@ -191,9 +195,9 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testPutInvalidPath($name) {
|
public function testPutInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$tmpFile = $this->getTextFile('foo');
|
$tmpFile = $this->getTextFile('foo');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -237,10 +241,8 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
unlink($targetFile);
|
unlink($targetFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidResourceException
|
|
||||||
*/
|
|
||||||
public function testGetInvalidTarget() {
|
public function testGetInvalidTarget() {
|
||||||
|
$this->expectException(InvalidResourceException::class);
|
||||||
$name = 'test.txt';
|
$name = 'test.txt';
|
||||||
$text = 'dummy';
|
$text = 'dummy';
|
||||||
$tmpFile = $this->getTextFile($text);
|
$tmpFile = $this->getTextFile($text);
|
||||||
|
|
@ -273,78 +275,60 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testCreateFolderInNonExistingFolder() {
|
public function testCreateFolderInNonExistingFolder() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->mkdir($this->root . '/foo/bar');
|
$this->share->mkdir($this->root . '/foo/bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testRemoveFolderInNonExistingFolder() {
|
public function testRemoveFolderInNonExistingFolder() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->rmdir($this->root . '/foo/bar');
|
$this->share->rmdir($this->root . '/foo/bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testRemoveNonExistingFolder() {
|
public function testRemoveNonExistingFolder() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->rmdir($this->root . '/foo');
|
$this->share->rmdir($this->root . '/foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\AlreadyExistsException
|
|
||||||
*/
|
|
||||||
public function testCreateExistingFolder() {
|
public function testCreateExistingFolder() {
|
||||||
|
$this->expectException(AlreadyExistsException::class);
|
||||||
$this->share->mkdir($this->root . '/bar');
|
$this->share->mkdir($this->root . '/bar');
|
||||||
$this->share->mkdir($this->root . '/bar');
|
$this->share->mkdir($this->root . '/bar');
|
||||||
$this->share->rmdir($this->root . '/bar');
|
$this->share->rmdir($this->root . '/bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidTypeException
|
|
||||||
*/
|
|
||||||
public function testCreateFileExistingFolder() {
|
public function testCreateFileExistingFolder() {
|
||||||
|
$this->expectException(InvalidTypeException::class);
|
||||||
$this->share->mkdir($this->root . '/bar');
|
$this->share->mkdir($this->root . '/bar');
|
||||||
$this->share->put($this->getTextFile(), $this->root . '/bar');
|
$this->share->put($this->getTextFile(), $this->root . '/bar');
|
||||||
$this->share->rmdir($this->root . '/bar');
|
$this->share->rmdir($this->root . '/bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testCreateFileInNonExistingFolder() {
|
public function testCreateFileInNonExistingFolder() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->put($this->getTextFile(), $this->root . '/foo/bar');
|
$this->share->put($this->getTextFile(), $this->root . '/foo/bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testTestRemoveNonExistingFile() {
|
public function testTestRemoveNonExistingFile() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->del($this->root . '/foo');
|
$this->share->del($this->root . '/foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testDownloadInvalidPath($name) {
|
public function testDownloadInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->get($name, '');
|
$this->share->get($name, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testDownloadNonExistingFile() {
|
public function testDownloadNonExistingFile() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->get($this->root . '/foo', '/dev/null');
|
$this->share->get($this->root . '/foo', '/dev/null');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidTypeException
|
|
||||||
*/
|
|
||||||
public function testDownloadFolder() {
|
public function testDownloadFolder() {
|
||||||
|
$this->expectException(InvalidTypeException::class);
|
||||||
$this->share->mkdir($this->root . '/foobar');
|
$this->share->mkdir($this->root . '/foobar');
|
||||||
$this->share->get($this->root . '/foobar', '/dev/null');
|
$this->share->get($this->root . '/foobar', '/dev/null');
|
||||||
$this->share->rmdir($this->root . '/foobar');
|
$this->share->rmdir($this->root . '/foobar');
|
||||||
|
|
@ -352,25 +336,21 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testDelInvalidPath($name) {
|
public function testDelInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->del($name);
|
$this->share->del($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidTypeException
|
|
||||||
*/
|
|
||||||
public function testRmdirFile() {
|
public function testRmdirFile() {
|
||||||
|
$this->expectException(InvalidTypeException::class);
|
||||||
$this->share->put($this->getTextFile(), $this->root . '/foobar');
|
$this->share->put($this->getTextFile(), $this->root . '/foobar');
|
||||||
$this->share->rmdir($this->root . '/foobar');
|
$this->share->rmdir($this->root . '/foobar');
|
||||||
$this->share->del($this->root . '/foobar');
|
$this->share->del($this->root . '/foobar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotEmptyException
|
|
||||||
*/
|
|
||||||
public function testRmdirNotEmpty() {
|
public function testRmdirNotEmpty() {
|
||||||
|
$this->expectException(NotEmptyException::class);
|
||||||
$this->share->mkdir($this->root . '/foobar');
|
$this->share->mkdir($this->root . '/foobar');
|
||||||
$this->share->put($this->getTextFile(), $this->root . '/foobar/asd');
|
$this->share->put($this->getTextFile(), $this->root . '/foobar/asd');
|
||||||
$this->share->rmdir($this->root . '/foobar');
|
$this->share->rmdir($this->root . '/foobar');
|
||||||
|
|
@ -378,45 +358,37 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testRmDirInvalidPath($name) {
|
public function testRmDirInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->rmdir($name);
|
$this->share->rmdir($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testDirNonExisting() {
|
public function testDirNonExisting() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->dir('/foobar/asd');
|
$this->share->dir('/foobar/asd');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testRmDirNonExisting() {
|
public function testRmDirNonExisting() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->rmdir('/foobar/asd');
|
$this->share->rmdir('/foobar/asd');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testRenameNonExisting() {
|
public function testRenameNonExisting() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->rename('/foobar/asd', '/foobar/bar');
|
$this->share->rename('/foobar/asd', '/foobar/bar');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testRenameInvalidPath($name) {
|
public function testRenameInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->rename($name, $name . '_');
|
$this->share->rename($name, $name . '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testRenameTargetNonExisting() {
|
public function testRenameTargetNonExisting() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$txt = $this->getTextFile();
|
$txt = $this->getTextFile();
|
||||||
$this->share->put($txt, $this->root . '/foo.txt');
|
$this->share->put($txt, $this->root . '/foo.txt');
|
||||||
unlink($txt);
|
unlink($txt);
|
||||||
|
|
@ -448,9 +420,9 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testReadStreamInvalidPath($name) {
|
public function testReadStreamInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->read($name);
|
$this->share->read($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -488,9 +460,9 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testWriteStreamInvalidPath($name) {
|
public function testWriteStreamInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$fh = $this->share->write($this->root . '/' . $name);
|
$fh = $this->share->write($this->root . '/' . $name);
|
||||||
fwrite($fh, 'foo');
|
fwrite($fh, 'foo');
|
||||||
fclose($fh);
|
fclose($fh);
|
||||||
|
|
@ -525,9 +497,9 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testDirInvalidPath($name) {
|
public function testDirInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->dir($name);
|
$this->share->dir($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -547,16 +519,14 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider invalidPathProvider
|
* @dataProvider invalidPathProvider
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidPathException
|
|
||||||
*/
|
*/
|
||||||
public function testStatInvalidPath($name) {
|
public function testStatInvalidPath($name) {
|
||||||
|
$this->expectException(InvalidPathException::class);
|
||||||
$this->share->stat($name);
|
$this->share->stat($name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\NotFoundException
|
|
||||||
*/
|
|
||||||
public function testStatNonExisting() {
|
public function testStatNonExisting() {
|
||||||
|
$this->expectException(NotFoundException::class);
|
||||||
$this->share->stat($this->root . '/fo.txt');
|
$this->share->stat($this->root . '/fo.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -687,10 +657,8 @@ abstract class AbstractShareTest extends TestCase {
|
||||||
$this->assertInstanceOf('\Icewind\SMB\IFileInfo', $info);
|
$this->assertInstanceOf('\Icewind\SMB\IFileInfo', $info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\FileInUseException
|
|
||||||
*/
|
|
||||||
public function testMoveIntoSelf() {
|
public function testMoveIntoSelf() {
|
||||||
|
$this->expectException(FileInUseException::class);
|
||||||
$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');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ use Icewind\SMB\System;
|
||||||
use Icewind\SMB\TimeZoneProvider;
|
use Icewind\SMB\TimeZoneProvider;
|
||||||
|
|
||||||
class NativeShareTest extends AbstractShareTest {
|
class NativeShareTest extends AbstractShareTest {
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
$this->requireBackendEnv('libsmbclient');
|
$this->requireBackendEnv('libsmbclient');
|
||||||
if (!function_exists('smbclient_state_new')) {
|
if (!function_exists('smbclient_state_new')) {
|
||||||
$this->markTestSkipped('libsmbclient php extension not installed');
|
$this->markTestSkipped('libsmbclient php extension not installed');
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ class NativeStreamTest extends TestCase {
|
||||||
|
|
||||||
protected $config;
|
protected $config;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
$this->requireBackendEnv('libsmbclient');
|
$this->requireBackendEnv('libsmbclient');
|
||||||
if (!function_exists('smbclient_state_new')) {
|
if (!function_exists('smbclient_state_new')) {
|
||||||
$this->markTestSkipped('libsmbclient php extension not installed');
|
$this->markTestSkipped('libsmbclient php extension not installed');
|
||||||
|
|
@ -137,7 +137,7 @@ class NativeStreamTest extends TestCase {
|
||||||
$this->assertFalse(stream_set_blocking($fh, false));
|
$this->assertFalse(stream_set_blocking($fh, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function tearDown() {
|
public function tearDown(): void {
|
||||||
if ($this->share) {
|
if ($this->share) {
|
||||||
$this->cleanDir($this->root);
|
$this->cleanDir($this->root);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ class NotifyHandlerTest extends TestCase {
|
||||||
|
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
$this->requireBackendEnv('smbclient');
|
$this->requireBackendEnv('smbclient');
|
||||||
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
||||||
$this->server = new Server(
|
$this->server = new Server(
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@
|
||||||
namespace Icewind\SMB\Test;
|
namespace Icewind\SMB\Test;
|
||||||
|
|
||||||
use Icewind\SMB\AnonymousAuth;
|
use Icewind\SMB\AnonymousAuth;
|
||||||
|
use Icewind\SMB\Exception\DependencyException;
|
||||||
use Icewind\SMB\IAuth;
|
use Icewind\SMB\IAuth;
|
||||||
use Icewind\SMB\Native\NativeServer;
|
use Icewind\SMB\Native\NativeServer;
|
||||||
use Icewind\SMB\ServerFactory;
|
use Icewind\SMB\ServerFactory;
|
||||||
|
|
@ -32,7 +33,7 @@ class ServerFactoryTest extends TestCase {
|
||||||
/** @var IAuth */
|
/** @var IAuth */
|
||||||
private $credentials;
|
private $credentials;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->credentials = new AnonymousAuth();
|
$this->credentials = new AnonymousAuth();
|
||||||
|
|
@ -59,10 +60,8 @@ class ServerFactoryTest extends TestCase {
|
||||||
$this->assertInstanceOf(NativeServer::class, $factory->createServer('localhost', $this->credentials));
|
$this->assertInstanceOf(NativeServer::class, $factory->createServer('localhost', $this->credentials));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\DependencyException
|
|
||||||
*/
|
|
||||||
public function testNoBackend() {
|
public function testNoBackend() {
|
||||||
|
$this->expectException(DependencyException::class);
|
||||||
$this->requireBackendEnv('smbclient');
|
$this->requireBackendEnv('smbclient');
|
||||||
$system = $this->getMockBuilder(System::class)
|
$system = $this->getMockBuilder(System::class)
|
||||||
->setMethods(['libSmbclientAvailable', 'getSmbclientPath'])
|
->setMethods(['libSmbclientAvailable', 'getSmbclientPath'])
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@
|
||||||
namespace Icewind\SMB\Test;
|
namespace Icewind\SMB\Test;
|
||||||
|
|
||||||
use Icewind\SMB\BasicAuth;
|
use Icewind\SMB\BasicAuth;
|
||||||
|
use Icewind\SMB\Exception\AuthenticationException;
|
||||||
|
use Icewind\SMB\Exception\InvalidHostException;
|
||||||
use Icewind\SMB\IShare;
|
use Icewind\SMB\IShare;
|
||||||
use Icewind\SMB\Options;
|
use Icewind\SMB\Options;
|
||||||
use Icewind\SMB\System;
|
use Icewind\SMB\System;
|
||||||
|
|
@ -22,7 +24,7 @@ class ServerTest extends TestCase {
|
||||||
|
|
||||||
private $config;
|
private $config;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
$this->requireBackendEnv('smbclient');
|
$this->requireBackendEnv('smbclient');
|
||||||
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
||||||
$this->server = new Server(
|
$this->server = new Server(
|
||||||
|
|
@ -47,10 +49,8 @@ class ServerTest extends TestCase {
|
||||||
$this->assertContains($this->config->share, $names);
|
$this->assertContains($this->config->share, $names);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\AuthenticationException
|
|
||||||
*/
|
|
||||||
public function testWrongUserName() {
|
public function testWrongUserName() {
|
||||||
|
$this->expectException(AuthenticationException::class);
|
||||||
$this->markTestSkipped('This fails for no reason on travis');
|
$this->markTestSkipped('This fails for no reason on travis');
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
|
|
@ -66,10 +66,8 @@ class ServerTest extends TestCase {
|
||||||
$server->listShares();
|
$server->listShares();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\AuthenticationException
|
|
||||||
*/
|
|
||||||
public function testWrongPassword() {
|
public function testWrongPassword() {
|
||||||
|
$this->expectException(AuthenticationException::class);
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
$this->config->host,
|
$this->config->host,
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
|
|
@ -84,10 +82,8 @@ class ServerTest extends TestCase {
|
||||||
$server->listShares();
|
$server->listShares();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidHostException
|
|
||||||
*/
|
|
||||||
public function testWrongHost() {
|
public function testWrongHost() {
|
||||||
|
$this->expectException(InvalidHostException::class);
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
uniqid(),
|
uniqid(),
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
|
|
@ -102,11 +98,8 @@ class ServerTest extends TestCase {
|
||||||
$server->listShares();
|
$server->listShares();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\InvalidHostException
|
|
||||||
*/
|
|
||||||
public function testHostEscape() {
|
public function testHostEscape() {
|
||||||
|
$this->expectException(InvalidHostException::class);
|
||||||
$server = new Server(
|
$server = new Server(
|
||||||
$this->config->host . ';asd',
|
$this->config->host . ';asd',
|
||||||
new BasicAuth(
|
new BasicAuth(
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,15 @@
|
||||||
namespace Icewind\SMB\Test;
|
namespace Icewind\SMB\Test;
|
||||||
|
|
||||||
use Icewind\SMB\BasicAuth;
|
use Icewind\SMB\BasicAuth;
|
||||||
|
use Icewind\SMB\Exception\ConnectException;
|
||||||
|
use Icewind\SMB\Exception\DependencyException;
|
||||||
use Icewind\SMB\Options;
|
use Icewind\SMB\Options;
|
||||||
use Icewind\SMB\System;
|
use Icewind\SMB\System;
|
||||||
use Icewind\SMB\TimeZoneProvider;
|
use Icewind\SMB\TimeZoneProvider;
|
||||||
use Icewind\SMB\Wrapped\Server as NormalServer;
|
use Icewind\SMB\Wrapped\Server as NormalServer;
|
||||||
|
|
||||||
class ShareTest extends AbstractShareTest {
|
class ShareTest extends AbstractShareTest {
|
||||||
public function setUp() {
|
public function setUp(): void {
|
||||||
$this->requireBackendEnv('smbclient');
|
$this->requireBackendEnv('smbclient');
|
||||||
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
||||||
$this->server = new NormalServer(
|
$this->server = new NormalServer(
|
||||||
|
|
@ -37,17 +39,13 @@ class ShareTest extends AbstractShareTest {
|
||||||
$this->share->mkdir($this->root);
|
$this->share->mkdir($this->root);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\DependencyException
|
|
||||||
*/
|
|
||||||
public function testAppendStream() {
|
public function testAppendStream() {
|
||||||
|
$this->expectException(DependencyException::class);
|
||||||
$this->share->append($this->root . '/foo');
|
$this->share->append($this->root . '/foo');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @expectedException \Icewind\SMB\Exception\ConnectException
|
|
||||||
*/
|
|
||||||
public function testHostEscape() {
|
public function testHostEscape() {
|
||||||
|
$this->expectException(ConnectException::class);
|
||||||
$this->requireBackendEnv('smbclient');
|
$this->requireBackendEnv('smbclient');
|
||||||
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
$this->config = json_decode(file_get_contents(__DIR__ . '/config.json'));
|
||||||
$this->server = new NormalServer(
|
$this->server = new NormalServer(
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ class TimeZoneProviderTest extends TestCase {
|
||||||
/** @var TimeZoneProvider */
|
/** @var TimeZoneProvider */
|
||||||
private $provider;
|
private $provider;
|
||||||
|
|
||||||
protected function setUp() {
|
protected function setUp(): void {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->system = $this->createMock(ISystem::class);
|
$this->system = $this->createMock(ISystem::class);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue