]> git.mxchange.org Git - friendica.git/commitdiff
Improve impossible exception-handler for storage move
authornupplaPhil <admin@philipp.info>
Fri, 17 Jan 2020 20:01:37 +0000 (21:01 +0100)
committernupplaPhil <admin@philipp.info>
Fri, 17 Jan 2020 22:55:18 +0000 (23:55 +0100)
src/Core/StorageManager.php
tests/src/Core/StorageManagerTest.php

index 8b5b73a788be0211db9a1c0c24245c7d06e5438f..d1a943a227646737f29dab82fd36186a1f637988 100644 (file)
@@ -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;
index 7cef2dc281e053aa3694f3402b2e766e32c10c55..fd72eb7fb29c96e529de29813376bbbfe347f202 100644 (file)
@@ -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);
+       }
 }