From b93b18d98afe0696357a74fe373e4b4542958965 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Thu, 4 Oct 2018 15:56:41 +0300 Subject: [PATCH] tests: Allow string to be passed to getTestUser() etc. If there's only one group, let's not require the brackets. Change-Id: Ib46ef1facbbbf2ba01c13b8290ebbe3a8e08cb4f --- tests/phpunit/MediaWikiTestCase.php | 4 ++-- tests/phpunit/includes/TestUserRegistry.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/phpunit/MediaWikiTestCase.php b/tests/phpunit/MediaWikiTestCase.php index d675e8518b..dd85cc2943 100644 --- a/tests/phpunit/MediaWikiTestCase.php +++ b/tests/phpunit/MediaWikiTestCase.php @@ -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 = [] ) { diff --git a/tests/phpunit/includes/TestUserRegistry.php b/tests/phpunit/includes/TestUserRegistry.php index 24aee24c9b..3064a3d316 100644 --- a/tests/phpunit/includes/TestUserRegistry.php +++ b/tests/phpunit/includes/TestUserRegistry.php @@ -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 ); -- 2.20.1