Commit graph

54 commits

Author SHA1 Message Date
umherirrender
6b2729ced9 Set wgMetaNamespace on TitleTest.php
Also added it to the MediaWikiTitleCodecTest.php (which seems not exists
at time of bug creation)

Bug: T67879
Change-Id: I8411d46320201b594ebaa56953dc355d863d0500
2014-11-26 18:05:30 +01:00
umherirrender
0731f52e9e Use setMwGlobals in TitleTest::testGetPageViewLanguage
Change-Id: I42cb31bf7c1fa1b77f2e8465e7e1e316972fec09
2014-10-16 19:44:39 +02:00
Kunal Mehta
b3dd0fb560 Improve test coverage of Title::isValidMoveOperation
Change-Id: Ifd81b0a894714ca94ab3e627ba83c881d96c3377
2014-09-19 19:23:19 +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
545f1d3a73 TitleTest: Break secure and split test into two tests with providers
Change-Id: Ib33819c3e8828c154951ab76db2a283e3a549ea0
2014-09-05 10:52:51 -07:00
Chad Horohoe
6c50c0cb9e TitleTest: fix minor todo about test naming
Change-Id: I1aa29b859cb1dcf0ff3c30c23f5d4c6b412f72f9
2014-08-28 11:38:18 -07:00
Antoine Musso
e5eb717d25 tests: avoid sql queries in TitleTest
testIsAlwaysKnown was invoked on an interwiki link. To have the test
pass, we used addDBData() to inject the interwiki in the database.  This
end up being execute on each test when it is only needed for a single
assertion.

Instead of creating a Title, use Title::makeTitle() to populate the
interwiki, thus letting us avoid the database hits.

Random timing: 1.20s -> 150ms.

Change-Id: I63a4e7b9af5eacb7dc1de4b33b8e631e6c3f1fa6
2014-08-22 23:16:01 +00:00
umherirrender
7ff005407e Remove colon after @deprecated/@param/@todo/@note
Change-Id: I4e66dad85eecf7e8e03ac760af900395e1bc11b6
2014-07-24 11:30:25 +02:00
Max Semenik
062cfffeb2 Integrate Special:MyLanguage from the Translate extension
In practice, this means the MediaWiki canonical way to uniquely and
humanly name translation pages on a multilingual wiki becomes
$source_page_title + '/' + $target_language_code, irrespective of
the enabling of the navigational subtitle and of the relative
titles (..) syntax for linking and transcluding, which are unrelated
and keep being controlled by $wgNamespacesWithSubpages.

This syntax has been prevalent on most wikis including mediawiki.org
since at least 2009, also thanks to #titleparts in ParserFunctions.

The part of the special page's functionality that made links to it red
when destination page wasn't present will be integrated with a follow-up
commit because they require more performance work.

I'm also including some Title tests that were written for testing the
redlinking functionality but are useful in general.

Bug: 66762
Change-Id: I520077c931431b5919e0208f75c20b5b25f3159d
2014-07-22 11:33:15 -07:00
jenkins-bot
01da3da43d Merge "Allow local interwiki links with an empty title part" 2014-07-03 17:46:48 +00:00
Timo Tijhof
c8c4056551 Title: Add unit test to assert ":A" is a valid title value
Mostly to catch regressions. While this is an invalid title,
it is valid as syntax when creating a Title *object*, the actual
page title itself does not allow leading colons.

Change-Id: Idbe8a3bfe487926c5fc8bdcfa69a957fc9d0bc49
2014-04-28 19:50:32 +02:00
Siebrand Mazeland
4916e08d8e Pass phpcs-strict on some test files (4/x)
Change-Id: Ifdbb431a6018c514b15ae71cc0c21b653a5e466d
2014-04-24 18:51:42 +02:00
This, that and the other
c815f959d6 Allow local interwiki links with an empty title part
For example, [[en:]] on enwiki. These links were for some reason considered
invalid. However, to support use-cases such as cross-wiki transclusion and
the importing of templates across wikis, this type of link should be
allowed.

I can't see that this would break anything. If anything, it will "un-break"
some links.

Should MediaWikiTitleCodec depend on Title::newMainPage? Almost certainly
not, but I note that splitTitleString is earmarked for demolition, so I
expect that the confusing dependency-web will be cleaned up in the future.
I also note that MediaWikiTitleCode already uses various static methods of
the Title class.

