Commit graph

216 commits

Author SHA1 Message Date
addshore
491993a2f5 Introduce stashMwGlobals method to MediaWikiTestCase
This method is factored out from the existing
seMwGlobals method.

The Doc from the initial method is also split and
improved and since tags has been added

Also adds tests

Change-Id: I0637194d637abf485a245b00587743f0f6dd495a
2014-03-09 14:49:15 +01:00
addshore
a3d8146e57 Catch Serialization Exception in MediaWikiTestCase
In the case that something is not serializable then
we should fall back and just set the value.

This is the case for Closures..
See
http://wikidata-jenkins.wmflabs.org/ci/job/wikidata-client-tests/748/console

Change-Id: Ib5f76932d60840a2f97671c134e18adc619974cd
2014-03-05 20:50:20 +01:00
addshore
6f5ea67f7f Make sure we don't use objects by ref in setMwGlobals
If we copy am object by ref into our temporary array
then this doesn't really make this method very useful
as the same object would be restored, with any changes
after the test has run.

Thus objects should be cloned when being dumped in
here, we use unserialize() and serialize() instead as
we would also want to clone the objects within the
object to avoid changes in there!

These is no point in adding an if is_object call so
we just serialize and deserialize everything!

Change-Id: I5e4ef114405888932014edae6b44afc6ee2c4863
2014-03-05 18:31:49 +00:00
Marius Hoch
5785c77a00 Ignore certain tidy warnings in assertValidHtmlDocument
Those aren't really useful, especially as tidy often
cries about parameters missing which have been
deprecated since HTML 4, so that these warnings have
no value for us.

Change-Id: Ic27c597aa988079ed08e152861bf1dee9581b829
2014-01-28 10:46:45 +00:00
jenkins-bot
f7afda4643 Merge "assertValidHtml for checking html in test cases." 2014-01-17 11:55:50 +00:00
daniel
df927f86c2 assertValidHtml for checking html in test cases.
implemented using tidy.

Change-Id: Idb98af785ca07ecd7afeebadf7396ecdc03a91bc
2014-01-17 12:42:35 +01:00
umherirrender
8138ad179d Fixed typo in comment in MediaWikiTestCase
Change-Id: I72214f134e0e94195cb56271c5fcb6997245fac6
2013-12-27 12:50:27 +01:00
daniel
08f91482c8 Detect leakage of error_reporting state in tests.
This causes PHPUnit test cases to fail if they changed the PHP 
error_reporting settings, and failed to restore it.

Change-Id: I34068eac94c974a461af0ff5753d9fcaa375f2e4
2013-11-16 22:03:20 +00:00
AlephNull
e9d53667f4 MySQL method to find out view + fix fatal in tests
We were missing a method to list out views defined in a database. This
patch adds in MysqlBase::isView() and MysqlBse::listViews().

Since listViews() cache its result in DatabaseBase::$allViews, we also
introduce a final DatabaseBase::clearViewsCache() to let us clear the
per process cache.

Finally, fixed fatal error when duplicating VIEWs in MySQL.

bug: 43571
Change-Id: I8650baa4b721fe69ea3e1d557dd76745c0c7754e
2013-11-07 09:43:59 +00:00
Tim Starling
d1bc243f65 Remove all instances of the word "iff"
It's elitist mathematical jargon. In all cases dealt with here, it adds
no additional meaning compared to "if", beyond what was already obvious
from context. Thus, its only purpose is to smugly demonstrate that the
author attended their second-year mathematics classes, at the expense of
causing confusion for everyone who doesn't have such a background.

If you really think you need to convey extra information beyond what
"if" gives you, the English language contains plenty of devices for doing
so, without resorting to neologisms.

Change-Id: Iae21095d02ec2935c10e94f532235c2671c115b1
2013-10-23 10:56:54 -07:00
jeroendedauw
35783c4635 Deprecate assertException in MediaWikiTestCase as it adds no value
setExpectedException, provided by PHPUnit itself, can and should be used instead

Change-Id: I06833eeeb492d2cc4e66b14aaebd5b2061a29e3a
2013-09-20 20:48:51 +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
Siebrand Mazeland
6da93fc6f6 Update code formatting
Also update some previous inconsistencies pointed out by Krinkle in change IDs:
* Ide20743a2e84ff68549286120e6cff9d9f396f54
* I811ca957b6588085d67606ebc0cd4033a1e53839

