LessFileCompilationTest.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /**
  3. * Modelled on Sebastian Bergmann's PHPUnit_Extensions_PhptTestCase class.
  4. *
  5. * @see https://github.com/sebastianbergmann/phpunit/blob/master/src/Extensions/PhptTestCase.php
  6. * @author Sam Smith <samsmith@wikimedia.org>
  7. */
  8. class LessFileCompilationTest extends ResourceLoaderTestCase {
  9. /**
  10. * @var string $file
  11. */
  12. protected $file;
  13. /**
  14. * @var ResourceLoaderModule The ResourceLoader module that contains
  15. * the file
  16. */
  17. protected $module;
  18. /**
  19. * @param string $file
  20. * @param ResourceLoaderModule $module The ResourceLoader module that
  21. * contains the file
  22. */
  23. public function __construct( $file, ResourceLoaderModule $module ) {
  24. parent::__construct( 'testLessFileCompilation' );
  25. $this->file = $file;
  26. $this->module = $module;
  27. }
  28. public function testLessFileCompilation() {
  29. $thisString = $this->toString();
  30. $this->assertTrue(
  31. is_string( $this->file ) && is_file( $this->file ) && is_readable( $this->file ),
  32. "$thisString must refer to a readable file"
  33. );
  34. $rlContext = $this->getResourceLoaderContext();
  35. // Bleh
  36. $method = new ReflectionMethod( $this->module, 'compileLessFile' );
  37. $method->setAccessible( true );
  38. $this->assertNotNull( $method->invoke( $this->module, $this->file, $rlContext ) );
  39. }
  40. public function toString() {
  41. $moduleName = $this->module->getName();
  42. return "{$this->file} in the \"{$moduleName}\" module";
  43. }
  44. }