From 577e3b11d7b486d09334f39215814638704e84b9 Mon Sep 17 00:00:00 2001 From: Robin Appelman Date: Mon, 28 Jan 2013 00:59:43 +0100 Subject: [PATCH] Filesystem: return all matching mounts in Mount::findById --- lib/files/mount.php | 7 ++++--- tests/lib/files/mount.php | 8 ++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/files/mount.php b/lib/files/mount.php index e28b6471fe..74ee483b1b 100644 --- a/lib/files/mount.php +++ b/lib/files/mount.php @@ -174,14 +174,15 @@ class Mount { /** * @param string $id - * @return \OC\Files\Storage\Storage + * @return \OC\Files\Storage\Storage[] */ public static function findById($id) { + $result = array(); foreach (self::$mounts as $mount) { if ($mount->getStorageId() === $id) { - return $mount; + $result[] = $mount; } } - return null; + return $result; } } diff --git a/tests/lib/files/mount.php b/tests/lib/files/mount.php index 9f16b03627..f223f0f6c5 100644 --- a/tests/lib/files/mount.php +++ b/tests/lib/files/mount.php @@ -23,7 +23,8 @@ class Mount extends \PHPUnit_Framework_TestCase { $this->assertEquals($rootMount, \OC\Files\Mount::find('/')); $this->assertEquals($rootMount, \OC\Files\Mount::find('/foo/bar')); - $mount = new \OC\Files\Mount(new Temporary(array()), '/foo'); + $storage = new Temporary(array()); + $mount = new \OC\Files\Mount($storage, '/foo'); $this->assertEquals($rootMount, \OC\Files\Mount::find('/')); $this->assertEquals($mount, \OC\Files\Mount::find('/foo/bar')); @@ -32,6 +33,9 @@ class Mount extends \PHPUnit_Framework_TestCase { $this->assertEquals(2, count(\OC\Files\Mount::findIn('/'))); $id = $mount->getStorageId(); - $this->assertEquals($mount, \OC\Files\Mount::findById($id)); + $this->assertEquals(array($mount), \OC\Files\Mount::findById($id)); + + $mount2 = new \OC\Files\Mount($storage, '/foo/bar'); + $this->assertEquals(array($mount, $mount2), \OC\Files\Mount::findById($id)); } }