From 732992a296e4de14ce1c75dfda952d2768158a4c Mon Sep 17 00:00:00 2001 From: nupplaPhil Date: Fri, 17 Jan 2020 21:01:37 +0100 Subject: [PATCH] Improve impossible exception-handler for storage move --- src/Core/StorageManager.php | 4 ++-- tests/src/Core/StorageManagerTest.php | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Core/StorageManager.php b/src/Core/StorageManager.php index 8b5b73a788..d1a943a227 100644 --- a/src/Core/StorageManager.php +++ b/src/Core/StorageManager.php @@ -240,8 +240,8 @@ class StorageManager */ public function move(Storage\IStorage $destination, array $tables = self::TABLES, int $limit = 5000) { - if ($destination === null) { - throw new Storage\StorageException('Can\'t move to NULL storage backend'); + if (!$this->isValidBackend($destination, true)) { + throw new Storage\StorageException(sprintf("Can't move to storage backend '%s'", $destination::getName())); } $moved = 0; diff --git a/tests/src/Core/StorageManagerTest.php b/tests/src/Core/StorageManagerTest.php index 7cef2dc281..fd72eb7fb2 100644 --- a/tests/src/Core/StorageManagerTest.php +++ b/tests/src/Core/StorageManagerTest.php @@ -265,4 +265,17 @@ class StorageManagerTest extends DatabaseTest $this->assertNotEmpty($data); } } + + /** + * Test moving data to a WRONG storage + * + * @expectedException \Friendica\Model\Storage\StorageException + * @expectedExceptionMessageRegExp /Can't move to storage backend '.*'/ + */ + public function testMoveStorageWrong() + { + $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n); + $storage = $storageManager->getByName(Storage\SystemResource::getName()); + $storageManager->move($storage); + } }