wiki.techinc.nl/tests/phpunit/suites/LessTestSuite.php
Timo Tijhof a186dc62fd resourceloader: Instantiate main class via ServiceWiring
It also removes some code duplication which is nice.

This unlocks various future changes, including:

* Making the `$config` parameter mandatory for the ResourceLoader class
  constructor, which currently falls back to global state.
  This should be deprecated and removed.

* Making it possible to instantiate the ResourceLoader class
  without all the default MW modules being registered from
  global state. E.g. move MW module registration from main class
  constructor to ServiceWiring, and remove the 'EmptyResourceLoader'
  class hack from unit tests, and use regular 'new ResourceLoader'
  instead.

* Making ResourceLoader a standalone library (some day),
  e.g. allowing it to be instantiated from a basic PHP script,
  in a way that is still useful and perhaps able to serve
  (most) RL modules without MW itself.

Bug: T32956
Change-Id: I4939f296c705b268e9cf8de635e923a739410470
2019-02-18 17:55:09 +00:00

36 lines
907 B
PHP

<?php
use MediaWiki\MediaWikiServices;
/**
* @author Sam Smith <samsmith@wikimedia.org>
*/
class LessTestSuite extends PHPUnit_Framework_TestSuite {
public function __construct() {
parent::__construct();
$resourceLoader = MediaWikiServices::getInstance()->getResourceLoader();
foreach ( $resourceLoader->getModuleNames() as $name ) {
$module = $resourceLoader->getModule( $name );
if ( !$module || !$module instanceof ResourceLoaderFileModule ) {
continue;
}
foreach ( $module->getAllStyleFiles() as $styleFile ) {
// TODO (phuedx, 2014-03-19) The
// ResourceLoaderFileModule class shouldn't
// know how to get a file's extension.
if ( $module->getStyleSheetLang( $styleFile ) !== 'less' ) {
continue;
}
$this->addTest( new LessFileCompilationTest( $styleFile, $module ) );
}
}
}
public static function suite() {
return new static;
}
}