tests: Allow string to be passed to getTestUser() etc.
authorAryeh Gregor <ayg@aryeh.name>
Thu, 4 Oct 2018 12:56:41 +0000 (15:56 +0300)
committerLegoktm <legoktm@member.fsf.org>
Thu, 4 Oct 2018 15:30:47 +0000 (15:30 +0000)
If there's only one group, let's not require the brackets.

Change-Id: Ib46ef1facbbbf2ba01c13b8290ebbe3a8e08cb4f

tests/phpunit/MediaWikiTestCase.php
tests/phpunit/includes/TestUserRegistry.php

index d675e85..dd85cc2 100644 (file)
@@ -158,7 +158,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
         *
         * @since 1.28
         *
-        * @param string[] $groups Groups the test user should be in.
+        * @param string|string[] $groups Groups the test user should be in.
         * @return TestUser
         */
        public static function getTestUser( $groups = [] ) {
@@ -170,7 +170,7 @@ abstract class MediaWikiTestCase extends PHPUnit\Framework\TestCase {
         *
         * @since 1.28
         *
-        * @param string[] $groups Groups the test user should be added in.
+        * @param string|string[] $groups Groups the test user should be added in.
         * @return TestUser
         */
        public static function getMutableTestUser( $groups = [] ) {
index 24aee24..3064a3d 100644 (file)
@@ -28,7 +28,7 @@ class TestUserRegistry {
         *
         * @param string $testName Caller's __CLASS__. Used to generate the
         *  user's username.
-        * @param string[] $groups Groups the test user should be added to.
+        * @param string|string[] $groups Groups the test user should be added to.
         * @return TestUser
         */
        public static function getMutableTestUser( $testName, $groups = [] ) {
@@ -38,7 +38,7 @@ class TestUserRegistry {
                        "TestUser $testName $id",  // username
                        "Name $id",                // real name
                        "$id@mediawiki.test",      // e-mail
-                       $groups,                   // groups
+                       (array)$groups,            // groups
                        $password                  // password
                );
                $testUser->getUser()->clearInstanceCache();
@@ -54,11 +54,11 @@ class TestUserRegistry {
         *
         * @since 1.28
         *
-        * @param string[] $groups Groups the test user should be added to.
+        * @param string|string[] $groups Groups the test user should be added to.
         * @return TestUser
         */
        public static function getImmutableTestUser( $groups = [] ) {
-               $groups = array_unique( $groups );
+               $groups = array_unique( (array)$groups );
                sort( $groups );
                $key = implode( ',', $groups );