Move Exceptions to their own namespace

This commit is contained in:
Robin Appelman 2014-08-06 23:15:12 +02:00
commit 5c57d2d094
22 changed files with 233 additions and 123 deletions

View file

@ -7,6 +7,10 @@
namespace Icewind\SMB; namespace Icewind\SMB;
use Icewind\SMB\Exception\AuthenticationException;
use Icewind\SMB\Exception\ConnectionException;
use Icewind\SMB\Exception\InvalidHostException;
class Connection extends RawConnection { class Connection extends RawConnection {
const DELIMITER = 'smb:'; const DELIMITER = 'smb:';
@ -22,12 +26,12 @@ class Connection extends RawConnection {
/** /**
* get all unprocessed output from smbclient until the next prompt * get all unprocessed output from smbclient until the next prompt
* *
* @throws ConnectionError * @throws ConnectionException
* @return string * @return string
*/ */
public function read() { public function read() {
if (!$this->isValid()) { if (!$this->isValid()) {
throw new ConnectionError(); throw new ConnectionException();
} }
$line = $this->readLine(); //first line is prompt $line = $this->readLine(); //first line is prompt
$this->checkConnectionError($line); $this->checkConnectionError($line);

View file

@ -7,43 +7,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
class Exception extends \Exception {
}
class ConnectException extends Exception {
}
class ConnectionError extends ConnectException {
}
class AuthenticationException extends ConnectException {
}
class InvalidHostException extends ConnectException {
}
class AccessDeniedException extends ConnectException {
}
class InvalidRequestException extends Exception {
}
class NotFoundException extends InvalidRequestException {
}
class AlreadyExistsException extends InvalidRequestException {
}
class NotEmptyException extends InvalidRequestException {
}
class InvalidTypeException extends InvalidRequestException {
}
class ForbiddenException extends InvalidRequestException {
}
class ErrorCodes { class ErrorCodes {
/** /**
* connection errors * connection errors

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class AccessDeniedException extends ConnectException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class AlreadyExistsException extends InvalidRequestException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class AuthenticationException extends ConnectException{}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class ConnectException extends Exception {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class ConnectionException extends ConnectException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class Exception extends \Exception {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class ForbiddenException extends InvalidRequestException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class InvalidHostException extends ConnectException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class InvalidRequestException extends Exception {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class InvalidTypeException extends InvalidRequestException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class NotEmptyException extends InvalidRequestException {}

View file

@ -0,0 +1,10 @@
<?php
/**
* Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
* This file is licensed under the Licensed under the MIT license:
* http://opensource.org/licenses/MIT
*/
namespace Icewind\SMB\Exception;
class NotFoundException extends InvalidRequestException {}

View file

@ -34,8 +34,8 @@ class NativeServer extends Server {
/** /**
* @return \Icewind\SMB\IShare[] * @return \Icewind\SMB\IShare[]
* @throws \Icewind\SMB\AuthenticationException * @throws \Icewind\SMB\Exception\AuthenticationException
* @throws \Icewind\SMB\InvalidHostException * @throws \Icewind\SMB\Exception\InvalidHostException
*/ */
public function listShares() { public function listShares() {
$this->connect(); $this->connect();

View file

@ -7,8 +7,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
require_once 'ErrorCodes.php';
class NativeShare implements IShare { class NativeShare implements IShare {
/** /**
* @var Server $server * @var Server $server
@ -36,9 +34,9 @@ class NativeShare implements IShare {
} }
/** /**
* @throws \Icewind\SMB\ConnectionError * @throws \Icewind\SMB\Exception\ConnectionException
* @throws \Icewind\SMB\AuthenticationException * @throws \Icewind\SMB\Exception\AuthenticationException
* @throws \Icewind\SMB\InvalidHostException * @throws \Icewind\SMB\Exception\InvalidHostException
*/ */
protected function connect() { protected function connect() {
if ($this->state and $this->state instanceof NativeShare) { if ($this->state and $this->state instanceof NativeShare) {
@ -63,7 +61,7 @@ class NativeShare implements IShare {
} }
private function buildUrl($path) { private function buildUrl($path) {
$url = 'smb://' . $this->server->getHost() . '/' . $this->name; $url = sprintf('smb://%s/%s', $this->server->getHost(), $this->name);
if ($path) { if ($path) {
$path = trim($path, '/'); $path = trim($path, '/');
$url .= '/' . $path; $url .= '/' . $path;
@ -77,8 +75,8 @@ class NativeShare implements IShare {
* @param string $path * @param string $path
* @return \Icewind\SMB\IFileInfo[] * @return \Icewind\SMB\IFileInfo[]
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function dir($path) { public function dir($path) {
$this->connect(); $this->connect();
@ -115,8 +113,8 @@ class NativeShare implements IShare {
* @param string $path * @param string $path
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\AlreadyExistsException * @throws \Icewind\SMB\Exception\AlreadyExistsException
*/ */
public function mkdir($path) { public function mkdir($path) {
$this->connect(); $this->connect();
@ -129,8 +127,8 @@ class NativeShare implements IShare {
* @param string $path * @param string $path
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function rmdir($path) { public function rmdir($path) {
$this->connect(); $this->connect();
@ -143,8 +141,8 @@ class NativeShare implements IShare {
* @param string $path * @param string $path
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function del($path) { public function del($path) {
return $this->state->unlink($this->buildUrl($path)); return $this->state->unlink($this->buildUrl($path));
@ -157,8 +155,8 @@ class NativeShare implements IShare {
* @param string $to * @param string $to
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\AlreadyExistsException * @throws \Icewind\SMB\Exception\AlreadyExistsException
*/ */
public function rename($from, $to) { public function rename($from, $to) {
$this->connect(); $this->connect();
@ -172,8 +170,8 @@ class NativeShare implements IShare {
* @param string $target remove file * @param string $target remove file
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function put($source, $target) { public function put($source, $target) {
$this->connect(); $this->connect();
@ -195,8 +193,8 @@ class NativeShare implements IShare {
* @param string $target local file * @param string $target local file
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function get($source, $target) { public function get($source, $target) {
$this->connect(); $this->connect();
@ -216,8 +214,8 @@ class NativeShare implements IShare {
* @param string $source * @param string $source
* @return resource a read only stream with the contents of the remote file * @return resource a read only stream with the contents of the remote file
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function read($source) { public function read($source) {
$this->connect(); $this->connect();
@ -231,8 +229,8 @@ class NativeShare implements IShare {
* @param string $source * @param string $source
* @return resource a read only stream with the contents of the remote file * @return resource a read only stream with the contents of the remote file
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function write($source) { public function write($source) {
$this->connect(); $this->connect();

View file

@ -7,7 +7,11 @@
namespace Icewind\SMB; namespace Icewind\SMB;
require_once 'ErrorCodes.php'; use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\ForbiddenException;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NotFoundException;
/** /**
* Low level wrapper for libsmbclient-php for error handling * Low level wrapper for libsmbclient-php for error handling

View file

@ -7,6 +7,8 @@
namespace Icewind\SMB; namespace Icewind\SMB;
use Icewind\SMB\Exception\ConnectionException;
class RawConnection { class RawConnection {
/** /**
* @var resource[] $pipes * @var resource[] $pipes
@ -37,7 +39,7 @@ class RawConnection {
)); ));
$this->process = proc_open($command, $descriptorSpec, $this->pipes, '/', $env); $this->process = proc_open($command, $descriptorSpec, $this->pipes, '/', $env);
if (!$this->isValid()) { if (!$this->isValid()) {
throw new ConnectionError(); throw new ConnectionException();
} }
} }

View file

@ -7,6 +7,9 @@
namespace Icewind\SMB; namespace Icewind\SMB;
use Icewind\SMB\Exception\AuthenticationException;
use Icewind\SMB\Exception\InvalidHostException;
class Server { class Server {
const CLIENT = 'smbclient'; const CLIENT = 'smbclient';
const LOCALE = 'en_US.UTF-8'; const LOCALE = 'en_US.UTF-8';
@ -77,8 +80,8 @@ class Server {
/** /**
* @return \Icewind\SMB\IShare[] * @return \Icewind\SMB\IShare[]
* *
* @throws \Icewind\SMB\AuthenticationException * @throws \Icewind\SMB\Exception\AuthenticationException
* @throws \Icewind\SMB\InvalidHostException * @throws \Icewind\SMB\Exception\InvalidHostException
*/ */
public function listShares() { public function listShares() {
$command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' . $command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' .

View file

@ -7,6 +7,13 @@
namespace Icewind\SMB; namespace Icewind\SMB;
use Icewind\SMB\Exception\AccessDeniedException;
use Icewind\SMB\Exception\AlreadyExistsException;
use Icewind\SMB\Exception\ConnectionException;
use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\InvalidTypeException;
use Icewind\SMB\Exception\NotEmptyException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\Streams\CallbackWrapper; use Icewind\Streams\CallbackWrapper;
class Share implements IShare { class Share implements IShare {
@ -37,20 +44,23 @@ class Share implements IShare {
} }
/** /**
* @throws \Icewind\SMB\ConnectionError * @throws \Icewind\SMB\Exception\ConnectionError
* @throws \Icewind\SMB\AuthenticationException * @throws \Icewind\SMB\Exception\AuthenticationException
* @throws \Icewind\SMB\InvalidHostException * @throws \Icewind\SMB\Exception\InvalidHostException
*/ */
protected function connect() { protected function connect() {
if ($this->connection and $this->connection->isValid()) { if ($this->connection and $this->connection->isValid()) {
return; return;
} }
$command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' . $command = sprintf('%s --authentication-file=/proc/self/fd/3 //%s/%s',
' //' . $this->server->getHost() . '/' . $this->name; Server::CLIENT,
$this->server->getHost(),
$this->name
);
$this->connection = new Connection($command); $this->connection = new Connection($command);
$this->connection->writeAuthentication($this->server->getUser(), $this->server->getPassword()); $this->connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
if (!$this->connection->isValid()) { if (!$this->connection->isValid()) {
throw new ConnectionError(); throw new ConnectionException();
} }
} }
@ -83,8 +93,8 @@ class Share implements IShare {
* @param $path * @param $path
* @return \Icewind\SMB\IFileInfo[] * @return \Icewind\SMB\IFileInfo[]
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function dir($path) { public function dir($path) {
$escapedPath = $this->escapePath($path); $escapedPath = $this->escapePath($path);
@ -146,8 +156,8 @@ class Share implements IShare {
* @param string $path * @param string $path
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\AlreadyExistsException * @throws \Icewind\SMB\Exception\AlreadyExistsException
*/ */
public function mkdir($path) { public function mkdir($path) {
return $this->simpleCommand('mkdir', $path); return $this->simpleCommand('mkdir', $path);
@ -159,8 +169,8 @@ class Share implements IShare {
* @param string $path * @param string $path
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function rmdir($path) { public function rmdir($path) {
return $this->simpleCommand('rmdir', $path); return $this->simpleCommand('rmdir', $path);
@ -172,8 +182,8 @@ class Share implements IShare {
* @param string $path * @param string $path
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function del($path) { public function del($path) {
//del return a file not found error when trying to delete a folder //del return a file not found error when trying to delete a folder
@ -200,8 +210,8 @@ class Share implements IShare {
* @param string $to * @param string $to
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\AlreadyExistsException * @throws \Icewind\SMB\Exception\AlreadyExistsException
*/ */
public function rename($from, $to) { public function rename($from, $to) {
$path1 = $this->escapePath($from); $path1 = $this->escapePath($from);
@ -218,8 +228,8 @@ class Share implements IShare {
* @param string $target remove file * @param string $target remove file
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function put($source, $target) { public function put($source, $target) {
$path1 = $this->escapeLocalPath($source); //first path is local, needs different escaping $path1 = $this->escapeLocalPath($source); //first path is local, needs different escaping
@ -235,8 +245,8 @@ class Share implements IShare {
* @param string $target local file * @param string $target local file
* @return bool * @return bool
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function get($source, $target) { public function get($source, $target) {
$path1 = $this->escapePath($source); $path1 = $this->escapePath($source);
@ -251,8 +261,8 @@ class Share implements IShare {
* @param string $source * @param string $source
* @return resource a read only stream with the contents of the remote file * @return resource a read only stream with the contents of the remote file
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function read($source) { public function read($source) {
$source = $this->escapePath($source); $source = $this->escapePath($source);
@ -260,9 +270,12 @@ class Share implements IShare {
$source = str_replace('\'', '\'"\'"\'', $source); $source = str_replace('\'', '\'"\'"\'', $source);
// since returned stream is closed by the caller we need to create a new instance // since returned stream is closed by the caller we need to create a new instance
// since we can't re-use the same file descriptor over multiple calls // since we can't re-use the same file descriptor over multiple calls
$command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' . $command = sprintf('%s --authentication-file=/proc/self/fd/3 //%s/%s -c \'get %s /proc/self/fd/5\'',
' //' . $this->server->getHost() . '/' . $this->name Server::CLIENT,
. ' -c \'get ' . $source . ' /proc/self/fd/5\''; $this->server->getHost(),
$this->name,
$source
);
$connection = new Connection($command); $connection = new Connection($command);
$connection->writeAuthentication($this->server->getUser(), $this->server->getPassword()); $connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
$fh = $connection->getFileOutputStream(); $fh = $connection->getFileOutputStream();
@ -276,8 +289,8 @@ class Share implements IShare {
* @param string $target * @param string $target
* @return resource a write only stream to upload a remote file * @return resource a write only stream to upload a remote file
* *
* @throws \Icewind\SMB\NotFoundException * @throws \Icewind\SMB\Exception\NotFoundException
* @throws \Icewind\SMB\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function write($target) { public function write($target) {
$target = $this->escapePath($target); $target = $this->escapePath($target);
@ -285,9 +298,12 @@ class Share implements IShare {
$target = str_replace('\'', '\'"\'"\'', $target); $target = str_replace('\'', '\'"\'"\'', $target);
// since returned stream is closed by the caller we need to create a new instance // since returned stream is closed by the caller we need to create a new instance
// since we can't re-use the same file descriptor over multiple calls // since we can't re-use the same file descriptor over multiple calls
$command = Server::CLIENT . ' --authentication-file=/proc/self/fd/3' . $command = sprintf('%s --authentication-file=/proc/self/fd/3 //%s/%s -c \'put /proc/self/fd/4 %s\'',
' //' . $this->server->getHost() . '/' . $this->name Server::CLIENT,
. ' -c \'put /proc/self/fd/4 ' . $target . '\''; $this->server->getHost(),
$this->name,
$target
);
$connection = new RawConnection($command); $connection = new RawConnection($command);
$connection->writeAuthentication($this->server->getUser(), $this->server->getPassword()); $connection->writeAuthentication($this->server->getUser(), $this->server->getPassword());
$fh = $connection->getFileInputStream(); $fh = $connection->getFileInputStream();
@ -368,11 +384,11 @@ class Share implements IShare {
* @param $lines * @param $lines
* *
* @throws NotFoundException * @throws NotFoundException
* @throws AlreadyExistsException * @throws \Icewind\SMB\Exception\AlreadyExistsException
* @throws AccessDeniedException * @throws \Icewind\SMB\Exception\AccessDeniedException
* @throws NotEmptyException * @throws \Icewind\SMB\Exception\NotEmptyException
* @throws InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
* @throws \Exception * @throws \Icewind\SMB\Exception\Exception
* @return bool * @return bool
*/ */
protected function parseOutput($lines) { protected function parseOutput($lines) {

View file

@ -203,28 +203,28 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testCreateFolderInNonExistingFolder() { public function testCreateFolderInNonExistingFolder() {
$this->share->mkdir($this->root . '/foo/bar'); $this->share->mkdir($this->root . '/foo/bar');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testRemoveFolderInNonExistingFolder() { public function testRemoveFolderInNonExistingFolder() {
$this->share->rmdir($this->root . '/foo/bar'); $this->share->rmdir($this->root . '/foo/bar');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testRemoveNonExistingFolder() { public function testRemoveNonExistingFolder() {
$this->share->rmdir($this->root . '/foo'); $this->share->rmdir($this->root . '/foo');
} }
/** /**
* @expectedException \Icewind\SMB\AlreadyExistsException * @expectedException \Icewind\SMB\Exception\AlreadyExistsException
*/ */
public function testCreateExistingFolder() { public function testCreateExistingFolder() {
$this->share->mkdir($this->root . '/bar'); $this->share->mkdir($this->root . '/bar');
@ -233,7 +233,7 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\InvalidTypeException * @expectedException \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function testCreateFileExistingFolder() { public function testCreateFileExistingFolder() {
$this->share->mkdir($this->root . '/bar'); $this->share->mkdir($this->root . '/bar');
@ -242,28 +242,28 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testCreateFileInNonExistingFolder() { public function testCreateFileInNonExistingFolder() {
$this->share->put($this->getTextFile(), $this->root . '/foo/bar'); $this->share->put($this->getTextFile(), $this->root . '/foo/bar');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testTestRemoveNonExistingFile() { public function testTestRemoveNonExistingFile() {
$this->share->del($this->root . '/foo'); $this->share->del($this->root . '/foo');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testDownloadNonExistingFile() { public function testDownloadNonExistingFile() {
$this->share->get($this->root . '/foo', '/dev/null'); $this->share->get($this->root . '/foo', '/dev/null');
} }
/** /**
* @expectedException \Icewind\SMB\InvalidTypeException * @expectedException \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function testDownloadFolder() { public function testDownloadFolder() {
$this->share->mkdir($this->root . '/foobar'); $this->share->mkdir($this->root . '/foobar');
@ -272,7 +272,7 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\InvalidTypeException * @expectedException \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function testDelFolder() { public function testDelFolder() {
$this->share->mkdir($this->root . '/foobar'); $this->share->mkdir($this->root . '/foobar');
@ -281,7 +281,7 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\InvalidTypeException * @expectedException \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function testRmdirFile() { public function testRmdirFile() {
$this->share->put($this->getTextFile(), $this->root . '/foobar'); $this->share->put($this->getTextFile(), $this->root . '/foobar');
@ -290,28 +290,28 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testDirNonExisting() { public function testDirNonExisting() {
$this->share->dir('/foobar/asd'); $this->share->dir('/foobar/asd');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testRmDirNonExisting() { public function testRmDirNonExisting() {
$this->share->rmdir('/foobar/asd'); $this->share->rmdir('/foobar/asd');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testRenameNonExisting() { public function testRenameNonExisting() {
$this->share->rename('/foobar/asd', '/foobar/bar'); $this->share->rename('/foobar/asd', '/foobar/bar');
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testRenameTargetNonExisting() { public function testRenameTargetNonExisting() {
$txt= $this->getTextFile(); $txt= $this->getTextFile();
@ -405,7 +405,7 @@ abstract class AbstractShare extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\NotFoundException * @expectedException \Icewind\SMB\Exception\NotFoundException
*/ */
public function testStatNonExisting() { public function testStatNonExisting() {
$this->share->stat($this->root . '/fo.txt'); $this->share->stat($this->root . '/fo.txt');

View file

@ -31,7 +31,7 @@ class Server extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\AuthenticationException * @expectedException \Icewind\SMB\Exception\AuthenticationException
*/ */
public function testWrongUserName() { public function testWrongUserName() {
$this->markTestSkipped('This fails for no reason on travis'); $this->markTestSkipped('This fails for no reason on travis');
@ -40,7 +40,7 @@ class Server extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\AuthenticationException * @expectedException \Icewind\SMB\Exception\AuthenticationException
*/ */
public function testWrongPassword() { public function testWrongPassword() {
$server = new \Icewind\SMB\Server($this->config->host, $this->config->user, uniqid()); $server = new \Icewind\SMB\Server($this->config->host, $this->config->user, uniqid());
@ -48,7 +48,7 @@ class Server extends \PHPUnit_Framework_TestCase {
} }
/** /**
* @expectedException \Icewind\SMB\InvalidHostException * @expectedException \Icewind\SMB\Exception\InvalidHostException
*/ */
public function testWrongHost() { public function testWrongHost() {
$server = new \Icewind\SMB\Server(uniqid(), $this->config->user, $this->config->password); $server = new \Icewind\SMB\Server(uniqid(), $this->config->user, $this->config->password);