use Friendica\Core\Config\IConfig;
use Friendica\Database\Database;
use Friendica\Model\Storage;
+use Friendica\Network\IHTTPRequest;
use Psr\Log\LoggerInterface;
private $logger;
/** @var L10n */
private $l10n;
+ /** @var IHTTPRequest */
+ private $httpRequest;
/** @var Storage\IStorage */
private $currentBackend;
* @param LoggerInterface $logger
* @param L10n $l10n
*/
- public function __construct(Database $dba, IConfig $config, LoggerInterface $logger, L10n $l10n)
+ public function __construct(Database $dba, IConfig $config, LoggerInterface $logger, L10n $l10n, IHTTPRequest $httpRequest)
{
- $this->dba = $dba;
- $this->config = $config;
- $this->logger = $logger;
- $this->l10n = $l10n;
+ $this->dba = $dba;
+ $this->config = $config;
+ $this->logger = $logger;
+ $this->l10n = $l10n;
+ $this->httpRequest = $httpRequest;
$this->backends = $config->get('storage', 'backends', self::DEFAULT_BACKENDS);
$currentName = $this->config->get('storage', 'name', '');
$this->backendInstances[$name] = new Storage\SystemResource();
break;
case Storage\ExternalResource::getName():
- $this->backendInstances[$name] = new Storage\ExternalResource();
+ $this->backendInstances[$name] = new Storage\ExternalResource($this->httpRequest);
break;
default:
$data = [
use Friendica\Model\Storage;
use Friendica\Core\Session;
use Friendica\Model\Storage\StorageException;
+use Friendica\Network\HTTPRequest;
use Friendica\Test\DatabaseTest;
use Friendica\Test\Util\Database\StaticDatabase;
use Friendica\Test\Util\VFSTrait;
private $logger;
/** @var L10n */
private $l10n;
+ /** @var HTTPRequest */
+ private $httpRequest;
use VFSTrait;
$this->config = new PreloadConfig($configCache, $configModel);
$this->l10n = \Mockery::mock(L10n::class);
+
+ $this->httpRequest = \Mockery::mock(HTTPRequest::class);
}
/**
*/
public function testInstance()
{
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
self::assertInstanceOf(StorageManager::class, $storageManager);
}
*/
public function testGetByName($name, $assert, $assertName, $userBackend)
{
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
$storage = $storageManager->getByName($name, $userBackend);
*/
public function testIsValidBackend($name, $assert, $assertName, $userBackend)
{
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
// true in every of the backends
self::assertEquals(!empty($assertName), $storageManager->isValidBackend($name));
*/
public function testListBackends()
{
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
self::assertEquals(StorageManager::DEFAULT_BACKENDS, $storageManager->listBackends());
}
*/
public function testGetBackend($name, $assert, $assertName, $userBackend)
{
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
self::assertNull($storageManager->getBackend());
{
$this->config->set('storage', 'name', $name);
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
if ($userBackend) {
self::assertInstanceOf($assert, $storageManager->getBackend());
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice);
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
self::assertTrue($storageManager->register(SampleStorageBackend::class));
$this->loadFixture(__DIR__ . '/../../datasets/storage/database.fixture.php', $this->dba);
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
$storage = $storageManager->getByName($name);
$storageManager->move($storage);
$this->expectExceptionMessage("Can't move to storage backend 'SystemResource'");
$this->expectException(StorageException::class);
- $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
+ $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
$storage = $storageManager->getByName(Storage\SystemResource::getName());
$storageManager->move($storage);
}