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>
|
2019-02-01 19:46:59 +00:00
|
|
|
* @coversNothing
|
2014-03-17 13:24:52 +00:00
|
|
|
*/
|
2014-08-20 13:13:43 +00:00
|
|
|
class LessFileCompilationTest extends ResourceLoaderTestCase {
|
2014-03-17 13:24:52 +00:00
|
|
|
|
|
|
|
|
/**
|
2019-11-29 13:33:43 +00:00
|
|
|
* @var string
|
2014-03-17 13:24:52 +00:00
|
|
|
*/
|
|
|
|
|
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();
|
2019-12-29 10:50:03 +00:00
|
|
|
$this->assertIsReadable( $this->file, "$thisString must refer to a readable file" );
|
2014-07-22 14:34:12 +00:00
|
|
|
|
2014-12-19 00:52:28 +00:00
|
|
|
$rlContext = $this->getResourceLoaderContext();
|
2014-08-20 13:13:43 +00:00
|
|
|
|
|
|
|
|
// Bleh
|
2020-02-04 22:44:14 +00:00
|
|
|
$method = new ReflectionMethod( $this->module, 'compileLessString' );
|
2014-08-20 13:13:43 +00:00
|
|
|
$method->setAccessible( true );
|
2020-02-04 22:44:14 +00:00
|
|
|
$fileContents = file_get_contents( $this->file );
|
|
|
|
|
$this->assertNotNull( $method->invoke( $this->module, $fileContents, $this->file, $rlContext ) );
|
2014-03-17 13:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
2019-11-02 04:05:36 +00:00
|
|
|
public function toString() : string {
|
2014-03-17 13:24:52 +00:00
|
|
|
$moduleName = $this->module->getName();
|
|
|
|
|
|
|
|
|
|
return "{$this->file} in the \"{$moduleName}\" module";
|
|
|
|
|
}
|
|
|
|
|
}
|