]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make Testcase class compatible with phpunit-9.5 26353/head
authorJoas Schilling <coding@schilljs.com>
Mon, 29 Mar 2021 07:41:32 +0000 (09:41 +0200)
committerJoas Schilling <coding@schilljs.com>
Mon, 29 Mar 2021 07:43:08 +0000 (09:43 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
tests/lib/TestCase.php

index 08c59633e42d9b0b5a980be9d15308f12fd52f4f..b5dcd76faf90edc97ae4cd4def0e0e0735f8f057 100644 (file)
@@ -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;
                        }
                }