aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2021-03-29 09:41:32 +0200
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2021-04-22 09:34:22 +0000
commitf600fbf364a22783234660d9db4f37e491dd9179 (patch)
tree640ae28768fa93f6257b4798205becc3a4a32a2a
parenta54eaeaaffbd9a4046afc4b0b6e9b8c8f8b27d67 (diff)
downloadnextcloud-server-f600fbf364a22783234660d9db4f37e491dd9179.tar.gz
nextcloud-server-f600fbf364a22783234660d9db4f37e491dd9179.zip
Make Testcase class compatible with phpunit-9.5
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--tests/lib/TestCase.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php
index 6cadf9693c3..066a7d5b137 100644
--- a/tests/lib/TestCase.php
+++ b/tests/lib/TestCase.php
@@ -459,15 +459,27 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase {
}
}
+ protected function getGroupAnnotations(): array {
+ if (method_exists($this, 'getAnnotations')) {
+ $annotations = $this->getAnnotations();
+ return $annotations['class']['group'] ?? [];
+ }
+
+ $r = new \ReflectionClass($this);
+ $doc = $r->getDocComment();
+ preg_match_all('#@group\s+(.*?)\n#s', $doc, $annotations);
+ return $annotations[1] ?? [];
+ }
+
protected function IsDatabaseAccessAllowed() {
// on travis-ci.org we allow database access in any case - otherwise
// this will break all apps right away
if (true == getenv('TRAVIS')) {
return true;
}
- $annotations = $this->getAnnotations();
- if (isset($annotations['class']['group'])) {
- if (in_array('DB', $annotations['class']['group']) || in_array('SLOWDB', $annotations['class']['group'])) {
+ $annotations = $this->getGroupAnnotations();
+ if (isset($annotations)) {
+ if (in_array('DB', $annotations) || in_array('SLOWDB', $annotations)) {
return true;
}
}