Files
nextcloud-server-mirror/tests/lib/HookHelper.php
Ferdinand Thiessen 8f0d669956 chore(files): remove unused update and post_update filesystem hooks
Nothing listens to `OC_Filesystem::update` or `post_update` anymore.
`write`/`post_write` are emitted at the same places and typed listeners
use `BeforeNodeWrittenEvent`/`NodeWrittenEvent`.

Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-11-03 18:46:47 +01:00

90 lines
1.7 KiB
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test;
use OC\Files\Filesystem;
use OCP\Util;
/**
* Helper class to register hooks on
*/
class HookHelper {
public static $hookCalls;
public static function setUpHooks() {
self::clear();
Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_create,
'\Test\HookHelper',
'createCallback'
);
Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_write,
'\Test\HookHelper',
'writeCallback'
);
Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_post_create,
'\Test\HookHelper',
'postCreateCallback'
);
Util::connectHook(
Filesystem::CLASSNAME,
Filesystem::signal_post_write,
'\Test\HookHelper',
'postWriteCallback'
);
}
public static function clear() {
self::$hookCalls = [];
}
public static function createCallback($params) {
self::$hookCalls[] = [
'signal' => Filesystem::signal_create,
'params' => $params
];
}
public static function writeCallback($params) {
self::$hookCalls[] = [
'signal' => Filesystem::signal_write,
'params' => $params
];
}
public static function postCreateCallback($params) {
self::$hookCalls[] = [
'signal' => Filesystem::signal_post_create,
'params' => $params
];
}
public static function postWriteCallback($params) {
self::$hookCalls[] = [
'signal' => Filesystem::signal_post_write,
'params' => $params
];
}
/**
* Callback that sets the run parameter to false
*/
public static function cancellingCallback($params) {
$params[Filesystem::signal_param_run] = false;
}
}