Bug: 64167
Change-Id: I27495aa62e6059c7725387135ae0358d7e6fb35b
2014-04-21 13:20:24 +10:00
jenkins-bot
79ebb4b028 Merge "Allow additional interwiki prefixes on local interwiki links" 2014-04-20 14:00:22 +00: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
Aude
1b0e883698 Revert "Temporarily remove tests added in I8eef5a165"
this was to be temporary, right? we need the tests in.

If there are issues with jenkins, this is not the *best*
way to fix them.

This reverts commit 44a1968531.

Change-Id: I5dd60a9818c28155d96a6642c588781667e682c3
2014-04-06 13:18:07 +00:00
This, that and the other
5461fd3f28 Allow additional interwiki prefixes on local interwiki links
This code was added by Brion back in 2004 as part of r6398.

According to Brion, links like [[en:wikt:foo]] on English Wikipedia are
"just crazy!", but I can't see any reason to disallow them.

Bug: 61357
Change-Id: If449e60a0ef95cfe3dd6f4b1809ac012be62a0ea
2014-04-05 13:34:34 +11:00
Ori Livneh
44a1968531 Temporarily remove tests added in I8eef5a165
Although the tests themselves pass, their introduction to the codebase pushed
the total number of tests past some threshold at which Jenkins starts
segfaulting. So remove the tests as a temporary workaround, and revert this
patch once the bug with Wikimedia's Jenkins deployment (bug 43972) is resolved.

Change-Id: I5722faf0e4216e1c1f98ecc1f2dba744b240b7d3
2014-03-28 13:36:26 -07:00
daniel
154bcdc63f Introducing TitleValue
TitleValue is intended to be a light weight alternative to the Title
class. Any operations on TitleValue are implemented in separate
service classes, like TitleFormatter and PageLinkRenderer. See
<https://www.mediawiki.org/wiki/Requests_for_comment/TitleValue>
for more information.

This change updates SpecialCategories and SpecialLinkSearch to use
TitleValue instead of Title, to demonstrate how TitleValue would be
used, and how the necessary services can be injected and applied.

The intention is to improve testability and reusability; these
advantages will however only become apparent with further refactoring
of the respective special pages. This will be done in follow-up
changes.

More work will be needed to migrate essential functionality from
Title and Linker classes into the respective service classes,
MediaWikiTitleCodec and MediaWikiPageLinkRenderer.

Change-Id: I8eef5a165de4ffcacfbc4911fdacdb15d502fff4
2014-03-28 18:42:17 +00:00
jenkins-bot
97a4ad455f Merge "Cleanup a bunch of tests and add todos" 2014-03-17 09:34:02 +00:00
This, that and the other
6cbdf65b4f Add $wgLocalInterwikis to handle multiple local prefixes
This is akin to $wgSkipSkin/$wgSkipSkins. It is quite plausible for a wiki
to have more than one self prefix (e.g. enwiki has w: en: wikipedia: and
maybe others).

Some recent changes code seems to use $wgLocalInterwiki for quite unclear
purposes:
- I removed the line using $wgLocalInterwiki from the RecentChange
  class, as the 'lang' field of $mExtra is not used anywhere in core code.
  Extensions may use it, but it would seem more appropriate for them to
  use something like $wgDBname (or indeed to consult $wgLocalInterwikis
  directly) if they need to identify a particular wiki.
- In the IRC formatter, the first prefix in the array is used (if set).
  Appropriate documentation is added to DefaultSettings.php.

Related to bug 954 comment 3.

Bug: 954
Bug: 955
Change-Id: I9dbb566385b464402c5e78510b95dd2ffb4d9489
2014-03-12 13:32:07 +01:00
addshore
9e85aabe52 Cleanup a bunch of tests and add todos
Change-Id: Iae44427edee3ed2a62abdb5a8f5d9f1ed2e7d660
2014-03-09 15:12:45 +01:00
umherirrender
b176b5b8ac Add title tests about interwiki prefix
Also test $wgLocalInterwiki.
The js part does not respect interwikis,
so there is no need to add tests for that.

Change-Id: I407355295b65bc67eb171da435c1505797569d3e
2014-02-04 14:53:54 +00:00
umherirrender
60b764796a Remove hints to fixed bug 54044
Change-Id: I119a2ec4114fd7939ef2d74e614b4a8ff8e257ac
2013-12-27 12:57:26 +01:00
umherirrender
c42684cca9 Make a single colon an invalid title in php and js
When secureAndSplit gets a single colon as input, the leading colon
is stripped and produces a title with a empty string. This change makes
that impossible by moving the empty string check to after the substring
removal of the colon.

