From 7206279585651191eefe63ea1c8a58c6cef87382 Mon Sep 17 00:00:00 2001 From: jrfnl Date: Thu, 28 Feb 2019 06:41:32 +0100 Subject: [PATCH] Tests\Core\AllTests: simplify creation of the test suite As the refactor will add a lot of new unit test files, let's automate the creation of the test suite some more by automatically adding all Test files within the `Test\Core` directory. --- tests/Core/AllTests.php | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/Core/AllTests.php b/tests/Core/AllTests.php index 36a98a9ba7..d6587f076e 100644 --- a/tests/Core/AllTests.php +++ b/tests/Core/AllTests.php @@ -12,15 +12,7 @@ use PHPUnit\TextUI\TestRunner; use PHPUnit\Framework\TestSuite; -require_once 'IsCamelCapsTest.php'; -require_once 'ErrorSuppressionTest.php'; -require_once 'File/FindEndOfStatementTest.php'; -require_once 'File/FindExtendedClassNameTest.php'; -require_once 'File/FindImplementedInterfaceNamesTest.php'; -require_once 'File/GetMemberPropertiesTest.php'; -require_once 'File/GetMethodParametersTest.php'; -require_once 'File/GetMethodPropertiesTest.php'; -require_once 'File/IsReferenceTest.php'; +require_once dirname(dirname(__DIR__)).'/scripts/ValidatePEAR/FileList.php'; class AllTests { @@ -46,15 +38,23 @@ public static function main() public static function suite() { $suite = new TestSuite('PHP CodeSniffer Core'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\IsCamelCapsTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\ErrorSuppressionTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindEndOfStatementTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindExtendedClassNameTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\FindImplementedInterfaceNamesTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMemberPropertiesTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodParametersTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\GetMethodPropertiesTest'); - $suite->addTestSuite('PHP_CodeSniffer\Tests\Core\File\IsReferenceTest'); + + $testFileIterator = (new \FileList(__DIR__, '', '`Test\.php$`Di'))->getList(); + foreach ($testFileIterator as $file) { + if (strpos($file, 'AbstractMethodUnitTest.php') !== false) { + continue; + } + + include_once $file; + + $class = str_replace(__DIR__, '', $file); + $class = str_replace('.php', '', $class); + $class = str_replace('/', '\\', $class); + $class = 'PHP_CodeSniffer\Tests\Core'.$class; + + $suite->addTestSuite($class); + } + return $suite; }//end suite()