Change-Id: Ife33b931870d0d7e04fcb40974997436d27f528f
2013-03-27 14:15:11 +01:00
umherirrender
8764b3aa7c Remove spaces in function signature
Change-Id: I45aea7a7af88cd913b2f485913620a8af0ab2fed
2013-03-18 20:44:43 +01:00
Antoine Musso
1b2c9970a6 acessor for MediaWikiTestCase::$useTemporaryTables
useTemporaryTables is marked private to prevent childs from overriding
the value which would cause a lot of madness whenever it forgot to reset
its status.  But that in turns prevents a child class from figuring out
whether we use temporary tables or not. The ActiveAbstract extension
test suite has such a requirement and hence need a proper accessor.

MediaWikiTestCase::usesTemporaryTables() is a public accessor to for the
private property MediaWikiTestCase::$useTemporaryTables.

Change-Id: I8016c49116a187d7523cc0d6190514f8a513eafb
2013-03-18 15:15:08 +00:00
Yuri Astrakhan
27d83878c0 Lots of spelling mistakes and phpdoc attributes
@throw->@throws
@returns->@return
@seealso->@see
@cover->@covers
etc

Change-Id: I9ae6bc3034e9790e2d66cd96473b923fe9ee7953
2013-03-10 23:16:28 -04:00
Siebrand Mazeland
ac63001d8e Update formatting
1 of n.

Change-Id: I852729f08bbb0c5e39c2db44362ccdc7f59dcc08
2013-02-14 12:22:13 +01:00
Antoine Musso
5a547ac784 test: helper to skip tests depending on 'gzip'
Some of our tests explicitly depends on the 'gzip' command line utility,
for example the Dumps test suite.  This patch adds up a simple helper
MediaWikiTestCase::checkHasGzip() which skips tests whenever gzip is
missing.

Change-Id: I5ded9a53d08dcf5f35e666f91e3f64e6e111af32
2013-01-29 09:52:21 +00:00
jenkins-bot
75ef257c29 Merge "pass codesniffer on tests/" 2013-01-28 23:47:45 +00:00
Antoine Musso
a7901801b4 test: helper to skip tests depending on a PHP ext
Some of our tests expect a specific PHP extension to be loaded to get
anything done, for example zlib or gd.  This patch creates a new helping
method that people can use to easily skip a test whenever a PHP
extension is not around: MediaWikiTestCase::checkPHPExtension()

Example usage:

 function testCompressFiles() {
   $this->checkPHPExtension( 'zlib' );
   ...
 }

Change-Id: Ia87317ca379b2d5d1d1fa4231f76033ee66086c2
2013-01-28 11:18:04 +00: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
Aaron Schulz
fb8e4beca3 Merge "While testing, turn off DataBase::ignoreErrors." 2012-12-06 17:38:21 +00:00
daniel
abf22b914a While testing, turn off DataBase::ignoreErrors.
Database errors should cause an exception, not return false,
unless the test case, or the code under test, explicitely calls
ignoreErrors(true). The DB object should be reset to fail fast
and safe for every test.

Change-Id: Ifc2a720ec46a1843d9ffb1488c54743a0099ef9d
2012-12-05 17:13:21 +01:00
Antoine Musso
5b9f76aef7 test: detects parent setUp not being called
Our test classes often overload MediaWikiTestCase::setUp() but forget to
call their parent. This patch makes MediaWikiTestCase to flag whenever
its own setUp() is called and then simply assert it got called. Any
class failing the assertion is missing a call to its parent setup which
is easily fixed by adding: parent::setUp().

It would be nice to find a similar trick for tearDown().

Change-Id: Ia2afed6052eb3863d6c8e68c551cf03b33bb4be9
2012-12-05 16:44:41 +01:00
jeroendedauw
ba9a170df2 Added assertException method to MediaWikiTestCase
Change-Id: I3ce667b4405241c66c5a979863d1cea2cf39956b
2012-11-30 11:35:08 +01:00
Hashar
289c407957 Merge "Add MediaWikiTestCase::checkHasDiff3 and use it" 2012-11-23 10:27:47 +00:00
daniel
e2bb376dd7 Added profiling to test runner.
MediaWikiTestCase now calls wfProfileIn/wfProfileOut for each call
to a test function. This makes it easy to track down slow tests.

