aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2024-09-19 19:28:07 +0200
committerGitHub <noreply@github.com>2024-09-19 19:28:07 +0200
commit75f5cb76300ca754f141573e76e029efb9369e51 (patch)
tree2e0eba97df761ca0da2d84ba959ca053090b8961 /tests
parent00a27afa264c98cd1ca65a682f459f60ef91b497 (diff)
parent4ccf62a2249495b5f01582fa529762e631051c56 (diff)
downloadnextcloud-server-75f5cb76300ca754f141573e76e029efb9369e51.tar.gz
nextcloud-server-75f5cb76300ca754f141573e76e029efb9369e51.zip
Merge pull request #48218 from nextcloud/ci/noid/prepare-phpunit-10
chore: Cleanup and prepare some app tests for PHPUnit 10
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/TestCase.php24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 03886d4a0be..d74dacd76c1 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -271,6 +271,30 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
);
}
+ /**
+ * Filter methods
+ *
+ * Returns all methods of the given class,
+ * that are public or abstract and not in the ignoreMethods list,
+ * to be able to fill onlyMethods() with an inverted list.
+ *
+ * @param string $className
+ * @param string[] $filterMethods
+ * @return string[]
+ */
+ public function filterClassMethods(string $className, array $filterMethods): array {
+ $class = new \ReflectionClass($className);
+
+ $methods = [];
+ foreach ($class->getMethods() as $method) {
+ if (($method->isPublic() || $method->isAbstract()) && !in_array($method->getName(), $filterMethods, true)) {
+ $methods[] = $method->getName();
+ }
+ }
+
+ return $methods;
+ }
+
public static function tearDownAfterClass(): void {
if (!self::$wasDatabaseAllowed && self::$realDatabase !== null) {
// in case an error is thrown in a test, PHPUnit jumps straight to tearDownAfterClass,