2014-03-17 13:24:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Modelled on Sebastian Bergmann's PHPUnit_Extensions_PhptTestCase class.
|
|
|
|
|
*
|
|
|
|
|
* @see https://github.com/sebastianbergmann/phpunit/blob/master/src/Extensions/PhptTestCase.php
|
|
|
|
|
* @author Sam Smith <samsmith@wikimedia.org>
|
|
|
|
|
*/
|
|
|
|
|
class LessFileCompilationTest extends MediaWikiTestCase {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var string $file
|
|
|
|
|
*/
|
|
|
|
|
protected $file;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @var ResourceLoaderModule The ResourceLoader module that contains
|
|
|
|
|
* the file
|
|
|
|
|
*/
|
|
|
|
|
protected $module;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string $file
|
|
|
|
|
* @param ResourceLoaderModule $module The ResourceLoader module that
|
|
|
|
|
* contains the file
|
|
|
|
|
*/
|
|
|
|
|
public function __construct( $file, ResourceLoaderModule $module ) {
|
|
|
|
|
parent::__construct( 'testLessFileCompilation' );
|
|
|
|
|
|
|
|
|
|
$this->file = $file;
|
|
|
|
|
$this->module = $module;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function testLessFileCompilation() {
|
2014-07-22 14:34:12 +00:00
|
|
|
$thisString = $this->toString();
|
|
|
|
|
$this->assertTrue(
|
|
|
|
|
is_string( $this->file ) && is_file( $this->file ) && is_readable( $this->file ),
|
|
|
|
|
"$thisString must refer to a readable file"
|
|
|
|
|
);
|
|
|
|
|
|
2014-08-07 10:25:56 +00:00
|
|
|
$compiler = ResourceLoader::getLessCompiler( RequestContext::getMain()->getConfig() );
|
2014-03-17 13:24:52 +00:00
|
|
|
$this->assertNotNull( $compiler->compileFile( $this->file ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getName( $withDataSet = true ) {
|
|
|
|
|
return $this->toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function toString() {
|
|
|
|
|
$moduleName = $this->module->getName();
|
|
|
|
|
|
|
|
|
|
return "{$this->file} in the \"{$moduleName}\" module";
|
|
|
|
|
}
|
|
|
|
|
}
|