Commit graph

69 commits

Author SHA1 Message Date
Reedy
d9d22e8f0b Remove ORM code from core
Bug: T114538
Change-Id: Ic4196ca9da927fc5c85b01cfff65f0636e3202ae
2015-10-29 13:06:36 +00:00
Reedy
58f0a7ee4e Wrap some long strings in tests/
Change-Id: I89d53c5051e5ee4bd8624df8ee2b25993090a7df
2015-09-26 21:01:59 +01:00
addshore
a737b61365 Add SpecialPageTestBase to simplify testing of special pages
This is copied from Wikibase. A follow up change adds a test
for Special:BlankPage to demonstrate how it works.

Change-Id: I3c34fd17ceb0049b160ec4f821474de457533983
2015-07-06 19:19:28 +00:00
Sam Smith
16cea35d85 Configure logged in session length independently
* Add the $wgExtendedLoginCookies configuration variable, which defines
  the set of login cookies that can have their lifetime configured
  independently
* Add the $wgExtendedLoginCookieExpiration configuration variable, which
  dictates when the extended lifetime login cookies expire
* Default $wgExtendedLoginCookieExpiration to null so that the current
  behaviour is unaffected

Bug: T68699
Change-Id: I0cc24524e4d7d9d1d21c9fa8a28c7c76b677b96c
2015-06-23 19:31:20 -04:00
umherirrender
eeea90d2b1 Add unit tests for all LogFormatters
Test the LogFormatter by passing old and new database rows to it.
The text shown on Special:Log and the api result returned by
list=logevents is tested.

Change-Id: Icfcba506f4fa3010cdaf973aa2df23b6e92c25e4
2015-05-03 21:58:00 +00:00
aude
2513086ec1 Add supportsDirectEditing methods to ContentHandler
This adds supportsDirectApiEditing and
supportsDirectEditing methods to ContentHandler. Both
return false by default for the ContentHandler base
class, and true for TextContentHandler and it's
derivatives. (everything in core)

Extension content types that directly extend
AbstractContent / ContentHandler, often / generally don't
support direct editing. EntityContent in Wikibase
and Flow boards are the two such content types currently
in gerrit-hosted extensions.

The use and direct settings of the allowNonTextContent
member variable is replaced by enableApiEditOverride and
a setter for that. The only place allowNonTextContent is
used in all of Wikimedia-hosted git repos is core itself
(EditPage and ApiEditPage), so should be safe to make
this change.

With this change, Wikibase can remove its ApiCheckCanExecute
hook handler that disallows editing there, and MobileFrontend
could check if direct editing is allowed before enabling it's
editing features, instead of Wikibase having to add
MobileFrontend hook handlers to disable the features.

Bug: T96382
Change-Id: I276cd6ecedf38108f1f2be16b38e699e8c5d2d0c
2015-04-17 15:55:20 +00:00
Bartosz Dziewoński
d469b37955 ResourceLoaderImage: Add basic tests
Also remove some wrappers from ResourceLoaderImageModule tests that
are no longer necessary, since the files they were mocking now exist.

Bug: T86334
Change-Id: If02e58716ce8e6c8327c8939c6c6425bd48bb560
2015-03-30 19:15:35 +02:00
Adam Roses Wight
9cfbbbe946 New testing wrapper to circumvent object access
The new TestingAccessWrapper class provides a convenient way to make
all of an object's methods and properties public.

TODO: We should organize test helpers into a source directory.  Note that the
helper and its test are in the same directory.

Change-Id: I958d55df18c74e9d2b25d98cd0316989a0fbbe6f
2015-03-16 23:58:36 -07:00
Kunal Mehta
870f50d45c resourceloader: Implement '$pages' parameter to ResourceLoaderWikiModule constructor
This makes it easier for subclasses to use ResourceLoaderWikiModule. Currently
many subclasses of this simply need to override the getPages() method.

