]> git.mxchange.org Git - friendica.git/blobdiff - tests/src/Core/StorageManagerTest.php
Improve impossible exception-handler for storage move
[friendica.git] / tests / src / Core / StorageManagerTest.php
index 083d12d5797b16f7da63dbbdbcf53e2f07d47c4b..fd72eb7fb29c96e529de29813376bbbfe347f202 100644 (file)
@@ -24,11 +24,6 @@ use Psr\Log\LoggerInterface;
 use Psr\Log\NullLogger;
 use Friendica\Test\Util\SampleStorageBackend;
 
-/**
- * @todo Rework Hook:: methods to dynamic to remove the separated process annotation
- *
- * @runTestsInSeparateProcesses
- */
 class StorageManagerTest extends DatabaseTest
 {
        /** @var Database */
@@ -144,7 +139,11 @@ class StorageManagerTest extends DatabaseTest
        {
                $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
 
-               $this->assertEquals($userBackend, $storageManager->isValidBackend($name));
+               // true in every of the backends
+               $this->assertEquals(!empty($assertName), $storageManager->isValidBackend($name));
+
+               // if userBackend is set to true, filter out e.g. SystemRessource
+               $this->assertEquals($userBackend, $storageManager->isValidBackend($name, true));
        }
 
        /**
@@ -266,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);
+       }
 }