Commit graph

22 commits

Author SHA1 Message Date
aude
9d60ec5a4f Add @group Database tags to tests that need it
These tests all involve database access in some way,
and thus need @group Database tags.

These failed when setting a bogus database password
and then running the tests.

Change-Id: I7f113a79ac44d09d88ec607f76b8ec22bc1ebcf1
2015-04-01 11:20:23 +02:00
umherirrender
26837cd280 Cleanup some docs (tests)
- Swap "$variable type" to "type $variable"
- Fixed spacing inside docs
- Makes beginning of @param/@var/@throws in capital
- Changed some types to match the more common spelling

Change-Id: Ia041964250d8b7c0349d79dc9b131c5b8696e795
2014-08-11 20:06:52 +02:00
Timo Tijhof
0c2a013beb test: Remove MagicVariableTest#testServernameFromDifferentProtocols
This test was causing failures locally when wgServer != localhost
because {{SERVERNAME}} is derived from wgServerName, not wgServer
and the test is only mocking wgServer.

> MagicVariableTest::testServername.. with data set #2 ('//localhost/')
> Magic servername should be <localhost:string>
> Failed asserting that two strings are identical.
> --- Expected
> +++ Actual
> @@ @@
> -localhost
> +krinkle.dev

This value is no longer derived by the Parser, but is instead
set using wfParserUrl in Setup.php.

Remove this obsolete test and add any missing test cases for
wgParserUrl to its test suite.

Change-Id: I7d7d201cb46841e63dac8ab9fd81b45b252264a3
2014-06-25 12:08:48 +02:00
Siebrand Mazeland
5a16395d8e Pass phpcs-strict on some test files (9/11)
Change-Id: I69f17bf2af45f03274fdb38853184880e46c3514
2014-04-24 13:50:47 -07: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
addshore
5bf45af50e Cleanup MagicVariableTest
- Give methods scope
 - Make providers static
 - Add @covers todo
 - Merge the Providers file that is only used in here

Change-Id: I60a6bbd5a8ad3d9d414de493ec2b083f52114a7b
2013-10-23 07:58:14 +00:00
Aaron Schulz
e8e2474c8f Revert "Misc follow-ups to I2fc3966e (a161c5e)"
That apparently caused bug 46397.

This reverts commit 388b14a15d


Bug : 46397
Change-Id: Ideaa86f0d535873a08e27d6f98f6bd4255b8c594
2013-03-22 21:24:58 +00:00
umherirrender
817d4fc55b MagicVariableTest.php: Use dataProvider
Setting a global 3 times in one test method looks weird

Change-Id: I97f6a932ee2d5c9a5e427cf0f40ced730b7e12ec
2013-03-20 20:10:18 +01:00
Alexandre Emsenhuber
388b14a15d Misc follow-ups to I2fc3966e (a161c5e)
- Also add LinkCache::addLinkObj() calls to isRedirect(), getLength() and getContentModel()
- Changed error messages when LinkCache returns null, since this really should not happen anymore
- Removed incorrect comments
- Only use the value of the member variable if GAID_FOR_UPDATE is not passed
  (for consistency between the three methods)
- Mark tests that need database access as such due to the call to Title::getContentModel()
  (generally called through Parser::getFunctionLang())

Change-Id: I84e0c47cdf7412f2b7fa5f296d066b64b7bbfd42
2013-02-18 13:31:55 +01:00
Siebrand Mazeland
49dfbc59d0 Update formatting
6 of n.

Change-Id: I0ca3f1f72349623631ce1d7f3a4e2ed5edbdbdf4
2013-02-15 12:44:42 +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
Alexandre Emsenhuber
07818096df (bug 35204) set wgLanguageCode in unit tests
Setting $wgContLang without changing $wgLanguageCode accordingly is a
very bad idea.

This caused about 20 exceptions when using LanguageCode set to 'fr'
on my installation:

"MWException: Error in MediaWikiLangTestCase::setUp(): $wgLanguageCode
('fr') is different from $wgContLang->getCode() (en)"

Follow-up of I2987db68 (2b0edc8).

Change-Id: I56d3f1bfc78d6a2e40460533524e82f360490206
2012-11-17 09:53:34 +01:00
umherirrender
dcb6ad0097 Use ParserOptions::newFromUserAndLang in tests
This avoids using $wgUser and $wgLang for the ParserOption, which is not
needed in the tests

Change-Id: Iea07e9a0f0898ec5f8eb98a40000f5d33b279c9e
2012-10-24 15:59:30 +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
Antoine Musso
ae87825ed9 test {{SERVERNAME}} with relative URLS
bug 31176 mentionned an issue with {{SERVERNAME}} returning the full
URL instead of servername when using relative URLs (//localhost).
The fix was made by r98193.

This patch test three different URL protocols (http, https & relative)
and check we return the expected 'localhost'.
2011-10-24 09:32:33 +00:00
Antoine Musso
c1f23144e1 using real identity for hashar
Converting my pseudonym to use my real identity instead:
Ashar Voultoiz -> Antoine Musso
2011-10-24 09:08:13 +00:00
Platonides
9d98f581bb Manually set the title as not being a redirect. Otherwise,
it needed a database from Parser::getFunctionLang() -> 
Title::getPageLanguage() -> Title::isRedirect()
2011-08-27 21:10:41 +00:00
Brian Wolff
c909720031 Follow-up r94680 - fix unit tests.
The way the magic variable unit tests are run looks a little sketchy to me...
2011-08-17 00:46:58 +00:00
Chad Horohoe
26ec01f63c Extend MediaWikiTestCase in a few places 2011-05-25 00:30:06 +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
7675773aa9 Move some providers in new MediaWikiProvide class
The MediaWikiProvide class would host providing methods reused in different
tests classes.  To use it, just use the Class::function syntax.

Example:
  /** @dataProvider MediaWikiProvide::Months */

Made a svn copy of phpunit/includes/parser/MagicVariableTest.php
to save the history.
2011-02-06 21:28:57 +00:00
Antoine Musso
596956c928 Test suite for revisions and date related magic variables.
Tests should be carefully reviewed, please note there is are exceptions
for 'revisionday' and 'revisionmonth1' magics which are hardcoded in
the parser to return an integer.

Follow up r66200

TESTS:

$ php phpunit.php -c suite.xml --filter MagicVariable --testdox
PHPUnit 3.5.10 by Sebastian Bergmann.

MagicVariable
 [x] Currentday is un padded
 [x] Currentdaytwo is zero padded
 [x] Localday is un padded
 [x] Localdaytwo is zero padded
 [x] Currentmonth is zero padded
 [x] Currentmonthone is un padded
 [x] Localmonth is zero padded
 [x] Localmonthone is un padded
 [x] Revisionday is un padded
 [x] Revisiondaytwo is zero padded
 [x] Revisionmonth is zero padded
 [x] Revisionmonthone is un padded
$
2011-02-02 21:04:21 +00:00