[MediaWiki-commits] [Gerrit] mediawiki...Flow[master]: Get rid of $wgFlowGroupPermissions hack

2016-12-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Get rid of $wgFlowGroupPermissions hack
..


Get rid of $wgFlowGroupPermissions hack

Just read the default permissions out of extension.json for tests.

Change-Id: I59f8ebc8bcac204092bfda6c526fec7b62bcea6d
---
M Hooks.php
M tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
M tests/phpunit/FlowTestCase.php
M tests/phpunit/PermissionsTest.php
4 files changed, 13 insertions(+), 30 deletions(-)

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



diff --git a/Hooks.php b/Hooks.php
index ac977d4..5058e65 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -32,22 +32,6 @@
 
require_once __DIR__ . '/defines.php';
 
-   // User permissions
-   // Added to $wgFlowGroupPermissions instead of 
$wgGroupPermissions immediately,
-   // to easily fetch Flow-specific permissions in 
tests/PermissionsTest.php.
-   // If you wish to make local permission changes, add them to 
$wgGroupPermissions
-   // directly - tests will fail otherwise, since they'll be based 
on a different
-   // permissions config than what's assumed to test.
-   $wgFlowGroupPermissions = array();
-   $wgFlowGroupPermissions['*']['flow-hide'] = true;
-   $wgFlowGroupPermissions['user']['flow-lock'] = true;
-   $wgFlowGroupPermissions['sysop']['flow-lock'] = true;
-   $wgFlowGroupPermissions['sysop']['flow-delete'] = true;
-   $wgFlowGroupPermissions['sysop']['flow-edit-post'] = true;
-   $wgFlowGroupPermissions['oversight']['flow-suppress'] = true;
-   $wgFlowGroupPermissions['flow-bot']['flow-create-board'] = true;
-   $wgGroupPermissions = array_merge_recursive( 
$wgGroupPermissions, $wgFlowGroupPermissions );
-
// Make sure all of these are granted via OAuth in Hooks.php
$wgAvailableRights[] = 'flow-hide';
$wgAvailableRights[] = 'flow-lock';
diff --git a/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php 
b/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
index 0734d35..073a1a0 100644
--- a/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
+++ b/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
@@ -57,13 +57,7 @@
 
// We don't want local config getting in the way of testing 
whether or
// not our permissions implementation works well.
-   // This will load default $wgGroupPermissions + Flow settings, 
so we can
-   // test if permissions work well, regardless of any custom 
config.
-   global $IP, $wgFlowGroupPermissions;
-   $wgGroupPermissions = array();
-   require "$IP/includes/DefaultSettings.php";
-   $wgGroupPermissions = array_merge_recursive( 
$wgGroupPermissions, $wgFlowGroupPermissions );
-   $this->setMwGlobals( 'wgGroupPermissions', $wgGroupPermissions 
);
+   $this->resetPermissions();
 
// When external store is used, data is written to "blobs" 
table, which
// by default doesn't exist - let's just not use 
externalstorage in test
diff --git a/tests/phpunit/FlowTestCase.php b/tests/phpunit/FlowTestCase.php
index 18ae56f..87d4e89 100644
--- a/tests/phpunit/FlowTestCase.php
+++ b/tests/phpunit/FlowTestCase.php
@@ -3,6 +3,7 @@
 namespace Flow\Tests;
 
 use EventRelayerNull;
+use ExtensionRegistry;
 use Flow\Container;
 use Flow\Data\FlowObjectCache;
 use Flow\Model\UUID;
@@ -39,4 +40,14 @@
 
return new FlowObjectCache( $wanCache, Container::get( 
'db.factory' ), $wgFlowCacheTime );
}
+
+   protected function resetPermissions() {
+   $registry = new ExtensionRegistry();
+   $data = $registry->readFromQueue( [ __DIR__ . 
'/../../extension.json' => 1 ] );
+   $perms = $data['globals']['wgGroupPermissions'];
+   unset( $perms[$registry::MERGE_STRATEGY] );
+   $this->stashMwGlobals( [ 'wgGroupPermissions'] );
+   global $wgGroupPermissions;
+   $wgGroupPermissions = wfArrayPlus2d( $perms, 
$wgGroupPermissions );
+   }
 }
diff --git a/tests/phpunit/PermissionsTest.php 
b/tests/phpunit/PermissionsTest.php
index 6d1d410..d9e9b7d 100644
--- a/tests/phpunit/PermissionsTest.php
+++ b/tests/phpunit/PermissionsTest.php
@@ -52,13 +52,7 @@
 
// We don't want local config getting in the way of testing 
whether or
// not our permissions implementation works well.
-   // This will load default $wgGroupPermissions + Flow settings, 
so we can
-   // test if permissions work well, regardless of any custom 
config.
-   global $IP, $wgFlowGroupPermissions;
-   

[MediaWiki-commits] [Gerrit] mediawiki...Flow[master]: Get rid of $wgFlowGroupPermissions hack

