Add proper exception for moving a folder into itself

This commit is contained in:
Robin Appelman 2018-01-18 16:10:01 +01:00
commit fb98c1cd25
3 changed files with 22 additions and 1 deletions

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 InvalidArgumentException extends InvalidRequestException {}

View file

@ -28,9 +28,11 @@ class NativeState {
1 => '\Icewind\SMB\Exception\ForbiddenException',
2 => '\Icewind\SMB\Exception\NotFoundException',
13 => '\Icewind\SMB\Exception\ForbiddenException',
16 => '\Icewind\SMB\Exception\FileInUseException',
17 => '\Icewind\SMB\Exception\AlreadyExistsException',
20 => '\Icewind\SMB\Exception\InvalidTypeException',
21 => '\Icewind\SMB\Exception\InvalidTypeException',
22 => '\Icewind\SMB\Exception\InvalidArgumentException',
28 => '\Icewind\SMB\Exception\OutOfSpaceException',
39 => '\Icewind\SMB\Exception\NotEmptyException',
110 => '\Icewind\SMB\Exception\TimedOutException',

View file

@ -7,6 +7,7 @@
namespace Icewind\SMB\Test;
use Icewind\SMB\Exception\FileInUseException;
use Icewind\SMB\Exception\InvalidPathException;
use Icewind\SMB\Exception\NotFoundException;
use Icewind\SMB\FileInfo;
@ -262,7 +263,7 @@ abstract class AbstractShare extends TestCase {
try {
$this->share->mkdir($this->root . '/foo/bar');
$this->fail();
} catch(NotFoundException $e) {
} catch (NotFoundException $e) {
$this->assertEquals($this->root . '/foo/bar', $e->getPath());
}
}
@ -670,4 +671,12 @@ abstract class AbstractShare extends TestCase {
$info = $this->share->stat('/');
$this->assertInstanceOf('\Icewind\SMB\IFileInfo', $info);
}
/**
* @expectedException \Icewind\SMB\Exception\FileInUseException
*/
public function testMoveIntoSelf() {
$this->share->mkdir($this->root . '/folder');
$this->share->rename($this->root . '/folder', $this->root . '/folder/subfolder');
}
}