Commit graph

45 commits

Author SHA1 Message Date
Adam Roses Wight
2521f8b5b9 (bug 56849) Deprecate dangerous edittime-based content update functions
Existing edit conflict logic relies on second-resolution timestamps,
which can fail in many exciting ways.  This patch provides new support
functions which take an explicit revision ID instead of a timestamp.

No functionality is changed.  Hopefully.

TODO:
* Make use of this code by replacing all edittime and starttime logic
with an explicit baseRevId.

Change-Id: I83cdd4adaaa67f81e933654228eccdc9fcdf9009
2014-05-24 05:23:39 +00:00
Siebrand Mazeland
4916e08d8e Pass phpcs-strict on some test files (4/x)
Change-Id: Ifdbb431a6018c514b15ae71cc0c21b653a5e466d
2014-04-24 18:51:42 +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
addshore
f86db05d8d Remove unused stuff from tests
Change-Id: Iddabfbc80378b02fa4a2c58f80d50241be8105d3
2014-03-07 21:16:32 +00:00
umherirrender
979b570e2d Give alreadyrolled error when rollback will be a null edit
When a rollback will not create a new version, the rollback should not
be success normally. Raise the alreadyrolled error to indicate this
situation.

This can happen, when the same user already rolled back his edit in the
meantime.

Change-Id: I953ae1ca79abb37bc44f3f8244a42a34111e6ab8
2014-02-17 20:24:13 +01: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
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
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
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
Siebrand Mazeland
419b02b6df Update formatting
3 of n.

Change-Id: I62ad009018c54da6cf081c334e44eb98a3c72695
2013-02-14 12:56:23 +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
daniel
d9cd65c902 Fix condition for the entries with a null model.
A null model means ‘guess from page name’.

Change-Id: I63e80761e46cc7707e9c862e2e50a950c1766aa4
2012-12-08 22:09:30 +01:00
Platonides
ab1c0eea37 The error message should refer to $wgContentHandlerUseDB
Change-Id: I81bc50e6949cecdc7f3d7e0b89f54464b4a146c7
2012-12-08 22:06:20 +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
Antoine Musso
d7cec7c36c raise timeout for WikiPage tests
The tests do lot of DB queries which are quiet slow when using a SQLite
backend. Marking the class as belonging to the 'medium' group should
raise the timeout to 10 seconds.

Change-Id: I7a779bf4e5f44e755055182e0feeb68c005a920c
2012-11-02 15:22:54 +01:00
daniel
b5b2b2f898 (Bug 41574) Supply Title object to Revision if possible.
The Revision object needs the Title to determine the default content model.
Providing the Title explicitely wherever possible avoids an extra database
lookup. Most importanlty, this fixes fatal errors that ocurr when the
database lookup fails due to slave lag or transaction state.

Change-Id: I516e82f7a893b274c513b128b8a46db491160b55
2012-11-01 13:48:18 +01:00
umherirrender
dcb6ad0097 Use ParserOptions::newFromUserAndLang in tests
This avoids using $wgUser and $wgLang for the ParserOption, which is not
needed in the tests

Change-Id: Iea07e9a0f0898ec5f8eb98a40000f5d33b279c9e
2012-10-24 15:59:30 +02:00
daniel
3d6e9faab5 (bBug 41127) Handle non-existent content in WikiPage
Change-Id: I8b80a6b7b49b0b8b43eb7d4913860d8ca899015e
2012-10-18 15:13:01 +01:00
daniel
8c9a4d8bbb [Bug 41030] fix fatal error when rendering non-existing pages
Change-Id: I68dc34aa7d4c27ea7d0fb9488324d0f899564960
2012-10-15 14:36:03 +02:00
daniel
329d5b3516 Merge branch 'Wikidata' into master.
This introduces the ContentHandler facility into MediaWiki,
see docs/contenthandler.txt.

For convenient review, a squashed version is available at
https://gerrit.wikimedia.org/r/27191

The ContentHandler facility is a major building block of the Wikidata project.
It has been discussed repeatedly on wikitech-l.

Change-Id: I3804e2d5f6f59e6a39db80744bdf61bfe8c14f98
2012-10-09 11:34:24 +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
daniel
bb51a58e57 Cleanup of Wikidata branch.
This cleans up several issues raised in comments to I3b2dad3a,
mostly style and merge artifacts.

Change-Id: I99f5e300a671db1353db151cd187ffd2e4478d03
2012-10-08 17:34:47 +02:00
daniel
63f42295c3 Don't assume main namespace contains wikitext
Change-Id: Ie5bb593f850ab97b2e63f064e3fc52bc17edfdd1
2012-09-20 16:18:30 +02:00
daniel
96f7db3f7b Avoid deprecation warnings in test cases.
a) when testing deprecated functions, use $this->hideDeprecated() to
suppress warnings.

