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 25b202af5f8..03aaf1e0a8b 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 2583863b554..4cc6c6a842c 100644 --- a/tests/lib/files/storage/local.php +++ b/tests/lib/files/storage/local.php @@ -70,5 +70,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); + } } |