Skip to content

Commit

Permalink
fix(psalm): Add missing stubs for tests
Browse files Browse the repository at this point in the history
Signed-off-by: provokateurin <kate@provokateurin.de>
  • Loading branch information
provokateurin committed Sep 19, 2024
1 parent 79a0f7f commit 65e1257
Show file tree
Hide file tree
Showing 8 changed files with 853 additions and 11 deletions.
6 changes: 6 additions & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,17 @@
<file name="tests/stubs/oc_files_node_node.php" />
<file name="tests/stubs/oc_files_objectstore_objectstorescanner.php" />
<file name="tests/stubs/oc_files_objectstore_objectstorestorage.php" />
<file name="tests/stubs/oc_files_setupmanager.php" />
<file name="tests/stubs/oc_files_storage_common.php" />
<file name="tests/stubs/oc_files_storage_local.php" />
<file name="tests/stubs/oc_files_storage_storage.php" />
<file name="tests/stubs/oc_files_storage_temporary.php" />
<file name="tests/stubs/oc_files_storage_wrapper_jail.php" />
<file name="tests/stubs/oc_files_storage_wrapper_permissionsmask.php" />
<file name="tests/stubs/oc_files_storage_wrapper_quota.php" />
<file name="tests/stubs/oc_files_storage_wrapper_wrapper.php" />
<file name="tests/stubs/oc_files_view.php" />
<file name="tests/stubs/oc_group_database.php" />
<file name="tests/stubs/oc_group_manager.php" />
<file name="tests/stubs/oc_hooks_basicemitter.php" />
<file name="tests/stubs/oc_hooks_emitter.php" />
Expand Down Expand Up @@ -100,6 +104,8 @@
<file name="tests/stubs/symfony_component_console_question_confirmationquestion.php" />
<file name="tests/stubs/symfony_component_console_question_confirmationquestion.php" />
<file name="tests/stubs/symfony_component_console_question_question.php" />
<file name="tests/stubs/test_testcase.php" />
<file name="tests/stubs/test_traits_usertrait.php" />
</stubs>
<projectFiles>
<directory name="lib" />
Expand Down
97 changes: 97 additions & 0 deletions tests/stubs/oc_files_setupmanager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OC\Files;

use OC\Files\Config\MountProviderCollection;
use OC\Files\Mount\HomeMountPoint;
use OC\Files\Mount\MountPoint;
use OC\Files\Storage\Common;
use OC\Files\Storage\Home;
use OC\Files\Storage\Storage;
use OC\Files\Storage\Wrapper\Availability;
use OC\Files\Storage\Wrapper\Encoding;
use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\Storage\Wrapper\Quota;
use OC\Lockdown\Filesystem\NullStorage;
use OC\Share\Share;
use OC\Share20\ShareDisableChecker;
use OC_App;
use OC_Hook;
use OC_Util;
use OCA\Files_External\Config\ConfigAdapter;
use OCA\Files_Sharing\External\Mount;
use OCA\Files_Sharing\ISharedMountPoint;
use OCA\Files_Sharing\SharedMount;
use OCP\Constants;
use OCP\Diagnostics\IEventLogger;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Config\ICachedMountInfo;
use OCP\Files\Config\IHomeMountProvider;
use OCP\Files\Config\IMountProvider;
use OCP\Files\Config\IUserMountCache;
use OCP\Files\Events\InvalidateMountCacheEvent;
use OCP\Files\Events\Node\FilesystemTornDownEvent;
use OCP\Files\Mount\IMountManager;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
use OCP\Files\Storage\IStorage;
use OCP\Group\Events\UserAddedEvent;
use OCP\Group\Events\UserRemovedEvent;
use OCP\ICache;
use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IUser;
use OCP\IUserManager;
use OCP\IUserSession;
use OCP\Lockdown\ILockdownManager;
use OCP\Share\Events\ShareCreatedEvent;
use Psr\Log\LoggerInterface;