Change-Id: I5ff2fea957c082f41da37936fe44948ad006f573
2012-11-22 19:34:32 +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
daniel
be39c351d4 Clean up database cloning for tests.
This change makes the operation for overlaying the wiki database
with a structurally equivalent test database statically accessible,
and adds a function to revert that operation.

This is a precondition to logging profiling info to the database
after the test run has finished.

Change-Id: I2e8335d50eefcc7a97c1cd122b509f0939eacc92
2012-11-16 19:48:33 +01:00
Nikerabbit
a9e9c0e3ff Merge "Stash global only once per test case." 2012-10-29 12:15:37 +00:00
daniel
7385890cfe Stash global only once per test case.
Make sure we only stash a given global only once per test case since we
do not want to override the original value.

This allows the same test to modify the same global multiple times,
while still preserving the original value to be restored after the
test case finished.

Change-Id: I9056d6d6879fb976a192960f661904287f9760a8
2012-10-29 11:07:06 +01:00
Timo Tijhof
a4aef7d495 Fix warnings and enforce conventions in ContentHandler tests.
Syntax:
* Call parent setUp from setUp.
* Set required globals for the test inside the test class instead
  of assuming the default settings.
* Data providers are called statically and outside setUp/tearDown
  ("public static function")
* Test function names should be prefixed with "test"
  ("testIsRedirect")
* Marked 2 functions as unused. JavascriptContentTest has 2 data
  providers for tests that don't exist in it (nor in TextContentText)
  but do exist in WikitextContentTest.

Style:
* Single quotes
* Remove odd comment "# =====" lines
* Consistent tree wrapping with arrays.
  array(
      array(
          .. ) );
  array(
      array(
          ..
      )
  );
  Some were closing on the previous line instead.
  Made it consistent now.
* Remove odd indentation to make nested arrays line up:
  array( 'foo' => array(  'bar' => true,
                          'baz' => array() ) )
  array( 'foo' => array(
      'bar' => true,
      'baz' => array()
  ) )

  We don't do this kind of indentation because it is fragile
  and becomes outdates when any of the earlier keys ("foo")
  change. Converted to a regular tree instead.

  Also triggered git warnings for mixing spaces with tabs, which
  is almost always an detector for this style.

* Not using @annotations in inline comments, reserved (and only
  parsed/meaningful) for block comments.

Follows-up 8b568be5e2

Change-Id: Ic55d539b9a58f448b550bcd98894d389764e0694
2012-10-25 22:37:32 +02:00
daniel
759518bdde Fixing dump tests for non-wikitext in NS_MAIN.
Change-Id: I7945a1b950d3b9b394a336813abc8cd1e288766f
2012-10-12 17:34:29 +02:00
daniel
4ec9459100 [Bug 40716] Fix SearchEngineTest etc with non-wikitext content.
Several core tests fail if there is non-wikitext content in the main namespace.
This change fixes SearchEngineTest and TitlePermissionTest for this case.
More fixes are to come.

Change-Id: I6a19b568c5700bc8584689de8f33e4b0b6ffc277
2012-10-12 13:09:08 +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
d1c8bf85f8 Fix HtmlTest, XmlTest; Add setMwGlobals method to base TestCase.
The HTML and XML test now set the globals they depend on
(instead of relying on the default settings).

Tests for the "other" scenarios still exist, globals are
overridden inline. They are automatically restored after each
test## function by PHPUnit from MediaWikiTestCase::tearDown.

Also fixed 2 other problems with the test suite:

* HtmlTest::testDropDefaults forgot to pass
  $message to the assertion from the provider ($case[3]).

* The data provider for HtmlTest::testDropDefaults was calling
  Html::element directly (instead of calling it within the test)
  which is problematic because data providers are expected to be
  static. PHPUnit calls them outside the setUp/tearDown flow.
  (also fixed the function to be public static, as PHPUnit
  expects).

That last one was crucial to make the test still pass correctly.

Updated the expected strings to what they are with these
fixed non-leakage settings.

Took wgHtml5 without xmlform as default. And added tests
for variations where it made sense.

Change-Id: Iccf6ea81f4bc2639273ab2ad101c58788ee49d45
2012-10-09 00:26:52 +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
c546fae8ed merge latest master into Wikidata branch
Change-Id: Id4e0f40c03679c13d8934a6add99b5cd86d0437d
2012-10-08 13:58:54 +02:00
jeroendedauw
430b31415f Replace remaining Array occurences with array
Change-Id: Id7c2fdd6814a8239acbe050d857b56350e691a49
2012-10-05 16:11:54 +02:00
jeroendedauw
5356dbd180 Switch on expected value, since the actual one can obviously be wrong
This gets rid of confusing error messages pointing to the provided type being invalid