UserModule and SiteModule keep their getPages override due to the set of pages
being dependent on context.

Change-Id: I388531398671afacfec36c6c5746d72267b5bdac
2015-03-03 17:17:02 +00:00
umherirrender
0a0ac07092 Do not list Test classes in the TestsAutoLoader.php
phpunit will load the file, when scanning all folders for Test files

Change-Id: I07b7252511dc31ea6433e645a9c46fb1517abced
2014-12-08 21:07:31 +01:00
umherirrender
aa09312ac0 Remove require_once from some tests by adding classes to TestsAutoLoader
Change-Id: If6d0a72acb98e0971fcce2facb239b67cbe639a5
2014-11-12 20:24:08 +01:00
aude
e78625dbcd Add test cases to SpecialPageFactoryTest for registration via callback
Change-Id: I9785e64d8daf27abca063f2bc584297db275c2db
2014-11-01 02:06:24 +01:00
Kunal Mehta
8968d8787f Check page_len in ResourceLoaderWikiModule::isKnownEmpty() for 'user' modules
In most cases, we just check whether the pages exist before saying
the module is not empty to avoid generating cached HTML without
the appropriate <script> or <link> tags.

However, for modules in the 'user' group, normal users cannot
delete their personal JavaScript/CSS pages, causing needless
extra requests, even though we know the pages are empty.

ResourceLoader::isKnownEmpty() now checks the page_len field
for modules in the 'user' group to check that there is
some actual content.

Bug: 68488
Change-Id: I0570f62887fd4642fd60367ae0b51d7dc19488ca
2014-08-30 00:24:37 +00:00
jenkins-bot
7eddc5caaa Merge "Run some parser tests with tidy." 2014-08-13 21:02:56 +00:00
addshore
f479ccf731 Move MediaWikiPasswordTestCase to password dir
Change-Id: I423e484929ce1bbc21e8f2ddd78196dee3520677
2014-08-09 00:40:06 +00:00
C. Scott Ananian
019e8ce29d Run some parser tests with tidy.
Note that the old parser tests helper function `tidy()` never actually did
anything, since $wgUseTidy was forced to `false` in the parser test setup.
Remove this unused code, and replace it with our new tidy support.

Allows new parser test sections: 'html+tidy' denotes "tidied" HTML (open
tags closed and other fixups to original wikitext markup) which should be
applicable to any parser.  'html/php+tidy' is output specific to the PHP
parser with tidy turned on.  The Parsoid backend will use the 'html/parsoid'
section if present, but if it is not present it will fallback to first the
'html+tidy' section, and if that is missing the 'html' section.

