Commit graph

16 commits

Author SHA1 Message Date
Timo Tijhof
9849db9c79 skins: Move default style modules to getDefaultModules
This advances T140664 as well, because it encourages module
loading logic from the skin to be in this single method.

Update the tests for setupSkinUserCss(), to now target
getDefaultModules() instead, given setupSkinUserCss() no longer
provides these behaviours. Had to move where the mock object
was created so that it can be injected in the skin (previously
it could be passed as parameter). Besides, its generally best-
practice to create mocks and stubs within the test anyhow, not in
the data provider.

Bug: T140664
Depends-On: Ib2b19ba165a9d646a770702cdf1724509156b93e
Change-Id: I3404c1c2a7e8eae0b803b31f333cb9b837f43d4a
2018-05-04 23:52:02 +00:00
Timo Tijhof
4da760c56a Skin: Remove the cache-compat remainings of mediawiki.sectionAnchor
Follows-up 5205405385. Two 2 years seems long enough :)

Bug: T18691
Change-Id: Id2f17312cbfe3ee9dda68bf8f9bcf94e18b003c6
2018-05-03 23:34:35 +00:00
jdlrobson
a01d8be82c Skins: getDefaultStyles can now define render blocking CSS
This optimisation attempts to minimise loading the styles in places
they are not needed.

The logic is kept inside Skin::getDefaultModules to avoid fragmentation
of where modules get defined.

Update ApiParse to avoid repetition of code.

Bug: T42792
Bug: T42812
Change-Id: I59f02a7bab3baa9d43f6bc2ef1f549d9d31d8456
2018-04-26 13:00:19 -07:00
Umherirrender
67d420b302 Move @group and @covers tags in tests close to class
For @group and @covers tags there should be no newline between the
comment and the class

Change-Id: I7277df13a332cf4d74ffdd8748e3fbdc259610dc
2018-01-28 13:30:07 +01:00
Umherirrender
45da581551 Use ::class to resolve class names in tests
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: Ie541a7baae10ab6f5c13f95ac2ff6598b8f8950c
2018-01-26 22:49:13 +01:00
Reedy
8f1f120147 Fix covers __constructor -> __construct
Change-Id: I264154c7707def3986560901f3501756853fff11
2017-10-15 18:36:53 +01:00
Timo Tijhof
a0947c9507 Skin: Make skins aware of their registered skin name
Remove the need for skin classes to have a hardcoded string as
skinname property value. This previously created the possibility
for the value to not match the skinname in the SkinFactory registry,
which creates confusing situations where message keys and load.php
urls are crafted with the internal skinname, but all other
handling (useskin, preferences, hooks, SkinFactory, ResourceLoader,
etc.) operate on the names in the registry.

We could enforce the matching by requiring a 1:1 relationship between
skinnames and Skin sub classes, but that is not backwards-compatible
with the 1:many map that wgValidSkinNames provides, and not compatible
SkinFactory either, which supports a factory function to return an
object. This makes a lot of sense and allows Skin-classees to be
re-used and composed with injection. If we do want to enforce 1:1,
we could validate it with a structure PHPUnit test, but instead this
change just uses the injected name from the constructor (passed by
ServiceWiring, previously unused).

The added unit test shows the new behaviour. Before this change,
getSkinName() on SkinFallback would always return 'fallback',
whereas now each instance of the class adheres to the registered
name (if it differs from the default).

Update the two direct uses of protected $skin->skinname to use
$skin->getSkinName() instead to enable sub-classes to optionally
implement an alternate source for the self-name (or to hardcode
it there as before).

Bug: T173546
Change-Id: I4383dcc3094da6e3c9ac12dc6c9311128db9db6e
2017-10-10 19:34:08 +00:00
Timo Tijhof
8fbd1cd1e1 phpunit: Fix OutputPage::__construct warning in SkinTemplateTest
https://integration.wikimedia.org/ci/job/mediawiki-core-code-coverage/2562/console
> Deprecated: Use of OutputPage::__construct was deprecated in MediaWiki 1.18.
> .. SkinTemplateTest->getMockOutputPage() ..

Change-Id: I7f44ffecc40b9d972839554361660e5b38ce3aef
2017-02-08 18:19:43 +00:00
addshore
3968dc9379 Add tests for SkinTemplate::setupSkinUserCss
Change-Id: I2033a98c3934a6e246b91338fd13472c4def0ddb
2017-01-20 14:10:52 +00:00
Chad Horohoe
b664350b0b SkinTemplateTest typofix
There's no "t" in "make"

Change-Id: I41dc25162262bddec94f3af35db86a246ccd7499
2016-08-11 13:54:05 -07:00
Bartosz Dziewoński
667522795b Fix trivial PHPCS violations in */skins/* directories
Due to T127238, files in various */skins/* directories are not checked
by PHPCS. Temporarily removed the exclude rule from phpcs.xml and ran:

  composer fix includes/skins/* tests/phpunit/includes/skins/* tests/phpunit/skins/*

Change-Id: I9240c1cee825920b6634903282be6252cce55686
2016-03-02 21:02:15 +01:00
Timo Tijhof
b4bac102b6 tests: Clean up file headers
* Remove redundant @licence/@license from test suite files.
  They already have full licence headers. And @licence raises a
  warning in Doxygen.

* Fix weird messes of comments inside comments and other things.

Change-Id: I38da8ca76330f72b8dc22b0ecf1ea69d5ea55ede
2015-04-01 00:17:12 +01:00
umherirrender
63dc5abc9a Fixed spacing
- Added space after reserved words: function, foreach, if
- Combined 'else if' into elseif
- Added braces to one-line statements
- Added spaces after comma, before parentheses

Change-Id: Ie5bbf680d6fbe0f0872dab2700c16b1394906a72
2014-08-27 18:31:50 +02:00
Kunal Mehta
d9d0289b6c Add more tests for SkinFactory
Change-Id: I0a8f93abe597d6b2393f1c813e7bf76093f3ec89
2014-08-20 00:26:50 -07:00
umherirrender
ab20f80116 Fixed spacing
- Added newline at end of files
- Added/Removed spaces around comma, parentheses and negation
- Added space after function word

Change-Id: I2dd338153aeb5f07702ba015945e95c7d0ae673b
2014-08-13 20:14:56 +00:00
Kunal Mehta
eb37e9d1ff Introduce SkinFactory
Modeled similar to ConfigFactory, this lets skins
register themselves via a callback, allowing for
proper dependency injection.

Loading via $wgValidSkinNames is still supported,
but considered "legacy", not deprecated though.

Skin::newFromKey is now deprecated (and had only
one caller in an extension, which I'll update
afterwards).

Change-Id: I1960483f87c2ef55c994545239b728fa376f17f4
2014-08-09 21:40:54 +01:00