Skip to content

Commit

Permalink
Tests\Core\AllTests: simplify creation of the test suite
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jrfnl committed Mar 4, 2019
1 parent 23f3d94 commit 19d9eb9
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions tests/Core/AllTests.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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()
Expand Down

0 comments on commit 19d9eb9

Please sign in to comment.