Commit graph

41 commits

Author SHA1 Message Date
Siebrand Mazeland
4916e08d8e Pass phpcs-strict on some test files (4/x)
Change-Id: Ifdbb431a6018c514b15ae71cc0c21b653a5e466d
2014-04-24 18:51:42 +02:00
umherirrender
db24b10ca8 Use lowercase key words
Change-Id: I57569b7082a0decc8128ecadd8ec5d1a5c327673
2013-11-23 15:56:42 +01:00
addshore
caec5f920a @covers tags for the rest of test files..
Change-Id: I0fafe80531325a412472ab7c9fc6d81c861b3751
2013-10-24 21:38:08 +01:00
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
d24779328e Fix protection rights usage
It has long been recognized that using the 'protect' right to control
the ability to edit sysop-protected pages is troublesome. r31247 fixed
this by adding an 'editprotected' right, but for some reason in r32164
this was changed to bypass protection completely instead of fixing the
bug identified in r31462.

This patch goes back to do it the right way: editprotected no longer
bypasses all protection, and it is used instead of 'protect' for
controlling access to sysop-protected pages. For good measure, the same
is done with autoconfirmed protection (semiprotection): a new
editsemiprotected right is created instead of overloading the
existing autoconfirmed right.

This also fixes bug 27152 by making editprotected no longer special.

Bug: 13137
Bug: 27152
Change-Id: I6bf650a3fbdab8589ae6945c8c916eafd949e41c
2013-07-04 15:38:36 +10:00
Brad Jorsch
fc989b468d Add user rights 'editmyuserjs' and 'editmyusercss'
These are needed for OAuth grants.

Change-Id: I52f8e4a5cb48573cb2dbc26fc508e61a95d748c3
2013-06-10 15:44:22 -04:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Kevin Israel
47d1060398 Remove is_numeric check from Title::checkUserBlock
This should allow the usernames of administrators such as "7"
to show correctly on permissions error pages.

I extracted the working code from UserBlockedError::__construct
into a separate method Block::getPermissionsError, called from
both places with context provided as an argument.

Additional changes to get the test suite to pass are included.

Bug: 46768
Change-Id: I49d973992a99e03b4e8de112b47b737037a85338
2013-04-24 01:05:23 +00:00
Siebrand Mazeland
7a24666935 Update formatting
2 of n.

Change-Id: I5406673e99ed53e4e330ed47f022a17177544daa
2013-02-14 12:36:35 +01:00
Brian Wolff
3896b55a37 Remove references to non-existent 'execute' right in Title.php
The permission checks in Title will automatically fail
any check against a special page, except for read, execute
and createaccount. However, execute is not a right. It
is not mentioned in any other MW file (or extension for
that matter). It is neither in the list of core user
rights in User.php, nor does it have a system msg
If someone wants to check if they can
run a special page, they should be doing a 'read'
check.

Note: The check in question was added in bc23aede55 back in 2008

I'm unsure if it is better to just leave it alone, or remove it.
However, its presence could cause some confusion, hence this
commit. Additionally I was unsure if this justified a release
notes entry.

Change-Id: I9cf2b0424b9cb189ac122b8274ec681302f560f7
2013-01-22 09:13:51 +01:00
Alexandre Emsenhuber
07818096df (bug 35204) set wgLanguageCode in unit tests
Setting $wgContLang without changing $wgLanguageCode accordingly is a
very bad idea.

This caused about 20 exceptions when using LanguageCode set to 'fr'
on my installation:

"MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode
('fr') is different from $wgContLang->getCode() (en)"

Follow-up of I2987db68 (2b0edc8).

Change-Id: I56d3f1bfc78d6a2e40460533524e82f360490206
2012-11-17 09:53:34 +01:00
umherirrender
84e75e744a Avoid using $wgUser in TitlePermissionTest
Change-Id: I2432cd66c11d68213f96ef96f972fc10d9dfa504
2012-10-14 19:00:24 +00:00
daniel
4ec9459100 [Bug 40716] Fix SearchEngineTest etc with non-wikitext content.
Several core tests fail if there is non-wikitext content in the main namespace.
This change fixes SearchEngineTest and TitlePermissionTest for this case.
More fixes are to come.

Change-Id: I6a19b568c5700bc8584689de8f33e4b0b6ffc277
2012-10-12 13:09:08 +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
Antoine Musso
86021805a4 Revert "(bug 32297) Use symbolic names, not offsets for a default timezone."
This reverts commit 3056b8dfd2.

Change-Id: I29cf9a5389709b30f869072ed836cb5b85ba5106
2012-07-02 13:12:16 +02:00
Szymon Świerkosz
3056b8dfd2 (bug 32297) Use symbolic names, not offsets for a default timezone.
Change-Id: I4a12487487bbb7897911b13068e2d7a1340e7206
2012-05-04 19:00:01 +02:00
Aaron Schulz
ea6b51694e r112563: Removed random bogus user IDs passed into to Block constructor in tests 2012-02-28 02:32:59 +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
Alexandre Emsenhuber
d1d5d0ee89 Removed useless second parameter to Title::quickUserCan() 2011-11-07 13:54:03 +00:00
Sam Reed
27665d27ae Update some deprecated code
Documentation

