AllTests.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * A test class for running all PHP_CodeSniffer unit tests.
  4. *
  5. * @author Greg Sherwood <gsherwood@squiz.net>
  6. * @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
  7. * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
  8. */
  9. namespace PHP_CodeSniffer\Tests;
  10. use PHPUnit\TextUI\TestRunner;
  11. if (is_file(__DIR__.'/../autoload.php') === true) {
  12. include_once 'Core/AllTests.php';
  13. include_once 'Standards/AllSniffs.php';
  14. } else {
  15. include_once 'CodeSniffer/Core/AllTests.php';
  16. include_once 'CodeSniffer/Standards/AllSniffs.php';
  17. }
  18. // PHPUnit 7 made the TestSuite run() method incompatible with
  19. // older PHPUnit versions due to return type hints, so maintain
  20. // two different suite objects.
  21. $phpunit7 = false;
  22. if (class_exists('\PHPUnit\Runner\Version') === true) {
  23. $version = \PHPUnit\Runner\Version::id();
  24. if ($version[0] === '7') {
  25. $phpunit7 = true;
  26. }
  27. }
  28. if ($phpunit7 === true) {
  29. include_once 'TestSuite7.php';
  30. } else {
  31. include_once 'TestSuite.php';
  32. }
  33. class PHP_CodeSniffer_AllTests
  34. {
  35. /**
  36. * Add all PHP_CodeSniffer test suites into a single test suite.
  37. *
  38. * @return \PHPUnit\Framework\TestSuite
  39. */
  40. public static function suite()
  41. {
  42. $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'] = [];
  43. $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'] = [];
  44. // Use a special PHP_CodeSniffer test suite so that we can
  45. // unset our autoload function after the run.
  46. $suite = new TestSuite('PHP CodeSniffer');
  47. $suite->addTest(Core\AllTests::suite());
  48. $suite->addTest(Standards\AllSniffs::suite());
  49. return $suite;
  50. }//end suite()
  51. }//end class