Fixup Database behaviour
This commit is contained in:
parent
90c99520bb
commit
470ba8b61b
|
@ -101,7 +101,7 @@ class Database implements ISelectableStorage
|
||||||
public function delete(string $reference)
|
public function delete(string $reference)
|
||||||
{
|
{
|
||||||
try {
|
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));
|
throw new ReferenceStorageException(sprintf('Database storage failed to delete %s', $reference));
|
||||||
}
|
}
|
||||||
} catch (Exception $exception) {
|
} catch (Exception $exception) {
|
||||||
|
|
|
@ -21,16 +21,14 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Model\Storage;
|
namespace Friendica\Test\src\Model\Storage;
|
||||||
|
|
||||||
use Friendica\Core\L10n;
|
|
||||||
use Friendica\Factory\ConfigFactory;
|
use Friendica\Factory\ConfigFactory;
|
||||||
use Friendica\Model\Storage\Database;
|
use Friendica\Model\Storage\Database;
|
||||||
use Friendica\Model\Storage\IStorage;
|
use Friendica\Model\Storage\ISelectableStorage;
|
||||||
use Friendica\Test\DatabaseTestTrait;
|
use Friendica\Test\DatabaseTestTrait;
|
||||||
use Friendica\Test\Util\Database\StaticDatabase;
|
use Friendica\Test\Util\Database\StaticDatabase;
|
||||||
use Friendica\Test\Util\VFSTrait;
|
use Friendica\Test\Util\VFSTrait;
|
||||||
use Friendica\Util\ConfigFileLoader;
|
use Friendica\Util\ConfigFileLoader;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Mockery\MockInterface;
|
|
||||||
use Psr\Log\NullLogger;
|
use Psr\Log\NullLogger;
|
||||||
|
|
||||||
class DatabaseStorageTest extends StorageTest
|
class DatabaseStorageTest extends StorageTest
|
||||||
|
@ -65,7 +63,7 @@ class DatabaseStorageTest extends StorageTest
|
||||||
return new Database($dba);
|
return new Database($dba);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertOption(IStorage $storage)
|
protected function assertOption(ISelectableStorage $storage)
|
||||||
{
|
{
|
||||||
self::assertEmpty($storage->getOptions());
|
self::assertEmpty($storage->getOptions());
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,12 @@ namespace Friendica\Test\src\Model\Storage;
|
||||||
use Friendica\Core\Config\IConfig;
|
use Friendica\Core\Config\IConfig;
|
||||||
use Friendica\Core\L10n;
|
use Friendica\Core\L10n;
|
||||||
use Friendica\Model\Storage\Filesystem;
|
use Friendica\Model\Storage\Filesystem;
|
||||||
use Friendica\Model\Storage\IStorage;
|
use Friendica\Model\Storage\ISelectableStorage;
|
||||||
use Friendica\Model\Storage\StorageException;
|
use Friendica\Model\Storage\StorageException;
|
||||||
use Friendica\Test\Util\VFSTrait;
|
use Friendica\Test\Util\VFSTrait;
|
||||||
use Friendica\Util\Profiler;
|
use Friendica\Util\Profiler;
|
||||||
use Mockery\MockInterface;
|
use Mockery\MockInterface;
|
||||||
use org\bovigo\vfs\vfsStream;
|
use org\bovigo\vfs\vfsStream;
|
||||||
use Psr\Log\NullLogger;
|
|
||||||
|
|
||||||
class FilesystemStorageTest extends StorageTest
|
class FilesystemStorageTest extends StorageTest
|
||||||
{
|
{
|
||||||
|
@ -65,7 +64,7 @@ class FilesystemStorageTest extends StorageTest
|
||||||
return new Filesystem($this->config, $l10n);
|
return new Filesystem($this->config, $l10n);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function assertOption(IStorage $storage)
|
protected function assertOption(ISelectableStorage $storage)
|
||||||
{
|
{
|
||||||
self::assertEquals([
|
self::assertEquals([
|
||||||
'storagepath' => [
|
'storagepath' => [
|
||||||
|
|
|
@ -21,17 +21,17 @@
|
||||||
|
|
||||||
namespace Friendica\Test\src\Model\Storage;
|
namespace Friendica\Test\src\Model\Storage;
|
||||||
|
|
||||||
|
use Friendica\Model\Storage\ISelectableStorage;
|
||||||
use Friendica\Model\Storage\IStorage;
|
use Friendica\Model\Storage\IStorage;
|
||||||
use Friendica\Model\Storage\ReferenceStorageException;
|
use Friendica\Model\Storage\ReferenceStorageException;
|
||||||
use Friendica\Model\Storage\StorageException;
|
|
||||||
use Friendica\Test\MockedTest;
|
use Friendica\Test\MockedTest;
|
||||||
|
|
||||||
abstract class StorageTest extends MockedTest
|
abstract class StorageTest extends MockedTest
|
||||||
{
|
{
|
||||||
/** @return IStorage */
|
/** @return ISelectableStorage */
|
||||||
abstract protected function getInstance();
|
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
|
* Test if the instance is "really" implementing the interface
|
||||||
|
|
Loading…
Reference in a new issue