Fixup Database behaviour

This commit is contained in:
Philipp 2021-08-07 22:07:47 +02:00
parent 90c99520bb
commit 470ba8b61b
No known key found for this signature in database
GPG Key ID: 9A28B7D4FF5667BD
4 changed files with 8 additions and 11 deletions

View File

@ -101,7 +101,7 @@ class Database implements ISelectableStorage
public function delete(string $reference)
{
try {
if (!$this->dba->delete('storage', ['id' => $reference])) {
if (!$this->dba->delete('storage', ['id' => $reference]) || $this->dba->affectedRows() === 0) {
throw new ReferenceStorageException(sprintf('Database storage failed to delete %s', $reference));
}
} catch (Exception $exception) {

View File

@ -21,16 +21,14 @@
namespace Friendica\Test\src\Model\Storage;
use Friendica\Core\L10n;
use Friendica\Factory\ConfigFactory;
use Friendica\Model\Storage\Database;
use Friendica\Model\Storage\IStorage;
use Friendica\Model\Storage\ISelectableStorage;
use Friendica\Test\DatabaseTestTrait;
use Friendica\Test\Util\Database\StaticDatabase;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\ConfigFileLoader;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
use Psr\Log\NullLogger;
class DatabaseStorageTest extends StorageTest
@ -65,7 +63,7 @@ class DatabaseStorageTest extends StorageTest
return new Database($dba);
}
protected function assertOption(IStorage $storage)
protected function assertOption(ISelectableStorage $storage)
{
self::assertEmpty($storage->getOptions());
}

View File

@ -24,13 +24,12 @@ namespace Friendica\Test\src\Model\Storage;
use Friendica\Core\Config\IConfig;
use Friendica\Core\L10n;
use Friendica\Model\Storage\Filesystem;
use Friendica\Model\Storage\IStorage;
use Friendica\Model\Storage\ISelectableStorage;
use Friendica\Model\Storage\StorageException;
use Friendica\Test\Util\VFSTrait;
use Friendica\Util\Profiler;
use Mockery\MockInterface;
use org\bovigo\vfs\vfsStream;
use Psr\Log\NullLogger;
class FilesystemStorageTest extends StorageTest
{
@ -65,7 +64,7 @@ class FilesystemStorageTest extends StorageTest
return new Filesystem($this->config, $l10n);
}
protected function assertOption(IStorage $storage)
protected function assertOption(ISelectableStorage $storage)
{
self::assertEquals([
'storagepath' => [

View File

@ -21,17 +21,17 @@
namespace Friendica\Test\src\Model\Storage;
use Friendica\Model\Storage\ISelectableStorage;
use Friendica\Model\Storage\IStorage;
use Friendica\Model\Storage\ReferenceStorageException;
use Friendica\Model\Storage\StorageException;
use Friendica\Test\MockedTest;
abstract class StorageTest extends MockedTest
{
/** @return IStorage */
/** @return ISelectableStorage */
abstract protected function getInstance();
abstract protected function assertOption(IStorage $storage);
abstract protected function assertOption(ISelectableStorage $storage);
/**
* Test if the instance is "really" implementing the interface