Commit graph

221 commits

Author SHA1 Message Date
jenkins-bot
e9df496d11 Merge "Add parser test for "extra interlanguage links"." 2014-06-27 14:04:26 +00:00
C. Scott Ananian
09498e1d7f Add parser test for "extra interlanguage links".
This support was added in https://gerrit.wikimedia.org/r/111390
but no parser tests were added at that time.

Bug: 32189
Change-Id: I299ce844919b3f20b3ce116adf64b37dd95325d0
2014-06-26 22:46:13 +00: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
Jackmcbarn
2d1c6e2634 Add support for testing transparent tags
Allow transparent tag hooks to be loaded during parser tests the way that
regular and function tag hooks can be.

Change-Id: I28ac9cc239628c248f72898d247fa1f6e2c308bd
2014-06-20 11:36:08 -04:00
jenkins-bot
8284e92f51 Merge "Add ParserOutput::unsetProperty, add tests" 2014-06-05 12:41:23 +00:00
Adrian Lang
12c76c1354 Add ParserOutput::unsetProperty, add tests
Change-Id: I29af31918c48a1225b6487c74fd638de26f07b28
2014-06-04 10:02:01 +00:00
C. Scott Ananian
dece73dff9 ParserTests: fix bits column in uploaded images for test cases.
When running parser tests on a sqlite3 database, the insertion of the
djvu image before running the test suite will fail because `NULL` is not
a valid value for the `bits` column of the `image` table.  This will
cause the test suite to eventually fail, since {{NUMBEROFFILES}} differs.

Test uploads show that `bits` is usually set to 0 for both SVG and
DJVU uploads, so fix this (in both the standalone test runner and the
phpunit test runner).

Change-Id: I8689a547d34035534723e87c4c2680c4e67245f2
2014-06-03 21:49:40 +00:00
Bartosz Dziewoński
fd718959b6 Copy various random files used by tests to tests/phpunit/data
The tests currently depend on them never being renamed, which is bad.
(Actual file data in git is de-duplicated automatically AFAIK.)

Change-Id: Id2440326981218f9e7d51541a168db59183fdadf
2014-06-03 22:52:51 +02:00
Tim Starling
4ba7a9c102 Revert "Use square bounding boxes for default-sized thumbnails"
Reverting for further discussion, due to community complaints at https://en.wikipedia.org/w/index.php?title=Wikipedia:Village_pump_%28technical%29&oldid=611154541#Infobox_Image

This reverts commit 7db5534179.

Change-Id: Ieea6224b2a295b5d65bbd486e30cf0573376c7e9
2014-06-02 11:24:09 +10:00
C. Scott Ananian
7db5534179 Use square bounding boxes for default-sized thumbnails
Thumbnails for portrait-orientation images have always been "too big",
especially when displayed in a gallery.  The 'upright' option did not
completely fix the issue.  Using a square bounding box for thumbnails
(and 'framed' images) without an explicit size specifiction provides
a better default appearance.

This also provides a clean syntax for content authored using
Parsoid/Visual Editor, which prefers square bounding boxes.

See:
https://www.mediawiki.org/wiki/Requests_for_comment/Square_bounding_boxes

Bug: 63903
Change-Id: I665d8945843d3b5437a74e376b63c44965590116
2014-05-21 14:30:06 -07:00
Bartosz Dziewoński
c3aa5ef597 Create Parser::stripOuterParagraph to avoid code duplication
We've had the logic for stripping the outer <p/> element in three
separate places. The version in OutputPage was missing the '$' at the
end of the regex, that was most likely a mistake caused by the
duplication.

Also, extend the logic in order not to generate invalid HTML if the
input contains more than one <p/> tag. Added tests for this and the
previous behaviour.

https://www.mail-archive.com/mediawiki-api@lists.wikimedia.org/msg03188.html

