Commit graph

36 commits

Author SHA1 Message Date
jenkins-bot
6d3641b7a7 Merge "Improve namespace handling in tests" 2017-09-29 05:33:26 +00:00
Brad Jorsch
2d9f29a846 Improve namespace handling in tests
MWNamespace has three internal caches, only one of which can be cleared
(and that somewhat oddly by passing a boolean to
MWNamespace::getCanonicalNamespaces()).

This change introduces a MWNamespace::clearCaches() method to clear all
three caches. It also adds some resetting in tests that seemed to be
missing it.

Change-Id: I1dcfcd8713888b3ff8fc75e95329ba72bd95d0c9
2017-09-29 05:21:47 +00:00
Max Semenik
19b739bd19 EditPage: Don't allow clients that mangle unicode to edit
Get rid of the hack that turns unicode into hexadecimal codes for
browsers that don't support unicode, and prevent their edits entirely.

And instead of relying on $wgBrowserBlacklist, use a hidden HTML form
field - if the contents are mangled and don't match the original, then
reject the edit.

Bug: T67297
Change-Id: I20c2e396d7dfd6a3b23b94b218f94a847522576b
2017-09-20 19:57:51 -07:00
James D. Forrester
1e9c361960 tests: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: I46261416f7603558dceb76ebe695a5cac274e417
2017-02-21 02:14:34 +00:00
Aaron Schulz
dc0cdc8a4d Make DeferredUpdates able to run DataUpdates
* Also make ErrorPageError exceptions display themselves
  in PRESEND mode. Before they were always suppressed.
* Make DataUpdate::runUpdates() simply wrap
  DeferredUpdates::execute().
* Remove unused installDBListener() method, which was
  basically moved to Maintenance.
* Enable DBO_TRX for DeferredUpdates::execute() in CLI mode
* Also perform sub-DeferrableUpdate jobs right after their
  parent for better transaction locality.
* Made rollbackMasterChangesAndLog() clear all master
  transactions/rounds, even if there are no changes yet.
  This keeps the state cleaner for continuing.
* For sanity, avoid calling acquirePageLock() in link updates
  unless the transaction ticket is set. These locks are
  already redundant and weaker in range than the locks the
  Job classes that run them get. This helps guard against
  DBTransactionError.
* Renamed $type to $stage to be more clear about the order.

Change-Id: I1e90b56cc80041d70fb9158ac4f027285ad0f2c9
2016-09-02 04:12:50 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aaron Schulz
f4a4457403 Convert page modification to using startAtomic()/endAtomic()
A few semantic changes result from this:
* If multiple pages are edited in a request, the updates happen
  in the same order relative to each other, but all in one second
  step instead of after each page edit.
* If the same page is edited twice in a request, the WikiPage hook
  argument will reflect the last request edit, not always the edit
  that fired the hook.

Bug: T120718
Change-Id: I9429f29e5a90f24e4d7af5797a80e63a9cc34146
2016-02-09 00:03:05 +00:00
jenkins-bot
5d97e89556 Merge "Give TestCase::checkHasDiff3 a better name" 2016-01-31 11:39:46 +00:00
addshore
96e1167d92 Give TestCase::checkHasDiff3 a better name
This method actually marks the test it is called
from as skipped if Diff3 is not confugured.

The new name "markTestSkippedIfNoDiff3" better
reflects that.

Change-Id: I1dffeba0aceb312b3a82216f0b55227e24bc2e34
2016-01-28 12:46:11 +01:00
Aaron Schulz
36a87a8902 Convert page creation to using startAtomic()/endAtomic()
A few semantic changes result from this:

* If multiple pages are created in a request, the updates happen
  in the same order relative to each other, but all in one second
  step instead of after each page edit.
* If an extension set some extra Status info or errors via the
  PageContentInsertComplete hook, they will not be seen by the
  caller (unless it was a CLI script possibly). Few callers use
  $status at all, and I did not see any that mutated it. Since
  the page is already committed when this hooks run (as has always
  been) they cannot veto edits and callers do not care or know what
  to do with random hook-set status errors; there was never much use
  in changing the Status anyway.

Bug: T120718
Change-Id: Ieba35056be31b2f648c57f59d19d3cbbe58f1b05
2016-01-27 11:38:05 -08:00
addshore
11516d3292 assertEquals does not return anything
Also this method is not documented as returning
anything

Change-Id: Ibcfda0bec5f84b308866a662400ed5e97dd1ac06
2016-01-27 16:37:46 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
aude
2513086ec1 Add supportsDirectEditing methods to ContentHandler
This adds supportsDirectApiEditing and
supportsDirectEditing methods to ContentHandler. Both
return false by default for the ContentHandler base
class, and true for TextContentHandler and it's
derivatives. (everything in core)

Extension content types that directly extend
AbstractContent / ContentHandler, often / generally don't
support direct editing. EntityContent in Wikibase
and Flow boards are the two such content types currently
in gerrit-hosted extensions.

The use and direct settings of the allowNonTextContent
member variable is replaced by enableApiEditOverride and
a setter for that. The only place allowNonTextContent is
used in all of Wikimedia-hosted git repos is core itself
(EditPage and ApiEditPage), so should be safe to make
this change.

With this change, Wikibase can remove its ApiCheckCanExecute
hook handler that disallows editing there, and MobileFrontend
could check if direct editing is allowed before enabling it's
editing features, instead of Wikibase having to add
MobileFrontend hook handlers to disable the features.

Bug: T96382
Change-Id: I276cd6ecedf38108f1f2be16b38e699e8c5d2d0c
2015-04-17 15:55:20 +00:00
Adam Roses Wight
52d78033ea phpcs fixups for line length
Change-Id: Ic36b111dcae0880fb34fb336065098650a30db5f
2015-03-14 11:05:41 +00:00
Timo Tijhof
96771e3a65 test: Clean up data providers that should be static
Follows-up b36d883.