Change-Id: Id283ef6e8fa6c3f18bc9ef3b740e8ec4bd181e3a
2012-09-24 15:15:43 +02:00
daniel
b6b686c13b merged master
Change-Id: I0ef7c7f33a5dc5855f38b20c03ddc5306f38ec66
2012-09-19 12:34:10 +02:00
Daniel Kinzler
e1dc9e8723 Merge "Added MediaWikiTestCase::assertTypeOrValue to facilitate common type checks" 2012-09-14 10:08:44 +00:00
Siebrand Mazeland
59ec5a325c Move api/ApiTestUser.php to TestUser.php and make available in MediaWikiTestCase class.
* Renamed class ApiTestUser to TestUser.

Change-Id: I1c3c659c3ba5c54a314d879132f760008983372d
2012-09-13 18:40:23 +00:00
jeroendedauw
ad6ccbcaf3 Added MediaWikiTestCase::assertTypeOrValue to facilitate common type checks
Also added MediaWikiTestCase::assertType which accepts both internal types, classes and interfaces

Change-Id: I168ef17ad2da3b744a106742760ef34cc683bf69
2012-09-13 20:22:03 +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
daniel
cc5cc79148 Restore (some) globals after each test
Change-Id: I5fbf777c2bd4b1f88ba76d5cc42ad6df2eee4a9c
2012-09-05 15:04:07 +02:00
Antoine Musso
19d5ab2e8a test: new assertHTMLEquals()
Very trivial helper to compare HTML content. The method just add a
newline after each closing angle and then call assertEquals().

Change-Id: I5e6daa916a4fb452824616fa3c8a87bdb8038e8c
2012-09-03 10:47:36 +02:00
daniel
9994968774 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 15:20:15 +02:00
Daniel Kinzler
392af46809 Revert "merged master"
This reverts commit 67bfdc7a68
2012-08-29 13:14:49 +00:00
daniel
67bfdc7a68 merged master
Change-Id: Ib2b879c4daa17401eeeb50767c0e5a54254855c3
2012-08-29 12:06:38 +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
167bea7e7e Clean up transactions after test.
MediaWikiTestCase::teardown() will now rollback any transactions
left open by a test case. This is intended to make sure tests do
not provide "interesting" results casued by transaction state
leaking from other tests.

Change-Id: Ia225251efd5aafbaa6674e2732ab1ba7761bfadc
2012-08-27 14:38:25 +02:00
daniel
29719f846b merging latest master
Change-Id: I36b7f2f63ab8c08f8412d521dc68ea45c8b67711
2012-08-20 16:55:28 +02:00
Aaron Schulz
d996871d6b Merge "Added utility method taking an array of elements and wrapping each element in it's own array." 2012-08-14 03:25:13 +00:00
Aaron Schulz
b701eb0713 Merge "Move method to its using test class rather then having a public static thing in the base test class" 2012-08-13 20:14:19 +00:00
Aaron Schulz
c638ca1914 Merge "Fix for assertArrayEquals. Was throwing fatal for object elements" 2012-08-13 20:09:10 +00:00
jeroendedauw
93fe721105 Fix for assertArrayEquals. Was throwing fatal for object elements
Change-Id: I8fa45237e028a814e0895ac0f2b3723394b50d6b
2012-08-12 22:55:55 +02:00
jeroendedauw
8caca131e4 Move method to its using test class rather then having a public static thing in the base test class
Change-Id: Id82225d0fb65dcd30b5724ee4f2d7838dfcb5ea6
2012-08-12 21:47:06 +02:00
jeroendedauw
10f8b5f340 Added utility method taking an array of elements and wrapping each element in it's own array.
Useful for data providers that only return a single argument.