class SetupManager {
public function __construct(private IEventLogger $eventLogger, private MountProviderCollection $mountProviderCollection, private IMountManager $mountManager, private IUserManager $userManager, private IEventDispatcher $eventDispatcher, private IUserMountCache $userMountCache, private ILockdownManager $lockdownManager, private IUserSession $userSession, ICacheFactory $cacheFactory, private LoggerInterface $logger, private IConfig $config, private ShareDisableChecker $shareDisableChecker)
{
}

public function isSetupComplete(IUser $user): bool
{
}

/**
* Setup the full filesystem for the specified user
*/
public function setupForUser(IUser $user): void
{
}

/**
* Set up the root filesystem
*/
public function setupRoot(): void
{
}

/**
* Set up the filesystem for the specified path
*/
public function setupForPath(string $path, bool $includeChildren = false): void
{
}

/**
* @param string $path
* @param string[] $providers
*/
public function setupForProvider(string $path, array $providers): void
{
}

public function tearDown()
{
}
}
210 changes: 210 additions & 0 deletions tests/stubs/oc_files_storage_local.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
<?php

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Files\Storage;

use OC\Files\Filesystem;
use OC\Files\Storage\Wrapper\Encryption;
use OC\Files\Storage\Wrapper\Jail;
use OCP\Constants;
use OCP\Files\ForbiddenException;
use OCP\Files\GenericFileException;
use OCP\Files\IMimeTypeDetector;
use OCP\Files\Storage\IStorage;
use OCP\Files\StorageNotAvailableException;
use OCP\IConfig;
use OCP\Util;
use Psr\Log\LoggerInterface;

/**
* for local filestore, we only have to map the paths
*/
class Local extends \OC\Files\Storage\Common {
protected $datadir;

protected $dataDirLength;

protected $realDataDir;

protected bool $unlinkOnTruncate;

protected bool $caseInsensitive = false;

public function __construct($arguments)
{
}

public function __destruct() {
}

public function getId()
{
}

public function mkdir($path)
{
}

public function rmdir($path)
{
}

public function opendir($path)
{
}

public function is_dir($path)
{
}

public function is_file($path)
{
}

public function stat($path)
{
}

public function getMetaData($path)
{
}

public function filetype($path)
{
}

public function filesize($path): false|int|float
{
}

public function isReadable($path)
{
}

public function isUpdatable($path)
{
}

public function file_exists($path)
{
}

public function filemtime($path)
{
}

public function touch($path, $mtime = null)
{
}

public function file_get_contents($path)
{
}

public function file_put_contents($path, $data)
{
}

public function unlink($path)
{
}

public function rename($source, $target): bool
{
}

public function copy($source, $target)
{
}

public function fopen($path, $mode)
{
}

public function hash($type, $path, $raw = false): string|false
{
}

public function free_space($path)
{
}

public function search($query)
{
}

public function getLocalFile($path)
{
}

/**
* @param string $query
* @param string $dir
* @return array
*/
protected function searchInDir($query, $dir = '')
{
}

/**
* check if a file or folder has been updated since $time
*
* @param string $path
* @param int $time
* @return bool
*/
public function hasUpdated($path, $time)
{
}

/**
* Get the source path (on disk) of a given path
*
* @param string $path
* @return string
* @throws ForbiddenException
*/
public function getSourcePath($path)
{
}

/**
* {@inheritdoc}
*/
public function isLocal()
{
}

public function getETag($path)
{
}

/**
* @param IStorage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @param bool $preserveMtime
* @return bool
*/
public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = false)
{
}

/**
* @param IStorage $sourceStorage
* @param string $sourceInternalPath
* @param string $targetInternalPath
* @return bool
*/
public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath)
{
}

public function writeStream(string $path, $stream, ?int $size = null): int
{
}
}
29 changes: 29 additions & 0 deletions tests/stubs/oc_files_storage_temporary.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\Files\Storage;

/**
* local storage backend in temporary folder for testing purpose
*/
class Temporary extends Local {
public function __construct($arguments = [])
{
}

public function cleanUp()
{
}

public function __destruct()
{
}

public function getDataDir()
{
}
}
Loading

0 comments on commit 65e1257

Please sign in to comment.