Commit graph

79 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
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
Aaron Schulz
91fb54d0f9 Reverted r84386; breakage too severe 2011-03-20 21:30:24 +00:00
Antoine Musso
5da14533aa Makes wikilinks nicer when possible
This patch mostly impact Title:getLocalUrl() with two changes:

1) Abstraction:

$wgActionPath related code is now in Title::resolveActionPath(). It now
interprets query parameters using an array which is easier to read than
playing with a regexp and the evil $matches[].


2) Tweaking:

Change the 7 years old (r2621) URL forge:
  "{$wgScript}?title={$dbkey}&{$query}"
  => /w/index.php?title=FOO&q=2

To a nicer
  "str_replace( '$1', $dbkey, $wgArticlePath )"
  => /wiki/FOO?q=2


Additional changes:

* Parser tests were modified to reflect the changes.
* PHPUnit TitleTest amended to test getLocalUrl() (add more!!)
* When using wgActionPaths, makes sure the 'view' action is a sane default
2011-03-20 14:57:49 +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