Commit graph

19 commits

Author SHA1 Message Date
addshore
fb16eb2abe Add more @covers tags and test cleanup
Other cleanup includes
 - Adding method scopes
 - Fixing php comments
 - Adding todos

Change-Id: I0a231008e6a59110ffcab6af1bd8c4d3ee13f21d
2013-10-22 08:59:42 +00:00
Brad Jorsch
08adf46b26 Add 'viewmyprivateinfo', 'editmyprivateinfo', and 'editmyoptions' rights
These are needed for OAuth grants.

Note that we don't bother with a 'viewmyoptions' right, since the
majority will be determinable from just observing the interface.

Note that the fact of having a confirmed email address cannot be
reliably hidden, and if the user has 'sendemail' they may be able to
determine the real name and email address by sending an email to another
account that they control.

Change-Id: I3f03dd010020e8d43cc2d3bca7b3ef7196d1c548
2013-07-03 13:40:04 -04:00
Siebrand Mazeland
7a24666935 Update formatting
2 of n.

Change-Id: I5406673e99ed53e4e330ed47f022a17177544daa
2013-02-14 12:36:35 +01:00
Antoine Musso
0fd05285d7 pass codesniffer on tests/
Fix almost all occurences of the following sniffs:

Generic.CodeAnalysis.UselessOverridingMethod.Found
Generic.Formatting.NoSpaceAfterCast.SpaceFound
Generic.Functions.FunctionCallArgumentSpacing.SpaceBeforeComma
Generic.Functions.OpeningFunctionBraceKernighanRitchie.BraceOnNewLine
Generic.PHP.LowerCaseConstant.Found
PSR2.Classes.PropertyDeclaration.ScopeMissing
PSR2.Files.EndFileNewline.TooMany
PSR2.Methods.MethodDeclaration.StaticBeforeVisibility

Change-Id: I96aacef5bafe5a2bca659744fba1380999cfc37d
2013-01-28 12:14:26 +01:00
aude
c5ca90e715 fix testEditCount to work with non-wikitext content in main NS
consistent with WikiPageTest and other places, perform the test
with the Help namespace as a workaround for now.

Change-Id: I2b766c17f35e0e79662b6302c122225a1a33e7be
2012-11-08 18:06:32 +01:00
parent5446
edf5632f6a (bug 37963) Fixed loading process for user options.
The bug has actually already been fixed, so this
patch just removes extraneous function calls and code in
User::getOption() and User::setOption(). It also adds
unit tests for user options (including a test for the
case provided in the bug report).

Change-Id: Idd8af9cf1a26a4adbde3ca71dde64539ecd0a207
2012-10-30 20:28:39 +01:00
Antoine Musso
93dcfa9f05 raise timeout for UserTest::testEditCount
UserTest::testEditCount did eleven calls to doEdit which is slow when
used with the sqlite backend. I have made to do less edits and also
marked it as '@group medium' which means the timeout will be 10 seconds
instead of 2 seconds.

Change-Id: If2d055075470f837009568d56b1119a57b177ba3
2012-10-26 15:40:29 +02:00
Marius Hoch
e65eb02d3e Unit test for User::getEditCount
Rather trivial test for User::getEditCount as suggested by
Siebrand in https://gerrit.wikimedia.org/r/26457

This required adding the User in the test to DB, as the data
is written to and read from the DB.

Change-Id: Ic4e55c01247158315b759654b34fdbdf9a61db01
2012-10-18 16:48:35 +02:00
Timo Tijhof
181c7cdc8e Clean and repair many phpunit tests (+ fix implied configuration)
This commit depends on the introduction of
MediaWikiTestCase::setMwGlobals in change Iccf6ea81f4.

Various tests already set their globals, but forgot to restore
them afterwards, or forgot to call the parent setUp, tearDown...

Either way they won't have to anymore with setMwGlobals.

Consistent use of function characteristics:
* protected function setUp
* protected function tearDown
* public static function (provide..)

(Matching the function signature with PHPUnit/Framework/TestCase.php)

