checkLess.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Checks LESS files in known resources for errors
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along
  16. * with this program; if not, write to the Free Software Foundation, Inc.,
  17. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. * http://www.gnu.org/copyleft/gpl.html
  19. *
  20. * @file
  21. * @ingroup Maintenance
  22. */
  23. require_once __DIR__ . '/Maintenance.php';
  24. /**
  25. * @ingroup Maintenance
  26. */
  27. class CheckLess extends Maintenance {
  28. public function __construct() {
  29. parent::__construct();
  30. $this->addDescription(
  31. 'Checks LESS files for errors by running the LessTestSuite PHPUnit test suite' );
  32. }
  33. public function execute() {
  34. global $IP;
  35. // NOTE (phuedx, 2014-03-26) wgAutoloadClasses isn't set up
  36. // by either of the dependencies at the top of the file, so
  37. // require it here.
  38. require_once __DIR__ . '/../tests/TestsAutoLoader.php';
  39. // If phpunit isn't available by autoloader try pulling it in
  40. if ( !class_exists( 'PHPUnit_Framework_TestCase' ) ) {
  41. require_once 'PHPUnit/Autoload.php';
  42. }
  43. // RequestContext::resetMain() will print warnings unless this
  44. // is defined.
  45. if ( !defined( 'MW_PHPUNIT_TEST' ) ) {
  46. define( 'MW_PHPUNIT_TEST', true );
  47. }
  48. $textUICommand = new PHPUnit_TextUI_Command();
  49. $argv = [
  50. "$IP/tests/phpunit/phpunit.php",
  51. "$IP/tests/phpunit/suites/LessTestSuite.php"
  52. ];
  53. $textUICommand->run( $argv );
  54. }
  55. }
  56. $maintClass = 'CheckLess';
  57. require_once RUN_MAINTENANCE_IF_MAIN;