b) use doEditContent() instead of doEdit()

Change-Id: Ifa9e0ef373ed72ef7d4a3c2dd558483af4a3fd55
2012-08-28 16:00:39 +02:00
daniel
0139923580 fixing long lines
Change-Id: Iebcd40a1a37a3a93cc571fa2c2b0a87f53dc97a4
2012-08-20 21:33:07 +02:00
daniel
cd987b8db6 fix some tests to work with =false
Change-Id: I520565ac119ea87d7ecca0af93c5fe77a32896ec
2012-07-24 17:58:02 +02:00
daniel
d87135d706 merged master
Change-Id: Iad12ee382d6aeb1fab6fefb611d290b74865ea4b
2012-07-23 22:07:18 +02:00
Antoine Musso
12e608e3d5 converts '@fixme' to '@todo FIXME'
@fixme is simply not recognized by doxygen whereas @todo is used to
generate a nice ... todo list!!

Change-Id: If956c0a164373126ce48b791d45c56962034eecd
2012-07-10 17:16:46 +02:00
daniel
b0fd13578e merged master
Change-Id: I0028e0ae01c7d025e60691cb4ad9d04869b9778c
2012-06-25 13:39:29 +02:00
Platonides
a05c1a1ab7 WikiPage::preSaveTransform() was deprecated in r103228 (018d885f)
Hide the warning on the tests and add tests for the Parser method.

Change-Id: I939bf59206da1dd45e33db2251e92d9792a0a767
2012-06-23 20:28:51 +02:00
daniel
250da851d1 merged master 2012-05-29 17:01:13 +02:00
Platonides
9180ab0b7c Make it work in wikis not configured in English.
(hardcodes message values)
 php phpunit.php includes/WikiPageTest.php

Change-Id: I4b93d983f467fd281695be5ac778d30db0b09c17
2012-05-23 23:09:15 +02:00
daniel
684178dfb6 Use Title, not IContextSource; remove createArticle, etc.
This merges the latest core patch into the Wikidata branch,
implementing suggestions collected on gerrit. Most importantly:

* Methods in the Content class no longer rely on a IContextSource
* createArticle and createEditPage were removed from Contenthandler
2012-05-23 08:53:01 +02:00
daniel
fa132be893 fix for Ibe3e88fa: restoring doDeleteUpdates().
When generalizing LinksUpdate to DataUpdate and introducing
WikiPage::getDeletionUpdates(), WikiPage::doDeleteUpdates()
was removed, even though it was still used by Title::moveToInternal().

This patch restores WikiPage::doDeleteUpdates(), using the
new logic based on WikiPage::getDeletionUpdates() to implement it.

Change-Id: I12a49d5ca3ccb6bb9cbb63dde436bcf2a7d8a985
2012-05-18 18:58:21 +02:00
daniel
01f36b721f merged latest master 2012-05-14 23:24:18 +02:00
daniel
cbc2014b2d Use integers for content_model and content_format.
Representing content_model and content_format as integers in the
database was suggested by Asher mainly to save space.

This change entails some refactoring and renaming, but no big
change in logic.
2012-05-14 10:22:52 +02:00
daniel
479711159c Adding test case for basic WikiPage functionality, including database interaction.
New tests are added to avoid regressions when the ContentHandler facility
is introduced.

Changeset 3: use tablesUsed to allow database cleanup after test, as per
             Aaron's suggestion.

Changeset 4: use array_merge instead of +=.

Changeset 5: trying dumber rollback test to see of jenkins likes it better.

Change-Id: I0a9f8dfd30031baa4b12cc128a39059868149884
2012-05-07 14:57:30 -07:00
daniel
060b6c74c6 implement feature switch for ContentHandler database integration, to allow for easy deployment 2012-05-02 15:41:47 +02:00
daniel
1665bc101a adding sanity checks to find out why testDoRollback is failing on jenkins 2012-04-30 17:52:46 +02:00
daniel
4538a5f4bc using SecondaryDataUpdate to clean up after deletion 2012-04-30 15:32:31 +02:00
daniel
fc91010111 backporting changes made during review of core patch 2012-04-30 12:50:31 +02:00
daniel
6a07b790ba explicitly define user objects for testing 2012-04-26 12:10:38 +02:00
daniel
853daf150e introducing WikiPageTest 2012-04-24 18:00:21 +02:00