Change-Id: I6bb3597898324556df912a23a7ffc9ff250b8f58
2014-05-15 12:20:19 -04:00
jenkins-bot
ac971d9a06 Merge "Add $wgServerName" 2014-05-09 10:18:09 +00:00
Ori Livneh
72c0ce43a8 Add $wgServerName
This partially reverts r73950 which removed $wgServerName on the ground that it
was only used for {{SERVERNAME}}. When it was pointed out that $wgServerName was
also used by several extensions, the response was not to restore the variable, but
to proceed to remove it from extensions as well.

It is a useful variable to have, as the discussion on Id819246a9 makes clear
(see Tim's comment on PS12 and Timo's reply). So let's reintroduce it, and expose
it in mw.config and ApiQuerySiteInfo as well.

Change-Id: I40a6fd427d38c64c628f70a2f407b145443ea204
2014-05-09 11:53:56 +02:00
Brian Wolff
5a81ad0e8a Throw an error if calling parser recursively
People accidentally (or sometimes intentionally) calling the
parser recursively has been a major source of bugs over the
years. I think its much better to fail suddenly, instead
of having unclear signs like UNIQ's all over the place.

Change-Id: I0e42aa69835c15a5df7aecb0dc5c3dec946bdf6a
2014-05-09 09:53:21 +02:00
Tpt
17117f74f5 Addition of a parser test for page= parameter of image inclusion
Support for DjVu is detected and parser tests that rely on it are disabled if needed.

Introduce DjVuSupport to easily detect DjVu support in unit tests

Change-Id: I53fd7b54e765d5f349abe74481bbc6f62f2b349e
2014-04-29 19:55:44 +02:00
Siebrand Mazeland
69ec133bc5 Pass phpcs-strict on some test files (10/11)
Change-Id: I5624292143fcabe890779f5095eae735d7afb176
2014-04-24 13:50:56 -07: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
C. Scott Ananian
0f799ce2b2 Update set of files cleaned up after parserTests
The parser tests now include more generated thumbnails, so we need to
update the list of thumbnail files we clean up after a run.

