Merge branch 'master' into master

This commit is contained in:
raffis 2018-08-28 09:13:33 +02:00 committed by GitHub
commit 4f91960314
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
46 changed files with 214 additions and 151 deletions

23
.editorconfig Normal file
View file

@ -0,0 +1,23 @@
[*]
charset=utf-8
end_of_line=lf
insert_final_newline=false
indent_style=space
indent_size=4
[{composer.lock,.babelrc,.stylelintrc,.eslintrc,jest.config,*.bowerrc,*.jsb3,*.jsb2,*.json}]
indent_style=space
indent_size=2
[{Makefile.*,Makefile,GNUmakefile,makefile,*.mk}]
indent_style=tab
tab_width=4
[{*.module,*.hphp,*.phtml,*.php5,*.php4,*.php,*.inc}]
indent_style=tab
tab_width=4
[{*.yml,*.yaml}]
indent_style=space
indent_size=2

2
.gitignore vendored
View file

@ -1,3 +1,5 @@
.idea .idea
vendor vendor
composer.lock composer.lock
.php_cs.cache

15
.php_cs.dist Normal file
View file

@ -0,0 +1,15 @@
<?php
$finder = PhpCsFixer\Finder::create()
->exclude('vendor')
->in(__DIR__)
;
return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'braces' => ['position_after_functions_and_oop_constructs' => 'same'],
'binary_operator_spaces' => ['align_double_arrow' => true, 'align_equals' => false],
])
->setIndent("\t")
->setFinder($finder)
;

View file

@ -50,6 +50,7 @@ install:
script: script:
- vendor/bin/phpunit --coverage-clover clover.xml -c tests/phpunit.xml - vendor/bin/phpunit --coverage-clover clover.xml -c tests/phpunit.xml
- vendor/friendsofphp/php-cs-fixer/php-cs-fixer fix --dry-run --diff --diff-format udiff
after_script: after_script:
- wget https://scrutinizer-ci.com/ocular.phar - wget https://scrutinizer-ci.com/ocular.phar

View file

