]> 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 2d131c632541a8465d3ce870c8cecb9b18c959ed..084caa68ab09f2550526b69cc7d206c1d2ca1fbe 100644 (file)
@@ -24,12 +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
- * @preserveGlobalState disabled
- */
 class StorageManagerTest extends DatabaseTest
 {
        /** @var Database */
@@ -145,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));
        }
 
        /**
@@ -267,4 +265,17 @@ class StorageManagerTest extends DatabaseTest
                        $this->assertNotEmpty($data);
                }
        }
+
+       /**
+        * Test moving data to a WRONG storage
+        *
+        * @expectedException \Friendica\Model\Storage\StorageException
+        * @expectedExceptionMessage Can't move to storage backend 'SystemResource'
+        */
+       public function testMoveStorageWrong()
+       {
+               $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+               $storage = $storageManager->getByName(Storage\SystemResource::getName());
+               $storageManager->move($storage);
+       }
 }