Commit graph

24 commits

Author SHA1 Message Date
umherirrender
675cc960a8 Use mergeMwGlobalArrayValue in AutoLoaderTest::setUp
Change-Id: Ieb7835855a28d1602ac357b51197cb66d9200209
2014-10-15 18:16:48 +02:00
umherirrender
b0cfcd0fcb Add missing @return and @param to doc blocks
Change-Id: I9d99ba1968ed8f97624d957754c8847dfe1b41da
2014-08-27 21:57:45 +02:00
Kunal Mehta
523ba0cf8b ResourcesTest: Add variable type annotations
Change-Id: I07ec986830dcec739b0553395b9a220b44bba77d
2014-08-22 00:32:09 +02:00
Bartosz Dziewoński
3971d0646c resourceloader: Allow skins to provide additional styles for any module
The newly introduced $wgResourceModuleSkinStyles global enables skins to
provide additional stylesheets to existing ResourceLoader module.

This both makes it easier (or at all possible) to override default
styles and lowers the style footprint by making it possible not to
load styles unused on most pages.

----

Example:

Use the file 'foo-styles.css' for the 'mediawiki.foo' module when using
the MySkin skin:

  $wgResourceModuleSkinStyles['myskin'] = array(
    'mediawiki.foo' => 'foo-styles.css',
    'remoteSkinPath' => 'MySkin',
    'localBasePath' => __DIR__,
  );

For detailed documentation, see the doc comment in DefaultSettings.php.
For a practical usage example, see Vector.php.

----

Implementation notes:

* The values defined in $wgResourceModuleSkinStyles are embedded into
  the modules as late as possible (in ResourceLoader::register()).
* Only plain file modules are supported, setting module skin styles
  for other module types has no effect.
* ResourceLoader and ResourceLoaderFileModule now support loading
  files from arbitrary paths to make this possible, defined using
  ResourceLoaderFilePath objects.
  * This required some adjustments in seemingly unrelated places for
    code which didn't handle the paths fully correctly before.