Fix "/*" comments to "/**"

Flesh out some missing returns, change some return types
2011-10-14 21:18:38 +00:00
Roan Kattouw
6f1fee123b Fix a message key typo in r41961 (!!), which didn't matter before because the relevant code (and the message) wasn't reachable. 2011-08-30 11:39:43 +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
Antoine Musso
854b84ef42 enhance tests name (for --testdox option) 2011-07-03 18:09:30 +00:00
Platonides
4a6f236904 Readd r90538, this time with the missing global $wgHooks; 2011-06-22 21:02:07 +00:00
Chad Horohoe
65e2d85048 Provisional revert of r90538. I can't replicate the failures, but CI's been complaining since this commit 2011-06-22 00:01:15 +00:00
Platonides
1d7f09a4f7 UploadTest::testTitleValidation accessed the database to fetch the interwikis.
phase3/includes/upload/UploadBase.php:620
phase3/tests/phpunit/includes/UploadTest.php:120
phase3/tests/phpunit/includes/UploadTest.php:55
phase3/tests/phpunit/includes/UploadTest.php:35

$wgContLang not needed, TitlePermissionTest.php changes the language, inheriting from MediaWikiLangTestCase
2011-06-21 17:41:25 +00:00
Chad Horohoe
81ad5dc1c5 Remove another empty test, courtesy of r65504. 2011-06-19 18:46:03 +00:00
Sam Reed
8bfd19b451 Swap else if for elseif
Trimming trailing whitespace also

Doing in 3 commits (3/3), so hopefully reviewable in CR...
2011-06-17 16:05:35 +00:00
Sam Reed
df02234e07 Fix unit tests for r89515 2011-06-05 18:42:50 +00:00
Paul Copperman
8455ac65d3 Follow-up r87326: Add regression test. 2011-05-04 11:51:38 +00:00
Platonides
d770bda7bc Remove unused global 2011-05-03 22:15:57 +00:00
Sam Reed
8e80b8c3c1 Tidy up some unused variables and such 2011-04-23 21:40:52 +00:00
Mark A. Hershberger
d42259d38c random w/s cleanup 2011-04-23 19:28:35 +00:00
Paul Copperman
f7e6dfb4a3 Various fixes for PHPUnit tests:
* Block.php: Set mExpiry to the value we store in the database, so that Block::equals() returns true. Fixes BlockTest::testInitializerFunctionsReturnCorrectBlock.
* In Title::checkUserBlock(): Convert message parameters to plain strings to make strict comparisons work. Fixes TitlePermissionTest::testUserBlock().
* ApiBlock.php: Follow-Up r85166, add 'Confirm' parameter to data array. Fixes ApiBlockTest::testMakeNormalBlock().
* ApiQueryTest.php: Use $wgMetaNamespace instead of $wgSitename	to account for customizations.
* RandomImageGenerator.php: Use default value for constructor param to prevent fatals.
* ApiTestCaseUpload.php: 
** Fix undefined variable $fileName.
** Remove stray ini_set statements, they don't belong there. Especially ini_set( 'error_reporting', 1 ) will effectively disable all reporting, which makes errors hard to track.
* ArticleTablesTest.php: Put testbug14404() in group Broken, as the fix for the bug has been reverted in r83868.
2011-04-07 14:54:38 +00:00
Chad Horohoe
b661588c1f Followup r83140: FakeMemCachedClient -> EmptyBagOStuff in tests 2011-03-03 12:55:22 +00:00
Alexandre Emsenhuber
51c6afc751 * Replaced $wgMessageCache by MessageCache::singleton(); since we only use one instance of this class (as for ParserCache, LinkCache)
* MessageCache::singleton() calls wfGetMessageCacheStorage() directly instead of using $messageMemc, just in case this would be called before that variable is set
* Per TimStarling: also removed deprecated methods in MessageCache class: addMessages() and related, [get|set|enable|disable]Transform(), loadAllMessages(), loadMessageFile() and some others. Same for the legacyData stuff in LocalisationCache that was only used by MessageCache::addMessages() and related. 
* Converted remaining extensions
2011-01-26 15:42:04 +00:00
Platonides
7d7ea3db13 Remove the createaccount error check, failing since r79377.
The * group have createaccount right, so this seems an error.
2011-01-05 23:20:54 +00:00
X!
a41edc27b5 Solve 1 test by changing static variables to non-static 2010-12-31 22:08:13 +00:00
Chad Horohoe
447529064b * verbose and color default output from phpunit
* Make a bunch of tests subclass MediaWikiTestCase
* Parser tests and ResourceLoaderTest can't subclass it yet due to various issues
2010-12-28 18:17:16 +00:00
Chad Horohoe
23f69f10ed Per wikitech-l discussion: Move tests from maintenance/tests/ to tests/. They're not strictly maintenance scripts, and some people want to do a selective checkout that doesn't include the tests. There's still debate on whether we should include these in the release downloads, but we had a pretty firm consensus to move this. 2010-12-14 16:26:35 +00:00