improve namespace related methods
authorAntoine Musso <hashar@users.mediawiki.org>
Mon, 21 Feb 2011 22:17:06 +0000 (22:17 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Mon, 21 Feb 2011 22:17:06 +0000 (22:17 +0000)
commitf909c62d649cba43c9a9d7928db0129ccb3d0961
treedc03fc5aa4ab8bf5ed9f33d350dff18738a6fbec
parente12336c2696fe2f441803bca6f07bd34167ca6c1
improve namespace related methods

MWNamespace::getTalk() could give erroneus results when using it on specials
namespaces (NS_MEDIA, NS_SPECIAL). It now use MWNamespace::isMethodValidFor()
which will throw an exception if a special namespace was given.

MWNamespace::getSubject() is now returning identity for specials namespaces.

New MWNamespace::getAssociated() used to find out the subject page of a talk
page and vice versa. Special namespaces will results in an exception.

TESTS:

Added tests for almost complete code coverage. Functions relying on global
$wgCanonicalNamespaces are still incomplete though.
MWNamespace::isMovable() needs more assertions.

Tests results (ignoring incomplete tests output):

$ php phpunit.php --filter MWNamespace
PHPUnit 3.5.10 by Sebastian Bergmann.

.........IIIII..........

Time: 1 second, Memory: 31.75Mb

OK, but incomplete or skipped tests!
Tests: 24, Assertions: 99, Incomplete: 5.
includes/Namespace.php
tests/phpunit/includes/MWNamespaceTest.php [new file with mode: 0644]