Bug: 54044
Change-Id: I574168c9ed281c535901c36dea7c179a4e794d20
2013-12-06 17:44:43 +00: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
4894793ab6 mw.Title: Rewrite from scratch (porting logic from Title.php)
Changes:

* Add support for fragments.

* Use wgLegalTitleChars instead of the old clean() method
  that stripped out characters instead of throwing an exception.

* Implemented various other parts of Title.php to make it more
  strict like Title.php. It is still slightly looser, but it
  now takes care of the following that Title.php did already:
  - Directory patterns ("../" etc.)
  - Extra initial colons
  - Titles in NS_TALK that don't round-trip to NS_MAIN
  - 3 or more consecutive tildes
  - Limited title size (255 bytes)

* Extracted parsing logic into a private static #parse method
  and introduced mw.Title.newFromText (a constructor that returns
  null|Title instead of throwing an exception).

* Extended test suite to cover the added features and fixed bugs.

* Since the PHP test suite was lacking these, added them there
  as well.

Bug fixes:

* Fragments are now excluded from the title instead of causing
  the input to be invalid or malformed (e.g. "Foo#bar" was being
  normalised to "Foo_bar").

* ".com" now parses and round-trips properly. The extension and
  rest of title are still separated, but only at the very end
  after all other processing, so though title cannot be empty,
  since we only do a lazy split afterwards, it will split into
  title="", ext="com" internally and join back together when
  needed (bug 38081).

* "Example.js " (trailing space after extension) was previously
  incorrectly parsed as title=Example.js,ext=null.

* "Foo    bar" (multiple consecutive spaces) was transformed
  into 1 space correctly, but "Foo___bar" was not. This has been
  fixed to match the PHP implementation (it merges underscores
  and whitespace of any kind).

Clean up:

* Removed various redundant private helper methods.

* Removed fixNsId as getNsIdByName uses wgNamespaceIds which
  always yields a valid value. The fixNsId was verifying
  something that was already valid.

* Yoda conditional in Title.php, got rid of.

* Use newFromText in jquery.byteLimit.test. It was previously
  using a very basic invalid test (=== '') and no try-catch.
  Since we're getting more strict, typing 'User:' results in
  an invalid title, which should result in the same behaviour
  as it previously did for the lazy === '' check.

Bug: 38081
Change-Id: Ief1c11dabadc2f822065c40be91e04d655933e4f
2013-10-01 23:38:53 +02:00
Timo Tijhof
dc9c9ee7fc Title: Add byte class to unicode class conversion for js
The upcoming rewrite of mw.Title needs to use wgLegalTitleChars,
but for that to work, it needs to be converted into something
that can work in javascript.

Signed-off-by: Timo Tijhof <krinklemail@gmail.com>
Signed-off-by: David Chan <david@sheetmusic.org.uk>
Change-Id: I163f3d7e3a680d52640a93f4bd195d8209669918
2013-09-27 19:21:14 +02:00
Siebrand Mazeland
791d0b2a98 Update code formatting
Change-Id: I16a9b42651f1cfb1a70dffbb67b7b83dfeb90d03
2013-04-26 14:21:20 +00:00
Alexandre Emsenhuber
15833dafdf Fix case of some Title methods
Change-Id: I1a37ffb0e8cde4deac027721b0e463585b58d634
2013-03-26 10:54:15 +01:00
Timo Tijhof
b36d883017 Tests: Make phpunit providers "public static".
Follows-up I9d2b148e57 (including phpunit/languages this time).

Bug: 46434
Change-Id: I30e5efcd88c516121c454676bd7a18f9b7c8fca6
2013-03-22 03:12:37 +01:00
Antoine Musso
0e7092026b typo in @cover statement
PHP Code Coverage uses the @cover comment statement to limit code
coverage to some specific function.  The method reference lacked the
trailing 's' leading to an error when running coverage:

PHP_CodeCoverage_Exception: Trying to @cover not existing method
"Title::checkReadPermission".

Change-Id: Ie09e804039271ec8f0165c32dc7849ea4be8a3b9
2013-03-14 04:56:42 +01:00
Siebrand Mazeland
7a24666935 Update formatting
2 of n.

