Commit graph

74 commits

Author SHA1 Message Date
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
Nikerabbit
d6b9b27492 Merge "Use the MWDebug class to display debug log back in the request." 2012-08-28 05:49:41 +00:00
Tim Starling
ad03f2f753 Revert Uri class due to bug 39710
Revert 94f623363b. Apparently all
ReverseChronologicalPager subclasses were broken by the unexplained
interface change in wfArrayToCgi(): changing the interpretation of
null array values from "omit this key" to "include this key with no
value". The function has always been called with the former
interpretation, that's why the special case was in there.

Also reverted dependent changes 4b517fa and part of 3d97704.

Change-Id: I41dadbde5d0e0e4c54cc76bfc13c263c15c73828
2012-08-28 10:53:09 +10:00
Alexandre Emsenhuber
61dd1d037b Use the MWDebug class to display debug log back in the request.
- This removes the duplication of MWDebug::$debug and
  OutputPage::$mDebugtext, so there's no need to store two times
  the same text
- Removed OutputPage::debug() since it's no longer used
- Had to keep OutputPage::$mDebugtext because it's still
  referenced by SemanticPageMaker extension
- Moved Skin::formatDebugHTML() to MWDebug::GetHTMLDebugLog()
  and replaced the call in Skin::generateDebugHTML() to use it
- Also check $logonly before sending entries to the debug
  toolbar in wfDebug(), for consistency
- Changed MWDebug::getDebugHTML() to also return the debug log
  in an HTML comment if $wgDebugComments is set to true and
  changed the location of this call to BaseTemplate::printTrail()
  so that its result is the latest possible. This also includes
  the debug toolbar.
- Removed MockOutputPage and related test cases since they are
  no longer accurate

Change-Id: Ie0f389f8566457b1c938c627ed930040741ac9d9
2012-08-27 23:47:19 +02:00
Daniel Friesen
94f623363b Add a Uri class.
Add a Uri class matching our mw.Uri JS class for handling uris.
This class should be helpful in a bunch of places where we end up doing manual
concatenation of things like the path + '?' + query of a url parsed with wfParseUrl.

[tylerromeo@gmail.com: Removed cat() function, fixed wfWarn() usage for aliases
 and added visibility to all functions. Also added test for aliases.]
Signed-off-by: Tyler Romeo <tylerromeo@gmail.com>

Change-Id: Iefdedb7c80cf1d4aab58050edab3ab44ba868a58
2012-08-06 22:46:25 -04:00
Antoine Musso
2389ec7141 MockOutputPage class in its own file
The MockOutputPage can be needed in various tests suite beside
GlobalFunctions. Seems to make sense to get it in its own class so we
can easily use it.

Change-Id: Icbb34db81e8cc8636d95f6326dd228bc74a741d7
2012-04-13 12:47:19 +02:00
Santhosh Thottingal
c56cca551e (bug 32748) unicode URL for articles print version
Printer friendly version of article must encode URL in unicode.

- Patch originally written by Brion Vibber
  https://bugzilla.wikimedia.org/attachment.cgi?id=9593
- introduces wfExpandIRI() global function, uses wfExpandIRI_callback.
- phpunit test.

Change-Id: I348b9f1d2ce65cb14f20d4a5751ac9359c8b8316
2012-04-02 18:14:41 +02:00
Aaron Schulz
7c54a34730 Reverted r113688, r113691 per CR and filed #61440 upstream. 2012-03-19 18:28:47 +00:00
Aaron Schulz
c8cc2ff897 r113688: updated test assertions 2012-03-13 00:18:29 +00:00
Antoine Musso
2721648de3 Break wfBCP47, wfBaseName and wfTimestamp tests
They are now in their own files. Rewrite wfTimestamp tests to use
data providers like it should.

Originally commited without history by ^demon as r108420
2012-01-09 16:30:32 +00:00
Antoine Musso
13427e7448 revert r108420, will split with history 2012-01-09 16:21:13 +00:00
Chad Horohoe
3bdc1d5e99 * Drop old parserTests.php way of running parser tests. You can run parser tests via --group Parser or specifying
the includes/parser/MediaWikiParserTest.php test case
* Drop now unused various test recorder options -- phpunit outputs its data in lots of machine-readable formats, use those if you need to work with
  test data
* There's still a lot of duplication between NewParserTest::setUp() and MediaWikiTestCase, but hey one step at a time ;-)
* All tests pass for me (make phpunit && make parser)
2012-01-09 15:18:07 +00:00
Daniel Friesen
14a99505df Followup r105809; Split up the tests with a dataProvider and add a round trip test. 2012-01-05 00:26:13 +00:00
Daniel Friesen
57c8fe18c7 Update wfArrayToCGI and wfCgiToArray:
- 'foo' => '' now outputs "&foo=" instead of the key being omitted
- 'foo' => null and 'foo' => false now omit the key instead of outputting "&foo="
- Added a test to make sure that 'foo' => true outputs "&foo=1"
- Fixed a php notice caused when passing a =value-less bit like "&qwerty" to wfCgiToArray by treating it like php and extracting it as 'qwerty' => ''
- Updated tests
2011-12-11 18:25:23 +00:00
Roan Kattouw
d045b999ec (bug 29854) Store protocol-relative links twice in the externallinks table, one with http: in el_index and once with https: . Modified patch by Brad Jorsch 2011-11-14 09:13:58 +00:00
Aaron Schulz
a727d79f97 FU r100915: split out GlobalWithDBTest (tests which need the DB) 2011-10-27 20:54:27 +00:00
Aaron Schulz
e8dfaccd3b * Allow passing in a blacklist into wfIsBadImage()
* Added wfIsBadImage() unit tests
2011-10-27 00:23:23 +00:00
Brion Vibber
a6fa806eae Followup r97954: fix unit tests for wfShellMaintenanceCmd() to work on Unix as well as Windows 2011-09-23 22:17:41 +00:00
Aaron Schulz
122a14140a Added wfShellMaintenanceCmd() for Het Deploy support 2011-09-23 20:42:22 +00:00
Roan Kattouw
2aa5f42df7 Followup r95072: add tests for wfMatchesDomainList 2011-08-20 10:41:44 +00:00
Platonides
ecceeb7585 Remove the globals. r91570 was wrong saying that parent::setUp()
would initialise those vars (this class parent is MediaWikiTestCase,
not MediaWikiLangTestCase) but the language doesn't seem to matter.
2011-07-19 21:05:17 +00:00
Brion Vibber
0572c46e6d Partial revert of r91106: followup to r91127.
Suppressing all warning output from unserialize() in ExifBitmap::formatMetadata will hide actual errors; we're now checking explicitly for the bad-metadata and no-metadata markers so the case this was added for should not happen.
2011-07-06 18:47:35 +00:00
Chad Horohoe
0989a2bcbc Call parent::setUp() and allow it to do lang setup stuff 2011-07-06 17:58:29 +00:00
Sam Reed
35205cfd4e Followup r91087, rename directory 2011-06-30 16:41:50 +00:00
Renamed from tests/phpunit/includes/GlobalFunctions.php/GlobalTest.php (Browse further)