* ResourceLoader and ResourceLoaderFileModule are now a bit more
  tightly coupled than before :(
* Included a tiny example change for the Vector skin, a lot more of
  similar cleanup is possible and planned for the future.
* Many of the non-essential mediawiki.* modules defined in
  Resources.php should be using `'skinStyles' => array( 'default' => … )`
  instead of `'styles' => …` to allow more customizations, this is
  also planned for the future after auditing which ones would actually
  benefit from this.

Change-Id: Ica4ff9696b490e35f60288d7ce1295766c427e87
2014-07-29 00:53:41 +02:00
jenkins-bot
66d3eb56af Merge "ResourceLoader: Test that all module dependencies are satisfiable" 2014-07-27 21:21:41 +00:00
umherirrender
4ee680a8b3 Fixed spacing
- Removed spaces after not operator (!)
- Removed spaces inside array index
- use tab as indent instead of spaces
- Add newline at end of file
- Removed spaces after casts

Change-Id: I9ba17c4385fcb43d38998d45f89cf42952bc791b
2014-07-24 11:53:04 +02:00
Chad Horohoe
f45e4de3b7 Make AutoLoaderTest handle namespaces
Bug: 67644
Change-Id: Ibeb0833742c574afac13bfebd278f9d2b8410de6
2014-07-16 17:32:21 +00:00
Bartosz Dziewoński
278e58bd66 ResourceLoader: Test that all module dependencies are satisfiable
Whenever module A depends on module B, module B must exist.

Whenever module A depends on module B, the possible targets of A must
be a subset of targets of module B.

Bug: 64513
Change-Id: I9de291d20d08df2813eb55be9a1f7e5efd907d6f
2014-06-29 20:28:05 +02:00
Brian Wolff
6beee2535f Restructure Media related tests to avoid duplicated code
Change-Id: I4428d38e0199b12255f3746e79f8093259a03da1
2014-05-27 11:01:12 +02:00
Siebrand Mazeland
4ede8c2e9d Pass phpcs-strict on some test files (11/11)
Woo!

Change-Id: I9fc116dfdf18c2772d047adb5bb14535d0bd39ed
2014-04-24 13:51:05 -07:00
Timo Tijhof
330444a4f9 resourceloader: Add unit test to ensure absence of illegal dependencies
Loading these can cause side-effects and is just redundant in
general.

Change-Id: Ic8b4ed45d4d42172a456cc5eaf314c41e4e6fd18
2014-04-08 17:10:34 -07:00
Timo Tijhof
9976cef4ed tests: Add ResourceLoaderTestCase and abstract context creation
Change-Id: Ib4b265256e60a2f2109da73dc7edba6a75587ce2
2014-03-07 20:09:59 +01:00
Kevin Israel
da83e1a083 AutoLoaderTest: Add support for class aliases
* Changed the regex to match class aliases, and added a check to
  also ensure that all aliases for a class are in the same file as
  the class (see cb77e59f7c for explanation).
* Removed support for the seemingly unmaintained Parsekit extension
  (no release since 2009, and known not to compile against PHP 5.4).
  The test would currently fail if Parsekit were used anyway because
  the class MyLocalSettingsGenerator is commented out.

Change-Id: I7be2352f4659abc7b4952a9f74a14d0cef911614
2014-01-23 16:31:42 -05:00
PleaseStand
cb77e59f7c Revert "Mechanism for renaming/aliasing classes"
Seems good in theory, though not quite usable in practice.
As with subclassing, the aliases would not work reliably
for code that uses type hints and/or instanceof.

See <https://bugs.php.net/bug.php?id=61422>, which I was
previously unaware of.

The best alternative is to add class_alias() calls to the
class files themselves, as well as duplicate entries to the
AutoLoader (just like when multiple classes are in the same
file).

There is no good way to show deprecation warnings, which
likely would have to be implemented in PHP itself. For now,
renamed classes should be indicated in RELEASE-NOTES. Maybe
I will file an RfC (at <https://wiki.php.net/rfc>) for this
and related improvements (e.g. making class names case
sensitive).

This reverts commit c61fdb4ef5.

Change-Id: I9771b4239543b543cfa078f357db1cd3918f081e
2014-01-11 21:48:30 +00:00
Kevin Israel
c61fdb4ef5 Mechanism for renaming/aliasing classes
Sometimes it is desirable to change a class name that is still referenced
in extensions or config files (e.g. for consistency, as in I507ba00a).
PHP's class_alias() function can help in preserving backward compatibility;
however, creating an alias first requires that the class be loaded.

Hence this is implemented in AutoLoader. Lazy loading continues to work,
the list of class names is still maintained in a central location, and
optionally, deprecation warnings can be generated.

Change-Id: I1d3fb04a448647b5be10bed7fec05238b9fc6fc7
2014-01-06 10:36:18 -05:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00: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
Siebrand Mazeland
6d2234640c Declare visibility on Autoloader::$autoloadLocalClassesLower
Make protected, add method to allow tests to clear the protected class
property, and remove a now unneeded class from the test.

Change-Id: I269cab8d3f4419c91dfe15d5722e19ff6da828d1
2013-11-07 09:41:47 -08:00
Timo Tijhof
4eb60da520 ResourcesTest: Assert no @media is used inside 'media'-specified resources
Change-Id: I85d652da7c1713d46a5085b9fde7fb24045348be
2013-11-03 23:08:41 +00:00
Adam Roses Wight
7f51cf22f9 Minor optimization to the AutoLoader
When MediaWiki autoloading fails, we should gracefully return false.
Instead, we have been calling strtolower roughly 1,000 times in the hope
of finding a case-insensitive match.

This patch preserves the legacy case-insensitivity, but improves its
performance by approximately 100x, by storing the case-insensitive class
lookups as a static variable.

There is a new global $wgAutoloadAttemptLowercase which will switch the
behavior if desired.  The default is to support case-insensitive loading.

Change-Id: Ifb12e05614a48390b730167e9d4ddcd8545db764
2013-10-28 21:39:57 +00:00
Antoine Musso
3c8674bdff tests: remove date from @author docs statements
phpunit interprets '@author' documentation statements to generate group.
Appending the year to the author name created duplicates entry:

 $ php phpunit.php --list-groups|grep Antoine
 Antoine Musso
 Antoine Musso, 2012
 $

Removing the date fix the duplication. I have also inserted
corresponding '@copyright' statements.

Change-Id: I65b19adb59c4894314ce68a0c815c5d3e4c30df0
2013-10-03 10:48:12 +02:00
Matt Walker
0964847d0f Added a Descriptive Comment to the AutoLoaderTest
Change-Id: Ib209f869f7ec11f29cc69fb02f558b54791eb2aa
2013-07-17 16:56:24 -07:00
Antoine Musso
67b935edb4 tests: resources tests were not being run
The ResourcesTest class under ./resources/ were not registered anywhere.
This patch move it under the `structure` testsuite and phaseout the, now
empty, `resources` directory.

Change-Id: I53410e1dc83263c4c541f4dc278a9e616265d7b1
2013-05-30 17:17:46 +02:00
Antoine Musso
f87320bdac tests: group structures tests in their own directory
The phpunit root directory has two test file:

 AutoLoaderTest.php
 StructureTest.php

The later was registered in phpunit under the `structure` test suite
while the former was not registered and hence never run (bug 47750).

This patch moves both files under the `structure` subdirectory and
change the suite to look in that directory.  That will avoid us having
to manually maintain a list of test files.

Updated the __DIR__ in StructureTest.php.

Change-Id: I419c9157f32bdf7e1ff26a42f4bb3f3922b7be37
2013-05-21 12:33:42 +02:00