jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344138 )

Change subject: GroupManager: API Unittest
......................................................................


GroupManager: API Unittest

Change-Id: I390f382e3520e6b3cbbe8eda95dcdef5bedeeaa3
ERM: #5802
---
M GroupManager/GroupManager.class.php
M GroupManager/extension.json
A GroupManager/tests/phpunit/BSApiTasksGroupManagerTest.php
3 files changed, 101 insertions(+), 0 deletions(-)

Approvals:
  Robert Vogel: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/GroupManager/GroupManager.class.php 
b/GroupManager/GroupManager.class.php
index 1870a1e..0530c3b 100644
--- a/GroupManager/GroupManager.class.php
+++ b/GroupManager/GroupManager.class.php
@@ -144,4 +144,16 @@
                }
        }
 
+       /**
+        * UnitTestsList allows registration of additional test suites to 
execute
+        * under PHPUnit. Extensions can append paths to files to the $paths 
array,
+        * and since MediaWiki 1.24, can specify paths to directories, which 
will
+        * be scanned recursively for any test case files with the suffix 
"Test.php".
+        * @param array $paths
+        */
+       public static function onUnitTestsList ( array &$paths ) {
+               $paths[] = __DIR__ . '/tests/phpunit/';
+               return true;
+       }
+
 }
diff --git a/GroupManager/extension.json b/GroupManager/extension.json
index 0033692..dc7d311 100644
--- a/GroupManager/extension.json
+++ b/GroupManager/extension.json
@@ -48,6 +48,9 @@
                "BSApiTasksGroupManager": 
"includes/api/BSApiTasksGroupManager.php",
                "SpecialGroupManager": 
"includes/specials/SpecialGroupManager.class.php"
        },
+       "Hooks": {
+               "UnitTestsList": "GroupManager::onUnitTestsList"
+       },
        "ResourceModules": {
                "ext.bluespice.groupManager": {
                        "scripts": "bluespice.groupManager.js",
diff --git a/GroupManager/tests/phpunit/BSApiTasksGroupManagerTest.php 
b/GroupManager/tests/phpunit/BSApiTasksGroupManagerTest.php
new file mode 100644
index 0000000..f5b0720
--- /dev/null
+++ b/GroupManager/tests/phpunit/BSApiTasksGroupManagerTest.php
@@ -0,0 +1,86 @@
+<?php
+
+/**
+ * @group medium
+ * @group API
+ */
+class BSApiTasksGroupManagerTest extends BSApiTasksTestBase {
+
+       protected function getModuleName() {
+               return 'bs-groupmanager';
+       }
+
+       function getTokens() {
+               return $this->getTokenList( self::$users[ 'sysop' ] );
+       }
+
+       public function testAddGroup() {
+               global $wgAdditionalGroups;
+
+               $aGroupsToAdd = array( 'DummyGroup', 'DummyGroup2', 
'DummyGroup3' );
+               foreach( $aGroupsToAdd as $sGroup ) {
+                       $oData = $this->addGroup( $sGroup );
+
+                       $this->assertTrue( $oData->success );
+                       $this->assertTrue( isset( $wgAdditionalGroups[$sGroup] 
) );
+               }
+       }
+
+       public function testEditGroup() {
+               global $wgAdditionalGroups, $wgGroupPermissions;
+
+               $wgGroupPermissions['DummyGroup'] = array();
+
+               $oData = $this->executeTask(
+                       'editGroup',
+                       array(
+                               'group' => 'DummyGroup',
+                               'newGroup' => 'FakeGroup'
+                       )
+               );
+
+               $this->assertEquals( true, $oData->success );
+               $this->assertTrue( isset( $wgAdditionalGroups['FakeGroup'] ) );
+               $this->assertFalse( $wgAdditionalGroups['DummyGroup'] );
+       }
+
+       public function testRemoveGroup() {
+               global $wgAdditionalGroups;
+
+               $oData = $this->executeTask(
+                       'removeGroup',
+                       array(
+                               'group' => 'FakeGroup'
+                       )
+               );
+
+               $this->assertEquals( true, $oData->success );
+               $this->assertFalse( $wgAdditionalGroups['FakeGroup'] );
+       }
+
+       public function testRemoveGroups() {
+               global $wgAdditionalGroups;
+
+               $oData = $this->executeTask(
+                       'removeGroups',
+                       array(
+                               'groups' => array( 'DummyGroup2', 'DummyGroup3' 
)
+                       )
+               );
+
+               $this->assertEquals( true, $oData->success );
+               $this->assertFalse( $wgAdditionalGroups['DummyGroup2'] );
+               $this->assertFalse( $wgAdditionalGroups['DummyGroup3'] );
+       }
+
+       protected function addGroup( $sName ) {
+               $oData = $this->executeTask(
+                       'addGroup',
+                       array(
+                               'group' => $sName
+                       )
+               );
+
+               return $oData;
+       }
+}
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/344138
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I390f382e3520e6b3cbbe8eda95dcdef5bedeeaa3
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: master
Gerrit-Owner: ItSpiderman <[email protected]>
Gerrit-Reviewer: Ljonka <[email protected]>
Gerrit-Reviewer: Mglaser <[email protected]>
Gerrit-Reviewer: Pwirth <[email protected]>
Gerrit-Reviewer: Robert Vogel <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to