Change-Id: I220948865e3de395363bf8858098e61de3c8d35b
2012-08-12 21:37:56 +02:00
jeroendedauw
974f4f8f37 Added missing @since tags and fixed style
Change-Id: I8941345be8f754bda40f4c36cf2082ca3d408c50
2012-08-12 21:35:37 +02:00
daniel
3db0b6684d fix logic bug in assertArrayEquals
Change-Id: I442ebfe77292918f29121aba1205de664723e468
2012-07-26 20:12:08 +02:00
daniel
91972a365f fix logic bug in assertArrayEquals
Change-Id: I442ebfe77292918f29121aba1205de664723e468
2012-07-26 20:08:54 +02:00
jeroendedauw
19bd054e8b Added assertArrayEquals method to MediaWikiTestCase to avoid duplicating asort and array_values all over the place
Change-Id: I8e8e7257b74268dff8c0d105a399257dfdc01b40
2012-07-08 19:03:42 +02:00
jeroendedauw
06e54b828f Added assertArrayEquals method to MediaWikiTestCase to avoid duplicating asort and array_values all over the place
Change-Id: I8e8e7257b74268dff8c0d105a399257dfdc01b40
2012-07-02 16:24:10 +02:00
awjrichards
c29fd59775 Big oops - merged to wrong branch.
Revert "Revert to arbitrarily old point before initial remote branch creation to help clean up"

This reverts commit ee0d3d330f
2012-06-05 22:58:54 +00:00
awjrichards
ee0d3d330f Revert to arbitrarily old point before initial remote branch creation to help clean up
Change-Id: I41a3d1e55d3ea9dffa42451237fe065f9334361d
2012-06-02 08:43:04 -07:00
Platonides
4c7dc368a6 The 4th Database::select() parameter is the function name.
The ORDER BY should be at $options.
This was throwing errors in PHP 5.4 due to the array being
converted to a string down at Database.php:862

Fixes 50ee1d2

Change-Id: Ifb0fc70144242f25fc916fb8d380ed3e2d334fb9
2012-06-01 00:13:36 +02:00
daniel
50ee1d23e5 Introducing LinksUpdateTest.
This test case is intended to test the updating of various links
tables using a LinksUpdate object, based on the information in
a ParserOutput object.

Patch set 3: Suggestions by Aaron:
             factored assertSelect() out into MediaWikiTestCase.
             Force sorting of result set under testing.

Change-Id: I2d01e67ee7396080a04e5dff637aca0dc159c65d
2012-05-13 17:07:10 +02:00
daniel
650e33efa4 Let tablesUsed imply needsDB in MediaWikiTestCase.
If the test says it uses database tables, then it needs the database.

And while we are at it, make the check for the test group declaration
more lenient.

Patch set 2: tweaked according to demon's comments.

Change-Id: Ib123745d45b85cebeab5ec87ea7d8227ec3d1dea
2012-05-07 14:56:33 -07:00
Christian Aistleitner
9e80e3a702 Adding temp file/dir management to MediaWikiTestCase
Change-Id: I4ac8f44f1d681925af231377e9d1b984488d3198
2012-04-10 17:08:00 +02:00
Aaron Schulz
c1c6433bfc * In NewParserTest, refactored code to use FileBackend (bug 31737). Also made some speed improvements and made regex= not flood the output with 600 items of crap.
* In FileBackendTest, call clean() on the dirs *after* deleting all the files first.
* Speed improvements to MediaWikiTestCase.
2012-01-25 23:11:53 +00:00
Alexandre Emsenhuber
46767b157e Use WikiPage instead of Article to call doEdit() 2011-12-16 18:55:20 +00:00
Aaron Schulz
e52f4fcb2a FU r105154: only clear tables that tests specify as written to. This reduces the obnoxious slowness that was getting in the way of FileBackend testing.
Since previously (pre-r105154) nothing was cleared, tests should still work.
2011-12-10 05:47:46 +00:00
Aaron Schulz
a66556d7eb * Made resetDB() actually clear out the tables rather than leave the contents
* Removed destroyDB(); unused and broken (does not use prefix)
2011-12-05 07:22:27 +00:00
Jure Kajzer
5933586266 some more oracle-phpunit-fu (should not affect non-oracle)
* CloneDatabase - already droping tables in internal function, removed duplicate action
* DatabaseOracle - stopped ignoring "temporary" parameter
* added two parameters to phpunit (use-normal-tables & reuse-db), default actions stay the same
* with reuse-db oracle phpunit test run on oracle down to 1m 20s ;)
2011-11-10 13:29:32 +00:00
Jure Kajzer
636f304d20 * phpunit fixes & optimizations for oracle backend 2011-11-09 15:50:24 +00:00
OverlordQ
8296d0736b Basic support for Postgres phpunit testing, currently throws 5 errors, 1 inc, 5 skipped 2011-10-24 19:28:31 +00:00
Aaron Schulz
a108dbfe8f Reverted r92489 and added/use hideDeprecated() to MW test framework 2011-07-25 16:27:33 +00:00
Platonides
4a6f236904 Readd r90538, this time with the missing global $wgHooks; 2011-06-22 21:02:07 +00:00
Chad Horohoe
65e2d85048 Provisional revert of r90538. I can't replicate the failures, but CI's been complaining since this commit 2011-06-22 00:01:15 +00:00
Platonides
1d7f09a4f7 UploadTest::testTitleValidation accessed the database to fetch the interwikis.
phase3/includes/upload/UploadBase.php:620
phase3/tests/phpunit/includes/UploadTest.php:120
phase3/tests/phpunit/includes/UploadTest.php:55
phase3/tests/phpunit/includes/UploadTest.php:35

