diff options
-rw-r--r-- | lib/private/files/storage/local.php | 3 | ||||
-rw-r--r-- | tests/lib/files/storage/local.php | 14 |
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/private/files/storage/local.php b/lib/private/files/storage/local.php index 6e9e5350273..66d448fd8c0 100644 --- a/lib/private/files/storage/local.php +++ b/lib/private/files/storage/local.php @@ -39,6 +39,9 @@ class Local extends \OC\Files\Storage\Common { protected $datadir; public function __construct($arguments) { + if (!isset($arguments['datadir']) || !is_string($arguments['datadir'])) { + throw new \InvalidArgumentException('No data directory set for local storage'); + } $this->datadir = $arguments['datadir']; if (substr($this->datadir, -1) !== '/') { $this->datadir .= '/'; diff --git a/tests/lib/files/storage/local.php b/tests/lib/files/storage/local.php index d2b27117c3b..9f4f3927386 100644 --- a/tests/lib/files/storage/local.php +++ b/tests/lib/files/storage/local.php @@ -63,5 +63,19 @@ class Local extends Storage { $etag2 = $this->instance->getETag('test.txt'); $this->assertNotEquals($etag1, $etag2); } + + /** + * @expectedException \InvalidArgumentException + */ + public function testInvalidArgumentsEmptyArray() { + new \OC\Files\Storage\Local([]); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testInvalidArgumentsNoArray() { + new \OC\Files\Storage\Local(null); + } } |