]> git.mxchange.org Git - friendica.git/commitdiff
Rename ISelectableStorage to IWritableStorage
authorPhilipp <admin@philipp.info>
Tue, 10 Aug 2021 20:07:52 +0000 (22:07 +0200)
committerPhilipp <admin@philipp.info>
Mon, 16 Aug 2021 21:27:42 +0000 (23:27 +0200)
17 files changed:
doc/AddonStorageBackend.md
src/Console/Storage.php
src/Core/StorageManager.php
src/DI.php
src/Model/Attach.php
src/Model/Photo.php
src/Model/Storage/Database.php
src/Model/Storage/Filesystem.php
src/Model/Storage/ISelectableStorage.php [deleted file]
src/Model/Storage/IWritableStorage.php [new file with mode: 0644]
src/Module/Admin/Storage.php
static/dependencies.config.php
tests/Util/SampleStorageBackend.php
tests/src/Core/StorageManagerTest.php
tests/src/Model/Storage/DatabaseStorageTest.php
tests/src/Model/Storage/FilesystemStorageTest.php
tests/src/Model/Storage/StorageTest.php

index b9b7182471871e165e30ee11ff40f6ebc7665fe3..e54960252be4777350d381531a5514bc00c0f42e 100644 (file)
@@ -10,12 +10,12 @@ A storage backend is implemented as a class, and the plugin register the class t
 
 The class must live in `Friendica\Addon\youraddonname` namespace, where `youraddonname` the folder name of your addon.
 
-The class must implement `Friendica\Model\Storage\ISelectableStorage` interface. All method in the interface must be implemented:
+The class must implement `Friendica\Model\Storage\IWritableStorage` interface. All method in the interface must be implemented:
 
