Browse Source

Improve impossible exception-handler for storage move

pull/8123/head
nupplaPhil 1 year ago
parent
commit
732992a296
No known key found for this signature in database GPG Key ID: D8365C3D36B77D90
2 changed files with 15 additions and 2 deletions
  1. +2
    -2
      src/Core/StorageManager.php
  2. +13
    -0
      tests/src/Core/StorageManagerTest.php

+ 2
- 2
src/Core/StorageManager.php View 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;


+ 13
- 0
tests/src/Core/StorageManagerTest.php View 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);
}
}

Loading…
Cancel
Save