Change-Id: I5406673e99ed53e4e330ed47f022a17177544daa
2013-02-14 12:36:35 +01:00
nullspoon
550b878e63 Whitelisting publicly readable title with regex
This patch make it possible to whitelist pages which anonymous users may
see. It is similar to $wgWhitelistRead expect it uses regular
expressions, the list of regex are to be added in the new global array
$wgWhitelistReadRegexp.

This would be useful in a semi-public team wiki situation where the
admin would want to hide an entire namespace from everyone except those
in a particular group due to sensitive team specific information.

Added new unit test testUserCan in includes/TitleTest.php to
test this new functionality.

* adds $wgWhitelistReadRegexp to DefaultSettings.php
* updates RELEASE-NOTES-1.21 new features
* updates CREDITS

Signed-off-by: Antoine Musso <hashar@free.fr>

Change-Id: I83f6a614874c3d289ff4bd8d015f1d9c92e500b6
2013-01-28 14:38:37 +01:00
daniel
c4e3c379c1 Fix test for view language for non-wikitext in main NS.
This test assumed wikitext in the main namespace. That is not always
the case. Now it expects wikitext in the Help namespace. Also not
guaranteed, that should pretty likely be currect.

Change-Id: Icf437b4396812131c501c4594ece2eff7604b6ba
2012-10-15 14:50:21 +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
c546fae8ed merge latest master into Wikidata branch
Change-Id: Id4e0f40c03679c13d8934a6add99b5cd86d0437d
2012-10-08 13:58:54 +02:00
Daniel Friesen
55a52d5915 more public accessors for Title class
This patch adds new public accessor to the Title class. They are merely
returning the already existing conventions.

Added tests for the four new methods:
 - Title::getBaseText()
 - Title::getRootText()
 - Title::getRootTitle()
 - Title::getSubpageText()

The later does not test with $wgNamespacesWithSubpages variants.

Change-Id: I4f7230c1a5487b82d06c78a45c50436085df57be
2012-10-01 20:52:03 +02:00
daniel
2f7200c04b adding @group Database to more tests
Change-Id: If1b63f8be80fdc18ccc3dc526f82f7684c5cf50b
2012-09-05 18:54:15 +02:00
daniel
b6fe213226 merge latest master.
some tests fail due to logical changes, will fix that in a follow-up

Change-Id: I8a5e4087ecf674fbcf6327c5d168cd401be12400
2012-09-05 17:50:13 +02:00
Liangent
c0fe9b4743 Followup da433140: add one more test and release note
Change-Id: I03f3fa9cb58b6e98a88a2828f19bae849acf5455
2012-09-04 23:14:20 +08:00
Liangent
da43314022 'lang' attrib in #mw-content-text should be set to variant code.
Change-Id: I15cd8c102991c5007b43e06939a0c1a7593d0933
2012-09-04 17:00:27 +02:00
Antoine Musso
fc6bc233be Fix doxygen docs before REL1_19 branching 2012-02-01 20:53:38 +00:00
Platonides
01a758111a Title::isValidMoveOperation needs a db 2011-10-02 21:07:17 +00:00
Bryan Tong Minh
ae6ee23e33 (bug 31213) Exception thrown when trying to move file cross-namespace.
* Don't try to construct a File object when the namespace is wrong
* Start on some tests
2011-09-29 18:35:34 +00:00
Brion Vibber
94e140fc68 * (bug 31100) Fix regression in sidebar (special: page links lost parameters)
Regression in Title::fixSpecialName() in r86255; fixed and added a unit test case to TitleTest.
2011-09-22 21:35:24 +00:00
Brion Vibber
c099e759ca Follow-up to r88667; finish reverting bogus test cases from r87964. It looks like these cases need to be re-added, but correctly; for instance getLocalUrl() **DOES NOT** return something in $wgArticlePath space when an action is given that's not view. It **MUST** return the matching $wgActionPath or else use $wgScript directly, to ensure that URL structuring rules & security rules are followed. 2011-05-23 20:24:09 +00:00
Siebrand Mazeland
75c6696aa8 Use consistent notation for "@todo FIXME". Should update http://svn.wikimedia.org/doc/todo.html nicely. 2011-05-17 22:03:20 +00:00
Antoine Musso
efd83c55fc merge in prettyURL patch
This is basicly a merge of r84386 & r84491, see their commit messages for
more details.

r84386 makes wikilinks nicer by updating the URL forge implemented by r2621
r84491 fix an issue with the (un)?watch links. getParamValue should not be
used to guess 'title' or 'action'
2011-05-13 11:41:17 +00:00