$wgContLang not needed, TitlePermissionTest.php changes the language, inheriting from MediaWikiLangTestCase
2011-06-21 17:41:25 +00:00
Mark A. Hershberger
a6722cc9aa w/s changes. 2011-06-02 19:32:45 +00:00
Max Semenik
7ad10e271d Don't duplicate tables starting with unittest_ which can be left if a previous run ended with a fatal on SQLite 2011-06-02 17:58:34 +00:00
Chad Horohoe
a98cdb721d Mostly revert r89302, was slower than the original 2011-06-01 23:17:29 +00:00
Chad Horohoe
5004f09bfa Exclude Block tests until somebody fixes them, also cache listTables() result so we can skip some queries 2011-06-01 22:54:33 +00:00
Chad Horohoe
f639fcdc4f Test db cleanup
* Fix Oracle stuff per CR on r88755
* Don't expect tests to clean up after themselves, do it in MediaWikiTestCase::run() (skipping user and interwiki, also per CR)
** Also don't do it from the destructor, phpunit calls this more often than you'd think
* Need to find: way to detect "is this the last test?" so we can drop our tables on completion
2011-06-01 22:43:19 +00:00
Antoine Musso
6d221bdabe Allow test to remove data from the database
This new removeDBData() is run after the tests result. It is similar
to the addDBData() method.
2011-05-28 21:19:24 +00:00
Chad Horohoe
c84f722f13 Fixup phpunit tests so we don't drop/create tables on EVERY SINGLE TEST.
Now just create them on the first test that needsDB() and skip creation on the rest.
Leaves you with a bunch of useless tables at the end of a run, but oh well at least its faster :)
2011-05-24 21:22:36 +00:00
Platonides
f10c7a0b93 Cosmetic change 2011-05-01 19:31:18 +00:00
Platonides
f80b75a6aa The $wgLocalisationCacheConf was being overwritten by the default value.
Restores the ability to run databaseless tests broken by r86775
2011-04-29 16:26:20 +00:00
Platonides
54026190a1 r82867 converted $wgCaches into a class instance. Update the parsertests.
This faking is needed to avoid Table 'unittest_objectcache' doesn't exist errors when using temporary tables.
2011-03-06 23:15:10 +00:00
Max Semenik
b11cd099bb Don't dupe/drop parts of searchindex on SQLite 2011-03-05 16:09:10 +00:00
Max Semenik
332d709d8b MediaWikiTestCase: factored prefix generation to a separate function 2011-03-05 15:44:28 +00:00
Platonides
2e33fb3ff6 Finally commit the testing stuff I have been with this week. Could be considered a continuation of r79411.
Mixture of the NewParserTests.php with old code present in MediaWikiParserTest.php, reverting r79184 (revert of a revert...) and even eval().
Using the iterator as dataProvider, but defering the insertion of articles, as the dataprovider is processed on load, before switching dbs.
Each parser test appear now as a phpunit test. This means that by adding 683 tests (partly from extensions) we now surpass two thousand tests.
The downside of that is that they become painfully slow.
Initialise $wgHooks to $wgHooks, not to array() (r82499) as otherwise we lose ParserFirstCallInit registrations.
There's no attempt to support extensions registering to $wgParser instead of using ParserFirstCallInit properly (Cite falls in this category).
2011-02-26 21:49:42 +00:00
Platonides
4ef087080d maintenance/commandLine.inc loads DefaultSettings, LocalSettings and then runs Setup.php
As Setup.php assigns variables based on the cache config, bootstrap.php was late on reseting them, as some objects were already created.
So we could end up with a SqlBagOStuff created there, which when later accessed (such as trying to invalidate the cache for a user) would 
-as any non-sqlite SqlBagOStuff- open a new db connection. Which is precisely what we shall not be done when dealing with temporary tables
(and would indeed fail miserably due to not finding unittest_objectcache table).

