Fix Storage Exceptions

This commit is contained in:
Philipp 2021-08-01 14:31:57 +02:00
parent 29c7552df5
commit 90c99520bb
No known key found for this signature in database
GPG key ID: 9A28B7D4FF5667BD
6 changed files with 46 additions and 35 deletions

View file

@ -62,10 +62,7 @@ class DatabaseStorageTest extends StorageTest
$dba = new StaticDatabase($configCache, $profiler, $logger);
/** @var MockInterface|L10n $l10n */
$l10n = \Mockery::mock(L10n::class)->makePartial();
return new Database($dba, $logger, $l10n);
return new Database($dba);
}
protected function assertOption(IStorage $storage)

View file

@ -50,7 +50,6 @@ class FilesystemStorageTest extends StorageTest
protected function getInstance()
{
$logger = new NullLogger();
$profiler = \Mockery::mock(Profiler::class);
$profiler->shouldReceive('startRecording');
$profiler->shouldReceive('stopRecording');
@ -63,7 +62,7 @@ class FilesystemStorageTest extends StorageTest
->with('storage', 'filesystem_path', Filesystem::DEFAULT_BASE_FOLDER)
->andReturn($this->root->getChild('storage')->url());
return new Filesystem($this->config, $logger, $l10n);
return new Filesystem($this->config, $l10n);
}
protected function assertOption(IStorage $storage)

View file

@ -22,6 +22,8 @@
namespace Friendica\Test\src\Model\Storage;
use Friendica\Model\Storage\IStorage;
use Friendica\Model\Storage\ReferenceStorageException;
use Friendica\Model\Storage\StorageException;
use Friendica\Test\MockedTest;
abstract class StorageTest extends MockedTest
@ -62,7 +64,7 @@ abstract class StorageTest extends MockedTest
self::assertEquals('data12345', $instance->get($ref));
self::assertTrue($instance->delete($ref));
$instance->delete($ref);
}
/**
@ -70,10 +72,11 @@ abstract class StorageTest extends MockedTest
*/
public function testInvalidDelete()
{
self::expectException(ReferenceStorageException::class);
$instance = $this->getInstance();
// Even deleting not existing references should return "true"
self::assertTrue($instance->delete(-1234456));
$instance->delete(-1234456);
}
/**
@ -81,10 +84,11 @@ abstract class StorageTest extends MockedTest
*/
public function testInvalidGet()
{
self::expectException(ReferenceStorageException::class);
$instance = $this->getInstance();
// Invalid references return an empty string
self::assertEmpty($instance->get(-123456));
$instance->get(-123456);
}
/**