wiki.techinc.nl/tests/phpunit/LessFileCompilationTest.php
Antoine Musso 85e97c051f Actually run the Less compilation tests
The testcase overrides the getName() method which is used by PHPUnit to
filter out invalid classes.  Remove the method to let PHPUnit pick up
the tests.

Tested locally using:

 php phpunit.php --debug --filter testLessFileCompilation

Bug: T106780
Change-Id: I5a59d69c96273725c2d4ca78d5e1b7303dd5cbf2
2015-07-27 18:26:47 +02:00

56 lines
1.4 KiB
PHP

<?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 ResourceLoaderTestCase {
/**
* @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() {
$thisString = $this->toString();
$this->assertTrue(
is_string( $this->file ) && is_file( $this->file ) && is_readable( $this->file ),
"$thisString must refer to a readable file"
);
$rlContext = $this->getResourceLoaderContext();
// Bleh
$method = new ReflectionMethod( $this->module, 'getLessCompiler' );
$method->setAccessible( true );
$compiler = $method->invoke( $this->module, $rlContext );
$this->assertNotNull( $compiler->compileFile( $this->file ) );
}
public function toString() {
$moduleName = $this->module->getName();
return "{$this->file} in the \"{$moduleName}\" module";
}
}