In summary, reenabling temporary tables disabled in r79411.
2011-02-21 23:19:26 +00:00
Platonides
74b466ae9c Spaces to tabs 2011-02-20 17:52:09 +00:00
Platonides
ee25269cf3 Fix the completely broken r81880 2011-02-10 10:03:38 +00:00
Platonides
4a01e74356 Add support of assertEmpty (used since r81596) for phpunit < 3.5.0 2011-02-10 09:51:31 +00:00
Antoine Musso
ba4a69e0e2 Fix @dataProvider with PHPUnit 3.5.8+
MediaWikiTestCase duplicates code from PHPUnit constructor. It worked
fine until PHPUnit 3.5.8 made FrameWork_TestCase attributes private,
thus the children class is no more able to update them ($data for example)
The change break any tests making use of the @dataProvider helper.

PHPUnit commit:
0b85d08c39

TESTS:
3.5.7  : OK -> OK
3.5.8  : KO -> OK
3.5.10 : KO -> OK

make databaseless
Tests: 486, Assertions: 73986, Incomplete: 1, Skipped: 3.

(skipped tests are SQLite related)
2011-02-05 16:25:18 +00:00
Alexandre Emsenhuber
de4a9c6b9a Reset the cache used in User::idFromName(), otherwise tests will try to add the user '127.0.0.1' multiple times, resulting in a database error (duplicate key for user_name field) 2011-01-25 16:32:43 +00:00
Jure Kajzer
f853d711ac * fixed Oracle code for installer and phpunit tests
* removed ORABlob class
2011-01-10 19:22:27 +00:00
Chad Horohoe
d71167fa60 Move table prefixes to constants, add doc to addDBData() 2011-01-10 18:34:59 +00:00
Platonides
1cb56fc8e3 Remove unused globals 2011-01-01 22:16:58 +00:00
X!
f8d74604fd More work on new parser tests:
-No need to specify a new function for each argument, use PHP5 magic to automatically set it
-Create (g|s)etCliArg() functions
-Implement some features from the old parser tests
2011-01-01 05:53:04 +00:00
X!
34fc833407 Start work on porting ParserTests completely into PHPunit.
Disable temporary tables, a few reports of them not working. The tables get deleted anyway, so why risk it?
2011-01-01 03:39:37 +00:00
X!
2441c2d5e4 For some reason tableExists() is being unreliable, which is resulting in tables not being dropped that _should_ be dropped. Drop them anyway and ignore the errors. 2010-12-31 21:51:21 +00:00
X!
a26353ec0b -If $this->db does not exist, skip destroying the DB
-Fix ApiTest errors due to DB rewrite
2010-12-31 21:40:26 +00:00
X!
02077c9901 Add check to make sure only MySQL and SQLite are used at the moment. These two are the only ones with the listTables() function, and the only ones that are tested. 2010-12-31 21:10:36 +00:00
X!
90e371195e Only destroy DB if it needs it 2010-12-31 21:05:51 +00:00
X!
1b7bfdee49 I made MySQL work, and broke SQLite in the process. I fix SQLite, and made MySQL break. Fixing MySQL again, hoping that SQLite works too. :) 2010-12-31 21:01:17 +00:00
X!
025defad3f Solved problem with SQLite: Globals were getting stored, and when a PDO reference is transferred, as is the case with SQLite, it serializes the globals. 2010-12-31 20:47:48 +00:00
X!
dd68f3947a More work on getting SQLite to work with unit tests. DB Prefix changing is now static to allow for external classes to change it. 2010-12-31 20:42:39 +00:00
X!
1993c83277 -Destroy the DB automatically when initting the DB
-Add $force option to wfSetVar
-More work on getting SQLite to work
2010-12-30 17:30:35 +00:00
Platonides
c97d18b7ea Follow up r79109. Do not use create_function. 2010-12-30 16:24:29 +00:00
Platonides
4cb81e08f4 Move MediaWikiTestCase class to a new file and load it from phpunit.php
This restores the ability to run single tests with 
php phpunit.php includes/filename.php
2010-12-29 15:52:07 +00:00