resourceloader: Move creation addLink() function to shared mw.loader scope
[mediawiki.git] / tests / phpunit / LessFileCompilationTest.php
blob73fa0b5dc386a1444e31be1607ad23e7ff0c5d8b
1 <?php
3 /**
4 * Modelled on Sebastian Bergmann's PHPUnit_Extensions_PhptTestCase class.
6 * @see https://github.com/sebastianbergmann/phpunit/blob/master/src/Extensions/PhptTestCase.php
7 * @author Sam Smith <samsmith@wikimedia.org>
8 */
9 class LessFileCompilationTest extends ResourceLoaderTestCase {
11 /**
12 * @var string $file
14 protected $file;
16 /**
17 * @var ResourceLoaderModule The ResourceLoader module that contains
18 * the file
20 protected $module;
22 /**
23 * @param string $file
24 * @param ResourceLoaderModule $module The ResourceLoader module that
25 * contains the file
27 public function __construct( $file, ResourceLoaderModule $module ) {
28 parent::__construct( 'testLessFileCompilation' );
30 $this->file = $file;
31 $this->module = $module;
34 public function testLessFileCompilation() {
35 $thisString = $this->toString();
36 $this->assertTrue(
37 is_string( $this->file ) && is_file( $this->file ) && is_readable( $this->file ),
38 "$thisString must refer to a readable file"
41 $rlContext = $this->getResourceLoaderContext();
43 // Bleh
44 $method = new ReflectionMethod( $this->module, 'getLessCompiler' );
45 $method->setAccessible( true );
46 $compiler = $method->invoke( $this->module, $rlContext );
48 $this->assertNotNull( $compiler->compileFile( $this->file ) );
51 public function toString() {
52 $moduleName = $this->module->getName();
54 return "{$this->file} in the \"{$moduleName}\" module";