Add tests for ExtensionJsonValidator
[lhc/web/wiklou.git] / tests / phpunit / LessFileCompilationTest.php
1 <?php
2
3 /**
4 * Modelled on Sebastian Bergmann's PHPUnit_Extensions_PhptTestCase class.
5 *
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 {
10
11 /**
12 * @var string $file
13 */
14 protected $file;
15
16 /**
17 * @var ResourceLoaderModule The ResourceLoader module that contains
18 * the file
19 */
20 protected $module;
21
22 /**
23 * @param string $file
24 * @param ResourceLoaderModule $module The ResourceLoader module that
25 * contains the file
26 */
27 public function __construct( $file, ResourceLoaderModule $module ) {
28 parent::__construct( 'testLessFileCompilation' );
29
30 $this->file = $file;
31 $this->module = $module;
32 }
33
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"
39 );
40
41 $rlContext = $this->getResourceLoaderContext();
42
43 // Bleh
44 $method = new ReflectionMethod( $this->module, 'compileLessFile' );
45 $method->setAccessible( true );
46 $this->assertNotNull( $method->invoke( $this->module, $this->file, $rlContext ) );
47 }
48
49 public function toString() {
50 $moduleName = $this->module->getName();
51
52 return "{$this->file} in the \"{$moduleName}\" module";
53 }
54 }