diff options
author | Joas Schilling <coding@schilljs.com> | 2024-09-19 18:19:32 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-09-19 18:19:32 +0200 |
commit | 4ccf62a2249495b5f01582fa529762e631051c56 (patch) | |
tree | 90191101e56ff673125988068e091b1c7e207ae4 /tests/lib/TestCase.php | |
parent | 96de697aa6fe7e75c7e311e07536cc84a29a0088 (diff) | |
download | nextcloud-server-4ccf62a2249495b5f01582fa529762e631051c56.tar.gz nextcloud-server-4ccf62a2249495b5f01582fa529762e631051c56.zip |
chore: Cleanup and prepare some app tests for PHPUnit 10ci/noid/prepare-phpunit-10
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests/lib/TestCase.php')
-rw-r--r-- | tests/lib/TestCase.php | 24 |
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, |