By far most data providers are static (and PHPUnit expects them
to be static and calls them that way).

Most of these classes already had their data providers static
but additional commits sloppily introduced non-static ones.

* ResourceLoaderWikiModuleTest, 8968d8787f.
* TitleTest, 545f1d3a73.
  Odd unused method 'dataTestIsValidMoveOperation' was introduced
  in 550b878e63.
* GlobalVarConfigTest, a3e18c3670.

Change-Id: I5da99f7cd3da68c550ae507ffe1f725d31e7666f
2014-09-18 12:52:44 -07:00
Chad Horohoe
f52842b536 EditPageTest: Rewrite testCreatePage() to use a data provider
Change-Id: I415f9fdbca6a625d8d1e9ff4c05c861a96dfa290
2014-09-04 22:30:22 +00:00
umherirrender
b0cfcd0fcb Add missing @return and @param to doc blocks
Change-Id: I9d99ba1968ed8f97624d957754c8847dfe1b41da
2014-08-27 21:57:45 +02:00
Étienne Beaulé
c3fcaba02f Enable the creation of empty pages
This change enables the direct creation of empty pages without needing
to use a work-around (such as "{{subst:ns:0}}"). A warning is added as
the message "blankarticle" to request confirmation that the empty page
was meant to be blank. A automatic edit summary has been added when
creating a blank page. The message is: "autosumm-newblank."

The API has been updated to permit the creation of empty pages, when
"text" is null, but not non-existant.

Unit tests have also been added to test these features.

Bug: 57238
Bug: 65206
Change-Id: I3457c36a909d1dbfaeed04a1f0568c69e0ef3386
2014-07-25 23:26:18 -04:00
withoutaname
da5090774f Remove two unused constants from EditPage.php
Specifically constants AS_USER_CANNOT_EDIT and AS_OK

Change-Id: I96b20962b7d4cab5c026a0f03abf9da066fbd9af
2014-07-21 17:50:47 -07:00
Max Semenik
bfa5d12e11 Editing unit tests: set title in context
It is assumed that users of EditFilterMergedContent hook need to get
the page being edited from context as it happens during normal functioning,
tests shouldn't violate this convention.

Bug: 66930
Change-Id: I8d453d819aad8630d4934a15e7bf512fa828fe24
2014-07-17 23:59:00 +00:00
Siebrand Mazeland
1fb1fa4601 Pass phpcs-strict on some test files (1/x)
Change-Id: I7f8dee09ac734cbc369441431841f2d4aa5d7f51
2014-04-24 17:05:32 +02:00
umherirrender
092cd8ee31 Fixed some @params documentation (tests)
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.
Also added some missing @param.

Change-Id: Ic8aaf0a93796b97d0fa4617c1f86ff59f4b36131
2014-04-17 20:43:42 +02:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
addshore
9c540db2df @covers tags for inclues/*Test
Change-Id: Id28acdd8fe0028bf1e46344cfed131076c8f4c95
2013-10-24 11:54:02 +01:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
umherirrender
31b13bba11 Fix EditPageTest for non-english test wikis
Follow-up: I070036f341b866cda67eb928c5b74ad2ce6c527c
Change-Id: Id87832ef84cb091c44f5c78adf370e2fca8ca6d7
2013-07-26 23:53:06 +02:00
MatmaRex
83cbdc6f36 Allow creation of empty MediaWiki: pages
This is useful now since it's possible to disable messages by blanking
them (see bug 14176).

Instead disallow creation of page contents equivalent to the default
message to serve the same purpose as disallowing blanking did (prevent
edits which wouldn't change anything anyway; the edit form is even
prefilled with the default contents).

Bug: 50124
Change-Id: I070036f341b866cda67eb928c5b74ad2ce6c527c
2013-07-02 18:40:02 +02:00
jenkins-bot
e439cfb1b1 Merge "Fix more UnitTests for databases that do not use integer timestamps" 2013-03-08 22:54:28 +00:00
Brent Garber
ba4b7bc35b Fix more UnitTests for databases that do not use integer timestamps
Change-Id: I6f8b19aa6e6a9efc3320bb18fa8c7ec8b72a0c17
2013-03-08 19:51:52 +00:00
Siebrand Mazeland
ac63001d8e Update formatting
1 of n.

Change-Id: I852729f08bbb0c5e39c2db44362ccdc7f59dcc08
2013-02-14 12:22:13 +01:00
umherirrender
9b3292e31a Add MediaWikiTestCase::checkHasDiff3 and use it
Some tests can only passed, when diff3 is enabled on the wiki, when not
the tests should marked as skipped. To avoid code duplicates inside
the test folder for the check, if diff3 is enabled, the new function
MediaWikiTestCase::checkHasDiff3 can be used.

Change-Id: Ie765da49a4a1358da78a3506e38772d61bcd010c
2012-11-22 17:45:50 +01:00
daniel
3dcf8c5284 (Bug 41352) Provide tests for edit conflicts.
This provides several test cases for EditPage, including some for
detecting and resolving edit conflicts. This is in preparation for
finding and eliminating the root cause of bug 41352.

Change-Id: I8f23c6535f7b3ee6462d9c5a19dd06070e77f9d1
2012-11-10 17:24:48 +01: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
Max Semenik
e7001ff574 Follow-up r113922: tests 2012-03-15 15:38:11 +00:00
Brion Vibber
0f78700c55 For bug 32617: lift some code out to a function - EditPage::extractSectionTitle - so it can be tested and fixed.
Added test cases, including one that fails thus demonstrating bug 32617.
2011-12-06 23:35:42 +00:00