Replaces:
 * public function (setUp|tearDown)\(
 * protected function $1(

 * \tfunction (setUp|tearDown)\(
 * \tprotected function $1(

 * \tfunction (data|provide)\(
 * \tpublic static function $1\(

Also renamed a few "data#", "provider#" and "provides#" functions
to "provide#" for consistency. This also removes confusion where
the /media tests had a few private methods called dataFile(),
which were sometimes expected to be data providers.

Fixes:

TimestampTest often failed due to a previous test setting a
different language (it tests "1 hour ago" so need to make sure
it is set to English).

MWNamespaceTest became a lot cleaner now that it executes with
a known context. Though the now-redundant code that was removed
didn't work anyway because wgContentNamespaces isn't keyed by
namespace id, it had them was values...

FileBackendTest:
* Fixed: "PHP Fatal: Using $this when not in object context"

HttpTest
* Added comment about:
  "PHP Fatal: Call to protected MWHttpRequest::__construct()"
  (too much unrelated code to fix in this commit)

ExternalStoreTest
* Add an assertTrue as well, without it the test is useless
  because regardless of whether wgExternalStores is true or false
  it only uses it if it is an array.

Change-Id: I9d2b148e57bada64afeb7d5a99bec0e58f8e1561
2012-10-09 03:01:51 +02:00
umherirrender
fdd2df0a80 Add UserTest::testAllRightsWithMessage
New test case, which checked, if for all available rights a right-
message exist (Core and Extensions)

Some missing rights added with extra patch sets (need merge/rebasing
before merge of this)

Change-Id: I28957835fb77a01a799439ad7b3d22b96db07204
2012-08-13 23:26:58 +02:00
Sam Reed
ec4604de3d Documentation and whitespace
Clearing another w/c
2012-01-19 14:56:18 +00:00
Tim Starling
3da36a9103 Reverted r92364 (per-namespace permissions).
This is the wrong configuration format for such a feature, and the wrong interface. We already have certain per-namespace permissions in the Title class, and we didn't need to add extra formal parameters to a whole lot of User methods in order to get them. The feature should be implemented wholly in Title, and the concept of user rights should remain relatively simple and easy to understand, and independent of its many applications, i.e. a user either has a right or doesn't. Rights are just a tool for developing access policies; the complexity should be in the caller.

The revert was mostly done by hand, since there were a lot of conflicts. I tried to preserve the gist of conflicting changes in r102187 and r102873. The test changes are not simple reverts, rather I just edited out the per-namespace tests. I reverted the followups r92589 and r104310.
2011-12-12 06:03:01 +00:00
Santhosh Thottingal
462319d089 Use dataProvider for the testIsValidUserName method. Followup r99466 2011-10-11 10:25:58 +00:00
Santhosh Thottingal
08aac7bd40 Stylize.php changes 2011-10-11 10:02:50 +00:00
Santhosh Thottingal
2a7c8be024 Testcases for isValidUserName method of User.php.
There are many cases this method will fail for non-latin languages, 
but not added now since there are bugs reported on that already and results
a rewrite of the method as per UAX 31 standard.
2011-10-11 09:17:36 +00:00
Platonides
2d9bb42682 Since r92364 UserTest.php needs a database 2011-07-19 21:41:25 +00:00
Bryan Tong Minh
1fb5d73612 First steps for bug 14801: add backend support for per-namespace permissions to core. This extends $wgGroupPermissions syntax from $wgGroupPermissions[$group][$right] = bool to $wgGroupPermissions[$group][$right] = array( NS_X => bool ). This is safely backwards compatible; the booleans are still fully supported, and any unset namespace will default to false.
* User::getRights(), User::isAllowed() and User::getGroupPermissions now optionally accept a namespace parameter. If not set, it will check whether the user has the right for all namespaces.
* Anything that uses Title::getUserPermissionsErrorsInternal() automatically supports per-namespace permissions. This includes Title::getUserPermissionsErrors and Title::(quick)UserCan.
* Fix tests that set User::mRights

The next step would be to change all User::isAllowed() to Title::quickUserCan or pass the namespace to User::isAllowed().
2011-07-16 16:09:00 +00:00
Bryan Tong Minh
6a16bea0d2 Follow-up r91895: Call parent destructor as well, just to be safe. 2011-07-11 18:38:26 +00:00
Bryan Tong Minh
8d89af55cc Add unit tests for $wgGroupPermissions/$wgRevokePermissions 2011-07-11 18:36:29 +00:00