diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2021-03-29 10:47:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 10:47:37 +0200 |
commit | 8d3fdf24c818985f32bf3eeb144ffa6abb32b475 (patch) | |
tree | 099459c0d1b5b22de01b2f5e9e986dcc0b232014 /tests | |
parent | 6bef9e71daa2a59a32cd13a334d4488e115acf41 (diff) | |
parent | cd35a5c71de5a4ec0068dfa851ef901a292a964b (diff) | |
download | nextcloud-server-8d3fdf24c818985f32bf3eeb144ffa6abb32b475.tar.gz nextcloud-server-8d3fdf24c818985f32bf3eeb144ffa6abb32b475.zip |
Merge pull request #26353 from nextcloud/techdebt/noid/make-testcase-class-compatible-with-phpunit-9.5
Make Testcase class compatible with phpunit-9.5
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/TestCase.php | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index 08c59633e42..b5dcd76faf9 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; } } |