Note that 'tidy' has a large number of open bugs (see
https://bugzilla.wikimedia.org/show_bug.cgi?id=2542 ) and so in some cases
we deliberately do *not* use 'html+tidy' or 'html/php+tidy' clauses, in
order to avoid documenting broken output.  In these cases, there is no
broken HTML in the PHP parser output, and so (in theory) the 'html' and
'html+tidy' sections would be identical (that is, if tidy didn't have
bugs).

Change-Id: Iba45f38774b221522dc3b6ae2d1312fb79f8f41f
2014-08-03 17:45:54 -04:00
addshore
892a992ab8 Remove MediaWikiPHPUnitCommand
All functionality has been moved to other places

Change-Id: I6b6b0ef846bc63108c4dff9e17098432fd9d1697
2014-08-02 21:35:34 +00:00
Tyler Anthony Romeo
95a8974c6b
Added password hashing API
Deprecated the old User::crypt, et. al password hashing
system and implemented an extensible password hashing
API.

The new Password class allows registering of child classes
and provides factory functions for creating new Password
objects. The built-in hash types are the old MediaWiki MD5
types, which are for backwards-compatibility only, and bcrypt.

Also included is support for wrapping existing hashes as well
as encrypting passwords with a configured encryption key.

Bug: 54948
Bug: 28419
Change-Id: I0a9c972931a0eff0cfb2619cef3ddffd03710285
2014-07-27 15:51:18 -04:00
aude
5121b62fbe Split code for making test RecentChange objects into own class
this code is useful for adding tests of the other
changes classes and better not to duplicate it.

Change-Id: I464b4fbf39a0f47cb8911378b731cdd1672ecd86
2014-07-25 22:38:30 +00:00
Brian Wolff
6beee2535f Restructure Media related tests to avoid duplicated code
Change-Id: I4428d38e0199b12255f3746e79f8093259a03da1
2014-05-27 11:01:12 +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
Sam Smith
13f3e21e9c Add a LESS test suite
Add the LessFileCompilationTest test case class, which represents the
validation of a LESS file by compilation.

Add the LessTestSuite test suite, which tests all LESS files registered
with the ResourceLoader, and use this to rewrite the checkLess.php
maintenance script.

Bug: 54665
Change-Id: Iedb8dc31e4817d8b4e40b655cf9b8fb092979e90
2014-03-31 23:02:53 -04:00
Timo Tijhof
9976cef4ed tests: Add ResourceLoaderTestCase and abstract context creation
Change-Id: Ib4b265256e60a2f2109da73dc7edba6a75587ce2
2014-03-07 20:09:59 +01:00
aude
9af34b1923 Improve organization of TestsAutoLoader
put db stuff together, put parser stuff together

Change-Id: I3473a28d0eced152d2b7ee9c6c9e4256188b90e3
2014-01-15 21:15:03 +00:00
btongminh
1f47c9b9ae Fix capitalization in ApiQueryBase::titlePartToKey()
ApiQueryBase::titlePartToKey now allows an extra parameter that
indicates the namespace in order to properly capitalize the title part.

This allows list=allcategories, list=allimages, list=alllinks,
list=allpages, list=deletedrevs and list=filearchive to
handle case-sensitivity properly for all parameters.

Bug: 25702
Change-Id: Iaa5a71ec536f3716f54bc84b39f645545dfd8660
2013-12-23 12:53:43 -05:00
addshore
64db7068c2 Split mocks/media/MockBitmaphandler file
Change-Id: Idc231e8fd1f1ad1e4173e7c0bddfbec4efaad96b
2013-11-16 13:03:27 +01:00
addshore
dc18b813e8 Cleanup Api phpunit Tests
- Splits multiple classes into individual files
- Adds @covers tags
- Fixes scope

Change-Id: I7d2816d3574fa53a2aaa8e2a84b7a7ecdd245252
2013-10-24 19:17:01 +01:00
addshore
c40786cba2 Cleanup tests/includes/media
- Adds @covers tags
- fixes comments
- fixes scope
- adds @todos
- split files per class

Change-Id: Id5aaa20769725a96f22fb838d376697c250874a5
2013-10-24 08:12:42 +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
daniel
41e2e116e2 Allow debugging of unit tests via wfDebugLog.
This adds a listener to the PHPUnit test runner that will report
testing progress via wfDebugLog. This is useful for debugging
situations in which phpunit itself fails to report errors and
does not terminate normally. Having a debug log should at least
help with locating the trigger of the problem.

Change-Id: I433537a7f26197d8cff6f133e26ae5709871500f
2013-07-25 09:54:14 +00:00
jenkins-bot
453a531a14 Merge "PHPUnit now recognizes extension parser tests" 2013-06-20 12:43:01 +00:00
Antoine Musso
a9ab983b26 PHPUnit now recognizes extension parser tests
Parser tests are registeredd by appending one or more .txt files to the
$wgParserTestFiles global setting.  Since this is shared with MediaWiki
core, I have made MediaWikiParserTest a factory of PHPUnit testsuite
which would filter in/out extensions tests.

The `extensions` test suite now has a second test suite builder which is
simply a wrapper around MediaWikiParserTest factory.

Play cases:

  $ php phpunit.php --group Parser --tap

Runs any parser tests including the ones coming from extensions.

With an extension having parser tests such as Cite:

  $ php phpunit.php --testsuite extensions --tap
  // Extensions tests are run including parser tests.

bug: 42506
Change-Id: Icc3e9d30706b32149aa9dd18552e4241ec4af67e
2013-06-17 15:21:31 +00:00
Chad Horohoe
0ca1132ea9 Remove Selenium tests from core
This never really worked properly, doesn't conform to coding
conventions, and isn't actually used by anyone for testing.

Our selenium stuff these days are in the qa/browsertests repo

Change-Id: I8f1efaa118fe41821fb3f4a6099d75a33681f17b
2013-06-14 16:20:09 -04:00
jarry1250
3f5d41d413 The language used to render SVGs should be definable
See bug for context.

The implementation is slightly untidy because I've written it so
as to avoid invalidating the existing SVG thumbs -- there will be
no immediate difference (visual/performance/other) as a result of
this.

Tested by me in both...
* [[File:Example.svg|thumb|lang=fr]] AND
* http://example.org/w/index.php?title=File:Example.svg&lang=fr
...modes. Example file on
https://commons.wikimedia.org/wiki/File:Gerrit_patchset_25838_test.svg

Added parser tests.

Bug: 32987
Change-Id: I4cadf96ecd5e169a88ad468a0478d355db980103
2013-06-05 19:28:03 +00:00
Antoine Musso
ea14e46965 autoloader missed some entries
Jenkins does not run the autoloader test (will be fixed in a different
commit).  This patch fix the main and test autoloader to add in all the
missing entries.

bug: 47750
Change-Id: I285fa7ed24a6fc45a4dc475b54d80cf3816436fb
2013-05-21 11:56:26 +02:00
Antoine Musso
dfaf583d83 tests: mock parser tests file access
I eventually got tired of our parser tests creating and deleting fixture
files over and over.  This patch mock the files in memory and just
expose the file metadata which is all we need for parser tests.

The mocked classes are under /tests/phpunit/mocks/ and respect the
hierarchy of /includes/.

The wiki.png and headbg.jpg files are still copied on each test :/

Change-Id: Iccdff67222e66d48d01dd1596d09df2ea24b8c2a
2013-05-10 10:16:55 -07:00
jenkins-bot
4fe59cd7c2 Merge "test: abstract parser test result" 2013-04-22 19:09:20 +00:00
jenkins-bot
dfc977826c Merge "Add non DBMS depending SQL tests for DatabaseBase" 2013-04-18 08:42:02 +00:00
umherirrender
302f4b0ce1 Add non DBMS depending SQL tests for DatabaseBase
Created a DatabaseTestHelper class, which extends DatabaseBase and
implements STUBs for the interface methods and abstract methods

Change-Id: I9965b3604e78b2722077a35a7b4ce62a5bcb370e
2013-04-16 09:38:30 +02:00
Antoine Musso
9a90062eca test: abstract parser test result
This patch introduce the new ParserTestResult class which is meant to
represent the result of a parser test.  I have refactored some methods
to take advantage of this new class.

It just hold the test description and the actual/expected parser output.
A short isSuccess() method is provided for convenience, we can later
improve the class to carry more methods.

Change-Id: Ifb86e09451875dc119633b52d3f7e4f47c67cc60
2013-04-08 11:15:28 +02:00
jeroendedauw
32b2cb41ba Removed duplicate class registration
Change-Id: Ic22a190c5d44e37e99067decfe8bec74422efcb1
2013-04-02 17:26:44 +02:00
Antoine Musso
f6b92231fd style: normalize end of files
By PSR2 PHP Standard, the files should ends with exactly one newline.
Some of our files have 2 or more and some other were missing a newline.

Fix almost all occurences of CodeSniffer sniff:
PSR2.Files.EndFileNewline.TooMany

I have not fixed the selenium files, I believe we will drop them.

Change-Id: I89fca8c1786fee94855b7b77bb0f364001ee84b6
2013-02-03 15:04:39 +01:00
jeroendedauw
a00337c3f8 Design improvements to sites code
Change-Id: I08ffa6a97093abbe85169f664b97498c5f39bf8e
2013-01-22 15:39:23 +01:00
Hashar
ace6ceaf48 Merge changes Ic85d486d,I95bfb886
* changes:
  Rename JavascriptContentTest to JavaScriptContentTest
  Use the canonical class name: s/JavascriptContent/JavaScriptContent/
2012-12-07 10:51:16 +00:00
Platonides
9a81302781 Rename JavascriptContentTest to JavaScriptContentTest
Better match the original class name.

Change-Id: Ic85d486d55c2bc58189e5d5b411d296e872fc577
2012-12-06 23:13:10 +01:00
Platonides
51d12871fa Register WikitextContentTest in the test autoloader.
Change-Id: I3c3b0fab9850196b0aad7c0bee06c4ca0b8e2fc6
2012-12-06 22:58:51 +01:00
Antoine Musso
440ed28185 test classes autoloading path was broken
Since 7c6c05a, the ORMTableTest and SeleniumTestConstants classes points
to a wrong path. The reason is the variable name has not been renamed
for them.

Change-Id: I430031d0d00a8f0da047184285d1797a145bd389
2012-11-10 21:39:54 +01:00
Timo Tijhof
7c6c05a459 (bug 41833) Test: Add AutoLoaderTest.
* Move scattered pieces from tests/* in main AutoLoader.php
  into tests/TestsAutoLoader.php.
  Verified with:
  'ack -Q i --ignore-dir tests/phpunit/ <classname>'
  on mediawiki/core that these classes are not used outside
  tests/phpunit/.

* Moved entry for maintenance/backup.inc to the main AutoLoader.

* Refactored assertion logic in maintenance/checkAutoLoader.php
  into a public static method used in it's execute method
  and in the (new) AutoLoaderTest suite.

* The new test was immediately failing, added missing classes
  and removed old ones that don't exist.

  And CheckAutoLoader itself, so that it can actually be used
  in AutoLoaderTest.php

* Per discussion on Gerrit, moved the logic into the unit test
  instead of refactoring the maintenance script, we no longer
  need the maintenance script.

* Fixed the regex to also detect abstract, final and interface.
  The test was failing badly, claiming many classes did not
  exist.

* Improved the logic to also catch entries in the AutoLoader
  configuration for inexisting classes in existing files.
  So far it only catched entries with wrong files and missing
  entries for classes in known files.
  An entry like "BlablaSomethingHere => includes/Action.php"
  did not emit any kind of warning. The refactored logic
  builds a reverse index and uses a simple assertEquals to
  find any inconsistencies (whatever the cause).

Change-Id: I0a307f23175d52345180cdfc7c2d5e172536be1b
2012-11-10 18:36:13 +01:00
aude
16e2c77715 move ORMTableTest from Wikibase to core
- this is more generally useful than to be buried inside Wikibase client.
- it was in Wikibase/client/tests/phpunit/includes/store/EntityCacheTableTest.php

- patchset 2: add to test autoloader

Change-Id: I5bc41d6d205f28bcc5bf0c8a78b782c8888c18eb
2012-11-09 09:57:45 +00:00
Antoine Musso
a03bf9e27f tests: rm duplicate code in language classes
The language classes have been using the same setUp() tearDown() to
craft a new language object. I have abstracted that code in
LanguageClassesTestCase and made all the language test classes to extend
it. The language is interpolated directly from the class name and an
object for it can be retrieved with the getLang() method.

Change-Id: Ib931336ce219edabe2c72b7e9f04c976a500723e
2012-10-29 09:40:30 +01:00