-namespace Friendica\Model\ISelectableStorage;
+namespace Friendica\Model\IWritableStorage;
 
 ```php
-interface ISelectableStorage
+interface IWritableStorage
 {
        public function get(string $reference);
        public function put(string $data, string $reference = '');
@@ -79,7 +79,7 @@ Each label should be translatable
        ];
 
 
-See doxygen documentation of `ISelectableStorage` interface for details about each method.
+See doxygen documentation of `IWritableStorage` interface for details about each method.
 
 ## Register a storage backend class
 
@@ -105,8 +105,9 @@ Each new Storage class should be added to the test-environment at [Storage Tests
 Add a new test class which's naming convention is `StorageClassTest`, which extend the `StorageTest` in the same directory.
 
 Override the two necessary instances:
+
 ```php
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 
 abstract class StorageTest 
 {
@@ -114,7 +115,7 @@ abstract class StorageTest
        abstract protected function getInstance();
 
        // Assertion for the option array you return for your new StorageClass
-       abstract protected function assertOption(ISelectableStorage $storage);
+       abstract protected function assertOption(IWritableStorage $storage);
 } 
 ```
 
@@ -138,9 +139,9 @@ If there's a predecessor to this exception (e.g. you caught an exception and are
 Example:
 
 ```php
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 
-class ExampleStorage implements ISelectableStorage 
+class ExampleStorage implements IWritableStorage 
 {
        public function get(string $reference) : string
        {
@@ -168,12 +169,12 @@ The file will be `addon/samplestorage/SampleStorageBackend.php`:
 <?php
 namespace Friendica\Addon\samplestorage;
 
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 
 use Friendica\Core\Config\IConfig;
 use Friendica\Core\L10n;
 
-class SampleStorageBackend implements ISelectableStorage
+class SampleStorageBackend implements IWritableStorage
 {
        const NAME = 'Sample Storage';
 
@@ -305,7 +306,7 @@ function samplestorage_storage_instance(\Friendica\App $a, array $data)
 **Theoretically - until tests for Addons are enabled too - create a test class with the name `addon/tests/SampleStorageTest.php`:
 
 ```php
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 use Friendica\Test\src\Model\Storage\StorageTest;
 
 class SampleStorageTest extends StorageTest 
@@ -319,7 +320,7 @@ class SampleStorageTest extends StorageTest
        }
 
        // Assertion for the option array you return for your new StorageClass
-       protected function assertOption(ISelectableStorage $storage)
+       protected function assertOption(IWritableStorage $storage)
        {
                $this->assertEquals([
                        'filename' => [
index 70e8e263024d8af6bc9b0b79c456f8501ee127ad..34419c48cd6ab1765e38df93cc5fc7dd70da598d 100644 (file)
@@ -132,7 +132,7 @@ HELP;
                }
 
                $name  = $this->args[1];
-               $class = $this->storageManager->getSelectableStorageByName($name);
+               $class = $this->storageManager->getWritableStorageByName($name);
 
                if (is_null($class)) {
                        $this->out($name . ' is not a registered backend.');
index 4603b0fdeda50e16df4cf5c55666dd8f0f736d5c..9e75f83058606e0b1d5934b05180b9f635536827 100644 (file)
@@ -82,13 +82,13 @@ class StorageManager
                $currentName = $this->config->get('storage', 'name', '');
 
                // you can only use user backends as a "default" backend, so the second parameter is true
-               $this->currentBackend = $this->getSelectableStorageByName($currentName);
+               $this->currentBackend = $this->getWritableStorageByName($currentName);
        }
 
        /**
         * Return current storage backend class
         *
-        * @return Storage\ISelectableStorage|null
+        * @return Storage\IWritableStorage|null
         */
        public function getBackend()
        {
@@ -96,16 +96,16 @@ class StorageManager
        }
 
        /**
-        * Returns a selectable storage backend class by registered name
+        * Returns a writable storage backend class by registered name
         *
         * @param string $name Backend name
         *
-        * @return Storage\ISelectableStorage
+        * @return Storage\IWritableStorage
         *
         * @throws Storage\ReferenceStorageException in case there's no backend class for the name
         * @throws Storage\StorageException in case of an unexpected failure during the hook call
         */
-       public function getSelectableStorageByName(string $name = null)
+       public function getWritableStorageByName(string $name = null)
        {
                // @todo 2020.09 Remove this call after 2 releases
                $name = $this->checkLegacyBackend($name);
@@ -130,7 +130,7 @@ class StorageManager
                                                ];
                                                try {
                                                        Hook::callAll('storage_instance', $data);
-                                                       if (($data['storage'] ?? null) instanceof Storage\ISelectableStorage) {
+                                                       if (($data['storage'] ?? null) instanceof Storage\IWritableStorage) {
                                                                $this->backendInstances[$data['name'] ?? $name] = $data['storage'];
                                                        } else {
                                                                throw new Storage\ReferenceStorageException(sprintf('Backend %s was not found', $name));
@@ -244,11 +244,11 @@ class StorageManager
        /**
         * Set current storage backend class
         *
-        * @param Storage\ISelectableStorage $storage The storage class
+        * @param Storage\IWritableStorage $storage The storage class
         *
         * @return boolean True, if the set was successful
         */
-       public function setBackend(Storage\ISelectableStorage $storage)
+       public function setBackend(Storage\IWritableStorage $storage)
        {
                if ($this->config->set('storage', 'name', $storage::getName())) {
                        $this->currentBackend = $storage;
@@ -327,15 +327,15 @@ class StorageManager
         * Copy existing data to destination storage and delete from source.
         * This method cannot move to legacy in-table `data` field.
         *
-        * @param Storage\ISelectableStorage $destination Destination storage class name
-        * @param array            $tables      Tables to look in for resources. Optional, defaults to ['photo', 'attach']
-        * @param int              $limit       Limit of the process batch size, defaults to 5000
+        * @param Storage\IWritableStorage $destination Destination storage class name
+        * @param array                    $tables      Tables to look in for resources. Optional, defaults to ['photo', 'attach']
+        * @param int                      $limit       Limit of the process batch size, defaults to 5000
         *
         * @return int Number of moved resources
         * @throws Storage\StorageException
         * @throws Exception
         */
-       public function move(Storage\ISelectableStorage $destination, array $tables = self::TABLES, int $limit = 5000)
+       public function move(Storage\IWritableStorage $destination, array $tables = self::TABLES, int $limit = 5000)
        {
                if (!$this->isValidBackend($destination, true)) {
                        throw new Storage\StorageException(sprintf("Can't move to storage backend '%s'", $destination::getName()));
@@ -354,7 +354,7 @@ class StorageManager
                        while ($resource = $this->dba->fetch($resources)) {
                                $id        = $resource['id'];
                                $data      = $resource['data'];
-                               $source    = $this->getSelectableStorageByName($resource['backend-class']);
+                               $source    = $this->getWritableStorageByName($resource['backend-class']);
                                $sourceRef = $resource['backend-ref'];
 
                                if (!empty($source)) {
index 9e96ddc0158cd824e8d4cd97f6be4e357c4dbab3..28ad130b4da93719beddf67b594732b38f967974 100644 (file)
@@ -387,11 +387,11 @@ abstract class DI
        }
 
        /**
-        * @return Model\Storage\ISelectableStorage
+        * @return Model\Storage\IWritableStorage
         */
        public static function storage()
        {
-               return self::$dice->create(Model\Storage\ISelectableStorage::class);
+               return self::$dice->create(Model\Storage\IWritableStorage::class);
        }
 
        //
index d3ff5462ca69ad5f6d54ca9f64cf03d1adf6d0f4..ac8bca07f1f2f5c876a550d60883e79c7243892c 100644 (file)
@@ -284,7 +284,7 @@ class Attach
                        $items = self::selectToArray(['backend-class','backend-ref'], $conditions);
 
                        foreach($items as $item) {
-                               $backend_class = DI::storageManager()->getSelectableStorageByName($item['backend-class'] ?? '');
+                               $backend_class = DI::storageManager()->getWritableStorageByName($item['backend-class'] ?? '');
                                if (!empty($backend_class)) {
                                        $fields['backend-ref'] = $backend_class->put($img->asString(), $item['backend-ref'] ?? '');
                                } else {
@@ -316,7 +316,7 @@ class Attach
                $items = self::selectToArray(['backend-class','backend-ref'], $conditions);
 
                foreach($items as $item) {
-                       $backend_class = DI::storageManager()->getSelectableStorageByName($item['backend-class'] ?? '');
+                       $backend_class = DI::storageManager()->getWritableStorageByName($item['backend-class'] ?? '');
                        if (!empty($backend_class)) {
                                try {
                                        $backend_class->delete($item['backend-ref'] ?? '');
index a38743d9d6adbfa5b3d10f13faedabd7b40db9a5..28eb6f36118dc23d186291d10651f90a580e7c85 100644 (file)
@@ -347,7 +347,7 @@ class Photo
 
                if (DBA::isResult($existing_photo)) {
                        $backend_ref = (string)$existing_photo["backend-ref"];
-                       $storage = DI::storageManager()->getSelectableStorageByName($existing_photo["backend-class"] ?? '');
+                       $storage = DI::storageManager()->getWritableStorageByName($existing_photo["backend-class"] ?? '');
                } else {
                        $storage = DI::storage();
                }
@@ -411,7 +411,7 @@ class Photo
                $photos = DBA::select('photo', ['id', 'backend-class', 'backend-ref'], $conditions);
 
                while ($photo = DBA::fetch($photos)) {
-                       $backend_class = DI::storageManager()->getSelectableStorageByName($photo['backend-class'] ?? '');
+                       $backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? '');
                        if (!empty($backend_class)) {
                                try {
                                        $backend_class->delete($item['backend-ref'] ?? '');
@@ -448,7 +448,7 @@ class Photo
                        $photos = self::selectToArray(['backend-class', 'backend-ref'], $conditions);
 
                        foreach($photos as $photo) {
-                               $backend_class = DI::storageManager()->getSelectableStorageByName($photo['backend-class'] ?? '');
+                               $backend_class = DI::storageManager()->getWritableStorageByName($photo['backend-class'] ?? '');
                                if (!empty($backend_class)) {
                                        $fields["backend-ref"] = $backend_class->put($img->asString(), $photo['backend-ref']);
                                } else {
index a77e26811753ec0ee2c246cbf452f5a1648c0227..3457fa4a3045c07099c4888a7f11a4034525d1fc 100644 (file)
@@ -29,7 +29,7 @@ use Friendica\Database\Database as DBA;
  *
  * This class manage data stored in database table.
  */
-class Database implements ISelectableStorage
+class Database implements IWritableStorage
 {
        const NAME = 'Database';
 
index fe5230049f8d18f4af16625c35b17ff01ba6fc55..2d6a3520159a75e4834158be4d04e1e7fae8780a 100644 (file)
@@ -36,7 +36,7 @@ use Friendica\Util\Strings;
  * Each new resource gets a value as reference and is saved in a
  * folder tree stucture created from that value.
  */
-class Filesystem implements ISelectableStorage
+class Filesystem implements IWritableStorage
 {
        const NAME = 'Filesystem';
 
diff --git a/src/Model/Storage/ISelectableStorage.php b/src/Model/Storage/ISelectableStorage.php
deleted file mode 100644 (file)
index d3b7547..0000000
+++ /dev/null
@@ -1,103 +0,0 @@
-<?php
-/**
- * @copyright Copyright (C) 2010-2021, the Friendica project
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program.  If not, see <https://www.gnu.org/licenses/>.
- *
- */
-
-namespace Friendica\Model\Storage;
-
-/**
- * Interface for selectable storage backends
- *
- * Used for storages with CRUD functionality, mainly used for user data (e.g. photos, attachements).
- * There's only one active, selectable storage possible and can be selected by the current administrator
- */
-interface ISelectableStorage extends IStorage
-{
-       /**
-        * Put data in backend as $ref. If $ref is not defined a new reference is created.
-        *
-        * @param string $data      Data to save
-        * @param string $reference Data reference. Optional.
-        *
-        * @return string Saved data reference
-        *
-        * @throws StorageException in case there's an unexpected error
-        */
-       public function put(string $data, string $reference = ""): string;
-
-       /**
-        * Remove data from backend
-        *
-        * @param string $reference Data reference
-        *
-        * @throws StorageException in case there's an unexpected error
-        * @throws ReferenceStorageException in case the reference doesn't exist
-        */
-       public function delete(string $reference);
-
-       /**
-        * Get info about storage options
-        *
-        * @return array
-        *
-        * This method return an array with informations about storage options
-        * from which the form presented to the user is build.
-        *
-        * The returned array is:
-        *
-        *    [
-        *      'option1name' => [ ..info.. ],
-        *      'option2name' => [ ..info.. ],
-        *      ...
-        *    ]
-        *
-        * An empty array can be returned if backend doesn't have any options
-        *
-        * The info array for each option MUST be as follows:
-        *
-        *    [
-        *      'type',      // define the field used in form, and the type of data.
-        *                   // one of 'checkbox', 'combobox', 'custom', 'datetime',
-        *                   // 'input', 'intcheckbox', 'password', 'radio', 'richtext'
-        *                   // 'select', 'select_raw', 'textarea'
-        *
-        *      'label',     // Translatable label of the field
-        *      'value',     // Current value
-        *      'help text', // Translatable description for the field
-        *      extra data   // Optional. Depends on 'type':
-        *                   // select: array [ value => label ] of choices
-        *                   // intcheckbox: value of input element
-        *                   // select_raw: prebuild html string of < option > tags
-        *    ]
-        *
-        * See https://github.com/friendica/friendica/wiki/Quick-Template-Guide
-        */
-       public function getOptions(): array;
-
-       /**
-        * Validate and save options
-        *
-        * @param array $data Array [optionname => value] to be saved
-        *
-        * @return array  Validation errors: [optionname => error message]
-        *
-        * Return array must be empty if no error.
-        */
-       public function saveOptions(array $data): array;
-}
diff --git a/src/Model/Storage/IWritableStorage.php b/src/Model/Storage/IWritableStorage.php
new file mode 100644 (file)
index 0000000..650b324
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+/**
+ * @copyright Copyright (C) 2010-2021, the Friendica project
+ *
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <https://www.gnu.org/licenses/>.
+ *
+ */
+
+namespace Friendica\Model\Storage;
+
+/**
+ * Interface for writable storage backends
+ *
+ * Used for storages with CRUD functionality, mainly used for user data (e.g. photos, attachements).
+ * There's only one active, writable storage possible. This type of storages are selectable by the current administrator
+ */
+interface IWritableStorage extends IStorage
+{
+       /**
+        * Put data in backend as $ref. If $ref is not defined a new reference is created.
+        *
+        * @param string $data      Data to save
+        * @param string $reference Data reference. Optional.
+        *
+        * @return string Saved data reference
+        *
+        * @throws StorageException in case there's an unexpected error
+        */
+       public function put(string $data, string $reference = ""): string;
+
+       /**
+        * Remove data from backend
+        *
+        * @param string $reference Data reference
+        *
+        * @throws StorageException in case there's an unexpected error
+        * @throws ReferenceStorageException in case the reference doesn't exist
+        */
+       public function delete(string $reference);
+
+       /**
+        * Get info about storage options
+        *
+        * @return array
+        *
+        * This method return an array with informations about storage options
+        * from which the form presented to the user is build.
+        *
+        * The returned array is:
+        *
+        *    [
+        *      'option1name' => [ ..info.. ],
+        *      'option2name' => [ ..info.. ],
+        *      ...
+        *    ]
+        *
+        * An empty array can be returned if backend doesn't have any options
+        *
+        * The info array for each option MUST be as follows:
+        *
+        *    [
+        *      'type',      // define the field used in form, and the type of data.
+        *                   // one of 'checkbox', 'combobox', 'custom', 'datetime',
+        *                   // 'input', 'intcheckbox', 'password', 'radio', 'richtext'
+        *                   // 'select', 'select_raw', 'textarea'
+        *
+        *      'label',     // Translatable label of the field
+        *      'value',     // Current value
+        *      'help text', // Translatable description for the field
+        *      extra data   // Optional. Depends on 'type':
+        *                   // select: array [ value => label ] of choices
+        *                   // intcheckbox: value of input element
+        *                   // select_raw: prebuild html string of < option > tags
+        *    ]
+        *
+        * See https://github.com/friendica/friendica/wiki/Quick-Template-Guide
+        */
+       public function getOptions(): array;
+
+       /**
+        * Validate and save options
+        *
+        * @param array $data Array [optionname => value] to be saved
+        *
+        * @return array  Validation errors: [optionname => error message]
+        *
+        * Return array must be empty if no error.
+        */
+       public function saveOptions(array $data): array;
+}
index 374d692bf7330273b7c680494990d7e1feda6748..e12cecd031e921ba1f51ed04fb5e47fc2d395ccd 100644 (file)
@@ -23,7 +23,7 @@ namespace Friendica\Module\Admin;
 
 use Friendica\Core\Renderer;
 use Friendica\DI;
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 use Friendica\Module\BaseAdmin;
 use Friendica\Util\Strings;
 
@@ -37,8 +37,8 @@ class Storage extends BaseAdmin
 
                $storagebackend = Strings::escapeTags(trim($parameters['name'] ?? ''));
 
-               /** @var ISelectableStorage $newstorage */
-               $newstorage = DI::storageManager()->getSelectableStorageByName($storagebackend);
+               /** @var IWritableStorage $newstorage */
+               $newstorage = DI::storageManager()->getWritableStorageByName($storagebackend);
 
                // save storage backend form
                $storage_opts        = $newstorage->getOptions();
@@ -68,8 +68,8 @@ class Storage extends BaseAdmin
                }
 
                if (!empty($_POST['submit_save_set'])) {
-                       /** @var ISelectableStorage $newstorage */
-                       $newstorage = DI::storageManager()->getSelectableStorageByName($storagebackend);
+                       /** @var IWritableStorage $newstorage */
+                       $newstorage = DI::storageManager()->getWritableStorageByName($storagebackend);
 
                        if (!DI::storageManager()->setBackend($newstorage)) {
                                notice(DI::l10n()->t('Invalid storage backend setting value.'));
@@ -92,7 +92,7 @@ class Storage extends BaseAdmin
                        $storage_form_prefix = preg_replace('|[^a-zA-Z0-9]|', '', $name);
 
                        $storage_form = [];
-                       foreach (DI::storageManager()->getSelectableStorageByName($name)->getOptions() as $option => $info) {
+                       foreach (DI::storageManager()->getWritableStorageByName($name)->getOptions() as $option => $info) {
                                $type = $info[0];
                                // Backward compatibilty with yesno field description
                                if ($type == 'yesno') {
@@ -111,7 +111,7 @@ class Storage extends BaseAdmin
                                'name'   => $name,
                                'prefix' => $storage_form_prefix,
                                'form'   => $storage_form,
-                               'active' => $current_storage_backend instanceof ISelectableStorage && $name === $current_storage_backend::getName(),
+                               'active' => $current_storage_backend instanceof IWritableStorage && $name === $current_storage_backend::getName(),
                        ];
                }
 
@@ -127,7 +127,7 @@ class Storage extends BaseAdmin
                        '$noconfig'              => DI::l10n()->t('This backend doesn\'t have custom settings'),
                        '$baseurl'               => DI::baseUrl()->get(true),
                        '$form_security_token'   => self::getFormSecurityToken("admin_storage"),
-                       '$storagebackend'        => $current_storage_backend instanceof ISelectableStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'),
+                       '$storagebackend'        => $current_storage_backend instanceof IWritableStorage ? $current_storage_backend::getName() : DI::l10n()->t('Database (legacy)'),
                        '$availablestorageforms' => $available_storage_forms,
                ]);
        }
index ea57efca5ab86034f9fd96a6b87c5f32f0adee27..5efe78ddf329bd4b89592ffa2708fb7aeb1e9005 100644 (file)
@@ -44,7 +44,7 @@ use Friendica\Core\Session\ISession;
 use Friendica\Core\StorageManager;
 use Friendica\Database\Database;
 use Friendica\Factory;
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 use Friendica\Model\User\Cookie;
 use Friendica\Network;
 use Friendica\Util;
@@ -213,7 +213,7 @@ return [
                        $_SERVER, $_COOKIE
                ],
        ],
-       ISelectableStorage::class => [
+       IWritableStorage::class => [
                'instanceOf' => StorageManager::class,
                'call' => [
                        ['getBackend', [], Dice::CHAIN_CALL],
index 1ebd64f6ee5136374d1936de95afe0d1317f975b..1185a2564695be78b82432d956ae1ab03576bc74 100644 (file)
 namespace Friendica\Test\Util;
 
 use Friendica\Core\Hook;
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 
 use Friendica\Core\L10n;
 
 /**
  * A backend storage example class
  */
-class SampleStorageBackend implements ISelectableStorage
+class SampleStorageBackend implements IWritableStorage
 {
        const NAME = 'Sample Storage';
 
index f01640dce404f78787b6111fb3a999c584b1fc5c..25ae44b1bcf7146cd1776af96b93a294dbf915a9 100644 (file)
@@ -178,7 +178,7 @@ class StorageManagerTest extends DatabaseTest
                $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n, $this->httpRequest);
 
                if ($userBackend) {
-                       $storage = $storageManager->getSelectableStorageByName($name);
+                       $storage = $storageManager->getWritableStorageByName($name);
                } else {
                        $storage = $storageManager->getByName($name);
                }
@@ -230,7 +230,7 @@ class StorageManagerTest extends DatabaseTest
                self::assertNull($storageManager->getBackend());
 
                if ($userBackend) {
-                       $selBackend = $storageManager->getSelectableStorageByName($name);
+                       $selBackend = $storageManager->getWritableStorageByName($name);
                        $storageManager->setBackend($selBackend);
 
                        self::assertInstanceOf($assert, $storageManager->getBackend());
@@ -287,7 +287,7 @@ class StorageManagerTest extends DatabaseTest
                SampleStorageBackend::registerHook();
                Hook::loadHooks();
 
-               self::assertTrue($storageManager->setBackend( $storageManager->getSelectableStorageByName(SampleStorageBackend::NAME)));
+               self::assertTrue($storageManager->setBackend( $storageManager->getWritableStorageByName(SampleStorageBackend::NAME)));
                self::assertEquals(SampleStorageBackend::NAME, $this->config->get('storage', 'name'));
 
                self::assertInstanceOf(SampleStorageBackend::class, $storageManager->getBackend());
@@ -314,7 +314,7 @@ class StorageManagerTest extends DatabaseTest
                $this->loadFixture(__DIR__ . '/../../datasets/storage/database.fixture.php', $this->dba);
 
                $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
-               $storage = $storageManager->getSelectableStorageByName($name);
+               $storage = $storageManager->getWritableStorageByName($name);
                $storageManager->move($storage);
 
                $photos = $this->dba->select('photo', ['backend-ref', 'backend-class', 'id', 'data']);
@@ -333,12 +333,12 @@ class StorageManagerTest extends DatabaseTest
        /**
         * Test moving data to a WRONG storage
         */
-       public function testWrongSelectableStorage()
+       public function testWrongWritableStorage()
        {
                $this->expectException(\TypeError::class);
 
                $storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
-               $storage = $storageManager->getSelectableStorageByName(Storage\SystemResource::getName());
+               $storage = $storageManager->getWritableStorageByName(Storage\SystemResource::getName());
                $storageManager->move($storage);
        }
 }
index 62c8e7f116d4d5310912e26a2f36df63cd1eca27..d7b810c1f887f579f85de1cc844635bd7db28b20 100644 (file)
@@ -23,7 +23,7 @@ namespace Friendica\Test\src\Model\Storage;
 
 use Friendica\Factory\ConfigFactory;
 use Friendica\Model\Storage\Database;
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 use Friendica\Test\DatabaseTestTrait;
 use Friendica\Test\Util\Database\StaticDatabase;
 use Friendica\Test\Util\VFSTrait;
@@ -63,7 +63,7 @@ class DatabaseStorageTest extends StorageTest
                return new Database($dba);
        }
 
-       protected function assertOption(ISelectableStorage $storage)
+       protected function assertOption(IWritableStorage $storage)
        {
                self::assertEmpty($storage->getOptions());
        }
index a0f267d183acc233f10a3f7050ecc213b9ed75df..45a72641630f8af4ac4fbdf2174fd93ff4705ac9 100644 (file)
@@ -24,7 +24,7 @@ namespace Friendica\Test\src\Model\Storage;
 use Friendica\Core\Config\IConfig;
 use Friendica\Core\L10n;
 use Friendica\Model\Storage\Filesystem;
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 use Friendica\Model\Storage\StorageException;
 use Friendica\Test\Util\VFSTrait;
 use Friendica\Util\Profiler;
@@ -64,7 +64,7 @@ class FilesystemStorageTest extends StorageTest
                return new Filesystem($this->config, $l10n);
        }
 
-       protected function assertOption(ISelectableStorage $storage)
+       protected function assertOption(IWritableStorage $storage)
        {
                self::assertEquals([
                        'storagepath' => [
index 4001bfc68b0b6acff8652c1b044d8b1f6bd64168..340aee8bfd45f9e6dcc6257f493067a8c5dab633 100644 (file)
 
 namespace Friendica\Test\src\Model\Storage;
 
-use Friendica\Model\Storage\ISelectableStorage;
+use Friendica\Model\Storage\IWritableStorage;
 use Friendica\Model\Storage\IStorage;
 use Friendica\Model\Storage\ReferenceStorageException;
 use Friendica\Test\MockedTest;
 
 abstract class StorageTest extends MockedTest
 {
-       /** @return ISelectableStorage */
+       /** @return IWritableStorage */
        abstract protected function getInstance();
 
-       abstract protected function assertOption(ISelectableStorage $storage);
+       abstract protected function assertOption(IWritableStorage $storage);
 
        /**
         * Test if the instance is "really" implementing the interface