@ -10,7 +10,8 @@
], ],
"require" : { "require" : {
"php": ">=5.6", "php": ">=5.6",
"icewind/streams": ">=0.2.0" "icewind/streams": ">=0.2.0",
"friendsofphp/php-cs-fixer": "^2.13"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^5.7" "phpunit/phpunit": "^5.7"

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
abstract class AbstractServer implements IServer { abstract class AbstractServer implements IServer {
const LOCALE = 'en_US.UTF-8'; const LOCALE = 'en_US.UTF-8';

View file

@ -13,7 +13,7 @@ abstract class AbstractShare implements IShare {
private $forbiddenCharacters; private $forbiddenCharacters;
public function __construct() { public function __construct() {
$this->forbiddenCharacters = array('?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r"); $this->forbiddenCharacters = ['?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r"];
} }
protected function verifyPath($path) { protected function verifyPath($path) {

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
class AnonymousAuth implements IAuth { class AnonymousAuth implements IAuth {
public function getUsername() { public function getUsername() {
return null; return null;

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
class BasicAuth implements IAuth { class BasicAuth implements IAuth {
/** @var string */ /** @var string */
private $username; private $username;
@ -62,5 +61,4 @@ class BasicAuth implements IAuth {
public function setExtraSmbClientOptions($smbClientState) { public function setExtraSmbClientOptions($smbClientState) {
// noop // noop
} }
} }

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class AccessDeniedException extends ConnectException {} class AccessDeniedException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class AlreadyExistsException extends InvalidRequestException {} class AlreadyExistsException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class AuthenticationException extends ConnectException{} class AuthenticationException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class ConnectException extends Exception {} class ConnectException extends Exception {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class ConnectionException extends ConnectException {} class ConnectionException extends ConnectException {
}

View file

@ -8,7 +8,7 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class Exception extends \Exception { class Exception extends \Exception {
static public function unknown($path, $error) { public static function unknown($path, $error) {
$message = 'Unknown error (' . $error . ')'; $message = 'Unknown error (' . $error . ')';
if ($path) { if ($path) {
$message .= ' for ' . $path; $message .= ' for ' . $path;
@ -23,7 +23,7 @@ class Exception extends \Exception {
* @param string $path * @param string $path
* @return Exception * @return Exception
*/ */
static public function fromMap(array $exceptionMap, $error, $path) { public static function fromMap(array $exceptionMap, $error, $path) {
if (isset($exceptionMap[$error])) { if (isset($exceptionMap[$error])) {
$exceptionClass = $exceptionMap[$error]; $exceptionClass = $exceptionMap[$error];
if (is_numeric($error)) { if (is_numeric($error)) {

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class FileInUseException extends InvalidRequestException {} class FileInUseException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class ForbiddenException extends InvalidRequestException {} class ForbiddenException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class InvalidArgumentException extends InvalidRequestException {} class InvalidArgumentException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class InvalidHostException extends ConnectException {} class InvalidHostException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class InvalidParameterException extends InvalidRequestException {} class InvalidParameterException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class InvalidPathException extends InvalidRequestException {} class InvalidPathException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class InvalidTypeException extends InvalidRequestException {} class InvalidTypeException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class NoLoginServerException extends ConnectException {} class NoLoginServerException extends ConnectException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class NotEmptyException extends InvalidRequestException {} class NotEmptyException extends InvalidRequestException {
}

View file

@ -7,4 +7,5 @@
namespace Icewind\SMB\Exception; namespace Icewind\SMB\Exception;
class NotFoundException extends InvalidRequestException {} class NotFoundException extends InvalidRequestException {
}

View file

@ -8,7 +8,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
interface INotifyHandler { interface INotifyHandler {
// https://msdn.microsoft.com/en-us/library/dn392331.aspx // https://msdn.microsoft.com/en-us/library/dn392331.aspx
const NOTIFY_ADDED = 1; const NOTIFY_ADDED = 1;

View file

@ -45,5 +45,4 @@ class KerberosAuth implements IAuth {
smbclient_option_set($smbClientState, SMBCLIENT_OPT_USE_KERBEROS, true); smbclient_option_set($smbClientState, SMBCLIENT_OPT_USE_KERBEROS, true);
smbclient_option_set($smbClientState, SMBCLIENT_OPT_FALLBACK_AFTER_KERBEROS, false); smbclient_option_set($smbClientState, SMBCLIENT_OPT_FALLBACK_AFTER_KERBEROS, false);
} }
} }

View file

@ -30,7 +30,10 @@ class NativeFileInfo implements IFileInfo {
/** /**
* @var array|null * @var array|null
*/ */
protected $statCache; protected $statCache = null;
/** @var callable|null */
protected $statCallback = null;
/** /**
* @var int * @var int
@ -41,13 +44,20 @@ class NativeFileInfo implements IFileInfo {
* @param NativeShare $share * @param NativeShare $share
* @param string $path * @param string $path
* @param string $name * @param string $name
* @param array $stat * @param array|callable $stat
*/ */
public function __construct($share, $path, $name, $stat = null) { public function __construct($share, $path, $name, $stat) {
$this->share = $share; $this->share = $share;
$this->path = $path; $this->path = $path;
$this->name = $name; $this->name = $name;
if (is_array($stat)) {
$this->statCache = $stat; $this->statCache = $stat;
} elseif (is_callable($stat)) {
$this->statCallback = $stat;
} else {
throw new \InvalidArgumentException('$stat needs to be an array or callback');
}
} }
/** /**
@ -69,7 +79,7 @@ class NativeFileInfo implements IFileInfo {
*/ */
protected function stat() { protected function stat() {
if (is_null($this->statCache)) { if (is_null($this->statCache)) {
$this->statCache = $this->share->getStat($this->getPath()); $this->statCache = call_user_func($this->statCallback);
} }
return $this->statCache; return $this->statCache;
} }

View file

@ -25,7 +25,6 @@ class NativeReadStream extends NativeStream {
$this->readBuffer = fopen('php://memory', 'r+'); $this->readBuffer = fopen('php://memory', 'r+');
return parent::stream_open($path, $mode, $options, $opened_path); return parent::stream_open($path, $mode, $options, $opened_path);
} }
/** /**
@ -39,13 +38,13 @@ class NativeReadStream extends NativeStream {
*/ */
public static function wrap($state, $smbStream, $mode, $url) { public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', NativeReadStream::class); stream_wrapper_register('nativesmb', NativeReadStream::class);
$context = stream_context_create(array( $context = stream_context_create([
'nativesmb' => array( 'nativesmb' => [
'state' => $state, 'state' => $state,
'handle' => $smbStream, 'handle' => $smbStream,
'url' => $url 'url' => $url
) ]
)); ]);
$fh = fopen('nativesmb://', $mode, false, $context); $fh = fopen('nativesmb://', $mode, false, $context);
stream_wrapper_unregister('nativesmb'); stream_wrapper_unregister('nativesmb');
return $fh; return $fh;

View file

@ -35,7 +35,7 @@ class NativeServer extends AbstractServer {
*/ */
public function listShares() { public function listShares() {
$this->connect(); $this->connect();
$shares = array(); $shares = [];
$dh = $this->state->opendir('smb://' . $this->getHost()); $dh = $this->state->opendir('smb://' . $this->getHost());
while ($share = $this->state->readdir($dh)) { while ($share = $this->state->readdir($dh)) {
if ($share['type'] === 'file share') { if ($share['type'] === 'file share') {

View file

@ -87,13 +87,16 @@ class NativeShare extends AbstractShare {
* @throws \Icewind\SMB\Exception\InvalidTypeException * @throws \Icewind\SMB\Exception\InvalidTypeException
*/ */
public function dir($path) { public function dir($path) {
$files = array(); $files = [];
$dh = $this->getState()->opendir($this->buildUrl($path)); $dh = $this->getState()->opendir($this->buildUrl($path));
while ($file = $this->getState()->readdir($dh)) { while ($file = $this->getState()->readdir($dh)) {
$name = $file['name']; $name = $file['name'];
if ($name !== '.' and $name !== '..') { if ($name !== '.' and $name !== '..') {
$files [] = new NativeFileInfo($this, $path . '/' . $name, $name); $fullPath = $path . '/' . $name;
$files [] = new NativeFileInfo($this, $fullPath, $name, function () use ($fullPath) {
return $this->getStat($fullPath);
});
} }
} }
@ -115,7 +118,7 @@ class NativeShare extends AbstractShare {
* @param string $path * @param string $path
* @return array * @return array
*/ */
public function getStat($path) { private function getStat($path) {
return $this->getState()->stat($this->buildUrl($path)); return $this->getState()->stat($this->buildUrl($path));
} }
@ -295,11 +298,10 @@ class NativeShare extends AbstractShare {
* *
* @param string $path * @param string $path
* @param string $attribute attribute to get the info * @param string $attribute attribute to get the info
* @param mixed $value * @param string|int $value
* @return string the attribute value * @return mixed the attribute value
*/ */
public function setAttribute($path, $attribute, $value) { public function setAttribute($path, $attribute, $value) {
if ($attribute === 'system.dos_attr.mode' and is_int($value)) { if ($attribute === 'system.dos_attr.mode' and is_int($value)) {
$value = '0x' . dechex($value); $value = '0x' . dechex($value);
} }

View file

@ -48,13 +48,13 @@ class NativeStream implements File {
*/ */
public static function wrap($state, $smbStream, $mode, $url) { public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', NativeStream::class); stream_wrapper_register('nativesmb', NativeStream::class);
$context = stream_context_create(array( $context = stream_context_create([
'nativesmb' => array( 'nativesmb' => [
'state' => $state, 'state' => $state,
'handle' => $smbStream, 'handle' => $smbStream,
'url' => $url 'url' => $url
) ]
)); ]);
$fh = fopen('nativesmb://', $mode, false, $context); $fh = fopen('nativesmb://', $mode, false, $context);
stream_wrapper_unregister('nativesmb'); stream_wrapper_unregister('nativesmb');
return $fh; return $fh;

View file

@ -25,7 +25,6 @@ class NativeWriteStream extends NativeStream {
$this->writeBuffer = fopen('php://memory', 'r+'); $this->writeBuffer = fopen('php://memory', 'r+');
return parent::stream_open($path, $mode, $options, $opened_path); return parent::stream_open($path, $mode, $options, $opened_path);
} }
/** /**
@ -39,13 +38,13 @@ class NativeWriteStream extends NativeStream {
*/ */
public static function wrap($state, $smbStream, $mode, $url) { public static function wrap($state, $smbStream, $mode, $url) {
stream_wrapper_register('nativesmb', NativeWriteStream::class); stream_wrapper_register('nativesmb', NativeWriteStream::class);
$context = stream_context_create(array( $context = stream_context_create([
'nativesmb' => array( 'nativesmb' => [
'state' => $state, 'state' => $state,
'handle' => $smbStream, 'handle' => $smbStream,
'url' => $url 'url' => $url
) ]
)); ]);
$fh = fopen('nativesmb://', $mode, false, $context); $fh = fopen('nativesmb://', $mode, false, $context);
stream_wrapper_unregister('nativesmb'); stream_wrapper_unregister('nativesmb');
return $fh; return $fh;

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
class Options implements IOptions { class Options implements IOptions {
/** @var int */ /** @var int */
private $timeout = 20; private $timeout = 20;

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB; namespace Icewind\SMB;
use Icewind\SMB\Exception\DependencyException; use Icewind\SMB\Exception\DependencyException;
use Icewind\SMB\Native\NativeServer; use Icewind\SMB\Native\NativeServer;
use Icewind\SMB\Wrapped\Server; use Icewind\SMB\Wrapped\Server;

View file

@ -52,7 +52,7 @@ class System implements ISystem {
protected function getBinaryPath($binary) { protected function getBinaryPath($binary) {
if (!isset($this->paths[$binary])) { if (!isset($this->paths[$binary])) {
$result = null; $result = null;
$output = array(); $output = [];
exec("which $binary 2>&1", $output, $result); exec("which $binary 2>&1", $output, $result);
$this->paths[$binary] = $result === 0 ? trim(implode('', $output)) : false; $this->paths[$binary] = $result === 0 ? trim(implode('', $output)) : false;
} }

View file

@ -30,7 +30,8 @@ class TimeZoneProvider implements ITimeZoneProvider {
$net = $this->system->getNetPath(); $net = $this->system->getNetPath();
// for local domain names we can assume same timezone // for local domain names we can assume same timezone
if ($net && $host && strpos($host, '.') !== false) { if ($net && $host && strpos($host, '.') !== false) {
$command = sprintf('%s time zone -S %s', $command = sprintf(
'%s time zone -S %s',
$net, $net,
escapeshellarg($host) escapeshellarg($host)
); );

View file

@ -20,7 +20,7 @@ class Connection extends RawConnection {
/** @var Parser */ /** @var Parser */
private $parser; private $parser;
public function __construct($command, Parser $parser, $env = array()) { public function __construct($command, Parser $parser, $env = []) {
parent::__construct($command, $env); parent::__construct($command, $env);
$this->parser = $parser; $this->parser = $parser;
} }
@ -65,7 +65,7 @@ class Connection extends RawConnection {
$promptLine = $this->readLine(); //first line is prompt $promptLine = $this->readLine(); //first line is prompt
$this->parser->checkConnectionError($promptLine); $this->parser->checkConnectionError($promptLine);
$output = array(); $output = [];
$line = $this->readLine(); $line = $this->readLine();
if ($line === false) { if ($line === false) {
$this->unknownError($promptLine); $this->unknownError($promptLine);

View file

@ -8,7 +8,6 @@
namespace Icewind\SMB\Wrapped; namespace Icewind\SMB\Wrapped;
use Icewind\SMB\Change; use Icewind\SMB\Change;
use Icewind\SMB\Exception\Exception; use Icewind\SMB\Exception\Exception;
use Icewind\SMB\Exception\RevisionMismatchException; use Icewind\SMB\Exception\RevisionMismatchException;

View file

@ -156,7 +156,7 @@ class Parser {
array_pop($output); array_pop($output);
$regex = '/^\s*(.*?)\s\s\s\s+(?:([NDHARS]*)\s+)?([0-9]+)\s+(.*)$/'; $regex = '/^\s*(.*?)\s\s\s\s+(?:([NDHARS]*)\s+)?([0-9]+)\s+(.*)$/';
//2 spaces, filename, optional type, size, date //2 spaces, filename, optional type, size, date
$content = array(); $content = [];
foreach ($output as $line) { foreach ($output as $line) {
if (preg_match($regex, $line, $matches)) { if (preg_match($regex, $line, $matches)) {
list(, $name, $mode, $size, $time) = $matches; list(, $name, $mode, $size, $time) = $matches;
@ -171,7 +171,7 @@ class Parser {
} }
public function parseListShares($output) { public function parseListShares($output) {
$shareNames = array(); $shareNames = [];
foreach ($output as $line) { foreach ($output as $line) {
if (strpos($line, '|')) { if (strpos($line, '|')) {
list($type, $name, $description) = explode('|', $line); list($type, $name, $description) = explode('|', $line);

View file

@ -42,7 +42,8 @@ class Server extends AbstractServer {
* @throws ConnectException * @throws ConnectException
*/ */
public function listShares() { public function listShares() {
$command = sprintf('%s %s %s -L %s', $command = sprintf(
'%s %s %s -L %s',
$this->system->getSmbclientPath(), $this->system->getSmbclientPath(),
$this->getAuthFileArgument(), $this->getAuthFileArgument(),
$this->getAuth()->getExtraCommandLineArguments(), $this->getAuth()->getExtraCommandLineArguments(),
@ -73,7 +74,7 @@ class Server extends AbstractServer {
$shareNames = $parser->parseListShares($output); $shareNames = $parser->parseListShares($output);
$shares = array(); $shares = [];
foreach ($shareNames as $name => $description) { foreach ($shareNames as $name => $description) {
$shares[] = $this->getShare($name); $shares[] = $this->getShare($name);
} }

View file

@ -76,7 +76,8 @@ class Share extends AbstractShare {
} }
protected function getConnection() { protected function getConnection() {
$command = sprintf('%s%s -t %s %s %s %s', $command = sprintf(
'%s%s -t %s %s %s %s',
$this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '', $this->system->getStdBufPath() ? $this->system->getStdBufPath() . ' -o0 ' : '',
$this->system->getSmbclientPath(), $this->system->getSmbclientPath(),
$this->server->getOptions()->getTimeout(), $this->server->getOptions()->getTimeout(),

View file

@ -44,47 +44,47 @@ abstract class AbstractShareTest extends TestCase {
} }
public function nameProvider() { public function nameProvider() {
return array( return [
array('simple'), ['simple'],
array('with spaces_and-underscores'), ['with spaces_and-underscores'],
array("single'quote'"), ["single'quote'"],
array("foo ; asd -- bar"), ["foo ; asd -- bar"],
array('日本語'), ['日本語'],
array('url %2F +encode'), ['url %2F +encode'],
array('a somewhat longer filename than the other with more charaters as the all the other filenames'), ['a somewhat longer filename than the other with more charaters as the all the other filenames'],
array('$as#d€££Ö€ßœĚęĘĞĜΣΥΦΩΫ') ['$as#d€££Ö€ßœĚęĘĞĜΣΥΦΩΫ']
); ];
} }
public function invalidPathProvider() { public function invalidPathProvider() {
// / ? < > \ : * | " are illegal characters in path on windows // / ? < > \ : * | " are illegal characters in path on windows
return array( return [
array("new\nline"), ["new\nline"],
array("\rreturn"), ["\rreturn"],
array('null' . chr(0) . 'byte'), ['null' . chr(0) . 'byte'],
array('foo?bar'), ['foo?bar'],
array('foo<bar>'), ['foo<bar>'],
array('foo:bar'), ['foo:bar'],
array('foo*bar'), ['foo*bar'],
array('foo|bar'), ['foo|bar'],
array('foo"bar"') ['foo"bar"']
); ];
} }
public function fileDataProvider() { public function fileDataProvider() {
return array( return [
array('Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'), ['Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua'],
array('Mixed language, 日本語 が わからか and Various _/* characters \\|” €') ['Mixed language, 日本語 が わからか and Various _/* characters \\|” €']
); ];
} }
public function nameAndDataProvider() { public function nameAndDataProvider() {
$names = $this->nameProvider(); $names = $this->nameProvider();
$data = $this->fileDataProvider(); $data = $this->fileDataProvider();
$result = array(); $result = [];
foreach ($names as $name) { foreach ($names as $name) {
foreach ($data as $text) { foreach ($data as $text) {
$result[] = array($name[0], $text[0]); $result[] = [$name[0], $text[0]];
} }
} }
return $result; return $result;
@ -122,7 +122,7 @@ abstract class AbstractShareTest extends TestCase {
} }
public function testRootStartsEmpty() { public function testRootStartsEmpty() {
$this->assertEquals(array(), $this->share->dir($this->root)); $this->assertEquals([], $this->share->dir($this->root));
} }
/** /**
@ -625,16 +625,16 @@ abstract class AbstractShareTest extends TestCase {
public function pathProvider() { public function pathProvider() {
// / ? < > \ : * | " are illegal characters in path on windows // / ? < > \ : * | " are illegal characters in path on windows
return array( return [
array('dir/sub/foo.txt'), ['dir/sub/foo.txt'],
array('bar.txt'), ['bar.txt'],
array("single'quote'/sub/foo.txt"), ["single'quote'/sub/foo.txt"],
array('日本語/url %2F +encode/asd.txt'), ['日本語/url %2F +encode/asd.txt'],
array( [
'a somewhat longer folder than the other with more charaters as the all the other filenames/' . 'a somewhat longer folder than the other with more charaters as the all the other filenames/' .
'followed by a somewhat long file name after that.txt' 'followed by a somewhat long file name after that.txt'
) ]
); ];
} }
/** /**

View file

@ -84,7 +84,6 @@ class NotifyHandlerTest extends TestCase {
try { try {
$share->mkdir('sub'); $share->mkdir('sub');
} catch (AlreadyExistsException $e) { } catch (AlreadyExistsException $e) {
} }
$process = $share->notify('sub'); $process = $share->notify('sub');
usleep(1000 * 100);// give it some time to start listening usleep(1000 * 100);// give it some time to start listening

View file

@ -7,22 +7,21 @@
namespace Icewind\SMB\Test; namespace Icewind\SMB\Test;
use Icewind\SMB\IFileInfo; use Icewind\SMB\IFileInfo;
use Icewind\SMB\Wrapped\FileInfo; use Icewind\SMB\Wrapped\FileInfo;
class ParserTest extends \PHPUnit_Framework_TestCase { class ParserTest extends \PHPUnit_Framework_TestCase {
public function modeProvider() { public function modeProvider() {
return array( return [
array('D', IFileInfo::MODE_DIRECTORY), ['D', IFileInfo::MODE_DIRECTORY],
array('A', IFileInfo::MODE_ARCHIVE), ['A', IFileInfo::MODE_ARCHIVE],
array('S', IFileInfo::MODE_SYSTEM), ['S', IFileInfo::MODE_SYSTEM],
array('H', IFileInfo::MODE_HIDDEN), ['H', IFileInfo::MODE_HIDDEN],
array('R', IFileInfo::MODE_READONLY), ['R', IFileInfo::MODE_READONLY],
array('N', IFileInfo::MODE_NORMAL), ['N', IFileInfo::MODE_NORMAL],
array('RA', IFileInfo::MODE_READONLY | IFileInfo::MODE_ARCHIVE), ['RA', IFileInfo::MODE_READONLY | IFileInfo::MODE_ARCHIVE],
array('RAH', IFileInfo::MODE_READONLY | IFileInfo::MODE_ARCHIVE | IFileInfo::MODE_HIDDEN) ['RAH', IFileInfo::MODE_READONLY | IFileInfo::MODE_ARCHIVE | IFileInfo::MODE_HIDDEN]
); ];
} }
/** /**
* @dataProvider modeProvider * @dataProvider modeProvider
@ -33,9 +32,9 @@ class ParserTest extends \PHPUnit_Framework_TestCase {
} }
public function statProvider() { public function statProvider() {
return array( return [
array( [
array( [
'altname: test.txt', 'altname: test.txt',
'create_time: Sat Oct 12 07:05:58 PM 2013 CEST', 'create_time: Sat Oct 12 07:05:58 PM 2013 CEST',
'access_time: Tue Oct 15 02:58:48 PM 2013 CEST', 'access_time: Tue Oct 15 02:58:48 PM 2013 CEST',
@ -43,15 +42,15 @@ class ParserTest extends \PHPUnit_Framework_TestCase {
'change_time: Sat Oct 12 07:05:58 PM 2013 CEST', 'change_time: Sat Oct 12 07:05:58 PM 2013 CEST',
'attributes: (80)', 'attributes: (80)',
'stream: [::$DATA], 29634 bytes' 'stream: [::$DATA], 29634 bytes'
), ],
array( [
'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'), 'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'),
'mode' => IFileInfo::MODE_NORMAL, 'mode' => IFileInfo::MODE_NORMAL,
'size' => 29634 'size' => 29634
) ]
), ],
array( [
array( [
'altname: folder', 'altname: folder',
'create_time: Sat Oct 12 07:05:58 PM 2013 CEST', 'create_time: Sat Oct 12 07:05:58 PM 2013 CEST',
'access_time: Tue Oct 15 02:58:48 PM 2013 CEST', 'access_time: Tue Oct 15 02:58:48 PM 2013 CEST',
@ -59,15 +58,15 @@ class ParserTest extends \PHPUnit_Framework_TestCase {
'change_time: Sat Oct 12 07:05:58 PM 2013 CEST', 'change_time: Sat Oct 12 07:05:58 PM 2013 CEST',
'attributes: D (10)', 'attributes: D (10)',
'stream: [::$DATA], 29634 bytes' 'stream: [::$DATA], 29634 bytes'
), ],
array( [
'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'), 'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'),
'mode' => IFileInfo::MODE_DIRECTORY, 'mode' => IFileInfo::MODE_DIRECTORY,
'size' => 29634 'size' => 29634
) ]
), ],
array( [
array( [
'altname: .hidden', 'altname: .hidden',
'create_time: Sat Oct 12 07:05:58 PM 2013 CEST', 'create_time: Sat Oct 12 07:05:58 PM 2013 CEST',
'access_time: Tue Oct 15 02:58:48 PM 2013 CEST', 'access_time: Tue Oct 15 02:58:48 PM 2013 CEST',
@ -75,14 +74,14 @@ class ParserTest extends \PHPUnit_Framework_TestCase {
'change_time: Sat Oct 12 07:05:58 PM 2013 CEST', 'change_time: Sat Oct 12 07:05:58 PM 2013 CEST',
'attributes: HA (22)', 'attributes: HA (22)',
'stream: [::$DATA], 29634 bytes' 'stream: [::$DATA], 29634 bytes'
), ],
array( [
'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'), 'mtime' => strtotime('12 Oct 2013 19:05:58 CEST'),
'mode' => IFileInfo::MODE_HIDDEN + IFileInfo::MODE_ARCHIVE, 'mode' => IFileInfo::MODE_HIDDEN + IFileInfo::MODE_ARCHIVE,
'size' => 29634 'size' => 29634
) ]
) ]
); ];
} }
/** /**
@ -94,21 +93,26 @@ class ParserTest extends \PHPUnit_Framework_TestCase {
} }
public function dirProvider() { public function dirProvider() {
return array( return [
array( [
array( [
' . D 0 Tue Aug 26 19:11:56 2014', ' . D 0 Tue Aug 26 19:11:56 2014',
' .. DR 0 Sun Oct 28 15:24:02 2012', ' .. DR 0 Sun Oct 28 15:24:02 2012',
' c.pdf N 29634 Sat Oct 12 19:05:58 2013', ' c.pdf N 29634 Sat Oct 12 19:05:58 2013',
'', '',
' 62536 blocks of size 8388608. 57113 blocks available' ' 62536 blocks of size 8388608. 57113 blocks available'
), ],
array( [
new FileInfo('/c.pdf', 'c.pdf', 29634, strtotime('12 Oct 2013 19:05:58 CEST'), new FileInfo(
IFileInfo::MODE_NORMAL) '/c.pdf',
'c.pdf',
29634,
strtotime('12 Oct 2013 19:05:58 CEST'),
IFileInfo::MODE_NORMAL
) )
) ]
); ]
];
} }
/** /**

View file

@ -21,7 +21,6 @@
namespace Icewind\SMB\Test; namespace Icewind\SMB\Test;
use Icewind\SMB\AnonymousAuth; use Icewind\SMB\AnonymousAuth;
use Icewind\SMB\IAuth; use Icewind\SMB\IAuth;
use Icewind\SMB\Native\NativeServer; use Icewind\SMB\Native\NativeServer;