Change-Id: Ibabab27ecb895a61f57fff265c8d6d3147666e0d
2014-03-25 14:41:23 -04:00
Siebrand Mazeland
0db516b9ac Use correct Creative Commons license abbreviation
Change-Id: I7df989de9dca2ee056030ff6f5830d5f0124185e
2014-03-24 13:51:29 +01:00
C. Scott Ananian
e784f96a56 Allow setting default thumb size in parser tests
The mediawiki default thumb size is 180px.  The Parsoid default thumb
size is 220px, to match the default thumb size for most WMF wikipedias
(see https://bugzilla.wikimedia.org/show_bug.cgi?id=43336).

This discrepancy leads to inconsistent image-related test output.
Allow a test to set an explicit default thumb size with the
'thumbsize' option so that it is possible to write consistent tests.

Change-Id: Ib764d1f1660a50caaf8f0ff245822d1d1a1d264e
2014-03-20 13:40:16 -04:00
C. Scott Ananian
eca4351d1f Parser tests: Make Foobar.svg consistent.
The parserTest.inc file created metadata saying that Foobar.svg was
240x180px, but created an empty SVG file; the DEFAULT_WIDTH and
DEFAULT_HEIGHT in includes/media/SVGMetadataExtractor.php would have
caused this to be treated as a 512x512px image.

In NewParserTest.php, a 200x200px image was created for Foobar.svg.

That caused inconsistent and confusing results for SVG-related parser
tests, depending on which of the testing frameworks you used.

Fixed both of these to use a consistent 240x180px image, since
non-square images are better for checking correct scaling.
(Parsoid has always used a 240x180px size for Foobar.svg).
The non-square image has caused three parser test results to
slightly change.

Change-Id: Ib60a7412d9be808a0995e94d3aa373f2c5ca9bad
2014-03-18 13:27:55 -04:00
Aaron Schulz
9ee2b6f7fc Added a MemoryFileBackend class and made MockFileBackend subclass it
* This backend passes all filebackend and parser tests
* Fixed setupUploads() in parser tests to just use create() instead
  of using store() and having a race condition in the process
* Fixed 'use-filebackend=' for Parser tests

bug: 58094
Change-Id: Ib0c38183cb7f9f2325da98c8a8a1eb2b8e39a7aa
2013-12-19 12:38:00 -08:00
jenkins-bot
76dc198651 Merge "filebackend: cleaned up the FileBackend constructor" 2013-12-10 22:09:21 +00:00
Aaron Schulz
2aa84651ca filebackend: cleaned up the FileBackend constructor
* Added some b/c code with deprecation warnings

Change-Id: Ifceffbc0a37a223bcd7cd3dc60181fc85765bc46
2013-12-03 13:57:01 -08:00
jenkins-bot
b0b37fd95c Merge "Revert "filebackend: cleaned up the FileBackend constructor"" 2013-12-03 20:46:05 +00:00
Aaron Schulz
2f29c7551b Revert "filebackend: cleaned up the FileBackend constructor"
Actually this messes with the implicit backend made for things like Math (when unconfigured), which uses the "new" operator.

This reverts commit 1f129a22cb.

Change-Id: I4c72c4f7c8b82e38df5496cf2b90fc9e19c40334
2013-12-03 20:40:24 +00:00
jenkins-bot
dfe52313df Merge "filebackend: cleaned up the FileBackend constructor" 2013-12-03 20:22:10 +00:00
Aaron Schulz
1f129a22cb filebackend: cleaned up the FileBackend constructor
* Moved some of the graph construction work to FileBackendGroup.
  This helps the code in not depending on the rest of MW so much.
* Updated tests and FileBackendMultiwrite, which are the only things
  directly constructing FileBackend objects.

Change-Id: I188a053c70ce088ce34613d5db40e6708e3ea9b7
2013-11-23 20:21:53 -08:00
aude
71cf107f99 Make setUp and tearDown protected in tests
These are protected in the parent MediaWikiTestCase and
PHPUnit_Framework_TestCase. No good reason to make them public.

Change-Id: I45ecc0e4209f0c3b27e63a550112e4e0ddf6e530
2013-11-24 01:48:09 +01:00
umherirrender
f153998317 Fixed spacing
- Removed double spaces
- Added space after if/switch/foreach
- Removed space on elseif
- Added space around parentheses
- Added newline at end of file
- Removed space before semicolon at end of line

Change-Id: Id40b87e04786c6111e6686d7f7eea1e588bdf37d
2013-11-19 19:03:54 +01:00
jenkins-bot
a34dd90a36 Merge "Fix Tidy quietly breaking TOC disabling" 2013-10-25 19:44:11 +00:00
Max Semenik
d6f673c115 Fix Tidy quietly breaking TOC disabling
The functionality was introduced in I2889bcb9
but doesn't work in presence if Tidy.

Change-Id: Ibf96cc3bc94fac75fd92ec5b9205011fcb68f0c2
2013-10-25 19:04:51 +00:00
addshore
caec5f920a @covers tags for the rest of test files..
Change-Id: I0fafe80531325a412472ab7c9fc6d81c861b3751
2013-10-24 21:38:08 +01:00
jenkins-bot
8cabb5f777 Merge "Make TOC hideable" 2013-10-24 19:22:32 +00:00
addshore
de7af7ac2c Fix scope on all /phpunit test methods
Change-Id: I3ce92463d485a0fb23e464e9a8059330f32d79af
2013-10-24 10:31:32 +02:00
addshore
17c1e91238 General cleanup of Parser tests
- Fixes scope
 - Adds covers tags

Change-Id: I6024f2f7cc7a1812a417c6c389b0a15addde0b5e
2013-10-23 12:26:15 +00: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
Max Semenik
21c1c7d025 Make TOC hideable
Currently, if an extension doesn't want a TOC, it has to remove it manually.
This change wraps the TOC in markers that make it easy to remove it in ParserOutput
on demand without fragmenting the parser cache with stuff like "use/not use TOC".

Change-Id: I2889bcb9eb999c9049601e92440132118e1a8a41
2013-10-18 17:47:47 +04:00
Brad Jorsch
12bc4f1c5b Handle raw <h#> when calculating $rawtoc
When the parser is constructing $rawtoc, it needs the sectionIndex
number to be able to calculate the byteoffset. This number is only
available for wikitext headings ("== foo =="), HTML headings
("<h2>foo</h2>") do not have it and the lack makes byteoffset be wrong
for all subsequent headings in the page.

To fix this, we just omit output of byteoffset in this situation.

Bug: 25203
Change-Id: I39e5faa4ac22d915f06125aac36ced11607b94a3
2013-10-09 13:48:03 -04:00
C. Scott Ananian
0d2c4c4d61 ParserTests: allow test of precedence between interwiki links and namespaces
Bug: 51680
Change-Id: I8ad82c596139824fb97d513a62513edf2941b958
2013-10-02 16:11:33 -04:00
jenkins-bot
7e06997959 Merge "Clean up parser test's InterwikiLoadPrefix hook" 2013-08-26 16:10:50 +00:00
umherirrender
24bfde2710 Fix spacing and break some lines
Change-Id: Ia57685d8858e02e399ad5c75ce64d12609d340ac
2013-08-24 17:06:25 +02:00
Brad Jorsch
7b08f602dc Clean up parser test's InterwikiLoadPrefix hook
Change I36865e38 adjusted the parser test class to hook
InterwikiLoadPrefix, and prevent any other uses of that hook. Which is
ok, except it doesn't clean up after itself so it winds up breaking any
other parser tests that use the same hook.

Change-Id: I351a56ac39a44721d427e9c980eaf5fff246fb57
2013-08-22 14:42:45 -04:00
C. Scott Ananian
35422cadf2 Allow lines empty but for tabs and comments to be ignored.
We originally allowed only spaces around comments.  Now allow tabs as
well.  This ought to affect very few pages, but it helps predictability
and to maintain consistency between the PHP preprocessor and parsoid.

Change-Id: Icb3ff6eec08aaa83ae332d03c910c13995c9c9ee
2013-08-13 15:36:57 -04:00
C. Scott Ananian
414e7ecae3 Code style cleanups to parserTest.inc and NewParserTest.php.
Break some long lines which were causing WARNINGs and ERRORs from the
PHP code style checker.

Change-Id: Id52e18119277030041786d0130e693289b3c519e
2013-07-16 15:01:05 -04:00
C. Scott Ananian
64800d7092 Add wgAllowExternalImages option to parser tests.
This allows us to test whether the parser properly respects the
$wgAllowExternalImages option.

I also renamed the 'rawhtml' option to wgRawHtml so that parser test
options which set wiki configuration variables have consistent names.

Bug: 51092
Change-Id: I6c453b3e366cf775d8eef2dcbde09fcfa7027125
2013-07-10 18:13:20 -04:00
Antoine Musso
2fe1b773d3 test: skip math parser tests when missing $wgTexvc
The Math extension has at least one test marked with the parsertest
option 'texvc'.  We now use it to detects whether $wgTexvc points to an
executable binary and would skip such parser tests if not.

'math' option is kept for backward compatibility, just in case.

Math extension has been updated to use this as of
https://gerrit.wikimedia.org/r/#/c/69873/

bug: 49884
Change-Id: I992b5a5b7aac067f1e368cb3eeba224c056b76f9
2013-06-27 14:18:03 +02:00
jenkins-bot
453a531a14 Merge "PHPUnit now recognizes extension parser tests" 2013-06-20 12:43:01 +00:00
Antoine Musso
35f802edd9 test: rework interwiki lookup in parser tests
Some of our parser tests lookup interwikis.  This was originally done
(parser/parserTest.inc) by inserting a set of interwikis in the database
and was later lamely copy pasted in the PHPUnit wrapped test suite
(phpunit/includes/parser/NewParserTest.php).

Since that time, we had duplicate code and had the test hitting the
database to fetch interwiki.  Nowadays, we can trick the Interwiki
lookup class by using the InterwikiLoadPrefix hook, that let us skip
database lookup entirely (by having the hook returning false) and get
rid of the duplicate code.

The good old parserTests.php still pass the tests :-]

Change-Id: I36865e3890e08a05b8a6aaafa309a87556e235b9
2013-06-17 20:58:42 +00:00