2016-12-03 Thread Legoktm (Code Review)
Legoktm has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/325156

Change subject: Get rid of $wgFlowGroupPermissions hack
..

Get rid of $wgFlowGroupPermissions hack

Just read the default permissions out of extension.json for tests.

Change-Id: I59f8ebc8bcac204092bfda6c526fec7b62bcea6d
---
M Hooks.php
M tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
M tests/phpunit/FlowTestCase.php
M tests/phpunit/PermissionsTest.php
4 files changed, 13 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/56/325156/1

diff --git a/Hooks.php b/Hooks.php
index ac977d4..5058e65 100644
--- a/Hooks.php
+++ b/Hooks.php
@@ -32,22 +32,6 @@
 
require_once __DIR__ . '/defines.php';
 
-   // User permissions
-   // Added to $wgFlowGroupPermissions instead of 
$wgGroupPermissions immediately,
-   // to easily fetch Flow-specific permissions in 
tests/PermissionsTest.php.
-   // If you wish to make local permission changes, add them to 
$wgGroupPermissions
-   // directly - tests will fail otherwise, since they'll be based 
on a different
-   // permissions config than what's assumed to test.
-   $wgFlowGroupPermissions = array();
-   $wgFlowGroupPermissions['*']['flow-hide'] = true;
-   $wgFlowGroupPermissions['user']['flow-lock'] = true;
-   $wgFlowGroupPermissions['sysop']['flow-lock'] = true;
-   $wgFlowGroupPermissions['sysop']['flow-delete'] = true;
-   $wgFlowGroupPermissions['sysop']['flow-edit-post'] = true;
-   $wgFlowGroupPermissions['oversight']['flow-suppress'] = true;
-   $wgFlowGroupPermissions['flow-bot']['flow-create-board'] = true;
-   $wgGroupPermissions = array_merge_recursive( 
$wgGroupPermissions, $wgFlowGroupPermissions );
-
// Make sure all of these are granted via OAuth in Hooks.php
$wgAvailableRights[] = 'flow-hide';
$wgAvailableRights[] = 'flow-lock';
diff --git a/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php 
b/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
index 0734d35..073a1a0 100644
--- a/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
+++ b/tests/phpunit/Collection/RevisionCollectionPermissionsTest.php
@@ -57,13 +57,7 @@
 
// We don't want local config getting in the way of testing 
whether or
// not our permissions implementation works well.
-   // This will load default $wgGroupPermissions + Flow settings, 
so we can
-   // test if permissions work well, regardless of any custom 
config.
-   global $IP, $wgFlowGroupPermissions;
-   $wgGroupPermissions = array();
-   require "$IP/includes/DefaultSettings.php";
-   $wgGroupPermissions = array_merge_recursive( 
$wgGroupPermissions, $wgFlowGroupPermissions );
-   $this->setMwGlobals( 'wgGroupPermissions', $wgGroupPermissions 
);
+   $this->resetPermissions();
 
// When external store is used, data is written to "blobs" 
table, which
// by default doesn't exist - let's just not use 
externalstorage in test
diff --git a/tests/phpunit/FlowTestCase.php b/tests/phpunit/FlowTestCase.php
index 18ae56f..bd47647 100644
--- a/tests/phpunit/FlowTestCase.php
+++ b/tests/phpunit/FlowTestCase.php
@@ -3,6 +3,7 @@
 namespace Flow\Tests;
 
 use EventRelayerNull;
+use ExtensionRegistry;
 use Flow\Container;
 use Flow\Data\FlowObjectCache;
 use Flow\Model\UUID;
@@ -39,4 +40,14 @@
 
return new FlowObjectCache( $wanCache, Container::get( 
'db.factory' ), $wgFlowCacheTime );
}
+
+   protected function resetPermissions() {
+   $registry = new ExtensionRegistry();
+   $data = $registry->readFromQueue( [ __DIR__ . 
'../../extension.json' => 1 ] );
+   $perms = $data['globals']['wgGroupPermissions'];
+   unset( $perms[$registry::MERGE_STRATEGY] );
+   $this->stashMwGlobals( [ 'wgGroupPermissions'] );
+   global $wgGroupPermissions;
+   $wgGroupPermissions = wfArrayPlus2d( $perms, 
$wgGroupPermissions );
+   }
 }
diff --git a/tests/phpunit/PermissionsTest.php 
b/tests/phpunit/PermissionsTest.php
index 6d1d410..d9e9b7d 100644
--- a/tests/phpunit/PermissionsTest.php
+++ b/tests/phpunit/PermissionsTest.php
@@ -52,13 +52,7 @@
 
// We don't want local config getting in the way of testing 
whether or
// not our permissions implementation works well.
-   // This will load default $wgGroupPermissions + Flow settings, 
so we can
-   // test if permissions work well, regardless of any custom 
config.
-